A_SetUserVarFloat

From ZDoom Wiki
Jump to navigation Jump to search

A_SetUserVarFloat (string name, float value)

Sets the calling actor's user variable of type float 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_SpawnProjectile call many times. This cuts down on the amount of lines needed and is much cleaner to implement.

actor ShockWaveDoomImp : DoomImp replaces DoomImp
{
  var float user_theta;
  states
  {
  Missile:
    TROO EF 8 A_FaceTarget
    TROO G 0 A_SetUserVarFloat("user_theta",0.0)
  Shock:
    TROO G 0 A_SpawnProjectile("DoomImpBall",32,0,user_theta)
    TROO G 0 A_SetUserVarFloat("user_theta",user_theta + 1.1)
    TROO G 0 A_JumpIf(user_theta >= 360.0,"EndShock")
    Loop
  EndShock:
    TROO G 6
    Goto See
  }
}

See also