Aller au contenu

Photo

How to Eliminate Hostile Non-Creatures From Enemy Check


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
Morbane

Morbane
  • Members
  • 1 883 messages
 I am using the CheckEnemyGroupingOnTarget() function to total up the number of targets within a radius of 10 m of the PC. I think that function checks for ANY hostile object - including Placeables...

I tried the snippet below to exclude all but OBJECT_TYPE_CREATURE.

object oEnemy = GetFirstObjectInShape(SHAPE_SPHERE, 10.0f, lSelf, TRUE, OBJECT_TYPE_CREATURE); while(GetIsObjectValid(oEnemy))
{
nEnemyCount = CheckEnemyGroupingOnTarget(oSelf, 10.0f);

oEnemy = GetNextObjectInShape(SHAPE_SPHERE, 10.0f, lSelf, TRUE, OBJECT_TYPE_CREATURE);
}

But it is not working - at least as far as recognising a single creature in a room full of placeables. I am trying really hard to avoid making every placeable in the game Faction: Friendly.

Any suggestions or solutions are welcomed.

Modifié par Morbane, 14 septembre 2010 - 03:49 .


#2
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
I'm not sure why you need to use the CheckEnemyGroupingOnTarget inside the while.



Try:

int nEnemyCount = 0;

object oEnemy = GetFirstObjectInShape(SHAPE_SPHERE, 10.0f, lSelf, TRUE, OBJECT_TYPE_CREATURE);

while(GetIsObjectValid(oEnemy))

{

nEnemyCount += GetIsEnemy(oEnemy);

oEnemy = GetNextObjectInShape(SHAPE_SPHERE, 10.0f, lSelf, TRUE, OBJECT_TYPE_CREATURE);

}



Regards


#3
Morbane

Morbane
  • Members
  • 1 883 messages

Kaldor Silverwand wrote...

I'm not sure why you need to use the CheckEnemyGroupingOnTarget inside the while.


It was the only way I could figure to check all creatures.

The CheckEnemyGroupingOnTarget() was working fine without the loop but it was picking up many enemies instead of just the one I was testing with.

I just assumed that it was picking up hostile placeables.?

Modifié par Morbane, 14 septembre 2010 - 06:17 .


#4
Morbane

Morbane
  • Members
  • 1 883 messages
Thanks Kaldor  :whistle:

Modifié par Morbane, 15 septembre 2010 - 05:47 .