Merge pull request #20 from Chuck5ta/develop21
Corections made to indentations in script
This commit is contained in:
commit
a9f0925fc1
@ -138,65 +138,65 @@ struct mob_yenniku : public CreatureScript
|
|||||||
|
|
||||||
struct mob_sleeping_creature : 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 Reset() override { }
|
||||||
|
|
||||||
void UpdateAI(const uint32 uiDiff)
|
void UpdateAI(const uint32 uiDiff)
|
||||||
{
|
{
|
||||||
// no point checking for nearby creatures if the creature is in combat
|
// no point checking for nearby creatures if the creature is in combat
|
||||||
if (!m_creature->IsInCombat())
|
if (!m_creature->IsInCombat())
|
||||||
{
|
{
|
||||||
// go to sleep if it is night time (9pm to 5am)
|
// go to sleep if it is night time (9pm to 5am)
|
||||||
time_t t = sWorld.GetGameTime();
|
time_t t = sWorld.GetGameTime();
|
||||||
struct tm *tmp = gmtime(&t);
|
struct tm *tmp = gmtime(&t);
|
||||||
if (tmp->tm_hour >= 21 || tmp->tm_hour < 5)
|
if (tmp->tm_hour >= 21 || tmp->tm_hour < 5)
|
||||||
{
|
{
|
||||||
// search area for nearby player characters
|
// search area for nearby player characters
|
||||||
Map::PlayerList const& players = m_creature->GetMap()->GetPlayers();
|
Map::PlayerList const& players = m_creature->GetMap()->GetPlayers();
|
||||||
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (Player* pPlayer = itr->getSource())
|
if (Player* pPlayer = itr->getSource())
|
||||||
{
|
{
|
||||||
// ignore Game Master characters
|
// ignore Game Master characters
|
||||||
if (pPlayer->isGameMaster())
|
if (pPlayer->isGameMaster())
|
||||||
break;
|
break;
|
||||||
// Acquire player's coordinates
|
// Acquire player's coordinates
|
||||||
float fPlayerXposition = pPlayer->GetPositionX();
|
float fPlayerXposition = pPlayer->GetPositionX();
|
||||||
float fPlayerYposition = pPlayer->GetPositionY();
|
float fPlayerYposition = pPlayer->GetPositionY();
|
||||||
float fPlayerZposition = pPlayer->GetPositionZ();
|
float fPlayerZposition = pPlayer->GetPositionZ();
|
||||||
|
|
||||||
// Check if the player is near the creature
|
// 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 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))
|
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);
|
m_creature->SetStandState(UNIT_STAND_STATE_STAND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// no players nearby, therefore send the creature to sleep
|
// no players nearby, therefore send the creature to sleep
|
||||||
m_creature->SetStandState(UNIT_STAND_STATE_SLEEP);
|
m_creature->SetStandState(UNIT_STAND_STATE_SLEEP);
|
||||||
m_creature->GetMotionMaster()->MoveIdle();
|
m_creature->GetMotionMaster()->MoveIdle();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// no player character around, therefore exit script
|
// no player character around, therefore exit script
|
||||||
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
|
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// player is nearby, therefore move in and engage them in combat
|
// player is nearby, therefore move in and engage them in combat
|
||||||
m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
|
m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
|
||||||
if (m_creature->isAttackReady())
|
if (m_creature->isAttackReady())
|
||||||
{
|
{
|
||||||
DoMeleeAttackIfReady();
|
DoMeleeAttackIfReady();
|
||||||
m_creature->resetAttackTimer();
|
m_creature->resetAttackTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ struct mob_sleeping_creature : public CreatureScript
|
|||||||
|
|
||||||
CreatureAI* GetAI(Creature* pCreature) override
|
CreatureAI* GetAI(Creature* pCreature) override
|
||||||
{
|
{
|
||||||
return new mob_sleeping_creatureAI(pCreature);
|
return new mob_sleeping_creatureAI(pCreature);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user