Offset

From ZDoom Wiki
Jump to: navigation, search

Offset (int xpos, int ypos)

Offset is a special property that may be used in DECORATE weapons. It has two arguments: xpos (default 0, positive values shift to the right, negative values shift to the left) and ypos (default 32, higher values shift down, lower values shift up. Both of these can be negatives.). It may be placed in a weapon's states after the state's duration, but before the action function. This does not affect states with A_WeaponReady unless weapon bobbing is disabled. Note that Offset(0, 0) is interpreted as "keep previous offset", not as "reset offset to 0, 0", for backward compatibility, since all states have offsets 0, 0 by default.

Example

This pistol uses only three unique sprite images. The recoil effect is entirely using Offset.

ACTOR Walther : Weapon
{
	Weapon.AmmoType1 "WaltherAmmo"
	Weapon.AmmoUse1 1
	Weapon.SlotNumber 2
 	AttackSound "Walther/Fire"
 	+NOAUTOFIRE
	States
	{
	Select:
		WALT A 1 A_Raise
		Loop
	Deselect:
		WALT A 1 A_Lower
		Loop
  	Ready:
		WALT A 1 A_WeaponReady
		Loop
	Fire:
		WALT C 1 Bright Offset(1,34) A_FireBullets(0,0,-1,11,"BulletPuff",1)
		WALT B 1 Offset(2,37)
		WALT B 1 Offset(1,36)
		WALT A 1 Offset(0,33)
		WALT A 1
		Goto Ready
	}
}