First Commit
For Azeroth!
This commit is contained in:
commit
e8e94a0a66
3777 changed files with 1419268 additions and 0 deletions
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright (C)
|
||||
* Copyright (C)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "HomeMovementGenerator.h"
|
||||
#include "Creature.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include "MoveSpline.h"
|
||||
|
||||
void HomeMovementGenerator<Creature>::DoInitialize(Creature* owner)
|
||||
{
|
||||
_setTargetLocation(owner);
|
||||
}
|
||||
|
||||
void HomeMovementGenerator<Creature>::DoFinalize(Creature* owner)
|
||||
{
|
||||
owner->ClearUnitState(UNIT_STATE_EVADE);
|
||||
if (arrived)
|
||||
{
|
||||
// Xinef: npc run by default
|
||||
//owner->SetWalk(true);
|
||||
owner->LoadCreaturesAddon(true);
|
||||
owner->AI()->JustReachedHome();
|
||||
}
|
||||
owner->m_targetsNotAcceptable.clear();
|
||||
owner->UpdateEnvironmentIfNeeded(2);
|
||||
}
|
||||
|
||||
void HomeMovementGenerator<Creature>::DoReset(Creature*)
|
||||
{
|
||||
}
|
||||
|
||||
void HomeMovementGenerator<Creature>::_setTargetLocation(Creature* owner)
|
||||
{
|
||||
// Xinef: dont interrupt in any cast!
|
||||
//if (owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED))
|
||||
// return;
|
||||
Movement::MoveSplineInit init(owner);
|
||||
float x, y, z, o;
|
||||
|
||||
// Xinef: if there is motion generator on controlled slot, this one is not updated
|
||||
// Xinef: always get reset pos from idle slot
|
||||
MovementGenerator* gen = owner->GetMotionMaster()->GetMotionSlot(MOTION_SLOT_IDLE);
|
||||
if (owner->GetMotionMaster()->empty() || !gen || !gen->GetResetPosition(x, y, z))
|
||||
{
|
||||
owner->GetHomePosition(x, y, z, o);
|
||||
init.SetFacing(o);
|
||||
}
|
||||
|
||||
init.MoveTo(x, y, z, MMAP::MMapFactory::IsPathfindingEnabled(owner->FindMap()), true);
|
||||
init.SetWalk(false);
|
||||
init.Launch();
|
||||
|
||||
arrived = false;
|
||||
|
||||
owner->ClearUnitState(uint32(UNIT_STATE_ALL_STATE & ~(UNIT_STATE_POSSESSED | UNIT_STATE_EVADE | UNIT_STATE_IGNORE_PATHFINDING | UNIT_STATE_NO_ENVIRONMENT_UPD)));
|
||||
}
|
||||
|
||||
bool HomeMovementGenerator<Creature>::DoUpdate(Creature* owner, const uint32 /*time_diff*/)
|
||||
{
|
||||
arrived = owner->movespline->Finalized();
|
||||
if (arrived)
|
||||
return false;
|
||||
|
||||
if (i_recalculateTravel)
|
||||
{
|
||||
_setTargetLocation(owner);
|
||||
i_recalculateTravel = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue