home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 58 / pcpp58b_TRIBES.iso / Tribes / base / scripts.vol / Training_AI.cs < prev    next >
Encoding:
Text File  |  1998-12-16  |  6.5 KB  |  243 lines

  1. // Training_AI.cs
  2. // This script defines all basic functionality for training 
  3. // missions AI, and more!
  4. ////////////////////////////////////////////////////////////
  5.  
  6. //Globals
  7. //////////////////////////
  8. $AI_Names[0] = "GotM*lk?";
  9. $AI_Names[1] = "Slacker";
  10. $AI_Names[2] = "Bob";
  11. $AI_Names[3] = "Cornboy!";
  12. $AI_Names[4] = "SymLink";
  13. $AI_Names[5] = "Skeet";
  14. $AI_Names[6] = "Jett";
  15. $AI_Names[7] = "Sne/\\keR";
  16. $AI_Names[8] = "DiamondBack";
  17. $AI_Names[9] = "Nailz";
  18. $AI_Names[10] = "Missing";
  19. $AI_Names[11] = "UberBob";
  20. $AI_Names[12] = "Ski to Die";
  21. $AI_Names[13] = "Sebirt";
  22. $AI_Names[14] = "Thulsa Doom";
  23. $AI_Names[15] = "MotoMan";
  24.  
  25. $AIkilled = 0;
  26. $MatchStartTime = getSimTime();
  27. $TrainMissionComplete = false;
  28.  
  29. //----------------------------------
  30. //Training::setupAI()
  31. //----------------------------------   
  32. function Training::setupAI(%clientId)
  33. {
  34.    %group = "MissionGroup\\AI";
  35.    %itemCount = Group::objectCount(%group);
  36.    $numGuards = %itemCount; 
  37.  
  38.    if( %group == -1 || %itemCount == 0 )
  39.       echo("No AI exists...");  
  40.        //what the hell?
  41.    else 
  42.    {  
  43.       for(%guard = 1; %guard <= %itemCount; %guard++)
  44.       {
  45.          %AIname = "guard" @ %guard;
  46.          $aiPathNum[%guard] = %AIname;
  47.          createAI(%AIname, %group @ "\\guard" @ %guard, larmor, $AI_Names[floor(getRandom() * 15)]);
  48.          %aiId = AI::getId( %AIname );
  49.          GameBase::setTeam(%aiId, 1);
  50.          AI::setVar( %AIname,  iq,  60 );
  51.          AI::setVar( %AIname,  attackMode, 0);
  52.          AI::DirectiveTarget(%AIname, %clientId);
  53.       }
  54.       AI::callWithId("*", Player::setItemCount, blaster, 1);
  55.       AI::callWithId("*", Player::mountItem, blaster, 0);
  56.       AI::SetVar( "*", triggerPct, 0.03 );
  57.    }
  58. }
  59.  
  60. //-----------------------------------------
  61. //ObjectiveMission::objectiveChanged()
  62. //-----------------------------------------
  63. function ObjectiveMission::objectiveChanged(%this, %taken)
  64. {
  65.    if(%this.trainingObjectiveComplete)
  66.    {
  67.       if($trainingType == 0)
  68.          TowersTraining::objectiveComplete(%this, %taken);
  69.       else if($trainingType == 1)
  70.          CTFTraining::objectiveComplete(%this);
  71.       else if($trainingType == 2)
  72.          RetrievalTraining::objectiveComplete(%this);
  73.       else
  74.          DestroyTraining::objectiveComplete(%this);  
  75.    }
  76. }
  77.  
  78. //-------------------------------------
  79. //Training::displayBitmap()
  80. //-------------------------------------
  81. function Training::displayBitmap(%line)
  82. {
  83.    %team = Client::getTeam(Client::getFirst());
  84.    
  85.    if($Train::missionType == "CTF") {
  86.       %bitmap1 = "capturetheflag_train1.bmp";
  87.       %bitmap2 = "capturetheflag_train2.bmp";
  88.    }
  89.    else if($Train::missionType == "C&H") {
  90.       %bitmap1 = "captureandhold_train1.bmp";
  91.       %bitmap2 = "captureandhold_train2.bmp";
  92.    }
  93.    else if($Train::missionType == "D&D") {
  94.       %bitmap1 = "defendanddest_train1.bmp";
  95.       %bitmap2 = "defendanddest_train2.bmp";
  96.    }
  97.    else if($Train::missionType == "F&R") {
  98.       %bitmap1 = "findandret_train1.bmp";
  99.       %bitmap2 = "findandret_train2.bmp";
  100.    }
  101.    else if($Train::missionType == "WELCOME") {
  102.       %bitmap1 = "intro_train1.bmp";
  103.       %bitmap2 = "intro_train2.bmp";
  104.    }
  105.    else if($Train::missionType == "VEHICLE") {
  106.       %bitmap1 = "vehicle_train1.bmp";
  107.       %bitmap2 = "vehicle_train2.bmp";
  108.    }
  109.    else if($Train::missionType == "COMMAND") {
  110.       %bitmap1 = "commander_train1.bmp";
  111.       %bitmap2 = "commander_train2.bmp";
  112.    }
  113.    else if($Train::missionType == "WEAPONS") {
  114.       %bitmap1 = "weapons_train1.bmp";
  115.       %bitmap2 = "weapons_train2.bmp";
  116.    }
  117.  
  118.    if(%bitmap1 == "" || %bitmap2 == "")
  119.    {
  120.       Team::setObjective(%team, %line, " ");
  121.       echo("no bitmap found");
  122.    }
  123.    else
  124.       Team::setObjective(%team, %line, "<jc><B0,0:" @ %bitmap1 @ "><B0,0:" @ %bitmap2 @ ">");
  125. }
  126.  
  127. //-----------------------------------
  128. //Game::pickRandomSpawn()
  129. //-----------------------------------
  130. function Game::pickRandomSpawn(%team)
  131. {
  132.    %group = nameToID("MissionGroup/Teams/team" @ %team @ "/DropPoints/Random");
  133.    %count = Group::objectCount(%group);
  134.    if(!%count)
  135.       return -1;
  136.  
  137.    %spawnIdx = floor(getRandom() * (%count - 0.1));
  138.    %value = %count;
  139.    for(%i = %spawnIdx; %i < %value; %i++) {
  140.       %set = newObject("set",SimSet);
  141.       %obj = Group::getObject(%group, %i);
  142.       if(containerBoxFillSet(%set,$SimPlayerObjectType|$VehicleObjectType,GameBase::getPosition(%obj),2,2,4,0) == 0) 
  143.          return %obj;
  144.       if(%i == %count - 1) {
  145.          %i = -1;
  146.          %value = %spawnIdx;
  147.       }
  148.       deleteObject(%set);
  149.    }
  150.    return false;
  151. }
  152.  
  153. //--------------------------------
  154. //TrainingEndGameCallback()
  155. //--------------------------------
  156. function TrainingEndGameCallback()
  157. {
  158.    if($Train::missionType == "WELCOME")
  159.       RestoreIcons();
  160.  
  161. //--------------------------------
  162. //RestoreIcons()
  163. //--------------------------------   
  164. function RestoreIcons()
  165. {
  166.    control::setVisible("healthHud", $AI_SaveHealth);
  167.    control::setVisible("jetPackHud", $AI_SaveJett);
  168.    control::setVisible("weaponHud", $AI_SaveWeapons);
  169.    control::setVisible("compassHud", $AI_SaveCompass);
  170.    control::setVisible("chatDisplayHud", $AI_SaveChat);
  171.    control::setVisible("sensorHUD", $AI_SavePing);
  172. }
  173.  
  174. //-------------------------------------
  175. //ObjectiveMission::refreshTeamScores()
  176. //-------------------------------------
  177. function ObjectiveMission::refreshTeamScores()
  178. {
  179.    //no scoring in training missions!
  180. }
  181.  
  182. //-------------------------------------
  183. //Game::refreshClientScore()
  184. //-------------------------------------
  185. function Game::refreshClientScore(%clientId)
  186. {
  187.    //no scoring in training missions!
  188. }
  189.  
  190. //------------------------------------
  191. //TowerSwitch::onDamage()
  192. //------------------------------------
  193. function TowerSwitch::onDamage()
  194. {
  195.    //tower switches can't take damage
  196. }
  197.  
  198. //---------------------------------
  199. //remoteSetTimeLimit()
  200. //--------------------------------
  201. function remoteSetTimeLimit(%client, %time)
  202. {
  203.    //start timer going up
  204. }
  205.  
  206. //-------------------------------------
  207. //AI::onDroneKilled()
  208. //-------------------------------------
  209. function AI::onDroneKilled(%aiName)
  210. {
  211.    $AIkilled++;
  212. }     
  213.  
  214. //these AI function callbacks can be very useful!
  215. function AI::onTargetLOSAcquired(%aiName, %idNum)
  216. {
  217. }
  218.  
  219. function AI::onTargetDied(%aiName, %idNum)
  220. {
  221. }                                 
  222.  
  223. function AI::onTargetLOSLost(%aiName, %idNum)
  224. {
  225. }
  226.  
  227. function AI::onTargetLOSRegained(%aiName, %idNum)
  228. {
  229. }
  230.  
  231. //do nothing functions
  232. function Mission::init()
  233. {
  234. }
  235.  
  236.  
  237.    
  238.  
  239.   
  240.  
  241.  
  242.