WorldRailgunFired
void WorldRailgunFired (WorldEvent e) (New from 4.14.0)
Usage
An event handler virtual function that is called after a railgun attack has been fired in the level. In contrast to WorldRailgunPreFired, this event cannot prevent the attack from happening, but it can be used to apply some kind of extra effects based on the attack (for example, spawn visual tracers or something else).
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 WorldHitscanFired). 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.
- Vector3 AttackPos
- World coordinates of the point from which the attack originated. (Normally this would be the position of the shooter with their attack height added on top.)
- Vector3 DamagePosition
- World coordinates of the point where the attack hit.
- Actor Inflictor
- The puff that was used by the attack.
- int AttackLineFlags
- (Need more info)
The direction vector from the attack origin to the point where it ended can be calculated with level.Vec3Diff(e.AttackPos, e.DamagePosition).Unit().
Examples
This event handler simply prints information on the screen and to the console whenever a railgun attack is fired:
class RailgunInfoHandler: EventHandler
{
override void WorldRailgunFired(WorldEvent e)
{
Console.MidPrint(smallfont, String.Format(
"Railgun fired:"
"\nAttacker: \cd%s\c-"
"\nAttack pos: \cd%d, %d, %d\c-"
"\nDamage pos: \cd%d, %d, %d\c-"
"\nInflictor: \cd%s\c-",
e.thing.GetClassName(),
e.attackpos.x, e.attackpos.y, e.attackpos.z,
e.damagePosition.x, e.damagePosition.y, e.damagePosition.z,
e.inflictor? e.inflictor.GetClassName() : 'none'));
}
}