Hi, I have the following problem:
Rem Project: Rpg_Npc_test
Rem Created: Wednesday, September 15, 2010
Rem ***** Main Source File *****
REM create type Goblin
TYPE GOBLIN
NAME AS STRING
IS_SHAMAN AS BOOLEAN
HITPOINTS
ATTACK
STRENGTH
STAMINA
QUICKNESS
ENDTYPE
REM MAX NUMBER OF OPPONENTS
MAX_OPP=10
REM create array for tribe
dim TRIBE_ARRAY (MAX_OPP) as GOBLIN
REM populate ARRAY
for i=1 to MAX_OPP
read TRIBE_ARRAY(i).NAME
read TRIBE_ARRAY(i).IS_SHAMAN
read TRIBE_ARRAY(i).HITPOINTS
read TRIBE_ARRAY(i).ATTACK
read TRIBE_ARRAY(i).STRENGTH
read TRIBE_ARRAY(i).STAMINA
read TRIBE_ARRAY(i).QUICKNESS
next i
REM Goblins data
DATA "Chief Gorkhat",0,40,60,55,50,45
DATA "Fraguk", 0,45,60,60,55,30
DATA "Zog",1,35,50,40,65,60
DATA "Grog",0,5 ,45,50,45,40
DATA "Gragun",0,40,45,55,40,35
DATA "Grulbul",0,40,45,45,40,40
DATA "Gromuk",0,40,45,35,40,55
DATA "Oggog",0,35,40,40,55,50
DATA "Fasul",0,35,40,35,40,60
DATA "Slugug",0,35,40,50,40,30
PRINT "GOBLIN "+TRIBE_ARRAY(3).NAME
IF TRIBE_ARRAY(3).IS_SHAMAN=1
PRINT "IS THE TRIBE SHAMAN"
PRINT
ELSE
PRINT "IS A GOBLIN"
PRINT
ENDIF
WAIT KEY
REM Player hit points,weapon damage & strength bonus
PLAYERHP=12
SB=3
SWORD=RND(8)+SB
PRINT SWORD
REM Apply DAMAGE to target
TARGET=4
D=TRIBE_ARRAY(TARGET).HITPOINTS - SWORD
PRINT D
REM Combat to death
REM WHILE PLAYERHP>0 && TRIBE_ARRAY(TARGET).HITPOINTS>0
Attack(TARGET,D)
REM Counterattack (TARGET,D2)
REM ENDWHILE
WAIT KEY
END
REM Attack Function
FUNCTION ATTACK(TARGET,D)
PRINT "You strike ";TRIBE_ARRAY(TARGET).NAME;". ";
TRIBE_ARRAY(TARGET).HITPOINTS=D
REM Dodge?
Dodgeroll=RND(99)+1
IF TRIBE_ARRAY(TARGET).QUICKNESS>Dodgeroll
PRINT "But";TRIBE_ARRAY(TARGET).NAME;" dodges your blow and prepares for a counterattack!"
ENDIF
REM how da heck do I exit the function if the dodge works? Compiler starts whining about endfunction..
IF TRIBE_ARRAY(TARGET).HITPOINTS>0
PRINT TRIBE_ARRAY(TARGET).NAME;" howls in pain and has ";TRIBE_ARRAY(TARGET).HITPOINTS;" hitpoints left"
PRINT TRIBE_ARRAY(TARGET).NAME;" tries to counterattack you.." REM ..because I am a lazy bastard.. (TODO counterattack)
ELSE
IF TRIBE_ARRAY(TARGET).HITPOINTS>-3
PRINT TRIBE_ARRAY(TARGET).NAME;" collapses to the ground, unconscious"
ELSE
PRINT TRIBE_ARRAY(TARGET).NAME;" dies"
ARRAY DELETE ELEMENT TRIBE_ARRAY(TARGET) REM Removes dead goblin from the tribe array (TODO before this; place a body & goblinĀ“s inventory on the ground in the map array to be done as well)
PRINT "Tribe has "; ARRAY COUNT(TRIBE_ARRAY());" goblins left" REM just checking that the previous command works
ENDIF
ENDIF
ENDFUNCTION
So how do I get out of the function if the goblin manages to dodge a blow?
--
Abolish All Religions