Merge pull request #20 from Chuck5ta/develop21

Corections made to indentations in script
This commit is contained in:
Charles A Edwards 2015-05-17 21:36:18 +01:00
commit a9f0925fc1

View File

@ -138,65 +138,65 @@ struct mob_yenniku : public CreatureScript
struct mob_sleeping_creature : public CreatureScript
{
mob_sleeping_creature() : CreatureScript("mob_sleeping_creature") {}
mob_sleeping_creature() : CreatureScript("mob_sleeping_creature") {}
struct mob_sleeping_creatureAI : public ScriptedAI
struct mob_sleeping_creatureAI : public ScriptedAI
{
mob_sleeping_creatureAI(Creature* pCreature) : ScriptedAI(pCreature) { }
mob_sleeping_creatureAI(Creature* pCreature) : ScriptedAI(pCreature) { }
void Reset() override { }
void UpdateAI(const uint32 uiDiff)
{
// no point checking for nearby creatures if the creature is in combat
if (!m_creature->IsInCombat())
{
// go to sleep if it is night time (9pm to 5am)
time_t t = sWorld.GetGameTime();
struct tm *tmp = gmtime(&t);
if (tmp->tm_hour >= 21 || tmp->tm_hour < 5)
{
// search area for nearby player characters
Map::PlayerList const& players = m_creature->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* pPlayer = itr->getSource())
{
// ignore Game Master characters
if (pPlayer->isGameMaster())
break;
// Acquire player's coordinates
float fPlayerXposition = pPlayer->GetPositionX();
float fPlayerYposition = pPlayer->GetPositionY();
float fPlayerZposition = pPlayer->GetPositionZ();
void UpdateAI(const uint32 uiDiff)
{
// no point checking for nearby creatures if the creature is in combat
if (!m_creature->IsInCombat())
{
// go to sleep if it is night time (9pm to 5am)
time_t t = sWorld.GetGameTime();
struct tm *tmp = gmtime(&t);
if (tmp->tm_hour >= 21 || tmp->tm_hour < 5)
{
// search area for nearby player characters
Map::PlayerList const& players = m_creature->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* pPlayer = itr->getSource())
{
// ignore Game Master characters
if (pPlayer->isGameMaster())
break;
// Acquire player's coordinates
float fPlayerXposition = pPlayer->GetPositionX();
float fPlayerYposition = pPlayer->GetPositionY();
float fPlayerZposition = pPlayer->GetPositionZ();
// Check if the player is near the creature
// If a player is nearby, then we do not need to check other player locations, therefore stop checking - break out of this
if (pPlayer->IsNearWaypoint(fPlayerXposition, fPlayerYposition, fPlayerZposition, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 4, 4, 4))
{
m_creature->SetStandState(UNIT_STAND_STATE_STAND);
return;
}
}
}
// no players nearby, therefore send the creature to sleep
m_creature->SetStandState(UNIT_STAND_STATE_SLEEP);
m_creature->GetMotionMaster()->MoveIdle();
// Check if the player is near the creature
// If a player is nearby, then we do not need to check other player locations, therefore stop checking - break out of this
if (pPlayer->IsNearWaypoint(fPlayerXposition, fPlayerYposition, fPlayerZposition, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 4, 4, 4))
{
m_creature->SetStandState(UNIT_STAND_STATE_STAND);
return;
}
}
}
// no players nearby, therefore send the creature to sleep
m_creature->SetStandState(UNIT_STAND_STATE_SLEEP);
m_creature->GetMotionMaster()->MoveIdle();
}
}
}
}
// no player character around, therefore exit script
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
// no player character around, therefore exit script
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
// player is nearby, therefore move in and engage them in combat
m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
if (m_creature->isAttackReady())
{
DoMeleeAttackIfReady();
m_creature->resetAttackTimer();
}
// player is nearby, therefore move in and engage them in combat
m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
if (m_creature->isAttackReady())
{
DoMeleeAttackIfReady();
m_creature->resetAttackTimer();
}
}
@ -204,7 +204,7 @@ struct mob_sleeping_creature : public CreatureScript
CreatureAI* GetAI(Creature* pCreature) override
{
return new mob_sleeping_creatureAI(pCreature);
return new mob_sleeping_creatureAI(pCreature);
}
};