It is more plausible as an action function. A_SetStateTicks(int ticks, int flags = 0)
- You could pass random(1,10) as ticks
- Flags could contain such options as "ADD", "SUBTRACT"... well, you get it. Default behaviour is to set (replace). -1 means unlimited time.
Setting the duration randomly in the first place probably demands some reengineering, while modifying the remaining duration of the current state seems possible.
Such a function should probably affect the state owner, and not necessarily the caller. (When called from a weapon, affect the current weapon state, not the player state; when called from custominventory pickup/use, make no difference.)
- Code: Select all • Expand view
TROO A 0 A_Look
TROO A 0 A_SetStateTicks(random(1,10))
TROO B 0 A_Look
TROO B 0 A_SetStateTicks(random(1,10))
A little less nice in decorate, but probably more easy to achieve.
Note: Add and subtract need not be different operations. You can pass negative values to subtract using "add".
Note: Add and subtract should not be able to change to or from -1. -1 represents an infinite duration, and cannot be reduced or increased significantly by finite operations.
Note: More advanced solutions than simply passing the desired duration (including -1 if infinity is desired) may be completely unnecessary. The feature is simpler if just sticking to the one parameter.