本文整理汇总了C++中CMonster::PlayerInRange方法的典型用法代码示例。如果您正苦于以下问题:C++ CMonster::PlayerInRange方法的具体用法?C++ CMonster::PlayerInRange怎么用?C++ CMonster::PlayerInRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMonster
的用法示例。
在下文中一共展示了CMonster::PlayerInRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MapProcess
// Map Process
PVOID MapProcess( PVOID TS )
{
bool only_npc = false;
while(GServer->ServerOnline)
{
pthread_mutex_lock( &GServer->PlayerMutex );
pthread_mutex_lock( &GServer->MapMutex );
for(UINT i=0;i<GServer->MapList.Map.size();i++)
{
CMap* map = GServer->MapList.Map.at(i);
if( map->PlayerList.size()<1 )
only_npc = true;
else
only_npc = false;
//continue;
if(!only_npc)
{
// Player update //------------------------
for(UINT j=0;j<map->PlayerList.size();j++)
{
CPlayer* player = map->PlayerList.at(j);
if(!player->Session->inGame) continue;
if(player->IsDead( )) continue;
//if(player->UpdateValues( ))
player->UpdatePosition( );
if(player->IsOnBattle( ))
player->DoAttack( );
player->RefreshBuff( );
player->PlayerHeal( );
player->Regeneration( );
player->CheckPlayerLevelUP( );
if( GServer->Config.AUTOSAVE == 1 )
{
clock_t etime = clock() - player->lastSaveTime;
if( etime >= GServer->Config.SAVETIME*1000 )
{
player->savedata( );
player->lastSaveTime = clock();
}
}
}
// Monster update //------------------------
pthread_mutex_lock( &map->MonsterMutex );
for(UINT j=0;j<map->MonsterList.size();j++)
{
CMonster* monster = map->MonsterList.at(j);
UINT thistimer = monster->AItimer;
if(monster->hitcount == 0xFF)//this is a delay for new monster spawns this might olso fix invisible monsters(if they attack directly on spawning the client dosn't get the attack packet(its not in it's visible list yet))
{
if(thistimer < (UINT)GServer->round((clock( ) - monster->lastAiUpdate)))
{
monster->hitcount = 0;
//monster->DoAi(monster->thisnpc->AI, 0);
monster->DoAi(monster->monAI, 0);
monster->lastAiUpdate=clock();
}
}
//still need this for special spawns
if(!map->IsNight( ) && monster->Status->nightonly)// if day, delete all night time monsters
{
//Log( MSG_INFO, "Night Only monster deleted. Type %i", monster->montype);
map->DeleteMonster( monster, true, j );
continue;
}
if(map->IsNight() && monster->Status->dayonly)
{
//Log( MSG_INFO, "Day Only monster deleted. Type %i", monster->montype);
map->DeleteMonster( monster, true, j );
continue;
}
if(!monster->PlayerInRange( )) continue;
if(!monster->UpdateValues( )) continue;
monster->UpdatePosition( );
if(monster->IsOnBattle( ))
{
//monster->DoAttack( );
if(thistimer<(UINT)GServer->round((clock( ) - monster->lastAiUpdate)))
{
//monster->DoAi(monster->thisnpc->AI, 2);
monster->DoAi(monster->monAI, 2);
monster->lastAiUpdate = clock();
//Log(MSG_INFO,"Monster type: %i current HP: %i",monster->montype, monster->Stats->HP);
}
else
{
//Log(MSG_INFO,"Monster doing attack");
monster->DoAttack( );
}
}
else if(!monster->IsOnBattle() && !monster->IsDead( ))
{
if(thistimer<(UINT)GServer->round((clock( ) - monster->lastAiUpdate)))
{
//monster->DoAi(monster->thisnpc->AI, 1);
monster->DoAi(monster->monAI, 1);
monster->lastAiUpdate = clock();
}
//.........这里部分代码省略.........