LineAttack (ZScript)

Actor, int LineAttack (double angle, double distance, double pitch, int damage, Name damageType, class<Actor> pufftype [, int flags [, out FTranslatedLineTarget victim [, double offsetz [, double offsetforward [, double offsetside]]]]])

Usage

Fires a hitscan attack, originating from the calling actor.

Parameters

  • angle: the angle at which the attack should be fired.
  • distance: the maximum distance at which the attack successfully hits.
  • pitch: the pitch by which the attack should be fired.
  • damage: the damage dealt by the attack.
  • damageType: the damage type of the attack.
  • pufftype: the puff to spawn. If this is null it defaults "BulletPuff".
  • flags: the following flags can be combined by using | between the constant names (Default is 0):
    • 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_ABSOFFSETangle is used as an absolute angle instead of a relative one to the calling actor's angle.
    • LAF_ABSPOSITION — the offset parameters below are treated as absolute coordinates.
  • victim: allows to obtain data related to the actor which was hit by the attack, like the pointer to said actor. To obtain the data, a variable of type FTranslatedLineTarget needs to be passed to this. Default is null.
  • offsetz: shifts the spawn point of the attack upwards and downwards. Positive values shift it upwards, while negative values shift it downwards. Default is 0.
  • offsetforward: shifts the spawn point of the attack forwards and backwards. Positive values shift it forwards, while negative values shift it backwards. Default is 0.
  • offsetside: shifts the spawn point of the attack to either sides. Positive values shift it to the right side, while negative values shift it to the left side. Default is 0.

Return value

The functions returns a pointer to the spawned puff and the amount of inflicted damage the hit actor may had sustained.

FTranslatedLineTarget contains information about the actor that was hit. This includes:

  • Actor linetarget - The actor that was hit by the attack if any. Otherwise null.
  • double angleFromSource - The angle of the target from the caller.
  • double attackAngleFromSource - The angle of the target from the position where it was hit.
  • bool unlinked - Found by a trace that went through an unlinked portal.
  • native void TraceBleed (int damage, Actor missile)

Examples

This fist uses a stripped-down version of A_Punch to highlight the function's use.

class NewFist : Fist
{
    Default
    {
        Weapon.SlotNumber 1;
    }

    States
    {
    Fire:
        PUNG B 4;
        PUNG C 4
        {
            FTranslatedLineTarget t;
            double ang = angle + Random2() * (5.625 / 256);
            double pitch = AimLineAttack(ang, 64, null, 0., ALF_CHECK3D);
            LineAttack(ang, 64, pitch, 100, 'Melee', "BulletPuff", LAF_ISMELEEATTACK, t);

            // Turn to face the hit actor.
            if (t.linetarget)
            {
                angle = t.angleFromSource;
            }
        }
        PUNG D 5;
        PUNG C 4;
        PUNG B 5 A_ReFire;
        Goto Ready;
    }
}

This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.