A_RailAttack
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.
Note: With the advent of ZScript, certain things should be considered: 1. This function has a very long list of arguments. As such, using named arguments is recommended to keep track of them. |
Parameters
- int damage
- The damage to inflict on each target that is hit; this can be a fixed value or an expression.
- int spawnofs_xy
- The horizontal distance from the center of the screen at which the railgun tracer should originate. Default is 0.
- bool useammo
- Whether or not ammo should be used up when firing. Default is true.
- color color1
- color color2
- The color of the particles that form the spiral (color1) and the core beam (color2) of the railgun's ray. This can be given as RRGGBB, a color defined in the X11R6RGB lump or any other supported color format. If the string is invalid, the particles will be black.
""
in ZScript (orNone
without quotes in DECORATE) will make the respective part of the ray (spiral or core) invisible. A value of 0 (the default), which is treated specially, draws the particles in one of three shades of gray, picked randomly.
- int flags
- The following flags can be combined with
|
- RGF_SILENT — The railgun will not play an attack sound when firing.
- RGF_NOPIERCING — The railgun will stop at the first enemy hit, rather than passing through.
- RGF_EXPLICITANGLE — The spread parameters are taken as explicit angles rather than maximum random amplitude.
- RGF_FULLBRIGHT — Rail particles will be rendered at maximum brightness, ignoring sector lighting.
- RGF_CENTERZ — Z offset originates from half of the player's height (adjusted when crouched), instead of using the Player.AttackZOffset property.
- RGF_NORANDOMPUFFZ — Disables the random z-offset of spawned puffs.
- double maxdiff
- This is used to make the rail more jagged, or lightning-like, with higher numbers. Default is 0 (straight).
- class<Actor> 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.
- double spread_xy
- Maximum angle of random horizontal spread. Default is 0.
- double spread_z
- Maximum angle of random vertical spread. Default is 0.
- double 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.
- int duration
- Lifetime of spawned particles, in tics. Default is 0, which uses the default value of 35 as the duration.
- double sparsity
- Distance between individial particles. Implemented as a multiplier. Default is 1.0.
- double driftspeed
- Speed at which particles "drift" away from their initial spawn point. Implemented as a multiplier. Default is 1.0.
- class<Actor> 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".
- Warning: Using actors for beam particles is generally discouraged, especially when the beam is long and/or the actors in question use additive renderstyle. Spawning multiple actors per a single tic can cause significant performance drops. For highly customized beams, using custom particles in ZScript is recommended.
- double 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.
- double spiraloffset
- The angle from which the outer ring starts spiraling. Default is 270.
- int 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 (deprecated)
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 } }
ZScript definition
Note: The ZScript definition below is for reference and may be different in the current version of GZDoom.The most up-to-date version of this code can be found on GZDoom GitHub. |
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)
{
if (range == 0) range = 8192;
if (sparsity == 0) sparsity=1.0;
let player = self.player;
if (!player) return;
let weapon = player.ReadyWeapon;
if (useammo && weapon != NULL && stateinfo != null && stateinfo.mStateType == STATE_Psprite)
{
if (!weapon.DepleteAmmo(weapon.bAltFire, true))
return; // out of ammo
}
if (!(flags & RGF_EXPLICITANGLE))
{
spread_xy = spread_xy * Random2[crailgun]() / 255.;
spread_z = spread_z * Random2[crailgun]() / 255.;
}
FRailParams p;
p.damage = damage;
p.offset_xy = spawnofs_xy;
p.offset_z = spawnofs_z;
p.color1 = color1;
p.color2 = color2;
p.maxdiff = maxdiff;
p.flags = flags;
p.puff = pufftype;
p.angleoffset = spread_xy;
p.pitchoffset = spread_z;
p.distance = range;
p.duration = duration;
p.sparsity = sparsity;
p.drift = driftspeed;
p.spawnclass = spawnclass;
p.SpiralOffset = SpiralOffset;
p.limit = limit;
self.RailAttack(p);
}