refactor(Core/Game): restyle game lib with astyle (#3466)

This commit is contained in:
Kargatum
2020-10-12 15:08:15 +07:00
committed by GitHub
parent e99b526e17
commit a2b26272d2
338 changed files with 52196 additions and 50944 deletions

View File

@@ -90,7 +90,7 @@ uint32 CreatureTemplate::GetRandomValidModelId() const
if (Modelid3) modelIDs[c++] = Modelid3;
if (Modelid4) modelIDs[c++] = Modelid4;
return ((c>0) ? modelIDs[urand(0, c-1)] : 0);
return ((c > 0) ? modelIDs[urand(0, c - 1)] : 0);
}
uint32 CreatureTemplate::GetFirstValidModelId() const
@@ -160,11 +160,11 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
}
Creature::Creature(bool isWorldObject): Unit(isWorldObject), MovableMapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipient(0), m_lootRecipientGroup(0),
m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_wanderDistance(0.0f),
m_transportCheckTimer(1000), lootPickPocketRestoreTime(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE),
m_DBTableGuid(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false),
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_moveInLineOfSightDisabled(false), m_moveInLineOfSightStrictlyDisabled(false),
m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_waypointID(0), m_path_id(0), m_formation(nullptr), _lastDamagedTime(0)
m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_wanderDistance(0.0f),
m_transportCheckTimer(1000), lootPickPocketRestoreTime(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE),
m_DBTableGuid(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false),
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_moveInLineOfSightDisabled(false), m_moveInLineOfSightStrictlyDisabled(false),
m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_waypointID(0), m_path_id(0), m_formation(nullptr), _lastDamagedTime(0)
{
m_regenTimer = CREATURE_REGEN_INTERVAL;
m_valuesCount = UNIT_END;
@@ -390,7 +390,7 @@ bool Creature::InitEntry(uint32 Entry, const CreatureData* data)
if (!m_wanderDistance && m_defaultMovementType == RANDOM_MOTION_TYPE)
m_defaultMovementType = IDLE_MOTION_TYPE;
for (uint8 i=0; i < CREATURE_MAX_SPELLS; ++i)
for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i)
m_spells[i] = GetCreatureTemplate()->spells[i];
return true;
@@ -506,112 +506,112 @@ void Creature::Update(uint32 diff)
sLog->outError("Creature (GUID: %u Entry: %u) in wrong state: JUST_DEAD (1)", GetGUIDLow(), GetEntry());
break;
case DEAD:
{
time_t now = time(nullptr);
if (m_respawnTime <= now)
{
bool allowed = IsAIEnabled ? AI()->CanRespawn() : true; // First check if there are any scripts that object to us respawning
if (!allowed) // Will be rechecked on next Update call
time_t now = time(nullptr);
if (m_respawnTime <= now)
{
bool allowed = IsAIEnabled ? AI()->CanRespawn() : true; // First check if there are any scripts that object to us respawning
if (!allowed) // Will be rechecked on next Update call
break;
uint64 dbtableHighGuid = MAKE_NEW_GUID(m_DBTableGuid, GetEntry(), HIGHGUID_UNIT);
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
if (!linkedRespawntime) // Can respawn
Respawn();
else // the master is dead
{
uint64 targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
SetRespawnTime(DAY);
else
m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime) + urand(5, MINUTE); // else copy time from master and add a little
SaveRespawnTime(); // also save to DB immediately
}
}
break;
}
case CORPSE:
{
Unit::Update(diff);
// deathstate changed on spells update, prevent problems
if (m_deathState != CORPSE)
break;
uint64 dbtableHighGuid = MAKE_NEW_GUID(m_DBTableGuid, GetEntry(), HIGHGUID_UNIT);
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
if (!linkedRespawntime) // Can respawn
Respawn();
else // the master is dead
if (m_groupLootTimer && lootingGroupLowGUID)
{
uint64 targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
SetRespawnTime(DAY);
else
m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime)+urand(5, MINUTE); // else copy time from master and add a little
SaveRespawnTime(); // also save to DB immediately
if (m_groupLootTimer <= diff)
{
Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID);
if (group)
group->EndRoll(&loot, GetMap());
m_groupLootTimer = 0;
lootingGroupLowGUID = 0;
}
else m_groupLootTimer -= diff;
}
}
break;
}
case CORPSE:
{
Unit::Update(diff);
// deathstate changed on spells update, prevent problems
if (m_deathState != CORPSE)
break;
if (m_groupLootTimer && lootingGroupLowGUID)
{
if (m_groupLootTimer <= diff)
else if (m_corpseRemoveTime <= time(nullptr))
{
Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID);
if (group)
group->EndRoll(&loot, GetMap());
m_groupLootTimer = 0;
lootingGroupLowGUID = 0;
}
else m_groupLootTimer -= diff;
}
else if (m_corpseRemoveTime <= time(nullptr))
{
RemoveCorpse(false);
RemoveCorpse(false);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outStaticDebug("Removing corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY));
sLog->outStaticDebug("Removing corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY));
#endif
}
break;
}
break;
}
case ALIVE:
{
Unit::Update(diff);
{
Unit::Update(diff);
// creature can be dead after Unit::Update call
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
if (!IsAlive())
// creature can be dead after Unit::Update call
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
if (!IsAlive())
break;
// if creature is charmed, switch to charmed AI
if (NeedChangeAI)
{
UpdateCharmAI();
NeedChangeAI = false;
IsAIEnabled = true;
// xinef: update combat state, if npc is not in combat - return to spawn correctly by calling EnterEvadeMode
SelectVictim();
}
Unit* owner = GetCharmerOrOwner();
if (IsCharmed() && !IsWithinDistInMap(owner, GetMap()->GetVisibilityRange()))
{
RemoveCharmAuras();
}
if (!IsInEvadeMode() && IsAIEnabled)
{
// do not allow the AI to be changed during update
m_AI_locked = true;
i_AI->UpdateAI(diff);
m_AI_locked = false;
}
// creature can be dead after UpdateAI call
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
if (!IsAlive())
break;
m_regenTimer -= diff;
if (m_regenTimer <= 0)
{
if (!IsInEvadeMode() && (!IsInCombat() || IsPolymorphed())) // regenerate health if not in combat or if polymorphed
RegenerateHealth();
if (getPowerType() == POWER_ENERGY)
Regenerate(POWER_ENERGY);
else
Regenerate(POWER_MANA);
m_regenTimer += CREATURE_REGEN_INTERVAL;
}
break;
// if creature is charmed, switch to charmed AI
if (NeedChangeAI)
{
UpdateCharmAI();
NeedChangeAI = false;
IsAIEnabled = true;
// xinef: update combat state, if npc is not in combat - return to spawn correctly by calling EnterEvadeMode
SelectVictim();
}
Unit* owner = GetCharmerOrOwner();
if (IsCharmed() && !IsWithinDistInMap(owner, GetMap()->GetVisibilityRange()))
{
RemoveCharmAuras();
}
if (!IsInEvadeMode() && IsAIEnabled)
{
// do not allow the AI to be changed during update
m_AI_locked = true;
i_AI->UpdateAI(diff);
m_AI_locked = false;
}
// creature can be dead after UpdateAI call
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
if (!IsAlive())
break;
m_regenTimer -= diff;
if (m_regenTimer <= 0)
{
if (!IsInEvadeMode() && (!IsInCombat() || IsPolymorphed())) // regenerate health if not in combat or if polymorphed
RegenerateHealth();
if (getPowerType() == POWER_ENERGY)
Regenerate(POWER_ENERGY);
else
Regenerate(POWER_MANA);
m_regenTimer += CREATURE_REGEN_INTERVAL;
}
break;
}
default:
break;
}
@@ -660,38 +660,38 @@ void Creature::Regenerate(Powers power)
switch (power)
{
case POWER_FOCUS:
{
// For hunter pets.
addvalue = 24 * sWorld->getRate(RATE_POWER_FOCUS);
break;
}
case POWER_ENERGY:
{
// For deathknight's ghoul.
addvalue = 20;
break;
}
case POWER_MANA:
{
// Combat and any controlled creature
if (IsInCombat() || GetCharmerOrOwnerGUID())
{
if (GetEntry() == NPC_IMP || GetEntry() == NPC_WATER_ELEMENTAL_TEMP || GetEntry() == NPC_WATER_ELEMENTAL_PERM)
{
addvalue = uint32((GetStat(STAT_SPIRIT) / (IsUnderLastManaUseEffect() ? 8.0f : 5.0f) + 17.0f));
}
else if (!IsUnderLastManaUseEffect())
{
float ManaIncreaseRate = sWorld->getRate(RATE_POWER_MANA);
float Spirit = GetStat(STAT_SPIRIT);
addvalue = uint32((Spirit / 5.0f + 17.0f) * ManaIncreaseRate);
}
// For hunter pets.
addvalue = 24 * sWorld->getRate(RATE_POWER_FOCUS);
break;
}
case POWER_ENERGY:
{
// For deathknight's ghoul.
addvalue = 20;
break;
}
case POWER_MANA:
{
// Combat and any controlled creature
if (IsInCombat() || GetCharmerOrOwnerGUID())
{
if (GetEntry() == NPC_IMP || GetEntry() == NPC_WATER_ELEMENTAL_TEMP || GetEntry() == NPC_WATER_ELEMENTAL_PERM)
{
addvalue = uint32((GetStat(STAT_SPIRIT) / (IsUnderLastManaUseEffect() ? 8.0f : 5.0f) + 17.0f));
}
else if (!IsUnderLastManaUseEffect())
{
float ManaIncreaseRate = sWorld->getRate(RATE_POWER_MANA);
float Spirit = GetStat(STAT_SPIRIT);
addvalue = uint32((Spirit / 5.0f + 17.0f) * ManaIncreaseRate);
}
}
else
addvalue = maxValue / 3;
break;
}
else
addvalue = maxValue / 3;
break;
}
default:
return;
}
@@ -723,7 +723,7 @@ void Creature::RegenerateHealth()
// Not only pet, but any controlled creature
// Xinef: fix polymorph rapid regen
if (!GetCharmerOrOwnerGUID() || IsPolymorphed())
addvalue = maxValue/3;
addvalue = maxValue / 3;
else //if (GetCharmerOrOwnerGUID())
{
float HealthIncreaseRate = sWorld->getRate(RATE_HEALTH);
@@ -755,7 +755,7 @@ void Creature::DoFleeToGetAssistance()
return;
float radius = sWorld->getFloatConfig(CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS);
if (radius >0)
if (radius > 0)
{
Creature* creature = nullptr;
@@ -864,7 +864,7 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry,
case CREATURE_ELITE_WORLDBOSS:
// Xinef: Reduce corpse delay for bossess outside of instance
if (!GetInstanceId())
m_corpseDelay = sWorld->getIntConfig(CONFIG_CORPSE_DECAY_ELITE)*2;
m_corpseDelay = sWorld->getIntConfig(CONFIG_CORPSE_DECAY_ELITE) * 2;
else
m_corpseDelay = sWorld->getIntConfig(CONFIG_CORPSE_DECAY_WORLDBOSS);
break;
@@ -918,9 +918,15 @@ bool Creature::isCanInteractWithBattleMaster(Player* player, bool msg) const
ClearGossipMenuFor(player);
switch (bgTypeId)
{
case BATTLEGROUND_AV: SendGossipMenuFor(player, 7616, this); break;
case BATTLEGROUND_WS: SendGossipMenuFor(player, 7599, this); break;
case BATTLEGROUND_AB: SendGossipMenuFor(player, 7642, this); break;
case BATTLEGROUND_AV:
SendGossipMenuFor(player, 7616, this);
break;
case BATTLEGROUND_WS:
SendGossipMenuFor(player, 7599, this);
break;
case BATTLEGROUND_AB:
SendGossipMenuFor(player, 7642, this);
break;
case BATTLEGROUND_EY:
case BATTLEGROUND_NA:
case BATTLEGROUND_BE:
@@ -928,8 +934,11 @@ bool Creature::isCanInteractWithBattleMaster(Player* player, bool msg) const
case BATTLEGROUND_RL:
case BATTLEGROUND_SA:
case BATTLEGROUND_DS:
case BATTLEGROUND_RV: SendGossipMenuFor(player, 10024, this); break;
default: break;
case BATTLEGROUND_RV:
SendGossipMenuFor(player, 10024, this);
break;
default:
break;
}
return false;
}
@@ -939,8 +948,8 @@ bool Creature::isCanInteractWithBattleMaster(Player* player, bool msg) const
bool Creature::isCanTrainingAndResetTalentsOf(Player* player) const
{
return player->getLevel() >= 10
&& GetCreatureTemplate()->trainer_type == TRAINER_TYPE_CLASS
&& player->getClass() == GetCreatureTemplate()->trainer_class;
&& GetCreatureTemplate()->trainer_type == TRAINER_TYPE_CLASS
&& player->getClass() == GetCreatureTemplate()->trainer_class;
}
Player* Creature::GetLootRecipient() const
@@ -967,7 +976,7 @@ void Creature::SetLootRecipient(Unit* unit, bool withGroup)
{
m_lootRecipient = 0;
m_lootRecipientGroup = 0;
RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE|UNIT_DYNFLAG_TAPPED);
RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE | UNIT_DYNFLAG_TAPPED);
return;
}
@@ -1036,7 +1045,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
if (cinfo)
{
if (displayId == cinfo->Modelid1 || displayId == cinfo->Modelid2 ||
displayId == cinfo->Modelid3 || displayId == cinfo->Modelid4)
displayId == cinfo->Modelid3 || displayId == cinfo->Modelid4)
displayId = 0;
if (npcflag == cinfo->npcflag)
@@ -1078,7 +1087,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
data.curmana = GetPower(POWER_MANA);
// prevent add data integrity problems
data.movementType = !m_wanderDistance && GetDefaultMovementType() == RANDOM_MOTION_TYPE
? IDLE_MOTION_TYPE : GetDefaultMovementType();
? IDLE_MOTION_TYPE : GetDefaultMovementType();
data.spawnMask = spawnMask;
data.npcflag = npcflag;
data.unit_flags = unit_flags;
@@ -1320,9 +1329,9 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap, bool gri
// xinef: fix shitness from db
if ((addToMap || gridLoad) && !data->overwrittenZ)
{
float tz = map->GetHeight(data->posX, data->posY, data->posZ+1.0f, true);
float tz = map->GetHeight(data->posX, data->posY, data->posZ + 1.0f, true);
if (tz >= data->posZ && tz - data->posZ <= 1.0f)
const_cast<CreatureData*>(data)->posZ = tz+0.1f;
const_cast<CreatureData*>(data)->posZ = tz + 0.1f;
const_cast<CreatureData*>(data)->overwrittenZ = true;
}
@@ -1371,7 +1380,7 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap, bool gri
curhealth = data->curhealth;
if (curhealth)
{
curhealth = uint32(curhealth*_GetHealthMod(GetCreatureTemplate()->rank));
curhealth = uint32(curhealth * _GetHealthMod(GetCreatureTemplate()->rank));
if (curhealth < 1)
curhealth = 1;
}
@@ -1501,7 +1510,7 @@ bool Creature::CanStartAttack(Unit const* who) const
// This set of checks is should be done only for creatures
if ((HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC) && who->GetTypeId() != TYPEID_PLAYER) || // flag is valid only for non player characters
(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC) && who->GetTypeId() == TYPEID_PLAYER)) // immune to PC and target is a player, return false
(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC) && who->GetTypeId() == TYPEID_PLAYER)) // immune to PC and target is a player, return false
return false;
if (Unit* owner = who->GetOwner())
@@ -1755,7 +1764,7 @@ SpellInfo const* Creature::reachWithSpellAttack(Unit* victim)
if (!victim)
return nullptr;
for (uint32 i=0; i < CREATURE_MAX_SPELLS; ++i)
for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
{
if (!m_spells[i])
continue;
@@ -1770,10 +1779,10 @@ SpellInfo const* Creature::reachWithSpellAttack(Unit* victim)
for (uint32 j = 0; j < MAX_SPELL_EFFECTS; j++)
{
if ((spellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) ||
(spellInfo->Effects[j].Effect == SPELL_EFFECT_INSTAKILL) ||
(spellInfo->Effects[j].Effect == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) ||
(spellInfo->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH)
)
(spellInfo->Effects[j].Effect == SPELL_EFFECT_INSTAKILL) ||
(spellInfo->Effects[j].Effect == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) ||
(spellInfo->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH)
)
{
bcontinue = false;
break;
@@ -1803,7 +1812,7 @@ SpellInfo const* Creature::reachWithSpellCure(Unit* victim)
if (!victim)
return nullptr;
for (uint32 i=0; i < CREATURE_MAX_SPELLS; ++i)
for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
{
if (!m_spells[i])
continue;
@@ -2066,8 +2075,8 @@ bool Creature::_CanDetectFeignDeathOf(const Unit* target) const
void Creature::UpdateMoveInLineOfSightState()
{
// xinef: pets, guardians and units with scripts / smartAI should be skipped
if (IsPet() || HasUnitTypeMask(UNIT_MASK_MINION|UNIT_MASK_SUMMON|UNIT_MASK_GUARDIAN|UNIT_MASK_CONTROLABLE_GUARDIAN) ||
GetScriptId() || GetAIName() == "SmartAI")
if (IsPet() || HasUnitTypeMask(UNIT_MASK_MINION | UNIT_MASK_SUMMON | UNIT_MASK_GUARDIAN | UNIT_MASK_CONTROLABLE_GUARDIAN) ||
GetScriptId() || GetAIName() == "SmartAI")
{
m_moveInLineOfSightStrictlyDisabled = false;
m_moveInLineOfSightDisabled = false;
@@ -2137,7 +2146,7 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const
return true;
// xinef: added size factor for huge npcs
float dist = std::min<float>(GetMap()->GetVisibilityRange() + GetObjectSize()*2, 150.0f);
float dist = std::min<float>(GetMap()->GetVisibilityRange() + GetObjectSize() * 2, 150.0f);
if (Unit* unit = GetCharmerOrOwner())
return victim->IsWithinDist(unit, dist);
@@ -2279,7 +2288,7 @@ void Creature::SetInCombatWithZone()
return;
}
Map::PlayerList const &PlList = map->GetPlayers();
Map::PlayerList const& PlList = map->GetPlayers();
if (PlList.isEmpty())
return;
@@ -2324,7 +2333,7 @@ bool Creature::IsSpellProhibited(SpellSchoolMask idSchoolMask) const
void Creature::_AddCreatureSpellCooldown(uint32 spell_id, uint32 end_time)
{
m_CreatureSpellCooldowns[spell_id] = World::GetGameTimeMS()+end_time;
m_CreatureSpellCooldowns[spell_id] = World::GetGameTimeMS() + end_time;
}
void Creature::AddSpellCooldown(uint32 spell_id, uint32 /*itemid*/, uint32 end_time, bool /*needSendToClient*/, bool /*forceSendToSpectator*/)
@@ -2390,7 +2399,7 @@ bool Creature::HasSpell(uint32 spellID) const
}
time_t Creature::GetRespawnTimeEx() const
{
{
time_t now = time(nullptr);
if (m_respawnTime > now)
@@ -2399,7 +2408,7 @@ time_t Creature::GetRespawnTimeEx() const
return now;
}
void Creature::GetRespawnPosition(float &x, float &y, float &z, float* ori, float* dist) const
void Creature::GetRespawnPosition(float& x, float& y, float& z, float* ori, float* dist) const
{
if (m_DBTableGuid)
{
@@ -2517,7 +2526,7 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem)
{
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item);
uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime);
uint32 diff = uint32((ptime - vCount->lastIncrementTime) / vItem->incrtime);
if ((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount)
{
m_vendorItemCounts.erase(itr);
@@ -2543,7 +2552,7 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us
if (itr == m_vendorItemCounts.end())
{
uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount-used_count : 0;
uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount - used_count : 0;
m_vendorItemCounts.push_back(VendorItemCount(vItem->item, new_count));
return new_count;
}
@@ -2556,14 +2565,14 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us
{
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item);
uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime);
uint32 diff = uint32((ptime - vCount->lastIncrementTime) / vItem->incrtime);
if ((vCount->count + diff * pProto->BuyCount) < vItem->maxcount)
vCount->count += diff * pProto->BuyCount;
else
vCount->count = vItem->maxcount;
}
vCount->count = vCount->count > used_count ? vCount->count-used_count : 0;
vCount->count = vCount->count > used_count ? vCount->count - used_count : 0;
vCount->lastIncrementTime = ptime;
return vCount->count;
}
@@ -2867,5 +2876,5 @@ float Creature::GetAttackDistance(Unit const* player) const
if (retDistance < 5.0f)
retDistance = 5.0f;
return (retDistance*aggroRate);
return (retDistance * aggroRate);
}

View File

@@ -153,7 +153,7 @@ struct CreatureTemplate
{
return (type_flags & CREATURE_TYPE_FLAG_EXOTIC_PET) != 0;
}
bool IsTameable(bool exotic) const
{
if (type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPE_FLAG_TAMEABLE_PET) == 0)
@@ -252,9 +252,9 @@ typedef std::unordered_map<uint32, EquipmentInfoContainerInternal> EquipmentInfo
struct CreatureData
{
CreatureData() : id(0), mapid(0), phaseMask(0), displayid(0), equipmentId(0),
posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), spawntimesecs(0),
wander_distance(0.0f), currentwaypoint(0), curhealth(0), curmana(0), movementType(0),
spawnMask(0), npcflag(0), unit_flags(0), dynamicflags(0), dbData(true), overwrittenZ(false) { }
posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), spawntimesecs(0),
wander_distance(0.0f), currentwaypoint(0), curhealth(0), curmana(0), movementType(0),
spawnMask(0), npcflag(0), unit_flags(0), dynamicflags(0), dbData(true), overwrittenZ(false) { }
uint32 id; // entry in creature_template
uint16 mapid;
uint32 phaseMask;
@@ -414,7 +414,7 @@ struct TrainerSpellData
TrainerSpellMap spellList;
uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value.
// req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2.
// req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2.
TrainerSpell const* Find(uint32 spell_id) const;
};
@@ -427,389 +427,389 @@ typedef std::map<uint32, time_t> CreatureSpellCooldowns;
class Creature : public Unit, public GridObject<Creature>, public MovableMapObject
{
public:
explicit Creature(bool isWorldObject = false);
virtual ~Creature();
void AddToWorld() override;
void RemoveFromWorld() override;
void SetObjectScale(float scale) override;
void SetDisplayId(uint32 modelId) override;
void DisappearAndDie();
bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData* data = nullptr);
bool LoadCreaturesAddon(bool reload = false);
void SelectLevel(bool changelevel = true);
void LoadEquipment(int8 id = 1, bool force = false);
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
void Update(uint32 time) override; // overwrited Unit::Update
void GetRespawnPosition(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
uint32 GetCorpseDelay() const { return m_corpseDelay; }
bool IsRacialLeader() const { return GetCreatureTemplate()->RacialLeader; }
bool IsCivilian() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
bool IsTrigger() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER; }
bool IsGuard() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GUARD; }
bool CanWalk() const { return GetCreatureTemplate()->InhabitType & INHABIT_GROUND; }
bool CanSwim() const override { return (GetCreatureTemplate()->InhabitType & INHABIT_WATER) || IS_PLAYER_GUID(GetOwnerGUID()); }
bool CanFly() const override { return GetCreatureTemplate()->InhabitType & INHABIT_AIR; }
void SetReactState(ReactStates st) { m_reactState = st; }
ReactStates GetReactState() const { return m_reactState; }
bool HasReactState(ReactStates state) const { return (m_reactState == state); }
void InitializeReactState();
///// TODO RENAME THIS!!!!!
bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
bool isCanTrainingAndResetTalentsOf(Player* player) const;
bool CanCreatureAttack(Unit const* victim, bool skipDistCheck = false) const;
bool IsImmunedToSpell(SpellInfo const* spellInfo) override;
bool HasMechanicTemplateImmunity(uint32 mask) const;
// redefine Unit::IsImmunedToSpell
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override;
// redefine Unit::IsImmunedToSpellEffect
bool isElite() const
{
if (IsPet())
return false;
uint32 rank = GetCreatureTemplate()->rank;
return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
}
bool isWorldBoss() const
{
if (IsPet())
return false;
return GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_BOSS_MOB;
}
bool IsDungeonBoss() const;
bool IsImmuneToKnockback() const;
bool IsAvoidingAOE() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_AVOID_AOE; }
uint8 getLevelForTarget(WorldObject const* target) const override; // overwrite Unit::getLevelForTarget for boss level support
bool IsInEvadeMode() const { return HasUnitState(UNIT_STATE_EVADE); }
bool AIM_Initialize(CreatureAI* ai = nullptr);
void Motion_Initialize();
CreatureAI* AI() const { return (CreatureAI*)i_AI; }
bool SetWalk(bool enable) override;
bool SetDisableGravity(bool disable, bool packetOnly = false) override;
bool SetSwim(bool enable) override;
bool SetCanFly(bool enable, bool packetOnly = false) override;
bool SetWaterWalking(bool enable, bool packetOnly = false) override;
bool SetFeatherFall(bool enable, bool packetOnly = false) override;
bool SetHover(bool enable, bool packetOnly = false) override;
uint32 GetShieldBlockValue() const override
{
return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20));
}
SpellSchoolMask GetMeleeDamageSchoolMask() const override { return m_meleeDamageSchoolMask; }
void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
void _AddCreatureSpellCooldown(uint32 spell_id, uint32 end_time);
virtual void AddSpellCooldown(uint32 spell_id, uint32 /*itemid*/, uint32 end_time, bool needSendToClient = false, bool forceSendToSpectator = false) override;
virtual bool HasSpellCooldown(uint32 spell_id) const override;
uint32 GetSpellCooldown(uint32 spell_id) const;
void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override;
bool IsSpellProhibited(SpellSchoolMask idSchoolMask) const;
bool HasSpell(uint32 spellID) const override;
bool UpdateEntry(uint32 entry, const CreatureData* data=NULL, bool changelevel=true );
bool UpdateStats(Stats stat) override;
bool UpdateAllStats() override;
void UpdateResistances(uint32 school) override;
void UpdateArmor() override;
void UpdateMaxHealth() override;
void UpdateMaxPower(Powers power) override;
void UpdateAttackPowerAndDamage(bool ranged = false) override;
void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) override;
void SetCanDualWield(bool value) override;
int8 GetOriginalEquipmentId() const { return m_originalEquipmentId; }
uint8 GetCurrentEquipmentId() { return m_equipmentId; }
void SetCurrentEquipmentId(uint8 id) { m_equipmentId = id; }
float GetSpellDamageMod(int32 Rank);
VendorItemData const* GetVendorItems() const;
uint32 GetVendorItemCurrentCount(VendorItem const* vItem);
uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count);
TrainerSpellData const* GetTrainerSpells() const;
CreatureTemplate const* GetCreatureTemplate() const { return m_creatureInfo; }
CreatureData const* GetCreatureData() const { return m_creatureData; }
CreatureAddon const* GetCreatureAddon() const;
std::string GetAIName() const;
std::string GetScriptName() const;
uint32 GetScriptId() const;
// override WorldObject function for proper name localization
std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override;
void setDeathState(DeathState s, bool despawn = false) override; // override virtual Unit::setDeathState
bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false, true); }
bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true, bool gridLoad = false);
void SaveToDB();
// overriden in Pet
virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
virtual void DeleteFromDB(); // overriden in Pet
Loot loot;
uint64 GetLootRecipientGUID() const { return m_lootRecipient; }
Player* GetLootRecipient() const;
Group* GetLootRecipientGroup() const;
bool hasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
bool isTappedBy(Player const* player) const; // return true if the creature is tapped by the player or a member of his party.
bool CanGeneratePickPocketLoot() const { return lootPickPocketRestoreTime == 0 || lootPickPocketRestoreTime < time(nullptr); }
void SetPickPocketLootTime() { lootPickPocketRestoreTime = time(nullptr) + MINUTE + GetCorpseDelay() + GetRespawnTime(); }
void ResetPickPocketLootTime() { lootPickPocketRestoreTime = 0; }
void SetLootRecipient (Unit* unit, bool withGroup = true);
void AllLootRemovedFromCorpse();
uint16 GetLootMode() const { return m_LootMode; }
bool HasLootMode(uint16 lootMode) const { return m_LootMode & lootMode; }
void SetLootMode(uint16 lootMode) { m_LootMode = lootMode; }
void AddLootMode(uint16 lootMode) { m_LootMode |= lootMode; }
void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; }
void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; }
SpellInfo const* reachWithSpellAttack(Unit* victim);
SpellInfo const* reachWithSpellCure(Unit* victim);
uint32 m_spells[CREATURE_MAX_SPELLS];
CreatureSpellCooldowns m_CreatureSpellCooldowns;
uint32 m_ProhibitSchoolTime[7];
bool CanStartAttack(Unit const* u) const;
float GetAggroRange(Unit const* target) const;
float GetAttackDistance(Unit const* player) const;
void SendAIReaction(AiReaction reactionType);
Unit* SelectNearestTarget(float dist = 0, bool playerOnly = false) const;
Unit* SelectNearestTargetInAttackDistance(float dist) const;
void DoFleeToGetAssistance();
void CallForHelp(float fRadius);
void CallAssistance();
void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; }
void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; }
bool HasSearchedAssistance() { return m_AlreadySearchedAssistance; }
bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const;
bool _IsTargetAcceptable(const Unit* target) const;
bool _CanDetectFeignDeathOf(const Unit* target) const; // pussywizard
// pussywizard: updated at faction change, disable move in line of sight if actual faction is not hostile to anyone
void UpdateMoveInLineOfSightState();
bool IsMoveInLineOfSightDisabled() { return m_moveInLineOfSightDisabled; }
bool IsMoveInLineOfSightStrictlyDisabled() { return m_moveInLineOfSightStrictlyDisabled; }
MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }
public:
explicit Creature(bool isWorldObject = false);
virtual ~Creature();
void AddToWorld() override;
void RemoveFromWorld() override;
void SetObjectScale(float scale) override;
void SetDisplayId(uint32 modelId) override;
void DisappearAndDie();
bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData* data = nullptr);
bool LoadCreaturesAddon(bool reload = false);
void SelectLevel(bool changelevel = true);
void LoadEquipment(int8 id = 1, bool force = false);
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
void Update(uint32 time) override; // overwrited Unit::Update
void GetRespawnPosition(float& x, float& y, float& z, float* ori = NULL, float* dist = NULL) const;
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
uint32 GetCorpseDelay() const { return m_corpseDelay; }
bool IsRacialLeader() const { return GetCreatureTemplate()->RacialLeader; }
bool IsCivilian() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
bool IsTrigger() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER; }
bool IsGuard() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GUARD; }
bool CanWalk() const { return GetCreatureTemplate()->InhabitType & INHABIT_GROUND; }
bool CanSwim() const override { return (GetCreatureTemplate()->InhabitType & INHABIT_WATER) || IS_PLAYER_GUID(GetOwnerGUID()); }
bool CanFly() const override { return GetCreatureTemplate()->InhabitType & INHABIT_AIR; }
void SetReactState(ReactStates st) { m_reactState = st; }
ReactStates GetReactState() const { return m_reactState; }
bool HasReactState(ReactStates state) const { return (m_reactState == state); }
void InitializeReactState();
///// TODO RENAME THIS!!!!!
bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
bool isCanTrainingAndResetTalentsOf(Player* player) const;
bool CanCreatureAttack(Unit const* victim, bool skipDistCheck = false) const;
bool IsImmunedToSpell(SpellInfo const* spellInfo) override;
bool HasMechanicTemplateImmunity(uint32 mask) const;
// redefine Unit::IsImmunedToSpell
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override;
// redefine Unit::IsImmunedToSpellEffect
bool isElite() const
{
if (IsPet())
return false;
uint32 rank = GetCreatureTemplate()->rank;
return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
}
bool isWorldBoss() const
{
if (IsPet())
return false;
return GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_BOSS_MOB;
}
bool IsDungeonBoss() const;
bool IsImmuneToKnockback() const;
bool IsAvoidingAOE() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_AVOID_AOE; }
uint8 getLevelForTarget(WorldObject const* target) const override; // overwrite Unit::getLevelForTarget for boss level support
bool IsInEvadeMode() const { return HasUnitState(UNIT_STATE_EVADE); }
bool AIM_Initialize(CreatureAI* ai = nullptr);
void Motion_Initialize();
CreatureAI* AI() const { return (CreatureAI*)i_AI; }
bool SetWalk(bool enable) override;
bool SetDisableGravity(bool disable, bool packetOnly = false) override;
bool SetSwim(bool enable) override;
bool SetCanFly(bool enable, bool packetOnly = false) override;
bool SetWaterWalking(bool enable, bool packetOnly = false) override;
bool SetFeatherFall(bool enable, bool packetOnly = false) override;
bool SetHover(bool enable, bool packetOnly = false) override;
uint32 GetShieldBlockValue() const override
{
return (getLevel() / 2 + uint32(GetStat(STAT_STRENGTH) / 20));
}
SpellSchoolMask GetMeleeDamageSchoolMask() const override { return m_meleeDamageSchoolMask; }
void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
void _AddCreatureSpellCooldown(uint32 spell_id, uint32 end_time);
virtual void AddSpellCooldown(uint32 spell_id, uint32 /*itemid*/, uint32 end_time, bool needSendToClient = false, bool forceSendToSpectator = false) override;
virtual bool HasSpellCooldown(uint32 spell_id) const override;
uint32 GetSpellCooldown(uint32 spell_id) const;
void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override;
bool IsSpellProhibited(SpellSchoolMask idSchoolMask) const;
bool HasSpell(uint32 spellID) const override;
bool UpdateEntry(uint32 entry, const CreatureData* data = NULL, bool changelevel = true );
bool UpdateStats(Stats stat) override;
bool UpdateAllStats() override;
void UpdateResistances(uint32 school) override;
void UpdateArmor() override;
void UpdateMaxHealth() override;
void UpdateMaxPower(Powers power) override;
void UpdateAttackPowerAndDamage(bool ranged = false) override;
void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) override;
void SetCanDualWield(bool value) override;
int8 GetOriginalEquipmentId() const { return m_originalEquipmentId; }
uint8 GetCurrentEquipmentId() { return m_equipmentId; }
void SetCurrentEquipmentId(uint8 id) { m_equipmentId = id; }
float GetSpellDamageMod(int32 Rank);
VendorItemData const* GetVendorItems() const;
uint32 GetVendorItemCurrentCount(VendorItem const* vItem);
uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count);
TrainerSpellData const* GetTrainerSpells() const;
CreatureTemplate const* GetCreatureTemplate() const { return m_creatureInfo; }
CreatureData const* GetCreatureData() const { return m_creatureData; }
CreatureAddon const* GetCreatureAddon() const;
std::string GetAIName() const;
std::string GetScriptName() const;
uint32 GetScriptId() const;
// override WorldObject function for proper name localization
std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override;
void setDeathState(DeathState s, bool despawn = false) override; // override virtual Unit::setDeathState
bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false, true); }
bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true, bool gridLoad = false);
void SaveToDB();
// overriden in Pet
virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
virtual void DeleteFromDB(); // overriden in Pet
Loot loot;
uint64 GetLootRecipientGUID() const { return m_lootRecipient; }
Player* GetLootRecipient() const;
Group* GetLootRecipientGroup() const;
bool hasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
bool isTappedBy(Player const* player) const; // return true if the creature is tapped by the player or a member of his party.
bool CanGeneratePickPocketLoot() const { return lootPickPocketRestoreTime == 0 || lootPickPocketRestoreTime < time(nullptr); }
void SetPickPocketLootTime() { lootPickPocketRestoreTime = time(nullptr) + MINUTE + GetCorpseDelay() + GetRespawnTime(); }
void ResetPickPocketLootTime() { lootPickPocketRestoreTime = 0; }
void SetLootRecipient (Unit* unit, bool withGroup = true);
void AllLootRemovedFromCorpse();
uint16 GetLootMode() const { return m_LootMode; }
bool HasLootMode(uint16 lootMode) const { return m_LootMode & lootMode; }
void SetLootMode(uint16 lootMode) { m_LootMode = lootMode; }
void AddLootMode(uint16 lootMode) { m_LootMode |= lootMode; }
void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; }
void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; }
SpellInfo const* reachWithSpellAttack(Unit* victim);
SpellInfo const* reachWithSpellCure(Unit* victim);
uint32 m_spells[CREATURE_MAX_SPELLS];
CreatureSpellCooldowns m_CreatureSpellCooldowns;
uint32 m_ProhibitSchoolTime[7];
bool CanStartAttack(Unit const* u) const;
float GetAggroRange(Unit const* target) const;
float GetAttackDistance(Unit const* player) const;
void SendAIReaction(AiReaction reactionType);
Unit* SelectNearestTarget(float dist = 0, bool playerOnly = false) const;
Unit* SelectNearestTargetInAttackDistance(float dist) const;
void DoFleeToGetAssistance();
void CallForHelp(float fRadius);
void CallAssistance();
void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; }
void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; }
bool HasSearchedAssistance() { return m_AlreadySearchedAssistance; }
bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const;
bool _IsTargetAcceptable(const Unit* target) const;
bool _CanDetectFeignDeathOf(const Unit* target) const; // pussywizard
// pussywizard: updated at faction change, disable move in line of sight if actual faction is not hostile to anyone
void UpdateMoveInLineOfSightState();
bool IsMoveInLineOfSightDisabled() { return m_moveInLineOfSightDisabled; }
bool IsMoveInLineOfSightStrictlyDisabled() { return m_moveInLineOfSightStrictlyDisabled; }
MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }
void RemoveCorpse(bool setSpawnTime = true, bool skipVisibility = false);
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0);
time_t const& GetRespawnTime() const { return m_respawnTime; }
time_t GetRespawnTimeEx() const;
void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(nullptr) + respawn : 0; }
void Respawn(bool force = false);
void SaveRespawnTime() override;
uint32 GetRespawnDelay() const { return m_respawnDelay; }
void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
void RemoveCorpse(bool setSpawnTime = true, bool skipVisibility = false);
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0);
time_t const& GetRespawnTime() const { return m_respawnTime; }
time_t GetRespawnTimeEx() const;
void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(nullptr) + respawn : 0; }
void Respawn(bool force = false);
void SaveRespawnTime() override;
uint32 GetRespawnDelay() const { return m_respawnDelay; }
void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
float GetWanderDistance() const { return m_wanderDistance; }
void SetWanderDistance(float dist) { m_wanderDistance = dist; }
uint32 m_groupLootTimer; // (msecs)timer used for group loot
uint32 lootingGroupLowGUID; // used to find group which is looting corpse
void SendZoneUnderAttackMessage(Player* attacker);
void SetInCombatWithZone();
bool hasQuest(uint32 quest_id) const override;
bool hasInvolvedQuest(uint32 quest_id) const override;
bool isRegeneratingHealth() { return m_regenHealth; }
void SetRegeneratingHealth(bool c) { m_regenHealth = c; }
virtual uint8 GetPetAutoSpellSize() const { return MAX_SPELL_CHARM; }
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
{
if (pos >= MAX_SPELL_CHARM || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
return 0;
else
return m_charmInfo->GetCharmSpell(pos)->GetAction();
}
void SetPosition(float x, float y, float z, float o);
void SetPosition(const Position &pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); }
void SetHomePosition(float x, float y, float z, float o) { m_homePosition.Relocate(x, y, z, o); }
void SetHomePosition(const Position &pos) { m_homePosition.Relocate(pos); }
void GetHomePosition(float& x, float& y, float& z, float& ori) const { m_homePosition.GetPosition(x, y, z, ori); }
Position const& GetHomePosition() const { return m_homePosition; }
void SetTransportHomePosition(float x, float y, float z, float o) { m_transportHomePosition.Relocate(x, y, z, o); }
void SetTransportHomePosition(const Position &pos) { m_transportHomePosition.Relocate(pos); }
void GetTransportHomePosition(float& x, float& y, float& z, float& ori) const { m_transportHomePosition.GetPosition(x, y, z, ori); }
Position const& GetTransportHomePosition() const { return m_transportHomePosition; }
uint32 GetWaypointPath() const { return m_path_id; }
void LoadPath(uint32 pathid) { m_path_id = pathid; }
float GetWanderDistance() const { return m_wanderDistance; }
void SetWanderDistance(float dist) { m_wanderDistance = dist; }
uint32 m_groupLootTimer; // (msecs)timer used for group loot
uint32 lootingGroupLowGUID; // used to find group which is looting corpse
void SendZoneUnderAttackMessage(Player* attacker);
void SetInCombatWithZone();
bool hasQuest(uint32 quest_id) const override;
bool hasInvolvedQuest(uint32 quest_id) const override;
bool isRegeneratingHealth() { return m_regenHealth; }
void SetRegeneratingHealth(bool c) { m_regenHealth = c; }
virtual uint8 GetPetAutoSpellSize() const { return MAX_SPELL_CHARM; }
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
{
if (pos >= MAX_SPELL_CHARM || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
return 0;
else
return m_charmInfo->GetCharmSpell(pos)->GetAction();
}
void SetPosition(float x, float y, float z, float o);
void SetPosition(const Position& pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); }
void SetHomePosition(float x, float y, float z, float o) { m_homePosition.Relocate(x, y, z, o); }
void SetHomePosition(const Position& pos) { m_homePosition.Relocate(pos); }
void GetHomePosition(float& x, float& y, float& z, float& ori) const { m_homePosition.GetPosition(x, y, z, ori); }
Position const& GetHomePosition() const { return m_homePosition; }
uint32 GetCurrentWaypointID() const { return m_waypointID; }
void UpdateWaypointID(uint32 wpID){ m_waypointID = wpID; }
void SetTransportHomePosition(float x, float y, float z, float o) { m_transportHomePosition.Relocate(x, y, z, o); }
void SetTransportHomePosition(const Position& pos) { m_transportHomePosition.Relocate(pos); }
void GetTransportHomePosition(float& x, float& y, float& z, float& ori) const { m_transportHomePosition.GetPosition(x, y, z, ori); }
Position const& GetTransportHomePosition() const { return m_transportHomePosition; }
void SearchFormation();
CreatureGroup* GetFormation() const { return m_formation; }
void SetFormation(CreatureGroup* formation) { m_formation = formation; }
uint32 GetWaypointPath() const { return m_path_id; }
void LoadPath(uint32 pathid) { m_path_id = pathid; }
Unit* SelectVictim();
uint32 GetCurrentWaypointID() const { return m_waypointID; }
void UpdateWaypointID(uint32 wpID) { m_waypointID = wpID; }
void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; }
bool IsReputationGainDisabled() const { return DisableReputationGain; }
bool IsDamageEnoughForLootingAndReward() const { return m_PlayerDamageReq == 0; }
void LowerPlayerDamageReq(uint32 unDamage)
{
if (m_PlayerDamageReq)
m_PlayerDamageReq > unDamage ? m_PlayerDamageReq -= unDamage : m_PlayerDamageReq = 0;
}
void ResetPlayerDamageReq() { m_PlayerDamageReq = GetHealth() / 2; }
uint32 m_PlayerDamageReq;
void SearchFormation();
CreatureGroup* GetFormation() const { return m_formation; }
void SetFormation(CreatureGroup* formation) { m_formation = formation; }
uint32 GetOriginalEntry() const { return m_originalEntry; }
void SetOriginalEntry(uint32 entry) { m_originalEntry = entry; }
Unit* SelectVictim();
static float _GetDamageMod(int32 Rank);
void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; }
bool IsReputationGainDisabled() const { return DisableReputationGain; }
bool IsDamageEnoughForLootingAndReward() const { return m_PlayerDamageReq == 0; }
void LowerPlayerDamageReq(uint32 unDamage)
{
if (m_PlayerDamageReq)
m_PlayerDamageReq > unDamage ? m_PlayerDamageReq -= unDamage : m_PlayerDamageReq = 0;
}
void ResetPlayerDamageReq() { m_PlayerDamageReq = GetHealth() / 2; }
uint32 m_PlayerDamageReq;
float m_SightDistance, m_CombatDistance;
uint32 GetOriginalEntry() const { return m_originalEntry; }
void SetOriginalEntry(uint32 entry) { m_originalEntry = entry; }
bool m_isTempWorldObject; //true when possessed
static float _GetDamageMod(int32 Rank);
// Handling caster facing during spellcast
void SetTarget(uint64 guid) override;
void FocusTarget(Spell const* focusSpell, WorldObject const* target);
void ReleaseFocus(Spell const* focusSpell);
float m_SightDistance, m_CombatDistance;
// Part of Evade mechanics
time_t GetLastDamagedTime() const { return _lastDamagedTime; }
void SetLastDamagedTime(time_t val) { _lastDamagedTime = val; }
bool m_isTempWorldObject; //true when possessed
protected:
bool CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, const CreatureData* data = nullptr);
bool InitEntry(uint32 entry, const CreatureData* data=NULL);
// Handling caster facing during spellcast
void SetTarget(uint64 guid) override;
void FocusTarget(Spell const* focusSpell, WorldObject const* target);
void ReleaseFocus(Spell const* focusSpell);
// vendor items
VendorItemCounts m_vendorItemCounts;
// Part of Evade mechanics
time_t GetLastDamagedTime() const { return _lastDamagedTime; }
void SetLastDamagedTime(time_t val) { _lastDamagedTime = val; }
static float _GetHealthMod(int32 Rank);
protected:
bool CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, const CreatureData* data = nullptr);
bool InitEntry(uint32 entry, const CreatureData* data = NULL);
uint64 m_lootRecipient;
uint32 m_lootRecipientGroup;
// vendor items
VendorItemCounts m_vendorItemCounts;
/// Timers
time_t m_corpseRemoveTime; // (msecs)timer for death or corpse disappearance
time_t m_respawnTime; // (secs) time of next respawn
uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
float m_wanderDistance;
uint16 m_transportCheckTimer;
uint32 lootPickPocketRestoreTime;
static float _GetHealthMod(int32 Rank);
ReactStates m_reactState; // for AI, not charmInfo
void RegenerateHealth();
void Regenerate(Powers power);
MovementGeneratorType m_defaultMovementType;
uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
uint8 m_equipmentId;
int8 m_originalEquipmentId; // can be -1
uint64 m_lootRecipient;
uint32 m_lootRecipientGroup;
bool m_AlreadyCallAssistance;
bool m_AlreadySearchedAssistance;
bool m_regenHealth;
bool m_AI_locked;
/// Timers
time_t m_corpseRemoveTime; // (msecs)timer for death or corpse disappearance
time_t m_respawnTime; // (secs) time of next respawn
uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
float m_wanderDistance;
uint16 m_transportCheckTimer;
uint32 lootPickPocketRestoreTime;
SpellSchoolMask m_meleeDamageSchoolMask;
uint32 m_originalEntry;
bool m_moveInLineOfSightDisabled;
bool m_moveInLineOfSightStrictlyDisabled;
ReactStates m_reactState; // for AI, not charmInfo
void RegenerateHealth();
void Regenerate(Powers power);
MovementGeneratorType m_defaultMovementType;
uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
uint8 m_equipmentId;
int8 m_originalEquipmentId; // can be -1
Position m_homePosition;
Position m_transportHomePosition;
bool m_AlreadyCallAssistance;
bool m_AlreadySearchedAssistance;
bool m_regenHealth;
bool m_AI_locked;
bool DisableReputationGain;
SpellSchoolMask m_meleeDamageSchoolMask;
uint32 m_originalEntry;
CreatureTemplate const* m_creatureInfo; // in difficulty mode > 0 can different from sObjectMgr->GetCreatureTemplate(GetEntry())
CreatureData const* m_creatureData;
bool m_moveInLineOfSightDisabled;
bool m_moveInLineOfSightStrictlyDisabled;
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
Position m_homePosition;
Position m_transportHomePosition;
bool IsInvisibleDueToDespawn() const override;
bool CanAlwaysSee(WorldObject const* obj) const override;
bool DisableReputationGain;
private:
void ForcedDespawn(uint32 timeMSToDespawn = 0);
CreatureTemplate const* m_creatureInfo; // in difficulty mode > 0 can different from sObjectMgr->GetCreatureTemplate(GetEntry())
CreatureData const* m_creatureData;
//WaypointMovementGenerator vars
uint32 m_waypointID;
uint32 m_path_id;
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
//Formation var
CreatureGroup* m_formation;
bool TriggerJustRespawned;
bool IsInvisibleDueToDespawn() const override;
bool CanAlwaysSee(WorldObject const* obj) const override;
time_t _lastDamagedTime; // Part of Evade mechanics
private:
void ForcedDespawn(uint32 timeMSToDespawn = 0);
Spell const* _focusSpell; ///> Locks the target during spell cast for proper facing
//WaypointMovementGenerator vars
uint32 m_waypointID;
uint32 m_path_id;
//Formation var
CreatureGroup* m_formation;
bool TriggerJustRespawned;
time_t _lastDamagedTime; // Part of Evade mechanics
Spell const* _focusSpell; ///> Locks the target during spell cast for proper facing
};
class AssistDelayEvent : public BasicEvent
{
public:
AssistDelayEvent(uint64 victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
public:
AssistDelayEvent(uint64 victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
bool Execute(uint64 e_time, uint32 p_time);
void AddAssistant(uint64 guid) { m_assistants.push_back(guid); }
private:
AssistDelayEvent();
bool Execute(uint64 e_time, uint32 p_time);
void AddAssistant(uint64 guid) { m_assistants.push_back(guid); }
private:
AssistDelayEvent();
uint64 m_victim;
std::list<uint64> m_assistants;
Unit& m_owner;
uint64 m_victim;
std::list<uint64> m_assistants;
Unit& m_owner;
};
class ForcedDespawnDelayEvent : public BasicEvent
{
public:
ForcedDespawnDelayEvent(Creature& owner) : BasicEvent(), m_owner(owner) { }
bool Execute(uint64 e_time, uint32 p_time);
public:
ForcedDespawnDelayEvent(Creature& owner) : BasicEvent(), m_owner(owner) { }
bool Execute(uint64 e_time, uint32 p_time);
private:
Creature& m_owner;
private:
Creature& m_owner;
};
#endif

View File

@@ -136,8 +136,7 @@ void FormationMgr::LoadCreatureFormations()
CreatureGroupMap[memberGUID] = group_member;
++count;
}
while (result->NextRow());
} while (result->NextRow());
sLog->outString(">> Loaded %u creatures in formations in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
@@ -248,7 +247,7 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z, bool run)
continue;
// Xinef: this should be automatized, if turn angle is greater than PI/2 (90<39>) we should swap formation angle
if (M_PI - fabs(fabs(m_leader->GetOrientation() - pathAngle) - M_PI) > M_PI*0.50f)
if (M_PI - fabs(fabs(m_leader->GetOrientation() - pathAngle) - M_PI) > M_PI * 0.50f)
{
// pussywizard: in both cases should be 2*M_PI - follow_angle
// pussywizard: also, GetCurrentWaypointID() returns 0..n-1, while point_1 must be > 0, so +1

View File

@@ -28,47 +28,47 @@ typedef std::unordered_map<uint32/*memberDBGUID*/, FormationInfo*> CreatureGro
class FormationMgr
{
public:
FormationMgr() { }
~FormationMgr();
static FormationMgr* instance();
void AddCreatureToGroup(uint32 group_id, Creature* creature);
void RemoveCreatureFromGroup(CreatureGroup* group, Creature* creature);
void LoadCreatureFormations();
CreatureGroupInfoType CreatureGroupMap;
public:
FormationMgr() { }
~FormationMgr();
static FormationMgr* instance();
void AddCreatureToGroup(uint32 group_id, Creature* creature);
void RemoveCreatureFromGroup(CreatureGroup* group, Creature* creature);
void LoadCreatureFormations();
CreatureGroupInfoType CreatureGroupMap;
};
class CreatureGroup
{
public:
// pussywizard: moved public to the top so it compiles and typedef is public
typedef std::map<Creature*, FormationInfo*> CreatureGroupMemberType;
public:
// pussywizard: moved public to the top so it compiles and typedef is public
typedef std::map<Creature*, FormationInfo*> CreatureGroupMemberType;
//Group cannot be created empty
explicit CreatureGroup(uint32 id) : m_leader(nullptr), m_groupID(id), m_Formed(false) {}
~CreatureGroup() {}
//Group cannot be created empty
explicit CreatureGroup(uint32 id) : m_leader(nullptr), m_groupID(id), m_Formed(false) {}
~CreatureGroup() {}
Creature* getLeader() const { return m_leader; }
uint32 GetId() const { return m_groupID; }
bool isEmpty() const { return m_members.empty(); }
bool isFormed() const { return m_Formed; }
const CreatureGroupMemberType& GetMembers() const { return m_members; }
Creature* getLeader() const { return m_leader; }
uint32 GetId() const { return m_groupID; }
bool isEmpty() const { return m_members.empty(); }
bool isFormed() const { return m_Formed; }
const CreatureGroupMemberType& GetMembers() const { return m_members; }
void AddMember(Creature* member);
void RemoveMember(Creature* member);
void FormationReset(bool dismiss);
void AddMember(Creature* member);
void RemoveMember(Creature* member);
void FormationReset(bool dismiss);
void LeaderMoveTo(float x, float y, float z, bool run);
void MemberAttackStart(Creature* member, Unit* target);
void LeaderMoveTo(float x, float y, float z, bool run);
void MemberAttackStart(Creature* member, Unit* target);
private:
Creature* m_leader; //Important do not forget sometimes to work with pointers instead synonims :D:D
CreatureGroupMemberType m_members;
private:
Creature* m_leader; //Important do not forget sometimes to work with pointers instead synonims :D:D
CreatureGroupMemberType m_members;
uint32 m_groupID;
bool m_Formed;
uint32 m_groupID;
bool m_Formed;
};
#define sFormationMgr FormationMgr::instance()

View File

@@ -160,7 +160,7 @@ void GossipMenu::ClearMenu()
PlayerMenu::PlayerMenu(WorldSession* session) : _session(session)
{
_gossipMenu.SetLocale(session->GetSessionDbLocaleIndex());
_gossipMenu.SetLocale(session->GetSessionDbLocaleIndex());
}
PlayerMenu::~PlayerMenu()
@@ -179,7 +179,7 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
//ACE_Read_Guard<ACE_RW_Thread_Mutex> lock1(_gossipMenu.GetLock());
//ACE_Read_Guard<ACE_RW_Thread_Mutex> lock2(_questMenu.GetLock());
WorldPacket data(SMSG_GOSSIP_MESSAGE, 24 + _gossipMenu.GetMenuItemCount()*100 + _questMenu.GetMenuItemCount()*75); // guess size
WorldPacket data(SMSG_GOSSIP_MESSAGE, 24 + _gossipMenu.GetMenuItemCount() * 100 + _questMenu.GetMenuItemCount() * 75); // guess size
data << uint64(objectGUID);
data << uint32(_gossipMenu.GetMenuId()); // new 2.4.0
data << uint32(titleTextId);
@@ -198,7 +198,7 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
data << uint32(_questMenu.GetMenuItemCount()); // max count 0x20
uint32 count = 0;
for (uint32 iI = 0; iI < _questMenu.GetMenuItemCount(); ++iI)
{
++count;
@@ -216,8 +216,8 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
int32 locale = _session->GetSessionDbLocaleIndex();
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
ObjectMgr::GetLocaleString(localeData->Title, locale, title);
data << title;
}
data << title;
}
}
_session->SendPacket(&data);
@@ -299,7 +299,7 @@ void QuestMenu::ClearMenu()
void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID)
{
WorldPacket data(SMSG_QUESTGIVER_QUEST_LIST, 100 + _questMenu.GetMenuItemCount()*75); // guess size
WorldPacket data(SMSG_QUESTGIVER_QUEST_LIST, 100 + _questMenu.GetMenuItemCount() * 75); // guess size
data << uint64(npcGUID);
data << Title;
data << uint32(eEmote._Delay); // player emote
@@ -322,7 +322,7 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string
int32 locale = _session->GetSessionDbLocaleIndex();
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
ObjectMgr::GetLocaleString(localeData->Title, locale, title);
data << uint32(questID);
data << uint32(qmi.QuestIcon);
data << int32(quest->GetQuestLevel());
@@ -353,12 +353,12 @@ void PlayerMenu::SendQuestGiverStatus(uint8 questStatus, uint64 npcGUID) const
void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const
{
std::string questTitle = quest->GetTitle();
std::string questDetails = quest->GetDetails();
std::string questObjectives = quest->GetObjectives();
std::string questAreaDescription = quest->GetAreaDescription();
std::string questTitle = quest->GetTitle();
std::string questDetails = quest->GetDetails();
std::string questObjectives = quest->GetObjectives();
std::string questAreaDescription = quest->GetAreaDescription();
int32 locale = _session->GetSessionDbLocaleIndex();
int32 locale = _session->GetSessionDbLocaleIndex();
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
{
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
@@ -366,7 +366,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
ObjectMgr::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription);
}
WorldPacket data(SMSG_QUESTGIVER_QUEST_DETAILS, 500); // guess size
data << uint64(npcGUID);
data << uint64(_session->GetPlayer()->GetDivider());
@@ -389,7 +389,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
else
{
data << uint32(quest->GetRewChoiceItemsCount());
for (uint32 i=0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
{
if (!quest->RewardChoiceItemId[i])
continue;
@@ -405,7 +405,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
data << uint32(quest->GetRewItemsCount());
for (uint32 i=0; i < QUEST_REWARDS_COUNT; ++i)
for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i)
{
if (!quest->RewardItemId[i])
continue;
@@ -573,11 +573,11 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
data << uint32(0); // req source count?
}
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
data << uint32(quest->RequiredItemId[i]);
data << uint32(quest->RequiredItemCount[i]);
}
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
data << uint32(quest->RequiredItemId[i]);
data << uint32(quest->RequiredItemCount[i]);
}
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
data << questObjectiveText[i];
@@ -590,16 +590,16 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const
{
std::string questTitle = quest->GetTitle();
std::string questTitle = quest->GetTitle();
std::string RewardText = quest->GetOfferRewardText();
int32 locale = _session->GetSessionDbLocaleIndex();
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
int32 locale = _session->GetSessionDbLocaleIndex();
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
if (QuestOfferRewardLocale const* questOfferRewardLocale = sObjectMgr->GetQuestOfferRewardLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(questOfferRewardLocale->RewardText, locale, RewardText);
WorldPacket data(SMSG_QUESTGIVER_OFFER_REWARD, 400); // guess size
data << uint64(npcGUID);
data << uint32(quest->GetQuestId());
@@ -626,7 +626,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b
}
data << uint32(quest->GetRewChoiceItemsCount());
for (uint32 i=0; i < quest->GetRewChoiceItemsCount(); ++i)
for (uint32 i = 0; i < quest->GetRewChoiceItemsCount(); ++i)
{
data << uint32(quest->RewardChoiceItemId[i]);
data << uint32(quest->RewardChoiceItemCount[i]);
@@ -683,10 +683,10 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID,
// We can always call to RequestItems, but this packet only goes out if there are actually
// items. Otherwise, we'll skip straight to the OfferReward
std::string questTitle = quest->GetTitle();
std::string requestItemsText = quest->GetRequestItemsText();
std::string questTitle = quest->GetTitle();
std::string requestItemsText = quest->GetRequestItemsText();
int32 locale = _session->GetSessionDbLocaleIndex();
int32 locale = _session->GetSessionDbLocaleIndex();
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
@@ -704,7 +704,7 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID,
QuestStatusMap::iterator qsitr = _player->getQuestStatusMap().find(quest->GetQuestId());
if (qsitr != _player->getQuestStatusMap().end() && qsitr->second.Status == QUEST_STATUS_INCOMPLETE)
{
for (uint8 i=0; i<6; ++i)
for (uint8 i = 0; i < 6; ++i)
if (quest->RequiredItemId[i] && qsitr->second.ItemCount[i] < quest->RequiredItemCount[i])
if (_player->GetItemCount(quest->RequiredItemId[i], false) >= quest->RequiredItemCount[i])
qsitr->second.ItemCount[i] = quest->RequiredItemCount[i];

View File

@@ -147,132 +147,132 @@ typedef std::vector<QuestMenuItem> QuestMenuItemList;
class GossipMenu
{
public:
GossipMenu();
~GossipMenu();
public:
GossipMenu();
~GossipMenu();
void AddMenuItem(int32 menuItemId, uint8 icon, std::string const& message, uint32 sender, uint32 action, std::string const& boxMessage, uint32 boxMoney, bool coded = false);
void AddMenuItem(uint32 menuId, uint32 menuItemId, uint32 sender, uint32 action);
void SetMenuId(uint32 menu_id) { _menuId = menu_id; }
uint32 GetMenuId() const { return _menuId; }
void SetLocale(LocaleConstant locale) { _locale = locale; }
LocaleConstant GetLocale() const { return _locale; }
void AddMenuItem(int32 menuItemId, uint8 icon, std::string const& message, uint32 sender, uint32 action, std::string const& boxMessage, uint32 boxMoney, bool coded = false);
void AddMenuItem(uint32 menuId, uint32 menuItemId, uint32 sender, uint32 action);
void AddGossipMenuItemData(uint32 menuItemId, uint32 gossipActionMenuId, uint32 gossipActionPoi);
void SetMenuId(uint32 menu_id) { _menuId = menu_id; }
uint32 GetMenuId() const { return _menuId; }
void SetLocale(LocaleConstant locale) { _locale = locale; }
LocaleConstant GetLocale() const { return _locale; }
uint32 GetMenuItemCount() const
{
return _menuItems.size();
}
void AddGossipMenuItemData(uint32 menuItemId, uint32 gossipActionMenuId, uint32 gossipActionPoi);
bool Empty() const
{
return _menuItems.empty();
}
uint32 GetMenuItemCount() const
{
return _menuItems.size();
}
GossipMenuItem const* GetItem(uint32 id) const
{
GossipMenuItemContainer::const_iterator itr = _menuItems.find(id);
if (itr != _menuItems.end())
return &itr->second;
bool Empty() const
{
return _menuItems.empty();
}
return nullptr;
}
GossipMenuItem const* GetItem(uint32 id) const
{
GossipMenuItemContainer::const_iterator itr = _menuItems.find(id);
if (itr != _menuItems.end())
return &itr->second;
GossipMenuItemData const* GetItemData(uint32 indexId) const
{
GossipMenuItemDataContainer::const_iterator itr = _menuItemData.find(indexId);
if (itr != _menuItemData.end())
return &itr->second;
return nullptr;
}
return nullptr;
}
GossipMenuItemData const* GetItemData(uint32 indexId) const
{
GossipMenuItemDataContainer::const_iterator itr = _menuItemData.find(indexId);
if (itr != _menuItemData.end())
return &itr->second;
uint32 GetMenuItemSender(uint32 menuItemId) const;
uint32 GetMenuItemAction(uint32 menuItemId) const;
bool IsMenuItemCoded(uint32 menuItemId) const;
return nullptr;
}
void ClearMenu();
uint32 GetMenuItemSender(uint32 menuItemId) const;
uint32 GetMenuItemAction(uint32 menuItemId) const;
bool IsMenuItemCoded(uint32 menuItemId) const;
GossipMenuItemContainer const& GetMenuItems() const
{
return _menuItems;
}
void ClearMenu();
private:
GossipMenuItemContainer _menuItems;
GossipMenuItemDataContainer _menuItemData;
uint32 _menuId;
LocaleConstant _locale;
GossipMenuItemContainer const& GetMenuItems() const
{
return _menuItems;
}
private:
GossipMenuItemContainer _menuItems;
GossipMenuItemDataContainer _menuItemData;
uint32 _menuId;
LocaleConstant _locale;
};
class QuestMenu
{
public:
QuestMenu();
~QuestMenu();
public:
QuestMenu();
~QuestMenu();
void AddMenuItem(uint32 QuestId, uint8 Icon);
void ClearMenu();
void AddMenuItem(uint32 QuestId, uint8 Icon);
void ClearMenu();
uint8 GetMenuItemCount() const
{
return _questMenuItems.size();
}
uint8 GetMenuItemCount() const
{
return _questMenuItems.size();
}
bool Empty() const
{
return _questMenuItems.empty();
}
bool Empty() const
{
return _questMenuItems.empty();
}
bool HasItem(uint32 questId) const;
bool HasItem(uint32 questId) const;
QuestMenuItem const& GetItem(uint16 index) const
{
return _questMenuItems[index];
}
QuestMenuItem const& GetItem(uint16 index) const
{
return _questMenuItems[index];
}
private:
QuestMenuItemList _questMenuItems;
private:
QuestMenuItemList _questMenuItems;
};
class PlayerMenu
{
public:
explicit PlayerMenu(WorldSession* session);
~PlayerMenu();
public:
explicit PlayerMenu(WorldSession* session);
~PlayerMenu();
GossipMenu& GetGossipMenu() { return _gossipMenu; }
QuestMenu& GetQuestMenu() { return _questMenu; }
GossipMenu& GetGossipMenu() { return _gossipMenu; }
QuestMenu& GetQuestMenu() { return _questMenu; }
bool Empty() const { return _gossipMenu.Empty() && _questMenu.Empty(); }
bool Empty() const { return _gossipMenu.Empty() && _questMenu.Empty(); }
void ClearMenus();
uint32 GetGossipOptionSender(uint32 selection) const { return _gossipMenu.GetMenuItemSender(selection); }
uint32 GetGossipOptionAction(uint32 selection) const { return _gossipMenu.GetMenuItemAction(selection); }
bool IsGossipOptionCoded(uint32 selection) const { return _gossipMenu.IsMenuItemCoded(selection); }
void ClearMenus();
uint32 GetGossipOptionSender(uint32 selection) const { return _gossipMenu.GetMenuItemSender(selection); }
uint32 GetGossipOptionAction(uint32 selection) const { return _gossipMenu.GetMenuItemAction(selection); }
bool IsGossipOptionCoded(uint32 selection) const { return _gossipMenu.IsMenuItemCoded(selection); }
void SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const;
void SendCloseGossip() const;
void SendPointOfInterest(uint32 poiId) const;
void SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const;
void SendCloseGossip() const;
void SendPointOfInterest(uint32 poiId) const;
/*********************************************************/
/*** QUEST SYSTEM ***/
/*********************************************************/
void SendQuestGiverStatus(uint8 questStatus, uint64 npcGUID) const;
/*********************************************************/
/*** QUEST SYSTEM ***/
/*********************************************************/
void SendQuestGiverStatus(uint8 questStatus, uint64 npcGUID) const;
void SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID);
void SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID);
void SendQuestQueryResponse(Quest const* quest) const;
void SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const;
void SendQuestQueryResponse(Quest const* quest) const;
void SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const;
void SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const;
void SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, bool canComplete, bool closeOnCancel) const;
void SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const;
void SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, bool canComplete, bool closeOnCancel) const;
private:
GossipMenu _gossipMenu;
QuestMenu _questMenu;
WorldSession* _session;
private:
GossipMenu _gossipMenu;
QuestMenu _questMenu;
WorldSession* _session;
};
#endif

View File

@@ -14,20 +14,20 @@
#include "ScriptMgr.h"
TempSummon::TempSummon(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject) :
Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN),
m_timer(0), m_lifetime(0)
Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN),
m_timer(0), m_lifetime(0)
{
m_summonerGUID = owner;
m_unitTypeMask |= UNIT_MASK_SUMMON;
}
Unit* TempSummon::GetSummoner() const
{
{
return m_summonerGUID ? ObjectAccessor::GetUnit(*this, m_summonerGUID) : nullptr;
}
void TempSummon::Update(uint32 diff)
{
{
Creature::Update(diff);
if (m_deathState == DEAD)
@@ -41,19 +41,6 @@ void TempSummon::Update(uint32 diff)
case TEMPSUMMON_DESPAWNED:
break;
case TEMPSUMMON_TIMED_DESPAWN:
{
if (m_timer <= diff)
{
UnSummon();
return;
}
m_timer -= diff;
break;
}
case TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT:
{
if (!IsInCombat())
{
if (m_timer <= diff)
{
@@ -62,81 +49,94 @@ void TempSummon::Update(uint32 diff)
}
m_timer -= diff;
break;
}
else if (m_timer != m_lifetime)
m_timer = m_lifetime;
case TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT:
{
if (!IsInCombat())
{
if (m_timer <= diff)
{
UnSummon();
return;
}
break;
}
m_timer -= diff;
}
else if (m_timer != m_lifetime)
m_timer = m_lifetime;
break;
}
case TEMPSUMMON_CORPSE_TIMED_DESPAWN:
{
if (m_deathState == CORPSE)
{
if (m_timer <= diff)
if (m_deathState == CORPSE)
{
UnSummon();
return;
}
if (m_timer <= diff)
{
UnSummon();
return;
}
m_timer -= diff;
m_timer -= diff;
}
break;
}
break;
}
case TEMPSUMMON_CORPSE_DESPAWN:
{
// if m_deathState is DEAD, CORPSE was skipped
if (m_deathState == CORPSE)
{
UnSummon();
return;
}
// if m_deathState is DEAD, CORPSE was skipped
if (m_deathState == CORPSE)
{
UnSummon();
return;
}
break;
}
break;
}
case TEMPSUMMON_DEAD_DESPAWN:
{
break;
}
{
break;
}
case TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN:
{
// if m_deathState is DEAD, CORPSE was skipped
if (m_deathState == CORPSE)
{
UnSummon();
return;
}
// if m_deathState is DEAD, CORPSE was skipped
if (m_deathState == CORPSE)
{
UnSummon();
return;
}
if (!IsInCombat())
{
if (m_timer <= diff)
if (!IsInCombat())
{
UnSummon();
return;
if (m_timer <= diff)
{
UnSummon();
return;
}
else
m_timer -= diff;
}
else
m_timer -= diff;
else if (m_timer != m_lifetime)
m_timer = m_lifetime;
break;
}
else if (m_timer != m_lifetime)
m_timer = m_lifetime;
break;
}
case TEMPSUMMON_TIMED_OR_DEAD_DESPAWN:
{
if (!IsInCombat() && IsAlive())
{
if (m_timer <= diff)
if (!IsInCombat() && IsAlive())
{
UnSummon();
return;
if (m_timer <= diff)
{
UnSummon();
return;
}
else
m_timer -= diff;
}
else
m_timer -= diff;
else if (m_timer != m_lifetime)
m_timer = m_lifetime;
break;
}
else if (m_timer != m_lifetime)
m_timer = m_lifetime;
break;
}
default:
UnSummon();
sLog->outError("Temporary summoned creature (entry: %u) have unknown type %u of ", GetEntry(), m_type);
@@ -145,7 +145,7 @@ void TempSummon::Update(uint32 diff)
}
void TempSummon::InitStats(uint32 duration)
{
{
ASSERT(!IsPet());
Unit* owner = GetSummoner();
@@ -197,7 +197,7 @@ void TempSummon::InitStats(uint32 duration)
}
void TempSummon::InitSummon()
{
{
Unit* owner = GetSummoner();
if (owner)
{
@@ -211,12 +211,12 @@ void TempSummon::InitSummon()
}
void TempSummon::SetTempSummonType(TempSummonType type)
{
{
m_type = type;
}
void TempSummon::UnSummon(uint32 msTime)
{
{
if (msTime)
{
ForcedUnsummonDelayEvent* pEvent = new ForcedUnsummonDelayEvent(*this);
@@ -252,7 +252,7 @@ bool ForcedUnsummonDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
}
void TempSummon::RemoveFromWorld()
{
{
if (!IsInWorld())
return;
@@ -269,7 +269,7 @@ void TempSummon::RemoveFromWorld()
}
Minion::Minion(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject) : TempSummon(properties, owner, isWorldObject)
, m_owner(owner)
, m_owner(owner)
{
ASSERT(m_owner);
m_unitTypeMask |= UNIT_MASK_MINION;
@@ -277,12 +277,12 @@ Minion::Minion(SummonPropertiesEntry const* properties, uint64 owner, bool isWor
}
void Minion::InitStats(uint32 duration)
{
{
TempSummon::InitStats(duration);
SetReactState(REACT_PASSIVE);
Unit *m_owner = GetOwner();
Unit* m_owner = GetOwner();
SetCreatorGUID(m_owner->GetGUID());
setFaction(m_owner->getFaction());
@@ -290,11 +290,11 @@ void Minion::InitStats(uint32 duration)
}
void Minion::RemoveFromWorld()
{
{
if (!IsInWorld())
return;
if (Unit *owner = GetOwner())
if (Unit* owner = GetOwner())
owner->SetMinion(this, false);
TempSummon::RemoveFromWorld();
@@ -306,12 +306,12 @@ Unit* Minion::GetOwner() const
}
bool Minion::IsGuardianPet() const
{
{
return IsPet() || (m_Properties && m_Properties->Category == SUMMON_CATEGORY_PET);
}
void Minion::setDeathState(DeathState s, bool despawn)
{
{
Creature::setDeathState(s, despawn);
if (s == JUST_DIED && IsGuardianPet())
if (Unit* owner = GetOwner())
@@ -336,10 +336,10 @@ Guardian::Guardian(SummonPropertiesEntry const* properties, uint64 owner, bool i
}
void Guardian::InitStats(uint32 duration)
{
{
Minion::InitStats(duration);
Unit *m_owner = GetOwner();
Unit* m_owner = GetOwner();
InitStatsForLevel(m_owner->getLevel());
if (m_owner->GetTypeId() == TYPEID_PLAYER && HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN))
@@ -349,13 +349,13 @@ void Guardian::InitStats(uint32 duration)
}
void Guardian::InitSummon()
{
{
TempSummon::InitSummon();
Unit *m_owner = GetOwner();
Unit* m_owner = GetOwner();
if (m_owner->GetTypeId() == TYPEID_PLAYER
&& m_owner->GetMinionGUID() == GetGUID()
&& !m_owner->GetCharmGUID())
&& m_owner->GetMinionGUID() == GetGUID()
&& !m_owner->GetCharmGUID())
m_owner->ToPlayer()->CharmSpellInitialize();
}
@@ -366,14 +366,14 @@ Puppet::Puppet(SummonPropertiesEntry const* properties, uint64 owner) : Minion(p
}
void Puppet::InitStats(uint32 duration)
{
{
Minion::InitStats(duration);
SetLevel(GetOwner()->getLevel());
SetReactState(REACT_PASSIVE);
}
void Puppet::InitSummon()
{
{
Minion::InitSummon();
if (!SetCharmedBy(GetOwner(), CHARM_TYPE_POSSESS))
{
@@ -388,7 +388,7 @@ void Puppet::InitSummon()
}
void Puppet::Update(uint32 time)
{
{
Minion::Update(time);
//check if caster is channelling?
if (IsInWorld())
@@ -402,7 +402,7 @@ void Puppet::Update(uint32 time)
}
void Puppet::RemoveFromWorld()
{
{
if (!IsInWorld())
return;

View File

@@ -27,75 +27,75 @@ struct TempSummonData
class TempSummon : public Creature
{
public:
explicit TempSummon(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
virtual ~TempSummon() {}
void Update(uint32 time);
virtual void InitStats(uint32 lifetime);
virtual void InitSummon();
virtual void UnSummon(uint32 msTime = 0);
void RemoveFromWorld();
void SetTempSummonType(TempSummonType type);
void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) {}
Unit* GetSummoner() const;
uint64 GetSummonerGUID() { return m_summonerGUID; }
TempSummonType const& GetSummonType() { return m_type; }
uint32 GetTimer() { return m_timer; }
void SetTimer(uint32 t) { m_timer = t; }
public:
explicit TempSummon(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
virtual ~TempSummon() {}
void Update(uint32 time);
virtual void InitStats(uint32 lifetime);
virtual void InitSummon();
virtual void UnSummon(uint32 msTime = 0);
void RemoveFromWorld();
void SetTempSummonType(TempSummonType type);
void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) {}
Unit* GetSummoner() const;
uint64 GetSummonerGUID() { return m_summonerGUID; }
TempSummonType const& GetSummonType() { return m_type; }
uint32 GetTimer() { return m_timer; }
void SetTimer(uint32 t) { m_timer = t; }
const SummonPropertiesEntry* const m_Properties;
private:
TempSummonType m_type;
uint32 m_timer;
uint32 m_lifetime;
uint64 m_summonerGUID;
const SummonPropertiesEntry* const m_Properties;
private:
TempSummonType m_type;
uint32 m_timer;
uint32 m_lifetime;
uint64 m_summonerGUID;
};
class Minion : public TempSummon
{
public:
Minion(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
void InitStats(uint32 duration);
void RemoveFromWorld();
Unit* GetOwner() const;
float GetFollowAngle() const { return m_followAngle; }
void SetFollowAngle(float angle) { m_followAngle = angle; }
bool IsPetGhoul() const {return GetEntry() == 26125 /*normal ghoul*/ || GetEntry() == 30230 /*Raise Ally ghoul*/;} // Ghoul may be guardian or pet
bool IsGuardianPet() const;
void setDeathState(DeathState s, bool despawn = false); // override virtual Unit::setDeathState
protected:
const uint64 m_owner;
float m_followAngle;
public:
Minion(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
void InitStats(uint32 duration);
void RemoveFromWorld();
Unit* GetOwner() const;
float GetFollowAngle() const { return m_followAngle; }
void SetFollowAngle(float angle) { m_followAngle = angle; }
bool IsPetGhoul() const {return GetEntry() == 26125 /*normal ghoul*/ || GetEntry() == 30230 /*Raise Ally ghoul*/;} // Ghoul may be guardian or pet
bool IsGuardianPet() const;
void setDeathState(DeathState s, bool despawn = false); // override virtual Unit::setDeathState
protected:
const uint64 m_owner;
float m_followAngle;
};
class Guardian : public Minion
{
public:
Guardian(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
void InitStats(uint32 duration);
bool InitStatsForLevel(uint8 level);
void InitSummon();
public:
Guardian(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
void InitStats(uint32 duration);
bool InitStatsForLevel(uint8 level);
void InitSummon();
bool UpdateStats(Stats stat);
bool UpdateAllStats();
void UpdateArmor();
void UpdateMaxHealth();
void UpdateMaxPower(Powers power);
void UpdateAttackPowerAndDamage(bool ranged = false);
void UpdateDamagePhysical(WeaponAttackType attType);
bool UpdateStats(Stats stat);
bool UpdateAllStats();
void UpdateArmor();
void UpdateMaxHealth();
void UpdateMaxPower(Powers power);
void UpdateAttackPowerAndDamage(bool ranged = false);
void UpdateDamagePhysical(WeaponAttackType attType);
};
class Puppet : public Minion
{
public:
Puppet(SummonPropertiesEntry const* properties, uint64 owner);
void InitStats(uint32 duration);
void InitSummon();
void Update(uint32 time);
void RemoveFromWorld();
protected:
Player* GetOwner() const;
const uint64 m_owner;
public:
Puppet(SummonPropertiesEntry const* properties, uint64 owner);
void InitStats(uint32 duration);
void InitSummon();
void Update(uint32 time);
void RemoveFromWorld();
protected:
Player* GetOwner() const;
const uint64 m_owner;
};
class ForcedUnsummonDelayEvent : public BasicEvent