void CStateMachinen::DoPursuit(CMonster& monster, eStateEvent evt) { const BASE_MONSTER_LIST& baseMonsterList = monster.GetSMonsterList(); StateParameter& stateParamter = monster.mStateParamter; if(0 == baseMonsterList.SkillInfo[stateParamter.CurAttackKind]) { SetState( &monster, eMA_STAND); return; } else if(0 == monster.GetTObject() || (monster.GetTObject() && (eObjectState_Die == monster.GetTObject()->GetState())) || FALSE == monster.GetTObject()->GetInited()) { SetState( &monster, eMA_STAND); return; } else if( monster.GetAbnormalStatus()->IsStun || monster.GetAbnormalStatus()->IsFreezing || monster.GetAbnormalStatus()->IsStone || monster.GetAbnormalStatus()->IsSlip || monster.GetAbnormalStatus()->IsMoveStop || monster.GetAbnormalStatus()->IsParalysis ) { return; } switch(evt) { case eSEVENT_Enter: { stateParamter.PursuitForgiveStartTime = gCurTime + baseMonsterList.PursuitForgiveTime; stateParamter.nextTime = gCurTime + 1000; monster.DoPursuit(); RandCurAttackKind( baseMonsterList, stateParamter); monster.SetNoCheckCollision(TRUE); break; } case eSEVENT_Process: { VECTOR3 ObjectPos = *CCharMove::GetPosition(&monster); VECTOR3 TObjectPos = *CCharMove::GetPosition(monster.GetTObject()); DWORD Distance = 0; float fDist = CalcDistanceXZ( &ObjectPos, &TObjectPos ) - monster.GetRadius(); if( fDist > 0.f ) { Distance = (DWORD)fDist; } if( stateParamter.prePursuitForgiveTime == 0 && ( stateParamter.PursuitForgiveStartTime < gCurTime || baseMonsterList.PursuitForgiveDistance < Distance ) ) { monster.RemoveAllAggro(); stateParamter.SearchLastTime = gCurTime + 3000; //3초간 선공몹 서치를 안하게 하기 위해서. SetState( &monster, eMA_WALKAROUND); MonSpeechInfo* pTemp = MON_SPEECHMGR->GetCurStateSpeechIndex( monster.GetMonsterKind(), eMon_Speech_ForgivePursuit ); if( pTemp ) monster.AddSpeech( pTemp->SpeechType, pTemp->SpeechIndex ); } else if( Distance < baseMonsterList.SkillInfo[stateParamter.CurAttackKind]->GetInfo().Range ) { SetState( &monster, eMA_ATTACK); break; } else if( stateParamter.nextTime > gCurTime ) { break; } stateParamter.nextTime = gCurTime + 1000; monster.DoPursuit(); RandCurAttackKind( baseMonsterList, stateParamter); break; } } }
void CStateMachinen::DoStand(CMonster& monster, eStateEvent evt) { const BASE_MONSTER_LIST& baseMonsterList = monster.GetSMonsterList(); StateParameter& stateParamter = monster.mStateParamter; switch(evt) { case eSEVENT_Enter: { // 소유주가 전투중인 경우 도와주러 간다 if(CObject* const ownerObject = g_pUserTable->FindUser(monster.GetOwnerIndex())) { if(ownerObject->GetObjectBattleState() && TRUE == monster.SetTObject(ownerObject->GetTObject())) { SetState( &monster, eMA_PERSUIT); stateParamter.nextTime = gCurTime + 500; break; } } stateParamter.nextTime = gCurTime + baseMonsterList.StandTime; monster.DoStand(); if(FALSE == monster.IsNoCheckCollision()) { break; } VECTOR3 vPos = {0}; monster.GetPosition(&vPos); if(g_pServerSystem->GetMap()->CollisionTilePos( vPos.x, vPos.z, g_pServerSystem->GetMapNum())) { break; } monster.SetNoCheckCollision(FALSE); break; } case eSEVENT_Process: { if(stateParamter.nextTime > gCurTime) { break; } Mon_SpeechState speechState = eMon_Speech_MAX; const BYTE rate = BYTE(rand() % 100); if(rate < baseMonsterList.StandRate) { SetState( &monster, eMA_STAND); speechState = eMon_Speech_KeepWalkAround; } else { SetState( &monster, eMA_WALKAROUND); speechState = eMon_Speech_WalkAround; } // 100617 ONS 정지상태에서 타겟이 죽었을 경우, 배회상태로 변경한다. if( monster.GetTObject() && monster.GetTObject()->GetState() == eObjectState_Die ) { monster.SetTObject(0); SetState( &monster, eMA_WALKAROUND); } const MonSpeechInfo* const speechInfo = MON_SPEECHMGR->GetCurStateSpeechIndex( monster.GetMonsterKind(), speechState); if(0 == speechInfo) { break; } monster.AddSpeech( speechInfo->SpeechType, speechInfo->SpeechIndex); break; } } }