Aller au contenu

Photo

Prioritizing Targets


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

#1
Imperator

Imperator
  • Members
  • 64 messages

Is there a way to further specify in general which things you want a creature to target with using an object?

 

I'd like to have the NPC that I'm working on target players first always before regular mobs/summons.

In addition to that I'd like it to go for things that are wizards/sorcerers, then clerics/druids, then all the rest after that.

 

Can I fit that all into the object oTarget like what I have down below?

 

 

object oTarget = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY | !REPUTATION_TYPE_NEUTRAL | !REPUTATION_TYPE_FRIEND , OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
 



#2
Baaleos

Baaleos
  • Members
  • 1 322 messages

PLAYER_CHAR_IS_PC    - If you use this flag, it will only target Players.

You can then say, if oTarget ==OBJECT_INVALID, then target NPC's instead.

Getting a single call that uses NPC's as a failsafe and Players as a pirority is unlikely.

You will need to call the method twice: but you can wrap it in your own method, to make it a single call in your script.

 

 

http://www.nwnlexico...NearestCreature


  • Imperator aime ceci

#3
KMdS!

KMdS!
  • Members
  • 189 messages

Here is something that may get you what you want.

 
// Will only return a target if they have mage or priest levels, are alive,
// can be seen, and are an enemy. Otherwise returns OBJECTINVALID.
// Mage levels are weighted for.
// Only PC's, Henchmen, and Dominated types are concidered.
object PriorityTarget()
{
    object oTarget = OBJECT_INVALID;
    int nCount = 1;
    object oCantidate = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, nCount, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN, CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY );
    while(GetIsObjectValid(oCantidate))
    {
        int PriorityLevel = 0;
        if(GetMaster(oCantidate) == OBJECT_INVALID || GetAssociateType(oCantidate) == ASSOCIATE_TYPE_HENCHMAN|| GetAssociateType(oCantidate) == ASSOCIATE_TYPE_DOMINATED)
        {
            int SorcerorLavels  = GetLevelByClass(CLASS_TYPE_SORCERER)*2;
            int WizardLavels    = GetLevelByClass(CLASS_TYPE_WIZARD)*2;
            int ClericLevels    = GetLevelByClass(CLASS_TYPE_CLERIC);
            int DruidLavels     = GetLevelByClass(CLASS_TYPE_DRUID);
 
            int CandidatePriorityLevel = SorcerorLavels+WizardLavels+ClericLevels+DruidLavels;
            if(CandidatePriorityLevel > PriorityLevel)
                oTarget = oCantidate;
        }
        oCantidate = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, ++nCount, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN, CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY );
    }
    return oTarget;
}

  • Imperator aime ceci

#4
Imperator

Imperator
  • Members
  • 64 messages

thanks for the replies, very helpful as always :)