本文整理汇总了C++中Targets::GetFirstTarget方法的典型用法代码示例。如果您正苦于以下问题:C++ Targets::GetFirstTarget方法的具体用法?C++ Targets::GetFirstTarget怎么用?C++ Targets::GetFirstTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Targets
的用法示例。
在下文中一共展示了Targets::GetFirstTarget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetObjectLevelCount
//TODO:
//check numcreaturesatmylevel(myself, 1)
//when the actor is alone
//it should (obviously) return true if the trigger
//evaluates object filters
//also check numcreaturesgtmylevel(myself,0) with
//actor having at high level
int GetObjectLevelCount(Scriptable* Sender, Object* oC)
{
if (!oC) {
return 0;
}
// EvaluateObject will return [PC]
// GetAllObjects will also return Myself (evaluates object filters)
// i believe we need the latter here
Targets* tgts = GetAllObjects(Sender->GetCurrentArea(), Sender, oC, 0);
int count = 0;
if (tgts) {
targetlist::iterator m;
const targettype *tt = tgts->GetFirstTarget(m, ST_ACTOR);
while (tt) {
count += ((Actor *) tt->actor)->GetXPLevel(true);
tt = tgts->GetNextTarget(m, ST_ACTOR);
}
}
delete tgts;
return count;
}
示例2: MatchActor
bool MatchActor(Scriptable *Sender, ieDword actorID, Object* oC)
{
if (!Sender) {
return false;
}
Actor *ac = Sender->GetCurrentArea()->GetActorByGlobalID(actorID);
if (!ac) {
return false;
}
// [0]/[ANYONE] can match all actors
if (!oC) {
return true;
}
bool filtered = false;
// name matching
if (oC->objectName[0]) {
if (strnicmp(ac->GetScriptName(), oC->objectName, 32) != 0) {
return false;
}
filtered = true;
}
// IDS targeting
// (if we already matched by name, we don't do this)
// TODO: check distance? area? visibility?
if (!filtered && !DoObjectIDSCheck(oC, ac, &filtered)) return false;
// globalID hack should never get here
assert(oC->objectFilters[0] != -1);
// object filters
if (oC->objectFilters[0]) {
// object filters insist on having a stupid targets list,
// so we waste a lot of time here
Targets *tgts = new Targets();
int ga_flags = 0; // TODO: correct?
// handle already-filtered vs not-yet-filtered cases
// e.g. LastTalkedToBy(Myself) vs LastTalkedToBy
if (filtered) tgts->AddTarget(ac, 0, ga_flags);
tgts = DoObjectFiltering(Sender, tgts, oC, ga_flags);
if (!tgts) return false;
// and sometimes object filters are lazy and not only don't filter
// what we give them, they clear it and return a list :(
// so we have to search the whole list..
bool ret = false;
targetlist::iterator m;
const targettype *tt = tgts->GetFirstTarget(m, ST_ACTOR);
while (tt) {
Actor *actor = (Actor *) tt->actor;
if (actor->GetGlobalID() == actorID) {
ret = true;
break;
}
tt = tgts->GetNextTarget(m, ST_ACTOR);
}
delete tgts;
if (!ret) return false;
}
return true;
}