本文整理汇总了C++中CMonster::GetFather方法的典型用法代码示例。如果您正苦于以下问题:C++ CMonster::GetFather方法的具体用法?C++ CMonster::GetFather怎么用?C++ CMonster::GetFather使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMonster
的用法示例。
在下文中一共展示了CMonster::GetFather方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckTracer
bool FightStateScript::CheckTracer(BaseType::EntityType *entity)
{
if(m_State == TRACING)
{
int ret = m_SkillTracer.Run(entity);
if(ret == SkillTracer::TIMEOUT ||
ret == SkillTracer::FAILED)
{
OnUseSkillEnd(ret);
}
if(ret == SkillTracer::Okay)
{
MonsterAI *ai = dynamic_cast<MonsterAI*>(entity);
CMonster *monster = dynamic_cast<CMonster*>(entity->GetOwner());
CServerRegion *region = dynamic_cast<CServerRegion*>(monster->GetFather());
CMoveShape *target = AIUtils::FindShape(region, m_SkillTracer.m_TargetID);
if(target == NULL)
{
OnUseSkillEnd(SkillTracer::FAILED);
}
else
{
ai->BeginSkill(m_SkillTracer.m_SkillID, m_SkillTracer.m_SkillLvl, target);
long actTime = monster->GetActModify(m_SkillTracer.m_SkillID);
ai->SetTimer(AIDriver::SCRIPT_EVENT, actTime);
}
}
return true;
}
return false;
}
示例2: Execute
void GuardSearch::Execute( BaseType::EntityType *entity )
{
CMonster *pSelf = dynamic_cast<CMonster*>( entity->GetOwner() );
ShapeListType player_list;
ShapeListType monster_list;
CServerRegion *pRegion = static_cast<CServerRegion*>( pSelf->GetFather() );
CMoveShape *pTarget = NULL;
if( CanAttackCurrent( pSelf, entity ) )
{
return;
}
// find the around players
pRegion->FindAroundObject( pSelf, TYPE_PLAYER, player_list );
// find the around monsters including the guards.
pRegion->FindAroundObject( pSelf, TYPE_MONSTER, monster_list );
// filter the result
Filter filter( static_cast<CMonster*>( pSelf ) );
filter_shape( player_list, filter );
filter_shape( monster_list, filter );
// retrieve the ai reference
DWORD ai_ref = pSelf->GetAIReferrence( 0 );
if( ai_ref >= 0 )
{
pTarget = SearchByAIRef1( pSelf, player_list, ai_ref );
}
if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 1 ) ) > 0 )
{
pTarget = SearchByAIRef2( pSelf, player_list, ai_ref );
}
if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 2 ) ) > 0 )
{
pTarget = SearchByAIRef3( pSelf, monster_list, ai_ref );
}
if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 3 ) ) > 0 )
{
pTarget = SearchByAIRef4( pSelf, monster_list, ai_ref );
}
if( pTarget != NULL )
{
// search successfully
entity->SetTarget( pTarget->GetExID(), pTarget->GetType() );
}
else if( entity->HasTarget() )
{
AI_EVENT_SENDER( entity ).ReturnPeace();
}
}
示例3: ReceiveEvent
void FightStateScript::ReceiveEvent(BaseType::EntityType *entity, const BaseType::EventType &ev)
{
SelfType::ReceiveEvent(entity, ev);
if(ev.Type() == ET_SCRIPT_USESKILL)
{
const ScriptUseSkillEvent &sev = (const ScriptUseSkillEvent&) ev;
CMonster *monster = dynamic_cast<CMonster*>(entity->GetOwner());
CServerRegion *region = dynamic_cast<CServerRegion*>(monster->GetFather());
MonsterAI *ai = dynamic_cast<MonsterAI*>(entity);
long id = sev.id;
long lvl = sev.lvl;
long actTime = monster->GetActModify(sev.id);
if(sev.type == ScriptUseSkillEvent::SHAPE)
{
if(sev.trace)
{
// trace the target
m_SkillTracer.Init(id, lvl, sev.targetId, sev.traceTime);
m_skillScriptID = sev.scriptId;
m_State = TRACING;
entity->Resume(0);
return ;
}
else
{
CMoveShape *target = AIUtils::FindShape(region, sev.targetId);
if(target == NULL)
{
OnUseSkillEnd(SkillTracer::FAILED);
return ;
}
ai->BeginSkill(id, lvl, target);
}
}
else if(sev.type == ScriptUseSkillEvent::CELL)
{
ai->BeginSkill(id, lvl, sev.x, sev.y);
}
m_skillScriptID = sev.scriptId;
// register act time timer
ai->SetTimer(AIDriver::SCRIPT_EVENT, actTime);
}
else if(ev.Type() == ET_SCRIPT_SKILLEND)
{
OnUseSkillEnd(SkillTracer::Okay);
}
else if(ev.Type() == ET_KILL)
{
entity->ChangeState(ST_DEAD);
}
}