--!name Wyrmsbane
--!icon game
local aA={"Veldra|40|30|w|0|6,9||0|0||w40/w3m7w30/wwmmh5mmw8g4f4w13/wwmhhVh4mmw5g4f6ggw11/wwmh5ffhmw4g3f5mmfg4w9/wwmmhf6ggw3ggf4m5fg5w7/w3mf3g6w3g3f4m3fg3s3gw6/w4fg8w4g3f5g4s4ggw5/w3g8fgw5g11s5gw5/wwg4Cg4ffgw5g8s7gw5/wwg6Tg3fggb3g9s6ggTw4/w3g11w4g3f3g4s4g3w5/w4g3ffg4w6gf6g9w5/w4ggf5ggw6ggf4h3g6w6/w5gf4g3w5g3f3h5g5w6/w5ggf3g4w4g7h3g5w7/w6g9w4g3p5g5w8/w7g4p3gw5gp8ggw9/w8gp7w5p7ggw10/w10p4w8p4ggw12/w23g4w13/w24gyw14/w25yw14/w25yw14/w23mmhhmmw11/w22mmh4mmw10/w22mpphKhpmw10/w22mmp5mw10/w23m6w11/w40|p,5,3,5;p,6,9,2;p,8,10,3;p,35,10,4;p,26,26,7","Castle Hale|16|14|F|0|7,12||0|0||W16/WF6kF7W/WFqF10qFW/WF14W/W6F3W7/WxxWF11W/WxFdF6nF4W/W4F11W/WF14W/WFnF12W/WF11nFFW/W6F3W7/g5qF3qg6/g16|n,7,1,king;n,2,2,t1;n,13,2,t2;x,1,5,0,g120;x,2,5,1,w;x,1,6,2,h;d,3,6,3;n,10,6,t3;n,2,9,t4;n,12,10,t5;n,5,12,t6;n,9,12,t7","Brindle|16|14|g|0|7,13||0|0||f16/fg14f/fgW5ggW5gf/fgWFvFWggWFvFWgf/fgWc3WggWc3Wgf/fgWF3WggWF3Wgf/fgWWFWWggWWFWWgf/fg6ng6nf/fggw3g4W5f/fggw3g4WFvFWf/fg5nfggWc3Wf/fggfg6WF3Wf/fg9WWFWWf/f6g3f7|n,4,3,inn1;n,11,3,wsh1;n,7,7,t8;n,14,7,t9;n,12,9,ish1;n,6,10,t10","Saltmere|16|14|s|0|8,13||0|0||w16/wws13w/wsW5s3W5w/wsWFvFWs3WFvFWw/wsWc3WsnsWc3Ww/wsWF3Ws3WF3Ww/wsWWFWWs3WWFWWw/wg13nw/wgW5g3fg4w/wgWFvFWg5fggw/wgWc3Wggng4fw/wgWF3Wg4WdWWw/wgWWFWWg4WxFWw/wf6gsgfW4w|n,4,3,inn2;n,12,3,wsh2;n,8,4,t11;n,14,7,t12;n,4,9,ish2;n,9,10,t13;d,12,11,4;x,12,12,5,Es4","Echo Cave|16|12|F|1|1,1|11,10|1|6|3,4,5|W16/WUF3WF7xFW/WFWWFWFW7FW/WFWF4WF5WFW/WFWFW4FW3FWFW/WF3WxF3WF5W/W3FW4FWFW5/WF6WFWF5W/WFW4FWFW5FW/WFWF10WFW/WF3W7SF3W/W16|x,13,1,6,g60;x,5,5,7,t","Echo Depths|16|12|F|1|1,10||5|0|4,5,6,7|W16/WF6WF7W/WFW4FWFW5FW/WFWxFWF3WF3WFW/WFWFFW5FWFWFW/WFWWF7WF3W/WFFW6FW4FW/WWFWF4WF4WFW/WFFWFWWFW4FWFW/WFWWFWxF4WF3W/WUF3W11/W16|x,3,3,8,T;x,6,9,9,g150","Ashkeep|16|14|F|0|6,13|10,9|0|8|8,9,10,11|W16/WF6WF7W/WFl4FWFl4xFW/WFlFFlFdFlFFlFFW/WFlFxlFWFl5FW/WFllFlFWF7W/WF6W9/W3FW4F7W/WF8l4FFW/WFl6FlSFlFFW/WF6lFl5FW/W6F9W/WF7W8/W6FW9|x,13,2,10,Ew7;d,7,3,11;x,4,4,12,h","Wyrm's Roost|16|12|F|0|1,10||7|0|10,11|W16/W6FZFW7/Wl5F3l5FW/WlF3lF3lF3lFW/WlFlF3lF3lFlFW/WlFl9FlFW/WlF11lFW/Wl6Fl7W/WF14W/WFl11FFW/WUF13W/W16|n,7,1,boss"}local d=snail local r=math.random local aC,aB=15,17 local aY={"Gloop,3,5,3,3,1,2","Nibbler,5,7,4,5,2,3","Duskwing,7,9,6,12,3,5","Sporeling,10,11,8,4,5,6,3,6, puffs choking spores!","Hexling,12,12,10,9,7,10,5,10, casts Spark!","Grimfang,18,18,12,14,11,14","Bonewalker,24,26,20,10,18,22","Hollow,28,30,24,16,26,30,5,10, casts Spark!","Stonehulk,60,42,48,6,70,60,12,20, hurls a boulder!","Emberdrake,50,52,40,18,90,70,10,18, breathes fire!","Cinderknight,72,64,58,20,120,100","Vorthax,320,104,80,40,0,0,26,36, breathes ashfire!",}local a1={{1,1,2},{1,2,3},{2,3,4,5},{4,5,6},{6,7,8},{7,8,9,10},{9,10,11}}local aZ={g=24,f=16,h=12,p=12,s=16,F=16,l=16,b=40}local aX={"Stick,2,0,Club,4,60,Bronze Sword,10,180,Iron Sword,18,560,Battle Axe,26,1200,Flame Sword,34,3200,Sun Blade,44,0","Clothes,2,0,Leather,6,70,Chain Mail,12,300,Scale Mail,18,700,Plate,24,1300,Wyrm Mail,32,3000","No shield,0,0,Wood Shield,3,90,Iron Shield,8,400,Silver Shield,16,0",}local ah={w=1,a=2,s=3}local W={"ew","ea","es"}local V={h="Herb",t="Torch",w="Wing",k="Key"}local ag={h=10,t=8,w=60,k=40}local a_={wsh1="w2,w3,a2,a3,s2",wsh2="w4,w5,w6,a4,a5,a6,s3",ish1="h,t,w",ish2="h,t,w,k"}local af={inn1=8,inn2=22}local z={"Heal",3,4,"Spark",4,2,"Glow",7,3,"Return",10,8,"Ward",13,5,"Mend",16,8,"Blaze",18,5}local a0={"Speak with the King to record your journey.","The treasury door needs a key. Saltmere sells them.","Herbs mend wounds. Torches push back the dark of caves.","The Echo Cave lies in the hills to the northwest.","Past the east bridge is the port of Saltmere.","Brindle is just southeast. Rest at its inn.","Monsters grow fiercer the farther you roam from here.","Something glints in the depths of the Echo Cave.","Wolves prowl the lands past the bridge.","Old songs say a Tidestone once raised a road to the isle.","The Wyrm's isle lies past the southern shore.","Stand at the shore's end and use the Tidestone.","The Sun Blade sleeps in Ashkeep.^Lava burns with every step. Carry herbs.",}local az="lv xp hp mp g ew ea es h t w k tide m x y wx wy fl ford boss"local a,h,X,p,D,ad,M local i,l="title",1 local function I(m,aS)local e={}for aq in(m..aS):gmatch("(.-)%"..aS)do e[#e+1]=aq end return e end local function aW(m)local o,t=m:match("(%d+),(%d+)")return tonumber(o),tonumber(t)end local function bd(j)local g=I(aY[j],",")for an=2,#g do g[an]=tonumber(g[an])or g[an]end return{n=g[1],hp=g[2],a=g[3],d=g[4],g=g[5],x=g[6],gd=g[7],lo=g[8],hi=g[9],t=g[10]}end local function x(m,k)local g=I(aX[m],",")return g[k*3-2],tonumber(g[k*3-1]),tonumber(g[k*3])end local function A(j)if M and M.i==j then return M end M=nil local g=I(aA[j],"|")local b={i=j,name=g[1],w=tonumber(g[2]),h=tonumber(g[3]),g=g[4],dark=g[5]=="1",up=tonumber(g[8]),down=tonumber(g[9]),r={},at={}}b.sx,b.sy=aW(g[6])if g[7]~=""then b.dx,b.dy=aW(g[7])end if g[10]~=""then b.mon={}for E in g[10]:gmatch("%d+")do b.mon[#b.mon+1]=tonumber(E)end end for be in(g[11].."/"):gmatch("(.-)/")do b.r[#b.r+1]=be:gsub("(%D)(%d+)",function(f,k)return f:rep(tonumber(k))end)end for c,o,t,E in g[12]:gmatch("(%a),(%d+),(%d+),([^;]*)")do b.at[t*64+o]=c..","..E end M=b return b end local function ab(b,o,t)local aP=b.at[t*64+o]if aP then local c,s,u=aP:match("(%a),([^,]*),?(.*)")return c,tonumber(s)or s,u end end local function H()return 15+8*(a.lv-1)end local function K()return a.lv<3 and 0 or 6+4*(a.lv-3)end local function aj()return 4+2*(a.lv-1)end local function ak()return 4+3*(a.lv-1)+select(2,x(1,a.ew))end local function aF()return aj()//2+select(2,x(2,a.ea))+select(2,x(3,a.es))end local function ao(C)return math.floor(5*C^2.3)end local function a9(u)return a.fl>>u&1==1 end local function _()return("HP %d/%d  MP %d/%d"):format(a.hp,H(),a.mp,K())end local function y()local e={}for j,c in ipairs(I(az," "))do e[j]=a[c]end d.save("W1 "..table.concat(e," "))end local function Y()a={lv=1,xp=0,hp=15,mp=0,g=100,ew=1,ea=1,es=1,h=1,t=1,w=0,k=0,tide=0,m=2,x=7,y=2,wx=6,wy=9,fl=0,ford=0,boss=0,light=0,ward=0}end local function bb()local m,aM,E=d.load(),I(az," "),{}if not m or m:sub(1,3)~="W1 "then return false end for k in m:gmatch("%-?%d+")do E[#E+1]=tonumber(k)end if#E~=#aM+1 then return false end Y()for j,c in ipairs(aM)do a[c]=E[j+1]end local b=aA[a.m]and A(a.m)if a.lv<1 or a.lv>30 or not b or a.x<0 or a.y<0 or a.x>=b.w or a.y>=b.h or a.g<0 or a.ew<1 or a.ew>7 or a.ea<1 or a.ea>6 or a.es<1 or a.es>4 then Y()return false end a.hp=math.max(1,math.min(a.hp,H()))a.mp=math.max(0,math.min(a.mp,K()))return true end local function as(b,o,t)local R=b.r[t+1]if not R or o<0 or o>=b.w then return nil end return R:sub(o+1,o+1)end local function aU(b,o,t)local e=as(b,o,t)if not e then return b.i==1 and"w"or"."end if e=="x"or e=="d"then local c,u=ab(b,o,t)if c and a9(u)then return e=="x"and b.g or"F"end elseif e=="y"then return a.ford==1 and"j"or"w"elseif e=="Z"and a.boss==1 then return"F"end return e end local function T(bk,bh,g)X={who=bk,p=I(bh,"^"),f=g}i="talk"end local function F(j,o,t)a.m,a.x,a.y,a.light=j,o,t,0 y()end local function aG()a.g=a.g//2 a.hp,a.mp=H(),K()F(2,7,2)T("King","Rise, hero. Death is not the end of your road.^Half of your gold was lost.")end local function aJ(k)a.hp=a.hp-k if a.hp<=0 then a.hp=0 aG()return true end end local function q(m)local C=h.log C[#C+1]=m if#C>6 then table.remove(C,1)end end local function aH(s,n)local u=s-n//2 if u<2 then return r(0,1)end return math.max(1,u*r(30,50)//100)end local function bc()while a.lv<30 and a.xp>=ao(a.lv)do local Z,N=H(),K()a.lv=a.lv+1 a.hp,a.mp=a.hp+H()-Z,a.mp+K()-N q("You reach level "..a.lv.."!")for j=2,#z,3 do if z[j]==a.lv then q("You learned "..z[j-1]..".")end end end end local function aO()local b,n=h.m,0 if b.lo and r(h.id==12 and 3 or 4)==1 then n=r(b.lo,b.hi)q(b.n..b.t.." "..n.." damage.")elseif r(20)==1 then q(b.n.." attacks, but misses.")else n=aH(b.a,aF())q(b.n.." hits you for "..n..".")end a.hp=a.hp-n if a.hp<=0 then a.hp=0;h.ph="lost";q("You have fallen...")end end local function aI(G)local b=bd(G)h={id=G,m=b,hp=b.hp,log={},ph="cmd"}l,i=1,"fight"q(G==12 and"Vorthax spreads his wings!"or b.n.." appears!")if G<12 and r(8)==1 then q(b.n.." strikes first!");aO()end end local function am(n,ba)h.hp=h.hp-n q(ba.." "..h.m.n.." takes "..n.." damage.")end local function at(g)h.log={}if not g()or h.ph~="cmd"then return end if h.hp>0 then return aO()end local b=h.m h.ph="won"q(b.n.." is defeated!")if h.id==12 then return end a.xp,a.g=a.xp+b.x,a.g+b.gd q("Gained "..b.x.." EXP and "..b.gd.." gold.")bc()end local function a2()if r(32)==1 then am(math.max(2,ak()*r(50,70)//100),"Critical hit!")elseif r(24)==1 then q(h.m.n.." dodges your blow.")else am(aH(ak(),h.m.d),"You strike!")end return true end local function a8()if h.id==12 then q("There is no escape from Vorthax!");return true end local f=math.max(20,math.min(90,55+aj()-h.m.g))if r(100)<=f then h.ph="fled";q("You slip away.")else q("You could not escape!")end return true end local function al(s,u)local Z=math.min(H()-a.hp,r(s,u))a.hp=a.hp+Z return"You recover "..Z.." HP."end local function aD(j,J)local L,N=z[j*3-2],z[j*3]if a.mp<N then return"Not enough MP.",false end local e if j==1 or j==6 then e=j==1 and al(12,20)or al(60,80)elseif J and(j==2 or j==7)then local n=j==2 and r(7,12)or r(40,55)if h.id==12 then n=n//2 end a.mp=a.mp-N am(n,L.."!")return nil,true elseif J then return"That spell is for travel.",false elseif j==3 then if not A(a.m).dark then return"It is bright enough here.",false end a.light=5;e="A soft light surrounds you."elseif j==4 then F(1,6,9);e="You are whisked back to Castle Hale."elseif j==5 then a.ward=80;e="Weak monsters will keep their distance."else return"That spell is for battle.",false end a.mp=a.mp-N return L.."! "..e,true end local function aV(c,J)if a[c]<1 then return"You have none.",false end local e if c=="h"then e=al(20,30)elseif J then return"Not now!",false elseif c=="t"then if not A(a.m).dark then return"It is bright enough here.",false end a.light=math.max(a.light,3);e="The torch flares to life."elseif c=="w"then F(1,6,9);e="The wing carries you to Castle Hale."else return"Walk into a locked door to use a key.",false end a[c]=a[c]-1 return e,true end local function bi()if a.m==1 and a.ford==0 then for a7=-1,1 do for a6=-1,1 do if as(A(1),a.x+a6,a.y+a7)=="y"then a.ford=1 y()return"The Tidestone glows. Stones rise from the sea!"end end end end return"The Tidestone hums quietly."end local ae={left=-1,right=1,up=0,down=0}local ay={left=0,right=0,up=-1,down=1}local function aT(B)if B=="king"then y()T("King","I have recorded your deeds.^You need "..(ao(a.lv)-a.xp).." more EXP to grow stronger.")elseif B=="boss"then T("Vorthax","So, a mayfly reaches my roost.^I will burn you to cinders!",function()aI(12)end)elseif B:sub(1,1)=="t"then T("Villager",a0[tonumber(B:sub(2))])elseif af[B]then p={t="Inn",inn=af[B],note="Rest for "..af[B].." gold?"}i,l="shop",1 else p={t=B:sub(1,1)=="w"and"Armory"or"Goods",list=I(a_[B],","),note="Welcome! What will you buy?"}i,l="shop",1 end end local function a4(u,f)local e,c=nil,f:sub(1,1)a.fl=a.fl|(1<<u)if c=="g"then a.g=a.g+tonumber(f:sub(2));e=f:sub(2).." gold"elseif c=="T"then a.tide=1;e="the Tidestone"elseif c=="E"then local m,k=ah[f:sub(2,2)],tonumber(f:sub(3))a[W[m]]=math.max(a[W[m]],k);e=x(m,k)else a[c]=math.min(9,a[c]+1);e=V[c]end D="You found "..e.."!"y()end local function bg(b,e)local c,s,u=ab(b,a.x,a.y)if c=="p"then local n=A(s)a.wx,a.wy=a.x,a.y return F(s,n.sx,n.sy)end if c=="x"and e=="x"then a4(s,u)end if e=="S"then local n=A(b.down)return F(b.down,n.sx,n.sy)elseif e=="U"then if b.up==1 then return F(1,a.wx,a.wy)end local n=A(b.up)return F(b.up,n.dx,n.dy)end if(e=="p"and aJ(1))or(e=="l"and aJ(3))then return end if a.ward>0 then a.ward=a.ward-1 end local R=aZ[e]if not R or r(R)>1 then return end local v=b.mon if b.i==1 then local ax=math.max(math.abs(a.x-6),math.abs(a.y-9))//6 if e=="s"or e=="p"then ax=ax+1 end v=a1[(a.y>=21 and 6 or math.min(ax,5))+1]end if not v then return end local G=v[r(#v)]if a.ward>0 and G*3<=a.lv+3 then return end aI(G)end local function bj(c)local b=A(a.m)local P,Q=a.x+ae[c],a.y+ay[c]if not as(b,P,Q)then if a.m>1 then F(1,a.wx,a.wy)end return end local e=aU(b,P,Q)local ap,s=ab(b,P,Q)if ap=="n"and e~="F"then return aT(s)end if e=="c"then ap,s=ab(b,P+ae[c],Q+ay[c])if ap=="n"then aT(s)end return end if e=="d"then D="The door is locked."if a.k>0 then a.k=a.k-1 a.fl=a.fl|(1<<s)D="You unlock the door."y()end return end if("mwWkqnvZ"):find(e,1,true)then return end a.x,a.y=P,Q bg(b,e)end local function O(c,k)if c=="up"then l=l>1 and l-1 or k elseif c=="down"then l=l<k and l+1 or 1 end end local function aa()local e={}for j=1,#z//3 do if z[j*3-1]<=a.lv then e[#e+1]=j end end return e end local function ac(J)local e={}for c in("htwk"):gmatch(".")do if a[c]>0 and(not J or c=="h")then e[#e+1]=c end end if not J and a.tide==1 then e[#e+1]="T"end return e end local function S(v,w)for j,f in ipairs(v)do d.row(w and z[f*3-2].."  "..z[f*3].." MP"or f=="T"and"Tidestone"or w==false and V[f].." x"..a[f]or f,l==j)end if w~=nil then d.row("Back",l==#v+1)end end local function a3(f)local m=#f>1 and ah[f:sub(1,1)]if m then local k=tonumber(f:sub(2))local c=W[m]local L,ai,ar=x(m,k)if a[c]==k then return"You already have that."end local aE=ar-select(3,x(m,a[c]))//2 if a.g<aE then return"You can't afford that."end a.g=a.g-math.max(0,aE)a[c]=k return"You equip the "..L.."."end if a.g<ag[f]then return"You can't afford that."end if a[f]>=9 then return"You can't carry more."end a.g,a[f]=a.g-ag[f],a[f]+1 return"You buy a "..V[f].."."end local function bf(f)local m=#f>1 and ah[f:sub(1,1)]if m then local k=tonumber(f:sub(2))local L,ai,ar=x(m,k)return L.."  "..ar.."G"..(a[W[m]]==k and"  (worn)"or"")end return V[f].."  "..ag[f].."G"end function start()d.ink("fast")ad=bb()if not ad then Y()end end function key(c)if i=="title"then local k=ad and 2 or 1 O(c,k)if c=="ok"then if k==2 and l==1 then i="map"return end Y()y()T("King","Welcome, heir of the old guard.^The Ashen Wyrm Vorthax has swallowed the dawn. ".."Veldra lies under cinder.^Take these 100 gold. Find his keep in the southern sea, and end him.")end elseif i=="map"then D=nil if ae[c]then bj(c)else y();i,l="menu",1 end elseif i=="talk"then local g=X.f i="map"if g then g()end elseif i=="menu"then if c=="top"then return end O(c,3)if c=="ok"then i=l==1 and"spells"or l==2 and"items"or"map"l=1 end elseif i=="spells"or i=="items"then local w=i=="spells"local v=w and aa()or ac(false)local f=v[l]O(c,#v+1)if c=="top"or c=="ok"and not f then i,l="menu",w and 1 or 2;return end if c~="ok"then return end if w then D=aD(f,false)elseif f=="T"then D=bi()else D=aV(f,false)end i="map"y()elseif i=="shop"then local k=p.inn and 2 or#p.list+1 O(c,k)if c=="top"or c=="ok"and l==k then i="map"elseif c~="ok"then return elseif not p.inn then p.note=a3(p.list[l])elseif a.g<p.inn then p.note="You can't afford a room."else a.g=a.g-p.inn a.hp,a.mp=H(),K()p.note="You rest soundly. Good morning!"end y()elseif i=="fight"then if h.ph~="cmd"then if h.ph=="lost"then return aG()end i="map"if h.ph=="won"and h.id==12 then a.boss=1;i="end"end return y()end local U=h.sub local v=U=="s"and aa()or U=="i"and ac(true)or nil if c=="top"then if U then h.sub,l=nil,1 end return end O(c,v and#v+1 or 4)if c~="ok"then return end local f=l if not U then if f==1 then at(a2)elseif f==4 then at(a8)else h.sub,l=f==2 and"s"or"i",1 end return end f=v[f]h.sub,l=nil,1 if not f then return end at(function()local e,au if U=="s"then e,au=aD(f,true)else e,au=aV(f,true)end if e then q(e)end return au end)elseif i=="end"then if c=="ok"then i="map"end end end local function a5()local b=A(a.m)d.title(b.name)d.text(_().."  G "..a.g.."  Lv "..a.lv)d.small(D or" ")local aK,aL=aC//2,aB//2 local aR=b.dark and math.max(1,a.light)or 99 local aQ,aN={},{}for aw=0,aB-1 do local t=a.y-aL+aw for av=0,aC-1 do local o=a.x-aK+av aN[av+1]=av==aK and aw==aL and"H"or(math.abs(o-a.x)>aR or math.abs(t-a.y)>aR)and"#"or aU(b,o,t)end aQ[aw+1]=table.concat(aN)end d.hint("Arrows walk   OK menu")d.board(table.concat(aQ,"/"))end function draw()if i=="title"then d.title("Wyrmsbane")d.center(true)d.image("logo")d.image("m12")d.center(false)S(ad and{"Continue","New Quest"}or{"New Quest"})d.hint("UP/DOWN choose   OK start")elseif i=="map"then a5()elseif i=="talk"then d.title(X.who)for ai,aq in ipairs(X.p)do d.text(aq)end d.gap()d.small("OK continue")d.hint("OK continue")elseif i=="menu"then d.title("Hero  Lv "..a.lv.."   EXP "..a.xp.."/"..ao(a.lv))d.text(_().."   Gold "..a.g)d.text("Attack "..ak().."   Defense "..aF().."   Agility "..aj())d.small(x(1,a.ew)..", "..x(2,a.ea)..", "..x(3,a.es))d.small(("Herbs %d  Torches %d  Wings %d  Keys %d"):format(a.h,a.t,a.w,a.k)..(a.tide==1 and"  Tidestone"or""))d.rule()S({"Spells","Items","Close"})d.gap()d.small("Progress saved. BACK again to leave.")d.hint("OK choose   BACK leave")elseif i=="spells"or i=="items"then local w=i=="spells"d.title(w and"Spells"or"Items")S(w and aa()or ac(false),w)d.small(_())d.hint("OK use   BACK menu")elseif i=="shop"then d.title(p.t)d.text(p.note)d.gap()if p.inn then d.row("Stay the night",l==1)else for j,f in ipairs(p.list)do d.row(bf(f),l==j)end end d.row("Leave",l==(p.inn and 2 or#p.list+1))d.gap()d.small("Gold "..a.g)d.hint("OK buy   BACK leave")elseif i=="fight"then d.title(h.m.n)d.center(true)d.image("m"..h.id)d.center(false)for ai,C in ipairs(h.log)do d.small(C)end d.rule()if h.ph~="cmd"then d.row("Continue",true)elseif h.sub then S(h.sub=="s"and aa()or ac(true),h.sub=="s")else S({"Fight","Spell","Item","Flee"})end d.small("Lv "..a.lv.."  ".._())d.hint("OK choose   BACK back")elseif i=="end"then d.title("Dawn")d.center(true)d.image("sun")d.text("Vorthax falls, and the ash lifts from Veldra.")d.text("The sun rises over Castle Hale once more.")d.gap()d.title("THE END")d.center(false)d.row("Keep exploring",true)d.hint("OK continue")end end
