Rusted Warfare Mod Workshop
All coursesCreative tools中文

Build a stable emergency state

Combine periodic conditions, remembered state and a recovery threshold

Write states and transitions first

The tank has cruise and emergency states, it enters below 50% health and leaves after repair reaches 80%, separate thresholds prevent rapid toggling near a single boundary

巡航 / Cruise
  └─ HP < 50% → 应急 / Emergency
应急 / Emergency
  └─ HP ≥ 80% → 巡航 / Cruise

Gate the entry transition

not memory.emergency prevents the entry action from repeating while already in emergency mode, the action updates state and speed and emits an observable message

[hiddenAction_enterEmergency]
autoTrigger: if self.hp < self.maxHp * 0.5 and not memory.emergency
setUnitMemory: emergency=true
setUnitStats: movespeed=1.2
showMessageToPlayer: 应急模式开启 / Emergency mode enabled

Define the recovery transition

The exit action requires emergency mode and at least 80% health, restore the original movement speed as well as the boolean state

[hiddenAction_leaveEmergency]
autoTrigger: if self.hp >= self.maxHp * 0.8 and memory.emergency
setUnitMemory: emergency=false
setUnitStats: movespeed=0.7
showMessageToPlayer: 已恢复巡航 / Cruise mode restored

Test cycles and boundaries

Observe health near 51%, 49%, 60% and 81%, expect one entry near 49% and one exit near 81%, repeat the full cycle and inspect messages, speed and ammunition

Try it yourself

Make a transition table listing every value that must change and later reset

Open interactive lesson and download the companion mod