text adventure, multi enemy fight subroutine - broken?

This forum is for posting code that needs help.

Palocles
Posts: 1
Joined: Fri Feb 03, 2012 8:21 am

text adventure, multi enemy fight subroutine - broken?

Post by Palocles »

Ok, so as i said on the other just Basic forum, my 'fight three enemies at once' subroutine isn't working properly.

It does seem to run properly to some degree but when it gets to the end it doesn't return, instead it reverts to an earlier point in the gosub. There might be a couple of other minor issues but that is the main one.

The [areas] are just to see if it works properly, as are the variables. I'll be cutting and pasting the sub into the actual code.

Code: Select all

[AREA1]

print "You're in the Kastle..."
print
Print "You hear a noise form behind you then suddenly!..."
mon1nam$ = "Goblin"
mon1ski = 9
mon1sta = 10
mon1dam = 4
mon1vul$ = "J"

mon2nam$ = "Grot"
mon2ski = 9
mon2sta = 15
mon2dam = 5
mon2vul$ = "S"

mon3nam$ = "Gobbo"
mon3ski = 8
mon3sta = 12
mon3dam = 4
mon3vul$ = "C"

ski = 15
sta = 50
luk = 20
dam = 5
round = 0
mon1ded$ = ""
mon2ded$ = ""
mon3ded$ = ""


gosub [fight3]
if fight$ =  "E" then
    print "You flee in terror from the fearsome creatures!"
    sta = sta - mon1dam
    goto [area2]
end if
print
print "You have defeated your enemies!"
print "Their shattered bodies lie before you."
dedgob = 3
goto [gameover]


[area2]
print
print "You manage to ascape from the monsters, phew!"
print "You have "; sta; " Stamina."
goto [gameover]

[fight3]
fight$ = ""
print "You are attacked by a "; mon1nam$; ", a "; mon2nam$; " and a "; mon3nam$; "."
print

[fight3pik]                                                                 'choose one of three to attack
print "Do you attack the (F)irst enemy, the (S)econd enemy, the (T)hird enemy "
input "or do you try to (E)scape?  "; fight$
select case fight$
case "E"
    return
case "F"
    goto [fight1of3]
case "S"
    goto [fight2of3]
case "T"
    goto [fight3of3]
case else
    goto [fight3pik]
end select
print

[fight1of3]                                                                     'choosing strike against enemy one
print
input "Choose your strike: (A)ttack, (L)unge, (J)ab, (S)lash, (C)leave:  "; att$
attdam = 0
attski = 0
select case att$
    case "A"
    lun = 0
    jab = 0
    sla = 0
    cle = 0
    case "L"
    if round = 0 then attdam = 2 and attski = 1
    lun = lun + 1
    case "J"
    attski = 1
    attdam = -1
    if mon1vul$ = "J" and jab = 0 then attdam = 0
    jab = jab + 1
    case "S"
    if mon1vul$ = "S" and sla = 0 then attdam = 2
    sla = sla + 1
    case "C"
    attski = -1
    attdam = 2
    if mon1vul$ = "C" and cle = 0 then attdam = 4
    cle = cle + 1
    case else
    goto [fight1of3]
end select

print                                                                       'fighting first of three enemy
plyatt = ski + weapski + attski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon1att = mon1ski + 2 + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon2att = mon2ski + 2 + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon3att = mon3ski + 2 + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
print "The "; mon1nam$; " rolled "; mon1att
print "The "; mon2nam$; " rolled "; mon2att
print "The "; mon3nam$; " rolled "; mon3att
print "You rolled "; plyatt
print
if plyatt > mon1att then hit1$ = "mon1"
if plyatt >= mon2att then hit2$ = "non"
if plyatt >= mon3att then hit3$ = "non"
if plyatt < mon1att then hit1$ = "ply"
if plyatt < mon2att then hit2$ = "ply"
if plyatt < mon3att then hit3$ = "ply"
if plyatt = mon1att then hit1$ = "non"
luk$ = ""
luck = 0

select case hit1$                                                           'player hits first monster
case "mon1"
    print "You hit the "; mon1nam$
    luck = 0
    input "Use luck, (Y)es? "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = 5
    if luk$ = "N" then luck = -2
    mon1sta = mon1sta - (dam + attdam + weapdam + luck + mon1arm)
    print mon1nam$; " has "; mon1sta; " stamina left."

case "ply"                                                                  'first monster hits player
    print "The "; mon1nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon1dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'first monster misses player
    print "The "; mon1nam$; " missed."
end select

select case hit2$                                                           'second monster hits player
case "ply"
    print "The "; mon2nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon2dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'second monster misses
    print "The "; mon2nam$; " missed."
end select

select case hit3$ 
case "ply"                                                                  'third monster hits player
    print "The "; mon3nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon3dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'third monster misses
    print "The "; mon3nam$; " missed."
end select

gosub [fight3rndend]
goto [fight3pik]


[fight2of3]                                                                     'choosing strike against enemy two
print
input "Choose your strike: (A)ttack, (L)unge, (J)ab, (S)lash, (C)leave:  "; att$
attdam = 0
attski = 0
select case att$
    case "A"
    lun = 0
    jab = 0
    sla = 0
    cle = 0
    case "L"
    if round = 0 then attdam = 2 and attski = 1
    lun = lun + 1
    case "J"
    attski = 1
    attdam = -1
    if mon2vul$ = "J" and jab = 0 then attdam = 0
    jab = jab + 1
    case "S"
    if mon2vul$ = "S" and sla = 0 then attdam = 2
    sla = sla + 1
    case "C"
    attski = -1
    attdam = 2
    if mon2vul$ = "C" and cle = 0 then attdam = 4
    cle = cle + 1
    case else
    goto [fight2of3]
end select

print                                                                       'fighting second of three enemy
plyatt = ski + weapski + attski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon1att = mon1ski + 2 +(int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon2att = mon2ski + 2 + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon3att = mon3ski + 2 + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
print "The "; mon1nam$; " rolled "; mon1att
print "The "; mon2nam$; " rolled "; mon2att
print "The "; mon3nam$; " rolled "; mon3att
print "You rolled "; plyatt
print
if plyatt >= mon1att then hit1$ = "non"
if plyatt > mon2att then hit2$ = "mon2"
if plyatt >= mon3att then hit3$ = "non"
if plyatt < mon1att then hit1$ = "ply"
if plyatt < mon2att then hit2$ = "ply"
if plyatt < mon3att then hit3$ = "ply"
if plyatt = mon2att then hit2$ = "non"
luk$ = ""
luck = 0

select case hit2$                                                           'player hits second monster
case "mon2"
    print "You hit the "; mon2nam$
    luck = 0
    input "Use luck, (Y)es? "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = 5
    if luk$ = "N" then luck = -2
    mon2sta = mon2sta - (dam + attdam + weapdam + luck + mon2arm)
    print mon2nam$; " has "; mon2sta; " stamina left."

case "ply"                                                                  'second monster hits player
    print "The "; mon2nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon2dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'second monster misses player
    print "The "; mon2nam$; " missed."
end select

select case hit1$                                                           'first monster hits player
case "ply"
    print "The "; mon1nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon1dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'first monster misses
    print "The "; mon1nam$; " missed."
end select

select case hit3$ 
case "ply"                                                                  'third monster hits player
    print "The "; mon3nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon3dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'third monster misses
    print "The "; mon3nam$; " missed."
end select

gosub [fight3rndend]
goto [fight3pik]


[fight3of3]                                                                     'choosing strike against enemy three
print
input "Choose your strike: (A)ttack, (L)unge, (J)ab, (S)lash, (C)leave:  "; att$
attdam = 0
attski = 0
select case att$
    case "A"
    lun = 0
    jab = 0
    sla = 0
    cle = 0
    case "L"
    if round = 0 then attdam = 2 and attski = 1
    lun = lun + 1
    case "J"
    attski = 1
    attdam = -1
    if mon3vul$ = "J" and jab = 0 then attdam = 0
    jab = jab + 1
    case "S"
    if mon3vul$ = "S" and sla = 0 then attdam = 2
    sla = sla + 1
    case "C"
    attski = -1
    attdam = 2
    if mon3vul$ = "C" and cle = 0 then attdam = 4
    cle = cle + 1
    case else
    goto [fight3of3]
end select

print                                                                       'fighting third of three enemy
plyatt = ski + weapski + attski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon1att = mon1ski + 2 +(int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon2att = mon2ski + 2 + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon3att = mon3ski + 2 + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
print "The "; mon1nam$; " rolled "; mon1att
print "The "; mon2nam$; " rolled "; mon2att
print "The "; mon3nam$; " rolled "; mon3att
print "You rolled "; plyatt
print
if plyatt >= mon1att then hit1$ = "non"
if plyatt >= mon2att then hit2$ = "non"
if plyatt > mon3att then hit3$ = "mon3"
if plyatt < mon1att then hit1$ = "ply"
if plyatt < mon2att then hit2$ = "ply"
if plyatt < mon3att then hit3$ = "ply"
if plyatt = mon3att then hit3$ = "non"
luk$ = ""
luck = 0

select case hit3$                                                           'player hits third monster
case "mon3"
    print "You hit the "; mon3nam$
    luck = 0
    input "Use luck, (Y)es? "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = 5
    if luk$ = "N" then luck = -2
    mon3sta = mon3sta - (dam + attdam + weapdam + luck + mon3arm)
    print mon3nam$; " has "; mon3sta; " stamina left."

case "ply"                                                                  'third monster hits player
    print "The "; mon3nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon3dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'third monster misses player
    print "The "; mon3nam$; " missed."
end select

select case hit1$                                                           'first monster hits player
case "ply"
    print "The "; mon1nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon1dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'first monster misses
    print "The "; mon1nam$; " missed."
end select

select case hit2$ 
case "ply"                                                                  'second monster hits player
    print "The "; mon2nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon2dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'second monster misses
    print "The "; mon2nam$; " missed."
end select

gosub [fight3rndend]
goto [fight3pik]


[fight3rndend]
gosub [rndcount]
if mon1sta <= 0 then mon1ded$ = "Y"
if mon2sta <= 0 then mon2ded$ = "Y"
if mon3sta <= 0 then mon3ded$ = "Y"
if mon1ded$ = "Y" then goto [fighttwothree]
if mon2ded$ = "Y" then goto [fightonethree]
if mon3ded$ = "Y" then goto [fightonetwo]
return


[fight2]                                                                        'intro to two monster fight
fight$ = ""
print "You are attacked by a "; mon1nam$; " and a "; mon2nam$; "."
print
goto [fightonetwopik]

[fightonetwo]                                                                   'continues three mon fight with two mon
fight$ = ""
print "You are left facing a "; mon1nam$; " and a "; mon2nam$; "."
print
goto [fightonetwopik]

[fightonetwopik]                                                                'choose one of two to attack
print "Do you attack the (F)irst enemy, the (S)econd enemy "
input "or do you try to (E)scape?  "; fight$
select case fight$
case "E"
    return
case "F"
    goto [fight1of2]
case "S"
    goto [fight2of2]
case else
    goto [fightonetwopik]
end select
print

[fight1of2]                                                                     'choosing strike against enemy one
print
input "Choose your strike: (A)ttack, (L)unge, (J)ab, (S)lash, (C)leave:  "; att$
attdam = 0
attski = 0
select case att$
    case "A"
    lun = 0
    jab = 0
    sla = 0
    cle = 0
    case "L"
    if round = 0 then attdam = 2 and attski = 1
    lun = lun + 1
    case "J"
    attski = 1
    attdam = -1
    if mon1vul$ = "J" and jab = 0 then attdam = 0
    jab = jab + 1
    case "S"
    if mon1vul$ = "S" and sla = 0 then attdam = 2
    sla = sla + 1
    case "C"
    attski = -1
    attdam = 2
    if mon1vul$ = "C" and cle = 0 then attdam = 4
    cle = cle + 1
    case else
    goto [fight1of2]
end select

print                                                                       'fighting first of two enemy
plyatt = ski + weapski + attski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon1att = mon1ski + 2 +(int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon2att = mon2ski + 2 + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
print "The "; mon1nam$; " rolled "; mon1att
print "The "; mon2nam$; " rolled "; mon2att
print "You rolled "; plyatt
print
if plyatt > mon1att then hit1$ = "mon1"
if plyatt >= mon2att then hit2$ = "non"
if plyatt < mon1att then hit1$ = "ply"
if plyatt < mon2att then hit2$ = "ply"
if plyatt = mon1att then hit1$ = "non"
luk$ = ""
luck = 0

select case hit1$                                                           'player hits first monster
case "mon1"
    print "You hit the "; mon1nam$
    luck = 0
    input "Use luck, (Y)es? "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = 5
    if luk$ = "N" then luck = -2
    mon1sta = mon1sta - (dam + attdam + weapdam + luck + mon1arm)
    print mon1nam$; " has "; mon1sta; " stamina left."

case "ply"                                                                  'first monster hits player
    print "The "; mon1nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon1dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'first monster misses player
    print "The "; mon1nam$; " missed."
end select

select case hit2$                                                           'second monster hits player
case "ply"
    print "The "; mon2nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon2dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'second monster misses
    print "The "; mon2nam$; " missed."
end select

gosub [fightonetworndend]
goto [fightonetwopik]


[fight2of2]                                                                     'choosing strike against enemy two
print
input "Choose your strike: (A)ttack, (L)unge, (J)ab, (S)lash, (C)leave:  "; att$
attdam = 0
attski = 0
select case att$
    case "A"
    lun = 0
    jab = 0
    sla = 0
    cle = 0
    case "L"
    if round = 0 then attdam = 2 and attski = 1
    lun = lun + 1
    case "J"
    attski = 1
    attdam = -1
    if mon2vul$ = "J" and jab = 0 then attdam = 0
    jab = jab + 1
    case "S"
    if mon2vul$ = "S" and sla = 0 then attdam = 2
    sla = sla + 1
    case "C"
    attski = -1
    attdam = 2
    if mon2vul$ = "C" and cle = 0 then attdam = 4
    cle = cle + 1
    case else
    goto [fight1of2]
end select

print                                                                       'fighting second of two enemy
plyatt = ski + weapski + attski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon1att = mon1ski + 2 +(int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon2att = mon2ski + 2 + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
print "The "; mon1nam$; " rolled "; mon1att
print "The "; mon2nam$; " rolled "; mon2att
print "You rolled "; plyatt
print
if plyatt >= mon1att then hit1$ = "non"
if plyatt > mon2att then hit2$ = "mon2"
if plyatt < mon1att then hit1$ = "ply"
if plyatt < mon2att then hit2$ = "ply"
if plyatt = mon2att then hit2$ = "non"
luk$ = ""
luck = 0

select case hit2$                                                           'player hits second monster
case "mon2"
    print "You hit the "; mon2nam$
    luck = 0
    input "Use luck, (Y)es? "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = 5
    if luk$ = "N" then luck = -2
    mon2sta = mon2sta - (dam + attdam + weapdam + luck + mon2arm)
    print mon2nam$; " has "; mon2sta; " stamina left."

case "ply"                                                                  'second monster hits player
    print "The "; mon2nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon2dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'second monster misses player
    print "The "; mon2nam$; " missed."
end select

select case hit1$                                                           'first monster hits player
case "ply"
    print "The "; mon1nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon1dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'second monster misses
    print "The "; mon2nam$; " missed."
end select

gosub [fightonetworndend]
goto [fightonetwopik]


[fightonetworndend]
gosub [rndcount]
if mon1sta <= 0 then mon1ded$ = "Y"
if mon2sta <= 0 then mon2ded$ = "Y"
if mon1ded$ = "Y" then goto [fighttwo]
if mon2ded$ = "Y" then goto [fightone]
return

[fightonethree]                                                                   'continues three mon fight with mons one and three
fight$ = ""
print "You are left facing a "; mon1nam$; " and a "; mon3nam$; "."
print
goto [fightonethreepik]

[fightonethreepik]                                                                'choose one of two to attack
print "Do you attack the (F)irst enemy, the (S)econd enemy "
input "or do you try to (E)scape?  "; fight$
select case fight$
case "E"
    return
case "F"
    goto [fight1of23]
case "S"
    goto [fight3of23]
case else
    goto [fightonethreepik]
end select
print

[fight1of23]                                                                     'choosing strike against enemy one
print
input "Choose your strike: (A)ttack, (L)unge, (J)ab, (S)lash, (C)leave:  "; att$
attdam = 0
attski = 0
select case att$
    case "A"
    lun = 0
    jab = 0
    sla = 0
    cle = 0
    case "L"
    if round = 0 then attdam = 2 and attski = 1
    lun = lun + 1
    case "J"
    attski = 1
    attdam = -1
    if mon1vul$ = "J" and jab = 0 then attdam = 0
    jab = jab + 1
    case "S"
    if mon1vul$ = "S" and sla = 0 then attdam = 2
    sla = sla + 1
    case "C"
    attski = -1
    attdam = 2
    if mon1vul$ = "C" and cle = 0 then attdam = 4
    cle = cle + 1
    case else
    goto [fight1of23]
end select

print                                                                       'fighting first of one/three enemies
plyatt = ski + weapski + attski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon1att = mon1ski + 2 +(int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon3att = mon3ski + 2 + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
print "The "; mon1nam$; " rolled "; mon1att
print "The "; mon3nam$; " rolled "; mon3att
print "You rolled "; plyatt
print
if plyatt > mon1att then hit1$ = "mon1"
if plyatt >= mon3att then hit3$ = "non"
if plyatt < mon1att then hit1$ = "ply"
if plyatt < mon3att then hit3$ = "ply"
if plyatt = mon1att then hit1$ = "non"
luk$ = ""
luck = 0

select case hit1$                                                           'player hits first monster
case "mon1"
    print "You hit the "; mon1nam$
    luck = 0
    input "Use luck, (Y)es? "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = 5
    if luk$ = "N" then luck = -2
    mon1sta = mon1sta - (dam + attdam + weapdam + luck + mon1arm)
    print mon1nam$; " has "; mon1sta; " stamina left."

case "ply"                                                                  'first monster hits player
    print "The "; mon1nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon1dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'first monster misses player
    print "The "; mon1nam$; " missed."
end select

select case hit3$                                                           'third monster hits player
case "ply"
    print "The "; mon3nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon3dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'third monster misses
    print "The "; mon3nam$; " missed."
end select

gosub [fightonethreerndend]
goto [fightonethreepik]


[fight3of23]                                                                     'choosing strike against enemy three
print
input "Choose your strike: (A)ttack, (L)unge, (J)ab, (S)lash, (C)leave:  "; att$
attdam = 0
attski = 0
select case att$
    case "A"
    lun = 0
    jab = 0
    sla = 0
    cle = 0
    case "L"
    if round = 0 then attdam = 2 and attski = 1
    lun = lun + 1
    case "J"
    attski = 1
    attdam = -1
    if mon3vul$ = "J" and jab = 0 then attdam = 0
    jab = jab + 1
    case "S"
    if mon3vul$ = "S" and sla = 0 then attdam = 2
    sla = sla + 1
    case "C"
    attski = -1
    attdam = 2
    if mon3vul$ = "C" and cle = 0 then attdam = 4
    cle = cle + 1
    case else
    goto [fight3of23]
end select

print                                                                       'fighting third of two enemy
plyatt = ski + weapski + attski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon1att = mon1ski + 1 +(int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon3att = mon3ski + 1 + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
print "The "; mon1nam$; " rolled "; mon1att
print "The "; mon3nam$; " rolled "; mon3att
print "You rolled "; plyatt
print
if plyatt >= mon1att then hit1$ = "non"
if plyatt > mon3att then hit3$ = "mon3"
if plyatt < mon1att then hit1$ = "ply"
if plyatt < mon3att then hit3$ = "ply"
if plyatt = mon3att then hit3$ = "non"
luk$ = ""
luck = 0

select case hit3$                                                           'player hits third monster
case "mon3"
    print "You hit the "; mon3nam$
    luck = 0
    input "Use luck, (Y)es? "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = 5
    if luk$ = "N" then luck = -2
    mon3sta = mon3sta - (dam + attdam + weapdam + luck + mon3arm)
    print mon3nam$; " has "; mon3sta; " stamina left."

case "ply"                                                                  'third monster hits player
    print "The "; mon3nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon3dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'third monster misses player
    print "The "; mon3nam$; " missed."
end select

select case hit1$                                                           'first monster hits player
case "ply"
    print "The "; mon1nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon1dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'first monster misses
    print "The "; mon1nam$; " missed."
end select

gosub [fightonethreerndend]
goto [fightonethreepik]


[fightonethreerndend]
gosub [rndcount]
if mon1sta <= 0 then mon1ded$ = "Y"
if mon3sta <= 0 then mon3ded$ = "Y"
if mon1ded$ = "Y" then goto [fightthree]
if mon3ded$ = "Y" then goto [fightone]
return


[fighttwothree]                                                                   'continues three mon fight with mons two and three
fight$ = ""
print "You are left facing a "; mon2nam$; " and a "; mon3nam$; "."
print
goto [fighttwothreepik]

[fighttwothreepik]                                                                'choose one of two to attack
print "Do you attack the (F)irst enemy, the (S)econd enemy "
input "or do you try to (E)scape?  "; fight$
select case fight$
case "E"
    return
case "F"
    goto [fight2of23]
case "S"
    goto [fight3of2and3]
case else
    goto [fighttwothreepik]
end select
print

[fight2of23]                                                                     'choosing strike against enemy two
print
input "Choose your strike: (A)ttack, (L)unge, (J)ab, (S)lash, (C)leave:  "; att$
attdam = 0
attski = 0
select case att$
    case "A"
    lun = 0
    jab = 0
    sla = 0
    cle = 0
    case "L"
    if round = 0 then attdam = 2 and attski = 1
    lun = lun + 1
    case "J"
    attski = 1
    attdam = -1
    if mon2vul$ = "J" and jab = 0 then attdam = 0
    jab = jab + 1
    case "S"
    if mon2vul$ = "S" and sla = 0 then attdam = 2
    sla = sla + 1
    case "C"
    attski = -1
    attdam = 2
    if mon2vul$ = "C" and cle = 0 then attdam = 4
    cle = cle + 1
    case else
    goto [fight2of23]
end select

print                                                                       'fighting first of one/three enemies
plyatt = ski + weapski + attski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon2att = mon2ski + 1 +(int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon3att = mon3ski + 1 + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
print "The "; mon2nam$; " rolled "; mon2att
print "The "; mon3nam$; " rolled "; mon3att
print "You rolled "; plyatt
print
if plyatt > mon2att then hit2$ = "mon2"
if plyatt >= mon3att then hit3$ = "non"
if plyatt < mon2att then hit2$ = "ply"
if plyatt < mon3att then hit3$ = "ply"
if plyatt = mon2att then hit2$ = "non"
luk$ = ""
luck = 0

select case hit2$                                                           'player hits second monster
case "mon2"
    print "You hit the "; mon2nam$
    luck = 0
    input "Use luck, (Y)es? "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = 5
    if luk$ = "N" then luck = -2
    mon2sta = mon2sta - (dam + attdam + weapdam + luck + mon2arm)
    print mon2nam$; " has "; mon2sta; " stamina left."

case "ply"                                                                  'second monster hits player
    print "The "; mon2nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon2dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'second monster misses player
    print "The "; mon2nam$; " missed."
end select

select case hit3$                                                           'third monster hits player
case "ply"
    print "The "; mon3nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon3dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'third monster misses
    print "The "; mon3nam$; " missed."
end select

gosub [fightonethreerndend]
goto [fightonethreepik]


[fight3of2and3]                                                                     'choosing strike against enemy three
print
input "Choose your strike: (A)ttack, (L)unge, (J)ab, (S)lash, (C)leave:  "; att$
attdam = 0
attski = 0
select case att$
    case "A"
    lun = 0
    jab = 0
    sla = 0
    cle = 0
    case "L"
    if round = 0 then attdam = 2 and attski = 1
    lun = lun + 1
    case "J"
    attski = 1
    attdam = -1
    if mon3vul$ = "J" and jab = 0 then attdam = 0
    jab = jab + 1
    case "S"
    if mon3vul$ = "S" and sla = 0 then attdam = 2
    sla = sla + 1
    case "C"
    attski = -1
    attdam = 2
    if mon3vul$ = "C" and cle = 0 then attdam = 4
    cle = cle + 1
    case else
    goto [fight3of2and3]
end select

print                                                                       'fighting third of two enemy
plyatt = ski + weapski + attski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon2att = mon2ski + 1 +(int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon3att = mon3ski + 1 + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
print "The "; mon2nam$; " rolled "; mon2att
print "The "; mon3nam$; " rolled "; mon3att
print "You rolled "; plyatt
print
if plyatt >= mon2att then hit2$ = "non"
if plyatt > mon3att then hit3$ = "mon3"
if plyatt < mon2att then hit2$ = "ply"
if plyatt < mon3att then hit3$ = "ply"
if plyatt = mon3att then hit3$ = "non"
luk$ = ""
luck = 0

select case hit3$                                                           'player hits third monster
case "mon3"
    print "You hit the "; mon3nam$
    luck = 0
    input "Use luck, (Y)es? "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = 5
    if luk$ = "N" then luck = -2
    mon3sta = mon3sta - (dam + attdam + weapdam + luck + mon3arm)
    print mon3nam$; " has "; mon3sta; " stamina left."

case "ply"                                                                  'third monster hits player
    print "The "; mon3nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon3dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'third monster misses player
    print "The "; mon3nam$; " missed."
end select

select case hit2$                                                           'second monster hits player
case "ply"
    print "The "; mon2nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon2dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'second monster misses
    print "The "; mon2nam$; " missed."
end select

gosub [fighttwothreerndend]
goto [fighttwothreepik]

[fighttwothreerndend]
gosub [rndcount]
if mon2sta <= 0 then mon2ded$ = "Y"
if mon3sta <= 0 then mon3ded$ = "Y"
if mon2ded$ = "Y" then goto [fightthree]
if mon3ded$ = "Y" then goto [fighttwo]
return

[fight1]
fight$ = ""
print "You are attacked by a "; mon1nam$; "!"
print
input "Do you wish to (A)ttack or try to (E)scape? "; fight$
print
select case fight$
    case "E"
        return
    case "A"
        goto [fightonepik]
end select

[fightone]
print "You are left facing a "; mon1nam$; "."
print
[fightonechoose]
input "Do you wish to (A)ttack or try to (E)scape? "; fight$
print
select case fight$
    case "E"
        return
    case "A"
        goto [fightonepik]
end select

[fightonepik]                                                                     'choosing strike against final enemy one
input "Choose your strike: (A)ttack, (L)unge, (J)ab, (S)lash, (C)leave:  "; att$
attdam = 0
attski = 0
select case att$
    case "A"
    lun = 0
    jab = 0
    sla = 0
    cle = 0
    case "L"
    if round = 0 then attdam = 2 and attski = 1
    lun = lun + 1
    case "J"
    attski = 1
    attdam = -1
    if mon1vul$ = "J" and jab = 0 then attdam = 0
    jab = jab + 1
    case "S"
    if mon1vul$ = "S" and sla = 0 then attdam = 2
    sla = sla + 1
    case "C"
    attski = -1
    attdam = 2
    if mon1vul$ = "C" and cle = 0 then attdam = 4
    cle = cle + 1
    case else
    goto [fightonepik]
end select

print                                                                       'fighting last enemy number one
plyatt = ski + weapski + attski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon1att = mon1ski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
print "The "; mon1nam$; " rolled "; mon1att
print "You rolled "; plyatt
print
if plyatt > mon1att then hit1$ = "mon1"
if plyatt < mon1att then hit1$ = "ply"
if plyatt = mon1att then hit1$ = "non"
luk$ = ""
luck = 0

select case hit1$                                                           'player hits numone mon
case "mon1"
    print "You hit the "; mon1nam$
    luck = 0
    input "Use luck, (Y)es? "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = 5
    if luk$ = "N" then luck = -2
    mon1sta = mon1sta - (dam + attdam + weapdam + luck + mon1arm)
    print mon1nam$; " has "; mon1sta; " stamina left."

case "ply"                                                                  'numone monster hits player
    print "The "; mon1nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon1dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'numone monster misses player
    print "The "; mon1nam$; " missed."
end select

gosub [rndcount]

if mon1sta <= 0 then mon1ded$ = "Y"
if mon1ded$ = "Y" then return
goto [fightonechoose]


[fighttwo]
fight$ = ""
print "You are left facing a "; mon2nam$; "."
print
[fighttwochoose]
input "Do you wish to (A)ttack or try to (E)scape? "; fight$
print
select case fight$
    case "E"
        return
    case "A"
        goto [fighttwopik]
end select

[fighttwopik]                                                                     'choosing strike against final enemy two
input "Choose your strike: (A)ttack, (L)unge, (J)ab, (S)lash, (C)leave:  "; att$
attdam = 0
attski = 0
select case att$
    case "A"
    lun = 0
    jab = 0
    sla = 0
    cle = 0
    case "L"
    if round = 0 then attdam = 2 and attski = 1
    lun = lun + 1
    case "J"
    attski = 1
    attdam = -1
    if mon2vul$ = "J" and jab = 0 then attdam = 0
    jab = jab + 1
    case "S"
    if mon2vul$ = "S" and sla = 0 then attdam = 2
    sla = sla + 1
    case "C"
    attski = -1
    attdam = 2
    if mon2vul$ = "C" and cle = 0 then attdam = 4
    cle = cle + 1
    case else
    goto [fighttwopik]
end select

print                                                                       'fighting last enemy number two
plyatt = ski + weapski + attski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon2att = mon2ski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
print "The "; mon2nam$; " rolled "; mon2att
print "You rolled "; plyatt
print
if plyatt > mon2att then hit2$ = "mon2"
if plyatt < mon2att then hit2$ = "ply"
if plyatt = mon2att then hit2$ = "non"
luk$ = ""
luck = 0

select case hit2$                                                           'player hits numtwo mon
case "mon2"
    print "You hit the "; mon2nam$
    luck = 0
    input "Use luck, (Y)es? "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = 5
    if luk$ = "N" then luck = -2
    mon2sta = mon2sta - (dam + attdam + weapdam + luck + mon2arm)
    print mon2nam$; " has "; mon2sta; " stamina left."

case "ply"                                                                  'num2 monster hits player
    print "The "; mon2nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon2dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'num2 monster misses player
    print "The "; mon2nam$; " missed."
end select

gosub [rndcount]

if mon2sta <= 0 then mon2ded$ = "Y"
if mon2ded$ = "Y" then return
goto [fighttwochoose]


[fightthree]
fight$ = ""
print "You are left facing a "; mon3nam$; "."
print
[fightthreechoose]
input "Do you wish to (A)ttack or try to (E)scape? "; fight$
print
select case fight$
    case "E"
        return
    case "A"
        goto [fightthreepik]
end select

[fightthreepik]                                                                     'choosing strike against final enemy one
input "Choose your strike: (A)ttack, (L)unge, (J)ab, (S)lash, (C)leave:  "; att$
attdam = 0
attski = 0
select case att$
    case "A"
    lun = 0
    jab = 0
    sla = 0
    cle = 0
    case "L"
    if round = 0 then attdam = 2 and attski = 1
    lun = lun + 1
    case "J"
    attski = 1
    attdam = -1
    if mon3vul$ = "J" and jab = 0 then attdam = 0
    jab = jab + 1
    case "S"
    if mon3vul$ = "S" and sla = 0 then attdam = 2
    sla = sla + 1
    case "C"
    attski = -1
    attdam = 2
    if mon3vul$ = "C" and cle = 0 then attdam = 4
    cle = cle + 1
    case else
    goto [fightonepik]
end select

print                                                                       'fighting last enemy number 3
plyatt = ski + weapski + attski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
mon3att = mon3ski + (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
print "The "; mon3nam$; " rolled "; mon3att
print "You rolled "; plyatt
print
if plyatt > mon3att then hit3$ = "mon3"
if plyatt < mon3att then hit3$ = "ply"
if plyatt = mon3att then hit3$ = "non"
luk$ = ""
luck = 0

select case hit3$                                                           'player hits num3 mon
case "mon3"
    print "You hit the "; mon3nam$
    luck = 0
    input "Use luck, (Y)es? "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = 5
    if luk$ = "N" then luck = -2
    mon3sta = mon3sta - (dam + attdam + weapdam + luck + mon3arm)
    print mon3nam$; " has "; mon3sta; " stamina left."

case "ply"                                                                  'num3 monster hits player
    print "The "; mon3nam$; " has hit you!"
    luck = 0
    input "Use luck, (Y)es "; luck$
    if luck$ = "Y" then gosub [useluck]
    if luk$ = "Y" then luck = -2
    if luk$ = "N" then luck = 2
    sta = sta - (mon3dam - arm + luck)
    print "You have "; sta; " stamina left."

case "non"                                                                  'numone monster misses player
    print "The "; mon3nam$; " missed."
end select

gosub [rndcount]

if mon3sta <= 0 then mon3ded$ = "Y"
if mon3ded$ = "Y" then return
goto [fightthreechoose]


[rndcount]
print
totrnd = totrnd + 1
round = round + 1
if round = 10 then gosub [time]
if round = 10 then round = 1
return


[time]
time = time +1
gosub [restorluk]
if time = 30 then print "You have been in the Kastle for half an hour already."
if time = 60 then print "You have been in the Kastle for an hour."
if time = 90 then print "You have been in the Kastle an hour and a half."
if time = 120 then print "You have been in the Kastle for two hours now."
if time = 150 then print "You have been in the Kastle for two and a half hours."
return


[useluck]
luktest = (int(rnd(1)*10)+1) + (int(rnd(1)*10)+1)
    if luktest > luk then luk$ = "N"
    if luktest <= luk then luk$ = "Y"
select case luk$
case "N"
    print "Luck test failed."
    print "Luck is "; luk
    print
    return
case "Y"
    print "Luck test successful."
    luk = luk -1
    print "Luck is "; luk
    print
    return
end select


[restorluk]
if luk < mxluk then tim = tim + 1
if tim = 10 then luk = luk + 1
if tim = 10 then tim = 1
return


[gameover]
if dedgob > 0 then
print "You have killed "; dedgob; " Goblins."
end if
if dedorc > 0 then
print "You have killed "; dedorc; " Orcs."
end if
print "You have been in the Kastle for "; time; " minutes."
print "You have fought "; totrnd; " rounds of combat."
END