# Expected vars: # NS (str), e.g. "spider_" # EYESPIDER (bool) # NOTE: make sure "stand" is the first anim, so any imports # should go below it # So we know we're not just a "spider-like" thing, e.g. coin_beast $SET_BOOL SPIDER $SET_BOOL DISABLE_RUNNING # !!! DISABLED FOR NOW # Should match the delays in anim/_roller.fus $SET_INT ROLLER_STAND_DELAY 1 $SET_STR STATE_STAND stand $SET_STR STATE_STEP step $SET_STR STATE_STEP_UP step $SET_STR STATE_STEP_DOWN step_down $SET_STR STATE_START_JUMP start_jump $SET_STR STATE_RUN_STEP run_step $SET_STR STATE_RUN_STEP_UP run_step $SET_STR STATE_RUN_STEP_DOWN run_step_down $SET_STR STATE_RUN_START_JUMP run_start_jump $SET_STR STATE_JUMP jump vars: "is_rollerspider": F "is_aimerspider": F "is_spikeyspider": F "is_flierspider": F "is_birdspider": F "is_flipspider": F "is_stickyspider": F # Labels which *don't* depend on "is_*spider" vars # (These labels are moved around to animate the spider) nosave label "label:head": $PREFIX NS "head" nosave label "label:crawl_head": $PREFIX NS "crawl_head" nosave label "label:sleep_head": $PREFIX NS "sleep_head" nosave label "label:fleg": $PREFIX NS "fleg" nosave label "label:bleg": $PREFIX NS "bleg" # Labels which *do* depend on "is_*spider" vars # (These labels are set by proc "update_vars", and are used # to customize the spider's appearance) nosave label "label:_head": null nosave label "label:eye": null nosave label "label:nose": null nosave label "label:toe": null nosave label "label:headbump": null nosave label "label:head_spikes": null nosave label "label:head_spikes_extended": null nosave "carrying": null nosave "carrying_respawn_counter": null nosave label "label:carrying": null nosave "spit_anim": null proc toplevel onstatesetchange "update_vars": # Sets various vars which depend on the "is_*spider" vars. # Defaults: set myvar("label:_head"): $PREFIX NS "_head" set myvar("label:eye"): $PREFIX NS "eye" set myvar("label:nose"): $PREFIX NS "nose" set myvar("label:toe"): null set myvar("label:headbump"): null set myvar("label:head_spikes"): null set myvar("label:head_spikes_extended"): null # Overriding the defaults depending on what kind(s) of spider we are: if: expr: myvar("is_rollerspider") then: set myvar("label:_head"): $PREFIX NS "_head_roller" if: expr: myvar("is_aimerspider") then: set myvar("label:nose"): $PREFIX NS "nose_aimer" set myvar("label:headbump"): $PREFIX NS "headbump_aimer" if: expr: myvar("is_flierspider") then: set myvar("label:headbump"): $PREFIX NS "headbump_flier" if: expr: myvar("is_spikeyspider") then: set myvar("label:head_spikes"): $PREFIX NS "head_spikes" set myvar("label:head_spikes_extended"): $PREFIX NS "head_spikes_extended" if: expr: myvar("is_flipspider") then: set myvar("label:eye"): $PREFIX NS "eye_flip" if: expr: myvar("is_stickyspider") then: set myvar("label:toe"): $PREFIX NS "toe_sticky" # Set myvar("spit_anim") $IF EYESPIDER: set myvar("spit_anim"): "anim/eyespit.fus" $IF !EYESPIDER: if: expr: myvar("is_spikeyspider") then: set myvar("spit_anim"): "anim/spikeyspit.fus" else: set myvar("spit_anim"): "anim/spit.fus" collmsgs: $IF !EYESPIDER: "touch" $IF !EYESPIDER: "enter_door" on "crush": goto: "dead" $IF !EYESPIDER: on "carryable": # "me" is a spider, "you" is a carryable thing (e.g. coin, food) if: not: exists myvar("carrying") then: # Transfer some vars from carryable thing to the spider who # will now be "carrying it" set myvar("carrying"): yourvar("carryable") set myvar("carrying_respawn_counter"): yourvar("respawn_counter") set myvar("label:carrying"): yourvar("carryable_rgraph") # Increment a var tracking how many of this thing are # being carried if: exists myvar("carrying_respawn_counter") then: inc mapvar(myvar("carrying_respawn_counter")) # When a thing is carried, it is "collected" as you: goto immediate: "_collected" proc onmapchange "mapchange": # Decrement a mapvar tracking how many of this thing are # being carried # (NOTE: this logic should match that for when spit "dies") if: exists myvar("carrying_respawn_counter") then: dec mapvar(myvar("carrying_respawn_counter")) # Unset "carrying" and related vars call: "_unset_carrying" proc "_unset_carrying": # Unsets "carrying" and related vars set myvar("carrying"): null set myvar("label:carrying"): null proc "_spawn_spit": # "me" is spider, "you" is spider's newly-spawned spit if: exists myvar("carrying") then: # Transfer the thing we're carrying over to our spit # Set spit's "carrying" to spider's "carrying" as you: set myvar("carrying"): yourvar("carrying") set myvar("carrying_respawn_counter"): yourvar("carrying_respawn_counter") set myvar("label:carrying"): yourvar("label:carrying") # Unset "carrying" and related vars call: "_unset_carrying" proc "spit": spawn: myvar("spit_anim") "fly" (0 0) 0 f do: call: "_spawn_spit" goto delay: "spit" proc "looking_up_spit": spawn: myvar("spit_anim") "fly" (1 0) 1 f do: call: "_spawn_spit" goto delay: "looking_up_spit" proc "crawl_spit": spawn: myvar("spit_anim") "crouch_fly" (0 0) 0 f do: call: "_spawn_spit" goto delay: "crawl_spit" proc "crawl_looking_up_spit": spawn: myvar("spit_anim") "crouch_fly" (1 0) 1 f do: call: "_spawn_spit" goto delay: "crawl_looking_up_spit" proc "swim_spit": spawn: myvar("spit_anim") "fly" (0 0) 0 f do: call: "_spawn_spit" goto delay: "swim_spit" collmap "stand": ;; . . ;; *\*/* ;; . - + - . ;; */*\* ;; (.) . collmap "crawl": ;; . ;; * ;; (.) . $UNSET_BOOL RUNNING import "anim/_spider_stand.fus" state "look_up": rgraph: $PREFIX NS "look_up" hitbox: collmap("stand") if() then: goto: "looking_up" state "unlook_up": rgraph: $PREFIX NS "unlook_up" hitbox: collmap("stand") if() then: goto: "stand" state "looking_up": rgraph: $PREFIX NS "looking_up" hitbox: collmap("stand") if: key: wentdown y then: call: "looking_up_spit" if: key: wasdown u coll: all no ;; *\*/* ;; - + - ;; \* ;; ;; ;; ( ) then: move: 1 0 rot: 1 goto immediate: "start_jump" if: any: key: wasdown f key: wasdown b then: goto delay: "unlook_up" if: key: wasdown d coll: all yes # Can only crawl when there's an edge under you. # This is significant for stickyspider. ;; (.)- . then: goto delay: "crawling_looking_up" if: key: not isdown x then: goto delay: "unlook_up" state "spit": rgraph: $PREFIX NS "spit" hitbox: collmap("stand") if() then: goto: "stand" state "looking_up_spit": rgraph: $PREFIX NS "looking_up_spit" hitbox: collmap("stand") if() then: goto: "looking_up" state "turn": rgraph: $PREFIX NS "turn" hitbox: collmap("stand") # Jump if: key: wasdown u coll: all no ;; \*/* ;; + - ;; /*\* ;; ( ) then: move: 1 0 if: $IF DISABLE_RUNNING: false key: wasdown f then: goto immediate: $GET_STR STATE_RUN_START_JUMP else: goto immediate: $GET_STR STATE_START_JUMP if() then: goto immediate: "step" state "stop_running": # (Expected to be "goto immediate"'d to) # # We were running, but now we should stop somehow. # Try to take a (regular, non-running) step forwards, to give a sense # of inertia. # Step up if: any: all: expr: myvar("is_stickyspider") coll: all yes ;; + ;; ;; ( ) + all: not: expr: myvar("is_stickyspider") coll: all yes ;; + ;; / ;; ( ) + then: move: 1 0 rot: 1 goto delay: "step" # Step if: any: all: expr: myvar("is_stickyspider") coll: all yes ;; ( ) + + all: not: expr: myvar("is_stickyspider") coll: all yes ;; ( ) + - + coll: all no ;; \*/* ;; + - ;; /*\* ;; ( ) then: move: 1 0 goto delay: "step" # Step down if: any: all: expr: myvar("is_stickyspider") coll: all yes ;; ( ) + ;; ;; + all: not: expr: myvar("is_stickyspider") coll: all yes ;; ( ) + ;; \ ;; + coll: all no ;; \*/* ;; + - ;; /*\*/* ;; ( ) - + - ;; */*\* then: move: 1 0 rot: -1 goto delay: "step_down" # If we can't take a step forward, then just go to the non-running # "stand" state. if() then: goto: "stand" state "sleep": rgraph: $PREFIX NS "sleep" hitbox: collmap("crawl") if: any: key: wasdown u key: wasdown d key: wasdown l key: wasdown r then: goto: "crawl" $IF EYESPIDER: state "eye_closing": rgraph: $PREFIX NS "eye_closing" hitbox: collmap("stand") if() then: goto: "eye_closed" state "eye_unclosing": rgraph: $PREFIX NS "eye_unclosing" hitbox: collmap("stand") if() then: goto: "stand" state "eye_closed": rgraph: $PREFIX NS "eye_closed" hitbox: collmap("stand") if: key: not isdown x then: goto delay: "eye_unclosing" state "mostly_dead": rgraph: "dead_cycle" unsafe if() then: die mostly state "dead": rgraph: "dead_cycle" unsafe if() then: die import "anim/_spider_crawl.fus" import "anim/_spider_swim.fus" import "anim/_spider_run.fus"