
'********************************************************************
' Creat By UnLiMiTeD Corporation 2014/2020 all copiright reserved   *
' http://e-gamer.wix.com/e-gamer                                    *
' Créé avec : LibertyBasic 4.51 (Pro edition)                       *
'********************************************************************

nomainwin
build2$ = "2014-2020" : versionGame = 5.81 : start = 1 : help = 0 : version = 1 :  factor = 1 : FPSmonitor = 0
sprites1$ = "perso1d perso2d perso3d perso4d perso1s perso2s perso3s perso4s perso1q perso2q perso3q perso4q perso1z perso2z perso3z perso4z E1 E2 E3 cata1 cata2 cata3 cata4 bullet persoDEAD ED1 atk"
sprites2$ = "nuage1 nuage2 nuage3 nuage4 OPTIONS ABOUT SAVE main UP HEAL HEAL2 sav load HELP quit fps music panteon"
for s = 1 to 27
    loadbmp word$(sprites1$,s), "data\perso\"+word$(sprites1$,s)+".bmp"
next
for s = 1 to 18
    loadbmp word$(sprites2$,s), "data\main\"+word$(sprites2$,s)+".bmp"
next

[INI]
timer 0
xp = 00 : xpTotal = 50 : lvl = 1 : Score = 0 : main = 0 : Gold = 1000 : Units = 0 : waveNumber = 1 : nom$ = "E1" : dir$ = "bmp\perso"
HEROpv = 200 : HEROatk = 15 : HEROdef = 2 : HEROpvTOTAL = 200 : regenCompteurLimite = 20 : regenCompteur = 0 : regen = 1 : regenCompteur2Limite = 10 : Movecata1 = 0
MoveE1 = 0 : MoveE2 = MoveE1 : MoveE3 = MoveE2 : MoveE4 = MoveE3 : MoveE5 = MoveE4 : MoveE6 = MoveE5 : MoveE7 = MoveE6 : MoveE8 = MoveE7 : MoveE9 = MoveE8 : MoveE10 = MoveE9
MoveE11 = MoveE10 : MoveE12 = MoveE11 : MoveE13 = MoveE12 : MoveE14 = MoveE13 : MoveE15 = MoveE14 : MoveE16 = MoveE15 : MoveE17 = MoveE16 : MoveE18 = MoveE17 : MoveE19 = MoveE18 : MoveE20 = MoveE19
MoveE21 = MoveE20 : MoveE22 = MoveE21 : MoveE23 = MoveE22 : MoveE24 = MoveE23 : MoveE25 = MoveE24 : MoveE26 = MoveE25 : MoveE27 = MoveE26 : MoveE28 = MoveE27 : MoveE29 = MoveE28 : MoveE30 = MoveE29
MoveE31 = MoveE30 : MoveE32 = MoveE31 : MoveE33 = MoveE32 : MoveE34 = MoveE33 : MoveE35 = MoveE34 : MoveE36 = MoveE35 : MoveE37 = MoveE36 : MoveE38 = MoveE37 : MoveE39 = MoveE38 : MoveE40 = MoveE39
MoveE41 = MoveE40 : MoveE42 = MoveE41 : MoveE43 = MoveE42 : MoveE44 = MoveE43 : MoveE45 = MoveE44 : MoveE46 = MoveE45 : MoveE47 = MoveE46 : MoveE48 = MoveE47 : MoveE49 = MoveE48 : MoveE50 = MoveE49
MoveE51 = MoveE50 : MoveE52 = MoveE51 : MoveE53 = MoveE52 : MoveE54 = MoveE53 : MoveE55 = MoveE54 : MoveE56 = MoveE55 : MoveE57 = MoveE56 : MoveE58 = MoveE57 : MoveE59 = MoveE58 : MoveE60 = MoveE59
MoveE61 = MoveE60 : MoveE62 = MoveE61 : MoveE63 = MoveE62 : MoveE64 = MoveE63 : MoveE65 = MoveE64 : MoveE66 = MoveE65 : MoveE67 = MoveE66 : MoveE68 = MoveE67 : MoveE69 = MoveE68 : MoveE70 = MoveE69
MoveE71 = MoveE70 : MoveE72 = MoveE71 : MoveE73 = MoveE72 : MoveE74 = MoveE73 : MoveE75 = MoveE74 : MoveE76 = MoveE75 : MoveE77 = MoveE76 : MoveE78 = MoveE77 : MoveE79 = MoveE78 : MoveE80 = MoveE79
MoveE81 = MoveE80 : MoveE82 = MoveE81 : MoveE83 = MoveE82 : MoveE84 = MoveE83 : MoveE85 = MoveE84 : MoveE86 = MoveE85 : MoveE87 = MoveE86 : MoveE88 = MoveE87 : MoveE89 = MoveE88 : MoveE90 = MoveE89
MoveE91 = MoveE90 : MoveE92 = MoveE91 : MoveE93 = MoveE92 : MoveE94 = MoveE93 : MoveE95 = MoveE94 : MoveE96 = MoveE95 : MoveE97 = MoveE96 : MoveE98 = MoveE97 : MoveE99 = MoveE98 : MoveE100 = MoveE99
castlePVtotal = 5000 : castlePV = castlePVtotal : castleArmor = 6 : castleREGEN = 5: lvlHPhero = 1 : lvlARMORhero = 1 : lvlATKhero = 1 : lvlREGENhero = 1
perso1dx=200 :perso1dy=500 : persoDEADy = perso1dy : persoDEADx = perso1dx : EDx = -100 : EDy = -100 : securPointcata1 = 0
CoutUPcastleHP = int(castlePVtotal/10)*2 : CoutUPcastleARMOR =  int(castleArmor*20+(castlePVtotal/4)) : CoutUPcastleREGEN =  int(castleREGEN*5)

if start = 1 then goto [ini]
'close #main
if menuGame = 1 then close #menuGame
menuGame = 0

[ini]
timer 0
start = 2 : main = 0
WindowWidth=1300 : WindowHeight=750 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)
graphicbox #debut.map, 0, 0, 1300, 750
open "" for window_nf as #debut
#debut, "trapclose [quit]"
#debut.map, "down;fill white"
#debut.map, "when leftButtonDown [SimpleClick1]"
#debut.map, "font Times New Roman 50 bold; color black;backcolor white"
#debut.map, "place 350 160;\";"          EMPIRE\CASTLE DEFENSE"
#debut.map, "font Times New Roman 25; color black;backcolor white"
if version = 1 then #debut.map, "place 495 382;\";"NOUVELLE PARTIE"
if version = 2 then #debut.map, "place 500 382;\";"START NEW GAME"
#debut.map, "font Times New Roman 12; color black;backcolor white"
#debut.map, "place 570 650;\";"Production 2014-2020"
#debut.map, "place 525 680;\";"Liberty Basic 4.51 Professional license"
#debut.map, "place 617 553;\";"Scores"
#debut.map, "place 605 270;\";"Version ";versionGame
#debut.map, "font Times New Roman 7; color black"
#debut.map, "drawbmp OPTIONS 540 470"
#debut.map, "drawbmp SAVE 620 470"
#debut.map, "drawbmp ABOUT 700 470"
#debut.map, "drawbmp panteon 605 565"
print #debut.map, "color black;size 1"
print #debut.map, "line "; 450; " "; 335; " "; 835; " "; 335
print #debut.map, "line "; 450; " "; 405; " "; 835; " "; 405
print #debut.map, "line "; 450; " "; 335; " "; 450; " "; 405
print #debut.map, "line "; 835; " "; 335; " "; 835; " "; 405
#debut.map, "flush"
if Setting = 2 then goto [setting]
wait

[SimpleClick1]
mX = MouseX : mY = MouseY
'notice mX; "/";mY
if mX>440 and mX<840 and mY>320 and mY<420 then close #debut : goto [Game]
if mX>540 and mX<580 and mY>470 and mY<505 then goto [setting]
if mX>620 and mX<660 and mY>470 and mY<505 then goto [load]
if mX>700 and mX<740 and mY>470 and mY<505 then goto [about]
if mX>605 and mX<675 and mY>565 and mY<600 then goto [score]
wait

[w]
wait

[score]
WindowWidth=450 : WindowHeight=420
UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)
if pant = 1 then close #pant
pant = 1
open "data\score.sys" for input as #save
input #save, score1
input #save, score2
input #save, score3
input #save, score4
input #save, score5
input #save, score6
input #save, score7
input #save, score8
input #save, score9
input #save, score10
input #save, score11
input #save, score12
input #save, score13
input #save, score14
input #save, score15
input #save, score16
input #save, score17
input #save, score18
input #save, score19
input #save, score20
input #save, Namescore1$
input #save, Namescore2$
input #save, Namescore3$
input #save, Namescore4$
input #save, Namescore5$
input #save, Namescore6$
input #save, Namescore7$
input #save, Namescore8$
input #save, Namescore9$
input #save, Namescore10$
input #save, Namescore11$
input #save, Namescore12$
input #save, Namescore13$
input #save, Namescore14$
input #save, Namescore15$
input #save, Namescore16$
input #save, Namescore17$
input #save, Namescore18$
input #save, Namescore19$
input #save, Namescore20$
close #save
graphicbox #pant.pant, 0, 0, 450, 420
open "" for window_nf as #pant
#pant, "trapclose [about3]"
#pant.pant, "font Times New Roman 12 bold; color black;backcolor white"
if version = 1 then #pant.pant, "place 20 20;\";"Panthéon des meilleurs Scores"
if version = 2 then #pant.pant, "place 20 20;\";"Pantheon : Best Scores"
#pant.pant, "font Times New Roman 9; color blue;backcolor white"
if version = 1 then
    #pant.pant, "place 20 50;\";"Première place  :  ";score1 ; " - "; Namescore1$
    #pant.pant, "place 20 70;\";"Seconde place  :  ";score2 ; " - "; Namescore2$
    #pant.pant, "place 20 90;\";"Troisième place  :  ";score3 ; " - "; Namescore3$
end if
if version = 2 then
    #pant.pant, "place 20 50;\";"First place  :  ";score1 ; " - "; Namescore1$
    #pant.pant, "place 20 70;\";"Second place  :  ";score2 ; " - "; Namescore2$
    #pant.pant, "place 20 90;\";"Third place  :  ";score3 ; " - "; Namescore3$
end if
#pant.pant, "font Times New Roman 9; color red;backcolor white"
#pant.pant, "place 20 125;\";"# 4  :  ";score4 ; " - "; Namescore4$
#pant.pant, "place 20 140;\";"# 5  :  ";score5 ; " - "; Namescore5$
#pant.pant, "place 20 155;\";"# 6  :  ";score6 ; " - "; Namescore6$
#pant.pant, "place 20 170;\";"# 7  :  ";score7 ; " - "; Namescore7$
#pant.pant, "place 20 185;\";"# 8  :  ";score8 ; " - "; Namescore8$
#pant.pant, "place 20 200;\";"# 9  :  ";score9 ; " - "; Namescore9$
#pant.pant, "place 20 215;\";"# 10  :  ";score10 ; " - "; Namescore10$
#pant.pant, "place 20 230;\";"# 11  :  ";score11 ; " - "; Namescore11$
#pant.pant, "place 20 245;\";"# 12  :  ";score12 ; " - "; Namescore12$
#pant.pant, "place 20 260;\";"# 13  :  ";score13 ; " - "; Namescore13$
#pant.pant, "place 20 275;\";"# 14  :  ";score14 ; " - "; Namescore14$
#pant.pant, "place 20 290;\";"# 15  :  ";score15 ; " - "; Namescore15$
#pant.pant, "place 20 305;\";"# 16  :  ";score16 ; " - "; Namescore16$
#pant.pant, "place 20 320;\";"# 17  :  ";score17 ; " - "; Namescore17$
#pant.pant, "place 20 335;\";"# 18  :  ";score18 ; " - "; Namescore18$
#pant.pant, "place 20 350;\";"# 19  :  ";score19 ; " - "; Namescore19$
#pant.pant, "place 20 365;\";"# 20  :  ";score20 ; " - "; Namescore20$
wait



[about]
WindowWidth=450 : WindowHeight=120
UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)
if about = 1 then close #about
about = 1
if version = 1 then statictext #about.txt,"Empire : Castle defense ® ";build2$;" par  ALEXANDRE LOMUTO                    Musique : Airship Thunderchild par Otto Halmen", 75, 32, 330, 30
if version = 2 then statictext #about.txt,"Empire : Castle defense ® ";build2$;" by  ALEXANDRE LOMUTO                    Music : Airship Thunderchild by Otto Halmen", 75, 32, 330, 30
button #about, "Fermer" , [about2], LR, 265, 10,120,25
open "" for window_popup as #about
#about, "trapclose [about2]"
wait
[about2]
close #about : about = 0 : wait
[about3]
close #pant : pant = 0 : wait

[setting]
if Setting = 1 then close #setting
Setting = 1
WindowWidth = 270 : WindowHeight = 125 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)
checkbox #setting.cb1, "Fr", [LangueFR], [LangueFR], 130, 10, 40, 20
checkbox #setting.cb2, "Eng", [LangueENG], [LangueENG], 190, 10, 40, 20
checkbox #setting.cb3, "On", [musicOn], [musicOff], 130, 30, 40, 20
checkbox #setting.cb4, "Off", [musicOff], [musicOn], 190, 30, 40, 20
checkbox #setting.cb5, "On", [RageModeOn], [RageModeOff], 130, 50, 40, 20
checkbox #setting.cb6, "Off", [RageModeOff], [RageModeOn], 190, 50, 40, 20
checkbox #setting.cb7, "On", [FPSOn], [FPSOff], 130, 70, 40, 20
checkbox #setting.cb8, "Off", [FPSOff], [FPSOn], 190, 70, 40, 20
if version = 1 then
   statictext #setting, "Langue", 10, 10, 60, 20
   statictext #setting, "Musique", 10, 30, 60, 20
   statictext #setting, "Mode rage", 10, 50, 100, 20
   statictext #setting, "Affichage des FPS", 10, 70, 100, 20
end if
if version = 2 then
   statictext #setting, "Language", 10, 10, 60, 20
   statictext #setting, "Music", 10, 30, 60, 20
   statictext #setting, "Rage Mode", 10, 50, 100, 20
   statictext #setting, "FPS Monitor", 10, 70, 100, 20
end if
Open "" for window_nf As #setting
if version = 1 then print #setting.cb1, "set" : print #setting.cb2, "reset"
if version = 2 then print #setting.cb2, "set" : print #setting.cb1, "reset"
if music = 1 then print #setting.cb3, "set" : print #setting.cb4, "reset"
if music = 0 then print #setting.cb4, "set" : print #setting.cb3, "reset"
if factor = 10 then print #setting.cb5, "set" : print #setting.cb6, "reset"
if factor = 1 then print #setting.cb6, "set" : print #setting.cb5, "reset"
if FPSmonitor = 1 then print #setting.cb7, "set" : print #setting.cb8, "reset"
if FPSmonitor = 0 then print #setting.cb8, "set" : print #setting.cb7, "reset"
#setting, "trapclose [quitSetting]"
#setting, "font Times New Roman 10 bold; color black"
wait

[FPSOn]
FPSmonitor = 1 : print #setting.cb7, "set" : print #setting.cb8, "reset" : wait
[FPSOff]
FPSmonitor = 0 : print #setting.cb8, "set" : print #setting.cb7, "reset" : wait
[LangueFR]
version = 1 : Setting = 0 : close #setting
if main = 0 then close #debut : goto [ini]
if main = 1 then close #main : goto [Game2]
[LangueENG]
version = 2 : Setting = 0 : close #setting
if main = 0 then close #debut : goto [ini]
if main = 1 then close #main : goto [Game2]
[musicOn]
music = 1 : print #setting.cb3, "set" : print #setting.cb4, "reset" : goto [iniMUSIC2]
[musicOff]
music = 0 : print #setting.cb4, "set" : print #setting.cb3, "reset" : goto [iniMUSIC]
[RageModeOn]
factor = 10 : print #setting.cb5, "set" : print #setting.cb6, "reset" : wait
[RageModeOff]
factor = 1 : print #setting.cb6, "set" : print #setting.cb5, "reset" : wait

[menuBACK]
timer 0
if menuGame = 1 then close #menuGame
if infoGame = 1 then close #info
menuGame = 0 : infoGame = 0
goto [INI]

[menuGame]
timer 0
if menuGame = 1 then close #menuGame
WindowWidth=160 : WindowHeight=220 : menuGame = 1
UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #menuGame.titre,"MENU", 45, 15, 200, 30
button #menuGame, "Menu" , [menuBACK], UL, 35, 50,80,25
if version = 1 then
   button #menuGame, "Sauvegarder" , [save], UL, 35, 80,80,25
   button #menuGame, "Aide" , [GameINI], UL, 35, 110,80,25
   button #menuGame, "Options" , [setting], UL, 35, 140,80,25
end if
if version = 2 then
   button #menuGame, "Save" , [save], UL, 35, 80,80,25
   button #menuGame, "Help" , [GameINI], UL, 35, 110,80,25
   button #menuGame, "Options" , [setting], UL, 35, 140,80,25
end if
open "" for window_nf as #menuGame
#menuGame, "trapclose [quitMenu]"
print #menuGame.titre, "!font Times New Roman 16 bold"
wait

[GameINI]
timer 0
if help = 1 then close #ini
help = 1 : WindowWidth=450 : WindowHeight=350
UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)
if version = 1 then
   statictext #ini.titre,"Contrôle et Aide :", 20, 20, 200, 15
   statictext #ini.titre2,"But du jeu :", 20, 130, 200, 15
   txt1$ = "Utilisez la souris de votre ordinateur pour vous déplacer. Clickez sur la zone que vous souhaité viser et votre personnage se déplacera la-bas. Une fois en contact avec les ennemis vos attaques se déclenche directement. Vous recevrez aussi leurs attaques."
   txt2$ = "Allez toujours plus loin ! Combattez jusqu'à que votre personnage n'est plus de force ou que vos remparts tombent. Plus vous allez loin et plus votre scoore augmentera. Défendez vos foritifications en tuant tous vos ennemis. De nombreuses améliorations vous aiderons dans votre destinée!"
 '  button #ini, "Fermer" , [quitHELP], LR, 265, 15,120,25
end if
if version = 2 then
   statictext #ini.titre,"Control and Help", 90, 20, 200, 15
   statictext #ini.titre2,"Goal :", 20, 130, 200, 15
   txt1$ = "You just have to use your mouse and click on ennemies for attack and kill it."
   txt2$ = "Kill all the enemies before your castle has 0 points of life. How? Your hero can hit points of damage by attacking the enemy (darken over several times! Each colision is a clash that hit an attack). Use it to kill your enemies. Good luck!"
  ' button #ini, "Close" , [quitHELP], LR, 265, 20,120,25
end if
statictext #ini.txt,txt1$, 20, 40, 400, 60
statictext #ini.txt,txt2$, 20, 150, 400, 80
open "" for window_nf as #ini
#ini, "trapclose [quitHELP]"
#ini, "font Times New Roman 10 bold; color black"
print #ini.titre, "!font Times New Roman 10 bold"
print #ini.titre2, "!font Times New Roman 10 bold"
wait

[Game]
timer 0
WindowWidth=1300 : WindowHeight=808 : main = 1 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)
graphicbox #main.menu, 0, 0, 1300, 30
graphicbox #main.map, 0, 30, 1300, 750
open "" for window_nf as #main
#main, "trapclose [quit]"
#main.map, "down;setfocus; when leftButtonDown [SimpleClickStart]"
#main.menu, "fill white;when leftButtonDown [SimpleClickStart2]"
#main.map, "drawbmp main 0 0"
#main.map, "background main"
gosub [loadSprites]
#main.menu, "drawbmp UP 5 3"
#main.menu, "drawbmp HEAL 30 3"
#main.menu, "drawbmp UP 230 3"
#main.menu, "drawbmp HEAL2 255 3"
#main.menu, "drawbmp music 980 2"
#main.menu, "drawbmp sav 1040 3"
#main.menu, "drawbmp load 1070 3"
#main.menu, "drawbmp HELP 1100 3"
#main.menu, "drawbmp quit 1130 3"
#main.menu, "drawbmp fps 1160 3"
#main.map,"addsprite persoDEAD persoDEAD"
#main.map,"addsprite perso1d perso2d perso3d perso4d"
#main.map,"addsprite perso1q perso2q perso3q perso4q"
#main.map,"addsprite perso1s perso2s perso3s perso4s"
#main.map,"addsprite perso1z perso2z perso3z perso4z"
#main.map, "addsprite E1 E2 E3"
#main.map, "addsprite cata1 cata1"
#main.map, "addsprite cata2 cata2"
#main.map, "addsprite cata3 cata3"
#main.map, "addsprite cata4 cata4"
#main.map, "addsprite bullet bullet"
#main.map, "addsprite ED1 ED1"
#main.map, "addsprite nuage1 nuage1"
#main.map, "addsprite nuage2 nuage2"
#main.map, "addsprite nuage3 nuage3"
#main.map, "addsprite nuage4 nuage4"
#main.map, "addsprite atk atk"
nomV$ = "E1" : nomD$ = "ED1" : nombre = 99
for i = 1 to nombre
    #main.map, "addsprite ";nomV$;i;" E2 E3 E1"
    #main.map, "addsprite ";nomD$;i;" ED1 "
next
#main.map,"spritexy perso1d ";perso1dx;" ";perso1dy
#main.map,"spritexy persoDEAD ";persoDEADx;" ";persoDEADy
perso1zx=perso1dx:perso1zy=perso1dy : perso1qx=perso1dx:perso1qy=perso1dy : perso1sx=perso1dx:perso1sy=perso1dy
nuage1x = -20 : nuage1y = 170 : nuage2x = -120 : nuage2y = 60 : nuage3x = 120 : nuage3y = 155 : nuage4x = 450 : nuage4y = 130
#main.map,"spritexy nuage1 ";nuage1x;" ";nuage1y
#main.map,"spritexy nuage2 ";nuage2x;" ";nuage2y
#main.map,"spritexy nuage3 ";nuage3x;" ";nuage3y
#main.map,"spritexy nuage4 ";nuage4x;" ";nuage4y
#main.map,"spritexy nuage4 ";nuage4x;" ";nuage4y
#main.map,"spritexy atk -100 -100"
#main.map,"SpriteVisible perso1z off"
#main.map,"SpriteVisible perso1q off"
#main.map,"SpriteVisible perso1s off"
#main.map,"SpriteVisible persoDEAD off"
#main.map,"SpriteVisible bullet off"
#main.map,"SpriteVisible cata1 off"
#main.map,"SpriteVisible cata2 off"
#main.map,"SpriteVisible cata3 off"
#main.map,"SpriteVisible cata4 off"
#main.map, "font Times New Roman 10; color black"
#main.menu, "font Times New Roman 10; color black"
#main.map,"drawsprites"
#main.map, "flush"
#main.menu, "color black;size 1"
#main.menu, "line 950 0 950 50"
#main.menu, "line 650 0 650 50"
#main.menu, "line 480 0 480 50"
#main.menu, "line 220 0 220 50"
#main.menu, "flush"
#main.menu, "font Times New Roman 8 bold; color black;backcolor white"
startSECURITY = 1
wait

[SimpleClickStart]
mX = MouseX : mY = MouseY
'mY = mY - 15 : mX = mX - 5
if mY < 30 then wait
timer 0
'notice mX;" / "; mY
if upgradeHERO = 1 then close #upgradeHERO : upgradeHERO = 0
if upgradeCASTLE = 1 then close #upgradeCASTLE : upgradeCASTLE = 0
if mX > perso1dx then goto [marcheDROITE2]
if mX < perso1qx then goto [marcheGAUCHE2]
if mY < perso1zy then goto [marcheHAUT2]
if mY > perso1sy then goto [marcheBAS2]
timer 10, [Eq]
wait

[SimpleClickStart2]
mX = MouseX : mY = MouseY
'notice mX;" / "; mY
if mX > 980 and mX < 1005 and mY > 2 and mY < 25 and MusicSELECT = 0 then goto [iniMUSIC2]
if mX > 980 and mX < 1005 and mY > 2 and mY < 25 and MusicSELECT = 1 then goto [iniMUSIC]
if mX > 5 and mX < 28 and mY > 3 and mY < 25 then goto [upgradeCASTLE]
if mX > 30 and mX < 53 and mY > 3 and mY < 25 then
    timer 0
    if version = 1 and castlePV = castlePVtotal then notice " " + chr$(13) + "Vos fortifications n'ont pas besoin d'être réparées ! " : wait
    if version = 2 and castlePV = castlePVtotal then notice " " + chr$(13) + "Your castle is full life, you dont need to repair ! " : wait
    goto [repair]
end if
if mX > 230 and mX < 255 and mY > 3 and mY < 25 then goto [upgradeHERO]
if mX > 256 and mX < 281 and mY > 3 and mY < 25 then
    timer 0
    if version = 1 and HEROpv = HEROpvTOTAL then notice " " + chr$(13) + " Votre héro est en bonne santé ! " : wait
    if version = 2 and HEROpv = HEROpvTOTAL then notice " " + chr$(13) + " Your character is full life, you dont need heal! " : wait
    goto [repair2]
end if
if mX > 1130 and mX < 1153 and mY > 3 and mY < 25 then
    timer 0
    if version = 1 then confirm "Voulez vous quitter la partie et revenir au menu principal ?";confirm$
    if version = 2 then confirm "Would you like to return to main menu ?";confirm$
    if confirm$ = "no" then timer 10, [Eq] : wait
    close #main : goto [INI]
end if
if mX > 1040 and mX < 1063 and mY > 3 and mY < 25 then goto [save]
if mX > 1070 and mX < 1093 and mY > 3 and mY < 25 then goto [loadS]
if mX > 1100 and mX < 1123 and mY > 3 and mY < 25 then goto [GameINI]
if mX > 1160 and mX < 1183 and mY > 3 and mY < 25 then
    if FPSmonitor = 0 then FPSmonitor = 1 : wait
    if FPSmonitor = 1 then FPSmonitor = 0 : wait
end if
wait

'----ajout des scoores ----------------------------------------------------------------------------------------------

[addTOscoore]
close #main
WindowWidth=250 : WindowHeight=160 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)
BackgroundColor$ = "white" : ForegroundColor$ = "black"
graphicbox #score.map, 0, 0, WindowWidth, WindowHeight
textbox #score.login, 20, 50, 200, 20
button #score.default, "VALIDER", [addTOscoore2],UL 80,85,80,25
open "" for dialog_nf as #score
print #score, "trapclose [addTOscoore2]"
print #score.map , "down;fill white;font Times Times New Roman 9"
print #score.map, "place 50 35 ;\"; "Indiquez votre nom : "
WAIT

[addTOscoore2]
print #score.login, "!contents? namePLAYER$"
close #score
open "data\score.sys" for input as #save
input #save, score1
input #save, score2
input #save, score3
input #save, score4
input #save, score5
input #save, score6
input #save, score7
input #save, score8
input #save, score9
input #save, score10
input #save, score11
input #save, score12
input #save, score13
input #save, score14
input #save, score15
input #save, score16
input #save, score17
input #save, score18
input #save, score19
input #save, score20
input #save, Namescore1$
input #save, Namescore2$
input #save, Namescore3$
input #save, Namescore4$
input #save, Namescore5$
input #save, Namescore6$
input #save, Namescore7$
input #save, Namescore8$
input #save, Namescore9$
input #save, Namescore10$
input #save, Namescore11$
input #save, Namescore12$
input #save, Namescore13$
input #save, Namescore14$
input #save, Namescore15$
input #save, Namescore16$
input #save, Namescore17$
input #save, Namescore18$
input #save, Namescore19$
input #save, Namescore20$
close #save

if Score >= score20 then
    if Score >= score19 then
        if Score >= score18 then
            if Score >= score17 then
                if Score >= score16 then
                    if Score >= score15 then
                        if Score >= score14 then
                            if Score >= score13 then
                                if Score >= score12 then
                                    if Score >= score11 then
                                        if Score >= score10 then
                                            if Score >= score9 then
                                                if Score >= score8 then
                                                    if Score >= score7 then
                                                        if Score >= score6 then
                                                            if Score >= score5 then
                                                                if Score >= score4 then
                                                                    if Score >= score3 then
                                                                        if Score >= score2 then
                                                                            if Score >= score1 then score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = score13 : Namescore14$ = Namescore13$ : score13 = score12 : Namescore13$ = Namescore12$ : score12 = score11 : Namescore12$ = Namescore11$ : score11 = score10 : Namescore11$ = Namescore10$ : score10 = score9 : Namescore10$ = Namescore9$ : score9 = score8 : Namescore9$ = Namescore8$ : score8 = score7 : Namescore8$ = Namescore7$ : score7 = score6 : Namescore7$ = Namescore6$ : score6 = score5 : Namescore6$ = Namescore5$ : score5 = score4 : Namescore5$ = Namescore4$ : score4 = score3 : Namescore4$ = Namescore3$ : score3 = score2 : Namescore3$ = Namescore2$ : score2 = score1 : Namescore2$ = Namescore1$ : score1 = Score : Namescore1$ = namePLAYER$ : goto [endingScore]
                                                                            score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = score13 : Namescore14$ = Namescore13$ : score13 = score12 : Namescore13$ = Namescore12$ : score12 = score11 : Namescore12$ = Namescore11$ : score11 = score10 : Namescore11$ = Namescore10$ : score10 = score9 : Namescore10$ = Namescore9$ : score9 = score8 : Namescore9$ = Namescore8$ : score8 = score7 : Namescore8$ = Namescore7$ : score7 = score6 : Namescore7$ = Namescore6$ : score6 = score5 : Namescore6$ = Namescore5$ : score5 = score4 : Namescore5$ = Namescore4$ : score4 = score3 : Namescore4$ = Namescore3$ : score3 = score2 : Namescore3$ = Namescore2$ : score2 = Score : Namescore2$ = namePLAYER$ : goto [endingScore]
                                                                        end if
                                                                        score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = score13 : Namescore14$ = Namescore13$ : score13 = score12 : Namescore13$ = Namescore12$ : score12 = score11 : Namescore12$ = Namescore11$ : score11 = score10 : Namescore11$ = Namescore10$ : score10 = score9 : Namescore10$ = Namescore9$ : score9 = score8 : Namescore9$ = Namescore8$ : score8 = score7 : Namescore8$ = Namescore7$ : score7 = score6 : Namescore7$ = Namescore6$ : score6 = score5 : Namescore6$ = Namescore5$ : score5 = score4 : Namescore5$ = Namescore4$ : score4 = score3 : Namescore4$ = Namescore3$ : score3 = Score : Namescore3$ = namePLAYER$ : goto [endingScore]
                                                                    end if
                                                                    score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = score13 : Namescore14$ = Namescore13$ : score13 = score12 : Namescore13$ = Namescore12$ : score12 = score11 : Namescore12$ = Namescore11$ : score11 = score10 : Namescore11$ = Namescore10$ : score10 = score9 : Namescore10$ = Namescore9$ : score9 = score8 : Namescore9$ = Namescore8$ : score8 = score7 : Namescore8$ = Namescore7$ : score7 = score6 : Namescore7$ = Namescore6$ : score6 = score5 : Namescore6$ = Namescore5$ : score5 = score4 : Namescore5$ = Namescore4$ : score4 = Score : Namescore4$ = namePLAYER$ : goto [endingScore]
                                                                end if
                                                                score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = score13 : Namescore14$ = Namescore13$ : score13 = score12 : Namescore13$ = Namescore12$ : score12 = score11 : Namescore12$ = Namescore11$ : score11 = score10 : Namescore11$ = Namescore10$ : score10 = score9 : Namescore10$ = Namescore9$ : score9 = score8 : Namescore9$ = Namescore8$ : score8 = score7 : Namescore8$ = Namescore7$ : score7 = score6 : Namescore7$ = Namescore6$ : score6 = score5 : Namescore6$ = Namescore5$ : score5 = Score : Namescore5$ = namePLAYER$ : goto [endingScore]
                                                            end if
                                                            score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = score13 : Namescore14$ = Namescore13$ : score13 = score12 : Namescore13$ = Namescore12$ : score12 = score11 : Namescore12$ = Namescore11$ : score11 = score10 : Namescore11$ = Namescore10$ : score10 = score9 : Namescore10$ = Namescore9$ : score9 = score8 : Namescore9$ = Namescore8$ : score8 = score7 : Namescore8$ = Namescore7$ : score7 = score6 : Namescore7$ = Namescore6$ : score6 = Score : Namescore6$ = namePLAYER$ : goto [endingScore]
                                                        end if
                                                        score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = score13 : Namescore14$ = Namescore13$ : score13 = score12 : Namescore13$ = Namescore12$ : score12 = score11 : Namescore12$ = Namescore11$ : score11 = score10 : Namescore11$ = Namescore10$ : score10 = score9 : Namescore10$ = Namescore9$ : score9 = score8 : Namescore9$ = Namescore8$ : score8 = score7 : Namescore8$ = Namescore7$ : score7 = Score : Namescore7$ = namePLAYER$ : goto [endingScore]
                                                    end if
                                                    score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = score13 : Namescore14$ = Namescore13$ : score13 = score12 : Namescore13$ = Namescore12$ : score12 = score11 : Namescore12$ = Namescore11$ : score11 = score10 : Namescore11$ = Namescore10$ : score10 = score9 : Namescore10$ = Namescore9$ : score9 = score8 : Namescore9$ = Namescore8$ : score8 = Score : Namescore8$ = namePLAYER$ : goto [endingScore]
                                                end if
                                                score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = score13 : Namescore14$ = Namescore13$ : score13 = score12 : Namescore13$ = Namescore12$ : score12 = score11 : Namescore12$ = Namescore11$ : score11 = score10 : Namescore11$ = Namescore10$ : score10 = score9 : Namescore10$ = Namescore9$ : score9 = Score : Namescore9$ = namePLAYER$ : goto [endingScore]
                                            end if
                                            score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = score13 : Namescore14$ = Namescore13$ : score13 = score12 : Namescore13$ = Namescore12$ : score12 = score11 : Namescore12$ = Namescore11$ : score11 = score10 : Namescore11$ = Namescore10$ : score10 = Score : Namescore10$ = namePLAYER$ : goto [endingScore]
                                        end if
                                        score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = score13 : Namescore14$ = Namescore13$ : score13 = score12 : Namescore13$ = Namescore12$ : score12 = score11 : Namescore12$ = Namescore11$ : score11 = Score : Namescore11$ = namePLAYER$ : goto [endingScore]
                                    end if
                                    score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = score13 : Namescore14$ = Namescore13$ : score13 = score12 : Namescore13$ = Namescore12$ : score12 = Score : Namescore12$ = namePLAYER$ : goto [endingScore]
                                end if
                                score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = score13 : Namescore14$ = Namescore13$ : score13 = Score : Namescore13$ = namePLAYER$ : goto [endingScore]
                            end if
                            score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = score14 : Namescore15$ = Namescore14$ : score14 = Score : Namescore14$ = namePLAYER$ : goto [endingScore]
                        end if
                        score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = score15 : Namescore16$ = Namescore15$ : score15 = Score : Namescore15$ = namePLAYER$ : goto [endingScore]
                    end if
                    score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = score16 : Namescore17$ = Namescore16$ : score16 = Score : Namescore16$ = namePLAYER$ : goto [endingScore]
                end if
                score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = score17 : Namescore18$ = Namescore17$ : score17 = Score : Namescore17$ = namePLAYER$ : goto [endingScore]
            end if
            score20 = score19 : Namescore20$ = Namescore19$ : score19 = score18 : Namescore19$ = Namescore18$ : score18 = Score : Namescore18$ = namePLAYER$ : goto [endingScore]
        end if
        score20 = score19 : Namescore20$ = Namescore19$ : score19 = Score : Namescore19$ = namePLAYER$ : goto [endingScore]
    end if
    score20 = Score : Namescore20$ = namePLAYER$ : goto [endingScore]
end if


[endingScore]
open "data\score.sys" for output as #save
print #save, score1
print #save, score2
print #save, score3
print #save, score4
print #save, score5
print #save, score6
print #save, score7
print #save, score8
print #save, score9
print #save, score10
print #save, score11
print #save, score12
print #save, score13
print #save, score14
print #save, score15
print #save, score16
print #save, score17
print #save, score18
print #save, score19
print #save, score20
print #save, Namescore1$
print #save, Namescore2$
print #save, Namescore3$
print #save, Namescore4$
print #save, Namescore5$
print #save, Namescore6$
print #save, Namescore7$
print #save, Namescore8$
print #save, Namescore9$
print #save, Namescore10$
print #save, Namescore11$
print #save, Namescore12$
print #save, Namescore13$
print #save, Namescore14$
print #save, Namescore15$
print #save, Namescore16$
print #save, Namescore17$
print #save, Namescore18$
print #save, Namescore19$
print #save, Namescore20$
close #save
goto [INI]

'----sauvegarde-----------------------------------------------------------------------------------------------------------------------|
[save]
timer 0
open "data\save.ini" for output as #save
print #save, dir$
print #save, nom$
print #save, version
print #save, xp
print #save, xpTotal
print #save, lvl
print #save, factor
print #save, Score
print #save, Gold
print #save, waveNumber
print #save, HEROpv
print #save, HEROpvTOTAL
print #save, HEROatk
print #save, HEROdef
print #save, regen
print #save, castlePVtotal
print #save, castlePV
print #save, castleArmor
print #save, castleREGEN
print #save, lvlARMORhero
print #save, lvlREGENhero
print #save, lvlATKhero
print #save, lvlHPhero
print #save, UnitsEtotal
CLOSE #save
if version = 1 then notice " " + chr$(13) + "Partie sauvegardée !"
if version = 2 then notice " " + chr$(13) + "Game saved !"
wait

'----chargement----------------------------------------------------------------------------------------------------------------|
[loadS]
TIMER 0
if version = 1 then confirm "Voulez vous charger la partie enregistrée ?";confirm$
if version = 2 then confirm "Would you like to load saved game ?"; confirm$
if confirm$ = "no" then wait
dir$ = "" : file$ = "data\save.ini"
if fileExist(dir$,file$) = 0 then
   if version = 1 then notice " " + chr$(13) + "Vous n'avez aucune sauvegarde d'enregistrée !"
   if version = 2 then notice " " + chr$(13) + "You have no backup saved!"
   timer 10, [Eq]
   wait
end if
close #main
goto [loading]
[load]
TIMER 0
if version = 1 then confirm "Voulez vous charger la partie enregistrée ?";confirm$
if version = 2 then confirm "Would you like to load saved game ?"; confirm$
if confirm$ = "no" then wait
dir$ = "" : file$ = "data\save.ini"
if fileExist(dir$,file$) = 0 then
   if version = 1 then notice " " + chr$(13) + "Vous n'avez aucune sauvegarde d'enregistrée !"
   if version = 2 then notice " " + chr$(13) + "You have no backup saved!"
   wait
end if
close #debut


[loading]
load = 1
open "data\save.ini" for input as #save
input #save, dir$
input #save, nom$
input #save, version
input #save, xp
input #save, xpTotal
input #save, lvl
input #save, factor
input #save, Score
input #save, Gold
input #save, waveNumber
input #save, HEROpv
input #save, HEROpvTOTAL
input #save, HEROatk
input #save, HEROdef
input #save, regen
input #save, castlePVtotal
input #save, castlePV
input #save, castleArmor
input #save, castleREGEN
input #save, lvlARMORhero
input #save, lvlREGENhero
input #save, lvlATKhero
input #save, lvlHPhero
input #save, UnitsEtotal
CLOSE #save
load = 1
UnitsE = UnitsEtotal
'CoutUPcastleHP = int(castlePVtotal/10)*2 : CoutUPcastleARMOR =  int(castleArmor*20+(castlePVtotal/4)) : CoutUPcastleREGEN =  int(castleREGEN*5)
goto [Game]

[lvlUPhero]
lvl = lvl +1
xpTotal = xpTotal + int( xpTotal/2 + int(25*waveNumber))
HEROpvTOTAL = HEROpvTOTAL + int(rnd(1)*(15*waveNumber)+1)
HEROpv = HEROpvTOTAL
HEROatk = HEROatk + int(rnd(1)*(5*waveNumber)+1)
HEROdef = HEROdef + int(rnd(1)*waveNumber)
regen = regen + waveNumber
return



'-----------------------------------------------------------------------------------
    [securPoints]
    UnitsE = UnitsE -1 : Gold = Gold + int((rnd(1)*30+1)*waveNumber)  : Score = Score + int(10*waveNumber) : xp = xp + int((rnd(1)*30+1)*waveNumber)
    if xp > xpTotal then gosub [lvlUPhero]
    return

    [colisions]
    dommage = int((rnd(1)*int(HEROatk+1))-defE) : dommageE = int((rnd(1)*int(atkE+1))-HEROdef/2) : if dommageE< 0 then dommageE = 0 : if dommage< 0 then dommage = 0
    if MoveE1>0 and int(E1x - perso1dx) <15  and int(E1x - perso1dx)  >-15 AND int(E1y - perso1dy)  <10 and int(E1y - perso1dy)  >-10 then PvE1 = int(PvE1 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE1 <= 0 then #main.map,"SpriteVisible E1 off"  : MoveE1 = 0 : if securPoint1 = 0 then gosub [securPoints] : securPoint1 = 1 : #main.map "spritetofront atk"
    if MoveE2>0 and int(E11x - perso1dx) <15 and int(E11x - perso1dx) >-15 AND int(E11y - perso1dy) <10 and int(E11y - perso1dy) >-10 then PvE2 = int(PvE2 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE2 <= 0 then #main.map,"SpriteVisible E11 off" : MoveE2 = 0 : if securPoint2 = 0 then gosub [securPoints] : securPoint2 = 1 : #main.map "spritetofront atk"
    if MoveE3>0 and int(E12x - perso1dx) <15 and int(E12x - perso1dx) >-15 AND int(E12y - perso1dy) <10 and int(E12y - perso1dy) >-10 then PvE3 = int(PvE3 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE3 <= 0 then #main.map,"SpriteVisible E12 off" : MoveE3 = 0 : if securPoint3 = 0 then gosub [securPoints] : securPoint3 = 1 : #main.map "spritetofront atk"
    if MoveE4>0 and int(E13x - perso1dx) <15 and int(E13x - perso1dx) >-15 AND int(E13y - perso1dy) <10 and int(E13y - perso1dy) >-10 then PvE4 = int(PvE4 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE4 <= 0 then #main.map,"SpriteVisible E13 off" : MoveE4 = 0 : if securPoint4 = 0 then gosub [securPoints] : securPoint4 = 1 : #main.map "spritetofront atk"
    if MoveE5>0 and int(E14x - perso1dx) <15 and int(E14x - perso1dx) >-15 AND int(E14y - perso1dy) <10 and int(E14y - perso1dy) >-10 then PvE5 = int(PvE5 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE5 <= 0 then #main.map,"SpriteVisible E14 off" : MoveE5 = 0 : if securPoint5 = 0 then gosub [securPoints] : securPoint5 = 1 : #main.map "spritetofront atk"
    if MoveE6>0 and int(E15x - perso1dx) <15 and int(E15x - perso1dx) >-15 AND int(E15y - perso1dy) <10 and int(E15y - perso1dy) >-10 then PvE6 = int(PvE6 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE6 <= 0 then #main.map,"SpriteVisible E15 off" : MoveE6 = 0 : if securPoint6 = 0 then gosub [securPoints] : securPoint6 = 1 : #main.map "spritetofront atk"
    if MoveE7>0 and int(E16x - perso1dx) <15 and int(E16x - perso1dx) >-15 AND int(E16y - perso1dy) <10 and int(E16y - perso1dy) >-10 then PvE7 = int(PvE7 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE7 <= 0 then #main.map,"SpriteVisible E16 off" : MoveE7 = 0 : if securPoint7 = 0 then gosub [securPoints] : securPoint7 = 1 : #main.map "spritetofront atk"
    if MoveE8>0 and int(E17x - perso1dx) <15 and int(E17x - perso1dx) >-15 AND int(E17y - perso1dy) <10 and int(E17y - perso1dy) >-10 then PvE8 = int(PvE8 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE8 <= 0 then #main.map,"SpriteVisible E17 off" : MoveE8 = 0 : if securPoint8 = 0 then gosub [securPoints] : securPoint8 = 1 : #main.map "spritetofront atk"
    if MoveE9>0 and int(E18x - perso1dx) <15 and int(E18x - perso1dx) >-15 AND int(E18y - perso1dy) <10 and int(E18y - perso1dy) >-10 then PvE9 = int(PvE9 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE9 <= 0 then #main.map,"SpriteVisible E18 off" : MoveE9 = 0 : if securPoint9 = 0 then gosub [securPoints] : securPoint9 = 1 : #main.map "spritetofront atk"
    if MoveE10>0 and int(E19x - perso1dx) <15 and int(E19x - perso1dx) >-15 AND int(E19y - perso1dy) <10 and int(E19y - perso1dy) >-10 then PvE10 = int(PvE10 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE10 <= 0 then #main.map,"SpriteVisible E19 off" : MoveE10 = 0 : if securPoint10 = 0 then gosub [securPoints] : securPoint10 = 1 : #main.map "spritetofront atk"
    if MoveE11>0 and int(E110x - perso1dx) <15 and int(E110x - perso1dx) >-15 AND int(E110y - perso1dy) <10 and int(E110y - perso1dy) >-10 then PvE11 = int(PvE11 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE11 <= 0 then #main.map,"SpriteVisible E110 off" : MoveE11 = 0 : if securPoint11 = 0 then gosub [securPoints] : securPoint11 = 1 : #main.map "spritetofront atk"
    if MoveE12>0 and int(E111x - perso1dx) <15 and int(E111x - perso1dx) >-15 AND int(E111y - perso1dy) <10 and int(E111y - perso1dy) >-10 then PvE12 = int(PvE12 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE12 <= 0 then #main.map,"SpriteVisible E111 off" : MoveE12 = 0 : if securPoint12 = 0 then gosub [securPoints] : securPoint12 = 1 : #main.map "spritetofront atk"
    if MoveE13>0 and int(E112x - perso1dx) <15 and int(E112x - perso1dx) >-15 AND int(E112y - perso1dy) <10 and int(E112y - perso1dy) >-10 then PvE13 = int(PvE13 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE13 <= 0 then #main.map,"SpriteVisible E112 off" : MoveE13 = 0 : if securPoint13 = 0 then gosub [securPoints] : securPoint13 = 1 : #main.map "spritetofront atk"
    if MoveE14>0 and int(E113x - perso1dx) <15 and int(E113x - perso1dx) >-15 AND int(E113y - perso1dy) <10 and int(E113y - perso1dy) >-10 then PvE14 = int(PvE14 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE14 <= 0 then #main.map,"SpriteVisible E113 off" : MoveE14 = 0 : if securPoint14 = 0 then gosub [securPoints] : securPoint14 = 1 : #main.map "spritetofront atk"
    if MoveE15>0 and int(E114x - perso1dx) <15 and int(E114x - perso1dx) >-15 AND int(E114y - perso1dy) <10 and int(E114y - perso1dy) >-10 then PvE15 = int(PvE15 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE15 <= 0 then #main.map,"SpriteVisible E114 off" : MoveE15 = 0 : if securPoint15 = 0 then gosub [securPoints] : securPoint15 = 1 : #main.map "spritetofront atk"
    if MoveE16>0 and int(E115x - perso1dx) <15 and int(E115x - perso1dx) >-15 AND int(E115y - perso1dy) <10 and int(E115y - perso1dy) >-10 then PvE16 = int(PvE16 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE16 <= 0 then #main.map,"SpriteVisible E115 off" : MoveE16 = 0 : if securPoint16 = 0 then gosub [securPoints] : securPoint16 = 1 : #main.map "spritetofront atk"
    if MoveE17>0 and int(E116x - perso1dx) <15 and int(E116x - perso1dx) >-15 AND int(E116y - perso1dy) <10 and int(E116y - perso1dy) >-10 then PvE17 = int(PvE17 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE17 <= 0 then #main.map,"SpriteVisible E116 off" : MoveE17 = 0 : if securPoint17 = 0 then gosub [securPoints] : securPoint17 = 1 : #main.map "spritetofront atk"
    if MoveE18>0 and int(E117x - perso1dx) <15 and int(E117x - perso1dx) >-15 AND int(E117y - perso1dy) <10 and int(E117y - perso1dy) >-10 then PvE18 = int(PvE18 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE18 <= 0 then #main.map,"SpriteVisible E117 off" : MoveE18 = 0 : if securPoint18 = 0 then gosub [securPoints] : securPoint18 = 1 : #main.map "spritetofront atk"
    if MoveE19>0 and int(E118x - perso1dx) <15 and int(E118x - perso1dx) >-15 AND int(E118y - perso1dy) <10 and int(E118y - perso1dy) >-10 then PvE19 = int(PvE19 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE19 <= 0 then #main.map,"SpriteVisible E118 off" : MoveE19 = 0 : if securPoint19 = 0 then gosub [securPoints] : securPoint19 = 1 : #main.map "spritetofront atk"
    if MoveE20>0 and int(E119x - perso1dx) <15 and int(E119x - perso1dx) >-15 AND int(E119y - perso1dy) <10 and int(E119y - perso1dy) >-10 then PvE20 = int(PvE20 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE20 <= 0 then #main.map,"SpriteVisible E119 off" : MoveE20 = 0 : if securPoint20 = 0 then gosub [securPoints] : securPoint20 = 1 : #main.map "spritetofront atk"
    if MoveE21>0 and int(E120x - perso1dx) <15 and int(E120x - perso1dx) >-15 AND int(E120y - perso1dy) <10 and int(E120y - perso1dy) >-10 then PvE21 = int(PvE21 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE21 <= 0 then #main.map,"SpriteVisible E120 off" : MoveE21 = 0 : if securPoint21 = 0 then gosub [securPoints] : securPoint21 = 1 : #main.map "spritetofront atk"
    if MoveE22>0 and int(E121x - perso1dx) <15 and int(E121x - perso1dx) >-15 AND int(E121y - perso1dy) <10 and int(E121y - perso1dy) >-10 then PvE22 = int(PvE22 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE22 <= 0 then #main.map,"SpriteVisible E121 off" : MoveE22 = 0 : if securPoint22 = 0 then gosub [securPoints] : securPoint22 = 1 : #main.map "spritetofront atk"
    if MoveE23>0 and int(E122x - perso1dx) <15 and int(E122x - perso1dx) >-15 AND int(E122y - perso1dy) <10 and int(E122y - perso1dy) >-10 then PvE23 = int(PvE23 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE23 <= 0 then #main.map,"SpriteVisible E122 off" : MoveE23 = 0 : if securPoint23 = 0 then gosub [securPoints] : securPoint23 = 1 : #main.map "spritetofront atk"
    if MoveE24>0 and int(E123x - perso1dx) <15 and int(E123x - perso1dx) >-15 AND int(E123y - perso1dy) <10 and int(E123y - perso1dy) >-10 then PvE24 = int(PvE24 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE24 <= 0 then #main.map,"SpriteVisible E123 off" : MoveE24 = 0 : if securPoint24 = 0 then gosub [securPoints] : securPoint24 = 1 : #main.map "spritetofront atk"
    if MoveE25>0 and int(E124x - perso1dx) <15 and int(E124x - perso1dx) >-15 AND int(E124y - perso1dy) <10 and int(E124y - perso1dy) >-10 then PvE25 = int(PvE25 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE25 <= 0 then #main.map,"SpriteVisible E124 off" : MoveE25 = 0 : if securPoint25 = 0 then gosub [securPoints] : securPoint25 = 1 : #main.map "spritetofront atk"
    if MoveE26>0 and int(E125x - perso1dx) <15 and int(E125x - perso1dx) >-15 AND int(E125y - perso1dy) <10 and int(E125y - perso1dy) >-10 then PvE26 = int(PvE26 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE26 <= 0 then #main.map,"SpriteVisible E125 off" : MoveE26 = 0 : if securPoint26 = 0 then gosub [securPoints] : securPoint26 = 1 : #main.map "spritetofront atk"
    if MoveE27>0 and int(E126x - perso1dx) <15 and int(E126x - perso1dx) >-15 AND int(E126y - perso1dy) <10 and int(E126y - perso1dy) >-10 then PvE27 = int(PvE27 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE27 <= 0 then #main.map,"SpriteVisible E126 off" : MoveE27 = 0 : if securPoint27 = 0 then gosub [securPoints] : securPoint27 = 1 : #main.map "spritetofront atk"
    if MoveE28>0 and int(E127x - perso1dx) <15 and int(E127x - perso1dx) >-15 AND int(E127y - perso1dy) <10 and int(E127y - perso1dy) >-10 then PvE28 = int(PvE28 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE28 <= 0 then #main.map,"SpriteVisible E127 off" : MoveE28 = 0 : if securPoint28 = 0 then gosub [securPoints] : securPoint28 = 1 : #main.map "spritetofront atk"
    if MoveE29>0 and int(E128x - perso1dx) <15 and int(E128x - perso1dx) >-15 AND int(E128y - perso1dy) <10 and int(E128y - perso1dy) >-10 then PvE29 = int(PvE29 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE29 <= 0 then #main.map,"SpriteVisible E128 off" : MoveE29 = 0 : if securPoint29 = 0 then gosub [securPoints] : securPoint29 = 1 : #main.map "spritetofront atk"
    if MoveE30>0 and int(E129x - perso1dx) <15 and int(E129x - perso1dx) >-15 AND int(E129y - perso1dy) <10 and int(E129y - perso1dy) >-10 then PvE30 = int(PvE30 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE30 <= 0 then #main.map,"SpriteVisible E129 off" : MoveE30 = 0 : if securPoint30 = 0 then gosub [securPoints] : securPoint30 = 1 : #main.map "spritetofront atk"
    if MoveE31>0 and int(E130x - perso1dx) <15 and int(E130x - perso1dx) >-15 AND int(E130y - perso1dy) <10 and int(E130y - perso1dy) >-10 then PvE31 = int(PvE31 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE31 <= 0 then #main.map,"SpriteVisible E130 off" : MoveE31 = 0 : if securPoint31 = 0 then gosub [securPoints] : securPoint31 = 1 : #main.map "spritetofront atk"
    if MoveE32>0 and int(E131x - perso1dx) <15 and int(E131x - perso1dx) >-15 AND int(E131y - perso1dy) <10 and int(E131y - perso1dy) >-10 then PvE32 = int(PvE32 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE32 <= 0 then #main.map,"SpriteVisible E131 off" : MoveE32 = 0 : if securPoint32 = 0 then gosub [securPoints] : securPoint32 = 1 : #main.map "spritetofront atk"
    if MoveE33>0 and int(E132x - perso1dx) <15 and int(E132x - perso1dx) >-15 AND int(E132y - perso1dy) <10 and int(E132y - perso1dy) >-10 then PvE33 = int(PvE33 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE33 <= 0 then #main.map,"SpriteVisible E132 off" : MoveE33 = 0 : if securPoint33 = 0 then gosub [securPoints] : securPoint33 = 1 : #main.map "spritetofront atk"
    if MoveE34>0 and int(E133x - perso1dx) <15 and int(E133x - perso1dx) >-15 AND int(E133y - perso1dy) <10 and int(E133y - perso1dy) >-10 then PvE34 = int(PvE34 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE34 <= 0 then #main.map,"SpriteVisible E133 off" : MoveE34 = 0 : if securPoint34 = 0 then gosub [securPoints] : securPoint34 = 1 : #main.map "spritetofront atk"
    if MoveE35>0 and int(E134x - perso1dx) <15 and int(E134x - perso1dx) >-15 AND int(E134y - perso1dy) <10 and int(E134y - perso1dy) >-10 then PvE35 = int(PvE35 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE35 <= 0 then #main.map,"SpriteVisible E134 off" : MoveE35 = 0 : if securPoint35 = 0 then gosub [securPoints] : securPoint35 = 1 : #main.map "spritetofront atk"
    if MoveE36>0 and int(E135x - perso1dx) <15 and int(E135x - perso1dx) >-15 AND int(E135y - perso1dy) <10 and int(E135y - perso1dy) >-10 then PvE36 = int(PvE36 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE33 <= 0 then #main.map,"SpriteVisible E135 off" : MoveE36 = 0 : if securPoint36 = 0 then gosub [securPoints] : securPoint36 = 1 : #main.map "spritetofront atk"
    if MoveE37>0 and int(E136x - perso1dx) <15 and int(E136x - perso1dx) >-15 AND int(E136y - perso1dy) <10 and int(E136y - perso1dy) >-10 then PvE37 = int(PvE37 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE37 <= 0 then #main.map,"SpriteVisible E136 off" : MoveE37 = 0 : if securPoint37 = 0 then gosub [securPoints] : securPoint37 = 1 : #main.map "spritetofront atk"
    if MoveE38>0 and int(E137x - perso1dx) <15 and int(E137x - perso1dx) >-15 AND int(E137y - perso1dy) <10 and int(E137y - perso1dy) >-10 then PvE38 = int(PvE38 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE38 <= 0 then #main.map,"SpriteVisible E137 off" : MoveE38 = 0 : if securPoint38 = 0 then gosub [securPoints] : securPoint38 = 1 : #main.map "spritetofront atk"
    if MoveE39>0 and int(E138x - perso1dx) <15 and int(E138x - perso1dx) >-15 AND int(E138y - perso1dy) <10 and int(E138y - perso1dy) >-10 then PvE39 = int(PvE39 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE39 <= 0 then #main.map,"SpriteVisible E138 off" : MoveE39 = 0 : if securPoint39 = 0 then gosub [securPoints] : securPoint39 = 1 : #main.map "spritetofront atk"
    if MoveE40>0 and int(E139x - perso1dx) <15 and int(E139x - perso1dx) >-15 AND int(E139y - perso1dy) <10 and int(E139y - perso1dy) >-10 then PvE40 = int(PvE40 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE40 <= 0 then #main.map,"SpriteVisible E139 off" : MoveE40 = 0 : if securPoint40 = 0 then gosub [securPoints] : securPoint40 = 1 : #main.map "spritetofront atk"
    if MoveE41>0 and int(E140x - perso1dx) <15 and int(E140x - perso1dx) >-15 AND int(E140y - perso1dy) <10 and int(E140y - perso1dy) >-10 then PvE41 = int(PvE41 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE41 <= 0 then #main.map,"SpriteVisible E140 off" : MoveE41 = 0 : if securPoint41 = 0 then gosub [securPoints] : securPoint41 = 1 : #main.map "spritetofront atk"
    if MoveE42>0 and int(E141x - perso1dx) <15 and int(E141x - perso1dx) >-15 AND int(E141y - perso1dy) <10 and int(E141y - perso1dy) >-10 then PvE42 = int(PvE42 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE42 <= 0 then #main.map,"SpriteVisible E141 off" : MoveE42 = 0 : if securPoint42 = 0 then gosub [securPoints] : securPoint42 = 1 : #main.map "spritetofront atk"
    if MoveE43>0 and int(E142x - perso1dx) <15 and int(E142x - perso1dx) >-15 AND int(E142y - perso1dy) <10 and int(E142y - perso1dy) >-10 then PvE43 = int(PvE43 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE43 <= 0 then #main.map,"SpriteVisible E142 off" : MoveE43 = 0 : if securPoint43 = 0 then gosub [securPoints] : securPoint43 = 1 : #main.map "spritetofront atk"
    if MoveE44>0 and int(E143x - perso1dx) <15 and int(E143x - perso1dx) >-15 AND int(E143y - perso1dy) <10 and int(E143y - perso1dy) >-10 then PvE44 = int(PvE44 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE44 <= 0 then #main.map,"SpriteVisible E143 off" : MoveE44 = 0 : if securPoint44 = 0 then gosub [securPoints] : securPoint44 = 1 : #main.map "spritetofront atk"
    if MoveE45>0 and int(E144x - perso1dx) <15 and int(E144x - perso1dx) >-15 AND int(E144y - perso1dy) <10 and int(E144y - perso1dy) >-10 then PvE45 = int(PvE45 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE45 <= 0 then #main.map,"SpriteVisible E144 off" : MoveE45 = 0 : if securPoint45 = 0 then gosub [securPoints] : securPoint45 = 1 : #main.map "spritetofront atk"
    if MoveE46>0 and int(E145x - perso1dx) <15 and int(E145x - perso1dx) >-15 AND int(E145y - perso1dy) <10 and int(E145y - perso1dy) >-10 then PvE46 = int(PvE46 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE46 <= 0 then #main.map,"SpriteVisible E145 off" : MoveE46 = 0 : if securPoint46 = 0 then gosub [securPoints] : securPoint46 = 1 : #main.map "spritetofront atk"
    if MoveE47>0 and int(E146x - perso1dx) <15 and int(E146x - perso1dx) >-15 AND int(E146y - perso1dy) <10 and int(E146y - perso1dy) >-10 then PvE47 = int(PvE47 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE47 <= 0 then #main.map,"SpriteVisible E146 off" : MoveE47 = 0 : if securPoint47 = 0 then gosub [securPoints] : securPoint47 = 1 : #main.map "spritetofront atk"
    if MoveE48>0 and int(E147x - perso1dx) <15 and int(E147x - perso1dx) >-15 AND int(E147y - perso1dy) <10 and int(E147y - perso1dy) >-10 then PvE48 = int(PvE48 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE48 <= 0 then #main.map,"SpriteVisible E147 off" : MoveE48 = 0 : if securPoint48 = 0 then gosub [securPoints] : securPoint48 = 1 : #main.map "spritetofront atk"
    if MoveE49>0 and int(E148x - perso1dx) <15 and int(E148x - perso1dx) >-15 AND int(E148y - perso1dy) <10 and int(E148y - perso1dy) >-10 then PvE49 = int(PvE49 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE49 <= 0 then #main.map,"SpriteVisible E148 off" : MoveE49 = 0 : if securPoint49 = 0 then gosub [securPoints] : securPoint49 = 1 : #main.map "spritetofront atk"
    if MoveE50>0 and int(E149x - perso1dx) <15 and int(E149x - perso1dx) >-15 AND int(E149y - perso1dy) <10 and int(E149y - perso1dy) >-10 then PvE50 = int(PvE50 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE50 <= 0 then #main.map,"SpriteVisible E149 off" : MoveE50 = 0 : if securPoint50 = 0 then gosub [securPoints] : securPoint50 = 1 : #main.map "spritetofront atk"
    if MoveE51>0 and int(E150x - perso1dx) <15 and int(E150x - perso1dx) >-15 AND int(E150y - perso1dy) <10 and int(E150y - perso1dy) >-10 then PvE51 = int(PvE51 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE51 <= 0 then #main.map,"SpriteVisible E150 off" : MoveE51 = 0 : if securPoint51 = 0 then gosub [securPoints] : securPoint51 = 1 : #main.map "spritetofront atk"
    if MoveE52>0 and int(E151x - perso1dx) <15 and int(E151x - perso1dx) >-15 AND int(E151y - perso1dy) <10 and int(E151y - perso1dy) >-10 then PvE52 = int(PvE52 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE52 <= 0 then #main.map,"SpriteVisible E151 off" : MoveE52 = 0 : if securPoint52 = 0 then gosub [securPoints] : securPoint52 = 1 : #main.map "spritetofront atk"
    if MoveE53>0 and int(E152x - perso1dx) <15 and int(E152x - perso1dx) >-15 AND int(E152y - perso1dy) <10 and int(E152y - perso1dy) >-10 then PvE53 = int(PvE53 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE53 <= 0 then #main.map,"SpriteVisible E152 off" : MoveE53 = 0 : if securPoint53 = 0 then gosub [securPoints] : securPoint53 = 1 : #main.map "spritetofront atk"
    if MoveE54>0 and int(E153x - perso1dx) <15 and int(E153x - perso1dx) >-15 AND int(E153y - perso1dy) <10 and int(E153y - perso1dy) >-10 then PvE54 = int(PvE54 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE54 <= 0 then #main.map,"SpriteVisible E153 off" : MoveE54 = 0 : if securPoint54 = 0 then gosub [securPoints] : securPoint54 = 1 : #main.map "spritetofront atk"
    if MoveE55>0 and int(E154x - perso1dx) <15 and int(E154x - perso1dx) >-15 AND int(E154y - perso1dy) <10 and int(E154y - perso1dy) >-10 then PvE55 = int(PvE55 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE55 <= 0 then #main.map,"SpriteVisible E154 off" : MoveE55 = 0 : if securPoint55 = 0 then gosub [securPoints] : securPoint55 = 1 : #main.map "spritetofront atk"
    if MoveE56>0 and int(E155x - perso1dx) <15 and int(E155x - perso1dx) >-15 AND int(E155y - perso1dy) <10 and int(E155y - perso1dy) >-10 then PvE56 = int(PvE56 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE56 <= 0 then #main.map,"SpriteVisible E155 off" : MoveE56 = 0 : if securPoint56 = 0 then gosub [securPoints] : securPoint56 = 1 : #main.map "spritetofront atk"
    if MoveE57>0 and int(E156x - perso1dx) <15 and int(E156x - perso1dx) >-15 AND int(E156y - perso1dy) <10 and int(E156y - perso1dy) >-10 then PvE57 = int(PvE57 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE57 <= 0 then #main.map,"SpriteVisible E156 off" : MoveE57 = 0 : if securPoint57 = 0 then gosub [securPoints] : securPoint57 = 1 : #main.map "spritetofront atk"
    if MoveE58>0 and int(E157x - perso1dx) <15 and int(E157x - perso1dx) >-15 AND int(E157y - perso1dy) <10 and int(E157y - perso1dy) >-10 then PvE58 = int(PvE58 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE58 <= 0 then #main.map,"SpriteVisible E157 off" : MoveE58 = 0 : if securPoint58 = 0 then gosub [securPoints] : securPoint58 = 1 : #main.map "spritetofront atk"
    if MoveE59>0 and int(E158x - perso1dx) <15 and int(E158x - perso1dx) >-15 AND int(E158y - perso1dy) <10 and int(E158y - perso1dy) >-10 then PvE59 = int(PvE59 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE59 <= 0 then #main.map,"SpriteVisible E158 off" : MoveE59 = 0 : if securPoint59 = 0 then gosub [securPoints] : securPoint59 = 1 : #main.map "spritetofront atk"
    if MoveE60>0 and int(E159x - perso1dx) <15 and int(E159x - perso1dx) >-15 AND int(E159y - perso1dy) <10 and int(E159y - perso1dy) >-10 then PvE60 = int(PvE60 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE60 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE60 = 0 : if securPoint60 = 0 then gosub [securPoints] : securPoint60 = 1 : #main.map "spritetofront atk"
    if MoveE61>0 and int(E160x - perso1dx) <15 and int(E160x - perso1dx) >-15 AND int(E160y - perso1dy) <10 and int(E160y - perso1dy) >-10 then PvE61 = int(PvE61 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE61 <= 0 then #main.map,"SpriteVisible E160 off" : MoveE61 = 0 : if securPoint61 = 0 then gosub [securPoints] : securPoint61 = 1 : #main.map "spritetofront atk"
    if MoveE62>0 and int(E161x - perso1dx) <15 and int(E161x - perso1dx) >-15 AND int(E161y - perso1dy) <10 and int(E161y - perso1dy) >-10 then PvE62 = int(PvE62 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE62 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE62 = 0 : if securPoint62 = 0 then gosub [securPoints] : securPoint62 = 1 : #main.map "spritetofront atk"
    if MoveE63>0 and int(E162x - perso1dx) <15 and int(E162x - perso1dx) >-15 AND int(E162y - perso1dy) <10 and int(E162y - perso1dy) >-10 then PvE63 = int(PvE63 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE63 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE63 = 0 : if securPoint63 = 0 then gosub [securPoints] : securPoint63 = 1 : #main.map "spritetofront atk"
    if MoveE64>0 and int(E163x - perso1dx) <15 and int(E163x - perso1dx) >-15 AND int(E163y - perso1dy) <10 and int(E163y - perso1dy) >-10 then PvE64 = int(PvE64 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE64 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE64 = 0 : if securPoint64 = 0 then gosub [securPoints] : securPoint64 = 1 : #main.map "spritetofront atk"
    if MoveE65>0 and int(E164x - perso1dx) <15 and int(E164x - perso1dx) >-15 AND int(E164y - perso1dy) <10 and int(E164y - perso1dy) >-10 then PvE65 = int(PvE65 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE65 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE65 = 0 : if securPoint65 = 0 then gosub [securPoints] : securPoint65 = 1 : #main.map "spritetofront atk"
    if MoveE66>0 and int(E165x - perso1dx) <15 and int(E165x - perso1dx) >-15 AND int(E165y - perso1dy) <10 and int(E165y - perso1dy) >-10 then PvE66 = int(PvE66 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE66 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE66 = 0 : if securPoint66 = 0 then gosub [securPoints] : securPoint66 = 1 : #main.map "spritetofront atk"
    if MoveE67>0 and int(E166x - perso1dx) <15 and int(E166x - perso1dx) >-15 AND int(E166y - perso1dy) <10 and int(E166y - perso1dy) >-10 then PvE67 = int(PvE67 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE67 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE67 = 0 : if securPoint67 = 0 then gosub [securPoints] : securPoint67 = 1 : #main.map "spritetofront atk"
    if MoveE68>0 and int(E167x - perso1dx) <15 and int(E167x - perso1dx) >-15 AND int(E167y - perso1dy) <10 and int(E167y - perso1dy) >-10 then PvE68 = int(PvE68 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE68 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE68 = 0 : if securPoint68 = 0 then gosub [securPoints] : securPoint68 = 1 : #main.map "spritetofront atk"
    if MoveE69>0 and int(E168x - perso1dx) <15 and int(E168x - perso1dx) >-15 AND int(E168y - perso1dy) <10 and int(E168y - perso1dy) >-10 then PvE69 = int(PvE69 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE69 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE69 = 0 : if securPoint69 = 0 then gosub [securPoints] : securPoint69 = 1 : #main.map "spritetofront atk"
    if MoveE70>0 and int(E169x - perso1dx) <15 and int(E169x - perso1dx) >-15 AND int(E169y - perso1dy) <10 and int(E169y - perso1dy) >-10 then PvE70 = int(PvE70 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE70 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE70 = 0 : if securPoint70 = 0 then gosub [securPoints] : securPoint70 = 1 : #main.map "spritetofront atk"
    if MoveE71>0 and int(E170x - perso1dx) <15 and int(E170x - perso1dx) >-15 AND int(E170y - perso1dy) <10 and int(E170y - perso1dy) >-10 then PvE71 = int(PvE71 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE71 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE71 = 0 : if securPoint71 = 0 then gosub [securPoints] : securPoint71 = 1 : #main.map "spritetofront atk"
    if MoveE72>0 and int(E171x - perso1dx) <15 and int(E171x - perso1dx) >-15 AND int(E171y - perso1dy) <10 and int(E171y - perso1dy) >-10 then PvE72 = int(PvE72 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE72 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE72 = 0 : if securPoint72 = 0 then gosub [securPoints] : securPoint72 = 1 : #main.map "spritetofront atk"
    if MoveE73>0 and int(E172x - perso1dx) <15 and int(E172x - perso1dx) >-15 AND int(E172y - perso1dy) <10 and int(E172y - perso1dy) >-10 then PvE73 = int(PvE73 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE73 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE73 = 0 : if securPoint73 = 0 then gosub [securPoints] : securPoint73 = 1 : #main.map "spritetofront atk"
    if MoveE74>0 and int(E173x - perso1dx) <15 and int(E173x - perso1dx) >-15 AND int(E173y - perso1dy) <10 and int(E173y - perso1dy) >-10 then PvE74 = int(PvE74 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE74 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE74 = 0 : if securPoint74 = 0 then gosub [securPoints] : securPoint74 = 1 : #main.map "spritetofront atk"
    if MoveE75>0 and int(E174x - perso1dx) <15 and int(E174x - perso1dx) >-15 AND int(E174y - perso1dy) <10 and int(E174y - perso1dy) >-10 then PvE75 = int(PvE75 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE75 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE75 = 0 : if securPoint75 = 0 then gosub [securPoints] : securPoint75 = 1 : #main.map "spritetofront atk"
    if MoveE76>0 and int(E175x - perso1dx) <15 and int(E175x - perso1dx) >-15 AND int(E175y - perso1dy) <10 and int(E175y - perso1dy) >-10 then PvE76 = int(PvE76 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE76 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE76 = 0 : if securPoint76 = 0 then gosub [securPoints] : securPoint76 = 1 : #main.map "spritetofront atk"
    if MoveE77>0 and int(E176x - perso1dx) <15 and int(E176x - perso1dx) >-15 AND int(E176y - perso1dy) <10 and int(E176y - perso1dy) >-10 then PvE77 = int(PvE77 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE77 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE77 = 0 : if securPoint77 = 0 then gosub [securPoints] : securPoint77 = 1 : #main.map "spritetofront atk"
    if MoveE78>0 and int(E177x - perso1dx) <15 and int(E177x - perso1dx) >-15 AND int(E177y - perso1dy) <10 and int(E177y - perso1dy) >-10 then PvE78 = int(PvE78 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE78 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE78 = 0 : if securPoint78 = 0 then gosub [securPoints] : securPoint78 = 1 : #main.map "spritetofront atk"
    if MoveE79>0 and int(E178x - perso1dx) <15 and int(E178x - perso1dx) >-15 AND int(E178y - perso1dy) <10 and int(E178y - perso1dy) >-10 then PvE79 = int(PvE79 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE79 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE79 = 0 : if securPoint79 = 0 then gosub [securPoints] : securPoint79 = 1 : #main.map "spritetofront atk"
    if MoveE80>0 and int(E179x - perso1dx) <15 and int(E179x - perso1dx) >-15 AND int(E179y - perso1dy) <10 and int(E179y - perso1dy) >-10 then PvE80 = int(PvE80 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE80 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE80 = 0 : if securPoint80 = 0 then gosub [securPoints] : securPoint80 = 1 : #main.map "spritetofront atk"
    if MoveE81>0 and int(E180x - perso1dx) <15 and int(E180x - perso1dx) >-15 AND int(E180y - perso1dy) <10 and int(E180y - perso1dy) >-10 then PvE81 = int(PvE81 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE81 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE81 = 0 : if securPoint81 = 0 then gosub [securPoints] : securPoint81 = 1 : #main.map "spritetofront atk"
    if MoveE82>0 and int(E181x - perso1dx) <15 and int(E181x - perso1dx) >-15 AND int(E181y - perso1dy) <10 and int(E181y - perso1dy) >-10 then PvE82 = int(PvE82 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE82 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE82 = 0 : if securPoint82 = 0 then gosub [securPoints] : securPoint82 = 1 : #main.map "spritetofront atk"
    if MoveE83>0 and int(E182x - perso1dx) <15 and int(E182x - perso1dx) >-15 AND int(E182y - perso1dy) <10 and int(E182y - perso1dy) >-10 then PvE83 = int(PvE83 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE83 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE83 = 0 : if securPoint83 = 0 then gosub [securPoints] : securPoint83 = 1 : #main.map "spritetofront atk"
    if MoveE84>0 and int(E183x - perso1dx) <15 and int(E183x - perso1dx) >-15 AND int(E183y - perso1dy) <10 and int(E183y - perso1dy) >-10 then PvE84 = int(PvE84 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE84 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE84 = 0 : if securPoint84 = 0 then gosub [securPoints] : securPoint84 = 1 : #main.map "spritetofront atk"
    if MoveE85>0 and int(E184x - perso1dx) <15 and int(E184x - perso1dx) >-15 AND int(E184y - perso1dy) <10 and int(E184y - perso1dy) >-10 then PvE85 = int(PvE85 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE85 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE85 = 0 : if securPoint85 = 0 then gosub [securPoints] : securPoint85 = 1 : #main.map "spritetofront atk"
    if MoveE86>0 and int(E185x - perso1dx) <15 and int(E185x - perso1dx) >-15 AND int(E185y - perso1dy) <10 and int(E185y - perso1dy) >-10 then PvE86 = int(PvE86 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE86 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE86 = 0 : if securPoint86 = 0 then gosub [securPoints] : securPoint86 = 1 : #main.map "spritetofront atk"
    if MoveE87>0 and int(E186x - perso1dx) <15 and int(E186x - perso1dx) >-15 AND int(E186y - perso1dy) <10 and int(E186y - perso1dy) >-10 then PvE87 = int(PvE87 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE87 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE87 = 0 : if securPoint87 = 0 then gosub [securPoints] : securPoint87 = 1 : #main.map "spritetofront atk"
    if MoveE88>0 and int(E187x - perso1dx) <15 and int(E187x - perso1dx) >-15 AND int(E187y - perso1dy) <10 and int(E187y - perso1dy) >-10 then PvE88 = int(PvE88 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE88 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE88 = 0 : if securPoint88 = 0 then gosub [securPoints] : securPoint88 = 1 : #main.map "spritetofront atk"
    if MoveE89>0 and int(E188x - perso1dx) <15 and int(E188x - perso1dx) >-15 AND int(E188y - perso1dy) <10 and int(E188y - perso1dy) >-10 then PvE89 = int(PvE89 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE89 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE89 = 0 : if securPoint89 = 0 then gosub [securPoints] : securPoint89 = 1 : #main.map "spritetofront atk"
    if MoveE90>0 and int(E189x - perso1dx) <15 and int(E189x - perso1dx) >-15 AND int(E189y - perso1dy) <10 and int(E189y - perso1dy) >-10 then PvE90 = int(PvE90 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE90 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE90 = 0 : if securPoint90 = 0 then gosub [securPoints] : securPoint90 = 1 : #main.map "spritetofront atk"
    if MoveE91>0 and int(E190x - perso1dx) <15 and int(E190x - perso1dx) >-15 AND int(E190y - perso1dy) <10 and int(E190y - perso1dy) >-10 then PvE91 = int(PvE91 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE91 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE91 = 0 : if securPoint91 = 0 then gosub [securPoints] : securPoint91 = 1 : #main.map "spritetofront atk"
    if MoveE92>0 and int(E191x - perso1dx) <15 and int(E191x - perso1dx) >-15 AND int(E191y - perso1dy) <10 and int(E191y - perso1dy) >-10 then PvE92 = int(PvE92 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE92 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE92 = 0 : if securPoint92 = 0 then gosub [securPoints] : securPoint92 = 1 : #main.map "spritetofront atk"
    if MoveE93>0 and int(E192x - perso1dx) <15 and int(E192x - perso1dx) >-15 AND int(E192y - perso1dy) <10 and int(E192y - perso1dy) >-10 then PvE93 = int(PvE93 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE93 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE93 = 0 : if securPoint93 = 0 then gosub [securPoints] : securPoint93 = 1 : #main.map "spritetofront atk"
    if MoveE94>0 and int(E193x - perso1dx) <15 and int(E193x - perso1dx) >-15 AND int(E193y - perso1dy) <10 and int(E193y - perso1dy) >-10 then PvE94 = int(PvE94 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE94 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE94 = 0 : if securPoint94 = 0 then gosub [securPoints] : securPoint94 = 1 : #main.map "spritetofront atk"
    if MoveE95>0 and int(E194x - perso1dx) <15 and int(E194x - perso1dx) >-15 AND int(E194y - perso1dy) <10 and int(E194y - perso1dy) >-10 then PvE95 = int(PvE95 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE95 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE95 = 0 : if securPoint95 = 0 then gosub [securPoints] : securPoint95 = 1 : #main.map "spritetofront atk"
    if MoveE96>0 and int(E195x - perso1dx) <15 and int(E195x - perso1dx) >-15 AND int(E195y - perso1dy) <10 and int(E195y - perso1dy) >-10 then PvE96 = int(PvE96 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE96 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE96 = 0 : if securPoint96 = 0 then gosub [securPoints] : securPoint96 = 1 : #main.map "spritetofront atk"
    if MoveE97>0 and int(E196x - perso1dx) <15 and int(E196x - perso1dx) >-15 AND int(E196y - perso1dy) <10 and int(E196y - perso1dy) >-10 then PvE97 = int(PvE97 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE97 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE97 = 0 : if securPoint97 = 0 then gosub [securPoints] : securPoint97 = 1 : #main.map "spritetofront atk"
    if MoveE98>0 and int(E197x - perso1dx) <15 and int(E197x - perso1dx) >-15 AND int(E197y - perso1dy) <10 and int(E197y - perso1dy) >-10 then PvE98 = int(PvE98 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE98 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE98 = 0 : if securPoint98 = 0 then gosub [securPoints] : securPoint98 = 1 : #main.map "spritetofront atk"
    if MoveE99>0 and int(E198x - perso1dx) <15 and int(E198x - perso1dx) >-15 AND int(E198y - perso1dy) <10 and int(E198y - perso1dy) >-10 then PvE99 = int(PvE99 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE99 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE99 = 0 : if securPoint99 = 0 then gosub [securPoints] : securPoint99 = 1 : #main.map "spritetofront atk"
    if MoveE100>0 and int(E199x - perso1dx) <15 and int(E199x - perso1dx) >-15 AND int(E199y - perso1dy) <10 and int(E199y - perso1dy) >-10 then PvE100 = int(PvE100 - dommage) : HEROpv = int(HEROpv - dommageE) : actiVtimingCounter = 1 : #main.map,"spritexy atk ";perso1dx;" ";perso1dy : #main.map,"SpriteVisible atk on" : if PvE100 <= 0 then #main.map,"SpriteVisible E159 off" : MoveE100 = 0 : if securPoint100 = 0 then gosub [securPoints] : securPoint100 = 1 : #main.map "spritetofront atk"
    if Movecata1>0 and perso1dx < cata1x+80 and perso1dx > cata1x AND perso1dy < cata1y+40 and perso1dy > cata1y-20 then HPcata1 = int(HPcata1 - HEROatk) : if HPcata1 <= 0 then #main.map,"SpriteVisible cata3 off" : Movecata1 = 0 : if securPointcata1 = 0 then gosub [securPoints] : securPointcata1 = 1
    return

'----------------------------------------------------------------------------------

    [txtREFRESH]
    if version = 1 then
        #main.menu, "place 60 18;\";"Fortifications : "; str$(castlePV);"    "
        #main.menu, "place 290 11;\";"Niveau : "; str$(lvl);"   -   ";str$(xp);" / "; str$(xpTotal)
        #main.menu, "place 290 24;\";"Santé : "; str$(HEROpv);" / "; str$(HEROpvTOTAL);"    "
        #main.menu, "place 500 11;\";"Vague : "; str$(waveNumber) ;"    "
        #main.menu, "place 500 24;\";"Ennemis restants : "; str$(UnitsE) ;"    "
        #main.menu, "place 670 24;\";"Votre OR : "; str$(Gold);"    "
    end if
    if version = 2 then
        #main.menu, "place 60 18;\";"Fortifications : "; str$(castlePV);"    "
        #main.menu, "place 290 12;\";"Level : "; str$(lvl);"   -   ";str$(xp);" / "; str$(xpTotal)
        #main.menu, "place 290 24;\";"Heal : "; str$(HEROpv);" / "; str$(HEROpvTOTAL);"    "
        #main.menu, "place 500 12;\";"Wave : "; str$(waveNumber) ;"    "
        #main.menu, "place 500 24;\";"Ennemies alive : "; str$(UnitsE) ;"    "
        #main.menu, "place 670 24;\";"Gold : "; str$(Gold);"    "
    end if
    #main.menu, "place 670 11;\";"Score : "; str$(Score) ;"    "
    if FPSmonitor = 1 then
        oldTime = time : time = time$("ms")
        frameTime = (time - oldTime) / 1000.0 ' frameTime is the time this frame has taken, in seconds
        if frameTime > 0 then
            fp$ = "FPS : ";str$(int(1/frameTime))
            if int(1/frameTime) < 1 then fp$ = "FPS : 1"
            compteFPStotal = compteFPStotal + int(1/frameTime) : compteFPS = compteFPS +1 : fp4$ = "FPS moyen : ";int(compteFPStotal/compteFPS)
            #main.menu, "place 1200 11;\";fp$;"  \";fp4$;"     " ';"  \";fp3$;"  \";fp4$
        end if
    end if
    return

    [collisionMARCHE]
    if mY < 30 then goto [marcheEXIT]
    if perso1qy < 350 or perso1dy < 350 or perso1zy < 350 then perso1qy = 350 : perso1dy = 350 : perso1zy = 350 : mY = 350 : goto [marcheEXIT]
    if perso1dx > 1280 then perso1dx = 1280 : mX = 1280 : goto [marcheEXIT]
    if perso1qy > 725 or perso1dy > 725 or perso1sy > 725 then perso1qy = 725 : perso1dy = 725 : perso1sy = 725 : mY = 725 : goto [marcheEXIT]
    if perso1qy<447 and perso1qx < 220 then perso1qx = 220 : mX = perso1qx
    if perso1qy>1 and perso1qx < 185 then perso1qx = 185 : mX = perso1qx
    if perso1qy>575 and perso1qx < 210 then perso1qx = 210 : mX = perso1qx
    return

    [Eq]
    if startSECURITY = 1 then mX = 200 : mY = 500
    startSECURITY = 0

    [marcheDROITE2]
    gosub [collisionMARCHE]
    if mX > perso1dx then
        PERSOmoove = 1
        perso1dx = perso1dx + 3
        if perso1dx > mX then perso1dx = mX
        #main.map,"SpriteVisible perso1s off"
        #main.map,"SpriteVisible perso1q off"
        #main.map,"SpriteVisible perso1z off"
        #main.map,"SpriteVisible perso1d on"
        perso1qx=perso1dx : perso1sx=perso1dx : perso1zx=perso1dx : perso1qy=perso1dy : perso1sy=perso1dy : perso1zy=perso1dy :  activPOS1 = 1
        #main.map,"spritexy perso1d ";perso1dx;" ";perso1dy
        #main.map, "cyclesprite perso1d 1"
        if mY < perso1dy then perso1dy = perso1dy - 2
        if mY > perso1dy then perso1dy = perso1dy + 2
        #main.map,"drawsprites"
        #main.map "spritetofront perso1d"
        GOTO [marcheEXIT]
    end if

    [marcheGAUCHE2]
    gosub [collisionMARCHE]
    if mX < perso1qx then
        PERSOmoove = 1
        perso1qx = perso1qx - 3
        if perso1qx < mX then perso1qx = mX
        #main.map,"SpriteVisible perso1s off"
        #main.map,"SpriteVisible perso1d off"
        #main.map,"SpriteVisible perso1z off"
        #main.map,"SpriteVisible perso1q on"
        perso1dx=perso1qx : perso1sx=perso1qx : perso1zx=perso1qx : perso1dy=perso1qy : perso1sy=perso1qy : perso1zy=perso1qy : activPOS2 = 1
        #main.map,"spritexy perso1q ";perso1qx;" ";perso1qy
        #main.map, "cyclesprite perso1q 1"
        if mY < perso1qy then perso1qy = perso1qy - 2
        if mY > perso1qy then perso1qy = perso1qy + 2
        #main.map,"drawsprites"
        #main.map "spritetofront perso1q"
        GOTO [marcheEXIT]
    end if

    [marcheHAUT2]
    gosub [collisionMARCHE]
    if mY < perso1zy then
        PERSOmoove = 1
        perso1zy = perso1zy - 3
        if perso1zy < mY then perso1zy = mY
        #main.map,"SpriteVisible perso1s off"
        #main.map,"SpriteVisible perso1d off"
        #main.map,"SpriteVisible perso1q off"
        #main.map,"SpriteVisible perso1z on"
        perso1qy=perso1zy : perso1sy=perso1zy : perso1dy=perso1zy :  perso1qx=perso1zx : perso1sx=perso1zx : perso1dx=perso1zx : activPOS3 = 1
        #main.map,"spritexy perso1z ";perso1zx;" ";perso1zy
        #main.map, "cyclesprite perso1z 1"
        #main.map,"drawsprites"
        #main.map "spritetofront perso1z"
        GOTO [marcheEXIT]
    end if

    [marcheBAS2]
    gosub [collisionMARCHE]
    if mY > perso1sy then
        PERSOmoove = 1
        perso1sy = perso1sy + 3
        if perso1sy > mY then perso1sy = mY
        #main.map,"SpriteVisible perso1z off"
        #main.map,"SpriteVisible perso1d off"
        #main.map,"SpriteVisible perso1q off"
        #main.map,"SpriteVisible perso1s on"
        perso1zy=perso1sy : perso1dy=perso1sy : perso1qy=perso1sy : perso1zx=perso1sx : perso1dx=perso1sx : perso1qx=perso1sx : activPOS4 = 1
        #main.map,"spritexy perso1s ";perso1sx;" ";perso1sy
        #main.map, "cyclesprite perso1s 1"
        #main.map,"drawsprites"
        #main.map "spritetofront perso1s"
        GOTO [marcheEXIT]
    end if

    [marcheEXIT]
    if timingCounter = 5 then #main.map,"SpriteVisible atk off" : timingCounter = 0 : actiVtimingCounter = 0
    if actiVtimingCounter = 1 then timingCounter = timingCounter + 1
    gosub [colisions]
  '  gosub [txtREFRESH]
    timer 0

    E1x=E1x - MoveE1 : E11x=E11x - MoveE2 : E12x=E12x - MoveE3 : E13x=E13x - MoveE4 : E14x=E14x - MoveE5 : E15x=E15x - MoveE6 : E16x=E16x - MoveE7 : E17x=E17x - MoveE8 : E18x=E18x - MoveE9 : E19x=E19x - MoveE10
    E110x=E110x - MoveE11 : E111x=E111x - MoveE12 : E112x=E112x - MoveE13 : E113x=E113x - MoveE14 : E114x=E114x - MoveE15 : E115x=E115x - MoveE16 : E116x=E116x - MoveE17 : E117x=E117x - MoveE18 : E118x=E118x - MoveE19 : E119x=E119x - MoveE20
    E120x=E120x - MoveE21 : E121x=E121x - MoveE22 : E122x=E122x - MoveE23 : E123x=E123x - MoveE24 : E124x=E124x - MoveE25 : E125x=E125x - MoveE26 : E126x=E126x - MoveE27 : E127x=E127x - MoveE28 : E128x=E128x - MoveE29 : E129x=E129x - MoveE30
    E130x=E130x - MoveE31 : E131x=E131x - MoveE32 : E132x=E132x - MoveE33 : E133x=E133x - MoveE34 : E134x=E134x - MoveE35 : E135x=E135x - MoveE36 : E136x=E136x - MoveE37 : E137x=E137x - MoveE38 : E138x=E138x - MoveE39 : E139x=E139x - MoveE40
    E140x=E140x - MoveE41 : E141x=E141x - MoveE42 : E142x=E142x - MoveE43 : E143x=E143x - MoveE44 : E144x=E144x - MoveE45 : E145x=E145x - MoveE46 : E146x=E146x - MoveE47 : E147x=E147x - MoveE48 : E148x=E148x - MoveE49 : E149x=E149x - MoveE50
    E150x=E150x - MoveE51 : E151x=E151x - MoveE52 : E152x=E152x - MoveE53 : E153x=E153x - MoveE54 : E154x=E154x - MoveE55 : E155x=E155x - MoveE56 : E156x=E156x - MoveE57 : E157x=E157x - MoveE58 : E158x=E158x - MoveE59 : E159x=E159x - MoveE60
    E160x=E160x - MoveE61 : E161x=E161x - MoveE62 : E162x=E162x - MoveE63 : E163x=E163x - MoveE64 : E164x=E164x - MoveE65 : E165x=E165x - MoveE66 : E166x=E166x - MoveE67 : E167x=E167x - MoveE68 : E168x=E168x - MoveE69 : E169x=E169x - MoveE70
    E170x=E170x - MoveE71 : E171x=E171x - MoveE72 : E172x=E172x - MoveE73 : E173x=E173x - MoveE74 : E174x=E174x - MoveE75 : E175x=E175x - MoveE76 : E176x=E176x - MoveE77 : E177x=E177x - MoveE78 : E178x=E178x - MoveE79 : E179x=E179x - MoveE80
    E180x=E180x - MoveE81 : E181x=E181x - MoveE82 : E182x=E182x - MoveE83 : E183x=E183x - MoveE84 : E184x=E184x - MoveE85 : E185x=E185x - MoveE86 : E186x=E186x - MoveE87 : E187x=E187x - MoveE88 : E188x=E188x - MoveE89 : E189x=E189x - MoveE90
    E190x=E190x - MoveE91 : E191x=E191x - MoveE92 : E192x=E192x - MoveE93 : E193x=E193x - MoveE94 : E194x=E194x - MoveE95 : E195x=E195x - MoveE96 : E196x=E196x - MoveE97 : E197x=E197x - MoveE98 : E198x=E198x - MoveE99 : E199x=E199x - MoveE100
    cata1x=cata1x - Movecata1 : compteur = compteur + 1

    if Movecata1 > 0 then #main.map,"spritexy cata1 ";cata1x;" ";cata1y : #main.map,"SpriteVisible cata1 on" : #main.map "spritetofront cata1" : #main.map,"SpriteVisible cata2 off" : #main.map,"SpriteVisible cata3 off" : #main.map,"SpriteVisible cata4 off"
    if securPointcata1 = 1 then #main.map,"SpriteVisible cata1 off" : #main.map,"SpriteVisible cata2 off" : #main.map,"SpriteVisible cata3 off" : #main.map,"spritexy cata4 ";cata1x;" ";cata1y : #main.map,"SpriteVisible cata4 on" : #main.map "spritetofront cata4"
    if MoveE1 > 0 then #main.map,"spritexy E1 ";E1x;" ";E1y : #main.map,"SpriteVisible E1 on" : #main.map, "cyclesprite E1 1" : #main.map,"SpriteVisible ED1 off" : #main.map "spritetofront E1"
    if MoveE1 = 0 then #main.map,"spritexy ED1 ";E1x;" ";E1y+10 : #main.map,"SpriteVisible ED1 on" : #main.map,"SpriteVisible E1 off"
    if MoveE2 > 0 then #main.map,"spritexy E11 ";E11x;" ";E11y : #main.map,"SpriteVisible E11 on" : #main.map, "cyclesprite E11 1" : #main.map,"SpriteVisible ED11 off" : #main.map "spritetofront E11"
    if MoveE2 = 0 then #main.map,"spritexy ED11 ";E11x;" ";E11y+10 : #main.map,"SpriteVisible ED11 on" : #main.map,"SpriteVisible E11 off"
    if MoveE3 > 0 then #main.map,"spritexy E12 ";E12x;" ";E12y : #main.map,"SpriteVisible E12 on" : #main.map, "cyclesprite E12 1" : #main.map,"SpriteVisible ED12 off" : #main.map "spritetofront E12"
    if MoveE3 = 0 then #main.map,"spritexy ED12 ";E12x;" ";E12y+10 : #main.map,"SpriteVisible ED12 on" : #main.map,"SpriteVisible E12 off"
    if MoveE4 > 0 then #main.map,"spritexy E13 ";E13x;" ";E13y : #main.map,"SpriteVisible E13 on" : #main.map, "cyclesprite E13 1" : #main.map,"SpriteVisible ED13 off" : #main.map "spritetofront E13"
    if MoveE4 = 0 then #main.map,"spritexy ED13 ";E13x;" ";E13y+10 : #main.map,"SpriteVisible ED13 on" : #main.map,"SpriteVisible E13 off"
    if MoveE5 > 0 then #main.map,"spritexy E14 ";E14x;" ";E14y : #main.map,"SpriteVisible E14 on" : #main.map, "cyclesprite E14 1" : #main.map,"SpriteVisible ED14 off" : #main.map "spritetofront E14"
    if MoveE5 = 0 then #main.map,"spritexy ED14 ";E14x;" ";E14y+10 : #main.map,"SpriteVisible ED14 on" : #main.map,"SpriteVisible E14 off"
    if MoveE6 > 0 then #main.map,"spritexy E15 ";E15x;" ";E15y : #main.map,"SpriteVisible E15 on" :  #main.map, "cyclesprite E15 1" : #main.map,"SpriteVisible ED15 off" : #main.map "spritetofront E15"
    if MoveE6 = 0 then #main.map,"spritexy ED15 ";E15x;" ";E15y+10 : #main.map,"SpriteVisible ED15 on" : #main.map,"SpriteVisible E15 off"
    if MoveE7 > 0 then #main.map,"spritexy E16 ";E16x;" ";E16y : #main.map,"SpriteVisible E16 on" : #main.map, "cyclesprite E16 1" : #main.map,"SpriteVisible ED16 off" : #main.map "spritetofront E16"
    if MoveE7 = 0 then #main.map,"spritexy ED16 ";E16x;" ";E16y+10 : #main.map,"SpriteVisible ED16 on" : #main.map,"SpriteVisible E16 off"
    if MoveE8 > 0 then #main.map,"spritexy E17 ";E17x;" ";E17y : #main.map,"SpriteVisible E17 on" : #main.map, "cyclesprite E17 1" : #main.map,"SpriteVisible ED17 off" : #main.map "spritetofront E17"
    if MoveE8 = 0 then #main.map,"spritexy ED17 ";E17x;" ";E17y+10 : #main.map,"SpriteVisible ED17 on" : #main.map,"SpriteVisible E17 off"
    if MoveE9 > 0 then #main.map,"spritexy E18 ";E18x;" ";E18y : #main.map,"SpriteVisible E18 on" : #main.map, "cyclesprite E18 1" : #main.map,"SpriteVisible ED18 off" : #main.map "spritetofront E18"
    if MoveE9 = 0 then #main.map,"spritexy ED18 ";E18x;" ";E18y+10 : #main.map,"SpriteVisible ED18 on" : #main.map,"SpriteVisible E18 off"
    if MoveE10 > 0 then #main.map,"spritexy E19 ";E19x;" ";E19y : #main.map,"SpriteVisible E19 on" : #main.map, "cyclesprite E19 1" : #main.map,"SpriteVisible ED19 off" : #main.map "spritetofront E19"
    if MoveE10 = 0 then #main.map,"spritexy ED19 ";E19x;" ";E19y+10 : #main.map,"SpriteVisible ED19 on" : #main.map,"SpriteVisible E19 off"
    if MoveE11 > 0 then #main.map,"spritexy E110 ";E110x;" ";E110y : #main.map,"SpriteVisible E110 on" : #main.map, "cyclesprite E110 1" : #main.map,"SpriteVisible ED110 off" : #main.map "spritetofront E110"
    if MoveE11 = 0 then #main.map,"spritexy ED110 ";E110x;" ";E110y+10 : #main.map,"SpriteVisible ED110 on" : #main.map,"SpriteVisible E110 off"
    if MoveE12 > 0 then #main.map,"spritexy E111 ";E111x;" ";E111y : #main.map,"SpriteVisible E111 on" : #main.map, "cyclesprite E111 1" : #main.map,"SpriteVisible ED111 off" : #main.map "spritetofront E111"
    if MoveE12 = 0 then #main.map,"spritexy ED111 ";E111x;" ";E111y+10 : #main.map,"SpriteVisible ED111 on" : #main.map,"SpriteVisible E111 off"
    if MoveE13 > 0 then #main.map,"spritexy E112 ";E112x;" ";E112y : #main.map,"SpriteVisible E112 on" : #main.map, "cyclesprite E112 1" : #main.map,"SpriteVisible ED112 off" : #main.map "spritetofront E112"
    if MoveE13 = 0 then #main.map,"spritexy ED112 ";E112x;" ";E112y+10 : #main.map,"SpriteVisible ED112 on" : #main.map,"SpriteVisible E112 off"
    if MoveE14 > 0 then #main.map,"spritexy E113 ";E113x;" ";E113y : #main.map,"SpriteVisible E113 on" : #main.map, "cyclesprite E113 1" : #main.map,"SpriteVisible ED113 off" : #main.map "spritetofront E113"
    if MoveE14 = 0 then #main.map,"spritexy ED113 ";E113x;" ";E113y+10 : #main.map,"SpriteVisible ED113 on" : #main.map,"SpriteVisible E113 off"
    if MoveE15 > 0 then #main.map,"spritexy E114 ";E114x;" ";E114y : #main.map,"SpriteVisible E114 on" : #main.map, "cyclesprite E114 1" : #main.map,"SpriteVisible ED114 off" : #main.map "spritetofront E114"
    if MoveE15 = 0 then #main.map,"spritexy ED114 ";E114x;" ";E114y+10 : #main.map,"SpriteVisible ED114 on" : #main.map,"SpriteVisible E114 off"
    if MoveE16 > 0 then #main.map,"spritexy E115 ";E115x;" ";E115y : #main.map,"SpriteVisible E115 on" : #main.map, "cyclesprite E115 1" : #main.map,"SpriteVisible ED115 off" : #main.map "spritetofront E115"
    if MoveE16 = 0 then #main.map,"spritexy ED115 ";E115x;" ";E115y+10 : #main.map,"SpriteVisible ED115 on" : #main.map,"SpriteVisible E115 off"
    if MoveE17 > 0 then #main.map,"spritexy E116 ";E116x;" ";E116y : #main.map,"SpriteVisible E116 on" : #main.map, "cyclesprite E116 1" : #main.map,"SpriteVisible ED116 off" : #main.map "spritetofront E116"
    if MoveE17 = 0 then #main.map,"spritexy ED116 ";E116x;" ";E116y+10 : #main.map,"SpriteVisible ED116 on" : #main.map,"SpriteVisible E116 off"
    if MoveE18 > 0 then #main.map,"spritexy E117 ";E117x;" ";E117y : #main.map,"SpriteVisible E117 on" : #main.map, "cyclesprite E117 1" : #main.map,"SpriteVisible ED117 off" : #main.map "spritetofront E117"
    if MoveE18 = 0 then #main.map,"spritexy ED117 ";E117x;" ";E117y+10 : #main.map,"SpriteVisible ED117 on" : #main.map,"SpriteVisible E117 off"
    if MoveE19 > 0 then #main.map,"spritexy E118 ";E118x;" ";E118y : #main.map,"SpriteVisible E118 on" : #main.map, "cyclesprite E118 1" : #main.map,"SpriteVisible ED118 off" : #main.map "spritetofront E118"
    if MoveE19 = 0 then #main.map,"spritexy ED118 ";E118x;" ";E118y+10 : #main.map,"SpriteVisible ED118 on" : #main.map,"SpriteVisible E118 off"
    if MoveE20 > 0 then #main.map,"spritexy E119 ";E119x;" ";E119y : #main.map,"SpriteVisible E119 on" : #main.map, "cyclesprite E119 1" : #main.map,"SpriteVisible ED119 off" : #main.map "spritetofront E119"
    if MoveE20 = 0 then #main.map,"spritexy ED119 ";E119x;" ";E119y+10 : #main.map,"SpriteVisible ED119 on" : #main.map,"SpriteVisible E119 off"
    if MoveE21 > 0 then #main.map,"spritexy E120 ";E120x;" ";E120y : #main.map,"SpriteVisible E120 on" : #main.map, "cyclesprite E120 1" : #main.map,"SpriteVisible ED120 off" : #main.map "spritetofront E120"
    if MoveE21 = 0 then #main.map,"spritexy ED120 ";E120x;" ";E120y+10 : #main.map,"SpriteVisible ED120 on" : #main.map,"SpriteVisible E120 off"
    if MoveE22 > 0 then #main.map,"spritexy E121 ";E121x;" ";E121y : #main.map,"SpriteVisible E121 on" : #main.map, "cyclesprite E121 1" : #main.map,"SpriteVisible ED121 off" : #main.map "spritetofront E121"
    if MoveE22 = 0 then #main.map,"spritexy ED121 ";E121x;" ";E121y+10 : #main.map,"SpriteVisible ED121 on" : #main.map,"SpriteVisible E121 off"
    if MoveE23 > 0 then #main.map,"spritexy E122 ";E122x;" ";E122y : #main.map,"SpriteVisible E122 on" : #main.map, "cyclesprite E122 1" : #main.map,"SpriteVisible ED122 off" : #main.map "spritetofront E122"
    if MoveE23 = 0 then #main.map,"spritexy ED122 ";E122x;" ";E122y+10 : #main.map,"SpriteVisible ED122 on" : #main.map,"SpriteVisible E122 off"
    if MoveE24 > 0 then #main.map,"spritexy E123 ";E123x;" ";E123y : #main.map,"SpriteVisible E123 on" : #main.map, "cyclesprite E123 1" : #main.map,"SpriteVisible ED123 off" : #main.map "spritetofront E123"
    if MoveE24 = 0 then #main.map,"spritexy ED123 ";E123x;" ";E123y+10 : #main.map,"SpriteVisible ED123 on" : #main.map,"SpriteVisible E123 off"
    if MoveE25 > 0 then #main.map,"spritexy E124 ";E124x;" ";E124y : #main.map,"SpriteVisible E124 on" : #main.map, "cyclesprite E124 1" : #main.map,"SpriteVisible ED124 off" : #main.map "spritetofront E124"
    if MoveE25 = 0 then #main.map,"spritexy ED124 ";E124x;" ";E124y+10 : #main.map,"SpriteVisible ED124 on" : #main.map,"SpriteVisible E124 off"
    if MoveE26 > 0 then #main.map,"spritexy E125 ";E125x;" ";E125y : #main.map,"SpriteVisible E125 on" : #main.map, "cyclesprite E125 1" : #main.map,"SpriteVisible ED125 off" : #main.map "spritetofront E125"
    if MoveE26 = 0 then #main.map,"spritexy ED125 ";E125x;" ";E125y+10 : #main.map,"SpriteVisible ED125 on" : #main.map,"SpriteVisible E125 off"
    if MoveE27 > 0 then #main.map,"spritexy E126 ";E126x;" ";E126y : #main.map,"SpriteVisible E126 on" : #main.map, "cyclesprite E126 1" : #main.map,"SpriteVisible ED126 off" : #main.map "spritetofront E126"
    if MoveE27 = 0 then #main.map,"spritexy ED126 ";E126x;" ";E126y+10 : #main.map,"SpriteVisible ED126 on" : #main.map,"SpriteVisible E126 off"
    if MoveE28 > 0 then #main.map,"spritexy E127 ";E127x;" ";E127y : #main.map,"SpriteVisible E127 on" : #main.map, "cyclesprite E127 1" : #main.map,"SpriteVisible ED127 off" : #main.map "spritetofront E127"
    if MoveE28 = 0 then #main.map,"spritexy ED127 ";E127x;" ";E127y+10 : #main.map,"SpriteVisible ED127 on" : #main.map,"SpriteVisible E127 off"
    if MoveE29 > 0 then #main.map,"spritexy E128 ";E128x;" ";E128y : #main.map,"SpriteVisible E128 on" : #main.map, "cyclesprite E128 1" : #main.map,"SpriteVisible ED128 off" : #main.map "spritetofront E128"
    if MoveE29 = 0 then #main.map,"spritexy ED128 ";E128x;" ";E128y+10 : #main.map,"SpriteVisible ED128 on" : #main.map,"SpriteVisible E128 off"
    if MoveE30 > 0 then #main.map,"spritexy E129 ";E129x;" ";E129y : #main.map,"SpriteVisible E129 on" : #main.map, "cyclesprite E129 1" : #main.map,"SpriteVisible ED129 off" : #main.map "spritetofront E129"
    if MoveE30 = 0 then #main.map,"spritexy ED129 ";E129x;" ";E129y+10 : #main.map,"SpriteVisible ED129 on" : #main.map,"SpriteVisible E129 off"
    if MoveE31 > 0 then #main.map,"spritexy E130 ";E130x;" ";E130y : #main.map,"SpriteVisible E130 on" : #main.map, "cyclesprite E130 1" : #main.map,"SpriteVisible ED130 off" : #main.map "spritetofront E130"
    if MoveE31 = 0 then #main.map,"spritexy ED130 ";E130x;" ";E130y+10 : #main.map,"SpriteVisible ED130 on" : #main.map,"SpriteVisible E130 off"
    if MoveE32 > 0 then #main.map,"spritexy E131 ";E131x;" ";E131y : #main.map,"SpriteVisible E131 on" : #main.map, "cyclesprite E131 1" : #main.map,"SpriteVisible ED131 off" : #main.map "spritetofront E131"
    if MoveE32 = 0 then #main.map,"spritexy ED131 ";E131x;" ";E131y+10 : #main.map,"SpriteVisible ED131 on" : #main.map,"SpriteVisible E131 off"
    if MoveE33 > 0 then #main.map,"spritexy E132 ";E132x;" ";E132y : #main.map,"SpriteVisible E132 on" : #main.map, "cyclesprite E132 1" : #main.map,"SpriteVisible ED132 off" : #main.map "spritetofront E132"
    if MoveE33 = 0 then #main.map,"spritexy ED132 ";E132x;" ";E132y+10 : #main.map,"SpriteVisible ED132 on" : #main.map,"SpriteVisible E132 off"
    if MoveE34 > 0 then #main.map,"spritexy E133 ";E133x;" ";E133y : #main.map,"SpriteVisible E133 on" : #main.map, "cyclesprite E133 1" : #main.map,"SpriteVisible ED133 off" : #main.map "spritetofront E133"
    if MoveE34 = 0 then #main.map,"spritexy ED133 ";E133x;" ";E133y+10 : #main.map,"SpriteVisible ED133 on" : #main.map,"SpriteVisible E133 off"
    if MoveE35 > 0 then #main.map,"spritexy E134 ";E134x;" ";E134y : #main.map,"SpriteVisible E134 on" : #main.map, "cyclesprite E134 1" : #main.map,"SpriteVisible ED134 off" : #main.map "spritetofront E134"
    if MoveE35 = 0 then #main.map,"spritexy ED134 ";E134x;" ";E134y+10 : #main.map,"SpriteVisible ED134 on" : #main.map,"SpriteVisible E134 off"
    if MoveE36 > 0 then #main.map,"spritexy E135 ";E135x;" ";E135y : #main.map,"SpriteVisible E135 on" : #main.map, "cyclesprite E135 1" : #main.map,"SpriteVisible ED135 off" : #main.map "spritetofront E135"
    if MoveE36 = 0 then #main.map,"spritexy ED135 ";E135x;" ";E135y+10 : #main.map,"SpriteVisible ED135 on" : #main.map,"SpriteVisible E135 off"
    if MoveE37 > 0 then #main.map,"spritexy E136 ";E136x;" ";E136y : #main.map,"SpriteVisible E136 on" : #main.map, "cyclesprite E136 1" : #main.map,"SpriteVisible ED136 off" : #main.map "spritetofront E136"
    if MoveE37 = 0 then #main.map,"spritexy ED136 ";E136x;" ";E136y+10 : #main.map,"SpriteVisible ED136 on" : #main.map,"SpriteVisible E136 off"
    if MoveE38 > 0 then #main.map,"spritexy E137 ";E137x;" ";E137y : #main.map,"SpriteVisible E137 on" : #main.map, "cyclesprite E137 1" : #main.map,"SpriteVisible ED137 off" : #main.map "spritetofront E137"
    if MoveE38 = 0 then #main.map,"spritexy ED137 ";E137x;" ";E137y+10 : #main.map,"SpriteVisible ED137 on" : #main.map,"SpriteVisible E137 off"
    if MoveE39 > 0 then #main.map,"spritexy E138 ";E138x;" ";E138y : #main.map,"SpriteVisible E138 on" : #main.map, "cyclesprite E138 1" : #main.map,"SpriteVisible ED138 off" : #main.map "spritetofront E138"
    if MoveE39 = 0 then #main.map,"spritexy ED138 ";E138x;" ";E138y+10 : #main.map,"SpriteVisible ED138 on" : #main.map,"SpriteVisible E138 off"
    if MoveE40 > 0 then #main.map,"spritexy E139 ";E139x;" ";E139y : #main.map,"SpriteVisible E139 on" : #main.map, "cyclesprite E139 1" : #main.map,"SpriteVisible ED139 off" : #main.map "spritetofront E139"
    if MoveE40 = 0 then #main.map,"spritexy ED139 ";E139x;" ";E139y+10 : #main.map,"SpriteVisible ED139 on" : #main.map,"SpriteVisible E139 off"
    if MoveE41 > 0 then #main.map,"spritexy E140 ";E140x;" ";E140y : #main.map,"SpriteVisible E140 on" : #main.map, "cyclesprite E140 1" : #main.map,"SpriteVisible ED140 off" : #main.map "spritetofront E140"
    if MoveE41 = 0 then #main.map,"spritexy ED140 ";E140x;" ";E140y+10 : #main.map,"SpriteVisible ED140 on" : #main.map,"SpriteVisible E140 off"
    if MoveE42 > 0 then #main.map,"spritexy E141 ";E141x;" ";E141y : #main.map,"SpriteVisible E141 on" : #main.map, "cyclesprite E141 1" : #main.map,"SpriteVisible ED141 off" : #main.map "spritetofront E141"
    if MoveE42 = 0 then #main.map,"spritexy ED141 ";E141x;" ";E141y+10 : #main.map,"SpriteVisible ED141 on" : #main.map,"SpriteVisible E141 off"
    if MoveE43 > 0 then #main.map,"spritexy E142 ";E142x;" ";E142y : #main.map,"SpriteVisible E142 on" : #main.map, "cyclesprite E142 1" : #main.map,"SpriteVisible ED142 off" : #main.map "spritetofront E142"
    if MoveE43 = 0 then #main.map,"spritexy ED142 ";E142x;" ";E142y+10 : #main.map,"SpriteVisible ED142 on" : #main.map,"SpriteVisible E142 off"
    if MoveE44 > 0 then #main.map,"spritexy E143 ";E143x;" ";E143y : #main.map,"SpriteVisible E143 on" : #main.map, "cyclesprite E143 1" : #main.map,"SpriteVisible ED143 off" : #main.map "spritetofront E143"
    if MoveE44 = 0 then #main.map,"spritexy ED143 ";E143x;" ";E143y+10 : #main.map,"SpriteVisible ED143 on" : #main.map,"SpriteVisible E143 off"
    if MoveE45 > 0 then #main.map,"spritexy E144 ";E144x;" ";E144y : #main.map,"SpriteVisible E144 on" : #main.map, "cyclesprite E144 1" : #main.map,"SpriteVisible ED144 off" : #main.map "spritetofront E144"
    if MoveE45 = 0 then #main.map,"spritexy ED144 ";E144x;" ";E144y+10 : #main.map,"SpriteVisible ED144 on" : #main.map,"SpriteVisible E144 off"
    if MoveE46 > 0 then #main.map,"spritexy E145 ";E145x;" ";E145y : #main.map,"SpriteVisible E145 on" : #main.map, "cyclesprite E145 1" : #main.map,"SpriteVisible ED145 off" : #main.map "spritetofront E145"
    if MoveE46 = 0 then #main.map,"spritexy ED145 ";E145x;" ";E145y+10 : #main.map,"SpriteVisible ED145 on" : #main.map,"SpriteVisible E145 off"
    if MoveE47 > 0 then #main.map,"spritexy E146 ";E146x;" ";E146y : #main.map,"SpriteVisible E146 on" : #main.map, "cyclesprite E146 1" : #main.map,"SpriteVisible ED146 off" : #main.map "spritetofront E146"
    if MoveE47 = 0 then #main.map,"spritexy ED146 ";E146x;" ";E146y+10 : #main.map,"SpriteVisible ED146 on" : #main.map,"SpriteVisible E146 off"
    if MoveE48 > 0 then #main.map,"spritexy E147 ";E147x;" ";E147y : #main.map,"SpriteVisible E147 on" : #main.map, "cyclesprite E147 1" : #main.map,"SpriteVisible ED147 off" : #main.map "spritetofront E147"
    if MoveE48 = 0 then #main.map,"spritexy ED147 ";E147x;" ";E147y+10 : #main.map,"SpriteVisible ED147 on" : #main.map,"SpriteVisible E147 off"
    if MoveE49 > 0 then #main.map,"spritexy E148 ";E148x;" ";E148y : #main.map,"SpriteVisible E148 on" : #main.map, "cyclesprite E148 1" : #main.map,"SpriteVisible ED148 off" : #main.map "spritetofront E148"
    if MoveE49 = 0 then #main.map,"spritexy ED148 ";E148x;" ";E148y+10 : #main.map,"SpriteVisible ED148 on" : #main.map,"SpriteVisible E148 off"
    if MoveE50 > 0 then #main.map,"spritexy E149 ";E149x;" ";E149y : #main.map,"SpriteVisible E149 on" : #main.map, "cyclesprite E149 1" : #main.map,"SpriteVisible ED149 off" : #main.map "spritetofront E149"
    if MoveE50 = 0 then #main.map,"spritexy ED149 ";E149x;" ";E149y+10 : #main.map,"SpriteVisible ED149 on" : #main.map,"SpriteVisible E149 off"
    if MoveE51 > 0 then #main.map,"spritexy E150 ";E150x;" ";E150y : #main.map,"SpriteVisible E150 on" : #main.map, "cyclesprite E150 1" : #main.map,"SpriteVisible ED150 off" : #main.map "spritetofront E150"
    if MoveE51 = 0 then #main.map,"spritexy ED150 ";E150x;" ";E150y+10 : #main.map,"SpriteVisible ED150 on" : #main.map,"SpriteVisible E150 off"
    if MoveE52 > 0 then #main.map,"spritexy E151 ";E151x;" ";E151y : #main.map,"SpriteVisible E151 on" : #main.map, "cyclesprite E151 1" : #main.map,"SpriteVisible ED151 off" : #main.map "spritetofront E151"
    if MoveE52 = 0 then #main.map,"spritexy ED151 ";E151x;" ";E151y+10 : #main.map,"SpriteVisible ED151 on" : #main.map,"SpriteVisible E151 off"
    if MoveE53 > 0 then #main.map,"spritexy E152 ";E152x;" ";E152y : #main.map,"SpriteVisible E152 on" : #main.map, "cyclesprite E152 1" : #main.map,"SpriteVisible ED152 off" : #main.map "spritetofront E152"
    if MoveE53 = 0 then #main.map,"spritexy ED152 ";E152x;" ";E152y+10 : #main.map,"SpriteVisible ED152 on" : #main.map,"SpriteVisible E152 off"
    if MoveE54 > 0 then #main.map,"spritexy E153 ";E153x;" ";E153y : #main.map,"SpriteVisible E153 on" : #main.map, "cyclesprite E153 1" : #main.map,"SpriteVisible ED153 off" : #main.map "spritetofront E153"
    if MoveE54 = 0 then #main.map,"spritexy ED153 ";E153x;" ";E153y+10 : #main.map,"SpriteVisible ED153 on" : #main.map,"SpriteVisible E153 off"
    if MoveE55 > 0 then #main.map,"spritexy E154 ";E154x;" ";E154y : #main.map,"SpriteVisible E154 on" : #main.map, "cyclesprite E154 1" : #main.map,"SpriteVisible ED154 off" : #main.map "spritetofront E154"
    if MoveE55 = 0 then #main.map,"spritexy ED154 ";E154x;" ";E154y+10 : #main.map,"SpriteVisible ED154 on" : #main.map,"SpriteVisible E154 off"
    if MoveE56 > 0 then #main.map,"spritexy E155 ";E155x;" ";E155y : #main.map,"SpriteVisible E155 on" : #main.map, "cyclesprite E155 1" : #main.map,"SpriteVisible ED155 off" : #main.map "spritetofront E155"
    if MoveE56 = 0 then #main.map,"spritexy ED155 ";E155x;" ";E155y+10 : #main.map,"SpriteVisible ED155 on" : #main.map,"SpriteVisible E155 off"
    if MoveE57 > 0 then #main.map,"spritexy E156 ";E156x;" ";E156y : #main.map,"SpriteVisible E156 on" : #main.map, "cyclesprite E156 1" : #main.map,"SpriteVisible ED156 off" : #main.map "spritetofront E156"
    if MoveE57 = 0 then #main.map,"spritexy ED156 ";E156x;" ";E156y+10 : #main.map,"SpriteVisible ED156 on" : #main.map,"SpriteVisible E156 off"
    if MoveE58 > 0 then #main.map,"spritexy E157 ";E157x;" ";E157y : #main.map,"SpriteVisible E157 on" : #main.map, "cyclesprite E157 1" : #main.map,"SpriteVisible ED157 off" : #main.map "spritetofront E157"
    if MoveE58 = 0 then #main.map,"spritexy ED157 ";E157x;" ";E157y+10 : #main.map,"SpriteVisible ED157 on" : #main.map,"SpriteVisible E157 off"
    if MoveE59 > 0 then #main.map,"spritexy E158 ";E158x;" ";E158y : #main.map,"SpriteVisible E158 on" : #main.map, "cyclesprite E158 1" : #main.map,"SpriteVisible ED158 off" : #main.map "spritetofront E158"
    if MoveE59 = 0 then #main.map,"spritexy ED158 ";E158x;" ";E158y+10 : #main.map,"SpriteVisible ED158 on" : #main.map,"SpriteVisible E158 off"
    if MoveE60 > 0 then #main.map,"spritexy E159 ";E159x;" ";E159y : #main.map,"SpriteVisible E159 on" : #main.map, "cyclesprite E159 1" : #main.map,"SpriteVisible ED159 off" : #main.map "spritetofront E159"
    if MoveE60 = 0 then #main.map,"spritexy ED159 ";E159x;" ";E159y+10 : #main.map,"SpriteVisible ED159 on" : #main.map,"SpriteVisible E159 off"
    if MoveE61 > 0 then #main.map,"spritexy E160 ";E160x;" ";E160y : #main.map,"SpriteVisible E160 on" : #main.map, "cyclesprite E160 1" : #main.map,"SpriteVisible ED160 off" : #main.map "spritetofront E160"
    if MoveE61 = 0 then #main.map,"spritexy ED160 ";E160x;" ";E160y+10 : #main.map,"SpriteVisible ED160 on" : #main.map,"SpriteVisible E160 off"
    if MoveE62 > 0 then #main.map,"spritexy E161 ";E161x;" ";E161y : #main.map,"SpriteVisible E161 on" : #main.map, "cyclesprite E161 1" : #main.map,"SpriteVisible ED161 off" : #main.map "spritetofront E161"
    if MoveE62 = 0 then #main.map,"spritexy ED161 ";E161x;" ";E161y+10 : #main.map,"SpriteVisible ED161 on" : #main.map,"SpriteVisible E161 off"
    if MoveE63 > 0 then #main.map,"spritexy E162 ";E162x;" ";E162y : #main.map,"SpriteVisible E162 on" : #main.map, "cyclesprite E162 1" : #main.map,"SpriteVisible ED162 off" : #main.map "spritetofront E162"
    if MoveE63 = 0 then #main.map,"spritexy ED162 ";E162x;" ";E162y+10 : #main.map,"SpriteVisible ED162 on" : #main.map,"SpriteVisible E162 off"
    if MoveE64 > 0 then #main.map,"spritexy E163 ";E163x;" ";E163y : #main.map,"SpriteVisible E163 on" : #main.map, "cyclesprite E163 1" : #main.map,"SpriteVisible ED163 off" : #main.map "spritetofront E163"
    if MoveE64 = 0 then #main.map,"spritexy ED163 ";E163x;" ";E163y+10 : #main.map,"SpriteVisible ED163 on" : #main.map,"SpriteVisible E163 off"
    if MoveE65 > 0 then #main.map,"spritexy E164 ";E164x;" ";E164y : #main.map,"SpriteVisible E164 on" : #main.map, "cyclesprite E164 1" : #main.map,"SpriteVisible ED164 off" : #main.map "spritetofront E164"
    if MoveE65 = 0 then #main.map,"spritexy ED164 ";E164x;" ";E164y+10 : #main.map,"SpriteVisible ED164 on" : #main.map,"SpriteVisible E164 off"
    if MoveE66 > 0 then #main.map,"spritexy E165 ";E165x;" ";E165y : #main.map,"SpriteVisible E165 on" : #main.map, "cyclesprite E165 1" : #main.map,"SpriteVisible ED165 off" : #main.map "spritetofront E165"
    if MoveE66 = 0 then #main.map,"spritexy ED165 ";E165x;" ";E165y+10 : #main.map,"SpriteVisible ED165 on" : #main.map,"SpriteVisible E165 off"
    if MoveE67 > 0 then #main.map,"spritexy E166 ";E166x;" ";E166y : #main.map,"SpriteVisible E166 on" : #main.map, "cyclesprite E166 1" : #main.map,"SpriteVisible ED166 off" : #main.map "spritetofront E166"
    if MoveE67 = 0 then #main.map,"spritexy ED166 ";E166x;" ";E166y+10 : #main.map,"SpriteVisible ED166 on" : #main.map,"SpriteVisible E166 off"
    if MoveE68 > 0 then #main.map,"spritexy E167 ";E167x;" ";E167y : #main.map,"SpriteVisible E167 on" : #main.map, "cyclesprite E167 1" : #main.map,"SpriteVisible ED167 off" : #main.map "spritetofront E167"
    if MoveE68 = 0 then #main.map,"spritexy ED167 ";E167x;" ";E167y+10 : #main.map,"SpriteVisible ED167 on" : #main.map,"SpriteVisible E167 off"
    if MoveE69 > 0 then #main.map,"spritexy E168 ";E168x;" ";E168y : #main.map,"SpriteVisible E168 on" : #main.map, "cyclesprite E168 1" : #main.map,"SpriteVisible ED168 off" : #main.map "spritetofront E168"
    if MoveE69 = 0 then #main.map,"spritexy ED168 ";E168x;" ";E168y+10 : #main.map,"SpriteVisible ED168 on" : #main.map,"SpriteVisible E168 off"
    if MoveE70 > 0 then #main.map,"spritexy E169 ";E169x;" ";E169y : #main.map,"SpriteVisible E169 on" : #main.map, "cyclesprite E169 1" : #main.map,"SpriteVisible ED169 off" : #main.map "spritetofront E169"
    if MoveE70 = 0 then #main.map,"spritexy ED169 ";E169x;" ";E169y+10 : #main.map,"SpriteVisible ED169 on" : #main.map,"SpriteVisible E169 off"
    if MoveE71 > 0 then #main.map,"spritexy E170 ";E170x;" ";E170y : #main.map,"SpriteVisible E170 on" : #main.map, "cyclesprite E170 1" : #main.map,"SpriteVisible ED170 off" : #main.map "spritetofront E170"
    if MoveE71 = 0 then #main.map,"spritexy ED170 ";E170x;" ";E170y+10 : #main.map,"SpriteVisible ED170 on" : #main.map,"SpriteVisible E170 off"
    if MoveE72 > 0 then #main.map,"spritexy E171 ";E171x;" ";E171y : #main.map,"SpriteVisible E171 on" : #main.map, "cyclesprite E171 1" : #main.map,"SpriteVisible ED171 off" : #main.map "spritetofront E171"
    if MoveE72 = 0 then #main.map,"spritexy ED171 ";E171x;" ";E171y+10 : #main.map,"SpriteVisible ED171 on" : #main.map,"SpriteVisible E171 off"
    if MoveE73 > 0 then #main.map,"spritexy E172 ";E172x;" ";E172y : #main.map,"SpriteVisible E172 on" : #main.map, "cyclesprite E172 1" : #main.map,"SpriteVisible ED172 off" : #main.map "spritetofront E172"
    if MoveE73 = 0 then #main.map,"spritexy ED172 ";E172x;" ";E172y+10 : #main.map,"SpriteVisible ED172 on" : #main.map,"SpriteVisible E172 off"
    if MoveE74 > 0 then #main.map,"spritexy E173 ";E173x;" ";E173y : #main.map,"SpriteVisible E173 on" : #main.map, "cyclesprite E173 1" : #main.map,"SpriteVisible ED173 off" : #main.map "spritetofront E173"
    if MoveE74 = 0 then #main.map,"spritexy ED173 ";E173x;" ";E173y+10 : #main.map,"SpriteVisible ED173 on" : #main.map,"SpriteVisible E173 off"
    if MoveE75 > 0 then #main.map,"spritexy E174 ";E174x;" ";E174y : #main.map,"SpriteVisible E174 on" : #main.map, "cyclesprite E174 1" : #main.map,"SpriteVisible ED174 off" : #main.map "spritetofront E174"
    if MoveE75 = 0 then #main.map,"spritexy ED174 ";E174x;" ";E174y+10 : #main.map,"SpriteVisible ED174 on" : #main.map,"SpriteVisible E174 off"
    if MoveE76 > 0 then #main.map,"spritexy E175 ";E175x;" ";E175y : #main.map,"SpriteVisible E175 on" : #main.map, "cyclesprite E175 1" : #main.map,"SpriteVisible ED175 off" : #main.map "spritetofront E175"
    if MoveE76 = 0 then #main.map,"spritexy ED175 ";E175x;" ";E175y+10 : #main.map,"SpriteVisible ED175 on" : #main.map,"SpriteVisible E175 off"
    if MoveE77 > 0 then #main.map,"spritexy E176 ";E176x;" ";E176y : #main.map,"SpriteVisible E176 on" : #main.map, "cyclesprite E176 1" : #main.map,"SpriteVisible ED176 off" : #main.map "spritetofront E176"
    if MoveE77 = 0 then #main.map,"spritexy ED176 ";E176x;" ";E176y+10 : #main.map,"SpriteVisible ED176 on" : #main.map,"SpriteVisible E176 off"
    if MoveE78 > 0 then #main.map,"spritexy E177 ";E177x;" ";E177y : #main.map,"SpriteVisible E177 on" : #main.map, "cyclesprite E177 1" : #main.map,"SpriteVisible ED177 off" : #main.map "spritetofront E177"
    if MoveE78 = 0 then #main.map,"spritexy ED177 ";E177x;" ";E177y+10 : #main.map,"SpriteVisible ED177 on" : #main.map,"SpriteVisible E177 off"
    if MoveE79 > 0 then #main.map,"spritexy E178 ";E178x;" ";E178y : #main.map,"SpriteVisible E178 on" : #main.map, "cyclesprite E178 1" : #main.map,"SpriteVisible ED178 off" : #main.map "spritetofront E178"
    if MoveE79 = 0 then #main.map,"spritexy ED178 ";E178x;" ";E178y+10 : #main.map,"SpriteVisible ED178 on" : #main.map,"SpriteVisible E178 off"
    if MoveE80 > 0 then #main.map,"spritexy E179 ";E179x;" ";E179y : #main.map,"SpriteVisible E179 on" : #main.map, "cyclesprite E179 1" : #main.map,"SpriteVisible ED179 off" : #main.map "spritetofront E179"
    if MoveE80 = 0 then #main.map,"spritexy ED179 ";E179x;" ";E179y+10 : #main.map,"SpriteVisible ED179 on" : #main.map,"SpriteVisible E179 off"
    if MoveE81 > 0 then #main.map,"spritexy E180 ";E180x;" ";E180y : #main.map,"SpriteVisible E180 on" : #main.map, "cyclesprite E180 1" : #main.map,"SpriteVisible ED180 off" : #main.map "spritetofront E180"
    if MoveE81 = 0 then #main.map,"spritexy ED180 ";E180x;" ";E180y+10 : #main.map,"SpriteVisible ED180 on" : #main.map,"SpriteVisible E180 off"
    if MoveE82 > 0 then #main.map,"spritexy E181 ";E181x;" ";E181y : #main.map,"SpriteVisible E181 on" : #main.map, "cyclesprite E181 1" : #main.map,"SpriteVisible ED181 off" : #main.map "spritetofront E181"
    if MoveE82 = 0 then #main.map,"spritexy ED181 ";E181x;" ";E181y+10 : #main.map,"SpriteVisible ED181 on" : #main.map,"SpriteVisible E181 off"
    if MoveE83 > 0 then #main.map,"spritexy E182 ";E182x;" ";E182y : #main.map,"SpriteVisible E182 on" : #main.map, "cyclesprite E182 1" : #main.map,"SpriteVisible ED182 off" : #main.map "spritetofront E182"
    if MoveE83 = 0 then #main.map,"spritexy ED182 ";E182x;" ";E182y+10 : #main.map,"SpriteVisible ED182 on" : #main.map,"SpriteVisible E182 off"
    if MoveE84 > 0 then #main.map,"spritexy E183 ";E183x;" ";E183y : #main.map,"SpriteVisible E183 on" : #main.map, "cyclesprite E183 1" : #main.map,"SpriteVisible ED183 off" : #main.map "spritetofront E183"
    if MoveE84 = 0 then #main.map,"spritexy ED183 ";E183x;" ";E183y+10 : #main.map,"SpriteVisible ED183 on" : #main.map,"SpriteVisible E183 off"
    if MoveE85 > 0 then #main.map,"spritexy E184 ";E184x;" ";E184y : #main.map,"SpriteVisible E184 on" : #main.map, "cyclesprite E184 1" : #main.map,"SpriteVisible ED184 off" : #main.map "spritetofront E184"
    if MoveE85 = 0 then #main.map,"spritexy ED184 ";E184x;" ";E184y+10 : #main.map,"SpriteVisible ED184 on" : #main.map,"SpriteVisible E184 off"
    if MoveE86 > 0 then #main.map,"spritexy E185 ";E185x;" ";E185y : #main.map,"SpriteVisible E185 on" : #main.map, "cyclesprite E185 1" : #main.map,"SpriteVisible ED185 off" : #main.map "spritetofront E185"
    if MoveE86 = 0 then #main.map,"spritexy ED185 ";E185x;" ";E185y+10 : #main.map,"SpriteVisible ED185 on" : #main.map,"SpriteVisible E185 off"
    if MoveE87 > 0 then #main.map,"spritexy E186 ";E186x;" ";E186y : #main.map,"SpriteVisible E186 on" : #main.map, "cyclesprite E186 1" : #main.map,"SpriteVisible ED186 off" : #main.map "spritetofront E186"
    if MoveE87 = 0 then #main.map,"spritexy ED186 ";E186x;" ";E186y+10 : #main.map,"SpriteVisible ED186 on" : #main.map,"SpriteVisible E186 off"
    if MoveE88 > 0 then #main.map,"spritexy E187 ";E187x;" ";E187y : #main.map,"SpriteVisible E187 on" : #main.map, "cyclesprite E187 1" : #main.map,"SpriteVisible ED187 off" : #main.map "spritetofront E187"
    if MoveE88 = 0 then #main.map,"spritexy ED187 ";E187x;" ";E187y+10 : #main.map,"SpriteVisible ED187 on" : #main.map,"SpriteVisible E187 off"
    if MoveE89 > 0 then #main.map,"spritexy E188 ";E188x;" ";E188y : #main.map,"SpriteVisible E188 on" : #main.map, "cyclesprite E188 1" : #main.map,"SpriteVisible ED188 off" : #main.map "spritetofront E188"
    if MoveE89 = 0 then #main.map,"spritexy ED188 ";E188x;" ";E188y+10 : #main.map,"SpriteVisible ED188 on" : #main.map,"SpriteVisible E188 off"
    if MoveE90 > 0 then #main.map,"spritexy E189 ";E189x;" ";E189y : #main.map,"SpriteVisible E189 on" : #main.map, "cyclesprite E189 1" : #main.map,"SpriteVisible ED189 off" : #main.map "spritetofront E189"
    if MoveE90 = 0 then #main.map,"spritexy ED189 ";E189x;" ";E189y+10 : #main.map,"SpriteVisible ED189 on" : #main.map,"SpriteVisible E189 off"
    if MoveE91 > 0 then #main.map,"spritexy E190 ";E190x;" ";E190y : #main.map,"SpriteVisible E190 on" : #main.map, "cyclesprite E190 1" : #main.map,"SpriteVisible ED190 off" : #main.map "spritetofront E190"
    if MoveE91 = 0 then #main.map,"spritexy ED190 ";E190x;" ";E190y+10 : #main.map,"SpriteVisible ED190 on" : #main.map,"SpriteVisible E190 off"
    if MoveE92 > 0 then #main.map,"spritexy E191 ";E191x;" ";E191y : #main.map,"SpriteVisible E191 on" : #main.map, "cyclesprite E191 1" : #main.map,"SpriteVisible ED191 off" : #main.map "spritetofront E191"
    if MoveE92 = 0 then #main.map,"spritexy ED191 ";E191x;" ";E191y+10 : #main.map,"SpriteVisible ED191 on" : #main.map,"SpriteVisible E191 off"
    if MoveE93 > 0 then #main.map,"spritexy E192 ";E192x;" ";E192y : #main.map,"SpriteVisible E192 on" : #main.map, "cyclesprite E192 1" : #main.map,"SpriteVisible ED192 off" : #main.map "spritetofront E192"
    if MoveE93 = 0 then #main.map,"spritexy ED192 ";E192x;" ";E192y+10 : #main.map,"SpriteVisible ED192 on" : #main.map,"SpriteVisible E192 off"
    if MoveE94 > 0 then #main.map,"spritexy E193 ";E193x;" ";E193y : #main.map,"SpriteVisible E193 on" : #main.map, "cyclesprite E193 1" : #main.map,"SpriteVisible ED193 off" : #main.map "spritetofront E193"
    if MoveE94 = 0 then #main.map,"spritexy ED193 ";E193x;" ";E193y+10 : #main.map,"SpriteVisible ED193 on" : #main.map,"SpriteVisible E193 off"
    if MoveE95 > 0 then #main.map,"spritexy E194 ";E194x;" ";E194y : #main.map,"SpriteVisible E194 on" : #main.map, "cyclesprite E194 1" : #main.map,"SpriteVisible ED194 off" : #main.map "spritetofront E194"
    if MoveE95 = 0 then #main.map,"spritexy ED194 ";E194x;" ";E194y+10 : #main.map,"SpriteVisible ED194 on" : #main.map,"SpriteVisible E194 off"
    if MoveE96 > 0 then #main.map,"spritexy E195 ";E195x;" ";E195y : #main.map,"SpriteVisible E195 on" : #main.map, "cyclesprite E195 1" : #main.map,"SpriteVisible ED195 off" : #main.map "spritetofront E195"
    if MoveE96 = 0 then #main.map,"spritexy ED195 ";E195x;" ";E195y+10 : #main.map,"SpriteVisible ED195 on" : #main.map,"SpriteVisible E195 off"
    if MoveE97 > 0 then #main.map,"spritexy E196 ";E196x;" ";E196y : #main.map,"SpriteVisible E196 on" : #main.map, "cyclesprite E196 1" : #main.map,"SpriteVisible ED196 off" : #main.map "spritetofront E196"
    if MoveE97 = 0 then #main.map,"spritexy ED196 ";E196x;" ";E196y+10 : #main.map,"SpriteVisible ED196 on" : #main.map,"SpriteVisible E196 off"
    if MoveE98 > 0 then #main.map,"spritexy E197 ";E197x;" ";E197y : #main.map,"SpriteVisible E197 on" : #main.map, "cyclesprite E197 1" : #main.map,"SpriteVisible ED197 off" : #main.map "spritetofront E197"
    if MoveE98 = 0 then #main.map,"spritexy ED197 ";E197x;" ";E197y+10 : #main.map,"SpriteVisible ED197 on" : #main.map,"SpriteVisible E197 off"
    if MoveE99 > 0 then #main.map,"spritexy E198 ";E198x;" ";E198y : #main.map,"SpriteVisible E198 on" : #main.map, "cyclesprite E198 1" : #main.map,"SpriteVisible ED198 off" : #main.map "spritetofront E198"
    if MoveE99 = 0 then #main.map,"spritexy ED198 ";E198x;" ";E198y+10 : #main.map,"SpriteVisible ED198 on" : #main.map,"SpriteVisible E198 off"
    if MoveE100 > 0 then #main.map,"spritexy E199 ";E199x;" ";E199y : #main.map,"SpriteVisible E199 on" : #main.map, "cyclesprite E199 1" : #main.map,"SpriteVisible ED199 off" : #main.map "spritetofront E199"
    if MoveE100 = 0 then #main.map,"spritexy ED199 ";E199x;" ";E199y+10 : #main.map,"SpriteVisible ED199 on" : #main.map,"SpriteVisible E199 off"

    if compteur >500 and ENDactionBULLET = 1 and HPcata1 > 0 and Movecata1>0 then Movecata1 = 0.2 : compteur = 0 : ACTIONcata1 = 1 : ENDactionBULLET = 0
    if cata1x<=600 and Movecata1 > 0 then cata1x= 600 : ENDactionBULLET = 1

    if ACTIONcata1= 1 and cata1x= 600 and Movecata1> 0 then
        #main.map,"spritexy cata3 ";cata3x;" ";cata1y-5
        #main.map,"SpriteVisible cata3 on"
        #main.map,"SpriteVisible cata1 off"
        ACTIONbullet = 1 : VALmaxBULLET = int(rnd(cata1y-12.0)*1.0+cata1y-12.0) : bulletx = cata1x +10.0 : bullety = cata1y -2
        #main.map,"SpriteVisible bullet on"
        #main.map "spritetofront bullet"
        else
        if Movecata1> 0 then
            #main.map,"spritexy cata1 ";cata1x;" ";cata1y
            #main.map,"SpriteVisible cata1 on"
            #main.map,"SpriteVisible cata3 off"
        end if
    end if

                if Movecata1 = 0 then #main.map,"SpriteVisible cata1 off" : #main.map,"SpriteVisible cata2 off" : #main.map,"SpriteVisible cata3 off"
                if ACTIONbullet = 1 then
                    ATKcata1 = int((1000*waveNumber)*factor)
                    if ANGLEbullet <= 150 then bulletx = bulletx- 1 : bullety = bullety- 0.25 : ANGLEbullet = ANGLEbullet +1
                    if ANGLEbullet > 150 and ANGLEbullet <= 250 then bulletx = bulletx- 1 : bullety = bullety- 0.1 : ANGLEbullet = ANGLEbullet +1
                    if ANGLEbullet > 250 and ANGLEbullet <= 500 then bulletx = bulletx- 1 : bullety = bullety+ 0.1 : ANGLEbullet = ANGLEbullet +1
                    if bulletx < 170 then ANGLEbullet = 0 : ACTIONbullet = 0 : bullety = cata1y +1.5 : bulletx = cata3x +2.0 : ENDactionBULLET = 1 : damageCATAcastle = int(ATKcata1-castleArmor) : if damageCATAcastle < 0 then damageCATAcastle = 0 : castlePV = castlePV - damageCATAcastle : #main.map,"SpriteVisible bullet off"
                end if
                #main.map,"spritexy bullet ";bulletx;" ";bullety : ACTIONcata1 = 0

                if MoveE1 > 0 then
                    if E1x<185 then E1x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E1x<220 and E1y<447 then E1x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E1x<210 and E1y>580 then E1x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE2 > 0 then
                    if E11x<185 then E11x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E11x<220 and E11y<447 then E11x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E11x<210 and E11y>580 then E11x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE3 > 0 then
                    if E12x<185 then E12x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E12x<220 and E12y<447 then E12x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E12x<210 and E12y>580 then E12x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE4 > 0 then
                    if E13x<185 then E13x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E13x<220 and E13y<447 then E13x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E13x<210 and E13y>580 then E13x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE5 > 0 then
                    if E14x<185 then E14x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E14x<220 and E14y<447 then E14x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E14x<210 and E14y>580 then E14x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE6 > 0 then
                    if E15x<185 then E15x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E15x<220 and E15y<447 then E15x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E15x<210 and E15y>580 then E15x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE7 > 0 then
                    if E16x<185 then E16x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E16x<220 and E16y<447 then E16x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E16x<210 and E16y>580 then E16x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE8 > 0 then
                    if E17x<185 then E17x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E17x<220 and E17y<447 then E17x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E17x<210 and E17y>580 then E17x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE9 > 0 then
                    if E18x<185 then E18x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E18x<220 and E18y<447 then E18x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E18x<210 and E18y>580 then E18x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE10 > 0 then
                    if E19x<185 then E19x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E19x<220 and E19y<447 then E19x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E19x<210 and E19y>580 then E19x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE11 > 0 then
                    if E110x<185 then E110x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E110x<220 and E110y<447 then E110x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E110x<210 and E110y>575 then E110x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE12 > 0 then
                    if E111x<185 then E111x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E111x<220 and E111y<447 then E111x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E111x<210 and E111y>575 then E111x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE13 > 0 then
                    if E112x<185 then E112x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E112x<220 and E112y<447 then E112x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E112x<210 and E112y>575 then E112x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                IF MoveE14 > 0 then
                    if E113x<185 then E113x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E113x<220 and E113y<447 then E113x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E113x<210 and E113y>575 then E113x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE15 > 0  then
                    if E114x<185 then E114x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E114x<220 and E114y<447 then E114x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E114x<210 and E114y>575 then E114x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE16 > 0 then
                    if E115x<185 then E115x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E115x<220 and E115y<447 then E115x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E115x<210 and E115y>575 then E115x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE17 > 0 then
                    if E116x<185 then E116x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E116x<220 and E116y<447 then E116x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E116x<210 and E116y>575 then E116x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE18 > 0 then
                    if E117x<185 then E117x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E117x<220 and E117y<447 then E117x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E117x<210 and E117y>575 then E117x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE19 > 0 then
                    if E118x<185 then E118x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E118x<220 and E118y<447 then E118x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E118x<210 and E118y>575 then E118x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE20 > 0 then
                    if E119x<185 then E119x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E119x<220 and E119y<447 then E119x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E119x<210 and E119y>575 then E119x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE21 > 0 then
                    if E120x<185 then E120x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E120x<220 and E120y<447 then E120x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E120x<210 and E120y>575 then E120x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE22 > 0 then
                    if E121x<185 then E121x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E121x<220 and E121y<447 then E121x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E121x<210 and E121y>575 then E121x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE23 > 0 then
                    if E122x<185 then E122x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E122x<220 and E122y<447 then E122x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E122x<210 and E122y>575 then E122x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE24 > 0 then
                    if E123x<185 then E123x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E123x<220 and E123y<447 then E123x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E123x<210 and E123y>575 then E123x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE25 > 0 then
                    if E124x<185 then E124x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E124x<220 and E124y<447 then E124x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E124x<210 and E124y>575 then E124x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE26 > 0 then
                    if E125x<185 then E125x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E125x<220 and E125y<447 then E125x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E125x<210 and E125y>575 then E125x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE27 > 0 then
                    if E126x<185 then E126x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E126x<220 and E126y<447 then E126x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E126x<210 and E126y>575 then E126x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE28 > 0 then
                    if E127x<185 then E127x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E127x<220 and E127y<447 then E127x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E127x<210 and E127y>575 then E127x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE29 > 0 then
                    if E128x<185 then E128x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E128x<220 and E128y<447 then E128x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E128x<210 and E128y>575 then E128x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE30 > 0 then
                    if E129x<185 then E129x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E129x<220 and E129y<447 then E129x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E129x<210 and E129y>575 then E129x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE31 > 0 then
                    if E130x<185 then E130x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E130x<220 and E130y<447 then E130x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E130x<210 and E130y>575 then E130x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE32 > 0 then
                    if E131x<185 then E131x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E131x<220 and E131y<447 then E131x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E131x<210 and E131y>575 then E131x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE33 > 0 then
                    if E132x<185 then E132x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E132x<220 and E132y<447 then E132x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E132x<210 and E132y>575 then E132x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE34 > 0 then
                    if E133x<185 then E133x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E133x<220 and E133y<447 then E133x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E133x<210 and E133y>575 then E133x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE35 > 0 then
                    if E134x<185 then E134x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E134x<220 and E134y<447 then E134x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E134x<210 and E134y>575 then E134x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE36 > 0 then
                    if E135x<185 then E135x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E135x<220 and E135y<447 then E135x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E135x<210 and E135y>575 then E135x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE37 > 0 then
                    if E136x<185 then E136x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E136x<220 and E136y<447 then E136x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E136x<210 and E136y>575 then E136x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE38 > 0 then
                    if E137x<185 then E137x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E137x<220 and E137y<447 then E137x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E137x<210 and E137y>575 then E137x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE39 > 0 then
                    if E138x<185 then E138x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E138x<220 and E138y<447 then E138x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E138x<210 and E138y>575 then E138x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE40 > 0 then
                    if E139x<185 then E139x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E139x<220 and E139y<447 then E139x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E139x<210 and E139y>575 then E139x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE41 > 0 then
                    if E140x<185 then E140x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E140x<220 and E140y<447 then E140x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E140x<210 and E140y>575 then E140x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE42 > 0 then
                    if E141x<185 then E141x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E141x<220 and E141y<447 then E141x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E141x<210 and E141y>575 then E141x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE43 > 0 then
                    if E142x<185 then E142x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E142x<220 and E142y<447 then E142x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E142x<210 and E142y>575 then E142x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE44 > 0 then
                    if E143x<185 then E143x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E143x<220 and E143y<447 then E143x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E143x<210 and E143y>575 then E143x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE45 > 0 then
                    if E144x<185 then E144x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E144x<220 and E144y<447 then E144x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E144x<210 and E144y>575 then E144x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE46 > 0  then
                    if E145x<185 then E145x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E145x<220 and E145y<447 then E145x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E145x<210 and E145y>575 then E145x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE47 > 0 then
                    if E146x<185 then E146x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E146x<220 and E146y<447 then E146x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E146x<210 and E146y>575 then E146x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE48 > 0 then
                    if E147x<185 then E147x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E147x<220 and E147y<447 then E147x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E147x<210 and E147y>575 then E147x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE49 > 0 then
                    if E148x<185 then E148x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E148x<220 and E148y<447 then E148x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E148x<210 and E148y>575 then E148x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE50 > 0 then
                    if E149x<185 then E149x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E149x<220 and E149y<447 then E149x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E149x<210 and E149y>575 then E149x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE51 > 0 then
                    if E150x<185 then E150x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E150x<220 and E150y<447 then E150x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E150x<210 and E150y>575 then E150x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE52 > 0 then
                    if E151x<185 then E151x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E151x<220 and E151y<447 then E151x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E151x<210 and E151y>575 then E151x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE53 > 0 then
                    if E152x<185 then E152x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E152x<220 and E152y<447 then E152x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E152x<210 and E152y>575 then E152x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE54 > 0 then
                    if E153x<185 then E153x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E153x<220 and E153y<447 then E153x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E153x<210 and E153y>575 then E153x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE55 > 0 then
                    if E154x<185 then E154x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E154x<220 and E154y<447 then E154x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E154x<210 and E154y>575 then E154x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE56 > 0 then
                    if E155x<185 then E155x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E155x<220 and E155y<447 then E155x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E155x<210 and E155y>575 then E155x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE57 > 0 then
                    if E156x<185 then E156x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E156x<220 and E156y<447 then E156x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E156x<210 and E156y>575 then E156x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE58 > 0 then
                    if E157x<185 then E157x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E157x<220 and E157y<447 then E157x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E157x<210 and E157y>575 then E157x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE59 > 0 then
                    if E158x<185 then E158x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E158x<220 and E158y<447 then E158x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E158x<210 and E158y>575 then E158x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE60 > 0 then
                    if E159x<185 then E159x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E159x<220 and E159y<447 then E159x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E159x<210 and E159y>575 then E159x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE61 > 0 then
                    if E160x<185 then E160x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E160x<220 and E160y<447 then E160x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E160x<210 and E160y>575 then E160x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE62 > 0 then
                    if E161x<185 then E161x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E161x<220 and E161y<447 then E161x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E161x<210 and E161y>575 then E161x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE63 > 0 then
                    if E162x<185 then E162x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E162x<220 and E162y<447 then E162x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E162x<210 and E162y>575 then E162x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE64 > 0 then
                    if E163x<185 then E163x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E163x<220 and E163y<447 then E163x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E163x<210 and E163y>575 then E163x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE65 > 0 then
                    if E164x<185 then E164x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E164x<220 and E164y<447 then E164x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E164x<210 and E164y>575 then E164x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE66 > 0 then
                    if E165x<185 then E165x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E165x<220 and E165y<447 then E165x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E165x<210 and E165y>575 then E165x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE67 > 0 then
                    if E166x<185 then E166x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E166x<220 and E166y<447 then E166x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E166x<210 and E166y>575 then E166x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE68 > 0 then
                    if E167x<185 then E167x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E167x<220 and E167y<447 then E167x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E167x<210 and E167y>575 then E167x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE69 > 0 then
                    if E168x<185 then E168x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E168x<220 and E168y<447 then E168x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E168x<210 and E168y>575 then E168x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE70 > 0 then
                    if E169x<185 then E169x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E169x<220 and E169y<447 then E169x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E169x<210 and E169y>575 then E169x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE71 > 0 then
                    if E170x<185 then E170x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E170x<220 and E170y<447 then E170x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E170x<210 and E170y>575 then E170x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE72 > 0 then
                    if E171x<185 then E171x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E171x<220 and E171y<447 then E171x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E171x<210 and E171y>575 then E171x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE73 > 0 then
                    if E172x<185 then E172x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E172x<220 and E172y<447 then E172x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E172x<210 and E172y>575 then E172x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE74 > 0 then
                    if E173x<185 then E173x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E173x<220 and E173y<447 then E173x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E173x<210 and E173y>575 then E173x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE75 > 0 then
                    if E174x<185 then E174x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E174x<220 and E174y<447 then E174x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E174x<210 and E174y>575 then E174x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE76 > 0 then
                    if E175x<185 then E175x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E175x<220 and E175y<447 then E175x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E175x<210 and E175y>575 then E175x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE77 > 0 then
                    if E176x<185 then E176x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E176x<220 and E176y<447 then E176x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E176x<210 and E176y>575 then E176x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE78 > 0 then
                    if E177x<185 then E177x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E177x<220 and E177y<447 then E177x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E177x<210 and E177y>575 then E177x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE79 > 0 then
                    if E178x<185 then E178x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E178x<220 and E178y<447 then E178x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E178x<210 and E178y>575 then E178x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE80 > 0 then
                    if E179x<185 then E179x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E179x<220 and E179y<447 then E179x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E179x<210 and E179y>575 then E179x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE81 > 0 then
                    if E180x<185 then E180x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E180x<220 and E180y<447 then E180x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E180x<210 and E180y>575 then E180x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE82 > 0 then
                    if E181x<185 then E181x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E181x<220 and E181y<447 then E181x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E181x<210 and E181y>575 then E181x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE83 > 0 then
                    if E182x<185 then E182x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E182x<220 and E182y<447 then E182x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E182x<210 and E182y>575 then E182x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE84 > 0 then
                    if E183x<185 then E183x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E183x<220 and E183y<447 then E183x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E183x<210 and E183y>575 then E183x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE85 > 0 then
                    if E184x<185 then E184x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E184x<220 and E184y<447 then E184x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E184x<210 and E184y>575 then E184x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE86 > 0 then
                    if E185x<185 then E185x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E185x<220 and E185y<447 then E185x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E185x<210 and E185y>575 then E185x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE87 > 0 then
                    if E186x<185 then E186x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E186x<220 and E186y<447 then E186x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E186x<210 and E186y>575 then E186x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE88 > 0 then
                    if E187x<185 then E187x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E187x<220 and E187y<447 then E187x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E187x<210 and E187y>575 then E187x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE89 > 0 then
                    if E188x<185 then E188x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E188x<220 and E188y<447 then E188x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E188x<210 and E188y>575 then E188x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE90 > 0 then
                    if E189x<185 then E189x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E189x<220 and E189y<447 then E189x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E189x<210 and E189y>575 then E189x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE91 > 0 then
                    if E190x<185 then E190x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E190x<220 and E190y<447 then E190x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E190x<210 and E190y>575 then E190x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE92 > 0 then
                    if E191x<185 then E191x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E191x<220 and E191y<447 then E191x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E191x<210 and E191y>575 then E191x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE93 > 0 then
                    if E192x<185 then E192x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E192x<220 and E192y<447 then E192x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E192x<210 and E192y>575 then E192x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE94 > 0 then
                    if E193x<185 then E193x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E193x<220 and E193y<447 then E193x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E193x<210 and E193y>575 then E193x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE95 > 0 then
                    if E194x<185 then E194x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E194x<220 and E194y<447 then E194x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E194x<210 and E194y>575 then E194x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE96 > 0 then
                    if E195x<185 then E195x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E195x<220 and E195y<447 then E195x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E195x<210 and E195y>575 then E195x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE97 > 0 then
                    if E196x<185 then E196x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E196x<220 and E196y<447 then E196x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E196x<210 and E196y>575 then E196x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE98 > 0 then
                    if E197x<185 then E197x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E197x<220 and E197y<447 then E197x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E197x<210 and E197y>575 then E197x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE99 > 0 then
                    if E198x<185 then E198x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E198x<220 and E198y<447 then E198x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E198x<210 and E198y>575 then E198x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if
                if MoveE100 > 0 then
                    if E199x<185 then E199x=185 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E199x<220 and E199y<447 then E199x=220 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                    if E199x<210 and E199y>575 then E199x=210 : damageEcastle = int(rnd(1)*((atkE+1)-castleArmor)+1) : castlePV = castlePV - damageEcastle
                end if

            regenCompteur = regenCompteur +1
            if regenCompteur >= regenCompteurLimite then regenCompteur = 0 : HEROpv = int(HEROpv + regen) : if HEROpv > HEROpvTOTAL then HEROpv = HEROpvTOTAL
            regenCompteur2 = regenCompteur2 + 1
            if regenCompteur2 >= regenCompteur2Limite then regenCompteur2 = 0 : castlePV = castlePV + castleREGEN : if castlePV > castlePVtotal then castlePV = castlePVtotal

            if UnitsE = 0 then
                timer 0
                #main.map,"drawsprites"
                IncomWave = 1000 * waveNumber
                Gold = Gold + IncomWave
                if version = 1 then notice " " + chr$(13) + " " + chr$(13) + "Victoire ! + ";IncomWave ;" d'or"
                if version = 2 then notice " " + chr$(13) + " " + chr$(13) + "Victory ! + ";IncomWave ;" gold"
                if HPcata1 >1 and Movecata1 > 0 then #main.map, "backcolor ";86;" ";53;" ";35;";" ;" place ";cata1x+20;" ";cata1y-3;";\";""; str$(HPcata1);" / "; str$(HPcataTOTAL1)
                goto [INInextWave]
            end if
            if castlePV <= 0 or HEROpv <= 0 then
                timer 0
                castlePV = 0
                perso1zx=perso1dx:perso1zy=perso1dy
                perso1qx=perso1zx:perso1qy=perso1zy
                perso1sx=perso1qx:perso1sy=perso1qy
                persoDEADx = perso1sx : persoDEADy = perso1sy
                #main.map,"SpriteVisible perso1q off"
                #main.map,"SpriteVisible perso1d off"
                #main.map,"SpriteVisible perso1s off"
                #main.map,"SpriteVisible perso1z off"
                #main.map,"SpriteVisible bullet off"
                #main.map,"spritexy persoDEAD ";persoDEADx;" ";persoDEADy
                #main.map,"SpriteVisible persoDEAD on"
                #main.map,"when characterInput [w]"
                #main.map,"drawsprites"
                if version = 1 and HEROpv <= 0 or version = 1 and castlePV <= 0 then notice " " + chr$(13) + " " + chr$(13) + "Défaite !"
                if version = 2 and HEROpv <= 0 or version = 2 and castlePV <= 0 then notice " " + chr$(13) + " " + chr$(13) + "Defeat !"
                castlePV = 0
                goto [addTOscoore]
            end if

            #main.map, "cyclesprite perso1s 0" : #main.map, "cyclesprite perso1z 0" : #main.map, "cyclesprite perso1d 0" : #main.map, "cyclesprite perso1q 0"
            nuage1x = nuage1x +0.2 : nuage2x = nuage2x +0.1 : nuage3x = nuage3x +0.15 : nuage4x = nuage4x +0.3
            if nuage1x > 1350 then nuage1x= -60 : if nuage2x > 1400 then nuage2x= -100 : if nuage3x > 1350 then nuage3x= -60 : if nuage4x > 1400 then nuage4x= -100
            #main.map,"spritexy nuage1 ";nuage1x;" ";nuage1y
            #main.map,"spritexy nuage2 ";nuage2x;" ";nuage2y
            #main.map,"spritexy nuage3 ";nuage3x;" ";nuage3y
            #main.map,"spritexy nuage4 ";nuage4x;" ";nuage4y
            if PERSOmoove = 0 then #main.map,"drawsprites"

            PERSOmoove = 0
            gosub [txtREFRESH]
            if MusicSELECT = 1 then TIMINGmusic = TIMINGmusic + 1
            if TIMINGmusic = 5000 and MusicSELECT = 1 then
                TIMINGmusic = 0
                gosub [stopMusic2]
                gosub [startMusic]
            end if

            if activPOS1 = 1 and castlePV > 0 or HEROpv > 0 then
               if mX > perso1dx then timer 50, [marcheDROITE2] : wait
               activPOS1 = 0
            end if
            if activPOS2 = 1 and castlePV > 0 or HEROpv > 0 then
                if mX < perso1qx then timer 50, [marcheGAUCHE2] : wait
                activPOS2 = 0
            end if
            if activPOS3 = 1 and castlePV > 0 or HEROpv > 0 then
                if mY < perso1zy then timer 50, [marcheHAUT2] : wait
                activPOS3 = 0
            end if
            if activPOS4 = 1 and castlePV > 0 or HEROpv > 0 then
                if mY > perso1sy then timer 50, [marcheBAS2] : wait
                activPOS4 = 0
            end if
            timer 50, [marcheEXIT]
            wait

[loadSprites]
timer 0
HPcata1 = int((500*waveNumber)*factor)
HPcataTOTAL1 = HPcata1 : securPointcata1 = 0
ATKcata1 = int((1000*waveNumber)*factor) : DEFcata1 = int((5+waveNumber)*factor) : Ncata = 1
PvE1 =  int((6 + int(2*waveNumber))*factor) : PvE2 = PvE1 : PvE3 = PvE2 : PvE4 = PvE3 : PvE5 = PvE4 : PvE6 = PvE5 : PvE7 = PvE6 : PvE8 = PvE7 : PvE9 = PvE8 : PvE10 = PvE9
PvE11 = PvE10 : PvE12 = PvE11 : PvE13 = PvE12 : PvE14 = PvE13 : PvE15 = PvE14 : PvE16 = PvE15 : PvE17 = PvE16 : PvE18 = PvE17 : PvE19 = PvE18 : PvE20 = PvE19
PvE21 = PvE20 : PvE22 = PvE21 : PvE23 = PvE22 : PvE24 = PvE23 : PvE25 = PvE24 : PvE26 = PvE25 : PvE27 = PvE26 : PvE28 = PvE27 : PvE29 = PvE28 : PvE30 = PvE29
PvE31 = PvE30 : PvE32 = PvE31 : PvE33 = PvE32 : PvE34 = PvE33 : PvE35 = PvE34 : PvE36 = PvE35 : PvE37 = PvE36 : PvE38 = PvE37 : PvE39 = PvE38 : PvE40 = PvE39
PvE41 = PvE40 : PvE42 = PvE41 : PvE43 = PvE42 : PvE44 = PvE43 : PvE45 = PvE44 : PvE46 = PvE45 : PvE47 = PvE46 : PvE48 = PvE47 : PvE49 = PvE48 : PvE50 = PvE49
PvE51 = PvE50 : PvE52 = PvE51 : PvE53 = PvE52 : PvE54 = PvE53 : PvE55 = PvE54 : PvE56 = PvE55 : PvE57 = PvE56 : PvE58 = PvE57 : PvE59 = PvE58 : PvE60 = PvE59
PvE61 = PvE60 : PvE62 = PvE61 : PvE63 = PvE62 : PvE64 = PvE63 : PvE65 = PvE64 : PvE66 = PvE65 : PvE67 = PvE66 : PvE68 = PvE67 : PvE69 = PvE68 : PvE60 = PvE69
PvE71 = PvE70 : PvE72 = PvE71 : PvE73 = PvE72 : PvE74 = PvE73 : PvE75 = PvE74 : PvE76 = PvE75 : PvE77 = PvE76 : PvE78 = PvE77 : PvE79 = PvE78 : PvE70 = PvE79
PvE81 = PvE80 : PvE82 = PvE81 : PvE83 = PvE82 : PvE84 = PvE83 : PvE85 = PvE84 : PvE86 = PvE85 : PvE87 = PvE86 : PvE88 = PvE87 : PvE89 = PvE88 : PvE80 = PvE89
PvE91 = PvE90 : PvE92 = PvE91 : PvE93 = PvE92 : PvE94 = PvE93 : PvE95 = PvE94 : PvE96 = PvE95 : PvE97 = PvE96 : PvE98 = PvE97 : PvE99 = PvE98 : PvE90 = PvE99
atkE = int((8 + waveNumber*5)*factor) : defE = int((1 + waveNumber)*factor)
E1x = int(rnd(1)*500)+1300 : E11x = int(rnd(1)*500)+1300 : E12x = int(rnd(1)*500)+1300 : E13x = int(rnd(1)*500)+1300 : E14x = int(rnd(1)*500)+1300 : E15x = int(rnd(1)*500)+1300 : E16x = int(rnd(1)*500)+1300 : E17x = int(rnd(1)*500)+1300 : E18x = int(rnd(1)*500)+1300 : E19x = int(rnd(1)*500)+1300
E110x = int(rnd(1)*500)+1300 : E111x = int(rnd(1)*500)+1300 : E112x = int(rnd(1)*500)+1300 : E113x = int(rnd(1)*500)+1300 : E114x = int(rnd(1)*500)+1300 : E115x = int(rnd(1)*500)+1300 : E116x = int(rnd(1)*500)+1300 : E117x = int(rnd(1)*500)+1300 : E118x = int(rnd(1)*500)+1300 : E119x = int(rnd(1)*500)+1300
E120x = int(rnd(1)*500)+1300 : E121x = int(rnd(1)*500)+1300 : E122x = int(rnd(1)*500)+1300 : E123x = int(rnd(1)*500)+1300 : E124x = int(rnd(1)*500)+1300 : E125x = int(rnd(1)*500)+1300 : E126x = int(rnd(1)*500)+1300 : E127x = int(rnd(1)*500)+1300 : E128x = int(rnd(1)*500)+1300 : E129x = int(rnd(1)*500)+1300
E130x = int(rnd(1)*500)+1300 : E131x = int(rnd(1)*500)+1300 : E132x = int(rnd(1)*500)+1300 : E133x = int(rnd(1)*500)+1300 : E134x = int(rnd(1)*500)+1300 : E135x = int(rnd(1)*500)+1300 : E136x = int(rnd(1)*500)+1300 : E137x = int(rnd(1)*500)+1300 : E138x = int(rnd(1)*500)+1300 : E139x = int(rnd(1)*500)+1300
E140x = int(rnd(1)*500)+1300 : E141x = int(rnd(1)*500)+1300 : E142x = int(rnd(1)*500)+1300 : E143x = int(rnd(1)*500)+1300 : E144x = int(rnd(1)*500)+1300 : E145x = int(rnd(1)*500)+1300 : E146x = int(rnd(1)*500)+1300 : E147x = int(rnd(1)*500)+1300 : E148x = int(rnd(1)*500)+1300 : E149x = int(rnd(1)*500)+1300
E150x = int(rnd(1)*500)+1300 : E151x = int(rnd(1)*500)+1300 : E152x = int(rnd(1)*500)+1300 : E153x = int(rnd(1)*500)+1300 : E154x = int(rnd(1)*500)+1300 : E155x = int(rnd(1)*500)+1300 : E156x = int(rnd(1)*500)+1300 : E157x = int(rnd(1)*500)+1300 : E158x = int(rnd(1)*500)+1300 : E159x = int(rnd(1)*500)+1300
E160x = int(rnd(1)*500)+1300 : E161x = int(rnd(1)*500)+1300 : E162x = int(rnd(1)*500)+1300 : E163x = int(rnd(1)*500)+1300 : E164x = int(rnd(1)*500)+1300 : E165x = int(rnd(1)*500)+1300 : E166x = int(rnd(1)*500)+1300 : E167x = int(rnd(1)*500)+1300 : E168x = int(rnd(1)*500)+1300 : E169x = int(rnd(1)*500)+1300
E170x = int(rnd(1)*500)+1300 : E171x = int(rnd(1)*500)+1300 : E172x = int(rnd(1)*500)+1300 : E173x = int(rnd(1)*500)+1300 : E174x = int(rnd(1)*500)+1300 : E175x = int(rnd(1)*500)+1300 : E176x = int(rnd(1)*500)+1300 : E177x = int(rnd(1)*500)+1300 : E178x = int(rnd(1)*500)+1300 : E179x = int(rnd(1)*500)+1300
E180x = int(rnd(1)*500)+1300 : E181x = int(rnd(1)*500)+1300 : E182x = int(rnd(1)*500)+1300 : E183x = int(rnd(1)*500)+1300 : E184x = int(rnd(1)*500)+1300 : E185x = int(rnd(1)*500)+1300 : E186x = int(rnd(1)*500)+1300 : E187x = int(rnd(1)*500)+1300 : E188x = int(rnd(1)*500)+1300 : E189x = int(rnd(1)*500)+1300
E190x = int(rnd(1)*500)+1300 : E191x = int(rnd(1)*500)+1300 : E192x = int(rnd(1)*500)+1300 : E193x = int(rnd(1)*500)+1300 : E194x = int(rnd(1)*500)+1300 : E195x = int(rnd(1)*500)+1300 : E196x = int(rnd(1)*500)+1300 : E197x = int(rnd(1)*500)+1300 : E198x = int(rnd(1)*500)+1300 : E199x = int(rnd(1)*500)+1300
E1y = int(rnd(1)*350)+345 : E11y = int(rnd(1)*350)+345 : E12y = int(rnd(1)*350)+345 : E13y = int(rnd(1)*350)+345 : E14y = int(rnd(1)*350)+345 : E15y = int(rnd(1)*350)+345 : E16y = int(rnd(1)*350)+345 : E17y = int(rnd(1)*350)+345 : E18y = int(rnd(1)*350)+345 : E19y = int(rnd(1)*350)+345
E110y = int(rnd(1)*350)+345 : E111y = int(rnd(1)*350)+345 : E112y = int(rnd(1)*350)+345 : E113y = int(rnd(1)*350)+345 : E114y = int(rnd(1)*350)+345 : E115y = int(rnd(1)*350)+345 : E116y = int(rnd(1)*350)+345 : E117y = int(rnd(1)*350)+345 : E118y = int(rnd(1)*350)+345 : E119y = int(rnd(1)*350)+345
E120y = int(rnd(1)*350)+345 : E121y = int(rnd(1)*350)+345 : E122y = int(rnd(1)*350)+345 : E123y = int(rnd(1)*350)+345 : E124y = int(rnd(1)*350)+345 : E125y = int(rnd(1)*350)+345 : E126y = int(rnd(1)*350)+345 : E127y = int(rnd(1)*350)+345 : E128y = int(rnd(1)*350)+345 : E129y = int(rnd(1)*350)+345
E130y = int(rnd(1)*350)+345 : E131y = int(rnd(1)*350)+345 : E132y = int(rnd(1)*350)+345 : E133y = int(rnd(1)*350)+345 : E134y = int(rnd(1)*350)+345 : E135y = int(rnd(1)*350)+345 : E136y = int(rnd(1)*350)+345 : E137y = int(rnd(1)*350)+345 : E138y = int(rnd(1)*350)+345 : E139y = int(rnd(1)*350)+345
E140y = int(rnd(1)*350)+345 : E141y = int(rnd(1)*350)+345 : E142y = int(rnd(1)*350)+345 : E143y = int(rnd(1)*350)+345 : E144y = int(rnd(1)*350)+345 : E145y = int(rnd(1)*350)+345 : E146y = int(rnd(1)*350)+345 : E147y = int(rnd(1)*350)+345 : E148y = int(rnd(1)*350)+345 : E149y = int(rnd(1)*350)+345
E150y = int(rnd(1)*350)+345 : E151y = int(rnd(1)*350)+345 : E152y = int(rnd(1)*350)+345 : E153y = int(rnd(1)*350)+345 : E154y = int(rnd(1)*350)+345 : E155y = int(rnd(1)*350)+345 : E156y = int(rnd(1)*350)+345 : E157y = int(rnd(1)*350)+345 : E158y = int(rnd(1)*350)+345 : E159y = int(rnd(1)*350)+345
E160y = int(rnd(1)*350)+345 : E161y = int(rnd(1)*350)+345 : E162y = int(rnd(1)*350)+345 : E163y = int(rnd(1)*350)+345 : E164y = int(rnd(1)*350)+345 : E165y = int(rnd(1)*350)+345 : E166y = int(rnd(1)*350)+345 : E167y = int(rnd(1)*350)+345 : E168y = int(rnd(1)*350)+345 : E169y = int(rnd(1)*350)+345
E170y = int(rnd(1)*350)+345 : E171y = int(rnd(1)*350)+345 : E172y = int(rnd(1)*350)+345 : E173y = int(rnd(1)*350)+345 : E174y = int(rnd(1)*350)+345 : E175y = int(rnd(1)*350)+345 : E176y = int(rnd(1)*350)+345 : E177y = int(rnd(1)*350)+345 : E178y = int(rnd(1)*350)+345 : E179y = int(rnd(1)*350)+345
E180y = int(rnd(1)*350)+345 : E181y = int(rnd(1)*350)+345 : E182y = int(rnd(1)*350)+345 : E183y = int(rnd(1)*350)+345 : E184y = int(rnd(1)*350)+345 : E185y = int(rnd(1)*350)+345 : E186y = int(rnd(1)*350)+345 : E187y = int(rnd(1)*350)+345 : E188y = int(rnd(1)*350)+345 : E189y = int(rnd(1)*350)+345
E190y = int(rnd(1)*350)+345 : E191y = int(rnd(1)*350)+345 : E192y = int(rnd(1)*350)+345 : E193y = int(rnd(1)*350)+345 : E194y = int(rnd(1)*350)+345 : E195y = int(rnd(1)*350)+345 : E196y = int(rnd(1)*350)+345 : E197y = int(rnd(1)*350)+345 : E198y = int(rnd(1)*350)+345 : E199y = int(rnd(1)*350)+345

securPoint1 = 0 : securPoint2 = 0 : securPoint3 = 0 : securPoint4 = 0 : securPoint5 = 0 : securPoint6 = 0 : securPoint7 = 0 : securPoint8 = 0 : securPoint9 = 0 : securPoint10 = 0
securPoint11 = 0 : securPoint12 = 0 : securPoint13 = 0 : securPoint14 = 0 : securPoint15 = 0 : securPoint16 = 0 : securPoint17 = 0 : securPoint18 = 0 : securPoint19 = 0 : securPoint20 = 0
securPoint21 = 0 : securPoint22 = 0 : securPoint23 = 0 : securPoint24 = 0 : securPoint25 = 0 : securPoint26 = 0 : securPoint27 = 0 : securPoint28 = 0 : securPoint29 = 0 : securPoint30 = 0
securPoint31 = 0 : securPoint32 = 0 : securPoint33 = 0 : securPoint34 = 0 : securPoint35 = 0 : securPoint36 = 0 : securPoint37 = 0 : securPoint38 = 0 : securPoint39 = 0 : securPoint40 = 0
securPoint41 = 0 : securPoint42 = 0 : securPoint43 = 0 : securPoint44 = 0 : securPoint45 = 0 : securPoint46 = 0 : securPoint47 = 0 : securPoint48 = 0 : securPoint49 = 0 : securPoint50 = 0
securPoint51 = 0 : securPoint52 = 0 : securPoint53 = 0 : securPoint54 = 0 : securPoint55 = 0 : securPoint56 = 0 : securPoint57 = 0 : securPoint58 = 0 : securPoint59 = 0 : securPoint60 = 0
securPoint61 = 0 : securPoint62 = 0 : securPoint63 = 0 : securPoint64 = 0 : securPoint65 = 0 : securPoint66 = 0 : securPoint67 = 0 : securPoint68 = 0 : securPoint69 = 0 : securPoint70 = 0
securPoint71 = 0 : securPoint72 = 0 : securPoint73 = 0 : securPoint74 = 0 : securPoint75 = 0 : securPoint76 = 0 : securPoint77 = 0 : securPoint78 = 0 : securPoint79 = 0 : securPoint80 = 0
securPoint81 = 0 : securPoint82 = 0 : securPoint83 = 0 : securPoint84 = 0 : securPoint85 = 0 : securPoint86 = 0 : securPoint87 = 0 : securPoint88 = 0 : securPoint89 = 0 : securPoint90 = 0
securPoint91 = 0 : securPoint92 = 0 : securPoint93 = 0 : securPoint94 = 0 : securPoint95 = 0 : securPoint96 = 0 : securPoint97 = 0 : securPoint98 = 0 : securPoint99 = 0 : securPoint100 = 0

gosub [waveMooveControle]
cata1x = 1300 : cata1y = int(rnd(1)*100)+370 : cata2x = cata1x : cata2y = cata1y : cata3x = cata1x : cata3y = cata1y
timer 10, [Eq]
return

[waveMooveControle]
if waveNumber = 1 then MoveE1 = rnd(0.1)*2+0.5 : MoveE2 = rnd(0.1)*2+0.5 : MoveE3 = rnd(0.1)*2+0.5 : MoveE4 = rnd(0.1)*2+0.5 : MoveE5 = rnd(0.1)*2+0.5 : MoveE6 = rnd(0.1)*2+0.5 : MoveE7 = rnd(0.1)*2+0.5 : MoveE8 = rnd(0.1)*2+0.5 : MoveE9 = rnd(0.1)*2+0.5 : MoveE10 = rnd(0.1)*2+0.5 : UnitsE = 10
if waveNumber = 2 then
    Movecata1 = 0 : UnitsE = 20
    MoveE1 = rnd(0.1)*2+0.5 : MoveE2 = rnd(0.1)*0.9+0.4 : MoveE3 = rnd(0.1)*2+0.5 : MoveE4 = rnd(0.1)*2+0.5 : MoveE5 = rnd(0.1)*2+0.5 : MoveE6 = rnd(0.1)*2+0.5 : MoveE7 = rnd(0.1)*2+0.5 : MoveE8 = rnd(0.1)*2+0.5 : MoveE9 = rnd(0.1)*2+0.5 : MoveE10 = rnd(0.1)*2+0.5
    MoveE11 = rnd(0.1)*2+0.5 : MoveE12 = rnd(0.1)*2+0.5 : MoveE13 = rnd(0.1)*2+0.5 : MoveE14 = rnd(0.1)*2+0.5 : MoveE15 = rnd(0.1)*2+0.5 : MoveE16 = rnd(0.1)*2+0.5 : MoveE17 = rnd(0.1)*2+0.5 : MoveE18 = rnd(0.1)*2+0.5 : MoveE19 = rnd(0.1)*2+0.5 : MoveE20 = rnd(0.1)*2+0.5
end if
if waveNumber = 3 then
    Movecata1 = 0.35 : UnitsE = 31
    MoveE1 = rnd(0.1)*2+0.5 : MoveE2 = rnd(0.1)*2+0.5 : MoveE3 = rnd(0.1)*2+0.5 : MoveE4 = rnd(0.1)*2+0.5 : MoveE5 = rnd(0.1)*2+0.5 : MoveE6 = rnd(0.1)*2+0.5 : MoveE7 = rnd(0.1)*2+0.5 : MoveE8 = rnd(0.1)*2+0.5 : MoveE9 = rnd(0.1)*2+0.5 : MoveE10 = rnd(0.1)*2+0.5
    MoveE11 = rnd(0.1)*2+0.5 : MoveE12 = rnd(0.1)*2+0.5 : MoveE13 = rnd(0.1)*2+0.5 : MoveE14 = rnd(0.1)*2+0.5 : MoveE15 = rnd(0.1)*2+0.5 : MoveE16 = rnd(0.1)*2+0.5 : MoveE17 = rnd(0.1)*2+0.5 : MoveE18 = rnd(0.1)*2+0.5 : MoveE19 = rnd(0.1)*2+0.5 : MoveE20 = rnd(0.1)*2+0.5
    MoveE21 = rnd(0.1)*2+0.5 : MoveE22 = rnd(0.1)*2+0.5 : MoveE23 = rnd(0.1)*2+0.5 : MoveE24 = rnd(0.1)*2+0.5 : MoveE25 = rnd(0.1)*2+0.5 : MoveE26 = rnd(0.1)*2+0.5 : MoveE27 = rnd(0.1)*2+0.5 : MoveE28 = rnd(0.1)*2+0.5 : MoveE29 = rnd(0.1)*2+0.5 : MoveE30 = rnd(0.1)*2+0.5
end if
if waveNumber = 4 then
    Movecata1 = 0.35 : UnitsE = 41
    MoveE1 = rnd(0.1)*2+0.5 : MoveE2 = rnd(0.1)*2+0.5 : MoveE3 = rnd(0.1)*2+0.5 : MoveE4 = rnd(0.1)*2+0.5 : MoveE5 = rnd(0.1)*2+0.5 : MoveE6 = rnd(0.1)*2+0.5 : MoveE7 = rnd(0.1)*2+0.5 : MoveE8 = rnd(0.1)*2+0.5 : MoveE9 = rnd(0.1)*2+0.5 : MoveE10 = rnd(0.1)*2+0.5
    MoveE11 = rnd(0.1)*2+0.5 : MoveE12 = rnd(0.1)*2+0.5 : MoveE13 = rnd(0.1)*2+0.5 : MoveE14 = rnd(0.1)*2+0.5 : MoveE15 = rnd(0.1)*2+0.5 : MoveE16 = rnd(0.1)*2+0.5 : MoveE17 = rnd(0.1)*2+0.5 : MoveE18 = rnd(0.1)*2+0.5 : MoveE19 = rnd(0.1)*2+0.5 : MoveE20 = rnd(0.1)*2+0.5
    MoveE21 = rnd(0.1)*2+0.5 : MoveE22 = rnd(0.1)*2+0.5 : MoveE23 = rnd(0.1)*2+0.5 : MoveE24 = rnd(0.1)*2+0.5 : MoveE25 = rnd(0.1)*2+0.5 : MoveE26 = rnd(0.1)*2+0.5 : MoveE27 = rnd(0.1)*2+0.5 : MoveE28 = rnd(0.1)*2+0.5 : MoveE29 = rnd(0.1)*2+0.5 : MoveE30 = rnd(0.1)*2+0.5
    MoveE31 = rnd(0.1)*2+0.5 : MoveE32 = rnd(0.1)*2+0.5 : MoveE33 = rnd(0.1)*2+0.5 : MoveE34 = rnd(0.1)*2+0.5 : MoveE35 = rnd(0.1)*2+0.5 : MoveE36 = rnd(0.1)*2+0.5 : MoveE37 = rnd(0.1)*2+0.5 : MoveE38 = rnd(0.1)*2+0.5 : MoveE39 = rnd(0.1)*2+0.5 : MoveE40 = rnd(0.1)*2+0.5
end if
if waveNumber = 5 then
    Movecata1 = 0.35 : UnitsE = 61
    MoveE1 = rnd(0.1)*2+0.5 : MoveE2 = rnd(0.1)*2+0.5 : MoveE3 = rnd(0.1)*2+0.5 : MoveE4 = rnd(0.1)*2+0.5 : MoveE5 = rnd(0.1)*2+0.5 : MoveE6 = rnd(0.1)*2+0.5 : MoveE7 = rnd(0.1)*2+0.5 : MoveE8 = rnd(0.1)*2+0.5 : MoveE9 = rnd(0.1)*2+0.5 : MoveE10 = rnd(0.1)*2+0.5
    MoveE11 = rnd(0.1)*2+0.5 : MoveE12 = rnd(0.1)*2+0.5 : MoveE13 = rnd(0.1)*2+0.5 : MoveE14 = rnd(0.1)*2+0.5 : MoveE15 = rnd(0.1)*2+0.5 : MoveE16 = rnd(0.1)*2+0.5 : MoveE17 = rnd(0.1)*2+0.5 : MoveE18 = rnd(0.1)*2+0.5 : MoveE19 = rnd(0.1)*2+0.5 : MoveE20 = rnd(0.1)*2+0.5
    MoveE21 = rnd(0.1)*2+0.5 : MoveE22 = rnd(0.1)*2+0.5 : MoveE23 = rnd(0.1)*2+0.5 : MoveE24 = rnd(0.1)*2+0.5 : MoveE25 = rnd(0.1)*2+0.5 : MoveE26 = rnd(0.1)*2+0.5 : MoveE27 = rnd(0.1)*2+0.5 : MoveE28 = rnd(0.1)*2+0.5 : MoveE29 = rnd(0.1)*2+0.5 : MoveE30 = rnd(0.1)*2+0.5
    MoveE31 = rnd(0.1)*2+0.5 : MoveE32 = rnd(0.1)*2+0.5 : MoveE33 = rnd(0.1)*2+0.5 : MoveE34 = rnd(0.1)*2+0.5 : MoveE35 = rnd(0.1)*2+0.5 : MoveE36 = rnd(0.1)*2+0.5 : MoveE37 = rnd(0.1)*2+0.5 : MoveE38 = rnd(0.1)*2+0.5 : MoveE39 = rnd(0.1)*2+0.5 : MoveE40 = rnd(0.1)*2+0.5
    MoveE41 = rnd(0.1)*2+0.5 : MoveE42 = rnd(0.1)*2+0.5 : MoveE43 = rnd(0.1)*2+0.5 : MoveE44 = rnd(0.1)*2+0.5 : MoveE45 = rnd(0.1)*2+0.5 : MoveE46 = rnd(0.1)*2+0.5 : MoveE47 = rnd(0.1)*2+0.5 : MoveE48 = rnd(0.1)*2+0.5 : MoveE49 = rnd(0.1)*2+0.5 : MoveE50 = rnd(0.1)*2+0.5
    MoveE51 = rnd(0.1)*2+0.5 : MoveE52 = rnd(0.1)*2+0.5 : MoveE53 = rnd(0.1)*2+0.5 : MoveE54 = rnd(0.1)*2+0.5 : MoveE55 = rnd(0.1)*2+0.5 : MoveE56 = rnd(0.1)*2+0.5 : MoveE57 = rnd(0.1)*2+0.5 : MoveE58 = rnd(0.1)*2+0.5 : MoveE59 = rnd(0.1)*2+0.5 : MoveE60 = rnd(0.1)*2+0.5
end if
if waveNumber = 6 then
    Movecata1 = 0.35 : UnitsE = 81
    MoveE1 = rnd(0.1)*2+0.5 : MoveE2 = rnd(0.1)*2+0.5 : MoveE3 = rnd(0.1)*2+0.5 : MoveE4 = rnd(0.1)*2+0.5 : MoveE5 = rnd(0.1)*2+0.5 : MoveE6 = rnd(0.1)*2+0.5 : MoveE7 = rnd(0.1)*2+0.5 : MoveE8 = rnd(0.1)*2+0.5 : MoveE9 = rnd(0.1)*2+0.5 : MoveE10 = rnd(0.1)*2+0.5
    MoveE11 = rnd(0.1)*2+0.5 : MoveE12 = rnd(0.1)*2+0.5 : MoveE13 = rnd(0.1)*2+0.5 : MoveE14 = rnd(0.1)*2+0.5 : MoveE15 = rnd(0.1)*2+0.5 : MoveE16 = rnd(0.1)*2+0.5 : MoveE17 = rnd(0.1)*2+0.5 : MoveE18 = rnd(0.1)*2+0.5 : MoveE19 = rnd(0.1)*2+0.5 : MoveE20 = rnd(0.1)*2+0.5
    MoveE21 = rnd(0.1)*2+0.5 : MoveE22 = rnd(0.1)*2+0.5 : MoveE23 = rnd(0.1)*2+0.5 : MoveE24 = rnd(0.1)*2+0.5 : MoveE25 = rnd(0.1)*2+0.5 : MoveE26 = rnd(0.1)*2+0.5 : MoveE27 = rnd(0.1)*2+0.5 : MoveE28 = rnd(0.1)*2+0.5 : MoveE29 = rnd(0.1)*2+0.5 : MoveE30 = rnd(0.1)*2+0.5
    MoveE31 = rnd(0.1)*2+0.5 : MoveE32 = rnd(0.1)*2+0.5 : MoveE33 = rnd(0.1)*2+0.5 : MoveE34 = rnd(0.1)*2+0.5 : MoveE35 = rnd(0.1)*2+0.5 : MoveE36 = rnd(0.1)*2+0.5 : MoveE37 = rnd(0.1)*2+0.5 : MoveE38 = rnd(0.1)*2+0.5 : MoveE39 = rnd(0.1)*2+0.5 : MoveE40 = rnd(0.1)*2+0.5
    MoveE41 = rnd(0.1)*2+0.5 : MoveE42 = rnd(0.1)*2+0.5 : MoveE43 = rnd(0.1)*2+0.5 : MoveE44 = rnd(0.1)*2+0.5 : MoveE45 = rnd(0.1)*2+0.5 : MoveE46 = rnd(0.1)*2+0.5 : MoveE47 = rnd(0.1)*2+0.5 : MoveE48 = rnd(0.1)*2+0.5 : MoveE49 = rnd(0.1)*2+0.5 : MoveE50 = rnd(0.1)*2+0.5
    MoveE51 = rnd(0.1)*2+0.5 : MoveE52 = rnd(0.1)*2+0.5 : MoveE53 = rnd(0.1)*2+0.5 : MoveE54 = rnd(0.1)*2+0.5 : MoveE55 = rnd(0.1)*2+0.5 : MoveE56 = rnd(0.1)*2+0.5 : MoveE57 = rnd(0.1)*2+0.5 : MoveE58 = rnd(0.1)*2+0.5 : MoveE59 = rnd(0.1)*2+0.5 : MoveE60 = rnd(0.1)*2+0.5
    MoveE61 = rnd(0.1)*2+0.5 : MoveE62 = rnd(0.1)*2+0.5 : MoveE63 = rnd(0.1)*2+0.5 : MoveE64 = rnd(0.1)*2+0.5 : MoveE65 = rnd(0.1)*2+0.5 : MoveE66 = rnd(0.1)*2+0.5 : MoveE67 = rnd(0.1)*2+0.5 : MoveE68 = rnd(0.1)*2+0.5 : MoveE69 = rnd(0.1)*2+0.5 : MoveE70 = rnd(0.1)*2+0.5
    MoveE71 = rnd(0.1)*2+0.5 : MoveE72 = rnd(0.1)*2+0.5 : MoveE73 = rnd(0.1)*2+0.5 : MoveE74 = rnd(0.1)*2+0.5 : MoveE75 = rnd(0.1)*2+0.5 : MoveE76 = rnd(0.1)*2+0.5 : MoveE77 = rnd(0.1)*2+0.5 : MoveE78 = rnd(0.1)*2+0.5 : MoveE79 = rnd(0.1)*2+0.5 : MoveE80 = rnd(0.1)*2+0.5
end if
if waveNumber >= 7 then
    Movecata1 = 0.35 : UnitsE = 101
    MoveE1 = rnd(0.1)*2+0.5 : MoveE2 = rnd(0.1)*2+0.5 : MoveE3 = rnd(0.1)*2+0.5 : MoveE4 = rnd(0.1)*2+0.5 : MoveE5 = rnd(0.1)*2+0.5 : MoveE6 = rnd(0.1)*2+0.5 : MoveE7 = rnd(0.1)*2+0.5 : MoveE8 = rnd(0.1)*2+0.5 : MoveE9 = rnd(0.1)*2+0.5 : MoveE10 = rnd(0.1)*2+0.5
    MoveE11 = rnd(0.1)*2+0.5 : MoveE12 = rnd(0.1)*2+0.5 : MoveE13 = rnd(0.1)*2+0.5 : MoveE14 = rnd(0.1)*2+0.5 : MoveE15 = rnd(0.1)*2+0.5 : MoveE16 = rnd(0.1)*2+0.5 : MoveE17 = rnd(0.1)*2+0.5 : MoveE18 = rnd(0.1)*2+0.5 : MoveE19 = rnd(0.1)*2+0.5 : MoveE20 = rnd(0.1)*2+0.5
    MoveE21 = rnd(0.1)*2+0.5 : MoveE22 = rnd(0.1)*2+0.5 : MoveE23 = rnd(0.1)*2+0.5 : MoveE24 = rnd(0.1)*2+0.5 : MoveE25 = rnd(0.1)*2+0.5 : MoveE26 = rnd(0.1)*2+0.5 : MoveE27 = rnd(0.1)*2+0.5 : MoveE28 = rnd(0.1)*2+0.5 : MoveE29 = rnd(0.1)*2+0.5 : MoveE30 = rnd(0.1)*2+0.5
    MoveE31 = rnd(0.1)*2+0.5 : MoveE32 = rnd(0.1)*2+0.5 : MoveE33 = rnd(0.1)*2+0.5 : MoveE34 = rnd(0.1)*2+0.5 : MoveE35 = rnd(0.1)*2+0.5 : MoveE36 = rnd(0.1)*2+0.5 : MoveE37 = rnd(0.1)*2+0.5 : MoveE38 = rnd(0.1)*2+0.5 : MoveE39 = rnd(0.1)*2+0.5 : MoveE40 = rnd(0.1)*2+0.5
    MoveE41 = rnd(0.1)*2+0.5 : MoveE42 = rnd(0.1)*2+0.5 : MoveE43 = rnd(0.1)*2+0.5 : MoveE44 = rnd(0.1)*2+0.5 : MoveE45 = rnd(0.1)*2+0.5 : MoveE46 = rnd(0.1)*2+0.5 : MoveE47 = rnd(0.1)*2+0.5 : MoveE48 = rnd(0.1)*2+0.5 : MoveE49 = rnd(0.1)*2+0.5 : MoveE50 = rnd(0.1)*2+0.5
    MoveE51 = rnd(0.1)*2+0.5 : MoveE52 = rnd(0.1)*2+0.5 : MoveE53 = rnd(0.1)*2+0.5 : MoveE54 = rnd(0.1)*2+0.5 : MoveE55 = rnd(0.1)*2+0.5 : MoveE56 = rnd(0.1)*2+0.5 : MoveE57 = rnd(0.1)*2+0.5 : MoveE58 = rnd(0.1)*2+0.5 : MoveE59 = rnd(0.1)*2+0.5 : MoveE60 = rnd(0.1)*2+0.5
    MoveE61 = rnd(0.1)*2+0.5 : MoveE62 = rnd(0.1)*2+0.5 : MoveE63 = rnd(0.1)*2+0.5 : MoveE64 = rnd(0.1)*2+0.5 : MoveE65 = rnd(0.1)*2+0.5 : MoveE66 = rnd(0.1)*2+0.5 : MoveE67 = rnd(0.1)*2+0.5 : MoveE68 = rnd(0.1)*2+0.5 : MoveE69 = rnd(0.1)*2+0.5 : MoveE70 = rnd(0.1)*2+0.5
    MoveE71 = rnd(0.1)*2+0.5 : MoveE72 = rnd(0.1)*2+0.5 : MoveE73 = rnd(0.1)*2+0.5 : MoveE74 = rnd(0.1)*2+0.5 : MoveE75 = rnd(0.1)*2+0.5 : MoveE76 = rnd(0.1)*2+0.5 : MoveE77 = rnd(0.1)*2+0.5 : MoveE78 = rnd(0.1)*2+0.5 : MoveE79 = rnd(0.1)*2+0.5 : MoveE80 = rnd(0.1)*2+0.5
    MoveE81 = rnd(0.1)*2+0.5 : MoveE82 = rnd(0.1)*2+0.5 : MoveE83 = rnd(0.1)*2+0.5 : MoveE84 = rnd(0.1)*2+0.5 : MoveE85 = rnd(0.1)*2+0.5 : MoveE86 = rnd(0.1)*2+0.5 : MoveE87 = rnd(0.1)*2+0.5 : MoveE88 = rnd(0.1)*2+0.5 : MoveE89 = rnd(0.1)*2+0.5 : MoveE90 = rnd(0.1)*2+0.5
    MoveE91 = rnd(0.1)*2+0.5 : MoveE92 = rnd(0.1)*2+0.5 : MoveE93 = rnd(0.1)*2+0.5 : MoveE94 = rnd(0.1)*2+0.5 : MoveE95 = rnd(0.1)*2+0.5 : MoveE96 = rnd(0.1)*2+0.5 : MoveE97 = rnd(0.1)*2+0.5 : MoveE98 = rnd(0.1)*2+0.5 : MoveE99 = rnd(0.1)*2+0.5 : MoveE100 = rnd(0.1)*2+0.5
end if
UnitsEtotal = UnitsE
UnitsEini = UnitsEini + UnitsE
return

[INInextWave]
timer 0
HPcata1 = int((500*waveNumber)*factor)
HPcataTOTAL1 = HPcata1
ATKcata1 = int((1000*waveNumber)*factor)
DEFcata1 = int((5+waveNumber)*factor)
Ncata = 1
cata1x = 1300 : cata1y = int(rnd(1)*100)+370
cata2x = cata1x : cata2y = cata1y
cata3x = cata1x : cata3y = cata1y

E1x = int(rnd(1)*500)+1300 : E11x = int(rnd(1)*500)+1300 : E12x = int(rnd(1)*500)+1300 : E13x = int(rnd(1)*500)+1300 : E14x = int(rnd(1)*500)+1300 : E15x = int(rnd(1)*500)+1300 : E16x = int(rnd(1)*500)+1300 : E17x = int(rnd(1)*500)+1300 : E18x = int(rnd(1)*500)+1300 : E19x = int(rnd(1)*500)+1300
E110x = int(rnd(1)*500)+1300 : E111x = int(rnd(1)*500)+1300 : E112x = int(rnd(1)*500)+1300 : E113x = int(rnd(1)*500)+1300 : E114x = int(rnd(1)*500)+1300 : E115x = int(rnd(1)*500)+1300 : E116x = int(rnd(1)*500)+1300 : E117x = int(rnd(1)*500)+1300 : E118x = int(rnd(1)*500)+1300 : E119x = int(rnd(1)*500)+1300
E120x = int(rnd(1)*500)+1300 : E121x = int(rnd(1)*500)+1300 : E122x = int(rnd(1)*500)+1300 : E123x = int(rnd(1)*500)+1300 : E124x = int(rnd(1)*500)+1300 : E125x = int(rnd(1)*500)+1300 : E126x = int(rnd(1)*500)+1300 : E127x = int(rnd(1)*500)+1300 : E128x = int(rnd(1)*500)+1300 : E129x = int(rnd(1)*500)+1300
E130x = int(rnd(1)*500)+1300 : E131x = int(rnd(1)*500)+1300 : E132x = int(rnd(1)*500)+1300 : E133x = int(rnd(1)*500)+1300 : E134x = int(rnd(1)*500)+1300 : E135x = int(rnd(1)*500)+1300 : E136x = int(rnd(1)*500)+1300 : E137x = int(rnd(1)*500)+1300 : E138x = int(rnd(1)*500)+1300 : E139x = int(rnd(1)*500)+1300
E140x = int(rnd(1)*500)+1300 : E141x = int(rnd(1)*500)+1300 : E142x = int(rnd(1)*500)+1300 : E143x = int(rnd(1)*500)+1300 : E144x = int(rnd(1)*500)+1300 : E145x = int(rnd(1)*500)+1300 : E146x = int(rnd(1)*500)+1300 : E147x = int(rnd(1)*500)+1300 : E148x = int(rnd(1)*500)+1300 : E149x = int(rnd(1)*500)+1300
E150x = int(rnd(1)*500)+1300 : E151x = int(rnd(1)*500)+1300 : E152x = int(rnd(1)*500)+1300 : E153x = int(rnd(1)*500)+1300 : E154x = int(rnd(1)*500)+1300 : E155x = int(rnd(1)*500)+1300 : E156x = int(rnd(1)*500)+1300 : E157x = int(rnd(1)*500)+1300 : E158x = int(rnd(1)*500)+1300 : E159x = int(rnd(1)*500)+1300
E160x = int(rnd(1)*500)+1300 : E161x = int(rnd(1)*500)+1300 : E162x = int(rnd(1)*500)+1300 : E163x = int(rnd(1)*500)+1300 : E164x = int(rnd(1)*500)+1300 : E165x = int(rnd(1)*500)+1300 : E166x = int(rnd(1)*500)+1300 : E167x = int(rnd(1)*500)+1300 : E168x = int(rnd(1)*500)+1300 : E169x = int(rnd(1)*500)+1300
E170x = int(rnd(1)*500)+1300 : E171x = int(rnd(1)*500)+1300 : E172x = int(rnd(1)*500)+1300 : E173x = int(rnd(1)*500)+1300 : E174x = int(rnd(1)*500)+1300 : E175x = int(rnd(1)*500)+1300 : E176x = int(rnd(1)*500)+1300 : E177x = int(rnd(1)*500)+1300 : E178x = int(rnd(1)*500)+1300 : E179x = int(rnd(1)*500)+1300
E180x = int(rnd(1)*500)+1300 : E181x = int(rnd(1)*500)+1300 : E182x = int(rnd(1)*500)+1300 : E183x = int(rnd(1)*500)+1300 : E184x = int(rnd(1)*500)+1300 : E185x = int(rnd(1)*500)+1300 : E186x = int(rnd(1)*500)+1300 : E187x = int(rnd(1)*500)+1300 : E188x = int(rnd(1)*500)+1300 : E189x = int(rnd(1)*500)+1300
E190x = int(rnd(1)*500)+1300 : E191x = int(rnd(1)*500)+1300 : E192x = int(rnd(1)*500)+1300 : E193x = int(rnd(1)*500)+1300 : E194x = int(rnd(1)*500)+1300 : E195x = int(rnd(1)*500)+1300 : E196x = int(rnd(1)*500)+1300 : E197x = int(rnd(1)*500)+1300 : E198x = int(rnd(1)*500)+1300 : E199x = int(rnd(1)*500)+1300
E1y = int(rnd(1)*350)+345 : E11y = int(rnd(1)*350)+345 : E12y = int(rnd(1)*350)+345 : E13y = int(rnd(1)*350)+345 : E14y = int(rnd(1)*350)+345 : E15y = int(rnd(1)*350)+345 : E16y = int(rnd(1)*350)+345 : E17y = int(rnd(1)*350)+345 : E18y = int(rnd(1)*350)+345 : E19y = int(rnd(1)*350)+345
E110y = int(rnd(1)*350)+345 : E111y = int(rnd(1)*350)+345 : E112y = int(rnd(1)*350)+345 : E113y = int(rnd(1)*350)+345 : E114y = int(rnd(1)*350)+345 : E115y = int(rnd(1)*350)+345 : E116y = int(rnd(1)*350)+345 : E117y = int(rnd(1)*350)+345 : E118y = int(rnd(1)*350)+345 : E119y = int(rnd(1)*350)+345
E120y = int(rnd(1)*350)+345 : E121y = int(rnd(1)*350)+345 : E122y = int(rnd(1)*350)+345 : E123y = int(rnd(1)*350)+345 : E124y = int(rnd(1)*350)+345 : E125y = int(rnd(1)*350)+345 : E126y = int(rnd(1)*350)+345 : E127y = int(rnd(1)*350)+345 : E128y = int(rnd(1)*350)+345 : E129y = int(rnd(1)*350)+345
E130y = int(rnd(1)*350)+345 : E131y = int(rnd(1)*350)+345 : E132y = int(rnd(1)*350)+345 : E133y = int(rnd(1)*350)+345 : E134y = int(rnd(1)*350)+345 : E135y = int(rnd(1)*350)+345 : E136y = int(rnd(1)*350)+345 : E137y = int(rnd(1)*350)+345 : E138y = int(rnd(1)*350)+345 : E139y = int(rnd(1)*350)+345
E140y = int(rnd(1)*350)+345 : E141y = int(rnd(1)*350)+345 : E142y = int(rnd(1)*350)+345 : E143y = int(rnd(1)*350)+345 : E144y = int(rnd(1)*350)+345 : E145y = int(rnd(1)*350)+345 : E146y = int(rnd(1)*350)+345 : E147y = int(rnd(1)*350)+345 : E148y = int(rnd(1)*350)+345 : E149y = int(rnd(1)*350)+345
E150y = int(rnd(1)*350)+345 : E151y = int(rnd(1)*350)+345 : E152y = int(rnd(1)*350)+345 : E153y = int(rnd(1)*350)+345 : E154y = int(rnd(1)*350)+345 : E155y = int(rnd(1)*350)+345 : E156y = int(rnd(1)*350)+345 : E157y = int(rnd(1)*350)+345 : E158y = int(rnd(1)*350)+345 : E159y = int(rnd(1)*350)+345
E160y = int(rnd(1)*350)+345 : E161y = int(rnd(1)*350)+345 : E162y = int(rnd(1)*350)+345 : E163y = int(rnd(1)*350)+345 : E164y = int(rnd(1)*350)+345 : E165y = int(rnd(1)*350)+345 : E166y = int(rnd(1)*350)+345 : E167y = int(rnd(1)*350)+345 : E168y = int(rnd(1)*350)+345 : E169y = int(rnd(1)*350)+345
E170y = int(rnd(1)*350)+345 : E171y = int(rnd(1)*350)+345 : E172y = int(rnd(1)*350)+345 : E173y = int(rnd(1)*350)+345 : E174y = int(rnd(1)*350)+345 : E175y = int(rnd(1)*350)+345 : E176y = int(rnd(1)*350)+345 : E177y = int(rnd(1)*350)+345 : E178y = int(rnd(1)*350)+345 : E179y = int(rnd(1)*350)+345
E180y = int(rnd(1)*350)+345 : E181y = int(rnd(1)*350)+345 : E182y = int(rnd(1)*350)+345 : E183y = int(rnd(1)*350)+345 : E184y = int(rnd(1)*350)+345 : E185y = int(rnd(1)*350)+345 : E186y = int(rnd(1)*350)+345 : E187y = int(rnd(1)*350)+345 : E188y = int(rnd(1)*350)+345 : E189y = int(rnd(1)*350)+345
E190y = int(rnd(1)*350)+345 : E191y = int(rnd(1)*350)+345 : E192y = int(rnd(1)*350)+345 : E193y = int(rnd(1)*350)+345 : E194y = int(rnd(1)*350)+345 : E195y = int(rnd(1)*350)+345 : E196y = int(rnd(1)*350)+345 : E197y = int(rnd(1)*350)+345 : E198y = int(rnd(1)*350)+345 : E199y = int(rnd(1)*350)+345

PvE1 =  int((5 + int(2*waveNumber))*factor) : PvE2 = PvE1 : PvE3 = PvE2 : PvE4 = PvE3 : PvE5 = PvE4 : PvE6 = PvE5 : PvE7 = PvE6 : PvE8 = PvE7 : PvE9 = PvE8 : PvE10 = PvE9
PvE11 = PvE10 : PvE12 = PvE11 : PvE13 = PvE12 : PvE14 = PvE13 : PvE15 = PvE14 : PvE16 = PvE15 : PvE17 = PvE16 : PvE18 = PvE17 : PvE19 = PvE18 : PvE20 = PvE19
PvE21 = PvE20 : PvE22 = PvE21 : PvE23 = PvE22 : PvE24 = PvE23 : PvE25 = PvE24 : PvE26 = PvE25 : PvE27 = PvE26 : PvE28 = PvE27 : PvE29 = PvE28 : PvE30 = PvE29
PvE31 = PvE30 : PvE32 = PvE31 : PvE33 = PvE32 : PvE34 = PvE33 : PvE35 = PvE34 : PvE36 = PvE35 : PvE37 = PvE36 : PvE38 = PvE37 : PvE39 = PvE38 : PvE40 = PvE39
PvE41 = PvE40 : PvE42 = PvE41 : PvE43 = PvE42 : PvE44 = PvE43 : PvE45 = PvE44 : PvE46 = PvE45 : PvE47 = PvE46 : PvE48 = PvE47 : PvE49 = PvE48 : PvE50 = PvE49
PvE51 = PvE50 : PvE52 = PvE51 : PvE53 = PvE52 : PvE54 = PvE53 : PvE55 = PvE54 : PvE56 = PvE55 : PvE57 = PvE56 : PvE58 = PvE57 : PvE59 = PvE58 : PvE60 = PvE59
PvE61 = PvE60 : PvE62 = PvE61 : PvE63 = PvE62 : PvE64 = PvE63 : PvE65 = PvE64 : PvE66 = PvE65 : PvE67 = PvE66 : PvE68 = PvE67 : PvE69 = PvE68 : PvE70 = PvE69
PvE71 = PvE70 : PvE72 = PvE71 : PvE73 = PvE72 : PvE74 = PvE73 : PvE75 = PvE74 : PvE76 = PvE75 : PvE77 = PvE76 : PvE78 = PvE77 : PvE79 = PvE78 : PvE80 = PvE79
PvE81 = PvE80 : PvE82 = PvE81 : PvE83 = PvE82 : PvE84 = PvE83 : PvE85 = PvE84 : PvE86 = PvE85 : PvE87 = PvE86 : PvE88 = PvE87 : PvE89 = PvE88 : PvE90 = PvE89
PvE91 = PvE90 : PvE92 = PvE91 : PvE93 = PvE92 : PvE94 = PvE93 : PvE95 = PvE94 : PvE96 = PvE95 : PvE97 = PvE96 : PvE98 = PvE97 : PvE99 = PvE98 : PvE100 = PvE99

securPoint1 = 0 : securPoint2 = 0 : securPoint3 = 0 : securPoint4 = 0 : securPoint5 = 0 : securPoint6 = 0 : securPoint7 = 0 : securPoint8 = 0 : securPoint9 = 0 : securPoint10 = 0
securPoint11 = 0 : securPoint12 = 0 : securPoint13 = 0 : securPoint14 = 0 : securPoint15 = 0 : securPoint16 = 0 : securPoint17 = 0 : securPoint18 = 0 : securPoint19 = 0 : securPoint20 = 0
securPoint21 = 0 : securPoint22 = 0 : securPoint23 = 0 : securPoint24 = 0 : securPoint25 = 0 : securPoint26 = 0 : securPoint27 = 0 : securPoint28 = 0 : securPoint29 = 0 : securPoint30 = 0
securPoint31 = 0 : securPoint32 = 0 : securPoint33 = 0 : securPoint34 = 0 : securPoint35 = 0 : securPoint36 = 0 : securPoint37 = 0 : securPoint38 = 0 : securPoint39 = 0 : securPoint40 = 0
securPoint41 = 0 : securPoint42 = 0 : securPoint43 = 0 : securPoint44 = 0 : securPoint45 = 0 : securPoint46 = 0 : securPoint47 = 0 : securPoint48 = 0 : securPoint49 = 0 : securPoint50 = 0
securPoint51 = 0 : securPoint52 = 0 : securPoint53 = 0 : securPoint54 = 0 : securPoint55 = 0 : securPoint56 = 0 : securPoint57 = 0 : securPoint58 = 0 : securPoint59 = 0 : securPoint60 = 0
securPoint61 = 0 : securPoint62 = 0 : securPoint63 = 0 : securPoint64 = 0 : securPoint65 = 0 : securPoint66 = 0 : securPoint67 = 0 : securPoint68 = 0 : securPoint69 = 0 : securPoint70 = 0
securPoint71 = 0 : securPoint72 = 0 : securPoint73 = 0 : securPoint74 = 0 : securPoint75 = 0 : securPoint76 = 0 : securPoint77 = 0 : securPoint78 = 0 : securPoint79 = 0 : securPoint80 = 0
securPoint81 = 0 : securPoint82 = 0 : securPoint83 = 0 : securPoint84 = 0 : securPoint85 = 0 : securPoint86 = 0 : securPoint87 = 0 : securPoint88 = 0 : securPoint89 = 0 : securPoint90 = 0
securPoint91 = 0 : securPoint92 = 0 : securPoint93 = 0 : securPoint94 = 0 : securPoint95 = 0 : securPoint96 = 0 : securPoint97 = 0 : securPoint98 = 0 : securPoint99 = 0 : securPoint100 = 0

securPointcata1 = 0 : ACTIONbullet = 0
atkE = int((8 + waveNumber*5)*factor) : defE = int((1 + waveNumber)*factor)
waveNumber = waveNumber + 1
gosub [waveMooveControle]
close #main
goto [Game]

[repair2]
timer 0
if Gold < int(waveNumber*100) and version = 1 then notice " " + chr$(13) + "Vous n'avez pas asser d'or pour vous soigner. (";int(waveNumber*100);")" : wait
if Gold < int(waveNumber*100) and version = 2 then notice " " + chr$(13) + "You dont have enought gold. (";int(waveNumber*100);")" : wait
if Gold >= int(waveNumber*100) and version = 1 and castlePVtotal >0 and HEROpv > 0  and HEROpv < HEROpvTOTAL then Gold = Gold - int(waveNumber*100) : HEROpv = HEROpvTOTAL : notice " " + chr$(13) + "Soins effectués"
if Gold >= int(waveNumber*100) and version = 2 and castlePVtotal >0 and HEROpv > 0  and HEROpv < HEROpvTOTAL then Gold = Gold - int(waveNumber*100) : HEROpv = HEROpvTOTAL : notice " " + chr$(13) + "Full heal"
timer 10, [Eq]
wait
[repair]
timer 0
if Gold < int(waveNumber*200) and version = 1 then notice " " + chr$(13) + "Vous n'avez pas asser d'or pour réparer vos fortifications. (";int(waveNumber*200);")"  : wait
if Gold < int(waveNumber*200) and version = 2 then notice " " + chr$(13) + "You dont have enought gold for repair castle. (";int(waveNumber*200);")"  : wait
if Gold >= int(waveNumber*200) and version = 1 and castlePVtotal >0 and HEROpv > 0  and castlePV < castlePVtotal then Gold = Gold - int(waveNumber*200) : castlePV = castlePVtotal : notice " " + chr$(13) + "Réparations effectuées"
if Gold >= int(waveNumber*200) and version = 2 and castlePVtotal >0 and HEROpv > 0  and castlePV < castlePVtotal then Gold = Gold - int(waveNumber*200) : castlePV = castlePVtotal : notice " " + chr$(13) + "Castle repair"
timer 10, [Eq]
wait

[upgradeCASTLE]
timer 0
if upgradeCASTLE = 1 then close #upgradeCASTLE
upgradeCASTLE = 1
WindowWidth=450 : WindowHeight=330
UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)


CoutUPcastleREGEN =  int(castleREGEN*10)
CoutUPcastleHP = int((castlePVtotal/10)*2)
CoutUPcastleARMOR =  int(castleArmor*20*castleArmor)

groupbox #upgradeCASTLE.1, "",  10, 10, 420, 80
groupbox #upgradeCASTLE.1, "",  10, 85, 420, 80
groupbox #upgradeCASTLE.1, "",  10, 160, 420, 80

if version = 1 then
    statictext #upgradeCASTLE.txtA, "Augmenter la solidité (";castlePVtotal;") de vos fortifications avec de nouveaux matériaux afin de tenir plus longtemps face aux dégâts de vos ennemis." , 20, 25, 400, 30
    statictext #upgradeCASTLE.txtC, "Pour ";CoutUPcastleHP;" d'or" , 130, 62, 150, 15
    button #upgradeCASTLE.santé, "AMELIORER" , [UPcastleHP], UL, 20, 60,100,22
    statictext #upgradeCASTLE.txtE, "Améliore la défense (";castleArmor;") de vos fortification en augmentant la taille et l'épaisseur des murs afin de réduire les dégâts reçus ." , 20, 100, 400, 30
    statictext #upgradeCASTLE.txtG, "Pour ";CoutUPcastleARMOR;" d'or", 130, 137, 150, 15
    button #upgradeCASTLE.armure, "AMELIORER" , [UPcastleARMOR], UL, 20, 135,100,22
    statictext #upgradeCASTLE.txtI, "Accélère les réparations (";castleREGEN;") des fortifications en ajoutant des ouvrier prêt a travaillés afin de réparer les dommages causés par l'ennemi." , 20, 175, 400, 30
    statictext #upgradeCASTLE.txtK, "Pour ";CoutUPcastleREGEN;" d'or." , 130, 213, 150, 15
    button #upgradeCASTLE.regen, "AMELIORER" , [UPcastleREGEN], UL, 20, 210,100,22
    statictext #upgradeCASTLE.txtGOLD, "VOTRE OR : "; Gold;" ", 135, 255, 200, 30
end if
if version = 2 then
    statictext #upgradeCASTLE.txtA, "Increase the strength (";castlePVtotal;") of your fortifications to take longer against the damage of your enemies." , 20, 25, 400, 30
    statictext #upgradeCASTLE.txtC, "For ";CoutUPcastleHP;" gold" , 130, 62, 150, 15
    button #upgradeCASTLE.santé, "UPGRADE" , [UPcastleHP], UL, 20, 60,100,22
    statictext #upgradeCASTLE.txtE, "Improves the armor (";castleArmor;")  of your fortification to reduce the damage received." , 20, 100, 400, 30
    statictext #upgradeCASTLE.txtG, "For ";CoutUPcastleARMOR;" gold", 130, 137, 150, 15
    button #upgradeCASTLE.armure, "UPGRADE" , [UPcastleARMOR], UL, 20, 135,100,22
    statictext #upgradeCASTLE.txtI, "Accelerate the repairs (";castleREGEN;") of the fortifications to restore strength." , 20, 175, 400, 30
    statictext #upgradeCASTLE.txtK, "For ";CoutUPcastleREGEN;" gold." , 130, 213, 150, 15
    button #upgradeCASTLE.regen, "UPGRADE" , [UPcastleREGEN], UL, 20, 210,100,22
    statictext #upgradeCASTLE.txtGOLD, "YOUR GOLD : "; Gold;" ", 130, 255, 200, 30
end if

if version = 1 then open "Amélioration des fortifications" for window_nf as #upgradeCASTLE
if version = 2 then open "Castle upgrade menu" for window_nf as #upgradeCASTLE
#upgradeCASTLE, "trapclose [quitUPcastle]"
#upgradeCASTLE, "font Times New Roman 9"
#upgradeCASTLE.txtGOLD, "!font Times New Roman 14 bold"
wait

[quitUPcastle]
close #upgradeCASTLE : upgradeCASTLE = 0 : timer 10, [Eq] : wait

[upgradeHERO]
timer 0
if upgradeHERO = 1 then close #upgradeHERO
upgradeHERO = 1
WindowWidth=450 : WindowHeight=410 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)
CoutUPheroHP = int(lvlHPhero*100) : CoutUPheroARMOR = int(lvlARMORhero*50)
CoutUPheroDAMAGE = int(lvlATKhero*50) : CoutUPheroREGEN = int(lvlREGENhero*20)

groupbox #upgradeHERO.1, "",  10, 10, 420, 80
groupbox #upgradeHERO.2, "",  10, 85, 420, 80
groupbox #upgradeHERO.3, "",  10, 160, 420, 80
groupbox #upgradeHERO.4, "",  10, 235, 420, 80

if version = 1 then
    statictext #upgradeHERO.txtA, "Augmente les points de vie ( ";HEROpvTOTAL;" ) définitivement de votre personnage pour que vous puissiez survivre aux attaques ennemis lors des combats." , 20, 25, 400, 35
    statictext #upgradeHERO.txtD, "Pour : ";CoutUPheroHP , 130, 62, 150, 15
    button #upgradeHERO.santé, "AMELIORER" , [UPheroHP], UL, 20, 60,100,22
    statictext #upgradeHERO.txtE, "Améliore la défense ( ";HEROdef;" ) définitivement de votre personnage pour diminuer les dégâts reçus par les ennemis sur le champ de bataille." , 20, 100, 400, 35
    statictext #upgradeHERO.txtH, "Pour : ";CoutUPheroARMOR , 130, 137, 150, 15
    button #upgradeHERO.armure, "AMELIORER" , [UPheroARMOR], UL, 20, 135,100,22
    statictext #upgradeHERO.txtJ, "Accélère la régénération ( ";regen;" ) définitivement de votre personnage pour regagner vos points de vie sur le champ de bataille." , 20, 175, 400, 35
    statictext #upgradeHERO.txtL, "Pour : ";CoutUPheroREGEN , 130, 212, 150, 15
    button #upgradeHERO.regen, "AMELIORER" , [UPheroREGEN], UL, 20, 210,100,22
    statictext #upgradeHERO.txtN, "Augmente l'attaque ( "; HEROatk ; " ) définitivement de votre personnage pour infliger d'avantage de dégâts aux ennemis sur le champs de bataille." , 20, 250, 400, 35
    statictext #upgradeHERO.txtP, "Pour : ";CoutUPheroDAMAGE , 130, 287, 150, 15
    button #upgradeHERO.attaque, "AMELIORER" , [UPheroATK], UL, 20, 285,100,22
    statictext #upgradeHERO.txtGOLD, "VOTRE OR : "; Gold;" ", 135, 330, 200, 30
end if
if version = 2 then
    statictext #upgradeHERO.txtA, "Up your character's life points ( ";HEROpvTOTAL;" ) definitly for help you in the battlefield." , 20, 25, 400, 35
    statictext #upgradeHERO.txtD, "For : ";CoutUPheroHP , 130, 62, 150, 15
    button #upgradeHERO.santé, "UPGRADE" , [UPheroHP], UL, 20, 60,100,22
    statictext #upgradeHERO.txtE, "Up your character's armor ( ";HEROdef;" ) definitly to decrease the damage received by enemies on the battlefield." , 20, 100, 400, 35
    statictext #upgradeHERO.txtH, "For : ";CoutUPheroARMOR , 130, 137, 150, 15
    button #upgradeHERO.armure, "UPGRADE" , [UPheroARMOR], UL, 20, 135,100,22
    statictext #upgradeHERO.txtJ, "Accelerate the regeneration ( ";regen;" ) permanently of your character to regain your hit points on the battlefield." , 20, 175, 400, 35
    statictext #upgradeHERO.txtL, "For : ";CoutUPheroREGEN , 130, 212, 150, 15
    button #upgradeHERO.regen, "UPGRADE" , [UPheroREGEN], UL, 20, 210,100,22
    statictext #upgradeHERO.txtN, "Increases the attack ( "; HEROatk;" ) permanently on your character to deal more damage to enemies on the battlefield." , 20, 250, 400, 35
    statictext #upgradeHERO.txtP, "For : ";CoutUPheroDAMAGE , 130, 287, 150, 15
    button #upgradeHERO.attaque, "UPGRADE" , [UPheroATK], UL, 20, 285,100,22
    statictext #upgradeHERO.txtGOLD, "YOUR GOLD : "; Gold;" ", 135, 330, 200, 30
end if

if version = 1 then open "Amélioration des caractéristiques du héro" for window_nf as #upgradeHERO
if version = 2 then open "Character upgrade menu" for window_nf as #upgradeHERO
#upgradeHERO, "trapclose [quitUPhero]"
#upgradeHERO, "font Times New Roman 9"
#upgradeHERO.txtGOLD, "!font Times New Roman 14 bold"
wait

[quitUPhero]
close #upgradeHERO : upgradeHERO = 0 : timer 10, [Eq] : wait

[UPheroHP]
CoutUPheroHP = int(lvlHPhero*100)
if Gold < CoutUPheroHP then
    if version = 1 then notice " " + chr$(13) + "Vous n'avez pas assez pour cette amélioration : Vous possédez ";Gold;" alors que le coût d'amélioration est de ";CoutUPheroHP;" ."
    if version = 2 then notice " " + chr$(13) + "You havent any money for this upgrade: You have ";Gold;" and the upgrade cost is to ";CoutUPheroHP;" ."
    wait
end if
Gold = Gold - CoutUPheroHP : HEROpv = HEROpv + int((HEROpvTOTAL/100)*20) : lvlHPhero = lvlHPhero + 1 : HEROpvTOTAL = HEROpvTOTAL + int((HEROpvTOTAL/100)*20) : CoutUPheroHP = int(lvlHPhero*100)
gosub [txtREFRESH]
if version = 1 then
    print #upgradeHERO.txtA, "Augmente les points de vie ( ";HEROpvTOTAL;" ) définitivement de votre personnage pour que vous puissiez survivre aux attaques ennemis lors des combats."
    print #upgradeHERO.txtD, "Pour : ";CoutUPheroHP
    print #upgradeHERO.txtGOLD, "VOTRE OR : "; Gold;"      "
end if
if version = 2 then
    print #upgradeHERO.txtA, "Up your character's life points ( ";HEROpvTOTAL;" ) definitly for help you in the battlefield."
    print #upgradeHERO.txtD, "For : ";CoutUPheroHP
    print #upgradeHERO.txtGOLD, "YOUR GOLD : "; Gold;"       "
end if
wait

[UPheroARMOR]
CoutUPheroARMOR = int(lvlARMORhero*50)
if Gold < CoutUPheroARMOR then
    if version = 1 then notice " " + chr$(13) + "Vous n'avez pas assez pour cette amélioration : Vous possédez ";Gold;" alors que le coût d'amélioration est de ";CoutUPheroARMOR;" ."
    if version = 2 then notice " " + chr$(13) + "You havent any money for this upgrade: You have ";Gold;" and the upgrade cost is to ";CoutUPheroARMOR;" ."
    wait
end if
Gold = Gold - CoutUPheroARMOR
HEROdef = HEROdef + 1
lvlARMORhero = lvlARMORhero + 1
CoutUPheroARMOR = int(lvlARMORhero*50)
gosub [txtREFRESH]
if version = 1 then
    print #upgradeHERO.txtE, "Améliore la défense ( ";HEROdef;" ) définitivement de votre personnage pour diminuer les dégâts reçus par les ennemis sur le champ de bataille."
    print #upgradeHERO.txtH, "Pour : ";CoutUPheroARMOR
    print #upgradeHERO.txtGOLD, "VOTRE OR : "; Gold;"        "
end if
if version = 2 then
    print #upgradeHERO.txtE, "Up your character's armor ( ";HEROdef;" ) definitly to decrease the damage received by enemies on the battlefield."
    print #upgradeHERO.txtH, "For : ";CoutUPheroARMOR
    print #upgradeHERO.txtGOLD, "YOUR GOLD : "; Gold;"        "
end if
wait

[UPheroATK]
CoutUPheroDAMAGE = int(lvlATKhero*50)
if Gold < CoutUPheroDAMAGE then
    if version = 1 then notice " " + chr$(13) + "Vous n'avez pas assez pour cette amélioration : Vous possédez ";Gold;" alors que le coût d'amélioration est de ";CoutUPheroDAMAGE;" ."
    if version = 2 then notice " " + chr$(13) + "You havent any money for this upgrade: You have ";Gold;" and the upgrade cost is to ";CoutUPheroDAMAGE;" ."
    wait
end if
Gold = Gold - CoutUPheroDAMAGE
HEROatk = HEROatk + 1
lvlATKhero = lvlATKhero + 1
CoutUPheroDAMAGE = int(lvlATKhero*50)
gosub [txtREFRESH]
if version = 1 then
    print #upgradeHERO.txtN, "Augmente l'attaque ( "; HEROatk ; " ) définitivement de votre personnage pour infliger d'avantage de dégâts aux ennemis sur le champs de bataille."
    print #upgradeHERO.txtP, "Pour : ";CoutUPheroDAMAGE
    print #upgradeHERO.txtGOLD, "VOTRE OR : "; Gold;"        "
end if
if version = 2 then
    print #upgradeHERO.txtN, "Increases the attack ( "; HEROatk;" ) permanently on your character to deal more damage to enemies on the battlefield."
    print #upgradeHERO.txtP, "For : ";CoutUPheroDAMAGE
    print #upgradeHERO.txtGOLD, "YOUR GOLD : "; Gold;"        "
end if
wait

[UPheroREGEN]
CoutUPheroREGEN = int(lvlREGENhero*20)
if Gold < CoutUPheroREGEN then
    if version = 1 then notice " " + chr$(13) + "Vous n'avez pas assez pour cette amélioration : Vous possédez ";Gold;" alors que le coût d'amélioration est de ";CoutUPheroREGEN;" ."
    if version = 2 then notice " " + chr$(13) + "You havent any money for this upgrade: You have ";Gold;" and the upgrade cost is to ";CoutUPheroREGEN;" ."
    wait
end if
Gold = Gold - CoutUPheroREGEN
regen = regen + 1
lvlREGENhero = lvlREGENhero + 1
CoutUPheroREGEN = int(lvlREGENhero*20)
gosub [txtREFRESH]
if version = 1 then
    print #upgradeHERO.txtJ, "Accélère la régénération ( ";regen;" ) définitivement de votre personnage pour regagner vos points de vie sur le champ de bataille."
    print #upgradeHERO.txtL, "Pour : ";CoutUPheroREGEN
    print #upgradeHERO.txtGOLD, "VOTRE OR : "; Gold;"        "
end if
if version = 2 then
    print #upgradeHERO.txtJ, "Accelerate the regeneration ( ";regen;" ) permanently of your character to regain your hit points on the battlefield."
    print #upgradeHERO.txtL, "For : ";CoutUPheroREGEN
    print #upgradeHERO.txtGOLD, "YOUR GOLD : "; Gold;"        "
end if
wait

[UPcastleHP]
CoutUPcastleHP = int((castlePVtotal/10)*2)
if Gold < CoutUPcastleHP then
    if version = 1 then notice " " + chr$(13) + "Vous n'avez pas assez pour cette amélioration : Vous possédez ";Gold;" alors que le coût d'amélioration est de ";CoutUPcastleHP;" ."
    if version = 2 then notice " " + chr$(13) + "You havent any money for this upgrade: You have ";Gold;" and the upgrade cost is to ";CoutUPcastleHP;" ."
    wait
end if
Gold = Gold - CoutUPcastleHP
castlePV = castlePV + int((castlePVtotal/100)*20)
castlePVtotal = castlePVtotal + int((castlePVtotal/100)*20)
CoutUPcastleHP = int((castlePVtotal/10)*2)
if version = 1 then
    print #upgradeCASTLE.txtA, "Augmenter la solidité (";castlePVtotal;") de vos fortifications avec de nouveaux matériaux afin de tenir plus longtemps face aux dégâts de vos ennemis."
    print #upgradeCASTLE.txtC, "Pour ";CoutUPcastleHP;" d'or"
    print #upgradeCASTLE.txtGOLD, "VOTRE OR : "; Gold;"       "
end if
if version = 2 then
    print #upgradeCASTLE.txtA, "Increase the strength (";castlePVtotal;") of your fortifications to take longer against the damage of your enemies."
    print #upgradeCASTLE.txtC, "For ";CoutUPcastleHP;" gold"
    print #upgradeCASTLE.txtGOLD, "YOUR GOLD : "; Gold;"       "
end if
gosub [txtREFRESH]
wait

[UPcastleARMOR]
CoutUPcastleARMOR =  int(castleArmor*20*castleArmor)
if Gold < CoutUPcastleARMOR then
    if version = 1 then notice " " + chr$(13) + "Vous n'avez pas assez pour cette amélioration : Vous possédez ";Gold;" alors que le coût d'amélioration est de ";CoutUPcastleARMOR;" ."
    if version = 2 then notice " " + chr$(13) + "You havent any money for this upgrade: You have ";Gold;" and the upgrade cost is to ";CoutUPcastleARMOR;" ."
    wait
end if
Gold = Gold - CoutUPcastleARMOR
castleArmor = castleArmor + int(castleArmor/2)
CoutUPcastleARMOR =  int(castleArmor*20*castleArmor)
if version = 1 then
    print #upgradeCASTLE.txtE, "Améliore la défense (";castleArmor;") de vos fortification en augmentant la taille et l'épaisseur des murs afin de réduire les dégâts reçus ."
    print #upgradeCASTLE.txtG, "Pour ";CoutUPcastleARMOR;" d'or"
    print #upgradeCASTLE.txtGOLD, "VOTRE OR : "; Gold;"       "
end if
if version = 2 then
    print #upgradeCASTLE.txtE, "Improves the armor (";castleArmor;")  of your fortification to reduce the damage received."
    print #upgradeCASTLE.txtG, "For ";CoutUPcastleARMOR;" gold"
    print #upgradeCASTLE.txtGOLD, "YOUR GOLD : "; Gold;"       "
end if
gosub [txtREFRESH]
wait

[UPcastleREGEN]
CoutUPcastleREGEN =  int(castleREGEN*10)
if Gold < CoutUPcastleREGEN then
    if version = 1 then notice " " + chr$(13) + "Vous n'avez pas assez pour cette amélioration : Vous possédez ";Gold;" alors que le coût d'amélioration est de ";CoutUPcastleREGEN;" ."
    if version = 2 then notice " " + chr$(13) + "You havent any money for this upgrade: You have ";Gold;" and the upgrade cost is to ";CoutUPcastleREGEN;" ."
    wait
end if
Gold = Gold - CoutUPcastleREGEN
castleREGEN = castleREGEN + 1
CoutUPcastleREGEN = int(castleREGEN*10)
gosub [txtREFRESH]
if version = 1 then
    print #upgradeCASTLE.txtI, "Accélère les réparations (";castleREGEN;") des fortifications en ajoutant des ouvrier prêt a travaillés afin de réparer les dommages causés par l'ennemi."
    print #upgradeCASTLE.txtK, "Pour ";CoutUPcastleREGEN;" d'or."
    print #upgradeCASTLE.txtGOLD, "VOTRE OR : "; Gold;"       "
end if
if version = 2 then
    print #upgradeCASTLE.txtI, "Accelerate the repairs (";castleREGEN;") of the fortifications to restore strength."
    print #upgradeCASTLE.txtK, "For ";CoutUPcastleREGEN;" gold."
    print #upgradeCASTLE.txtGOLD, "YOUR GOLD : "; Gold;"       "
end if
wait

[quitHELP]
close #ini : help = 0 : timer 10, [Eq] : wait
[quitSetting]
close #setting : Setting = 0 : wait
[quitMenu]
close #menuGame : menuGame = 0 : #main.map, "down;drawsprites" : timer 10, [Eq] : wait

[quit]
timer 0
if menuGame = 1 then close #menuGame
if infoGame = 1 then close #info
if upgradeCASTLE = 1 then close #upgradeCASTLE
if upgradeHERO = 1 then close #upgradeHERO
if upgrades = 1 then close #upgrades
if Setting = 1 then close #setting
if help = 1 then close #ini
if main = 1 then close #main
if main = 0 then close #debut
if about = 1 then close #about
if pant = 1 then close #pant
gosub [stopMusic2]
end

[iniMUSIC]
MusicSELECT = 0 : gosub [stopMusic2] : wait
[iniMUSIC2]
MusicSELECT = 1 : gosub [startMusic] : wait

    [MusicSELECT]
    if MusicSELECT = 1 then MusicSELECT = 0 : gosub [stopMusic2] : wait
    MusicSELECT = 1
    gosub [startMusic] : wait
    [stopMusic]
    MusicSELECT = 0 : gosub [stopMusic2] : wait

    [startMusic]
    mus$ = "data\music\main.mp3"
    ext$ = upper$(right$(mus$,3))
    mp3$ = "open "+mus$+" type MpegVideo alias fictoplay"
    if ext$ = "MID" then a$ = mid$ else a$ = mp3$
    calldll #winmm,"mciSendStringA",a$ as ptr,_
        i1 as ulong,_
        i2 as long,_
        i3 as long,_
        r as long
    a$="play fictoplay"
    calldll #winmm,"mciSendStringA",_
        a$ as ptr,_
        i1 as ulong,_
        i2 as long,_
        i3 as long,_
        r as long
    return

    [stopMusic2]
    a$="close fictoplay"
    calldll #winmm,"mciSendStringA",_
        a$ as ptr,_
        i1 as ulong,_
        i2 as long,_
        i3 as long,_
        r as long
    return

    function fileExist(dir$,file$)
        dim info$(10, 10)
        files dir$,file$, info$(
        if val(info$(0, 0)) > 0 then
            fileExist = 1
        else
            fileExist = 0
        end if
    end function
