I honestly can't help because I have no idea where your gotos are leading and I can't see because of no indentation. But heres some battle system code I made a long time ago. See if you can learn anything or if it can help.
Joined: Thu Jul 15th 2010
Location: Cyberspace
Posted: 5th Aug 2010 14:03 Edited: 5th Aug 2010 16:38 | link | toggle
If we do a Text Adventure you can use the text battle system I made:
+ Code Snippet
Rem Project: Text Game
Rem Created: 7/16/2010 12:37:38 AM
Rem ***** Main Source File *****
Global Potion as Integer
sw = screen width()
set text font "Ariel"
set text size 15
fighting: ` make the main program first
Potion = 1
EnStr$ = "Your enemy's health is "
Attack$ = ""
EAttack$ = ""
Ehealth# = rnd(200)+350
Gosub Weapons
Gosub Enemy
Gosub Armor
Do
Done = 0
CLS
Box 10,340,200,440, rgb(255,0,0), rgb(255,0,0), rgb(255,0,0), rgb(255,0,0)
Box 600,320,790,400, rgb(0,255,0), rgb(0,255,0), rgb(0,255,0), rgb(0,255,0)
Box 10,50,50,200
Box 10,10,Yhealth/2, 20, rgb(255,0,0), rgb(255,0,0), rgb (0,255,0), rgb(0,255,0)
Box Yhealth/2, 10 , 210, 20, rgb(0,0,0), rgb(0,0,0), rgb(0,0,0), rgb(0,0,0)
box sw - Ehealth#/2,10,sw-10,20, rgb(255,0,0), rgb(255,0,0), rgb(0,255,0), rgb(0,255,0)
box sw-Ehealth#/2,10,sw-Ehealth#/2,20, rgb(0,0,0), rgb(0,0,0), rgb(0,0,0), rgb(0,0,0)
EDefence = 0
Block = 0 ` so there arent lots of these words below clogging up memory and space
Center Text 320, 290,"The Enemy is "+Enemy$
Center Text 320, 270,"You are equiped with a "+Weapon$
Center Text 320, 250,"Your armor set is "+Armor$
Center Text 320, 230,EnStr$ + str$(Ehealth#)
Center Text 320, 210,"Your health is "+str$(Yhealth)
Center Text 320, 190,Attack$
Center Text 320, 170,EAttack$
Center Text 320, 150,"Click red button to do a charge and attack.Press Green button to do a block with your shield and then shield slam."
If Potion = 1
Center Text 320, 130,"Click white button to drink a Health Potion"
endif
Gosub GUI
loop
Weapons:
WeaponSR = rnd(5)+1 ` randomize for the results
DIM Weapons#(6) ` make an array(IDK why?)
If WeaponSR = 1 `makin the weapons
Weapon$ ="Axe"
ENdif
If WeaponSR = 2
Weapon$= "Gladius"
Endif
If WeaponSR = 3
Weapon$= "Spear"
Endif
If WeaponSR = 4
Weapon$= "Inflatable Duck"
Endif
If WeaponSR = 5
Weapon$= "Shoop Da WHOOP"
Endif
If WeaponSR = 6
Weapon$= "Chainsaw"
Endif
Return
Enemy:
EnemySR = rnd(5)+1
DIM Enemys#(6)
If EnemySR = 1
Enemy$ = "a Orc"
Endif
If EnemySR = 2
Enemy$ = "a Fire-Drake"
Endif
If EnemySR = 3
Enemy$ = "an Enemy Trooper"
Endif
If EnemySR = 4
Enemy$ = "Barack Obama"
Endif
If EnemySR = 5
Enemy$ = "ChangBiao Luo"
Endif
If EnemySR = 6
Enemy$ = "Paul The Octopus"
Endif
Return
Armor:
ArmorSR = rnd(5)+1
DIM Armor#(6)
If ArmorSR = 1
Armor$ = "Mithril Ring-Mail Armor"
Endif
If ArmorSR = 2
Armor$ = "Mithril Plate Armor"
Endif
If ArmorSR = 3
Armor$ = "Titanium Plate Armor"
Endif
If ArmorSR = 4
Armor$ = "Titanium Ring-Mail Armor"
Endif
If ArmorSR = 5
Armor$ = "Steel Ring-Mail Armor"
Endif
If ArmorSR = 6
Armor$ = "Steel Plate Armor"
Endif
gosub YourHealth
Return
Charge:
if WeaponSR = 1
Hitpos = rnd(5)
if Hitpos = 0
Attack$ = "You swing your axe but miss."
else
YDamage# = rnd(89)+35
If EDefence = 1
YDamage# = YDamage#/10
endif
Attack$ = "You swing your axe and hit him for "+str$(YDamage#)+" damage."
Ehealth# = Ehealth# - YDamage#
Endif
Endif
if WeaponSR = 2
Hitpos = rnd(6)
if Hitpos = 0
Attack$ = "You slash your gladius but miss."
else
YDamage# = rnd(80)+25
If EDefence = 1
YDamage# = YDamage#/10
endif
Attack$ = "You slash your Gladius and hit him for "+str$(YDamage#)+" damage."
Ehealth# = Ehealth# - YDamage#
Endif
endif
if WeaponSR = 3
Hitpos = rnd(9)
if Hitpos = 0
Attack$ = "You jab your spear but miss."
else
YDamage# = rnd(60)+20
If EDefence = 1
YDamage# = YDamage#/10
endif
Attack$ = "You jab your spear and hit him for "+str$(YDamage#)+" damage."
Ehealth# = Ehealth# - YDamage#
Endif
endif
if WeaponSR = 4
Hitpos = rnd(15)
if Hitpos = 0
Attack$ = "You throw your Inflatable Duck but miss."
else
YDamage# = rnd(70)+10
If EDefence = 1
YDamage# = YDamage#/10
endif
Attack$ = "You throw your Inflatable Duck and hit him for "+str$(YDamage#)+" damage."
Ehealth# = Ehealth# - YDamage#
endif
endif
if WeaponSR = 5
Hitpos = rnd(1)
if Hitpos = 0
Attack$ = "You shoot your Shoop Da WHOOP but miss."
else
YDamage#=rnd(250)+60
If EDefence = 1
YDamage# = YDamage#/10
endif
Attack$ = "You shoot your Shoop DA WHOOP and hit him for "+str$(YDamage#)+" damage."
Ehealth# = Ehealth# - YDamage#
endif
endif
if WeaponSR = 6
Hitpos = rnd(13)
if Hitpos = 0
Attack$ = "You revup your chainsaw but miss."
else
YDamage#=rnd(40)+15
If EDefence = 1
YDamage# = YDamage#/10
endif
Attack$ = "You rev up your chainsaw and hit him for "+str$(YDamage#)+" damage."
Ehealth# = Ehealth# - YDamage#
endif
endif
if Ehealth#<1
do
cls
Print " You OWNED that scrub! Play again(Y/N)?"
If keystate(21)=1
goto fighting
endif
If keystate(49)=1
end
endif
loop
endif
Done = 1
return
YourHealth:
If ArmorSR = 1
Yhealth = 500
endif
If ArmorSR = 2
Yhealth = 550
endif
If ArmorSR = 3
Yhealth = 450
endif
If ArmorSR = 4
Yhealth = 400
endif
If ArmorSR = 5
Yhealth = 300
endif
If ArmorSR = 6
Yhealth = 350
endif
return
Shield:
ShieldHap = rnd(4)
if ShieldHap = 0
Block = 0
Attack$ = "Your block didnt work"
else
SAttack = rnd(5)+1
Block = 1
Ehealth# = Ehealth# - SAttack
Attack$ = "The Shield slam was a sucess"
endif
if Ehealth#<1
do
cls
Print " You OWNED that scrub! Play again(Y/N)?"
If keystate(21)=1
goto fighting
endif
If keystate(49)=1
end
endif
loop
endif
Done = 1
Return
EAttack:
if EnemySR = 1
Ehitpos = rnd(5)
If Ehitpos = 0
EAttack$ = "The Orc slashed his sword but missed."
else
EDamage = rnd(60)+20
if Block = 1
EDamage = EDamage/10
Endif
EAttack$ = "The Orc hit you with his sword for "+str$(EDamage)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 2
Ehitpos = rnd(5)
If Ehitpos = 0
EAttack$ = "The Fire-Drake blocked"
Def = 1
else
EDamage = rnd(80)+30
if Block = 1
EDamage = EDamage/10
Endif
EAttack$ = "The Fire-Drake hit for "+str$(EDamage)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 3
Ehitpos = rnd(10)
If Ehitpos = 0
EAttack$ = "The Enemy Trooper slashed his sword but missed."
else
EDamage = rnd(70)+5
if Block = 1
EDamage = EDamage/10
Endif
EAttack$ = "The Enemy Trooper hit you with his sword for "+str$(EDamage)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 4
Ehitpos = rnd(1)
If Ehitpos = 0
EAttack$ = "Barack Obama had gone into Defense Mode."
Def = 1
else
EDamage = rnd(200)+100
if Block = 1
EDamage = EDamage/10
Endif
EAttack$ = "Obama called the milatary and they hit you for "+str$(EDamage)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 5
Ehitpos = rnd(3)
If Ehitpos = 0
EAttack$ = "ChangBiao Luo is being stupid and missed."
else
EDamage = rnd(150)+30
if Block = 1
EDamage = EDamage/10
Endif
EAttack$ = "ChangBiao Luo yelled at you for "+str$(EDamage)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 6
Ehitpos = rnd(5)
If Ehitpos = 0
EAttack$ = "Paul the Octopus missed you."
else
EDamage = rnd(70)+5
if Block = 1
EDamage = EDamage/10
Endif
EAttack$ = "Paul the Octopus predicted you would get hit for "+str$(EDamage)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if Yhealth<1 ` you lose sucka
do
cls
Print " Im sorry, you lost. Play again(Y/N)?"
if keystate(21) =1
gosub fighting
endif
if keystate(49) =1
end
endif
loop
endif
return
PotionCheck:
If Potion = 1
Gosub PotionDrink
Else
EAttack$ = "Oops. You don't have a potion. You wasted a turn"
Endif
Done = 1
return
PotionDrink:
If EnemySR = 4
Yhealth = Yhealth + 150
Attack$ = "Your health has increased by 150"
Potion = 0
Else
Yhealth = Yhealth + 100
Attack$ = "Your health has increased by 100"
Potion = 0
Endif
return
function mouseWithin(x1,y1,x2,y2)
mx = mousex()
my = mousey()
if mx>=x1 and mx<=x2 and my>=y1 and my<=y2 then exitfunction 1
endfunction 0
GUI:
wait 500
Click1 = 0
Click2 = 0
Click3 = 0
repeat
If mouseclick() = 1 and Click1 = 0
If mouseWithin(10,340,200,440) = 1 and Click1 = 0
Gosub ClickRed
endif
endif
if mouseclick() = 0 then Click1 = 0
If Mouseclick() = 1 and Click2 = 0
If mouseWithin(600,320,790,400) = 1 and Click2 = 0
Gosub ClickGreen
endif
endif
If Mouseclick() = 0 then Click2 = 0
If mouseclick() = 1 and Click3 =0
If mouseWithin(10,50,50,200) = 1 and Click3 = 0
gosub PotionCheck
endif
endif
until Done = 1
return
ClickRed:
Gosub Charge
Gosub EAttack
return
ClickGreen:
Gosub Shield
Gosub EAttack
return