$IF !NO_COLLECT_ON_SPIT: on "spit": goto immediate: "_collected" $IF !NO_COLLECT_ON_TOUCH: on "touch": goto immediate: "_collected" proc "while_collected": # What we do every frame after we have been collected # (Basically, wait to potentially respawn) # Respawn based on a mapvar if: exists myvar("respawn_counter") then: if: expr: <= mapvar(myvar("respawn_counter")) 0 then: goto immediate: "init" # Respawn based on a timer if: exists myvar("respawn_in") then: if: expr: <= myvar("respawn_in") 0 then: goto immediate: "init" else: dec myvar("respawn_in") # Default anim: init state "init": if: exists myvar("collected_key") expr: mapvar(myvar("collected_key")) then: goto: "collected" if() then: if: any: not: exists myvar("key") expr: mapvar(myvar("key")) not: exists myvar("antikey") expr: mapvar(myvar("antikey")) then: goto immediate: "_appear" else: # Do nothing; so, our state will remain "init", # so we will be invisible, and each frame we will # retry all these checks. state "_appear": if: exists myvar("appear") expr: myvar("appear") then: if: exists myvar("crouch") expr: myvar("crouch") then: goto delay: "appear_crouch" else: goto delay: "appear" if() then: if: exists myvar("crouch") expr: myvar("crouch") then: goto immediate: "_crouch" else: goto immediate: "_stand" state "_collected": if() then: if: exists myvar("collected_key") then: if: exists myvar("num_key") then: dec mapvar(myvar("num_key")) if: expr: <= mapvar(myvar("num_key")) 0 then: set mapvar(myvar("collected_key")): T else: set mapvar(myvar("collected_key")): T if: exists myvar("respawn_time") then: set myvar("respawn_in"): myvar("respawn_time") $IF RESPAWN_TIME: else: set myvar("respawn_in"): $GET_INT RESPAWN_TIME goto: "collected"