WorldHitscanFired
void WorldHitscanFired (WorldEvent e) (New from 4.14.0)
Usage
An event handler virtual function that is called after a hitscan attack has been fired in the level. In contrast to WorldHitscanPreFired, 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).
Notes:
- This event is triggered by "bullet" hitscan attack function, such as LineAttack() or any of its derivatives. However, it's NOT triggered by "railgun" functions such as RailAttack(); for a similar railgun-related function see WorldRailgunFired.
- A separate event is triggered for every hitscan "bullet".
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
- The flags passed from the attack function. These are the same as the LineAttack() flags:
- LAF_ISMELEEATTACK — enables, but does not force, the puff to enter its Melee state if it has it.
- LAF_NORANDOMPUFFZ — disables the random z offset given to the puff when spawned.
- LAF_NOIMPACTDECAL — disables the generation of decals as a result of the attack.
- LAF_NOINTERACT — guarantees puff spawning and returns it directly to the calling function. Damage is not inflicted, sounds are not played, and blood splatters are not spawned.
- LAF_TARGETISSOURCE — the calling actor's target is considered the source of the damage, otherwise it is the calling actor itself.
- LAF_OVERRIDEZ — disregards the default calculations for the height at which the attack is fired, and instead fires it from the base of the actor, only taking offsetz into account.
- LAF_ABSOFFSET — the forward/side offset parameters will not be rotated by the angle value, instead aligning to the global X/Y axes (they will still be offsets from the actor's position, however).
- LAF_ABSPOSITION — the offset parameters will be treated like global map position, not relative to the actor's current position. (Clarificaton needed: Does this imply LAF_ABSOFFSET?)
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 hitscan attack is fired:
class HitscanInfoHandler: EventHandler
{
override void WorldHitscanFired(WorldEvent e)
{
Console.MidPrint(smallfont, String.Format(
"Hitscan 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'));
}
}