pardon the messy code, I am trying to work out somethings with a battle system for a rpg sytle game and the problem is: object #2 will not flag the attack variable....
appreciate any help
REM Project: test
REM Created: 10/02/05 12:34:29 AM
REM
REM ***** Main Source File *****
REM
Sync On
make matrix 1,1500,1500,50,50
randomize timer()
make object cube 1,.5
position object 1, 20,0,20
make object cube 2,.5
position object 2, 40,1,40
make object sphere 3,1
position object 3,100,1,100
make object cone 4,1
position object 4, 75,1,75
type character
maxhealth as float
mana as integer
health as integer
dmg as float
heal as float
hth as float
stm as integer
maxstm as float
endtype
global dim player(1)as character
player(0).maxhealth=100
player(0).mana=100
player(0).health=100
player(0).dmg=0.0
player(0).heal=0.0
player(0).hth=0.0
player(0).stm=100
player(0).maxstm=100
type monster
mon_obj as integer
mon_maxhealth as float
mon_mana as integer
mon_health as integer
mon_dmg as float
mon_heal as float
mon_hth as float
mon_stm as integer
mon_maxstm as float
endtype
global dim mon (10)as monster
for m=1 to 4
mon(m).mon_obj=0
mon(m).mon_maxhealth=100
mon(m).mon_mana=100
mon(m).mon_health=100
mon(m).mon_dmg=0.0
mon(m).mon_heal=0.0
mon(m).mon_hth=0.0
mon(m).mon_stm=100
mon(m).mon_maxstm=100
next m
mon(3).mon_maxhealth=100
mon(4).mon_health=75
`controls on player
s#=.1
a#=.1
ar#=.6
dist#=10 : ` distance camera behind player
height#=2: ` height above player
smooth=1 : ` smoothing value
Do
fps=screen fps()
set cursor 0,0
print "fps "; fps
print "test"; mons_engage
print "attack"; attack
print "mon"; item_1
Print "monster health"; mon(mons_engage).mon_health
print "turn"; ply_turn
print "mon turn"; mon_turn
gosub enymove
if attack=1 then gosub attack_commands
opx#=object position x(1)
opy#=object position y(1)
opz#=object position z(1)
mx=mousex()
my=mousey()
item_1=PICK OBJECT(mx, my, 2, 2010)
item_1d= get pick distance()
if keystate(44) then move object left 1,s#
if keystate(46) then move object right 1,s#
`if mouseclick()=2 then move object 1,s#
if keystate(17)
move object 1,s#
endif
if upkey()=1 then move object 1,s#
if keystate(31) then move object 1,-s#
if downkey()=1 then move object 1,-s#
if keystate(30) then yrotate object 1,wrapvalue(object angle y(1)-ar#)
if leftkey()=1 then yrotate object 1,wrapvalue(object angle y(1)-ar#)
if keystate(32) then yrotate object 1,wrapvalue(object angle y(1)+ar#)
if rightkey()=1 then yrotate object 1,wrapvalue(object angle y(1)+ar#)
set camera to follow object position x(1),object position y(1),object position z(1),object angle y(1),dist#,height#,smooth,0
Sync
Loop
enymove:
`******************************************************************************************************************
`************************* this loop is not working properly, object #2 will not flag the attack var **************
`******************************************************************************************************************
for m1 = 2 to 4
xa#=opx#:ya#=opy#:za#=opz#
mon_opx#=object position x(m1)
mon_opy#=object position y(m1)
mon_opz#=object position z(m1)
xb#=mon_opx#:yb#=mon_opy#:zb#=mon_opz#
d#=sqrt((xa#-xb#)^2 + (ya#-yb#)^2 + (za#-zb#)^2):` distance formula
if d#<50 and d#>3 then point object m1, opx#,mon_opy#,opz#
if d#<40 and d#>5 then move object m1,.05:loop object m1,2,15:set object speed m1,30
if d#>50 or d#<5 then move object m1,0:stop object m1
if d#<12 then attack=1 else attack=0
mon_y#=get ground height(1,object position x(m1),object position z(m1))
position object m1,object position x(m1),mon_y#,object position z(m1)
next m1
`******************************************************************************************************************
`******************************************************************************************************************
`******************************************************************************************************************
return
attack_commands:
item_1=PICK OBJECT(mx, my, 2, 2010)
item_1d= get pick distance()
Print "player health"; player(0).health
if item_1>1
mon_atk_opx#=object position x(item_1)
mon_atk_opy#=object position y(item_1)
mon_atk_opz#=object position z(item_1)
xc#=mon_atk_opx#:yc#=mon_atk_opy#:zc#=mon_atk_opz#
d_attack#=sqrt((xa#-xc#)^2 + (ya#-yc#)^2 + (za#-zc#)^2)
endif
if item_1>1 and mouseclick()=1 and d_attack#<12 and attack=1
color object item_1,7
mons_engage=item_1
ply_turn1=0
ply_turn=rnd(10)
mon_turn=rnd(10)
endif
if ply_turn>mon_turn and mouseclick()=0 and ply_turn1=0
ply_hit=rnd(25)
mon(mons_engage).mon_health=mon(mons_engage).mon_health-ply_hit
ply_turn1=1
endif
if mon_turn>ply_turn and mouseclick()=0 and ply_turn1=0
ply_hit=rnd(25)
player(0).health=player(0).health-ply_hit
ply_turn1=1
endif
return