本文整理汇总了C++中Creature::AddUnitState方法的典型用法代码示例。如果您正苦于以下问题:C++ Creature::AddUnitState方法的具体用法?C++ Creature::AddUnitState怎么用?C++ Creature::AddUnitState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Creature
的用法示例。
在下文中一共展示了Creature::AddUnitState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnTrigger
bool OnTrigger(Player* player, AreaTriggerEntry const* /* trigger */)
{
if (player->GetQuestStatus(QUEST_THE_LONESOME_WATCHER) != QUEST_STATUS_INCOMPLETE)
return false;
Creature* stormforgedMonitor = Creature::GetCreature(*player, stormforgedMonitorGUID);
if (stormforgedMonitor)
return false;
Creature* stormforgedEradictor = Creature::GetCreature(*player, stormforgedEradictorGUID);
if (stormforgedEradictor)
return false;
stormforgedMonitor = player->SummonCreature(NPC_STORMFORGED_MONITOR, stormforgedMonitorPosition, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
if (stormforgedMonitor)
{
stormforgedMonitorGUID = stormforgedMonitor->GetGUID();
stormforgedMonitor->SetWalk(false);
/// The npc would search an alternative way to get to the last waypoint without this unit state.
stormforgedMonitor->AddUnitState(UNIT_STATE_IGNORE_PATHFINDING);
stormforgedMonitor->GetMotionMaster()->MovePath(NPC_STORMFORGED_MONITOR * 100, false);
}
stormforgedEradictor = player->SummonCreature(NPC_STORMFORGED_ERADICTOR, stormforgedEradictorPosition, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
if (stormforgedEradictor)
{
stormforgedEradictorGUID = stormforgedEradictor->GetGUID();
stormforgedEradictor->GetMotionMaster()->MovePath(NPC_STORMFORGED_ERADICTOR * 100, false);
}
return true;
}
示例2: urand
void FollowMovementGenerator<Creature>::Initialize(Creature& owner)
{
owner.AddUnitState(UNIT_STATE_FOLLOW); // _MOVE set in _SetTargetLocation after required checks
_updateSpeed(owner);
_setTargetLocation(owner, true);
m_evadeTimer = urand(4000, 8000);
}
示例3:
void HomeMovementGenerator<Creature>::Initialize(Creature & owner) {
float x, y, z;
owner.GetHomePosition(x, y, z, ori);
owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
owner.AddUnitState(UNIT_STAT_EVADE);
_setTargetLocation(owner);
}
示例4: CreateNPCPassenger
Creature* Transport::CreateNPCPassenger(uint32 guid, CreatureData const* data)
{
Map* map = GetMap();
Creature* creature = new Creature();
if (!creature->LoadCreatureFromDB(guid, map, false))
{
delete creature;
return NULL;
}
float x = data->posX;
float y = data->posY;
float z = data->posZ;
float o = data->orientation;
creature->SetTransport(this);
creature->m_movementInfo.transport.guid = GetGUID();
creature->m_movementInfo.transport.pos.Relocate(x, y, z, o); // m_movementInfo.transport.pos.m_positionX x=offset
CalculatePassengerPosition(x, y, z, &o); // This method transforms supplied transport offsets into global coordinates offset > worldpos
creature->m_movementInfo.transport.seat = -1;
GetMap()->CreatureRelocation(creature, x, y, z, o, false);
creature->Relocate(x, y, z, o); // me->m_positionX x=worldpos
creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
creature->SetTransportHomePosition(creature->m_movementInfo.transport.pos);
/// @HACK - transport models are not added to map's dynamic LoS calculations
/// because the current GameObjectModel cannot be moved without recreating
creature->AddUnitState(UNIT_STATE_IGNORE_PATHFINDING);
if (!creature->IsPositionValid())
{
TC_LOG_ERROR("entities.transport", "Creature (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)", creature->GetGUIDLow(), creature->GetEntry(), creature->GetPositionX(), creature->GetPositionY());
delete creature;
return NULL;
}
if (!data->phaseIds.empty())
{
for (uint16 ph : data->phaseIds)
creature->SetInPhase(ph, false, true);
}
else
creature->CopyPhaseFrom(this);
if (!map->AddToMap(creature))
{
delete creature;
return NULL;
}
_staticPassengers.insert(creature);
sScriptMgr->OnAddCreaturePassenger(this, creature);
return creature;
}
示例5: CreateNPCPassenger
Creature* Transport::CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data)
{
Map* map = GetMap();
Creature* creature = new Creature();
if (!creature->LoadCreatureFromDB(guid, map, false))
{
delete creature;
return NULL;
}
ASSERT(data);
float x = data->posX;
float y = data->posY;
float z = data->posZ;
float o = data->orientation;
creature->SetTransport(this);
creature->m_movementInfo.transport.guid = GetGUID();
creature->m_movementInfo.transport.pos.Relocate(x, y, z, o);
CalculatePassengerPosition(x, y, z, &o);
creature->Relocate(x, y, z, o);
creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
creature->SetTransportHomePosition(creature->m_movementInfo.transport.pos);
/// @HACK - transport models are not added to map's dynamic LoS calculations
/// because the current GameObjectModel cannot be moved without recreating
creature->AddUnitState(UNIT_STATE_IGNORE_PATHFINDING);
if (!creature->IsPositionValid())
{
TC_LOG_ERROR("entities.transport", "Passenger %s not created. Suggested coordinates aren't valid (X: %f Y: %f)", creature->GetGUID().ToString().c_str(), creature->GetPositionX(), creature->GetPositionY());
delete creature;
return NULL;
}
if (data->phaseid)
creature->SetInPhase(data->phaseid, false, true);
else if (data->phaseGroup)
for (auto phase : sDB2Manager.GetPhasesForGroup(data->phaseGroup))
creature->SetInPhase(phase, false, true);
else
creature->CopyPhaseFrom(this);
if (!map->AddToMap(creature))
{
delete creature;
return NULL;
}
_staticPassengers.insert(creature);
sScriptMgr->OnAddCreaturePassenger(this, creature);
return creature;
}
示例6:
void RandomMovementGenerator<Creature>::Initialize(Creature& creature)
{
if (!creature.IsAlive())
return;
if (!wander_distance)
wander_distance = creature.GetRespawnRadius();
creature.AddUnitState(UNIT_STATE_ROAMING);
_setRandomLocation(creature);
}
示例7: SetRandomLocation
void RandomMovementGenerator<Creature>::Initialize(Creature &creature)
{
if (!creature.isAlive())
return;
if (!_wanderDistance)
_wanderDistance = creature.GetRespawnRadius();
creature.AddUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE);
SetRandomLocation(creature);
}
示例8:
void RandomMovementGenerator<Creature>::Initialize(Creature &creature)
{
if (!creature.isAlive())
return;
if (!wander_distance)
wander_distance = creature.GetRespawnRadius();
creature.AddUnitState(UNIT_STATE_ROAMING);
i_nextMoveTime.Reset(urand(1000, 5000));
}
示例9:
void WaypointMovementGenerator<Creature>::InitTraveller(Creature &unit, const WaypointData &node)
{
node.run ? unit.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING):
unit.AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
unit.SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
unit.SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
// TODO: make this part of waypoint node, so that creature can walk when desired?
if (unit.canFly())
unit.SetByteFlag(UNIT_FIELD_BYTES_1, 3, 0x02);
unit.AddUnitState(UNIT_STAT_ROAMING);
}
示例10: init
bool WaypointMovementGenerator<Creature>::StartMove(Creature &creature)
{
if (!i_path || i_path->empty())
return false;
if (Stopped())
return true;
if (m_isArrivalDone)
{
if ((i_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint
{
creature.SetHomePosition(i_path->at(i_currentNode)->x, i_path->at(i_currentNode)->y, i_path->at(i_currentNode)->z, creature.GetOrientation());
creature.GetMotionMaster()->Initialize();
return false;
}
i_currentNode = (i_currentNode+1) % i_path->size();
}
WaypointData const* node = i_path->at(i_currentNode);
if (!node)
return false;
m_isArrivalDone = false;
creature.AddUnitState(UNIT_STATE_ROAMING_MOVE);
Movement::MoveSplineInit init(creature);
init.MoveTo(node->x, node->y, node->z);
//! Accepts angles such as 0.00001 and -0.00001, 0 must be ignored, default value in waypoint table
if (node->orientation && node->delay)
init.SetFacing(node->orientation);
init.SetWalk(!node->run);
init.Launch();
//Call for creature group update
if (creature.GetFormation() && creature.GetFormation()->getLeader() == &creature)
{
creature.SetWalk(!node->run);
creature.GetFormation()->LeaderMoveTo(node->x, node->y, node->z);
}
return true;
}
示例11: CreateNPCPassenger
Creature* Transport::CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data)
{
Map* map = GetMap();
Creature* creature = Creature::CreateCreatureFromDB(guid, map, false);
if (!creature)
return nullptr;
ASSERT(data);
float x = data->posX;
float y = data->posY;
float z = data->posZ;
float o = data->orientation;
creature->SetTransport(this);
creature->m_movementInfo.transport.guid = GetGUID();
creature->m_movementInfo.transport.pos.Relocate(x, y, z, o);
creature->m_movementInfo.transport.seat = -1;
CalculatePassengerPosition(x, y, z, &o);
creature->Relocate(x, y, z, o);
creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
creature->SetTransportHomePosition(creature->m_movementInfo.transport.pos);
/// @HACK - transport models are not added to map's dynamic LoS calculations
/// because the current GameObjectModel cannot be moved without recreating
creature->AddUnitState(UNIT_STATE_IGNORE_PATHFINDING);
if (!creature->IsPositionValid())
{
TC_LOG_ERROR("entities.transport", "Passenger %s not created. Suggested coordinates aren't valid (X: %f Y: %f)", creature->GetGUID().ToString().c_str(), creature->GetPositionX(), creature->GetPositionY());
delete creature;
return nullptr;
}
PhasingHandler::InitDbPhaseShift(creature->GetPhaseShift(), data->phaseUseFlags, data->phaseId, data->phaseGroup);
PhasingHandler::InitDbVisibleMapId(creature->GetPhaseShift(), data->terrainSwapMap);
if (!map->AddToMap(creature))
{
delete creature;
return nullptr;
}
_staticPassengers.insert(creature);
sScriptMgr->OnAddCreaturePassenger(this, creature);
return creature;
}
示例12: SpawnAdds
void SpawnAdds()
{
Creature* pCreature = NULL;
for (uint8 i = 0; i < 4; ++i)
{
pCreature = me->SummonCreature(SpiritInfo[i].entry, SpiritInfo[i].x, SpiritInfo[i].y, SpiritInfo[i].z, SpiritInfo[i].orient, TEMPSUMMON_DEAD_DESPAWN, 0);
if (pCreature)
{
pCreature->CastSpell(pCreature, SPELL_SPIRIT_AURA, true);
pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
pCreature->AddUnitState(UNIT_STATE_STUNNED);
SpiritGUID[i] = pCreature->GetGUID();
}
}
}
示例13: CreateNPCPassenger
Creature* Transport::CreateNPCPassenger(uint32 guid, CreatureData const* data)
{
Map* map = GetMap();
Creature* creature = new Creature();
if (!creature->LoadCreatureFromDB(guid, map, false))
{
delete creature;
return NULL;
}
float x = data->posX;
float y = data->posY;
float z = data->posZ;
float o = data->orientation;
creature->SetTransport(this);
creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
creature->m_movementInfo.transport.guid = GetGUID();
creature->m_movementInfo.transport.pos.Relocate(x, y, z, o);
CalculatePassengerPosition(x, y, z, &o);
creature->Relocate(x, y, z, o);
creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
creature->SetTransportHomePosition(creature->m_movementInfo.transport.pos);
/// @HACK - transport models are not added to map's dynamic LoS calculations
/// because the current GameObjectModel cannot be moved without recreating
creature->AddUnitState(UNIT_STATE_IGNORE_PATHFINDING);
if (!creature->IsPositionValid())
{
TC_LOG_ERROR(LOG_FILTER_TRANSPORTS, "Creature (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)",creature->GetGUIDLow(),creature->GetEntry(),creature->GetPositionX(),creature->GetPositionY());
delete creature;
return NULL;
}
if (!map->AddToMap(creature))
{
delete creature;
return NULL;
}
_staticPassengers.insert(creature);
sScriptMgr->OnAddCreaturePassenger(this, creature);
return creature;
}
示例14: init
bool WaypointMovementGenerator<Creature>::StartMove(Creature &creature)
{
if (!i_path || i_path->empty())
return false;
if (Stopped())
return true;
const WaypointData *node = i_path->at(i_currentNode);
if (m_isArrivalDone)
{
if ((i_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint
{
creature.SetHomePosition(node->x, node->y, node->z, creature.GetOrientation());
creature.GetMotionMaster()->Initialize();
return false;
}
i_currentNode = (i_currentNode+1) % i_path->size();
}
m_isArrivalDone = false;
creature.AddUnitState(UNIT_STAT_ROAMING_MOVE);
Movement::MoveSplineInit init(creature);
init.MoveTo(node->x, node->y, node->z);
if (node->orientation != 100 && node->delay != 0)
init.SetFacing(node->orientation);
init.SetWalk(!node->run);
init.Launch();
//Call for creature group update
if (creature.GetFormation() && creature.GetFormation()->getLeader() == &creature)
creature.GetFormation()->LeaderMoveTo(node->x, node->y, node->z);
return true;
}
示例15: traveller
bool
RandomMovementGenerator<Creature>::Update(Creature &creature, const uint32 diff)
{
if (creature.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED))
{
i_nextMoveTime.Update(i_nextMoveTime.GetExpiry()); // Expire the timer
creature.ClearUnitState(UNIT_STAT_ROAMING);
return true;
}
i_nextMoveTime.Update(diff);
if (i_destinationHolder.HasArrived() && !creature.IsStopped() && !creature.canFly())
creature.ClearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_MOVE);
if (!i_destinationHolder.HasArrived() && creature.IsStopped())
creature.AddUnitState(UNIT_STAT_ROAMING);
CreatureTraveller traveller(creature);
if (i_destinationHolder.UpdateTraveller(traveller, diff, true))
{
if (i_nextMoveTime.Passed())
{
if (irand(0, RUNNING_CHANCE_RANDOMMV) > 0)
creature.AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
_setRandomLocation(creature);
}
else if (creature.isPet() && creature.GetOwner() && !creature.IsWithinDist(creature.GetOwner(), PET_FOLLOW_DIST+2.5f))
{
creature.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
_setRandomLocation(creature);
}
}
return true;
}