Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script "IceMissileScript" (void) /* Call this in the missile's XDeath state with "CallACS("IceMissileScript")" */
- {
- int proj_rad, proj_height, proj_x, proj_y, proj_z, tar_x, tar_y, tar_z, tar_rad, tar_height;
- proj_rad = GetActorProperty(0, APROP_Radius) << 16; /* Get the radius of the projectile (converted to fixed point) */
- proj_height = GetActorProperty(0, APROP_Height) << 16; /* Get the height of the projectile (converted to fixed point) */
- proj_x = GetActorX(0); /* Get projectile X position */
- proj_y = GetActorY(0); /* Get projectile Y position */
- proj_z = GetActorZ(0); /* Get projectile Z position */
- /* Now set activator to the projectile's tracer (what the monster was trying to hit) to get
- information about the actor without having to use tids */
- SetActivator(0,AAPTR_TRACER);
- tar_rad = GetActorProperty(0, APROP_Radius) << 16; /* Get the radius of the target (converted to fixed point) */
- tar_height = GetActorProperty(0, APROP_Height) << 16; /* Get the height of the target (converted to fixed point) */
- tar_x = GetActorX(0); /* Get target X position */
- tar_y = GetActorY(0); /* Get target Y position */
- tar_z = GetActorZ(0); /* Get target Z position */
- /* Now we compare the positions, because just hitting a shootable target (since it was called
- from the XDeath state) does not guarantee it hit the actor the monster was aiming at. */
- /* If you don't understand what stuff like "||" (or) or "&&" (and) is, google "ZDoom ACS
- operators; they are also the same as C's operators in pretty much all cases */
- /* We check Z positions first */
- if( ( (proj_z >= tar_z && proj_z <= (tar_z + tar_height)) /* If projectile's bottom is between the target's bottom and top */
- || ((proj_z + proj_height) >= tar_z && (proj_z + proj_height) <= (tar_z + tar_height)) ) /* OR if projectile's top is between the target's bottom and top */
- && /* AND */
- /* Now we check position on the XY plane */
- ( VectorLength(tar_x - proj_x, tar_y - proj_y) /* The distance between the two positions... */
- /* ..is less than or equal to the sum of the two actor's radii (using hypotenuse of radii
- because in (G)ZDoom actors are square, not round, and radius refers to distance from
- the actor's center to the nearest side (not corner), or effectively 1/2 of the length
- of a single side of the actor's cube hitbox */
- <= (VectorLength(proj_rad, proj_rad) + VectorLength(tar_rad, tar_rad)) ) ){ /* If all above conditions are met, then.. */
- GiveInventory("ItemName",1); /* Give the current activator (the monster's target and what the projectile hit
- an inventory item "ItemName" which should be a CustomInventory item; since you can put all decorate action
- functions in the item's pickup state (such as A_GiveInventory and others--basically whatever you have currently
- happening in the pain sate) this allows you to set the what the effect does in Decorate rather than ACS so you
- don't have to modify this script and can work in Decorate instead. */
- /* If there ends up being more effects you want that are only available in ACS, add them here right after this line */
- } /* End of IF statement */
- /* Don't need to add an ELSE since if the IF condition isn't met the script will just stop on it's own */
- /* It's worth noting that by adding a script argument (instead of the "(void)" up there now) you could
- easily have this script work for other projectiles, and have the same script be used by multiple
- projectiles and do different things for each; it's very easy to do and either I or someone else that
- knows ACS could help you, or if you want to try it yourself look up "ACS switch statement" */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement