- STEALTH -
@Stage\n\nwhen flag clicked\nbroadcast (setup v) and wait\nbroadcast (intro v)\nwait (1) seconds\nbroadcast (music:title:start v)\nreset timer\nrepeat until <(timer) > [4.9]>\n    set [brightness v] effect to (((timer) * (11)) - (50))\nend\nbroadcast (menu v) and wait\n\nwhen I receive [menu v]\nswitch backdrop to (menu background v)\nbroadcast (watermark v)\nrepeat until <(menu) = [False]>\n    set [can progress? v] to [0]\n    broadcast (progress v) and wait\n    wait until <(can progress?) = [1]>\nend\nwait (0.3) seconds\nbroadcast (storyline v) and wait\nswitch backdrop to (background v)\nbroadcast (music:title:stop v) and wait\nwait (0.3) seconds\nif <(level) > [10]> then\n    broadcast (music:game2:start v)\nelse\n    broadcast (music:game1:start v)\nend\nset [game active? v] to [0]\nbroadcast (render v) and wait\nif <(level) = [11]> then\n    if <(gamemode) = [2]> then\n        set [time left v] to [80]\n    else\n        set [time left v] to [120]\n    end\n    broadcast (start timer v)\nend\nset [game active? v] to [1]\nbroadcast (init game v) and wait\nbroadcast (begin v)\n\nwhen I receive [next v]\nset [game active? v] to [0]\nchange [level v] by (1)\nif <(level) > [13]> then\n    broadcast (music:game2:stop v)\n    broadcast (stop siren v)\n    broadcast (render:clear entities v) and wait\n    erase all\n    broadcast (cutscene v)\n    stop [this script v]\nelse\n    if <(level) > (max level)> then\n        set [max level v] to (level)\n    end\n    broadcast (render v) and wait\n    if <(level) = [11]> then\n        if <(item (2) of [sounds playing? v]) = [0]> then\n            broadcast (music:game1:stop v)\n            broadcast (music:game2:start v)\n        end\n        broadcast (start timer v)\n        set [player hp v] to [10]\n        if <(gamemode) = [2]> then\n            set [time left v] to [80]\n        else\n            set [time left v] to [120]\n        end\n    end\nend\nset [game active? v] to [1]\n\nwhen I receive [init game v]\nif <(gamemode) = [2]> then\n    set [guard speed v] to [1.5]\n    set [pad threshold v] to [12]\nend\n\nwhen I receive [intro v]\nset [brightness v] effect to (-100)\n\nwhen I receive [render v]\nset [rendering? v] to [1]\nbroadcast (show loading v) and wait\nbroadcast (render:switch maps v) and wait\nbroadcast (render:clear entities v) and wait\nbroadcast (render:terrain v) and wait\nbroadcast (render:entities v) and wait\nbroadcast (activate blackout v)\nif <(level) = [1]> then\n    broadcast (part1 v) and wait\nelse\n    if <(level) = [11]> then\n        broadcast (part2 v) and wait\n    end\nend\nbroadcast (hide loading v) and wait\nbroadcast (activate entities v)\nset [rendering? v] to [0]\n\nwhen I receive [setup v]\nclear graphic effects\nswitch backdrop to (menu background v)\nset [menu v] to [True]\nset [level v] to [1]\nset [max level v] to (level)\nset [pause v] to [0]\nset [game active? v] to [1]\nset [rendering? v] to [0]\nset [gamemode v] to [1]\nset [guard speed v] to [1]\nset [pad threshold v] to [10]\nset [menuscreen v] to [main]\nset [master volume v] to [100]\nset [music volume v] to [100]\nset [sound fx volume v] to [100]\nset [player hp v] to [10]\nset [time left v] to [120]\n\n@Player\n\nwhen I receive [begin v]\nreturn to start\nrepeat until <(level) > [13]>\n    physics\nend\nhide\n\ndefine touch ground <up?>\nchange [falling v] by (1)\nrepeat until <not <<touching (ground v)?> or <touching (doors v)?>>>\n    if <up?> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling v] to [0]\n    end\n    set [yv v] to [0]\nend\n\ndefine walk (speed) (direction)\nchange x by (speed)\npoint in direction (direction)\nset [slope v] to [0]\nrepeat until <<not <<touching (ground v)?> or <touching (doors v)?>>> or <(slope) = [4]>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <(slope) = [4]> then\n    change x by ((0) - (speed))\n    change y by ((0) - (slope))\n    set [xv v] to [0]\nend\nchange [frame v] by (0.25)\n\ndefine check bombs\nset [bombs activated? v] to [1]\nset [n v] to [0]\nrepeat (length of [bomb progress v])\n    change [n v] by (1)\n    if <not <(item (n) of [bomb progress v]) = (pad threshold)>> then\n        set [bombs activated? v] to [0]\n    end\nend\n\ndefine return to start\nswitch costume to (player v)\nshow\ngo to x: (-250) y: (-156)\npoint in direction (90)\nglide (0.5) secs to x: (-222) y: (-156)\nreset\n\ndefine reset\nswitch costume to (player v)\nset rotation style [left-right v]\npoint in direction (90)\nshow\nset [xv v] to [0]\nset [yv v] to [0]\nset [jump height v] to [11]\nset [speed v] to [2]\nset [gravity v] to [1]\nset [falling v] to [0]\nset [reset? v] to [0]\nset [the guard pos v] to [0]\nbroadcast (hide ! v)\n\ndefine set costume\nif <([abs v] of (xv) ) > [0.5]> then\n    switch costume to ([floor v] of (((frame) mod (4)) + (2)) )\nelse\n    switch costume to (player v)\nend\n\nwhen I receive [menu v]\nstop [other scripts in sprite v]\nreset\nhide\n\nwhen I receive [explosion has happened v]\nreturn to start\n\nwhen I receive [setup v]\nreset\nhide\n\ndefine physics\nswitch costume to (hitbox v)\nchange [yv v] by ((0) - (gravity))\nchange y by (yv)\ntouch ground <(yv) > [0]>\nif <(pause) > [0]> then\n    change [pause v] by (-1)\nelse\n    if <(game active?) = [1]> then\n        if <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n            change [xv v] by ((0) - (speed))\n        end\n        if <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n            change [xv v] by (speed)\n        end\n    end\nend\nset [xv v] to ((xv) * (0.7))\nif <(xv) > [0.5]> then\n    walk (xv) (90)\nelse\n    if <(xv) < [-0.5]> then\n        walk (xv) (-90)\n    else\n        set [frame v] to [0]\n    end\nend\nif <<(pause) = [0]> and <(game active?) = [1]>> then\n    if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n        if <<(falling) < [3]> and <(jump key) = [0]>> then\n            set [yv v] to (jump height)\n            set [falling v] to [6]\n            set [jump key v] to [1]\n        else\n            set [jump key v] to [0]\n        end\n    end\nend\nif <<<touching (torches v)?> or <not <(player hp) > [0]>>> and <(reset?) = [0]>> then\n    if <not <(player hp) > [0]>> then\n        set [level v] to [10]\n        set [player hp v] to [10]\n        broadcast (next v)\n        return to start\n    else\n        broadcast (player been caught v)\n        set [pause v] to [50]\n        set [reset? v] to [1]\n    end\nend\nif <<(reset?) = [1]> and <(pause) = [0]>> then\n    return to start\nend\nif <(x position) > [235]> then\n    if <(length of [bomb progress v]) > [0]> then\n        check bombs\n        if <(bombs activated?) = [1]> then\n            broadcast (next v)\n            return to start\n        end\n    else\n        broadcast (next v)\n        return to start\n    end\nend\nif <<((frame) mod (2)) = [0]> and <(frame) > [0]>> then\n    if <(falling) < [3]> then\n        broadcast (footstep v)\n    end\nend\nset costume\n\n@Guard\n\nwhen I receive [render:entities v]\nset [#cloneid v] to [0]\nrepeat (length of [guard pos v])\n    change [#cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nset [#cloneid v] to [-1]\n\nwhen I start as a clone\nswitch costume to (guard v)\nset [my level v] to (level)\nget coords (item (#CloneID) of [guard pos v])\ngo to x: (x) y: (y)\npoint in direction (90)\nshow\n\ndefine at edge?\nset [at edge:return v] to [1]\nmove (tile width) steps\nchange y by (-2)\nif <<touching (ground v)?> or <touching (doors v)?>> then\n    set [at edge:return v] to [0]\nend\nchange y by (2)\nmove ((0) - (tile width)) steps\n\ndefine delete clones\nset [#cloneid v] to [0]\ndelete this clone\n\nwhen I receive [render:clear entities v]\ndelete clones\ndelete (all) of [guard pos v]\n\ndefine at wall?\nset [at wall:return v] to [0]\nmove (tile width) steps\nif <<touching (ground v)?> or <touching (doors v)?>> then\n    set [at wall:return v] to [1]\nend\nmove ((0) - (tile width)) steps\n\ndefine None\nset [pos v] to (join ((round (x)) + (500)) ((round (y)) + (500)))\n\nwhen I receive [activate entities v]\nrepeat until <not <(my level) = (level)>>\n    if <<(pause) = [0]> and <(game active?) = [1]>> then\n        move\n    end\nend\ndelete clones\n\ndefine move\nswitch costume to (hitbox v)\nat wall?\nif <(at wall:return) = [1]> then\n    point in direction ((direction) * (-1))\nelse\n    at edge?\n    if <(at edge:return) = [1]> then\n        point in direction ((direction) * (-1))\n    end\nend\nmove (guard speed) steps\nchange [frame v] by (0.15)\nswitch costume to ([floor v] of (((frame) mod (4)) + (2)) )\njoin coords (x position) (y position)\nreplace item (#CloneID) of [guard pos v] with ((pos) * ((direction) / (90)))\n\nwhen I receive [setup v]\ndelete clones\ndelete (all) of [guard pos v]\nhide\n\ndefine None\nset [x v] to ((join (letter (1) of (pos)) (join (letter (2) of (pos)) (letter (3) of (pos)))) - (500))\nset [y v] to ((join (letter (4) of (pos)) (join (letter (5) of (pos)) (letter (6) of (pos)))) - (500))\n\nwhen I receive [menu v]\ndelete clones\ndelete (all) of [guard pos v]\nhide\n\n@Hostile Guard\n\nwhen I receive [render:entities v]\nset [#cloneid v] to [0]\nrepeat (length of [hguard pos v])\n    change [#cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nset [#cloneid v] to [-1]\n\nwhen I start as a clone\nswitch costume to (guard v)\nset [timer v] to (pick random (0) to (80))\nset [my level v] to (level)\nget coords (item (#CloneID) of [hguard pos v])\ngo to x: (x) y: (y)\ninsert [0] at (#CloneID) of [projectile data v] \npoint in direction (90)\nshow\n\ndefine at edge?\nset [at edge:return v] to [1]\nmove ((tile width) + ((guard speed) + (1))) steps\nchange y by (-2)\nif <<touching (ground v)?> or <touching (doors v)?>> then\n    set [at edge:return v] to [0]\nend\nchange y by (2)\nmove ((0) - ((tile width) + ((guard speed) + (1)))) steps\n\ndefine delete clones\nset [#cloneid v] to [0]\ndelete this clone\n\nwhen I receive [setup v]\ndelete clones\ndelete (all) of [hguard pos v]\ndelete (all) of [projectile data v]\nhide\n\ndefine None\nset [x v] to ((join (letter (1) of (pos)) (join (letter (2) of (pos)) (letter (3) of (pos)))) - (500))\nset [y v] to ((join (letter (4) of (pos)) (join (letter (5) of (pos)) (letter (6) of (pos)))) - (500))\n\nwhen I receive [render:clear entities v]\ndelete clones\ndelete (all) of [hguard pos v]\ndelete (all) of [projectile data v]\n\ndefine None\nset [pos v] to (join ((round (x)) + (500)) ((round (y)) + (500)))\n\ndefine can shoot? <>\nif <condition> then\n    set [timer v] to [0]\n    replace item (#CloneID) of [projectile data v] with [1]\nelse\n    change [timer v] by (pick random (0.25) to (1.75))\nend\n\nwhen I receive [activate entities v]\nrepeat until <not <(my level) = (level)>>\n    if <<(pause) = [0]> and <(game active?) = [1]>> then\n        move\n        can shoot? <(timer) > [80]>\n    end\nend\ndelete clones\n\ndefine at wall?\nset [at wall:return v] to [0]\nmove ((tile width) + ((guard speed) + (1))) steps\nif <<touching (ground v)?> or <touching (doors v)?>> then\n    set [at wall:return v] to [1]\nend\nmove ((0) - ((tile width) + ((guard speed) + (1)))) steps\n\ndefine move\nswitch costume to (hitbox v)\nif <(x position) > ([x position v] of [player v])> then\n    point in direction (-90)\nelse\n    point in direction (90)\nend\nat wall?\nat edge?\nswitch costume to ([floor v] of (((frame) mod (4)) + (2)) )\nif <<(at wall:return) = [0]> and <(at edge:return) = [0]>> then\n    if <([abs v] of ((x position) - ([x position v] of [player v])) ) > [4]> then\n        move ((guard speed) + (1)) steps\n        change [frame v] by (0.15)\n    else\n        switch costume to (guard v)\n    end\nend\njoin coords (x position) (y position)\nreplace item (#CloneID) of [hguard pos v] with (pos)\n\nwhen I receive [menu v]\ndelete clones\ndelete (all) of [hguard pos v]\ndelete (all) of [projectile data v]\nhide\n\n@Render\n\ndefine setup\nset [screen width v] to [480]\nset [screen height v] to [360]\nset [tile width v] to [12]\nset [tile height v] to [12]\nset [tiles row v] to ([floor v] of ((screen width) / (tile width)) )\nset [tiles column v] to ([floor v] of ((screen height) / (tile height)) )\nset [total tiles v] to ((tiles row) * (tiles column))\n\ndefine upload\nshow\ngo to x: (((tile width) / (2)) - ((screen width) / (2))) y: (((tile height) / (2)) - ((screen height) / (2)))\nset size to (100) %\nbroadcast (upload:show v) and wait\nrepeat (tiles column)\n    repeat (tiles row)\n        switch costume to (render v)\n        if <touching color (#000000)?> then\n            switch costume to (ground1 v)\n        else\n            if <touching color (#0f0f0f)?> then\n                switch costume to (ground2 v)\n            else\n                if <touching color (#1f1f1f)?> then\n                    switch costume to (ground3 v)\n                else\n                    if <touching color (#2f2f2f)?> then\n                        switch costume to (ground4 v)\n                    else\n                        if <touching color (#3f3f3f)?> then\n                            switch costume to (ground5 v)\n                        else\n                            if <touching color (#4f4f4f)?> then\n                                switch costume to (ground6 v)\n                            else\n                                if <touching color (#5f5f5f)?> then\n                                    switch costume to (ground7 v)\n                                else\n                                    if <touching color (#6f6f6f)?> then\n                                        switch costume to (ground8 v)\n                                    else\n                                        if <touching color (#7f7f7f)?> then\n                                            switch costume to (ground9 v)\n                                        else\n                                            if <touching color (#8f8f8f)?> then\n                                                switch costume to (ground10 v)\n                                            else\n                                                if <touching color (#9f9f9f)?> then\n                                                    switch costume to (ground11 v)\n                                                else\n                                                    if <touching color (#afafaf)?> then\n                                                        switch costume to (ground12 v)\n                                                    else\n                                                        if <touching color (#bfbfbf)?> then\n                                                            switch costume to (ground13 v)\n                                                        else\n                                                            if <touching color (#cfcfcf)?> then\n                                                                switch costume to (ground14 v)\n                                                            else\n                                                                if <touching color (#dfdfdf)?> then\n                                                                    switch costume to (ground15 v)\n                                                                else\n                                                                    if <touching color (#efefef)?> then\n                                                                        switch costume to (ground16 v)\n                                                                    else\n                                                                        if <touching color (#684000)?> then\n                                                                            switch costume to (crate v)\n                                                                        else\n                                                                            if <touching color (#ff00bf)?> then\n                                                                                switch costume to (guard v)\n                                                                            else\n                                                                                if <touching color (#ff0000)?> then\n                                                                                    switch costume to (keypad v)\n                                                                                else\n                                                                                    if <touching color (#00ff55)?> then\n                                                                                        switch costume to (door v)\n                                                                                    else\n                                                                                        if <touching color (#003fff)?> then\n                                                                                            switch costume to (bomb v)\n                                                                                        else\n                                                                                            if <touching color (#ffff99)?> then\n                                                                                                switch costume to (cool looking thing v)\n                                                                                            else\n                                                                                                if <touching color (#ff9400)?> then\n                                                                                                    switch costume to (girder v)\n                                                                                                else\n                                                                                                    if <touching color (#ffd499)?> then\n                                                                                                        switch costume to (girder1 v)\n                                                                                                    else\n                                                                                                        if <touching color (#ffe9cc)?> then\n                                                                                                            switch costume to (girder2 v)\n                                                                                                        else\n                                                                                                            if <touching color (#001966)?> then\n                                                                                                                switch costume to (hguard v)\n                                                                                                            else\n                                                                                                            end\n                                                                                                        end\n                                                                                                    end\n                                                                                                end\n                                                                                            end\n                                                                                        end\n                                                                                    end\n                                                                                end\n                                                                            end\n                                                                        end\n                                                                    end\n                                                                end\n                                                            end\n                                                        end\n                                                    end\n                                                end\n                                            end\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n        add ((costume [number v]) - (1)) to [level data v]\n        change x by (tile width)\n    end\n    change y by (tile height)\n    set x to (((tile width) / (2)) - ((screen width) / (2)))\nend\nbroadcast (upload:hide v)\nhide\n\nwhen I receive [setup v]\nerase all\nhide\nsetup\n\ndefine upload all\nbroadcast (setup v) and wait\nswitch backdrop to (render v)\ndelete (all) of [level data v]\nbroadcast (upload:reset maps v) and wait\nrepeat (13)\n    upload\n    broadcast (upload:progress v) and wait\nend\n\ndefine load level data\ndelete (all) of [_level v]\nset [load data marker v] to (((level) - (1)) * (total tiles))\nrepeat until <(length of [_level v]) = (total tiles)>\n    insert [0] at (last) of [_level v] \n    change [load data marker v] by (1)\n    if <not <((item (load data marker) of [level data v]) mod (length of [level data v])) = [0]>> then\n        replace item (last) of [_level v] with ((item (load data marker) of [level data v]) mod (length of [level data v]))\n    end\nend\n\nwhen I receive [render:terrain v]\nrender\n\ndefine render\nload level data\nshow\ngo to x: (((tile width) / (2)) - ((screen width) / (2))) y: (((tile height) / (2)) - ((screen height) / (2)))\nset size to (100) %\nerase all\nset [load marker v] to [0]\nrepeat (length of [_level v])\n    change [load marker v] by (1)\n    if <not <(item (load marker) of [_level v]) = [0]>> then\n        if <(item (load marker) of [_level v]) = [18]> then\n            join coords (x position) (y position)\n            add (pos) to [guard pos v]\n        else\n            if <(item (load marker) of [_level v]) = [19]> then\n                join coords (x position) (y position)\n                add (pos) to [pad pos v]\n            else\n                if <(item (load marker) of [_level v]) = [20]> then\n                    join coords (x position) (y position)\n                    add (pos) to [door pos v]\n                else\n                    if <(item (load marker) of [_level v]) = [21]> then\n                        join coords (x position) (y position)\n                        add (pos) to [bomb pos v]\n                    else\n                        if <(item (load marker) of [_level v]) = [22]> then\n                            change y by (114)\n                            change x by (6)\n                            switch costume to (cool looking thing v)\n                            stamp\n                            change y by (-114)\n                            change x by (-6)\n                        else\n                            if <(item (load marker) of [_level v]) = [26]> then\n                                join coords (x position) (y position)\n                                add (pos) to [hguard pos v]\n                            else\n                                switch costume to ((item (load marker) of [_level v]) + (1))\n                                stamp\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    change x by (tile width)\n    if <((load marker) mod (tiles row)) = [0]> then\n        change y by (tile height)\n        set x to (((tile width) / (2)) - ((screen width) / (2)))\n    end\nend\nhide\n\ndefine None\nset [pos v] to (join ((x) + (500)) ((y) + (500)))\n\nwhen I receive [menu v]\nerase all\nhide\nsetup\n\n@Render Map\n\nwhen I receive [setup v]\ngo to x: (0) y: (0)\nswitch costume to (level 1 v)\nhide\n\nwhen I receive [upload:hide v]\nhide\n\nwhen I receive [upload:show v]\nshow\n\nwhen I receive [upload:progress v]\nnext costume\n\nwhen I receive [upload:reset maps v]\nswitch costume to (level 1 v)\n\n@Ground\n\nwhen I receive [init game v]\nset [ghost v] effect to (100)\nshow\n\nwhen I receive [setup v]\nswitch costume to (level 1 v)\ngo to x: (0) y: (0)\nhide\n\nwhen I receive [render:switch maps v]\nswitch costume to (level)\n\nwhen I receive [menu v]\nswitch costume to (level 1 v)\ngo to x: (0) y: (0)\nhide\n\nwhen I receive [cutscene v]\nswitch costume to (level 1 v)\ngo to x: (0) y: (0)\nhide\n\n@Sound engine\n\nwhen I receive [music:game2:start v]\nif <(sound) = [0]> then\n    set [loop? v] to [1]\n    set [sound v] to [2]\n    create clone of (_myself_ v)\n    set [sound v] to [0]\n    set [loop? v] to [0]\nend\n\nwhen I receive [setup v]\nset [sound v] to [0]\nstop all sounds\ndelete (all) of [sounds playing? v]\nrepeat (15)\n    add [0] to [sounds playing? v]\nend\n\nwhen I receive [music:title:start v]\nif <(sound) = [0]> then\n    set [loop? v] to [1]\n    set [sound v] to [1]\n    create clone of (_myself_ v)\n    set [sound v] to [0]\n    set [loop? v] to [0]\nend\n\nwhen I receive [footstep v]\nif <(sound) = [0]> then\n    set [sound v] to [4]\n    create clone of (_myself_ v)\n    set [sound v] to [0]\nend\n\nwhen I receive [activate entities v]\nif <(sound) = [0]> then\n    if <(length of [guard pos v]) > [0]> then\n        set [loop? v] to [1]\n        set [sound v] to [5]\n        create clone of (_myself_ v)\n        set [sound v] to [0]\n        set [loop? v] to [0]\n    end\nend\n\nwhen I receive [activate entities v]\nif <(sound) = [0]> then\n    if <(level) = [10]> then\n        set [loop? v] to [1]\n        set [sound v] to [6]\n        create clone of (_myself_ v)\n        set [sound v] to [0]\n        set [loop? v] to [0]\n    end\nend\n\nwhen I receive [door open v]\nif <(sound) = [0]> then\n    set [sound v] to [7]\n    create clone of (_myself_ v)\n    set [sound v] to [0]\nend\n\nwhen I receive [music:game1:stop v]\nif <(sound) = [3]> then\n    stop [other scripts in sprite v]\n    replace item (sound) of [sounds playing? v] with [0]\n    delete this clone\nend\n\nwhen I receive [music:title:stop v]\nif <(sound) = [1]> then\n    stop [other scripts in sprite v]\n    replace item (sound) of [sounds playing? v] with [0]\n    delete this clone\nend\n\nwhen I receive [render:clear entities v]\nif <<(sound) > [3]> and <not <(sound) = [11]>>> then\n    stop [other scripts in sprite v]\n    replace item (sound) of [sounds playing? v] with [0]\n    delete this clone\nend\n\nwhen I receive [bomb activate v]\nif <(sound) = [0]> then\n    set [sound v] to [8]\n    create clone of (_myself_ v)\n    set [sound v] to [0]\nend\n\nwhen I receive [music:game2:stop v]\nif <(sound) = [2]> then\n    stop [other scripts in sprite v]\n    replace item (sound) of [sounds playing? v] with [0]\n    delete this clone\nend\n\nwhen I receive [siren v]\nif <(sound) = [0]> then\n    set [loop? v] to [1]\n    set [sound v] to [11]\n    create clone of (_myself_ v)\n    set [sound v] to [0]\n    set [loop? v] to [0]\nend\n\nwhen I receive [start timer v]\nif <(sound) = [0]> then\n    if <(item (11) of [sounds playing? v]) = [0]> then\n        broadcast (siren v)\n    end\nend\n\ndefine get closest light\nset [closest light index v] to [1]\nset [n v] to [0]\nrepeat (length of [light_dist v])\n    change [n v] by (1)\n    if <(item (n) of [light_dist v]) < (item (closest light index) of [light_dist v])> then\n        set [closest light index v] to (n)\n    end\nend\n\nwhen I start as a clone\nforever\n    replace item (sound) of [sounds playing? v] with [1]\n    if <(sound) > [3]> then\n        if <(sound) = [5]> then\n            get closest light\n            set volume to (((((25) / (item (closest light index) of [light_dist v])) * (sound fx volume)) / (100)) * (master volume)) %\n        else\n            set volume to (((sound fx volume) / (100)) * (master volume)) %\n        end\n    else\n        set volume to (((music volume) / (100)) * (master volume)) %\n    end\nend\n\nwhen I receive [bullet v]\nif <(sound) = [0]> then\n    set [sound v] to [9]\n    create clone of (_myself_ v)\n    set [sound v] to [0]\n    wait (pick random (0.4) to (0.7)) seconds\n    if <(menuscreen) = [game]> then\n        set [sound v] to [10]\n        create clone of (_myself_ v)\n        set [sound v] to [0]\n    end\nend\n\nwhen I start as a clone\nplay sound (sound) until done\nif <(loop?) = [1]> then\n    create clone of (_myself_ v)\n    delete this clone\nend\nstop [other scripts in sprite v]\nreplace item (sound) of [sounds playing? v] with [0]\ndelete this clone\n\nwhen I receive [stop siren v]\nif <(sound) = [11]> then\n    stop [other scripts in sprite v]\n    replace item (sound) of [sounds playing? v] with [0]\n    delete this clone\nend\n\nwhen I receive [explosion v]\nif <(sound) = [0]> then\n    set [sound v] to [12]\n    create clone of (_myself_ v)\n    set [sound v] to [0]\nend\n\nwhen I receive [slide1 v]\nif <(sound) = [0]> then\n    set [sound v] to [13]\n    create clone of (_myself_ v)\n    set [sound v] to [0]\nend\n\nwhen I receive [stop slide3 v]\nif <(sound) = [15]> then\n    stop [other scripts in sprite v]\n    replace item (sound) of [sounds playing? v] with [0]\n    delete this clone\nend\n\nwhen I receive [stop slide2 v]\nif <(sound) = [14]> then\n    stop [other scripts in sprite v]\n    replace item (sound) of [sounds playing? v] with [0]\n    delete this clone\nend\n\nwhen I receive [music:game1:start v]\nif <(sound) = [0]> then\n    set [loop? v] to [1]\n    set [sound v] to [3]\n    create clone of (_myself_ v)\n    set [sound v] to [0]\n    set [loop? v] to [0]\nend\n\nwhen I receive [slide3 v]\nif <(sound) = [0]> then\n    set [sound v] to [15]\n    create clone of (_myself_ v)\n    set [sound v] to [0]\nend\n\nwhen I receive [stop slide1 v]\nif <(sound) = [13]> then\n    stop [other scripts in sprite v]\n    replace item (sound) of [sounds playing? v] with [0]\n    delete this clone\nend\n\nwhen I receive [stop torch v]\nif <(sound) = [5]> then\n    stop [other scripts in sprite v]\n    replace item (sound) of [sounds playing? v] with [0]\n    delete this clone\nend\n\nwhen I receive [slide2 v]\nif <(sound) = [0]> then\n    set [sound v] to [14]\n    create clone of (_myself_ v)\n    set [sound v] to [0]\nend\n\nwhen I receive [outro voice v]\nif <(sound) = [0]> then\n    set [sound v] to [16]\n    create clone of (_myself_ v)\n    set [sound v] to [0]\nend\n\n@Blackout\n\ndefine None\nswitch costume to (costume1 v)\nset size to (n) %\nswitch costume to (mask v)\n\nwhen I receive [setup v]\nset size to (225) \%\nswitch costume to (mask v)\ngo to [front v] layer\nhide\n\nwhen I receive [activate blackout v]\nif <(level) < [14]> then\n    go to x: (-250) y: (-156)\n    show\nend\n\nwhen I receive [begin v]\ngo to [front v] layer\nrepeat until <(level) > [13]>\n    go to (player v)\nend\nhide\n\nwhen I receive [menu v]\nset size to (225) \%\nstop [other scripts in sprite v]\nswitch costume to (mask v)\ngo to [front v] layer\nhide\n\n@Whiteout\n\nwhen I receive [setup v]\ngo to x: (0) y: (0)\nhide\n\nwhen I receive [time up v]\nbroadcast (stop siren v)\nset [game active? v] to [0]\nset [ghost v] effect to (100)\nshow\ngo to [front v] layer\nbroadcast (explosion v)\nrepeat (50)\n    change [ghost v] effect by (-2)\nend\nbroadcast (explosion has happened v)\ngo to [front v] layer\nwait (1) seconds\nrepeat (20)\n    change [ghost v] effect by (4)\nend\nhide\n\n@Level Text\n\nwhen I receive [begin v]\ngo to [front v] layer\nrepeat until <(level) > [13]>\n    go to [front v] layer\n    switch costume to (level)\n    set [ghost v] effect to (((100) / (distance to [player v])) * (100))\n    go to x: (((0) - ([x position v] of [player v])) / (5)) y: (((0) - ([y position v] of [player v])) / (5))\n    if <<(rendering?) = [0]> and <(game active?) = [1]>> then\n        show\n    else\n        hide\n    end\nend\nhide\n\nwhen I receive [activate blackout v]\nif <(level) < [14]> then\n    switch costume to (level)\n    go to x: (((0) - ([x position v] of [player v])) / (5)) y: (((0) - ([y position v] of [player v])) / (5))\n    show\nend\n\nwhen I receive [setup v]\nswitch costume to (level)\ngo to [front v] layer\nhide\n\nwhen I receive [menu v]\nstop [other scripts in sprite v]\nswitch costume to (level)\ngo to [front v] layer\nhide\n\n@Timer\n\nwhen I receive [setup v]\ndelete clones\nhide\n\ndefine delete clones\nset [#cloneid v] to [0]\ndelete this clone\n\nwhen I receive [activate entities v]\nif <(#CloneID) > [0]> then\n    repeat until <(level) > [13]>\n        if <<(rendering?) = [0]> and <(game active?) = [1]>> then\n            show\n        else\n            hide\n        end\n        go to x: ((((#CloneID) - (1)) * (10)) - (230)) y: (160)\n        go to [front v] layer\n        if <(#CloneID) = [1]> then\n            if <(length of (time left)) = [3]> then\n                switch costume to (letter (1) of (time left))\n            else\n                switch costume to (0 v)\n            end\n        else\n            if <(#CloneID) = [2]> then\n                if <(length of (time left)) = [2]> then\n                    switch costume to (letter (1) of (time left))\n                else\n                    if <(length of (time left)) = [3]> then\n                        switch costume to (letter (2) of (time left))\n                    else\n                        switch costume to (0 v)\n                    end\n                end\n            else\n                switch costume to (letter (length of (time left)) of (time left))\n            end\n        end\n    end\n    delete clones\nend\n\nwhen I receive [render:entities v]\nif <(level) = [11]> then\n    set [#cloneid v] to [0]\n    repeat (3)\n        change [#cloneid v] by (1)\n        create clone of (_myself_ v)\n    end\n    set [#cloneid v] to [0]\nend\n\nwhen I receive [start timer v]\nif <(#CloneID) = [0]> then\n    repeat until <(time left) = [0]>\n        wait until <(game active?) = [1]>\n        wait (1) seconds\n        change [time left v] by (-1)\n    end\n    broadcast (time up v)\nend\n\nwhen I receive [render:clear entities v]\nif <not <(level) > [11]>> then\n    delete clones\nend\n\nwhen I start as a clone\ngo to x: ((((#CloneID) - (1)) * (10)) - (235)) y: ((((#CloneID) - (1)) * (10)) + (175))\nswitch costume to (0 v)\nshow\n\n@Health Bar\n\nwhen I receive [setup v]\nswitch costume to (10 v)\nset [active? v] to [0]\nhide\n\nwhen I receive [activate entities v]\nswitch costume to (10 v)\nif <(level) > [10]> then\n    show\n    repeat until <(level) > [13]>\n        go to x: ([x position v] of [player v]) y: (([y position v] of [player v]) + (34))\n        if <not <(player hp) < [0]>> then\n            switch costume to ([floor v] of ((((player hp) / (10)) * (100)) / (10)) )\n        else\n            switch costume to (0 v)\n        end\n    end\n    hide\nend\n\n@Torches\n\ndefine delete clones\nset [#cloneid v] to [0]\ndelete this clone\n\nwhen I receive [setup v]\ndelete (all) of [light_dist v]\ndelete clones\nhide\n\nwhen I receive [render:clear entities v]\ndelete (all) of [light_dist v]\ndelete clones\n\nwhen I start as a clone\nset [my level v] to (level)\nget coords (item (#CloneID) of [guard pos v])\ninsert [0] at (#CloneID) of [light_dist v] \nset [ghost v] effect to (50)\ngo to x: (x) y: ((y) + (6))\npoint in direction (90)\nshow\n\nwhen I receive [render:entities v]\nset [#cloneid v] to [0]\nrepeat (length of [guard pos v])\n    change [#cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nset [#cloneid v] to [-1]\n\nwhen I receive [activate entities v]\nrepeat until <not <(my level) = (level)>>\n    get coords ([abs v] of (item (#CloneID) of [guard pos v]) )\n    go to x: (x) y: ((y) + (6))\n    if <(item (#CloneID) of [guard pos v]) > [0]> then\n        point in direction (90)\n    else\n        point in direction (-90)\n    end\n    replace item (#CloneID) of [light_dist v] with ([sqrt v] of ((((x position) - ([x position v] of [player v])) * ((x position) - ([x position v] of [player v]))) + (((([y position v] of [player v]) - (y position)) * (([y position v] of [player v]) - (y position))) + (144))) )\nend\ndelete clones\n\ndefine get coords (pos)\nset [x v] to ((join (letter (1) of (pos)) (join (letter (2) of (pos)) (letter (3) of (pos)))) - (500))\nset [y v] to ((join (letter (4) of (pos)) (join (letter (5) of (pos)) (letter (6) of (pos)))) - (500))\n\nwhen I receive [player been caught v]\nif <touching (player v)?> then\n    set [the guard pos v] to (join ((x position) + (500)) ((y position) + (500)))\n    broadcast (show ! v)\nend\n\n@Arm\n\nwhen I receive [setup v]\ndelete clones\nhide\n\nwhen I receive [render:entities v]\nset [#cloneid v] to [0]\nrepeat (length of [hguard pos v])\n    change [#cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nset [#cloneid v] to [0]\n\nwhen I start as a clone\nswitch costume to (arm v)\nset [my level v] to (level)\nget coords (item (#CloneID) of [hguard pos v])\ngo to x: (x) y: ((y) + (8))\npoint in direction (90)\nshow\n\nwhen I receive [activate entities v]\nrepeat until <not <(my level) = (level)>>\n    if <<(pause) = [0]> and <(game active?) = [1]>> then\n        get coords (item (#CloneID) of [hguard pos v])\n        go to x: (x) y: ((y) + (8))\n        point towards ([x position v] of [player v]) (([y position v] of [player v]) + (16))\n        if <([x position v] of [player v]) > (x position)> then\n            switch costume to (arm v)\n        else\n            switch costume to (arm2 v)\n        end\n    end\nend\ndelete clones\n\ndefine None\nset [dir v] to ([atan v] of (((y position) - (y)) / ((x) - (x position))) )\nif <((x) - (x position)) < [0]> then\n    change [dir v] by (180)\nelse\n    if <(dir) < [0]> then\n        change [dir v] by (1)\n    end\nend\nchange [dir v] by (90)\npoint in direction (dir)\n\ndefine None\nset [x v] to ((join (letter (1) of (num)) (join (letter (2) of (num)) (letter (3) of (num)))) - (500))\nset [y v] to ((join (letter (4) of (num)) (join (letter (5) of (num)) (letter (6) of (num)))) - (500))\n\ndefine delete clones\nset [#cloneid v] to [0]\ndelete this clone\n\nwhen I receive [render:clear entities v]\ndelete clones\n\nwhen I receive [menu v]\ndelete clones\nhide\n\n@Projectile\n\nwhen I receive [setup v]\ndelete clones\nhide\n\ndefine delete clones\nset [#cloneid v] to [0]\ndelete this clone\n\nwhen I receive [activate entities v]\nset [my level v] to (level)\nrepeat until <not <(my level) = (level)>>\n    if <[projectile data v] contains [1]?> then\n        find index\n        create clone of (_myself_ v)\n        set [#cloneid v] to [0]\n    end\nend\n\ndefine find index\nset [n v] to [0]\nrepeat until <(item (n) of [projectile data v]) = [1]>\n    change [n v] by (1)\n    if <(n) > (length of [projectile data v])> then\n        set [n v] to [0]\n        stop [this script v]\n    end\nend\nset [#cloneid v] to (n)\nreplace item (#CloneID) of [projectile data v] with [0]\n\nwhen I start as a clone\nbroadcast (bullet v)\nget pos (item (#CloneID) of [hguard pos v])\ngo to x: (x) y: ((y) + (8))\npoint towards ([x position v] of [player v]) (([y position v] of [player v]) + (16))\nshow\nrepeat until <<touching (player v)?> or <<touching (ground v)?> or <touching (_edge_ v)?>>>\n    move (8) steps\nend\nif <touching (player v)?> then\n    change [player hp v] by (-3)\nend\ndelete this clone\n\ndefine None\nset [x v] to ((join (letter (1) of (num)) (join (letter (2) of (num)) (letter (3) of (num)))) - (500))\nset [y v] to ((join (letter (4) of (num)) (join (letter (5) of (num)) (letter (6) of (num)))) - (500))\n\ndefine None\nset [dir v] to ([atan v] of (((y position) - (y)) / ((x) - (x position))) )\nif <((x) - (x position)) < [0]> then\n    change [dir v] by (180)\nelse\n    if <(dir) < [0]> then\n        change [dir v] by (1)\n    end\nend\nchange [dir v] by (90)\npoint in direction (dir)\n\n@!\n\nwhen I receive [setup v]\nset [the guard pos v] to [0]\nhide\n\ndefine None\nset [x v] to ((join (letter (1) of (pos)) (join (letter (2) of (pos)) (letter (3) of (pos)))) - (500))\nset [y v] to ((join (letter (4) of (pos)) (join (letter (5) of (pos)) (letter (6) of (pos)))) - (500))\n\nwhen I receive [show ! v]\nwait until <not <(the guard pos) = [0]>>\nget coords (the guard pos)\ngo to x: (x) y: (y)\nset [ghost v] effect to (100)\nshow\nrepeat (5)\n    change [ghost v] effect by (-20)\n    change y by (6)\nend\n\nwhen I receive [hide ! v]\nset [the guard pos v] to [0]\nhide\n\n@keypad\n\nwhen I receive [render:clear entities v]\ndelete clones\ndelete (all) of [pad pos v]\ndelete (all) of [pad progress v]\nhide\n\ndefine None\nset [x v] to ((join (letter (1) of (pos)) (join (letter (2) of (pos)) (letter (3) of (pos)))) - (500))\nset [y v] to ((join (letter (4) of (pos)) (join (letter (5) of (pos)) (letter (6) of (pos)))) - (500))\n\nwhen I receive [setup v]\ndelete clones\ndelete (all) of [pad pos v]\ndelete (all) of [pad progress v]\nhide\n\ndefine delete clones\nset [#cloneid v] to [0]\ndelete this clone\n\nwhen I receive [render:entities v]\nset [#cloneid v] to [0]\nrepeat (length of [pad pos v])\n    change [#cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nset [#cloneid v] to [-1]\n\nwhen I receive [activate entities v]\nrepeat until <not <(my level) = (level)>>\n    if <(item (#CloneID) of [pad progress v]) < (pad threshold)> then\n        if <<<([x position v] of [player v]) > ((x position) - (10))> and <([x position v] of [player v]) < ((x position) + (10))>> and <<([y position v] of [player v]) > ((y position) - (24))> and <([y position v] of [player v]) < ((y position) + (4))>>> then\n            say [Press space!]\n            if <key (space v) pressed?> then\n                replace item (#CloneID) of [pad progress v] with ((item (#CloneID) of [pad progress v]) + (1))\n                wait until <not <key (space v) pressed?>>\n            end\n        else\n            say []\n        end\n    else\n        if <(played sound?) = [0]> then\n            broadcast (door open v)\n            broadcast (bomb activate v)\n            set [played sound? v] to [1]\n        end\n        say []\n        switch costume to (keypad2 v)\n    end\nend\ndelete clones\n\nwhen I start as a clone\ninsert [0] at (#CloneID) of [pad progress v] \nset [my level v] to (level)\nget coords (item (#CloneID) of [pad pos v])\nset [played sound? v] to [0]\ngo to x: (x) y: (y)\nswitch costume to (keypad v)\ngo [backward v] (50) layers\nshow\n\nwhen I receive [menu v]\ndelete clones\ndelete (all) of [pad pos v]\ndelete (all) of [pad progress v]\nhide\n\n@Progress bar\n\nwhen I receive [render:entities v]\nset [type v] to [1]\nset [#cloneid v] to [0]\nrepeat (length of [pad pos v])\n    change [#cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nset [type v] to [2]\nset [#cloneid v] to [0]\nrepeat (length of [bomb pos v])\n    change [#cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nset [#cloneid v] to [-1]\n\nwhen I receive [render:clear entities v]\ndelete clones\n\nwhen I receive [setup v]\ndelete clones\nhide\n\ndefine delete clones\nset [#cloneid v] to [0]\ndelete this clone\n\nwhen I start as a clone\nset [my level v] to (level)\nif <(type) = [1]> then\n    get coords (item (#CloneID) of [pad pos v])\nelse\n    get coords (item (#CloneID) of [bomb pos v])\nend\ngo to x: (x) y: ((y) + (12))\nswitch costume to (progress bar v)\ngo [backward v] (50) layers\nif <(type) = [1]> then\n    set [ghost v] effect to ((((item (#CloneID) of [pad progress v]) / (pad threshold)) * (-100)) + (100))\nelse\n    set [ghost v] effect to ((((item (#CloneID) of [bomb progress v]) / (pad threshold)) * (-100)) + (100))\nend\nshow\n\ndefine None\nset [x v] to ((join (letter (1) of (pos)) (join (letter (2) of (pos)) (letter (3) of (pos)))) - (500))\nset [y v] to ((join (letter (4) of (pos)) (join (letter (5) of (pos)) (letter (6) of (pos)))) - (500))\n\nwhen I receive [activate entities v]\nrepeat until <not <(my level) = (level)>>\n    if <(type) = [1]> then\n        set [color v] effect to (((item (#CloneID) of [pad progress v]) / (pad threshold)) * (80))\n        set [ghost v] effect to ((((item (#CloneID) of [pad progress v]) / (pad threshold)) * (-100)) + (100))\n        if <(item (#CloneID) of [pad progress v]) = (pad threshold)> then\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            delete this clone\n        end\n    else\n        set [color v] effect to (((item (#CloneID) of [bomb progress v]) / (pad threshold)) * (80))\n        set [ghost v] effect to ((((item (#CloneID) of [bomb progress v]) / (pad threshold)) * (-100)) + (100))\n        if <(item (#CloneID) of [bomb progress v]) = (pad threshold)> then\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            delete this clone\n        end\n    end\nend\ndelete clones\n\nwhen I receive [menu v]\ndelete clones\nhide\n\n@Bomb\n\ndefine None\nset [x v] to ((join (letter (1) of (pos)) (join (letter (2) of (pos)) (letter (3) of (pos)))) - (500))\nset [y v] to ((join (letter (4) of (pos)) (join (letter (5) of (pos)) (letter (6) of (pos)))) - (500))\n\nwhen I receive [setup v]\ndelete clones\ndelete (all) of [bomb pos v]\ndelete (all) of [bomb progress v]\nhide\n\nwhen I receive [render:clear entities v]\ndelete clones\ndelete (all) of [bomb pos v]\ndelete (all) of [bomb progress v]\n\nwhen I receive [render:entities v]\nset [#cloneid v] to [0]\nrepeat (length of [bomb pos v])\n    change [#cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nset [#cloneid v] to [-1]\n\ndefine delete clones\nset [#cloneid v] to [0]\ndelete this clone\n\nwhen I receive [activate entities v]\nrepeat until <not <(my level) = (level)>>\n    if <(item (#CloneID) of [bomb progress v]) < (pad threshold)> then\n        if <<<([x position v] of [player v]) > ((x position) - (10))> and <([x position v] of [player v]) < ((x position) + (10))>> and <<([y position v] of [player v]) > ((y position) - (24))> and <([y position v] of [player v]) < ((y position) + (4))>>> then\n            say [Press space!]\n            if <key (space v) pressed?> then\n                replace item (#CloneID) of [bomb progress v] with ((item (#CloneID) of [bomb progress v]) + (1))\n                wait until <not <key (space v) pressed?>>\n            end\n        else\n            say []\n        end\n    else\n        if <(played sound?) = [0]> then\n            broadcast (bomb activate v)\n            set [played sound? v] to [1]\n        end\n        say []\n        switch costume to (bomb2 v)\n    end\nend\ndelete clones\n\nwhen I start as a clone\ninsert [0] at (#CloneID) of [bomb progress v] \nset [my level v] to (level)\nget coords (item (#CloneID) of [bomb pos v])\nset [played sound? v] to [0]\ngo to x: (x) y: (y)\nswitch costume to (bomb v)\ngo [backward v] (50) layers\nshow\n\nwhen I receive [menu v]\ndelete clones\ndelete (all) of [bomb pos v]\ndelete (all) of [bomb progress v]\nhide\n\n@Doors\n\nwhen I receive [render:clear entities v]\ndelete (all) of [door pos v]\ndelete clones\n\nwhen I receive [setup v]\ndelete (all) of [door pos v]\ndelete clones\nhide\n\nwhen I receive [activate entities v]\nrepeat until <not <(my level) = (level)>>\n    if <(item (#ControllerID) of [pad progress v]) = (pad threshold)> then\n        wait (0.05) seconds\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n        delete this clone\n    end\nend\ndelete clones\n\nwhen I receive [render:entities v]\nset [#cloneid v] to [0]\nrepeat (length of [door pos v])\n    change [#cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nset [#cloneid v] to [-1]\n\ndefine None\nset [x v] to ((join (letter (1) of (pos)) (join (letter (2) of (pos)) (letter (3) of (pos)))) - (500))\nset [y v] to ((join (letter (4) of (pos)) (join (letter (5) of (pos)) (letter (6) of (pos)))) - (500))\n\ndefine get chars before [] but after [] in []\nset [get chars:return v] to []\nset [get chars:n v] to [0]\nrepeat until <(letter ((get chars:n) + (1)) of (data)) = (char1)>\n    change [get chars:n v] by (1)\n    set [get chars:return v] to (join (get chars:return) (letter (get chars:n) of (data)))\nend\nif <not <(char2) = []>> then\n    delete (1) of [get chars:get data v]\n    set [get chars:n v] to [0]\n    repeat (length of (get chars:return))\n        change [get chars:n v] by (1)\n        add (letter (get chars:n) of (get chars:return)) to [get chars:get data v]\n    end\n    repeat until <not <[get chars:get data v] contains (char2)?>>\n        delete (1) of [get chars:get data v]\n    end\n    set [get chars:return v] to (get chars:get data)\nend\n\ndefine get controller\nset [get controller:n v] to [0]\nrepeat (length of [door controllers v])\n    change [get controller:n v] by (1)\n    get chars before [-] but after [] in (item (get controller:n) of [door controllers v])\n    if <(get chars:return) = (my level)> then\n        get chars before [:] but after [-] in (item (get controller:n) of [door controllers v])\n        if <(get chars:return) = (#CloneID)> then\n            get chars before [;] but after [:] in (item (get controller:n) of [door controllers v])\n            set [#controllerid v] to (get chars:return)\n        end\n    end\nend\n\ndefine delete clones\nset [#cloneid v] to [0]\ndelete this clone\n\nwhen I start as a clone\nset [my level v] to (level)\nget coords (item (#CloneID) of [door pos v])\nget controller\ngo to x: (x) y: (y)\nswitch costume to (door v)\ngo [backward v] (50) layers\nshow\n\nwhen I receive [menu v]\ndelete (all) of [door pos v]\ndelete clones\nhide\n\n@Menu\n\nwhen I receive [setup v]\ndelete clones\nhide\n\ndefine delete clones\nset [#cloneid v] to [-1]\ndelete this clone\n\nwhen this sprite clicked\nif <(#CloneID) = [1]> then\n    set [menuscreen v] to [level select]\n    set [can progress? v] to [1]\nelse\n    if <(#CloneID) = [2]> then\n        set [gamemode v] to [2]\n        set [menuscreen v] to [level select]\n        set [can progress? v] to [1]\n    else\n        if <(#CloneID) = [3]> then\n            set [menuscreen v] to [options]\n            set [can progress? v] to [1]\n        else\n            if <(#CloneID) = [7]> then\n                set [menuscreen v] to [main]\n                set [can progress? v] to [1]\n            else\n            end\n        end\n    end\nend\n\ndefine create options buttons\nset [#cloneid v] to [3]\nrepeat (8)\n    change [#cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nset [#cloneid v] to [-1]\n\nwhen I receive [options v]\ncreate options buttons\n\nwhen I receive [progress v]\ndelete clones\nif <(menuscreen) = [main]> then\n    create title buttons\nelse\n    if <(menuscreen) = [options]> then\n        create options buttons\n    else\n    end\nend\n\nwhen I start as a clone\nif <(#CloneID) < [4]> then\n    set [ghost v] effect to (100)\n    switch costume to (#CloneID)\n    go to x: ((-90) - ((#CloneID) * (18))) y: ((20) - ((#CloneID) * (36)))\n    show\n    repeat (4)\n        change [ghost v] effect by (-25)\n    end\n    repeat until <not <(menuscreen) = [main]>>\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (10)\n            if <not <(x position) > ((-60) - ((#CloneID) * (18)))>> then\n                change x by (3)\n            end\n        else\n            set [brightness v] effect to (0)\n            if <not <(x position) < ((-88) - ((#CloneID) * (18)))>> then\n                change x by (-3)\n            end\n        end\n    end\n    repeat (4)\n        change [ghost v] effect by (25)\n    end\n    delete clones\nelse\n    if <(#CloneID) < [8]> then\n        set [ghost v] effect to (100)\n        switch costume to (#CloneID)\n        go to x: ((-20) - (((#CloneID) - (3)) * (18))) y: ((20) - (((#CloneID) - (3)) * (36)))\n        show\n        repeat (4)\n            change [ghost v] effect by (-25)\n        end\n        if <(#CloneID) = [7]> then\n            repeat until <not <(menuscreen) = [options]>>\n                if <touching (mouse-pointer v)?> then\n                    set [brightness v] effect to (10)\n                    if <not <(x position) > ((10) - (((#CloneID) - (3)) * (18)))>> then\n                        change x by (3)\n                    end\n                else\n                    set [brightness v] effect to (0)\n                    if <not <(x position) < ((-18) - (((#CloneID) - (3)) * (18)))>> then\n                        change x by (-3)\n                    end\n                end\n            end\n        else\n            wait until <not <(menuscreen) = [options]>>\n        end\n        repeat (4)\n            change [ghost v] effect by (25)\n        end\n        delete clones\n    else\n        if <(#CloneID) < [11]> then\n            set [ghost v] effect to (100)\n            switch costume to (slider button v)\n            set y to ((20) - (((#CloneID) - (7)) * (36)))\n            if <(#CloneID) = [8]> then\n                set x to ([floor v] of ((((master volume) / (100)) * (128)) - (24)) )\n            else\n                if <(#CloneID) = [9]> then\n                    set x to ([floor v] of ((((music volume) / (100)) * (128)) - (42)) )\n                else\n                    set x to ([floor v] of ((((music volume) / (100)) * (128)) - (60)) )\n                end\n            end\n            show\n            repeat (4)\n                change [ghost v] effect by (-25)\n            end\n            set [move? v] to [0]\n            set [slider is active? v] to [0]\n            repeat until <not <(menuscreen) = [options]>>\n                if <touching (mouse-pointer v)?> then\n                    if <<mouse down?> and <(slider is active?) = [0]>> then\n                        set [slider is active? v] to [1]\n                        set [move? v] to [1]\n                    end\n                    set [brightness v] effect to (10)\n                else\n                    set [brightness v] effect to (0)\n                end\n                if <not <mouse down?>> then\n                    set [slider is active? v] to [0]\n                    set [move? v] to [0]\n                end\n                if <(move?) = [1]> then\n                    set x to (mouse x)\n                    set [brightness v] effect to (10)\n                end\n                if <(#CloneID) = [8]> then\n                    if <not <(x position) > [-24]>> then\n                        set x to (-24)\n                    end\n                    if <not <(x position) < [104]>> then\n                        set x to (104)\n                    end\n                else\n                    if <(#CloneID) = [9]> then\n                        if <not <(x position) > [-42]>> then\n                            set x to (-42)\n                        end\n                        if <not <(x position) < [82]>> then\n                            set x to (82)\n                        end\n                    else\n                        if <not <(x position) > [-60]>> then\n                            set x to (-60)\n                        end\n                        if <not <(x position) < [68]>> then\n                            set x to (68)\n                        end\n                    end\n                end\n                if <(#CloneID) = [8]> then\n                    set [master volume v] to ([floor v] of ((((x position) + (24)) / (128)) * (100)) )\n                else\n                    if <(#CloneID) = [9]> then\n                        set [music volume v] to ([floor v] of ((((x position) + (42)) / (128)) * (100)) )\n                    else\n                        set [sound fx volume v] to ([floor v] of ((((x position) + (60)) / (128)) * (100)) )\n                    end\n                end\n            end\n            repeat (4)\n                change [ghost v] effect by (25)\n            end\n            delete clones\n        else\n        end\n    end\nend\n\ndefine create title buttons\nset [#cloneid v] to [0]\nrepeat (3)\n    change [#cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nset [#cloneid v] to [-1]\n\n@Level select\n\ndefine delete clones\nset [#cloneid v] to [0]\ndelete this clone\n\nwhen I receive [setup v]\ndelete clones\nhide\n\ndefine generate buttons\ndelete (all) of [locked v]\nswitch costume to (1 v)\nset [#cloneid v] to [0]\nrepeat (12)\n    change [#cloneid v] by (1)\n    add [1] to [locked v]\n    create clone of (_myself_ v)\n    next costume\nend\n\nwhen I start as a clone\nset [ghost v] effect to (100)\nswitch costume to (#CloneID)\nif <(#CloneID) < [6]> then\n    go to x: ((((#CloneID) - (1)) * (49)) - (105)) y: (0)\nelse\n    if <(#CloneID) < [11]> then\n        go to x: ((((#CloneID) - (6)) * (49)) - (115)) y: (-50)\n    else\n        go to x: ((((#CloneID) - (11)) * (125)) - (90)) y: (-100)\n    end\nend\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nif <(#CloneID) < [12]> then\n    replace item (#CloneID) of [locked v] with ([abs v] of ((<not <(#CloneID) < ((max level) + (1))>> * (1)) - (1)) )\nelse\n    delete (#CloneID) of [locked v]\nend\nrepeat until <not <(menuscreen) = [level select]>>\n    if <(#CloneID) < [12]> then\n        if <(item (#CloneID) of [locked v]) = [1]> then\n            if <touching (mouse-pointer v)?> then\n                set [brightness v] effect to (10)\n            else\n                set [brightness v] effect to (0)\n            end\n        else\n            set [brightness v] effect to (-15)\n        end\n    else\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (10)\n        else\n            set [brightness v] effect to (0)\n        end\n    end\nend\nrepeat (4)\n    change [ghost v] effect by (25)\nend\ndelete clones\n\nwhen I receive [progress v]\ndelete clones\nif <(menuscreen) = [level select]> then\n    generate buttons\nend\n\nwhen this sprite clicked\nif <(#CloneID) > [0]> then\n    if <(#CloneID) < [12]> then\n        if <(item (#CloneID) of [locked v]) = [1]> then\n            set [level v] to (#CloneID)\n            set [can progress? v] to [1]\n            set [menu v] to [false]\n            set [menuscreen v] to [game]\n        end\n    else\n        set [menuscreen v] to [main]\n        set [can progress? v] to [1]\n    end\nend\n\n@Pause\n\nwhen I receive [setup v]\ndelete clones\nset [pause? v] to [0]\nhide\n\nwhen I receive [begin v]\nrepeat until <(level) > [13]>\n    wait until <key (p v) pressed?>\n    if <(rendering?) = [0]> then\n        set [pause? v] to ((1) - (pause?))\n        set [game active? v] to (pause?)\n    end\n    if <(game active?) = [0]> then\n        generate pause menu\n    else\n        broadcast (delete pause menu v)\n    end\n    wait until <not <key (p v) pressed?>>\nend\n\ndefine generate pause menu\ncreate backboard\ncreate title\ncreate buttons\ncreate guard\n\nwhen I receive [delete pause menu v]\nrepeat (4)\n    change [ghost v] effect by (25)\nend\ndelete clones\n\nwhen I start as a clone\nif <(#CloneID) = [1]> then\n    switch costume to (backing v)\n    go to x: (0) y: (0)\n    set [ghost v] effect to (100)\n    show\n    go to [front v] layer\n    repeat (4)\n        change [ghost v] effect by (-25)\n    end\nelse\n    if <(#CloneID) = [2]> then\n        switch costume to ((level) + (3))\n        go to x: (-90) y: (90)\n        set [ghost v] effect to (100)\n        show\n        go to [front v] layer\n        repeat (4)\n            change [ghost v] effect by (-25)\n        end\n    else\n        if <(#CloneID) < [5]> then\n            switch costume to ((#CloneID) - (1))\n            if <(#CloneID) = [3]> then\n                go to x: (-112) y: (30)\n            else\n                go to x: (-132) y: (-10)\n            end\n            set [ghost v] effect to (100)\n            show\n            go to [front v] layer\n            repeat (4)\n                change [ghost v] effect by (-25)\n            end\n            forever\n                if <touching (mouse-pointer v)?> then\n                    set [brightness v] effect to (10)\n                    if <not <(x position) > ((-80) - (((#CloneID) - (3)) * (20)))>> then\n                        change x by (3)\n                    end\n                else\n                    set [brightness v] effect to (0)\n                    if <not <(x position) < ((-110) - (((#CloneID) - (3)) * (20)))>> then\n                        change x by (-3)\n                    end\n                end\n            end\n        else\n            if <(#CloneID) = [5]> then\n                switch costume to (guard v)\n                go to x: (120) y: (0)\n                set [ghost v] effect to (100)\n                show\n                go to [front v] layer\n                repeat (4)\n                    change [ghost v] effect by (-25)\n                end\n            else\n            end\n        end\n    end\nend\n\ndefine create backboard\nset [#cloneid v] to [1]\ncreate clone of (_myself_ v)\nset [#cloneid v] to [0]\n\ndefine delete clones\nset [#cloneid v] to [0]\ndelete this clone\n\ndefine create buttons\nset [#cloneid v] to [2]\nrepeat (2)\n    change [#cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nset [#cloneid v] to [0]\n\ndefine create title\nset [#cloneid v] to [2]\ncreate clone of (_myself_ v)\nset [#cloneid v] to [0]\n\ndefine create guard\nset [#cloneid v] to [5]\ncreate clone of (_myself_ v)\nset [#cloneid v] to [0]\n\nwhen I receive [menu v]\ndelete clones\nset [pause? v] to [0]\nhide\n\nwhen this sprite clicked\nif <(#CloneID) = [3]> then\n    set [pause? v] to ((1) - (pause?))\n    set [game active? v] to (pause?)\n    broadcast (delete pause menu v)\nelse\n    broadcast (music:game1:stop v)\n    broadcast (music:game2:stop v)\n    broadcast (music:title:start v)\n    broadcast (stop torch v)\n    set [menuscreen v] to [main]\n    set [menu v] to [True]\n    broadcast (menu v)\nend\n\n@title\n\nwhen I receive [music:title:start v]\nwait (0.1) seconds\nset [ghost v] effect to (100)\nrepeat (20)\n    change [ghost v] effect by (-5)\n    wait (0.05) seconds\nend\nglide (2.5) secs to x: (0) y: (75)\nwait until <(menu) = [False]>\nhide\n\nwhen I receive [setup v]\nset [ghost v] effect to (100)\ngo to x: (0) y: (0)\ngo to [front v] layer\nhide\n\nwhen I receive [intro v]\nshow\n\nwhen I receive [menu v]\ngo to x: (0) y: (75)\nshow\ngo to [front v] layer\n\n@Loading Screen\n\nwhen I receive [setup v]\nhide\n\nwhen I receive [show loading v]\nclear graphic effects\nset [ghost v] effect to (100)\ngo to [front v] layer\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\n\nwhen I receive [hide loading v]\nrepeat (10)\n    change [brightness v] effect by (-15)\n    change [ghost v] effect by (10)\nend\nhide\n\n@Game Over\n\nwhen I receive [setup v]\ngo to x: (0) y: (0)\nclear graphic effects\nhide\n\nwhen I receive [player been caught v]\nswitch costume to (game over v)\nwait (1) seconds\nset [game active? v] to [0]\nset [ghost v] effect to (100)\ngo to [front v] layer\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nwait (1.5) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\nset [game active? v] to [1]\n\nwhen I receive [explosion has happened v]\nswitch costume to (game over2 v)\nset [ghost v] effect to (100)\ngo to [front v] layer\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nwait (1.5) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nset [level v] to [10]\nset [player hp v] to [10]\nbroadcast (next v)\nhide\n\n@Parts\n\nwhen I receive [setup v]\ngo to x: (0) y: (0)\nclear graphic effects\nhide\n\nwhen I receive [part1 v]\nswitch costume to (part 1 v)\nset [ghost v] effect to (100)\ngo to [front v] layer\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nwait (1.5) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\nwhen I receive [part2 v]\nswitch costume to (part 2 v)\nset [ghost v] effect to (100)\ngo to [front v] layer\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nwait (1.5) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\n@Intro\n\nwhen I receive [setup v]\ngo to x: (0) y: (0)\nswitch costume to (intro1 v)\nhide\n\nwhen I receive [storyline v]\nshow\nswitch costume to (intro1 v)\nset [ghost v] effect to (100)\nrepeat (5)\n    change [ghost v] effect by (-20)\nend\nset [n v] to [0]\nrepeat (3)\n    broadcast (join [slide] ((n) + (1)))\n    wait until <key (space v) pressed?>\n    wait until <not <key (space v) pressed?>>\n    change [n v] by (1)\n    repeat (4)\n        change [brightness v] effect by (-40)\n    end\n    broadcast (join [stop slide] (n))\n    if <(n) < [3]> then\n        next costume\n        set [brightness v] effect to (-100)\n        repeat (4)\n            change [brightness v] effect by (25)\n        end\n        clear graphic effects\n    end\nend\nrepeat (5)\n    change [ghost v] effect by (20)\n    change [brightness v] effect by (-25)\nend\nhide\nclear graphic effects\n\n@Outro\n\nwhen I receive [setup v]\ngo to x: (0) y: (0)\nhide\n\nwhen I receive [outro v]\nshow\nset [ghost v] effect to (100)\nrepeat (5)\n    go to [front v] layer\n    change [ghost v] effect by (-20)\nend\nbroadcast (kill cutscene v)\nbroadcast (outro voice v)\nwait until <not <key (space v) pressed?>>\nwait until <key (space v) pressed?>\nbroadcast (stop outro voice v)\nbroadcast (music:title:start v)\nset [menuscreen v] to [main]\nset [menu v] to [True]\nbroadcast (menu v)\nhide\n\n@Cutscene\n\nwhen I receive [setup v]\ndelete clones\nhide\n\ndefine delete clones\nset [#cloneid v] to [0]\ndelete this clone\n\nwhen I receive [cutscene v]\nset [menuscreen v] to [outro]\nswitch backdrop to (night bakcground v)\nswitch costume to (desert v)\ngo to x: (0) y: (0)\nshow\nwait (1) seconds\ncreate player\n\ndefine create player\nset [#cloneid v] to [1]\ncreate clone of (_myself_ v)\nset [#cloneid v] to [0]\n\nwhen I start as a clone\nif <(#CloneID) = [1]> then\n    forever\n        repeat (3)\n            wait (0.1) seconds\n            next costume\n        end\n        wait (0.1) seconds\n        switch costume to (player v)\n    end\nend\n\nwhen I receive [kill cutscene v]\ndelete clones\nhide\n\nwhen I start as a clone\nif <(#CloneID) = [1]> then\n    switch costume to (player v)\n    set size to (300) %\n    set [ghost v] effect to (100)\n    go to [front v] layer\n    go to x: (-200) y: (-30)\n    repeat (4)\n        go to [front v] layer\n        change [ghost v] effect by (-25)\n    end\n    glide (2) secs to x: (0) y: (-80)\n    broadcast (animate explosion v)\n    glide (1) secs to x: (100) y: (-105)\n    change [#cloneid v] by (1)\n    create clone of (_myself_ v)\n    set [#cloneid v] to [1]\n    glide (1) secs to x: (200) y: (-130)\n    repeat (4)\n        change [ghost v] effect by (25)\n    end\n    delete this clone\nelse\n    switch costume to (blackout v)\n    set size to (100) %\n    set [ghost v] effect to (100)\n    go to x: (0) y: (0)\n    go to [front v] layer\n    repeat (10)\n        go to [front v] layer\n        change [ghost v] effect by (-10)\n    end\n    wait (1) seconds\n    broadcast (outro v)\nend\n\n@Explosion\n\ndefine explode\nshow\nswitch costume to (costume1 v)\ngo [backward v] (9999) layers\nrepeat (27)\n    next costume\n    wait (0.032) seconds\nend\nhide\n\nwhen I receive [setup v]\ngo to x: (-140) y: (50)\nswitch costume to (costume1 v)\ngo [backward v] (9999) layers\nhide\n\nwhen I receive [animate explosion v]\nbroadcast (explosion v)\nexplode\n\n@Thumbnail\n\nwhen flag clicked\nset [timer marker v] to [60]\nforever\n    set [timer marker v] to ((timer) + (0.5))\nend\n\nwhen I receive [setup v]\ngo to x: (0) y: (0)\nhide\n\nwhen [timer v] > (timer marker)\nif <(rendering?) = [0]> then\n    show\n    go to [front v] layer\n    go to x: (0) y: (-360)\n    repeat until <(y position) > [-0.5]>\n        change y by ((y position) / (-4))\n    end\n    stop [all v]\nend\n\n@Watermark\n\nwhen I receive [setup v]\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\nhide\n\nwhen I receive [watermark v]\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\n\nwhen backdrop switches to [background v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\n