Then load object one then use the clone object command.
In your function, rather than editing object 1 or 2, edit object
obj and set obj to the correct value. You can also use an array to handle the object number:
dim enemy(3)
objNo = 1
load object "enemy_1.x",objNo
enemy(1) = objNo
objNo = objNo + 1
clone object objNo,enemy(1)
enemy(2) = objNo
objNo = objNo + 1
clone object objNo,enemy(1)
enemy(3) = objNo
do
`code goes here
for obj = 1 to 3
run_ai(enemy(obj))
next obj
loop
function run_ai(obj)
`code goes here (the object number being 'obj')
endfunction
However, user defined types would be better than an array:
TYPE TEnemyBlueprint
ID as integer
Health as integer
Name as string
ENDTYPE
dim enemy(3) as TEnemyBlueprint
objNo = 1
load object "enemy_1.x",objNo
enemy(1).ID = objNo
objNo = objNo + 1
clone object objNo,enemy(1)
enemy(2).ID = objNo
objNo = objNo + 1
clone object objNo,enemy(1)
enemy(3).ID = objNo
do
`code goes here
for obj = 1 to 3
run_ai(enemy(obj).ID)
next obj
loop
function run_ai(obj)
`code goes here (the object number being 'obj')
endfunction
This way you can use the UDT array enemy(i) to hold its health, name, object number (ID) and anything else you require. Of course this will only work if you use DBP not DBC
Hello!