daily pastebin goal
63%
SHARE
TWEET

Gun Game ACS

ProfessorPants Jan 3rd, 2012 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #library "global"
  2. #include "zcommon.acs"
  3.  
  4. //Included for easy manipulation in case of conflicting script numbers.
  5. #define FIRST 701       //OPEN
  6. #define SECOND 702      //ENTER
  7. #define THIRD 703       //RESPAWN
  8. #define FOURTH 704      //(Melee).......Also referenced in keyconf.txt.
  9. #define FIFTH 705       //(Kill)
  10. #define SIXTH 706       //(Win)
  11. #define SEVENTH 707     //(Regen).......Also referenced in /actors/player.txt.
  12. #define EIGHTH 708      //DISCONNECT
  13. #define NINTH 709       //(Display killer info)
  14.  
  15. #define NUMOFGUNS 21 //This must be equal to the total number of elements in the GunList array.
  16. #define NUMOFOLDGUNS 12 //This must be equal to the total number of elements in the ClassicGunList array.
  17.  
  18. #define MAXNUMOFGUNS NUMOFGUNS+NUMOFOLDGUNS
  19.  
  20. //Element 0 will be given whenever the melee bind is used.
  21. str GunList[MAXNUMOFGUNS] =
  22. {
  23. "Kick",
  24. "Revolver",
  25. "DualPistols",
  26. "CoachGun",
  27. "WesternShotgun",
  28. "DukeShotgun",
  29. "AK47",
  30. "MachineGun",
  31. "Rifle",
  32. "M16",
  33. "G3",
  34. "MP40",
  35. "GatlingGun",
  36. "M60",
  37. "SniperRifle",
  38. "HeavyRifle",
  39. "Bazooka",
  40. "M79",
  41. "Flametosser",
  42. "SawThrower",
  43. "IronCrossbow",
  44. };
  45.  
  46. str ClassicGunList[MAXNUMOFGUNS] =
  47. {
  48. "Kick",
  49. "~Pistol",
  50. "~Shotgun",
  51. "~Chaingun",
  52. "~Supershotgun",
  53. "~Minigun",
  54. "~RocketLauncher",
  55. "~GrenadeLauncher",
  56. "~PlasmaRifle",
  57. "~Railgun",
  58. "~BFG9000",
  59. "~BFG10k",
  60. };
  61.  
  62. //----------------------DECLARING VARIABLES.
  63. int GunLevel[32];
  64.  
  65. //Variables used in the For loops which set up Classic and Random mode.
  66. int qwerty = 0;
  67. str asdf = "~Chainsaw";
  68. int randy = 0;
  69.  
  70. //Regeneration stuff.
  71. bool AlreadyRunning[32];
  72. bool InPain[32];
  73. int PainDelayCount[32];
  74.  
  75. bool GameOver = 0;
  76. //----------------------VARIABLES DECLARED.
  77.  
  78. function int Max (int a, int b)
  79. {
  80. if (a>b) {return a;}
  81. return b;
  82. }
  83.  
  84. Script FIRST OPEN //Activated on map load. (Setting up game modifiers.)
  85. {
  86. qwerty=NUMOFGUNS;
  87. if (GetCVar("Buckshot")==1)
  88. {
  89. Log(s:"Buckshot is enabled, running Classic mode.");
  90. For(qwerty=0; qwerty<NUMOFOLDGUNS; qwerty++)
  91. {
  92. GunList[qwerty]=ClassicGunList[qwerty];
  93. }
  94. }
  95. if (GetCVar("Instagib")==1)
  96. {
  97. Log(s:"Instagib is enabled, running Random mode.");
  98. For(qwerty=0; qwerty<NUMOFOLDGUNS-1; qwerty++)
  99. {
  100. GunList[qwerty+NUMOFGUNS]=ClassicGunList[qwerty+1];
  101. }
  102. For(qwerty=1; qwerty<MAXNUMOFGUNS-1; qwerty++)
  103. {
  104. asdf=GunList[qwerty]; //Store original weapon.
  105. randy=Random(1,MAXNUMOFGUNS-2); //Pick a random weapon.
  106. GunList[qwerty]=GunList[randy]; //Set original weapon to randomly chosen one.
  107. GunList[randy]=asdf; //Set randomly chosen weapon to original one.
  108. }
  109. }
  110. }
  111.  
  112. Script SECOND ENTER //Activated at spawn. (Setting up inventory.)
  113. {
  114. Delay(1); //Make sure the OPEN script is run first.
  115. if (GameOver==1) {SetPlayerProperty(1,1,4); SetPlayerProperty(1,1,5);} //Make sure the game isn't ending.
  116. Thing_ChangeTID(0,PlayerNumber()+1001);
  117. SetThingSpecial(0,ACS_ExecuteAlways,FIFTH,0,PlayerNumber()); //On death, run script FIFTH, but make the killer the activator.
  118. ClearInventory(); //So Buckshot and Instagib don't break everything.
  119. GiveInventory("AllKeys",1);
  120. if (GunLevel[PlayerNumber()]<1) {GunLevel[PlayerNumber()]=1;} //Prevent negative weapon level.
  121. GiveInventory(GunList[GunLevel[PlayerNumber()]],1); //Give whatever weapon they are up to.
  122. //Update ACS Mini-HUD.
  123. SetFont("BIGFONT");
  124. HUDMessage(s:"\cg",s:GunList[GunLevel[PlayerNumber()]],s:" (\cb",d:GunLevel[PlayerNumber()],s:"\cg/\cb",d:qwerty-1,s:"\cg)";
  125. HUDMSG_PLAIN,42,0,1.0,0.0,0);
  126. }
  127.  
  128. Script THIRD RESPAWN //Activated at respawn.
  129. {
  130. ACS_ExecuteAlways(SECOND,0); //Reset inventory again.
  131. }
  132.  
  133. Script FOURTH (void) net //Melee script.
  134. {
  135. if (GetActorProperty(0,APROP_Health)<=0 | GameOver==1) {Terminate;} //Make sure they're not dead and the game isn't ending.
  136. GiveInventory(GunList[0],1); SetWeapon(GunList[0]); //Give (and switch to) melee weapon.
  137. }
  138.  
  139. Script FIFTH (int victim) //Activated at death, with the killer as the activator. (Leveling up.)
  140. {
  141. GiveActorInventory(victim+1001,"HideHUD",1); //Hide the dead player's HUD.
  142. if (!(ClassifyActor(0) & ACTOR_PLAYER)) {GunLevel[victim]--; Terminate;} //If they died from a "world" event, decrease their weapon level and end script.
  143. if (PlayerNumber()==victim) {GunLevel[PlayerNumber()]--; Terminate;} //If they killed themself, decrease their weapon level and end script.
  144. if (CheckWeapon(GunList[0])==1) {GunLevel[victim]--; Terminate;} //If they used the melee weapon, lower the victim's weapon level and end script.
  145. if (GunLevel[PlayerNumber()]+1>=qwerty) {ACS_ExecuteAlways(SIXTH,0); Terminate;} //If they're up to the last weapon in the array, go directly to win script.
  146. ACS_ExecuteAlways(NINTH,0,PlayerNumber(),victim); //Display killer info to dead guy.
  147. //Everything checked out fine, level up.
  148. ClearInventory(); //Remove old weapon.
  149. GiveInventory("AllKeys",1);
  150. GunLevel[PlayerNumber()]++; //Increase weapon level.
  151. if (GetActorProperty(0,APROP_Health)<=0) {Terminate;} //Make sure they're alive.
  152. GiveInventory(GunList[GunLevel[PlayerNumber()]],1); //Give new weapon.
  153. //Update ACS Mini-HUD.
  154. SetFont("BIGFONT");
  155. HUDMessage(s:"\cg",s:GunList[GunLevel[PlayerNumber()]],s:" (\cb",d:GunLevel[PlayerNumber()],s:"\cg/\cb",d:qwerty-1,s:"\cg)";
  156. HUDMSG_PLAIN,42,0,1.0,0.0,0);
  157. }
  158.  
  159. Script SIXTH (void) //Activated on win. (Ending the level.)
  160. {
  161. if (GameOver==1) {Terminate;} //Prevent more than one player winning.
  162. GameOver=1;
  163. Log(n:0,s:"\cc won."); //Console message.
  164. SetFont("BIGFONT");
  165. HUDMessageBold(s:"\cg",n:0,s:"\cg wins!";HUDMSG_PLAIN,0,0,0.5,0.45,0); //Main HUD message.
  166. SetActivator(-1); //In case the script activator disconnects.
  167. SetPlayerProperty(1,1,4); //Freeze players.
  168. SetPlayerProperty(1,1,5); //Make players invulnerable.
  169. Delay(35*3);
  170. SetPlayerProperty(1,0,4); //Unfreeze players.
  171. SetPlayerProperty(1,0,5); //Make players vulnerable.
  172. Exit_Normal(0); //Exit map.
  173. }
  174.  
  175. Script SEVENTH (int HealDelay) //Activated when damage is inflicted. (Regen script.)
  176. {
  177. if (GetActorProperty(0,APROP_Health)>=100) {Terminate;} //Don't heal if they have over 100 health already.
  178. InPain[PlayerNumber()]=1; //Set pain variable for player.
  179. if (AlreadyRunning[PlayerNumber()]==1) {Terminate;} //Make sure they aren't already being healed.
  180. AlreadyRunning[PlayerNumber()]=1; //Declare that they are being healed.
  181. While (GetActorProperty(0,APROP_Health)<100 && GetActorProperty(0,APROP_Health)>0) //Regenerate only while their health is between 0 and 100.
  182. {
  183. if (InPain[PlayerNumber()]==1) //Take a pause if damage is inflicted while healing.
  184. {
  185. InPain[PlayerNumber()]=0; //Reset pain variable.
  186. For(PainDelayCount[PlayerNumber()]=1; PainDelayCount[PlayerNumber()]<35*HealDelay; PainDelayCount[PlayerNumber()]++) //Count to variable set in /actors/player.txt (in seconds.)
  187. {
  188. if (InPain[PlayerNumber()]==1) {InPain[PlayerNumber()]=0; PainDelayCount[PlayerNumber()]=1;} //If damage is inflicted during pause, restart counter.
  189. Delay(1);
  190. }
  191. }
  192. HealThing(1);
  193. Delay(2);
  194. }
  195. AlreadyRunning[PlayerNumber()]=0; //Full health reached, reset variable before ending script.
  196. }
  197.  
  198. Script EIGHTH (int quitter) DISCONNECT //Activated on disconnect/spectate. (Resetting variables.)
  199. {
  200. GunLevel[quitter]=0; //Reset gun level for new players.
  201. //Reset health regen variables.
  202. AlreadyRunning[quitter]=0;
  203. InPain[quitter]=0;
  204. PainDelayCount[quitter]=0;
  205. }
  206.  
  207. Script NINTH (int killer, int victim) //Display killer info to dead guy.
  208. {
  209. SetActivator(victim+1001);
  210. SetFont("BIGFONT");
  211. HUDMessage(s:"\ccKiller's Health: \cg",d:Max(GetActorProperty(killer+1001,APROP_Health),0);
  212. HUDMSG_FADEOUT,11,0,0.5,0.45,2.0,1.0);
  213. HUDMessage(s:"\ccKiller's Gun: \cg",s:GunList[GunLevel[killer]-1],s:" (\cb",d:GunLevel[killer]-1,s:"\cg/\cb",d:qwerty-1,s:"\cg)";
  214. HUDMSG_FADEOUT,328,0,0.5,0.50,2.0,1.0);
  215. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top