-- Cannonball -- the Enigma Level -- (c) 2002 Petr Machata/ant_39 -- Licensed under GPL v2.0 or above -- 2003-01-08 dofile(enigma.FindDataFile("levels/ant.lua")) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- function construct(x, y) set_floor("fl-metal", x, y) end function destruct(x, y) set_floor("fl-abyss", x, y) end -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- forcecount = 0 force = 100 act_state = 0 DOORCOUNT = 0 function forceup() forcecount = forcecount + 1 enigma.AddConstantForce(force,0) end function forcedn() enigma.AddConstantForce((-1)*force*forcecount,0) forcecount = 0 end function run_trigger_action() if (act_state == 0) then act_state = 1 end end function restart_trigger_action() act_state = 0 forcedn() end function tick() if (act_state == 0) then enigma.SendMessage(enigma.GetNamedObject("doorA1"), "open", nil) enigma.SendMessage(enigma.GetNamedObject("doorA2"), "open", nil) elseif (act_state == 1) then enigma.SendMessage(enigma.GetNamedObject("doorA1"), "close", nil) enigma.SendMessage(enigma.GetNamedObject("doorA2"), "close", nil) act_state = act_state + 1 elseif (act_state == 2) then for i=1,DOORCOUNT do enigma.SendMessage(enigma.GetNamedObject("doorB"..i), "open", nil) end act_state = act_state + 1 elseif (act_state == 3) then forceup() act_state = act_state + 1 elseif (act_state == 4) then for i=1,DOORCOUNT do enigma.SendMessage(enigma.GetNamedObject("doorB"..i), "close", nil) end act_state = 0 else act_state = 0 end end function inc_doorcount(x,y) DOORCOUNT = DOORCOUNT +1 local key = "doorB"..DOORCOUNT enigma.NameObject(enigma.GetNamedObject("doorB1"), key) end -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- cells={} cells[";"]=cell{floor={face="fl-tigris"}} cells[":"]=cell{floor={face="fl-sahara"}} cells["."]=cell{floor={face="fl-abyss"}} cells["_"]=cell{floor={face="fl-metal"}} cells["w"]=cell{floor={face="fl-wood"}} cells["v"]=cell{floor={face="fl-gradient", attr={type=1}}} cells["^"]=cell{floor={face="fl-gradient", attr={type=2}}} cells[">"]=cell{floor={face="fl-gradient", attr={type=23}}} cells["|"]=cell{floor={face="fl-gradient", attr={type=3}}} cells["T"]=cell{floor={face="fl-gradient", attr={type=5}}} cells["L"]=cell{floor={face="fl-gradient", attr={type=7}}} cells["R"]=cell{floor={face="fl-gradient", attr={type=9}}} cells["/"]=cell{floor={face="fl-gradient", attr={type=10}}} cells[" "]=cell{parent={{checkerfloor,{cells[":"], cells[";"]}}}} cells["="]=cell{parent=cells[" "],stone={face="st-rock5"}} cells["#"]=cell{parent=cells[" "],stone={face="st-rock6"}} cells["&"]=cell{parent=cells[" "],stone={face="st-oneway", attr={orientation=EAST}}} cells["%"]=cell{parent=cells[" "],stone={face="st-oneway", attr={orientation=WEST}}} cells["x"]=cell{parent=cells[" "],stone={face="st-grate1"}} cells["a"]=cell{parent=cells[" "],stone={face="st-door", attr={name="doorA1", type="h"}}} cells["b"]=cell{parent=cells[" "],stone={face="st-door", attr={name="doorA2", type="h"}}} cells["e"]=cell{parent=cells[" "],stone={face="st-door", attr={name="doorE", type="v"}}} cells["f"]=cell{parent=cells[" "],stone={face="st-door", attr={name="doorF", type="v"}}} cells["!"]=cell{parent={cells[" "], inc_doorcount},stone={face="st-door_b", attr={name="doorB1", type="v"}}} cells["D"]=cell{parent=cells["w"],stone={face="st-death"}} cells["W"]=cell{parent=cells["w"],stone={face="st-brick"}} cells["E"]=cell{parent=cells["w"],stone={face="st-floppy", attr={action="openclose", target="doorE"}}} cells["F"]=cell{parent=cells["w"],stone={face="st-floppy", attr={action="openclose", target="doorF"}}} cells["~"]=cell{parent={cells[" "]},stone={face="st-timer", attr={action="callback", target="tick", interval=1}}} cells["`"]=cell{parent={cells[" "]},stone={face="st-timer", attr={action="callback", target="move_constructors", interval=0.15}}} cells["+"]=cell{parent=cells[" "],item={face="it-trigger", attr={action="callback", target="forceup"}}} cells["-"]=cell{parent=cells["_"],item={face="it-trigger", attr={action="callback", target="forcedn"}}} cells["*"]=cell{parent={cells[">"], cells["+"]}} cells["o"]=cell{parent=cells[" "],item={face="it-trigger", attr={action="callback", target="run_trigger_action"}}} cells["9"]=cell{parent=cells[" "],item={face="it-trigger", attr={action="callback", target="restart_trigger_action", invisible=1}}} cells["h"]=cell{parent=cells["w"],item={face="it-floppy"}} cells["s"]=cell{parent=cells["x"],item={face="it-spring1"}} cells["?"]=cell{parent={cells[" "]},item={face="it-document", attr={text="Look carefully. A hidden treasure awaits you..."}}} cells["$"]=cell{parent={cells["."], {path_empty, {1}} }} cells["@"]=cell{parent={cells["$"], {path_train, {1}}, cells["_"]}} cells["c"]=cell{parent={cells["@"], {path_constructor,{1, construct}}}} cells["d"]=cell{parent={cells["$"], {path_destructor, {1, destruct}} }} cells["X"]=cell{parent={cells["x"], cells["$"]}} cells["Y"]=cell{parent={cells["x"], cells["@"]}} cells["y"]=cell{parent={cells["x"], cells["w"]}} cells["0"]=cell{parent=cells["w"],stone={face="st-oxyd", attr={flavor="b", color="0"}}} cells["O"]=cell{parent=cells["9"],item={face="ac-blackball", attr={player=0}, actor=1}} level = { "====================.....................................~WWWWWWWWWWWWWWWWWWW", "=xxxxxxxxxxxxxxxxxx==wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwWW......$$c@Y@@d$...W", "=xx O %ww=..............www..............Www%wwwwwwXwwwWwwwXwwwW", "=x 9 ====...............w...............WWWW...wwwXXXXXXXXXwwwW", "=x#a###############=..................w............WWWWWWW...wwwwwwwWwwwwwWWW", "=x# !TvvvvvvvvvvvR&__................www...........wwwwww&wwwwwwwwwwWEwwwwe0W", "=x#o!|>>*>>>*>>>*>&____________-.....whw.........wwwwwwwDWWWWWWWWWWWWWWWWWWWW", "=x# !L^^^^^^^^^^^/&__................www...........wwwwww&wwwwwwwwwwWFwwwwf0W", "=x#b###############=..................w............WWWWWWW...wwwwwwwWwwwwwWWW", "=x 9 ====...............w...............WWWW...wwwXXXXXXXXXwwwW", "=xx %ww=..............www..............Www%wwwwwwXwwwWwwwXwwwW", "=sxxxxxxxxxxxxxxxxx==wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwWW......$$c@Y@@d$...W", "====================.....................................`WWWWWWWWWWWWWWWWWWW" } -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- randomseed(enigma.GetTicks()) create_world_by_map(level) oxyd_shuffle()