int Dialog::FindFirstState(Scriptable* target) { for (unsigned int i = 0; i < TopLevelCount; i++) { Condition *cond = GetState( Order[i] )->condition; if (cond && cond->Evaluate(target)) { return Order[i]; } } return -1; }
int Dialog::FindRandomState(Scriptable* target) { unsigned int i; unsigned int max = TopLevelCount; if (!max) return -1; unsigned int pick = RAND(0, max-1); for (i=pick; i < max; i++) { Condition *cond = GetState(i)->condition; if (cond && cond->Evaluate(target)) { return i; } } for (i=0; i < pick; i++) { Condition *cond = GetState(i)->condition; if (cond && cond->Evaluate(target)) { return i; } } return -1; }
EBTStatus ConditionTask::update(Agent* pAgent, EBTStatus childStatus) { BEHAVIAC_UNUSED_VAR(pAgent); BEHAVIAC_UNUSED_VAR(childStatus); // EBTStatus result = BT_FAILURE; BEHAVIAC_ASSERT(Condition::DynamicCast(this->GetNode())); Condition* pConditionNode = (Condition*)(this->GetNode()); bool ret = pConditionNode->Evaluate(pAgent); return ret ? BT_SUCCESS : BT_FAILURE; }