SHARE
TWEET

doing things with a projectile for anon

skroton Jun 12th, 2016 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* can't currently test, so may be typos you will have to fix for it it compile */
  2.  
  3. ////////////////////////////////////////////////////////
  4. // First version, assumes you have already defined a new player class that you're using
  5. ////////////////////////////////////////////////////////
  6.  
  7. /* place the following into the player class decorate definition, not the weapon definition, in the same space as properties and actor flags */
  8.  
  9. var int user_proj_tid; /* or whatever name you want use */
  10.  
  11. /* the acs */
  12.  
  13. /* if you're wanting current zandro compatibility, set this to a number or use decorate and acs constants (http://zdoom.org/wiki/Constants) to make it easier to read, if you do that remember to remove quotes from script names as they are no longer strings */
  14. script "set_tid" (void) /* this is the script that you set the result value as the tid and use in a_spawnitemex */
  15. {
  16.   int p_tid; /* this will be used to store the tid we use for the new projectile */
  17.   p_tid = UniqueTID; /* grab a unique tid and set p_tid to it */
  18.   SetUserVariable(0, "user_proj_tid", p_tid); /* set the player's user variable to the new tid, so we can recall it later */
  19.   SetResultValue(p_tid); /* set p_tid as result value so it gets assigned to the projectile spawned by a_spawnitemex */
  20. }
  21.  
  22. /* now this you call from a single line, a 0 duration frame like a "TNT1 A 0", directly after the a_spawnitemex where you used the "set_tid" script */
  23.  
  24. script "proj_assign" (void) /* since this is called from the weapon, the activator is the player */
  25. {
  26.   int p_tid; /* the projectile's tid */
  27.   p_tid = GetUserVariable(0 "user_proj_tid"); /* grab the tid of the projectile, stored in the player's user variable "user_proj_tid" */
  28.   /* now do the things you want to do in the script, using tid of "0" to refer to player (since the player activated the script), and tid of "p_tid" to refer to the projectile */
  29.   /* note that there are a couple of cases--like checkactorinventory--where "0" will not refer to script activator, and you will either have to use a different function (in the case of checkactorinventory, use checkinventory) or more rarely (like set SetPointer) you'll have to set the activator to the projectile, use the function, then set the activator back to the original activator--for the player you will need to either grab player number and use one of the player pointers [see: http://zdoom.org/wiki/Actor_pointer] or assign a new tid to the player, then switch back using that tid, or have already assigned a unique tid to the player via an enter script and either grab the tid from the player or, if you've stored the tids of players in a map array, grab the tid from the map array
  30.  
  31.  
  32. ////////////////////////////////////////////////////////
  33. // Second version, you don't need to have a new player class
  34. ////////////////////////////////////////////////////////
  35.  
  36. /* place the following in your acs, outside of any scripts */
  37.  
  38. int p_tids[64]; /* or whatever name you want use, array to store tids of projectile for every potential player in zandro */
  39.  
  40. /* the acs */
  41.  
  42. /* if you're wanting current zandro compatibility, set this to a number or use decorate and acs constants (http://zdoom.org/wiki/Constants) to make it easier to read, if you do that remember to remove quotes from script names as they are no longer strings */
  43. script "set_tid" (void) /* this is the script that you set the result value as the tid and use in a_spawnitemex */
  44. {
  45.   int p_tid; /* this will be used to store the tid we use for the new projectile */
  46.   p_tid = UniqueTID; /* grab a unique tid and set p_tid to it */
  47.   p_tids[PlayerNumber()] = p_tid; /* store the projectile tid in the location corresponding to the activating player's player number in the array */
  48.   SetResultValue(p_tid); /* set p_tid as result value so it gets assigned to the projectile spawned by a_spawnitemex */
  49. }
  50.  
  51. /* now this you call from a single line, a 0 duration frame like a "TNT1 A 0", directly after the a_spawnitemex where you used the "set_tid" script */
  52.  
  53. script "proj_assign" (void) /* since this is called from the weapon, the activator is the player */
  54. {
  55.   int p_tid; /* the projectile's tid */
  56.   p_tid =  p_tids[PlayerNumber()]; /* grab the tid of the projectile, stored in the p_tids array in the location corresponding to the activating player's player number */
  57.   /* now do the things you want to do in the script, using tid of "0" to refer to player (since the player activated the script), and tid of "p_tid" to refer to the projectile */
  58.   /* note that there are a couple of cases--like checkactorinventory--where "0" will not refer to script activator, and you will either have to use a different function (in the case of checkactorinventory, use checkinventory) or more rarely (like set SetPointer) you'll have to set the activator to the projectile, use the function, then set the activator back to the original activator--for the player you will need to either grab player number and use one of the player pointers [see: http://zdoom.org/wiki/Actor_pointer] or assign a new tid to the player, then switch back using that tid, or have already assigned a unique tid to the player via an enter script and either grab the tid from the player or, if you've stored the tids of players in a map array, grab the tid from the map array
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