A_FireProjectile
Actor A_FireProjectile (class<Actor> missiletype [, double angle [, bool useammo [, double spawnofs_xy [, double spawnheight [, int flags [, double pitch]]]]]])
Actor, Actor A_FireProjectile (class<Actor> missiletype [, double angle [, bool useammo [, double spawnofs_xy [, double spawnheight [, int flags [, double pitch]]]]]]) (New from 4.10.0)
Usage
Fires a projectile from a Weapon or a CustomInventory. Optionally you can specify an angle and a spawn offset.
This serves as a replacement for A_FireCustomMissile which has a pitch miscalculation in it.
If used in a weapon, useammo specifies whether this attack uses ammo or not. This parameter is irrelevant if used in a custom inventory.
The following flags can optionally be used. Multiple flags can be combined by separating them with the pipe character '|'.
- FPF_AIMATANGLE — Alternate autoaim behavior, relevant when playing with autoaim. Autoaiming is based off of the projectile's trajectory instead of the player's aim. If this flag is set, the engine looks at the horizontal line of fire projected for the projectile, independent of the player's aim. If the horizontal line of fire cuts close enough to a valid target (again ignoring vertical aim), that projectile will fire directly towards that target. If this flag is not set, the engine looks at the player's horizontal aim. If the horizontal line of fire cuts close enough to a valid target (ignoring vertical aim), the resulting projectile will fire with the vertical angle adjusted to aim directly at the target.
- FPF_TRANSFERTRANSLATION — Transfer Translation. The projectile fired uses the same translation as the actor that fired it. In most cases, this will be the player.
- FPF_NOAUTOAIM — Disables autoaim for this attack.
pitch becomes relevant with autoaim off. It adjusts the player's vertical aim by the given angle value, like the angle parameter affects the horizontal aim. A positive value makes it fire the missile lower than the player's aim, a negative value makes it fire higher, in constrast to how A_FireCustomMissile inverts the effect of the pitch parameter.
Return values
A_FireProjectile returns two Actor pointers, both pointing to the projectile that was fired. The only difference between them Both of those are pointers to the projectile that was fired, but they're created under different conditions:
- The first pointer is only created if the projectile managed to enter its Spawn state sequence. If the projectile is fired an an enemy, object or a wall at a point-blank range, it'll instead immediately enter its Death (Crash, XDeath, etc.) state sequence, completely skipping Spawn, and this pointer will be null.
- The second pointer (New from 4.10.0) is always created, regardless of the state sequence the projectile entered.
As such, if there's a need to modify some properties of the projectile, the second pointer should be used, because the first one is simply not guaranteed to exist. (The second pointer should still be null-checked for safety, but normally it will never be null).
Example:
// Create two pointers:
Actor p1, p2;
// Cast both of them to the projectile:
[p1, p2] = A_FireProjectile("Rocket");
// Modify the resulting projectile's damage:
if (p2)
{
p2.SetDamage(80);
}
Examples
Fire: TRIF A 5 Bright A_FireProjectile("RifleBullet",0,1,8,8,0) TRIF B 5 Bright TRIG A 10 TRIG B 0 A_Refire Goto Ready