本文整理汇总了C++中CMonster类的典型用法代码示例。如果您正苦于以下问题:C++ CMonster类的具体用法?C++ CMonster怎么用?C++ CMonster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CMonster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoScriptMove
void CStateMachinen::DoScriptMove(CMonster& monster, eStateEvent event)
{
StateParameter& stateParamter = monster.mStateParamter;
switch(event)
{
case eSEVENT_Enter:
{
VECTOR3 position = {
float(monster.GetFiniteStateMachine().GetMemory().GetVariable("__move_x__")),
0,
float(monster.GetFiniteStateMachine().GetMemory().GetVariable("__move_z__")),
};
monster.OnMove(
&position);
stateParamter.nextTime = gCurTime + CCharMove::GetMoveEstimateTime(
&monster);
break;
}
case eSEVENT_Process:
{
if( stateParamter.nextTime > gCurTime )
{
break;
}
SetState(
&monster,
eMA_STAND);
break;
}
}
}
示例2: OnUseSkillEnd
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;
}
示例3: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
// 注册错误回调函数
FKAISystem::RegisterErrorMsgReceiver( OutPut );
// 初始化状态机表
FKAISystem::SetStateFilesDirectory( "Bin/Data/AIScript" );
CMonster* pMonster = new CMonster();
pMonster->Init("状态机表名称");
for( ;; )
{
// 获取帧间隔时间
static float lastTime = 0;
lastTime = g_fAccumTime;
g_fAccumTime = (float)timeGetTime() / 1000.0f;
g_fTimeFromLastFrame = g_fAccumTime - lastTime;
//最低帧数控制
if (g_fTimeFromLastFrame>0.2f)
g_fTimeFromLastFrame = 0.2f;
// 每帧间隔CPU休眠时间
if(g_dwSleepTime > 0) Sleep(g_dwSleepTime);
pMonster->Update( g_fTimeFromLastFrame );
}
pMonster->Destory();
return 0;
}
示例4: CMonster
bool CObjectManager::Start()
{
for (int i = 0; i < MAX_MONSTER; ++i)
{
CMonster *pMonster = new CMonster();
//pMonster->Initalize(); // Warning : Initalize -> Clear -> SetIndex 순서 바뀌면 안됨
pMonster->SetIndex(i);
InsertMonsterToMap(i, pMonster);
//if (0 == i)
//{
// pMonster->SetMonsterType(MonsterType::MONSTER_TYPE_END);
// continue; // 0은 더미 NPC라서 풀에 넣을 필요없음
//}
//else if (i < DEFENDER_MONSTER_START)
//{
// pMonster->SetMonsterType(MonsterType::ATTACKER);
//}
//else if (i < SURPPORT_MONSTER_START)
//{
// pMonster->SetMonsterType(MonsterType::DEFENDER);
//}
//else
//{
// pMonster->SetMonsterType(MonsterType::SUPPORTER);
//}
if (0 == i) continue;
m_monsterPool.push(pMonster);
}
return true;
}
示例5: DoPause
void CStateMachinen::DoPause(CMonster& monster, eStateEvent event)
{
StateParameter& stateParamter = monster.mStateParamter;
switch(event)
{
case eSEVENT_Enter:
{
const DWORD pausedTick = monster.GetFiniteStateMachine().GetMemory().GetVariable(
"__tick__");
stateParamter.nextTime = gCurTime + pausedTick;
break;
}
case eSEVENT_Process:
{
if(gCurTime > stateParamter.nextTime)
{
const eMONSTER_ACTION pausedAction = eMONSTER_ACTION(monster.GetFiniteStateMachine().GetMemory().GetVariable(
"__lastState__"));
SetState(
&monster,
pausedAction);
}
break;
}
}
}
示例6: LogError
void SummonDeadState::Execute(BaseType::EntityType *entity)
{
if (entity == NULL)
{
LogError(AI_MODULE, "entity object is null.");
return;
}
CMonster *monster = static_cast<CMonster*>(entity->GetOwner());
monster->AddDelEvent(0);
}
示例7: skillDamage
void CPlayer::skillDamage(AdvancedAttribute targetAttr)
{
CMonster *pTargetMonster = dynamic_cast<CMonster *>(getTargetObject());
if(pTargetMonster != NULL)
{
AdvancedAttribute monsterAdv = pTargetMonster->getAdvAttr();
pTargetMonster->addHate(getUID(), targetAttr.iHP - monsterAdv.iHP);
}
CUnitObject::skillDamage(targetAttr);
}
示例8: Process
//*****************************************************************************************
void CAnt::Process(
//Process an ant for movement.
//Params:
const int /*nLastCommand*/, //(in) Last swordsman command.
CCueEvents &CueEvents) //(in/out) Accepts pointer to a cues object that will be populated
//with codes indicating events that happened that may correspond to
//sound or graphical effects.
{
//If another monster has already got the player, don't move this one there too.
if (CueEvents.HasOccurred(CID_MonsterKilledPlayer))
return;
//Decide where to move to.
UINT wSX, wSY;
if (!GetTarget(wSX,wSY))
return;
//If next to the target then jump out and kill it.
//The ant is not killed, but is largely immobile out of water.
if (abs(static_cast<int>(this->wX - wSX)) <= 1 && abs(static_cast<int>(this->wY - wSY)) <= 1)
{
bool bAttack = this->pCurrentGame->IsPlayerAt(wSX, wSY);
if (!bAttack)
{
CMonster *pMonster = this->pCurrentGame->pRoom->GetMonsterAtSquare(wSX, wSY);
if (pMonster && pMonster->IsAttackableTarget())
bAttack = true;
}
if (bAttack)
{
//Move onto target if possible.
const int dx = wSX - this->wX;
const int dy = wSY - this->wY;
const UINT wOSquare = this->pCurrentGame->pRoom->GetOSquare(wSX,wSY);
if (!(bIsWall(wOSquare) || bIsCrumblyWall(wOSquare) || bIsDoor(wOSquare) ||
DoesArrowPreventMovement(dx, dy) ||
this->pCurrentGame->pRoom->DoesSquarePreventDiagonal(this->wX, this->wY, dx, dy)))
{
MakeStandardMove(CueEvents, dx, dy);
SetOrientation(dx, dy);
return;
}
}
}
//Get movement offsets.
int dxFirst, dyFirst, dx, dy;
if (!GetDirectMovement(wSX, wSY, dxFirst, dyFirst, dx, dy))
return;
//Move roach to new destination square.
MakeStandardMove(CueEvents,dx,dy);
SetOrientation(dxFirst, dyFirst);
}
示例9: CMonster
void CGameProc::Loaddata()
{
int nMonsterCnt;
nMonsterCnt=GetPrivateProfileInt("map0","monstercnt",0,"data\\map.txt");
for (int i=0;i<nMonsterCnt;i++)
{
CMonster *pMonster;
pMonster=new CMonster();
pMonster->Create(i,m_pD3DDevice);
m_xMonsterList.MoveCurrentToTop();
m_xMonsterList.AddNode(pMonster);
}
}
示例10: 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);
}
}
示例11: CMonster
void CMonsterGen::OnLoop() {
if(MeatGen(rate) && monsterCount < monsterMax) {
CMonster* monsterPiece = new CMonster();
if (monsterPiece->OnLoad("monster.png", 64, 64, 8) == false) {
return;
}
monsterPiece->X = SDL_GetTicks()%624 + (rand()%500);
monsterPiece->Y = SDL_GetTicks()%300 + (rand()%400);
monsterPiece->ID = 1337*(monsterType) + meatID;
meatID++;
monsterCount++;
CEntity::EntityList.push_back(monsterPiece);
}
}
示例12: FindMonster
void CObjectManager::DeleteMonster(const UINT id)
{
CMonster* pMon = FindMonster(id);
if (m_monsterMappingHashMap.erase(id))
{
//#ifdef _DEBUG
//cout << "CObjectManager Mapping HashMap -> Monster Erase : " << id << endl;
//#endif
}
InsertMonsterToPool(pMon);
pMon->Clear();
}
示例13: EscapeSpring
void MonsterAI::EscapeSpring()
{
CMonster *monster = static_cast<CMonster*>(GetOwner());
if (monster == NULL)
{
LogError(AI_MODULE, "MosterAI has no owner object...");
return;
}
if(monster->GetHP() * 100.0f / monster->GetMaxHP() <= monster->GetEscapePoint())
{
// change to escape state
ChangeState(ST_ESCAPE);
}
}
示例14: AddDamage
//LMA: moving to long long...
//void CMonster::AddDamage( CCharacter* enemy, long long hitpower)
void CMonster::AddDamage( CCharacter* enemy, long long hitpower)
{
//Log(MSG_INFO,"In CMonster::AddDamage");
CPlayer* player = NULL;
if(enemy->IsMonster( ))
{
CMonster* monster = (CMonster*) enemy;
if(!enemy->IsSummon( )) return;
player = monster->GetOwner( );
if(player==NULL) return;
}
else
{
player = (CPlayer*) enemy;
}
if(MonsterDrop->firsthit==0 && hitpower > 0)
{
MonsterDrop->firsthit = player->CharInfo->charid;
MonsterDrop->firstlevel = player->Stats->Level;
if( player->Party->party!=NULL )
thisparty = player->Party->party;
else
thisparty = NULL;
}
for(UINT i=0;i<PlayersDamage.size();i++)
{
MonsterDamage* thisplayer = PlayersDamage.at(i);
if(thisplayer->charid == player->CharInfo->charid)
{
if( hitpower > Stats->HP )
{
//hitpower += (long int)Stats->HP + (long int)( Stats->HP * 0.10 );
hitpower += Stats->HP + (long long) ( Stats->HP * 0.10 );
}
thisplayer->damage += hitpower;
return;
}
}
MonsterDamage* newplayer = new MonsterDamage;
newplayer->charid = player->CharInfo->charid;
if( hitpower > Stats->HP )
{
//hitpower += (long int)Stats->HP + (long int)( Stats->HP * 0.10 );
hitpower += Stats->HP + (long long)( Stats->HP * 0.10 );
}
newplayer->damage = hitpower;
PlayersDamage.push_back( newplayer );
}
示例15: IsValidOper
static int IsValidOper( CShopManager *pShopMgr, CMessage *pMsg, const CGUID &npcID, long lShopID )
{
CPlayer *pPlayer = pMsg->GetPlayer();
CServerRegion *pRegion = pMsg->GetRegion();
if( pPlayer == NULL || pRegion == NULL )
{
return -2;
}
if( pPlayer->IsDied() )
{
return -1;
}
if( pPlayer->GetCurrentProgress() != CPlayer::PROGRESS_FBUSINESS )
{
PutoutLog( LOG_FILE, LT_WARNING, "The Player [%s] is not in PROGRESS_FBUSINESS state.",
pPlayer->GetName() );
return -1;
}
SetPlayerState( pPlayer, true );
CMonster *pNPC = (CMonster*) pRegion->FindAroundObject( pPlayer, TYPE_MONSTER, npcID );
if( pNPC == NULL )
{
return -1;
}
CShop *pShop = pShopMgr->GetShop( lShopID );
if( pShop == NULL )
{
return -1;
}
// NPC是否与商店对应
if( strcmp( pNPC->GetOriginName(), pShop->GetNpcOrigName() ) != 0 )
{
return -1;
}
if( pNPC->Distance( pPlayer ) > 10 )
{
return -1;
}
return 0;
}