Advertisement
skroton

SSP acs

Jun 1st, 2016
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.52 KB | None | 0 0
  1. #library "opppacs"
  2. #include "zcommon.acs"
  3.  
  4. #libdefine OPPP_spawn   860 /* item spawning script */
  5. #libdefine OPPP_pickup  861 /* pickup script */
  6. #libdefine OPPP_vis     862 /* clientside script to make pickup visible or invisible */
  7.  
  8. /* string array of all classes for spawning */
  9. str pickup_class[40] = { "Backpack_Pickup",   "Cell_Pickup",       "CellPack_Pickup", "Clip_Pickup",        "ClipBox_Pickup",        "RocketAmmo_Pickup", "RocketBox_Pickup",    "Shell_Pickup",      "ShellBox_Pickup",    "BFG9000_Pickup",
  10.                          "Chaingun_Pickup",   "Chainsaw_Pickup",   "Pistol_Pickup",   "PlasmaRifle_Pickup", "RocketLauncher_Pickup", "Shotgun_Pickup",    "SuperShotgun_Pickup", "Berserk_Pickup",    "HealthBonus_Pickup", "Medikit_Pickup",
  11.                          "Megasphere_Pickup", "Soulsphere_Pickup", "Stimpack_Pickup", "ArmorBonus_Pickup",  "BlueArmor_Pickup",      "GreenArmor_Pickup", "Allmap_Pickup",       "BlurSphere_Pickup", "Infrared_Pickup",    "InvulnerabilitySphere_Pickup",
  12.                          "RadSuit_Pickup",    "NULL",              "NULL",            "NULL",               "NULL",                  "NULL",              "NULL",                "NULL",              "NULL",               "NULL"                          };
  13.  
  14. /* string array of suffixes for classes for spawning */
  15. str pickup_num[64] = { "_00", "_01", "_02", "_03", "_04", "_05", "_06", "_07", "_08", "_09",
  16.                        "_10", "_11", "_12", "_13", "_14", "_15", "_16", "_17", "_18", "_19",
  17.                        "_20", "_21", "_22", "_23", "_24", "_25", "_26", "_27", "_28", "_29",
  18.                        "_30", "_31", "_32", "_33", "_34", "_35", "_36", "_37", "_38", "_39",
  19.                        "_40", "_41", "_42", "_43", "_44", "_45", "_46", "_47", "_48", "_49",
  20.                        "_50", "_51", "_52", "_53", "_54", "_55", "_56", "_57", "_58", "_59",
  21.                        "_60", "_61", "_62", "_63" };
  22.                        
  23.  
  24. script OPPP_spawn (int class) /* class of item to spawn */
  25. {
  26.   int var, tid, i; /* user array, unique tid, loop variable */
  27.   int a_x, a_y, a_z; /* activator x, y, and z position */
  28.   str con_class; /* constructed class to spawn */
  29.  
  30.   a_x = GetActorX(0); /* get activator x position */
  31.   a_y = GetActorY(0); /* get activator z position */
  32.   a_z = GetActorZ(0); /* get activator x position */
  33.  
  34.   for(i = 0; i < 64; ++i){ /* for all player numbers, 0 - 63 */
  35.     if(PlayerInGame(i) && /* if player i is in game AND */
  36.      !GetUserArray(0, "user_player", i)){ /* spawner has NOT already spawned item for player i */
  37.       tid = UniqueTID(); /* get a new unique tid */
  38.       con_class = strparam(s:pickup_class[class], s:pickup_num[i]); /* construct class to spawn */
  39.       /* spawn an actor of the specified class at the activator position with new tid */
  40.       SpawnForced(con_class, a_x, a_y, a_z, tid);
  41.       SetUserArray(0, "user_player", i, 1); }} /* mark in activator user array that item has been spawned for i player */
  42.       /* log(s:"class: ", s:con_class, s:" array value: ", i:GetUserArray(0, "user_player", i)); */
  43. }
  44.  
  45. /* script to determine whether item will be picked up */
  46. script OPPP_pickup (int player) /* the player that pick up is intended for, passed to script */
  47. {
  48.   int player_num, result; /*  the player number of player trying to pick up item, result variable */
  49.   result = 0; /* this should already be 0, but who the fuck knows */
  50.   player_num = PlayerNumber(); /* get  the number of the activating player */
  51.   /* log(s:"player: ", i:player, s:" player_num: ", i:player_num); /* debug log */
  52.   if(player_num == player){ /* if the player number matches the intended player pickup, sent via decorate */
  53.     result = 1; }/* set result to one */
  54.   SetResultValue(result); /* return result */
  55. }
  56.  
  57. script OPPP_vis (void) CLIENTSIDE
  58. {
  59.   int player_con, damage; /*  the number of the local player, the damage property being hackily used as player number arg */
  60.   player_con = ConsolePlayerNumber(); /* get  the number of the local player */
  61.   damage = GetActorProperty(0, APROP_Damage); /* get the damage property being hackily used as player number arg */
  62.   /* log(s:"damage: ", i:damage, s:" player_con: ", i:player_con); */
  63.  
  64.   if(player_con > -1){ /* make sure this is not being executed on the server */
  65.     if(player_con == damage){ /* if the player number arg is the same as local player number */
  66.       SetActorState(0,"CanSee"); /* set the actor to the visible state */
  67.       terminate; }} /* terminate the script */
  68.    SetActorState(0,"NoSee"); /* otherwise (default) set the actor to the invisible state */
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement