A_SetUserVar

From ZDoom Wiki
Jump to: navigation, search

A_SetUserVar (string name, int value)

Sets the calling actor's user variable of type int named name to value. The name must begin with user_.

User variables are not used by anything internally, contrarily to the args array and the special1 and special2 fields.

Notes

  • User variables on weapons will not work unless they are defined on the player actor itself.
  • CustomInventory items can modify a monster's variables, but it must be defined in both the monster, and the CustomInventory actors. Until the CustomInventory enters its Use state legitimately (NOT through state jumps, but actual internal triggering), it will only modify its own user variables. If the inventory item needs modifying for only itself once grabbed, do so in the Pickup state.

Examples

This code creates an imp which attacks with a 360 degree "shockwave" attack composed of 360 individual fireballs. Old mods achieved this effect by reproducing a A_CustomMissile call many times. This cuts down on the amount of lines needed and is much cleaner to implement.

actor ShockWaveDoomImp : DoomImp replaces DoomImp
{
  var int user_theta;
  states
  {
  Missile:
    TROO EF 8 A_FaceTarget
    TROO G 0 A_SetUserVar("user_theta",0)
  Shock:
    TROO G 0 A_CustomMissile("DoomImpBall",32,0,user_theta)
    TROO G 0 A_SetUserVar("user_theta",user_theta+1)
    TROO G 0 A_JumpIf(user_theta==360,"EndShock")
    Loop
  EndShock:
    TROO G 6
    Goto See
  }
}

See also