本文整理汇总了C++中Position::GetPositionX方法的典型用法代码示例。如果您正苦于以下问题:C++ Position::GetPositionX方法的具体用法?C++ Position::GetPositionX怎么用?C++ Position::GetPositionX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Position
的用法示例。
在下文中一共展示了Position::GetPositionX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckPlayersInDistance
bool CheckPlayersInDistance()
{
bool returnValue = false;
if (me->GetMap())
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (me->GetMap()->IsDungeon() && !players.isEmpty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
Player* player = itr->getSource();
// Only apply to attackable, alive and in 70.0 yards players
if (player && !player->isGameMaster() && player->isAlive() && me->IsValidAttackTarget(player))
{
if (player->GetDistance(CenterPoint) <= 70.0f)
returnValue = true;
// In combat with that player, check, that player does not get too far away
if (DoGetThreat(player))
{
if (player->GetDistance(CenterPoint) > 40.0f)
{
player->NearTeleportTo(CenterPoint.GetPositionX(), CenterPoint.GetPositionY(), CenterPoint.GetPositionZ(), CenterPoint.GetOrientation());
}
}
}
}
}
}
return returnValue;
}
示例2: Relocate
void Vehicle::Relocate(Position pos)
{
sLog->outDebug(LOG_FILTER_VEHICLES, "Vehicle::Relocate %u", _me->GetEntry());
std::set<Unit*> vehiclePlayers;
for (int8 i = 0; i < 8; i++)
vehiclePlayers.insert(GetPassenger(i));
// passengers should be removed or they will have movement stuck
RemoveAllPassengers();
for (std::set<Unit*>::const_iterator itr = vehiclePlayers.begin(); itr != vehiclePlayers.end(); ++itr)
{
if (Unit* plr = (*itr))
{
// relocate/setposition doesn't work for player
plr->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation());
//plr->TeleportTo(pPlayer->GetMapId(), triggerPos.GetPositionX(), triggerPos.GetPositionY(), triggerPos.GetPositionZ(), triggerPos.GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT);
}
}
_me->UpdatePosition(pos, true);
// problems, and impossible to do delayed enter
//pPlayer->EnterVehicle(veh);
}
示例3: AttackStart
void AttackStart(Unit* attacker)
{
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
return;
// we do this checks to see if the creature is one of the creatures that sorround the boss
if (Creature* colossus = Unit::GetCreature(*me, instance ? instance->GetData64(DATA_DRAKKARI_COLOSSUS) : 0))
{
Position homePosition;
me->GetHomePosition().GetPosition(&homePosition);
Position colossusHomePosition;
colossus->GetHomePosition().GetPosition(&colossusHomePosition);
float distance = homePosition.GetExactDist(colossusHomePosition.GetPositionX(),colossusHomePosition.GetPositionY(),colossusHomePosition.GetPositionZ());
if (distance < 12.0f)
{
MoveMojos(colossus);
me->SetReactState(REACT_PASSIVE);
}
else
ScriptedAI::AttackStart(attacker);
}
}
示例4: CreateAreaTrigger
bool AreaTrigger::CreateAreaTrigger(uint32 guidlow, uint32 triggerEntry, Unit* caster, SpellInfo const* spell, Position const& pos)
{
SetMap(caster->GetMap());
Relocate(pos);
if (!IsPositionValid())
{
TC_LOG_ERROR("misc", "AreaTrigger (spell %u) not created. Invalid coordinates (X: %f Y: %f)", spell->Id, GetPositionX(), GetPositionY());
return false;
}
WorldObject::_Create(guidlow, HIGHGUID_AREATRIGGER, caster->GetPhaseMask());
SetEntry(triggerEntry);
SetDuration(spell->GetDuration());
SetObjectScale(1);
SetUInt32Value(AREATRIGGER_SPELLID, spell->Id);
SetUInt32Value(AREATRIGGER_SPELLVISUALID, spell->SpellVisual[0]);
SetUInt32Value(AREATRIGGER_DURATION, spell->GetDuration());
SetFloatValue(AREATRIGGER_FINAL_POS + 0, pos.GetPositionX());
SetFloatValue(AREATRIGGER_FINAL_POS + 1, pos.GetPositionY());
SetFloatValue(AREATRIGGER_FINAL_POS + 2, pos.GetPositionZ());
if (!GetMap()->AddToMap(this))
return false;
return true;
}
示例5: SpawnAdds
void SpawnAdds()
{
uint8 u = 0;
for (uint8 i = 0; i < 30; ++i)
{
Position pos;
me->GetPosition(&pos);
me->GetRandomNearPosition(pos, 30.0f);
pos.m_positionZ = me->GetMap()->GetHeight(pos.GetPositionX(), pos.GetPositionY(), MAX_HEIGHT) + 2.0f;
if (Creature* trigger = me->SummonCreature(NPC_TRIGGER, pos))
{
Creature* temp1 = trigger->FindNearestCreature(NPC_HEALTHY_MUSHROOM, 4.0f, true);
Creature* temp2 = trigger->FindNearestCreature(NPC_POISONOUS_MUSHROOM, 4.0f, true);
if (temp1 || temp2)
{
trigger->DisappearAndDie();
}
else
{
u = 1 - u;
trigger->DisappearAndDie();
me->SummonCreature(u > 0 ? NPC_POISONOUS_MUSHROOM : NPC_HEALTHY_MUSHROOM, pos, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60 * IN_MILLISECONDS);
}
}
}
}
示例6: IsSummonedBy
void IsSummonedBy(Unit* owner) override
{
if (owner->GetTypeId() != TYPEID_UNIT)
return;
Position pos;
if (MarrowgarAI* marrowgarAI = CAST_AI(MarrowgarAI, owner->GetAI()))
pos.Relocate(marrowgarAI->GetLastColdflamePosition());
else
pos.Relocate(owner);
if (owner->HasAura(SPELL_BONE_STORM))
{
float ang = Position::NormalizeOrientation(pos.GetAngle(me));
me->SetOrientation(ang);
owner->GetNearPoint2D(pos.m_positionX, pos.m_positionY, 5.0f - owner->GetObjectSize(), ang);
}
else
{
Player* target = ObjectAccessor::GetPlayer(*owner, owner->GetAI()->GetGUID(DATA_COLDFLAME_GUID));
if (!target)
{
me->DespawnOrUnsummon();
return;
}
float ang = Position::NormalizeOrientation(pos.GetAngle(target));
me->SetOrientation(ang);
owner->GetNearPoint2D(pos.m_positionX, pos.m_positionY, 15.0f - owner->GetObjectSize(), ang);
}
me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), me->GetPositionZ(), me->GetOrientation());
DoCast(SPELL_COLDFLAME_SUMMON);
_events.ScheduleEvent(EVENT_COLDFLAME_TRIGGER, 500);
}
示例7: SummonKrikThik
TempSummon* SummonKrikThik(uint32 creatureId)
{
float angle = frand(0, 2*M_PI);
float x = CenterPos.GetPositionX() + (RADIUS_CIRCLE * std::cos(angle));
float y = CenterPos.GetPositionY() + (RADIUS_CIRCLE * std::sin(angle));
return me->SummonCreature(creatureId, x, y, CenterPos.GetPositionZ());
}
示例8: GetRandomPositionOnCircle
// uniformly distribute on the circle
static Position GetRandomPositionOnCircle(Position const& center, float radius)
{
double angle = rand_norm() * 2.0 * M_PI;
double relDistance = rand_norm() + rand_norm();
if (relDistance > 1)
relDistance = 1 - relDistance;
return Position(center.GetPositionX() + std::sin(angle)*relDistance*radius, center.GetPositionY() + std::cos(angle)*relDistance*radius, center.GetPositionZ());
}
示例9: UpdateAI
void UpdateAI (const uint32 diff)
{
if (!UpdateVictim() || me->HasUnitState(UNIT_STAT_CASTING))
return;
if ((me->HealthBelowPct(69) && Phase == 0) || (me->HealthBelowPct(34) && Phase == 1))
{
Phase++;
// Switch Position with a random Shadow of Obsidius and empty Threat list
Creature* target = ShadowOfObsidiusList[urand(0, RAID_MODE(1, 2))];
Position telePos;
me->GetPosition(&telePos);
// Switch Positions
me->NearTeleportTo(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0);
target->NearTeleportTo(telePos.GetPositionX(), telePos.GetPositionY(), telePos.GetPositionZ(), 0);
// Resetts Aggro
me->getThreatManager().resetAllAggro();
me->MonsterYell("Your kind has no place in the master's world.", LANG_UNIVERSAL, NULL);
return;
}
events.Update(diff);
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_THUNDERCLAP:
DoCastAOE(SPELL_THUNDERCLAP);
events.ScheduleEvent(EVENT_THUNDERCLAP, 7000);
break;
case EVENT_TWILIGHT_CORRUPTION:
if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 200, true))
DoCast(pTarget, SPELL_TWILIGHT_CORRUPTION);
events.ScheduleEvent(EVENT_TWILIGHT_CORRUPTION, 10000);
break;
case EVENT_STONE_BLOW:
DoCastVictim(SPELL_STONE_BLOW);
events.ScheduleEvent(EVENT_STONE_BLOW, 13000);
break;
default:
break;
}
}
DoMeleeAttackIfReady();
}
示例10: OnTrigger
bool OnTrigger(Player* player, const AreaTriggerEntry* /*at*/)
{
player->GetMap()->LoadGrid(GuardSummonPos.GetPositionX(), GuardSummonPos.GetPositionY());
if (InstanceScript* instance = player->GetInstanceScript())
if (instance->GetBossState(DATA_ANUBREKHAN) != DONE)
if (Creature* Anub = Unit::GetCreature(*player, instance->GetData64(DATA_ANUBREKHAN)))
Anub->AI()->DoAction(ACTION_INTRO);
return true;
}
示例11: SpawnMobs
void SpawnMobs()
{
for (uint8 i = 0; i < DUNGEON_MODE(5,6); ++i)
{
switch (urand(0,2))
{
case 0:
me->SummonCreature(CREATURE_YMIRJAR_WARRIOR, SpawnLoc.GetPositionX()+rand()%5, SpawnLoc.GetPositionY()+rand()%5, SpawnLoc.GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
break;
case 1:
me->SummonCreature(CREATURE_YMIRJAR_WITCH_DOCTOR, SpawnLoc.GetPositionX()+rand()%5, SpawnLoc.GetPositionY()+rand()%5, SpawnLoc.GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
break;
case 2:
me->SummonCreature(CREATURE_YMIRJAR_HARPOONER, SpawnLoc.GetPositionX()+rand()%5, SpawnLoc.GetPositionY()+rand()%5, SpawnLoc.GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
break;
}
}
}
示例12: init
void FleeingMovementGenerator<T>::SetTargetLocation(T* owner)
{
if (!owner || !owner->IsAlive())
return;
if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting())
{
MovementGenerator::AddFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED);
owner->StopMoving();
_path = nullptr;
return;
}
Position destination = owner->GetPosition();
GetPoint(owner, destination);
// Add LOS check for target point
if (!owner->IsWithinLOS(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ()))
{
_timer.Reset(200);
return;
}
if (!_path)
{
_path = std::make_unique<PathGenerator>(owner);
_path->SetPathLengthLimit(30.0f);
}
bool result = _path->CalculatePath(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ());
if (!result || (_path->GetPathType() & PATHFIND_NOPATH))
{
_timer.Reset(100);
return;
}
owner->AddUnitState(UNIT_STATE_FLEEING_MOVE);
Movement::MoveSplineInit init(owner);
init.MovebyPath(_path->GetPath());
init.SetWalk(false);
int32 traveltime = init.Launch();
_timer.Reset(traveltime + urand(800, 1500));
}
示例13: SelectNextWaypoint
void SelectNextWaypoint(float& x, float& y)
{
if (direction)
actualAngle -= M_PI / 8;
else
actualAngle += M_PI / 8;
x = CenterPos.GetPositionX() + (me->GetObjectSize() + RADIUS_CIRCLE) * std::cos(actualAngle);
y = CenterPos.GetPositionY() + (me->GetObjectSize() + RADIUS_CIRCLE) * std::sin(actualAngle);
}
示例14: GetPositionOffsetTo
void Position::GetPositionOffsetTo(const Position & endPos, Position & retOffset) const
{
float dx = endPos.GetPositionX() - GetPositionX();
float dy = endPos.GetPositionY() - GetPositionY();
retOffset.m_positionX = dx * std::cos(GetOrientation()) + dy * std::sin(GetOrientation());
retOffset.m_positionY = dy * std::cos(GetOrientation()) - dx * std::sin(GetOrientation());
retOffset.m_positionZ = endPos.GetPositionZ() - GetPositionZ();
retOffset.SetOrientation(endPos.GetOrientation() - GetOrientation());
}
示例15: PeriodicTick
void PeriodicTick(constAuraEffectPtr aurEff)
{
if (!GetCaster())
return;
count++;
Position pos;
GetCaster()->GetNearPosition(pos, 4.0f * count, 0.0f);
GetCaster()->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_FLAME_BREATH_1, true);
}