WorldRailgunPreFired

From ZDoom Wiki
Jump to navigation Jump to search

StaticEventHandler

bool WorldRailgunPreFired (WorldEvent e) (New from 4.14.0)

Usage

An event handler virtual function that is called before a railgun is fired in the level. This event can be used to block railgun attacks from happening and potentially replace them with something else, such as projectiles.

Note: This event is only triggered by rail attacks, i.e. attacks fired by RailAttack() or its derivatives. It is NOT triggered by "bullet" hitscan attacks such as LineAttack() or any of its derivatives (for that see WorldHitscanPreFired). Please note that internally "bullet" and "railgun" attacks, while technically both hitscans, are handled by different functions and have a few special, different behaviors tied to them.

Passed values

This event gets a pointer to the WorldEvent struct, and can read certain fields from it preceding the value with e..

  • Actor thing
A pointer to the actor who fired the attack.
  • angle AttackAngle
The absolute horizontal angle offset at which the attack was fired, as passed from the attack function. To convert this to a relative angle, subtract e.thing.angle from this value.
  • angle AttackPitch
The vertical angle offset at which the attack was fired, as passed from the attack function.
  • double AttackDistance
The maximum range of the the attack, as passed from the attack function. For reference, player attacks by default use PLAYERMISSILERANGE (8192) and monster attacks use MISSILERANGE (2048), but all hitscan and railgun functions allow specifying a custom distance.
  • int damage
The damage the hitscan attack should deal. Note, this is the value after all randomization has been applied to it by the function, if any. (For example, by default A_FireBullets multiplies its damage by random(1, 3).)
  • Name damageType
The damage type applied to the attack (either through its arguments or a custom puff).
  • class<Actor> AttackPuffType
The puff class used by the attack. Note that with railgun attacks the puffs are usually invisible, but they still spawn and are used to handle damage types and other special conditions. (See Puff usage and behavior for details.)
  • double AttackZ
Vertical offset of the attack from the shooter's origin. This is similar to the spawnofs_z argument of A_CustomRailgun.
  • double AttackOffsetSide
Side offset of the attack from the shooter's origin. This is similar to the spawnofs_xy argument of A_CustomRailgun.
  • FRailParams RailParams
A pointer to the FRailParams struct transferred from the initial function call. All relevant data can also be read from this struct.
Note: Since this function gets access to the FRailParams struct, which also contains data on the railgun attack, some of the data is duplicated in this event. For example, you can check the damage that would be dealt by the railgun attack both with e.damage and e.RailParams.damage, and they will contain the same value. Same goes for several other fields.


Return value

  • bool — returning true will block the attack from happening (note, this will not prevent anything else that might normally be tied to the attack, such as ammo consumption, sounds, etc.). By default returns false.

Examples

Nuvolachalk.png Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated.


See also