A RailAttack

From ZDoom Wiki
Jump to navigation Jump to search

StateProvider

action void A_RailAttack(int damage, int spawnofs_xy = 0, bool useammo = true, color color1 = 0, color color2 = 0, int flags = 0, double maxdiff = 0, class<Actor> pufftype = "BulletPuff", double spread_xy = 0, double spread_z = 0, double range = 0, int duration = 0, double sparsity = 1.0, double driftspeed = 1.0, class<Actor> spawnclass = "none", double spawnofs_z = 0, int spiraloffset = 270, int limit = 0)

Usage

Fires a rail attack. Only works on weapons.

Parameters

  • damage: The damage to inflict on each target that is hit; this can be a fixed value or an expression.
  • spawnofs_xy: The horizontal distance from the center of the screen at which the railgun tracer should originate. Default is 0.
  • useammo: Whether or not ammo should be used up when firing. Default is true.
  • color1: The color of the particles that form the spiral "ring" of the beam. This can be in the form of a RRGGBB string or a string holding a color defined in the X11R6RGB lump. If the string is invalid, the particles will be black. None (without quotes) in DECORATE or "" in ZScript will make the ring invisible. A value of 0, which is treated specially, draws the the particles in one of four shades of blue, picked randomly. Default is 0.
  • color2: The color of the particles that form the central "core" of the beam. This can be in the form of a RRGGBB string or a string holding a color defined in the X11R6RGB lump. If the string is invalid, the particles will be black. None (without quotes) in DECORATE or "" in ZScript will make the core invisible. A value of 0, which is treated specially, draws the particles in one of three shades of gray, picked randomly. Default is 0.
  • flags: The following flags can be combined by using the | character between the constant names:
    • RGF_SILENT — Silent: The railgun will not play an attack sound when firing.
    • RGF_NOPIERCING — Not piercing: The railgun will stop at the first enemy hit, rather than passing through.
    • RGF_EXPLICITANGLE — Explicit angle: The spread parameters are taken as explicit angles rather than maximum random amplitude.
    • RGF_FULLBRIGHT — Full bright: Rail particles will be rendered at maximum brightness, ignoring sector lighting.
    • RGF_CENTERZ — Attack from center: Z offset originates from half of the player's height (adjusted when crouched), instead of using the Player.AttackZOffset property.
    • RGF_NORANDOMPUFFZ — No random puff Z: Disables the random z-offset of spawned puffs.
  • maxdiff: This is used to make the rail more jagged, or lightning-like, with higher numbers. Default is 0 (straight).
  • pufftype: The puff actor to use. By default, the puff will only spawn in rare circumstances (e.g. when hitting a dormant monster) unless the puff actor has the ALWAYSPUFF flag set. Even if not shown, the selected puff will still be used for applying custom damagetypes and other properties. Puffs with the ALWAYSPUFF flag spawn on floors and ceilings. Default is "BulletPuff".
  • spread_xy: Maximum angle of random horizontal spread. Default is 0.
  • spread_z: Maximum angle of random vertical spread. Default is 0.
  • range: Maximum distance (in map units, as fixed-point) the rail shot will travel before vanishing. Default is 0, which uses the default value of 8192 as the range.
  • duration: Lifetime of spawned particles, in tics. Default is 0, which uses the default value of 35 as the duration.
  • sparsity: Distance between individial particles. Implemented as a multiplier. Default is 1.0.
  • driftspeed: Speed at which particles "drift" away from their initial spawn point. Implemented as a multiplier. Default is 1.0.
  • spawnclass: Actor to spawn in place of trail particles. If non-null, the specified actor will be spaced sparsity units apart instead of the usual trail. It will also inherit the pitch of the shooter and track the owner, allowing for explosive trails to not hurt the owner. Particle-specific properties such as duration, driftspeed, and rail color are ignored in such a case. Default is "None".
  • spawnofs_z: The vertical distance from the center of the screen at which the railgun tracer should originate. Negative values shift the tracer down, positive values shift it up. Default is 0.
  • spiraloffset: the angle from which the outer ring starts spiraling. Default is 270.
  • limit: Sets the maximum number of actors to pierce through, if they are applicable for damaging. Default is 0 (no limit is set).

Examples

This is a generic railgun for the player. This will work copy and pasted, but you'll need graphics. Notice that this example does not have a gunflash, you can still add one though

ZScript

class PlayerRailgun : Weapon
{
    Default
    {
        Radius 24;
        Height 16;
        Obituary "%o got railgunned by %k.";
        Weapon.SelectionOrder 100;
        Weapon.SlotNumber 6;
        Weapon.Kickback 500;
        Weapon.AmmoType "Clip";
        Weapon.AmmoUse 1;
        Weapon.AmmoGive 30;
        AttackSound "weapons/rbeam";
        +EXTREMEDEATH;
    }
	States
	{
	Spawn:
		RLGN A -1;
		Stop;
	Ready:
		RLGN B 1 A_WeaponReady;
		Loop;
	Deselect:
		RLGN B 1 A_Lower;
		Loop;
	Select:
		RLGN B 1 A_Raise;
		Loop;
	Fire:
		RLGN C 4;
		RLGN D 4 bright A_RailAttack(2, color1:"ffffa0", color2:"ffffa0", pufftype:null);
		RLGN E 4 bright;
		RLGN F 4;
		TNT1 A 0 A_ReFire;
		Goto Ready;
	}
}

DECORATE

ACTOR PlayerRailgun : Weapon
{
  Radius 24
  Height 16
  Obituary "%o got railgunned by %k."
  Weapon.SelectionOrder 100
  Weapon.SlotNumber 6
  Weapon.Kickback 500
  Weapon.AmmoType "Clip"
  Weapon.AmmoUse 1
  Weapon.AmmoGive 30
  AttackSound "weapons/rbeam"
  +EXTREMEDEATH
  States
  {
  Spawn:
    RLGN A -1
    Stop
  Ready:
    RLGN B 1 A_WeaponReady
    Loop
  Deselect:
    RLGN B 1 A_Lower
    Loop
  Select:
    RLGN B 1 A_Raise
    Loop
  Fire:
    RLGN C 4
    RLGN D 0 A_RailAttack(2, 0, 1, "ffffa0", "ffffa0", 0, 0, "none")
    RLGN E 8 Bright
    RLGN F 4
    TNT1 A 0 A_ReFire
    Goto Ready
  }
}