home *** CD-ROM | disk | FTP | other *** search
/ Hacker 9 / HACKER09.ISO / Games / StarSiege.exe / Starsiege / Missions.vol / CTF_Titanic_Assault.cs < prev    next >
Text File  |  1998-07-27  |  18KB  |  673 lines

  1. //
  2. // ctfStdLib.cs 
  3. //
  4. // Simple capture the flag routines
  5. //
  6.  
  7. $maxFlagCount = 5;           // no of flags required by a team to end the game
  8. $flagValue    = 25;          // points your team gets for capturing
  9. $carrierValue =  5;          //  "      "    "    "    " killing carrier
  10.  
  11. $ctfWon = 0;
  12.  
  13. //--------------------------------------------------------------------------------
  14.  
  15. function setDefaultMissionOptions()
  16. {
  17.    $server::TeamPlay = true;
  18.    $server::AllowDeathmatch = false;
  19.    $server::AllowTeamPlay = true;    
  20. }
  21.  
  22.  
  23. //--------------------------------------------------------------------------------
  24.  
  25. function onMissionStart()
  26. {
  27.     initGlobalVars();
  28. }
  29.  
  30. function player::onAdd(%this)
  31. {
  32.    chat(%this, 0, strcat("Welcome to CTF, ", getName(%this), ". Here are the rules:"));
  33.    chat(%this, 0, "- Your flag must be at home for a capture!");
  34.    chat(%this, 0, strcat("- Captures are worth ", $flagValue, " points"));
  35.    chat(%this, 0, strcat("- Flag carriers are worth ", $carrierValue, " points"));
  36.    chat(%this, 0, strcat("- Generic kills are worth ZERO points"));
  37.    chat(%this, 0, strcat("- First team to get ", $maxFlagCount, " flags wins."));
  38.  
  39.    %color    = teamToColor(getTeam(%this));
  40.    %colorKey = strcat(%color, "FlagCarried");
  41.    %teamPlayerCount = getTeamPlayerCount(getTeam(%this));
  42.  
  43.    // if no one has players flag, and they are the only player of that color
  44.    // setFlag to true   
  45.    if(!dataRetrieve(0,%colorKey) && %teamPlayerCount <= 1)
  46.    {
  47.            setFlag(%color, true );
  48.    }
  49. }
  50.  
  51. //--------------------------------------------------------------------------------
  52. function player::onRemove(%this)
  53. {
  54.     %teamPlayerCount = getTeamPlayerCount(getTeam(%this));
  55.        if(%teamPlayerCount <= 1)
  56.     {
  57.         %color = teamToColor(getTeam(%this));
  58.         setFlag(%color, false);                    
  59.     }
  60. }
  61.  
  62.  
  63. //--------------------------------------------------------------------------------
  64. function vehicle::onAdd(%this)
  65. {
  66.     %color = teamToColor(getTeam(%this));
  67.     %flagKey = strcat(%color, "FlagCount");
  68.  
  69.     // if the flag isn't at the base, but no one has it, correct situation
  70.     if(dataRetrieve(0, %flagKey) && !dataRetrieve(0, strcat(%color, "FlagCarried")))
  71.     {
  72.         setFlag(%color, true);
  73.     }
  74. }
  75.  
  76. //--------------------------------------------------------------------------------
  77. function vehicle::onDestroyed(%destroyed,%destroyer)
  78. {
  79.    // if the destroyed vehicle has a flag, it goes back to it's base
  80.    %color = dataRetrieve(%destroyed, "hasFlag");
  81.    if (%color != "") {
  82.       playerDropsFlag(%destroyed);
  83.       // let everyone know this guy drops the flag
  84.       wallDim(strcat(getName(%destroyed), " surrenders the ", %color, " flag"));
  85.  
  86.       // destroyer's team gets credit for killing the carrier
  87.       %key = strcat(getTeam(%destroyer), "CarriersKilled");
  88.       dataStore(0, %key, 1 + dataRetrieve(0, %key));
  89.    }
  90. }
  91.  
  92. //--------------------------------------------------------------------------------
  93. function setFlag(%color, %bool)
  94. {
  95.     %flagCountKey = strcat(%color, "FlagCount");
  96.     
  97.     // set flag to visible
  98.     if(%bool)
  99.     {
  100.            dataStore(0, %flagCountKey, 0);    
  101.            setShapeVisibility(getObjectId(strcat("MissionGroup\\Scenario\\", %color, "Base\\", %color, "Flag")), true);                
  102.     }
  103.     
  104.     // set flag to non-visible
  105.     else
  106.     {
  107.  
  108.         dataStore(0, %flagCountKey, 1);
  109.         setShapeVisibility(getObjectId(strcat("MissionGroup\\Scenario\\", %color, "Base\\", %color, "Flag")),false);    
  110.     }
  111. }
  112.  
  113. function playerDropsFlag(%vehicle)
  114. {
  115.     // figure out which color of flag the guy is carrying
  116.    %color = dataRetrieve(%vehicle, "hasFlag");
  117.    // the player is no longer carrying this or any flag
  118.    dataRelease(%vehicle, "hasFlag");
  119.    setVehicleSpecialIdentity(%vehicle, false);
  120.    dataStore(0, strcat(%color, "FlagCarried"), 0);
  121.    
  122.    %teamPlayerCount = getTeamPlayerCount(colorToTeam(%color));
  123.    if(%teamPlayerCount < 1)
  124.    {
  125.           setFlag(%color, false);    
  126.    }    
  127.    else
  128.    {    
  129.            setFlag(%color, true);   
  130.    }   
  131. }
  132.  
  133.  
  134. //--------------------------------------------------------------------------------
  135.  
  136. function checkFlagRetrieved(%atColor, %vehicle)
  137. {
  138.    // is the game over already?
  139.    if ($ctfWon != 0) 
  140.       { return; }
  141.  
  142.    // you made it back to your own base, do you have any other teams' flags?
  143.    if (dataRetrieve(%vehicle, "hasFlag") == "") 
  144.       { return; }
  145.  
  146.    // is the player's team flag at his base when he brings back the enemy's flag?
  147.    if (dataRetrieve(0, strcat(%atColor, "FlagCount")) != 0) 
  148.       { return; }
  149.  
  150.    // player is no longer carrying the flag
  151.    %hasColor = dataRetrieve(%vehicle, "hasFlag");
  152.    playerDropsFlag(%vehicle);
  153.  
  154.    // player's team gets credit for stealing the flag
  155.    %collectedKey = strcat(getTeam(%vehicle), "FlagsCollected");
  156.    %collectedCount = dataRetrieve(0, %collectedKey);
  157.    %collectedCount = %collectedCount + 1;
  158.    dataStore(0, %collectedKey, %collectedCount);
  159.  
  160.    // let everyone know what happened
  161.    %needMore = $maxFlagCount - %collectedCount;
  162.    if (%needMore == 0) {
  163.       wallDim(strcat(getName(%vehicle), " captured the ", %hasColor, " flag!"));
  164.       $ctfWon = 1;
  165.       schedule("missionEndConditionMet();", 5.0);
  166.       winEvent(getTeam(%vehicle));
  167.       playerDropsFlag(%vehicle);
  168.    }
  169.    else {
  170.       wallDim(strcat(getName(%vehicle), " captured the ", %hasColor, " flag! ", getTeam(%vehicle), " needs ", %needMore, " more to win"));
  171.    }
  172. }
  173.  
  174. //--------------------------------------------------------------------------------
  175. function initGlobalVars()
  176. {
  177.     dataStore(0, "BlueFlagsCollected", 0);
  178.     dataStore(0, "RedFlagsCollected", 0);
  179.     dataStore(0, "YellowFlagsCollected", 0);
  180.     dataStore(0, "PurpleFlagsCollected", 0);
  181.  
  182.     dataStore(0, "blueFlagCount", 1);
  183.     dataStore(0, "redFlagCount", 1);
  184.     dataStore(0, "yellowFlagCount", 1);
  185.     dataStore(0, "purpleFlagCount", 1);
  186.  
  187.     dataStore(0, "yellowFlagCarried", 0);
  188.     dataStore(0, "blueFlagCarried", 0);
  189.     dataStore(0, "redFlagCarried", 0);
  190.     dataStore(0, "purpleFlagCarried", 0);
  191.  
  192.       setShapeVisibility(getObjectId("MissionGroup\\Scenario\\yellowBase\\yellowFlag"), false);
  193.       setShapeVisibility(getObjectId("MissionGroup\\Scenario\\blueBase\\blueFlag"), false);
  194.       setShapeVisibility(getObjectId("MissionGroup\\Scenario\\redBase\\redFlag"), false);
  195.       setShapeVisibility(getObjectId("MissionGroup\\Scenario\\purpleBase\\purpleFlag"), false);
  196. }
  197.  
  198. function winEvent(%Team)
  199. {
  200.     %r = %g = %b = 0;
  201.  
  202.     if(%Team == Yellow)
  203.     {
  204.         %r = %g = 0.5;
  205.     }
  206.     
  207.     if(%Team == Blue)
  208.     {
  209.         %b = 0.5;
  210.     }
  211.     
  212.     if(%Team == Red)
  213.     {
  214.         %r = 0.5;
  215.     }
  216.     
  217.     if(%Team == Purple)
  218.     {
  219.         %r = 0.345;
  220.         %g = 0.1254;
  221.         %b = 0.254;
  222.     }
  223.  
  224.     %count = playerManager::getPlayerCount();
  225.     for(%i = 0; %i < %count; %i = %i +1)
  226.     {
  227.         %curPlayerNum = playerManager::getPlayerNum(%i);
  228.         messageBox(%curPlayerNum, strcat("GAME OVER! \n", %Team, " won the game!"));
  229.         fadeEvent(%curPlayerNum, out, 6.0, %r, %g, %b);
  230.     }
  231. }
  232.  
  233.  
  234. function checkFlagStolen(%color, %vehicle)
  235. {
  236.    // is the game over already?
  237.    if ($ctfWon != 0)
  238.       { return; }
  239.           
  240.    // you just hit the trigger at an enemy base, is there a flag here?
  241.    %flagCountKey = strcat(%color, "FlagCount");
  242.    %flagCount = dataRetrieve(0, %flagCountKey);
  243.    
  244.    if (%flagCount != 0 || dataRetrieve(%vehicle, "hasFlag") != "") 
  245.    { return; }
  246.  
  247.    if (getVehicleName(%vehicle) == "none")
  248.       { return; }
  249.  
  250.    // stop the flag shape from rendering
  251.    setShapeVisibility(getObjectId(strcat("MissionGroup\\Scenario\\", %color, "Base\\", %color, "Flag")), false);
  252.  
  253.    // setup the vehicle to carry the flag
  254.    setVehicleSpecialIdentity(%vehicle, true, %color);
  255.    dataStore(%vehicle, "hasFlag", %color);
  256.  
  257.    // increment flag count so nobody else can pickup this flag
  258.    dataStore(0, %flagCountKey, 1);
  259.  
  260.    // set global bool for flag of that color
  261.    dataStore(0, strcat(%color, "FlagCarried"), 1); 
  262.  
  263.    // let everyone know what happened
  264.    wallDim(strcat(getName(%vehicle), " STOLE the ", %color, " flag"));
  265. }
  266.  
  267. //-------------------------------------------------------------------------------
  268. function colorToTeam(%color)
  269. {
  270.     if(%color == "yellow")
  271.     { return "Yellow";}
  272.     if(%color == "blue")
  273.     {return "Blue";}
  274.     if(%color == "red")
  275.     {return "Red";}
  276.     if(%color == "purple")
  277.     {return "Purple";}
  278.  
  279.     return 0;
  280. }
  281. function teamToColor(%team)
  282. {
  283.     if(%team == "Yellow")
  284.     {return "yellow";}
  285.     if(%team == "Blue")
  286.     {return "blue";}
  287.     if(%team == "Red")
  288.     {return "red";}
  289.     if(%team == "Purple")
  290.     {return "purple";}
  291.  
  292.     return 0;
  293. }   
  294.  
  295. //--------------------------------------------------------------------------------
  296. function getTeamPlayerCount(%team)
  297. {
  298.     %count = playerManager::getPlayerCount();
  299.     %teamPlayerCount = 0;
  300.  
  301.     for(%i = 0; %i < %count; %i = %i + 1 )
  302.     {
  303.         %curPlayerNum = playerManager::getPlayerNum(%i);
  304.         if(getTeam(%curPlayerNum) == %team)
  305.         {
  306.             %teamPlayerCount = %teamPlayerCount + 1;
  307.         }    
  308.     }
  309.     return %teamPlayerCount;        
  310. }
  311.  
  312. //--------------------------------------------------------------------------------
  313. function initFlagTrigger(%name, %color)
  314. {
  315.    %flagCountKey = strcat(%color, "FlagCount");
  316.    dataStore(0, %flagCountKey, 1);
  317.    %flagsCollectedKey = strcat(%name, "FlagsCollected");
  318.    dataStore(0, %flagsCollected, 0);
  319.    %carriersKilledKey = strcat(%name, "CarriersKilled");
  320.    dataStore(0, %carriersKilledKey, 0);
  321. }
  322.  
  323. //--------------------------------------------------------------------------------
  324. function flagTriggerOnEnter(%colorName, %color, %object)
  325. {
  326.    %flagKey = strcat(%color, "FlagCount");
  327.    %teamPlayerCount = getTeamPlayerCount(%colorName);
  328.  
  329.    //echo(%colorName, " playerCount = ", %teamPlayerCount, " ", %flagKey, " = ", dataRetrieve(0, %flagKey) );
  330.    
  331.    if(%teamPlayerCount < 1 && dataRetrieve(0, %flagKey) != 1)
  332.    {
  333.            %flagKey = strcat(%color, "FlagCount");
  334.            dataStore(0, %flagKey, 1);
  335.         setShapeVisibility(getObjectId(strcat("MissionGroup\\Scenario\\", %color, "Base\\", %color, "Flag")),false);                    
  336.            wallDim(strcat("The ", %color, " flag vanishes!"));
  337.    }
  338.  
  339.    if (getTeam(%object) != %colorName) {
  340.       checkFlagStolen(%color, %object);
  341.    }
  342.    else {
  343.       checkFlagRetrieved(%color, %object);          
  344.    }
  345. }
  346.  
  347. //--------------------------------------------------------------------------------
  348.  
  349. //--------------------------------------------------------------------------------
  350.  
  351. // Team color specific code
  352.  
  353. // Yellow
  354. function yellowFlagTrigger::trigger::onAdd(%this)
  355. {
  356.    initFlagTrigger("Yellow", "yellow");
  357. }
  358. function yellowFlagTrigger::trigger::onEnter(%this, %object)
  359. {
  360.    flagTriggerOnEnter("Yellow", "yellow", %object);
  361. }
  362.  
  363. // Blue
  364. function blueFlagTrigger::trigger::onAdd(%this)
  365. {
  366.    initFlagTrigger("Blue", "blue");
  367. }
  368. function blueFlagTrigger::trigger::onEnter(%this, %object)
  369. {
  370.    flagTriggerOnEnter("Blue", "blue", %object);
  371. }
  372.  
  373. // Red
  374. function redFlagTrigger::trigger::onAdd(%this)
  375. {
  376.    initFlagTrigger("Red", "red");
  377. }
  378. function redFlagTrigger::trigger::onEnter(%this, %object)
  379. {
  380.    flagTriggerOnEnter("Red", "red", %object);
  381. }
  382.  
  383. // Purple
  384. function purpleFlagTrigger::trigger::onAdd(%this)
  385. {
  386.    initFlagTrigger("Purple", "purple");
  387. }
  388. function purpleFlagTrigger::trigger::onEnter(%this, %object)
  389. {
  390.    flagTriggerOnEnter("Purple", "purple", %object);
  391. }
  392.  
  393. //--------------------------------------------------------------------------------
  394.  
  395. //--------------------------------------------------------------------------------
  396.  
  397. // Scoreboard code
  398.  
  399. function getTeamCarriersKilled(%a)
  400. {
  401.    %key = strcat(getTeamNameFromTeamId(%a), "CarriersKilled");
  402.    return dataRetrieve(0, %key);
  403. }
  404.  
  405. function getPlayerCarriersKilled(%a)
  406. {
  407.    %key = strcat(getTeam(%a), "CarriersKilled");
  408.    return dataRetrieve(0, %key);
  409. }
  410.  
  411. function getTeamFlags(%a)
  412. {
  413.    %collectedKey = strcat(getTeamNameFromTeamId(%a), "FlagsCollected");
  414.    %flags = dataRetrieve(0, %collectedKey);
  415.    if (%flags == "") {
  416.       return 0;
  417.    }
  418.    else {
  419.       return %flags;
  420.    }
  421. }
  422.  
  423. function getPlayerFlags(%a)
  424. {
  425.    %collectedKey = strcat(getTeam(%a), "FlagsCollected");
  426.    %flags = dataRetrieve(0, %collectedKey);
  427.    if (%flags == "") {
  428.       return 0;
  429.    }
  430.    else {
  431.       return %flags;
  432.    }
  433. }   
  434.  
  435. function getPlayerScore(%a)
  436. {
  437.    return(getPlayerFlags(%a) * $flagValue + getPlayerCarriersKilled(%a) * $carrierValue);
  438. }
  439.  
  440. function getTeamScore(%a)
  441. {
  442.    return(getTeamFlags(%a) * $flagValue + getTeamCarriersKilled(%a) * $carrierValue);
  443. }
  444.  
  445. function initScoreBoard()
  446. {
  447.    deleteVariables("$ScoreBoard::PlayerColumn*");
  448.    deleteVariables("$ScoreBoard::TeamColumn*");
  449.  
  450.    // Player ScoreBoard column headings
  451.    $ScoreBoard::PlayerColumnHeader1 = "TEAM";
  452.    $ScoreBoard::PlayerColumnHeader2 = "FLAGS";
  453.    $ScoreBoard::PlayerColumnHeader3 = "SCORE";
  454.    $ScoreBoard::PlayerColumnHeader4 = "CARRIER KILLS";
  455.    $ScoreBoard::PlayerColumnHeader5 = "PING";
  456.  
  457.    // Player ScoreBoard column functions
  458.    $ScoreBoard::PlayerColumnFunction1 = "getTeam";
  459.    $ScoreBoard::PlayerColumnFunction2 = "getPlayerFlags";
  460.    $ScoreBoard::PlayerColumnFunction3 = "getPlayerScore";
  461.    $ScoreBoard::PlayerColumnFunction4 = "getPlayerCarriersKilled";
  462.    $ScoreBoard::PlayerColumnFunction5 = "getPing";
  463.  
  464.  
  465.    //Team ScoreBoard column headings
  466.    $ScoreBoard::TeamColumnHeader1 = "FLAGS";
  467.    $ScoreBoard::TeamColumnHeader2 = "SCORE";
  468.    $ScoreBoard::TeamColumnHeader3 = "CARRIERS KILLED";
  469.  
  470.   
  471.    // Team ScoreBoard column functions
  472.    $ScoreBoard::TeamColumnFunction1 = "getTeamFlags";
  473.    $ScoreBoard::TeamColumnFunction2 = "getTeamScore";
  474.    $ScoreBoard::TeamColumnFunction3 = "getTeamCarriersKilled";
  475.  
  476.    // tell server to process all the scoreboard definitions defined above
  477.    serverInitScoreBoard();
  478. }
  479.  
  480. //--------------------------------------------------------------------------------
  481.  
  482. //--easter code
  483.  
  484. function vanishTrigger1::trigger::onAdd(%this)
  485. {
  486.     dataStore(%this, "isActive", true); // bool for trigger active
  487.  
  488. }
  489.  
  490. function vanishTrigger1::trigger::onEnter(%this, %object)
  491. {
  492.     triggerOnEnter(1, %object);    
  493. }
  494.  
  495.  
  496. function vanishTrigger2::trigger::onAdd(%this)
  497. {
  498.     dataStore(%this, "isActive", false); // bool for trigger active
  499.       
  500. }
  501.  
  502. function vanishTrigger2::trigger::onEnter(%this, %object)
  503. {
  504.     triggerOnEnter(2, %object);    
  505. }
  506.  
  507.  
  508. function vanishTrigger3::trigger::onAdd(%this, %object)
  509. {
  510.     dataStore(%this, "isActive", false); // bool for trigger active
  511.         
  512. }
  513.  
  514.  
  515. function vanishTrigger3::trigger::onEnter(%this, %object)
  516. {
  517.     triggerOnEnter(3, %object);    
  518. }
  519.  
  520. function teleportTrigger::trigger::onAdd(%this)
  521. {
  522.     dataStore(%this, "isActive", false); // bool for trigger active
  523.     
  524. }
  525.  
  526.  
  527. function teleportTrigger::trigger::onEnter(%this, %object)
  528. {
  529.     triggerOnEnter(teleport, %object);    
  530. }
  531.  
  532.  
  533. function triggerOnEnter(%index, %object)
  534. {
  535.     %thisTrigger = "";
  536.     %nextTrigger = "";
  537.     %chatMsg = "";
  538.     
  539.     if(%index == 1)
  540.     {
  541.         %thisTrigger = getObjectId("MissionGroup\\extra\\vanishTrigger1");
  542.         %nextTrigger = getObjectId("MissionGroup\\extra\\vanishTrigger2");
  543.         %thisFlag =       getObjectId("MissionGroup\\extra\\flag1");
  544.         %nextFlag =    getObjectId("MissionGroup\\extra\\flag2");
  545.         %chatMsg  = "Trigger 2 activated.";                  
  546.     }
  547.  
  548.     if(%index == 2)
  549.     {
  550.         %thisTrigger = getObjectId("MissionGroup\\extra\\vanishTrigger2");
  551.         %nextTrigger = getObjectId("MissionGroup\\extra\\vanishTrigger3");
  552.         %thisFlag =       getObjectId("MissionGroup\\extra\\flag2");
  553.         %nextFlag =    getObjectId("MissionGroup\\extra\\flag3");
  554.         %chatMsg = "Trigger 3 activated.";    
  555.     }
  556.  
  557.     if(%index == 3)
  558.     {
  559.         %thisTrigger = getObjectId("MissionGroup\\extra\\vanishTrigger3");
  560.         %nextTrigger = getObjectId("MissionGroup\\extra\\teleportTrigger");
  561.         %thisFlag =       getObjectId("MissionGroup\\extra\\flag3");
  562.         %nextFlag =    getObjectId("MissionGroup\\extra\\teleport");
  563.         %chatMsg = "Teleportation device online.";     
  564.     }
  565.  
  566.     if(%index == teleport)
  567.     {
  568.         %thisTrigger = getObjectId("MissionGroup\\extra\\teleportTrigger");
  569.         %nextTrigger = getObjectId("MissionGroup\\extra\\vanishTrigger1");
  570.         %thisFlag =       getObjectId("MissionGroup\\extra\\teleport");
  571.         %nextFlag =    getObjectId("MissionGroup\\extra\\flag1");
  572.         %chatMsg = "Teleportation Device is inoperable.";    
  573.     }
  574.     
  575.     if(%thisTrigger == "" || %nextTrigger == "")
  576.     {
  577.         echo("bad triggerIds!");
  578.         return;
  579.     }
  580.     
  581.     %isActive = dataRetrieve(%thisTrigger, "isActive");
  582.  
  583.     if(%isActive != false)
  584.     {
  585.         dataStore(%thisTrigger, "isActive", false);
  586.         dataStore(%nextTrigger, "isActive", true);
  587.         
  588.         if(%index != 3)
  589.         {
  590.             setShapeVisibility(%nextFlag, true);
  591.         }
  592.                 
  593.         if(%index == teleport)
  594.         {
  595.             %malfunctionChance = randomFloat(0.0,0.1);
  596.             if(%malfunctionChance > randomFloat(0.0,1.0))
  597.             {
  598.                 malfunction(%object);
  599.             }
  600.             else
  601.             {
  602.                 teleport(%object);
  603.             }
  604.         }
  605.         else
  606.         {
  607.             setShapeVisibility(%thisFlag, false);
  608.             chat(%object, 0, %chatMsg);    
  609.         }                    
  610.     }
  611.     else if(%index == teleport)
  612.     {
  613.         chat(%object, 0, %chatMsg);
  614.     }    
  615. }
  616.  
  617. function teleport(%object)
  618. {
  619.     %flagNum = randomInt(1,4);
  620.     %x = %y = %z = 0;
  621.  
  622.     if(%flagNum == 1)
  623.     {
  624.         %x = (0 - 6222.650);
  625.         %y = 2927.654;
  626.         %z = 68.975;
  627.     }
  628.  
  629.     if(%flagNum == 2)
  630.     {
  631.         %x = (0 - 4844.965);
  632.         %y = 1628.186;
  633.         %z = 48.300;
  634.     }
  635.  
  636.     if(%flagNum == 3)
  637.     {
  638.         %x = (0 - 5040.110);
  639.         %y = 3794.496;
  640.         %z = 44.725;
  641.     }
  642.  
  643.     if(%flagNum == 4)
  644.     {
  645.         %x = (0 - 4400.192);
  646.         %y = 2736.57;
  647.         %z = 77.488;
  648.     }
  649.     
  650.     %playerNum = playerManager::vehicleIdToPlayerNum(%object);
  651.     
  652.     //echo("flagNum = ", %flagNum);
  653.     //echo("x = ", %x, " y = ", %y, " z = ", %z);
  654.  
  655.     chat(%object, 0, "Teleportation initiated.");
  656.     healObject(%object, 600.0);
  657.     reloadObject(%object, 60.0);
  658.     fadeEvent(%playerNum, out, 2.0, 1.0, 1.0, 1.0);
  659.     schedule(strcat("setPosition(", %object, ",", %x,",", %y,",", %z,");"), 2.0);
  660.     schedule(strcat("fadeEvent(", %playerNum, ",in, 2.0, 1.0, 1.0, 1.0);"), 2.1);
  661.     schedule(strcat("chat(", %object,", 0, \"Teleportation complete.\");"), 2.5);
  662. }
  663.  
  664.  
  665. function malfunction(%object)
  666. {
  667.     chat(%object, 0, "Teleportation initiated.");
  668.     %playerNum = playerManager::vehicleIdToPlayerNum(%object);
  669.     fadeEvent(%playerNum, out, 2.5, 0.5,0.0,0.0);
  670.     schedule(strcat("chat(", %object, ", 0, \"Teleportation malfunction!\");"),1.8);
  671.     schedule(strcat("fadeEvent(", %playerNum, ", in, 1.5, 0.5,0.0,0.0);"), 2.5);
  672.     schedule(strcat("damageObject(", %object, ", 10000);"), 2.5);        
  673. }