Author Topic: GetNearestCreature question  (Read 415 times)

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
GetNearestCreature question
« on: November 14, 2010, 06:56:01 pm »


               Has anyone tried using bits for constants there? Does it work?

For example I need to get creature that OBJECT_SELF either see or hear (ha, anothere question does by "heard" mean "spotted by listen skill" ?). But there isn't PERCEPTION_TYPE_SEEN_OR_HEARD constant. So I thought I will use PERCEPTION_TYPE_SEEN|PERCEPTION_TYPE_HEARD. But testing this is quite difficult...
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
GetNearestCreature question
« Reply #1 on: November 14, 2010, 07:53:22 pm »


               

ShaDoOoW wrote...

Has anyone tried using bits for constants there? Does it work?

For example I need to get creature that OBJECT_SELF either see or hear (ha, anothere question does by "heard" mean "spotted by listen skill" ?). But there isn't PERCEPTION_TYPE_SEEN_OR_HEARD constant. So I thought I will use PERCEPTION_TYPE_SEEN|PERCEPTION_TYPE_HEARD. But testing this is quite difficult...



int PERCEPTION_SEEN_AND_HEARD           = 0;
int PERCEPTION_NOT_SEEN_AND_NOT_HEARD   = 1;
int PERCEPTION_HEARD_AND_NOT_SEEN       = 2;
int PERCEPTION_SEEN_AND_NOT_HEARD       = 3;
int PERCEPTION_NOT_HEARD                = 4;
int PERCEPTION_HEARD                    = 5;
int PERCEPTION_NOT_SEEN                 = 6;
int PERCEPTION_SEEN                     = 7;

Lets first look at the two Perscptions you are asking about


int PERCEPTION_SEEN                      = 7;  or in binary  0000_0111
int PERCEPTION_HEARD                    = 5; or in binary  0000_0101 

So  PERCEPTION_SEEN | PERCEPTION_HEARD is the same as saying 
 0000_0111 |   0000_0101  =  0000_0111  OR    7 | 5 = 7    

So saying  PERCEPTION_SEEN | PERCEPTION_HEARD  =  PERCEPTION_SEEN

So no that will not work. 

I think I would end up useing
int i=0;
do
{
   i++;
   oTarget =GetNearestObject(OBJECT_TYPE_CREATURE,OBJECT_SELF,i);
   If (GetIsSeen(oTarget) || GetIsHeard(oTarget)) break;
}
while(GetIsObjectValid(oTarget));  
               
               

               


                     Modifié par Lightfoot8, 14 novembre 2010 - 11:55 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
GetNearestCreature question
« Reply #2 on: November 14, 2010, 08:59:41 pm »


               Does not work then, thanks.