Skip to main content

trigger_changevalue

trigger_changevalue icon
Point entityPorted from SevenKewpSven Co-op

A trigger_changevalue changes a key of other entities while the map runs. It replaces the value, or it combines the current value with a new one, for example by adding, multiplying or appending text. See Changing keys for every rule, and the Changing values guide for small setups.

Attributes​

The entity also has these common keys:

KeyDescriptionDefault
Destination entitytarget

Names the entities to change: every entity with this name, or !activator or !caller.

Key namem_iszValueName

Names the key to change by its key name, such as health, rendercolor or target, or a custom key such as $i_count.

New valuem_iszNewValue

Sets the new value, as a number, three numbers x y z or text. A single value can also be a named constant, in capitals or not, such as FL_ONGROUND, SOLID_NOT, EF_NODRAW, MOVETYPE_FLY, kRenderTransAdd or CLASS_PLAYER. A ~ in front of a constant flips all its bits.

Type of valuem_iszValueType

Sets the operation.

The 31 choices
  • Replace (= new value) (0)
  • Add (= old + new) (1)
  • Mul (= old * new) (2)
  • Sub (= old - new) (3)
  • Div (= old / new) (4)
  • Pow (= old ^ new) (16)
  • Mod (= old % new, whole numbers) (12)
  • AND (= old & new) (5)
  • OR (= old | new) (6)
  • XOR (= old ^ new) (13)
  • Clear bits (= old & ~new) (15)
  • Min (= min(old, new)) (30)
  • Max (= max(old, new)) (31)
  • NAND (bitwise: = ~(old & new)) (7)
  • NOR (bitwise: = ~(old | new)) (8)
  • NXOR (bitwise: = ~(old ^ new)) (14)
  • Direction to Angles (= angles of old) (9)
  • Angles to Direction (= direction of old) (10)
  • Append (String concatenation) (11)
  • Sin (= sin(new)) (17)
  • Cos (= cos(new)) (18)
  • Tan (= tan(new)) (19)
  • Cot (= cot(new)) (23)
  • Arcsin (= arcsin(new)) (20)
  • Arccos (= arccos(new)) (21)
  • Arctan (= arctan(new)) (22)
  • Arccot (= arccot(new)) (24)
  • Whole numbers stay whole numbers, and numbers with decimals keep their decimals. Mod works on whole numbers, so 6.5 mod 4 is 2
  • The entity works out a vector one part at a time
  • "Direction to Angles" and "Angles to Direction" turn the key's own value into the other form. They don't use New value or the flags Don't use X, Don't use Y and Don't use Z
  • Text keys only take Replace and Append
Default Replace (= new value) (0)
Trigonometric funcs. behaviorm_trigonometricBehaviour

Sets the unit of the angle operations.

  • Degrees (0) - Sin, Cos, Tan and Cot take the value in degrees, and Arcsin, Arccos, Arctan and Arccot give degrees, so the sine of 30 is 0.5
  • Radians (1) - Both are in radians
Default Degrees (0)
Append spacesm_iAppendSpaces

For text, adds this many spaces after the result, up to 255.

Default 0
Trigger after operationmessage

Fires this target after the change. It can be a name, !activator or !caller.

Treat new value asvalue_type

Sets whether the entity uses New value as you wrote it or as a locus key. A locus key is worked out for the activator each time the entity fires.

  • Literal value (0)
  • Locus Ratio (1)
  • Locus Position (2)
  • Locus Velocity (3)
Default Literal value (0)

Flags​

1Don't use X

The X of a vector stays as it is

2Don't use Y

The Y of a vector stays as it is

4Don't use Z

The Z of a vector stays as it is

32Invert target value

The current value becomes negative before the operation

64Invert source value

The new value becomes negative before the operation

Notes​

  • Any use type triggers the change. The entity writes the new value the way the map loader writes a key, so it works on every key that the entity reads from the map
  • If you put three numbers such as 0 0 50 into a key that holds a single number, the key gets the vector's length, here 50. If the second and the third number are 0, as in -30 0 0, the key gets the first number, here -30
  • Three numbers go into a vector key part by part, so 64 0 0 with Add moves an origin 64 units along X only. A single number such as 2 goes into every part
  • A division or a modulo by zero leaves the value as it was
  • You can only replace a key that the game can't read back. Any other operation leaves it as it is, and with developer 1 set in the console, the console says so
  • The entity refuses keys that name a model or a sound, because nothing can be precached while the map runs. It also refuses classname and headscale. With developer 1 set in the console, the console shows each refused key
  • Setups from Sven Co-op carry over, because the class names, key names, flags and operation numbers are the same

See also​

Changes since 1.38​

  • trigger_changevalue is new