A_WeaponOffset
Note: While the function described on this page is defined in the Actor class, it only works when called either from a PlayerPawn state, or from one of the StateProvider states handled by PSprite, such as Weapon's Ready/Fire/etc. state sequences or a CustomInventory's Use state sequence. It will have no effect in any other context (such as calling it from a weapon's DoEffect override). If there's a need to achieve a similar effect from a different context, obtain a pointer to the necessary PSprite and modify its fields directly. |
native void A_WeaponOffset(double wx = 0, double wy = 32, int flags = 0)
Usage
This function can only be called on weapons. Offsets a weapon by the defined amount of wx and wy similar to the Offset frame keyword, but a lot more robust.
Offsets stack on top of weapon bobbing and behave independently, allowing you to use A_WeaponReady without losing offsets.
This function is the same as calling A_OverlayOffset with the layer parameter set to PSP_WEAPON.
Parameters
- double wx
- Adjusts horizontal position based on positive (right) or negative (left) numbers. Default is 0.
- double wy
- Adjusts vertical position. Larger values lower the weapon, and vice versa. Default is 32, also expressed as the WEAPONTOP constant.
- int flags
- Flags can be combined with
|
:- WOF_KEEPX — wx parameter will not be used, keeping the horizontal offset as-is.
- WOF_KEEPY — wy parameter will not be used, keeping the vertical offset as-is.
- WOF_ADD — Adds the current x and y parameters to the current offsets instead of overriding them. Also implies interpolation (see below).
- WOF_INTERPOLATE — Interpolates the offset between tics, smoothing out the animation.
Examples
This shows an example of how a weapon's Fire state sequence could be made with one frame that is first quickly pushed to the right and down, then returned back more slowly:
...
Fire:
WEAP A 2
{
A_FireBullets(5, 3.5, 1, 10);
A_GunFlash();
}
WEAP AAA 1 A_WeaponOffset(4.0, 3.0, WOF_ADD);
WEAP AAAAAA 1 A_WeaponOffset(-2.0, -1.5, WOF_ADD);
WEAP A 5 A_ReFire;
goto Ready;
...
Note, in practice a more convincing recoil effect could be achived by also adding A_OverlayScale and A_OverlayRotate into the mix.