Hi MPalmer
Check into arrays. For every enemy you create, you assign it an ID. This ID is later used to access the enemy's data within the array. Here's some code showing an array:
rem create our array
dim MyArray( 10 ) as integer
rem write some data into the array
for n = 0 to 10
MyArray( n ) = n * 3
next n
rem print data to screen
for n = 0 to 10
print MyArray( n )
next n
rem wait for user input
wait key
rem end program
end
So this would be how to create a zombie:
rem vector3 UDT
type vec3
x# as float
y# as float
z# as float
endtype
rem UDT for zombie
type ZombieAT
active as integer
pos as vec3
Obj as dword
health as integer
endtype
rem create our zombie array
dim Zombie( MaxZombie ) as ZombieAT
rem make 3 zombies and position randomly
for n = 1 to 3
x# = rnd( 1000 )
z# = rnd( 1000 )
y# = get ground height( 1 , x# , z# )
CreateZombie( n , x# , y# , z# )
next n
rem main loop
do
rem ...do stuff here...
rem refresh screen
sync
rem end of main loop
loop
rem end
end
rem functions -----------------------
function CreateZombie( ID , x# , y# , z# )
rem make sure zombie isn't already active
if Zombie( ID ).active > 0 then exitfunction
rem find a free object for the zombie
Zombie( ID ).Obj = find free object()
rem load zombie into memory
load object "H-Zombie-Attack1.x",Zombie( ID ).Obj
scale object Zombie( ID ).Obj,3000,3000,3000
loop object Zombie( ID ).Obj
position object Zombie( ID ).Obj,x# , y# , z#
rem set values
Zombie( ID ).Active = 1
Zombie( ID ).pos.x# = x#
Zombie( ID ).pos.y# = y#
Zombie( ID ).pos.z# = z#
Zombie( ID ).health = 100
endfunction
function DestroyZombie( ID )
rem make sure zombie is active
if Zombie( ID ).active < 1 then exitfunction
rem destroy zombie
delete object Zombie( ID ).Obj
Zombie( ID ).active = 0
endfunction
TheComet