If I say this in a open loop
+ Code SnippetFor x=AllEnemys.length to 0 Step -1
AllEnemys[x].Distance=getDistance(GloabPower,AllEnemys[x].ID)
print(AllEnemys[x].HitPoints)
if AllEnemys[x].Distance<20
dec AllEnemys[x].HitPoints,5
endif
next x
Only one enemy looses health, is not the reason for a array to hold information for many objects and there health and other things?
but I find in many, many times there are errors in the array. Here it is being made.
+ Code Snippettype Enemys
ID
Image
imageS
imageN
PosX
PosY
posZ
Anim
Power
HitPoints
HitPointsObject
InBattle
Selected
Hp
Distance
endtype
dim AllEnemys[] as Enemys
global ThisEnemy as Enemys
And here is when I load in my enemies
+ Code Snippet // Load character for our enemies
for x=0 to 1
ThisEnemy.ID = LoadObjectWithChildren("models\minos\orc.fbx")
ThisEnemy.Image = LoadImage("models\minos\minos_1_D2.png")
ThisEnemy.imageS= LoadImage("models\minos\minos_1_S.png")
ThisEnemy.HitPointsObject=CreateObjectPlane(5,5)
setobjectimage(ThisEnemy.ID,ThisEnemy.Image ,0)
setobjectimage(ThisEnemy.ID,ThisEnemy.ImageS,2)
SetObjectScalePermanent(ThisEnemy.ID,0.3,0.3,0.3)
RotateObjectLocalY(ThisEnemy.ID,180)
FixObjectPivot(ThisEnemy.ID)
SetObjectLightMode(ThisEnemy.ID,1)
ThisEnemy.PosX=random(2200,2280)
ThisEnemy.posZ=random(3600,3680)
ThisEnemy.PosY=GetObjectHeightMapHeight( terrain,ThisEnemy.PosX,ThisEnemy.PosZ)
SetObjectPosition(ThisEnemy.ID,ThisEnemy.PosX, ThisEnemy.PosY,ThisEnemy.posZ)
SetObjectPosition(ThisEnemy.HitPointsObject,ThisEnemy.PosX, ThisEnemy.PosY+24,ThisEnemy.posZ)
SetObjectImage(ThisEnemy.HitPointsObject,HealthImages,0)
SetObjectTransparency(ThisEnemy.HitPointsObject, 1)
PlayObjectAnimation(ThisEnemy.ID, "", 1,160, 1, 0.1 ) // idle
SetObjectAnimationSpeed(ThisEnemy.ID,30)
ThisEnemy.HitPoints=100
ThisEnemy.Power=20
AllEnemys.Insert(ThisEnemy)
next x
So I do not know why it will not see my other object in the array, It only addresses the one other loaded object.