mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +00:00
Initial project location adjustment
This commit is contained in:
parent
11641a8bd7
commit
9d20fe2b32
244 changed files with 0 additions and 0 deletions
|
|
@ -1,120 +0,0 @@
|
|||
/**
|
||||
* MaNGOS is a full featured server for World of Warcraft, supporting
|
||||
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
|
||||
*
|
||||
* Copyright (C) 2005-2014 MaNGOS project <http://getmangos.eu>
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
|
||||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
||||
*/
|
||||
|
||||
#include "Creature.h"
|
||||
#include "MapManager.h"
|
||||
#include "RandomMovementGenerator.h"
|
||||
#include "Map.h"
|
||||
#include "Util.h"
|
||||
#include "movement/MoveSplineInit.h"
|
||||
#include "movement/MoveSpline.h"
|
||||
|
||||
template<>
|
||||
RandomMovementGenerator<Creature>::RandomMovementGenerator(const Creature& creature)
|
||||
{
|
||||
float respX, respY, respZ, respO, wander_distance;
|
||||
creature.GetRespawnCoord(respX, respY, respZ, &respO, &wander_distance);
|
||||
i_nextMoveTime = ShortTimeTracker(0);
|
||||
i_x = respX;
|
||||
i_y = respY;
|
||||
i_z = respZ;
|
||||
i_radius = wander_distance;
|
||||
// TODO - add support for flying mobs using some distance
|
||||
i_verticalZ = 0.0f;
|
||||
}
|
||||
|
||||
template<>
|
||||
void RandomMovementGenerator<Creature>::_setRandomLocation(Creature& creature)
|
||||
{
|
||||
const float angle = rand_norm_f() * (M_PI_F * 2.0f);
|
||||
const float range = rand_norm_f() * i_radius;
|
||||
|
||||
float destX = i_x + range * cos(angle);
|
||||
float destY = i_y + range * sin(angle);
|
||||
float destZ = i_z + frand(-1, 1) * i_verticalZ;
|
||||
creature.UpdateAllowedPositionZ(destX, destY, destZ);
|
||||
|
||||
creature.addUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||
|
||||
Movement::MoveSplineInit init(creature);
|
||||
init.MoveTo(destX, destY, destZ, true);
|
||||
init.SetWalk(true);
|
||||
init.Launch();
|
||||
|
||||
if (creature.CanFly())
|
||||
i_nextMoveTime.Reset(0);
|
||||
else
|
||||
i_nextMoveTime.Reset(urand(500, 10000));
|
||||
}
|
||||
|
||||
template<>
|
||||
void RandomMovementGenerator<Creature>::Initialize(Creature& creature)
|
||||
{
|
||||
creature.addUnitState(UNIT_STAT_ROAMING); // _MOVE set in _setRandomLocation
|
||||
|
||||
if (!creature.isAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||
return;
|
||||
|
||||
_setRandomLocation(creature);
|
||||
}
|
||||
|
||||
template<>
|
||||
void RandomMovementGenerator<Creature>::Reset(Creature& creature)
|
||||
{
|
||||
Initialize(creature);
|
||||
}
|
||||
|
||||
template<>
|
||||
void RandomMovementGenerator<Creature>::Interrupt(Creature& creature)
|
||||
{
|
||||
creature.InterruptMoving();
|
||||
creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);
|
||||
creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE), false);
|
||||
}
|
||||
|
||||
template<>
|
||||
void RandomMovementGenerator<Creature>::Finalize(Creature& creature)
|
||||
{
|
||||
creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);
|
||||
creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE), false);
|
||||
}
|
||||
|
||||
template<>
|
||||
bool RandomMovementGenerator<Creature>::Update(Creature& creature, const uint32& diff)
|
||||
{
|
||||
if (creature.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||
{
|
||||
i_nextMoveTime.Reset(0); // Expire the timer
|
||||
creature.clearUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (creature.movespline->Finalized())
|
||||
{
|
||||
i_nextMoveTime.Update(diff);
|
||||
if (i_nextMoveTime.Passed())
|
||||
_setRandomLocation(creature);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue