Author Topic: GetNearestCreature  (Read 329 times)

Legacy_Calvix2

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
GetNearestCreature
« on: August 30, 2011, 07:42:05 pm »


               Hi,
tried get nearest PC that is around Enemy NPC, witch entered a trigger

object oTarget = GetNearestCreature( CREATURE_TYPE_PLAYER_CHAR , PLAYER_CHAR_IS_PC , GetEnteringObject() ,CREATURE_TYPE_IS_ALIVE, TRUE);

but always get a OBJECT_INVALID.

Any suggestion ?
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
GetNearestCreature
« Reply #1 on: August 30, 2011, 07:52:07 pm »


               object GetNearestCreature(int nFirstCriteriaType, int nFirstCriteriaValue, object oTarget=OBJECT_SELF, int nNth=1, int nSecondCriteriaType=-1, int nSecondCriteriaValue=-1, int nThirdCriteriaType=-1,  int nThirdCriteriaValue=-1 )

Looking at that, it looks like you're missing the nNth portion of it.  You'll need to add a 1 after  GetEnteringObject().

 I'm surprised it didn't give an error when you compiled it with it missing that.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
GetNearestCreature
« Reply #2 on: August 30, 2011, 07:58:28 pm »


               object oTarget = GetNearestCreature( CREATURE_TYPE_PLAYER_CHAR , PLAYER_CHAR_IS_PC , GetEnteringObject() );  


It will default to is alive
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
GetNearestCreature
« Reply #3 on: August 31, 2011, 11:03:58 am »


               

Failed.Bard wrote...

object GetNearestCreature(int nFirstCriteriaType, int nFirstCriteriaValue, object oTarget=OBJECT_SELF, int nNth=1, int nSecondCriteriaType=-1, int nSecondCriteriaValue=-1, int nThirdCriteriaType=-1,  int nThirdCriteriaValue=-1 )

Looking at that, it looks like you're missing the nNth portion of it.  You'll need to add a 1 after  GetEnteringObject().

 I'm surprised it didn't give an error when you compiled it with it missing that.

As LightFoot8 said default value for nSecondCriteriaType and nSecondCriteriaValue is PLAYER_CHAR_IS_ALIVE,TRUE, this is special behavior since 1.69. But this means that you wont find dead PC by this! If you want to find PC in any state you have to repeat the call with parameters for DEAD if you find OBJECT_INVALID.

Also I would not used GetEnteringObject() as a object to look from rather OBJECT_SELF. You cant be sure that it was NPC who entered trigger, it could be the PC you are looking for.
               
               

               


                     Modifié par ShaDoOoW, 31 août 2011 - 10:06 .