Project tidy up and sync

This commit is contained in:
Antz 2020-01-09 12:22:21 +00:00
parent 49fe617b55
commit 5531a0087d
44 changed files with 484 additions and 427 deletions

View file

@ -35,8 +35,8 @@
*/
#ifndef _AUCTION_HOUSE_MGR_H
#define _AUCTION_HOUSE_MGR_H
#ifndef MANGOS_H_AUCTION_HOUSE_MGR
#define MANGOS_H_AUCTION_HOUSE_MGR
#include "Common.h"
#include "DBCStructure.h"

View file

@ -207,7 +207,7 @@ void Creature::AddToWorld()
// Make active if required
if (sWorld.isForceLoadMap(GetMapId()) || (GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_ACTIVE))
SetActiveObjectState(true);
{ SetActiveObjectState(true); }
#ifdef ENABLE_ELUNA
if (!inWorld)
@ -407,7 +407,7 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameE
bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData* data /*=NULL*/, GameEventCreatureData const* eventData /*=NULL*/, bool preserveHPAndPower /*=true*/)
{
if (!InitEntry(Entry, data, eventData))
{ return false; }
{ return false; }
// creatures always have melee weapon ready if any
SetSheath(SHEATH_STATE_MELEE);
@ -422,9 +422,13 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData* data /*=
SelectLevel();
if (team == HORDE)
{ setFaction(GetCreatureInfo()->FactionHorde); }
{
setFaction(GetCreatureInfo()->FactionHorde);
}
else
{ setFaction(GetCreatureInfo()->FactionAlliance); }
{
setFaction(GetCreatureInfo()->FactionAlliance);
}
SetUInt32Value(UNIT_NPC_FLAGS, GetCreatureInfo()->NpcFlags);
@ -439,7 +443,9 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData* data /*=
// we may need to append or remove additional flags
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT))
{ unitFlags |= UNIT_FLAG_IN_COMBAT; }
{
unitFlags |= UNIT_FLAG_IN_COMBAT;
}
SetUInt32Value(UNIT_FIELD_FLAGS, unitFlags);
SetUInt32Value(UNIT_FIELD_FLAGS_2, unitFlags2);
@ -463,24 +469,34 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData* data /*=
if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(GetCreatureInfo()->FactionAlliance))
{
if (factionTemplate->factionFlags & FACTION_TEMPLATE_FLAG_PVP)
{ SetPvP(true); }
{
SetPvP(true);
}
else
{ SetPvP(false); }
{
SetPvP(false);
}
}
// Try difficulty dependend version before falling back to base entry
CreatureTemplateSpells const* templateSpells = sCreatureTemplateSpellsStorage.LookupEntry<CreatureTemplateSpells>(GetCreatureInfo()->Entry);
if (!templateSpells)
{ templateSpells = sCreatureTemplateSpellsStorage.LookupEntry<CreatureTemplateSpells>(GetEntry()); }
{
templateSpells = sCreatureTemplateSpellsStorage.LookupEntry<CreatureTemplateSpells>(GetEntry());
}
if (templateSpells)
for (int i = 0; i < CREATURE_MAX_SPELLS; ++i)
{ m_spells[i] = templateSpells->spells[i]; }
{
m_spells[i] = templateSpells->spells[i];
}
SetVehicleId(GetCreatureInfo()->VehicleTemplateId, 0);
// if eventData set then event active and need apply spell_start
if (eventData)
{ ApplyGameEventSpells(eventData, true); }
{
ApplyGameEventSpells(eventData, true);
}
return true;
}
@ -489,7 +505,9 @@ uint32 Creature::ChooseDisplayId(const CreatureInfo* cinfo, const CreatureData*
{
// Use creature event model explicit, override any other static models
if (eventData && eventData->modelid)
{ return eventData->modelid; }
{
return eventData->modelid;
}
// Use creature model explicit, override template (creature.modelid)
if (data && data->modelid_override)
@ -759,7 +777,9 @@ void Creature::RegeneratePower()
{
Modifier const* modifier = (*i)->GetModifier();
if (modifier->m_miscvalue == int32(powerType))
{
addValue += modifier->m_amount;
}
}
AuraList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT);
@ -767,7 +787,9 @@ void Creature::RegeneratePower()
{
Modifier const* modifier = (*i)->GetModifier();
if (modifier->m_miscvalue == int32(powerType))
{
addValue *= (modifier->m_amount + 100) / 100.0f;
}
}
ModifyPower(powerType, int32(addValue));
@ -823,7 +845,9 @@ void Creature::DoFleeToGetAssistance()
if (!pCreature)
{ SetFeared(true, getVictim()->GetObjectGuid(), 0 , sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_FLEE_DELAY)); }
else
{
GetMotionMaster()->MoveSeekAssistance(pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ());
}
}
}
@ -1187,7 +1211,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
{
// The following if-else assumes that there are 4 model fields and needs updating if this is changed.
static_assert(MAX_CREATURE_MODEL == 4, "Need to update custom model check for new/removed model fields.");
if (displayId != cinfo->ModelId[0] && displayId != cinfo->ModelId[1] &&
displayId != cinfo->ModelId[2] && displayId != cinfo->ModelId[3])
{
@ -1524,18 +1548,18 @@ float Creature::_GetSpellDamageMod(int32 Rank)
{
switch (Rank) // define rates for each elite rank
{
case CREATURE_ELITE_NORMAL:
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_NORMAL_SPELLDAMAGE);
case CREATURE_ELITE_ELITE:
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE);
case CREATURE_ELITE_RAREELITE:
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE);
case CREATURE_ELITE_WORLDBOSS:
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE);
case CREATURE_ELITE_RARE:
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_RARE_SPELLDAMAGE);
default:
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE);
case CREATURE_ELITE_NORMAL:
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_NORMAL_SPELLDAMAGE);
case CREATURE_ELITE_ELITE:
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE);
case CREATURE_ELITE_RAREELITE:
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE);
case CREATURE_ELITE_WORLDBOSS:
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE);
case CREATURE_ELITE_RARE:
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_RARE_SPELLDAMAGE);
default:
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE);
}
}
@ -2187,19 +2211,29 @@ bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /
bool Creature::CanInitiateAttack()
{
if (hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_DIED))
{ return false; }
{
return false;
}
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE))
{ return false; }
{
return false;
}
if (isPassiveToHostile())
{ return false; }
{
return false;
}
if (m_aggroDelay != 0)
{
return false;
}
if (!CanAttackByItself())
{
return false;
}
return true;
}
@ -2502,7 +2536,9 @@ bool Creature::HasCategoryCooldown(uint32 spell_id) const
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
if (!spellInfo)
{ return false; }
{
return false;
}
CreatureSpellCooldowns::const_iterator itr = m_CreatureCategoryCooldowns.find(spellInfo->GetCategory());
return (itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->GetCategoryRecoveryTime() / IN_MILLISECONDS)) > time(NULL));
@ -3036,9 +3072,13 @@ void Creature::SetRoot(bool enable)
void Creature::SetWaterWalk(bool enable)
{
if (enable)
{
m_movementInfo.AddMovementFlag(MOVEFLAG_WATERWALKING);
}
else
{
m_movementInfo.RemoveMovementFlag(MOVEFLAG_WATERWALKING);
}
if (IsInWorld())
{

View file

@ -46,24 +46,24 @@ struct GameEventCreatureData;
enum CreatureFlagsExtra
{
CREATURE_EXTRA_FLAG_INSTANCE_BIND = 0x00000001, // creature kill bind instance with killer and killer's group
CREATURE_EXTRA_FLAG_CIVILIAN = 0x00000002, // not aggro (ignore faction/reputation hostility)
CREATURE_EXTRA_FLAG_NO_PARRY = 0x00000004, // creature can't parry
CREATURE_EXTRA_FLAG_NO_PARRY_HASTEN = 0x00000008, // creature can't counter-attack at parry
CREATURE_EXTRA_FLAG_NO_BLOCK = 0x00000010, // creature can't block
CREATURE_EXTRA_FLAG_NO_CRUSH = 0x00000020, // creature can't do crush attacks
CREATURE_EXTRA_FLAG_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP
CREATURE_EXTRA_FLAG_INVISIBLE = 0x00000080, // creature is always invisible for player (mostly trigger creatures)
CREATURE_EXTRA_FLAG_NOT_TAUNTABLE = 0x00000100, // creature is immune to taunt auras and effect attack me
CREATURE_EXTRA_FLAG_AGGRO_ZONE = 0x00000200, // creature sets itself in combat with zone on aggro
CREATURE_EXTRA_FLAG_GUARD = 0x00000400, // creature is a guard
CREATURE_EXTRA_FLAG_NO_CALL_ASSIST = 0x00000800, // creature shouldn't call for assistance on aggro
CREATURE_EXTRA_FLAG_ACTIVE = 0x00001000, // creature is active object. Grid of this creature will be loaded and creature set as active
CREATURE_EXTRA_FLAG_MMAP_FORCE_ENABLE = 0x00002000, // creature is forced to use MMaps
CREATURE_EXTRA_FLAG_MMAP_FORCE_DISABLE = 0x00004000, // creature is forced to NOT use MMaps
CREATURE_EXTRA_FLAG_WALK_IN_WATER = 0x00008000, // creature is forced to walk in water even it can swim
CREATURE_EXTRA_FLAG_HAVE_NO_SWIM_ANIMATION = 0x00010000, // we have to not set "swim" animation or creature will have "no animation"
CREATURE_EXTRA_FLAG_NO_MELEE = 0x00020000, // creature can't melee
CREATURE_EXTRA_FLAG_INSTANCE_BIND = 0x00000001, // creature kill bind instance with killer and killer's group
CREATURE_EXTRA_FLAG_CIVILIAN = 0x00000002, // not aggro (ignore faction/reputation hostility)
CREATURE_EXTRA_FLAG_NO_PARRY = 0x00000004, // creature can't parry
CREATURE_EXTRA_FLAG_NO_PARRY_HASTEN = 0x00000008, // creature can't counter-attack at parry
CREATURE_EXTRA_FLAG_NO_BLOCK = 0x00000010, // creature can't block
CREATURE_EXTRA_FLAG_NO_CRUSH = 0x00000020, // creature can't do crush attacks
CREATURE_EXTRA_FLAG_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP
CREATURE_EXTRA_FLAG_INVISIBLE = 0x00000080, // creature is always invisible for player (mostly trigger creatures)
CREATURE_EXTRA_FLAG_NOT_TAUNTABLE = 0x00000100, // creature is immune to taunt auras and effect attack me
CREATURE_EXTRA_FLAG_AGGRO_ZONE = 0x00000200, // creature sets itself in combat with zone on aggro
CREATURE_EXTRA_FLAG_GUARD = 0x00000400, // creature is a guard
CREATURE_EXTRA_FLAG_NO_CALL_ASSIST = 0x00000800, // creature shouldn't call for assistance on aggro
CREATURE_EXTRA_FLAG_ACTIVE = 0x00001000, // creature is active object. Grid of this creature will be loaded and creature set as active
CREATURE_EXTRA_FLAG_MMAP_FORCE_ENABLE = 0x00002000, // creature is forced to use MMaps
CREATURE_EXTRA_FLAG_MMAP_FORCE_DISABLE = 0x00004000, // creature is forced to NOT use MMaps
CREATURE_EXTRA_FLAG_WALK_IN_WATER = 0x00008000, // creature is forced to walk in water even it can swim
CREATURE_EXTRA_FLAG_HAVE_NO_SWIM_ANIMATION = 0x00010000, // we have to not set "swim" animation or creature will have "no animation"
CREATURE_EXTRA_FLAG_NO_MELEE = 0x00020000, // creature can't melee
};
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
@ -74,8 +74,8 @@ enum CreatureFlagsExtra
#endif
#define MAX_KILL_CREDIT 2
#define MAX_CREATURE_MODEL 4
#define USE_DEFAULT_DATABASE_LEVEL 0 // just used to show we don't want to force the new creature level and use the level stored in db
#define MAX_CREATURE_MODEL 4 // only single send to client in static data
#define USE_DEFAULT_DATABASE_LEVEL 0 // just used to show we don't want to force the new creature level and use the level stored in db
// from `creature_template` table
struct CreatureInfo
@ -263,7 +263,7 @@ struct CreatureModelInfo
float bounding_radius;
float combat_reach;
uint8 gender;
uint32 modelid_other_gender; // The oposite gender for this modelid (male/female)
uint32 modelid_other_gender; // The opposite gender for this modelid (male/female)
uint32 modelid_alternative; // An alternative model. Generally same gender(2)
};

View file

@ -113,7 +113,9 @@ CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32
CanCastResult castResult = CanCastSpell(pTarget, pSpell, uiCastFlags & CAST_TRIGGERED);
if (castResult != CAST_OK)
{ return castResult; }
{
return castResult;
}
}
// Interrupt any previous spell

View file

@ -25,9 +25,9 @@
#ifndef MANGOS_CREATUREAI_H
#define MANGOS_CREATUREAI_H
#include "SharedDefines.h"
#include "Dynamic/FactoryHolder.h"
#include "ObjectGuid.h"
#include "SharedDefines.h"
class WorldObject;
class GameObject;
@ -352,6 +352,7 @@ class CreatureAI
*/
virtual void ReceiveAIEvent(AIEventType /*eventType*/, Creature* /*pSender*/, Unit* /*pInvoker*/, uint32 /*miscValue*/) {}
// Reset should be defined here, as it is called from out the AI ctor now
virtual void Reset() {}
protected:

View file

@ -110,7 +110,9 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c),
// Debug check
#ifndef MANGOS_DEBUG
if (i->event_flags & EFLAG_DEBUG_ONLY)
{ continue; }
{
continue;
}
#endif
if (m_creature->GetMap()->IsDungeon())
{
@ -120,11 +122,11 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c),
}
}
else if (IsEventFlagsFitForNormalMap(i->event_flags))
++events_count;
{ ++events_count; }
}
// EventMap had events but they were not added because they must be for instance
if (events_count == 0)
sLog.outErrorEventAI("Creature %u has events but no events added to list because of instance flags (spawned in map %u, difficulty %u).", m_creature->GetEntry(), m_creature->GetMapId(), m_creature->GetMap()->GetDifficulty());
{ sLog.outErrorEventAI("Creature %u has events but no events added to list because of instance flags (spawned in map %u, difficulty %u).", m_creature->GetEntry(), m_creature->GetMapId(), m_creature->GetMap()->GetDifficulty()); }
else
{
m_CreatureEventAIList.reserve(events_count);
@ -133,29 +135,33 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c),
// Debug check
#ifndef MANGOS_DEBUG
if (i->event_flags & EFLAG_DEBUG_ONLY)
{ continue; }
{ continue; }
#endif
bool storeEvent = false;
if (m_creature->GetMap()->IsDungeon())
{
if ((1 << (m_creature->GetMap()->GetSpawnMode() + 1)) & i->event_flags)
storeEvent = true;
{ storeEvent = true; }
}
else if (IsEventFlagsFitForNormalMap(i->event_flags))
storeEvent = true;
{ storeEvent = true; }
if (storeEvent)
{
m_CreatureEventAIList.push_back(CreatureEventAIHolder(*i));
// Cache for fast use
if (i->event_type == EVENT_T_OOC_LOS)
{
m_HasOOCLoSEvent = true;
}
}
}
}
}
else
{ sLog.outErrorEventAI("EventMap for Creature %u is empty but creature is using CreatureEventAI.", m_creature->GetEntry()); }
{
sLog.outErrorEventAI("EventMap for Creature %u is empty but creature is using CreatureEventAI.", m_creature->GetEntry());
}
}
#define LOG_PROCESS_EVENT \
@ -344,6 +350,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
// We don't really care about the whole list, just return first available
pActionInvoker = *(pList.begin());
LOG_PROCESS_EVENT;
// Repeat Timers
pHolder.UpdateRepeatTimer(m_creature, event.friendly_is_cc.repeatMin, event.friendly_is_cc.repeatMax);
break;
@ -400,7 +407,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_AURA:
{
if (!m_creature->IsInCombat())
return false;
{ return false; }
SpellAuraHolder* holder = m_creature->GetSpellAuraHolder(event.buffed.spellId);
if (!holder || holder->GetStackAmount() < event.buffed.amount)
@ -428,7 +435,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_MISSING_AURA:
{
if (!m_creature->IsInCombat())
return false;
{ return false; }
SpellAuraHolder* holder = m_creature->GetSpellAuraHolder(event.buffed.spellId);
if (holder && holder->GetStackAmount() >= event.buffed.amount)
@ -459,12 +466,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
{
if (!m_creature->IsInCombat() || !m_creature->GetMaxPower(POWER_ENERGY))
{ return false; }
uint32 perc = (m_creature->GetPower(POWER_ENERGY) * 100) / m_creature->GetMaxPower(POWER_ENERGY);
if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
{ return false; }
LOG_PROCESS_EVENT;
// Repeat Timers
pHolder.UpdateRepeatTimer(m_creature, event.percent_range.repeatMin, event.percent_range.repeatMax);
@ -526,7 +533,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker, Creature* pAIEventSender)
{
if (action.type == ACTION_T_NONE)
if (action.type == ACTION_T_NONE) //0
{ return; }
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Process action %u (script %u) triggered for %s (invoked by %s)",
@ -535,8 +542,8 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
bool reportTargetError = false;
switch (action.type)
{
case ACTION_T_TEXT:
case ACTION_T_CHANCED_TEXT:
case ACTION_T_TEXT: //1
case ACTION_T_CHANCED_TEXT: //44
{
if (!action.text.TextId[0])
{ return; }
@ -546,19 +553,19 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (action.type == ACTION_T_TEXT)
{
if (action.text.TextId[1] && action.text.TextId[2])
textId = action.text.TextId[rnd % 3];
{ textId = action.text.TextId[rnd % 3]; }
else if (action.text.TextId[1] && (rnd % 2))
{ textId = action.text.TextId[1]; }
{ textId = action.text.TextId[1]; }
else
{ textId = action.text.TextId[0]; }
{ textId = action.text.TextId[0]; }
}
// ACTION_T_CHANCED_TEXT, chance hits
else if ((rnd % 100) < action.chanced_text.chance)
{
if (action.chanced_text.TextId[0] && action.chanced_text.TextId[1])
textId = action.chanced_text.TextId[rnd % 2];
{ textId = action.chanced_text.TextId[rnd % 2]; }
else
{ textId = action.chanced_text.TextId[0]; }
{ textId = action.chanced_text.TextId[0]; }
}
if (textId)
@ -588,7 +595,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
break;
}
case ACTION_T_SET_FACTION:
case ACTION_T_SET_FACTION: //2
{
if (action.set_faction.factionId)
{ m_creature->SetFactionTemporary(action.set_faction.factionId, action.set_faction.factionFlags); }
@ -597,7 +604,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
break;
}
case ACTION_T_MORPH_TO_ENTRY_OR_MODEL:
case ACTION_T_MORPH_TO_ENTRY_OR_MODEL: //3
{
if (action.morph.creatureId || action.morph.modelId)
{
@ -618,30 +625,31 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{ m_creature->DeMorph(); }
break;
}
case ACTION_T_SOUND:
case ACTION_T_SOUND: //4
m_creature->PlayDirectSound(action.sound.soundId);
break;
case ACTION_T_EMOTE:
case ACTION_T_EMOTE: //5
m_creature->HandleEmote(action.emote.emoteId);
break;
case ACTION_T_RANDOM_SOUND:
case ACTION_T_RANDOM_SOUND: //9
{
int32 temp = GetRandActionParam(rnd, action.random_sound.soundId1, action.random_sound.soundId2, action.random_sound.soundId3);
if (temp >= 0)
{ m_creature->PlayDirectSound(temp); }
break;
}
case ACTION_T_RANDOM_EMOTE:
case ACTION_T_RANDOM_EMOTE: //10
{
int32 temp = GetRandActionParam(rnd, action.random_emote.emoteId1, action.random_emote.emoteId2, action.random_emote.emoteId3);
if (temp >= 0)
{ m_creature->HandleEmote(temp); }
break;
}
case ACTION_T_CAST:
case ACTION_T_CAST: //11
{
uint32 selectFlags = 0;
uint32 spellId = 0;
if (!(action.cast.castFlags & (CAST_TRIGGERED | CAST_FORCE_CAST | CAST_FORCE_TARGET_SELF)))
{
spellId = action.cast.spellId;
@ -711,7 +719,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
break;
}
case ACTION_T_SUMMON:
case ACTION_T_SUMMON: //12
{
Unit* target = GetTargetByType(action.summon.target, pActionInvoker, pAIEventSender, reportTargetError);
if (!target && reportTargetError)
@ -730,13 +738,13 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{ pCreature->AI()->AttackStart(target); }
break;
}
case ACTION_T_THREAT_SINGLE_PCT:
case ACTION_T_THREAT_SINGLE_PCT: //13
if (Unit* target = GetTargetByType(action.threat_single_pct.target, pActionInvoker, pAIEventSender, reportTargetError))
{ m_creature->GetThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent); }
else if (reportTargetError)
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_THREAT_SINGLE_PCT(%u), target-type %u", EventId, action.type, action.threat_single_pct.target); }
break;
case ACTION_T_THREAT_ALL_PCT:
case ACTION_T_THREAT_ALL_PCT: //14
{
ThreatList const& threatList = m_creature->GetThreatManager().getThreatList();
for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
@ -744,7 +752,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{ m_creature->GetThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); }
break;
}
case ACTION_T_QUEST_EVENT:
case ACTION_T_QUEST_EVENT: //15
if (Unit* target = GetTargetByType(action.quest_event.target, pActionInvoker, pAIEventSender, reportTargetError))
{
if (target->GetTypeId() == TYPEID_PLAYER)
@ -753,7 +761,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
else if (reportTargetError)
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_QUEST_EVENT(%u), target-type %u", EventId, action.type, action.quest_event.target); }
break;
case ACTION_T_CAST_EVENT:
case ACTION_T_CAST_EVENT: //16
if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker, pAIEventSender, reportTargetError, 0, SELECT_FLAG_PLAYER))
{
if (target->GetTypeId() == TYPEID_PLAYER)
@ -762,7 +770,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
else if (reportTargetError)
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_CST_EVENT(%u), target-type %u", EventId, action.type, action.cast_event.target); }
break;
case ACTION_T_SET_UNIT_FIELD:
case ACTION_T_SET_UNIT_FIELD: //17
{
Unit* target = GetTargetByType(action.set_unit_field.target, pActionInvoker, pAIEventSender, reportTargetError);
@ -775,21 +783,21 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
break;
}
case ACTION_T_SET_UNIT_FLAG:
case ACTION_T_SET_UNIT_FLAG: //18
if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError))
{ target->SetFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); }
else if (reportTargetError)
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target); }
break;
case ACTION_T_REMOVE_UNIT_FLAG:
case ACTION_T_REMOVE_UNIT_FLAG: //19
if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError))
{ target->RemoveFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); }
else if (reportTargetError)
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVE_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target); }
case ACTION_T_AUTO_ATTACK:
case ACTION_T_AUTO_ATTACK: //20
m_MeleeEnabled = action.auto_attack.state != 0;
break;
case ACTION_T_COMBAT_MOVEMENT:
case ACTION_T_COMBAT_MOVEMENT: //21
// ignore no affect case
if (m_isCombatMovement == (action.combat_movement.state != 0) || m_creature->IsNonMeleeSpellCasted(false))
{ return; }
@ -801,11 +809,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
else if (action.combat_movement.melee && m_creature->IsInCombat() && m_creature->getVictim())
{ m_creature->SendMeleeAttackStop(m_creature->getVictim()); }
break;
case ACTION_T_SET_PHASE:
case ACTION_T_SET_PHASE: //22
m_Phase = action.set_phase.phase;
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: ACTION_T_SET_PHASE - script %u for %s, phase is now %u", EventId, m_creature->GetGuidStr().c_str(), m_Phase);
break;
case ACTION_T_INC_PHASE:
case ACTION_T_INC_PHASE: //23
{
int32 new_phase = int32(m_Phase) + action.set_inc_phase.step;
if (new_phase < 0)
@ -824,13 +832,13 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: ACTION_T_INC_PHASE - script %u for %s, phase is now %u", EventId, m_creature->GetGuidStr().c_str(), m_Phase);
break;
}
case ACTION_T_EVADE:
case ACTION_T_EVADE: //24
EnterEvadeMode();
break;
case ACTION_T_FLEE_FOR_ASSIST:
case ACTION_T_FLEE_FOR_ASSIST: //25
m_creature->DoFleeToGetAssistance();
break;
case ACTION_T_QUEST_EVENT_ALL:
case ACTION_T_QUEST_EVENT_ALL: //26
if (action.quest_event_all.useThreatList)
{
ThreatList const& threatList = m_creature->GetThreatManager().getThreatList();
@ -841,7 +849,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
else if (pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER)
{ ((Player*)pActionInvoker)->GroupEventHappens(action.quest_event_all.questId, m_creature); }
break;
case ACTION_T_CAST_EVENT_ALL:
case ACTION_T_CAST_EVENT_ALL: //27
{
ThreatList const& threatList = m_creature->GetThreatManager().getThreatList();
for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
@ -849,13 +857,13 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{ temp->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetObjectGuid(), action.cast_event_all.spellId); }
break;
}
case ACTION_T_REMOVEAURASFROMSPELL:
case ACTION_T_REMOVEAURASFROMSPELL: //28
if (Unit* target = GetTargetByType(action.remove_aura.target, pActionInvoker, pAIEventSender, reportTargetError))
{ target->RemoveAurasDueToSpell(action.remove_aura.spellId); }
else if (reportTargetError)
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVEAURASFROMSPELL(%u), target-type %u", EventId, action.type, action.remove_aura.target); }
break;
case ACTION_T_RANGED_MOVEMENT:
case ACTION_T_RANGED_MOVEMENT: //29
m_attackDistance = (float)action.ranged_movement.distance;
m_attackAngle = action.ranged_movement.angle / 180.0f * M_PI_F;
@ -869,17 +877,17 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
}
break;
case ACTION_T_RANDOM_PHASE:
case ACTION_T_RANDOM_PHASE: //30
m_Phase = GetRandActionParam(rnd, action.random_phase.phase1, action.random_phase.phase2, action.random_phase.phase3);
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: ACTION_T_RANDOM_PHASE - script %u for %s, phase is now %u", EventId, m_creature->GetGuidStr().c_str(), m_Phase);
break;
case ACTION_T_RANDOM_PHASE_RANGE:
case ACTION_T_RANDOM_PHASE_RANGE: //31
if (action.random_phase_range.phaseMax > action.random_phase_range.phaseMin)
{ m_Phase = action.random_phase_range.phaseMin + (rnd % (action.random_phase_range.phaseMax - action.random_phase_range.phaseMin)); }
else
{ sLog.outErrorEventAI("ACTION_T_RANDOM_PHASE_RANGE can not have Param2 <= Param1. Divide by Zero. Event = %d. CreatureEntry = %d", EventId, m_creature->GetEntry()); }
break;
case ACTION_T_SUMMON_ID:
case ACTION_T_SUMMON_ID: //32
{
Unit* target = GetTargetByType(action.summon_id.target, pActionInvoker, pAIEventSender, reportTargetError);
if (!target && reportTargetError)
@ -894,9 +902,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
Creature* pCreature = NULL;
if ((*i).second.SpawnTimeSecs)
pCreature = m_creature->SummonCreature(action.summon_id.creatureId, i->second.position_x, i->second.position_y, i->second.position_z, i->second.orientation, TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN, i->second.SpawnTimeSecs);
{ pCreature = m_creature->SummonCreature(action.summon_id.creatureId, i->second.position_x, i->second.position_y, i->second.position_z, i->second.orientation, TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN, i->second.SpawnTimeSecs); }
else
pCreature = m_creature->SummonCreature(action.summon_id.creatureId, i->second.position_x, i->second.position_y, i->second.position_z, i->second.orientation, TEMPSUMMON_TIMED_OOC_DESPAWN, 0);
{ pCreature = m_creature->SummonCreature(action.summon_id.creatureId, i->second.position_x, i->second.position_y, i->second.position_z, i->second.orientation, TEMPSUMMON_TIMED_OOC_DESPAWN, 0); }
if (!pCreature)
{ sLog.outErrorEventAI("failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, EventId, m_creature->GetEntry()); }
@ -905,7 +913,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
break;
}
case ACTION_T_KILLED_MONSTER:
case ACTION_T_KILLED_MONSTER: //33
// first attempt player/group who tapped creature
if (Player* pPlayer = m_creature->GetLootRecipient())
{ pPlayer->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature); }
@ -921,7 +929,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{ sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_KILLED_MONSTER(%u), target-type %u", EventId, action.type, action.killed_monster.target); }
}
break;
case ACTION_T_SET_INST_DATA:
case ACTION_T_SET_INST_DATA: //34
{
InstanceData* pInst = m_creature->GetInstanceData();
if (!pInst)
@ -933,7 +941,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
pInst->SetData(action.set_inst_data.field, action.set_inst_data.value);
break;
}
case ACTION_T_SET_INST_DATA64:
case ACTION_T_SET_INST_DATA64: //35
{
Unit* target = GetTargetByType(action.set_inst_data64.target, pActionInvoker, pAIEventSender, reportTargetError);
if (!target)
@ -953,7 +961,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
pInst->SetData64(action.set_inst_data64.field, target->GetObjectGuid().GetRawValue());
break;
}
case ACTION_T_UPDATE_TEMPLATE:
case ACTION_T_UPDATE_TEMPLATE: //36
if (m_creature->GetEntry() == action.update_template.creatureId)
{
sLog.outErrorEventAI("Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", EventId, m_creature->GetEntry());
@ -962,7 +970,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
m_creature->UpdateEntry(action.update_template.creatureId, action.update_template.team ? HORDE : ALLIANCE);
break;
case ACTION_T_DIE:
case ACTION_T_DIE: //37
if (m_creature->IsDead())
{
sLog.outErrorEventAI("Event %d ACTION_T_DIE on dead creature. Creature %d", EventId, m_creature->GetEntry());
@ -970,27 +978,27 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
break;
case ACTION_T_ZONE_COMBAT_PULSE:
case ACTION_T_ZONE_COMBAT_PULSE: //38
{
m_creature->SetInCombatWithZone();
break;
}
case ACTION_T_CALL_FOR_HELP:
case ACTION_T_CALL_FOR_HELP: //39
{
m_creature->CallForHelp((float)action.call_for_help.radius);
break;
}
case ACTION_T_SET_SHEATH:
case ACTION_T_SET_SHEATH: //40
{
m_creature->SetSheath(SheathState(action.set_sheath.sheath));
break;
}
case ACTION_T_FORCE_DESPAWN:
case ACTION_T_FORCE_DESPAWN: //41
{
m_creature->ForcedDespawn(action.forced_despawn.msDelay);
break;
}
case ACTION_T_SET_INVINCIBILITY_HP_LEVEL:
case ACTION_T_SET_INVINCIBILITY_HP_LEVEL: //42
{
if (action.invincibility_hp_level.is_percent)
{ m_InvinceabilityHpLevel = m_creature->GetMaxHealth() * action.invincibility_hp_level.hp_level / 100; }
@ -998,7 +1006,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{ m_InvinceabilityHpLevel = action.invincibility_hp_level.hp_level; }
break;
}
case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL:
case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL: //43
{
if (action.mount.creatureId || action.mount.modelId)
{
@ -1020,34 +1028,34 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
break;
}
case ACTION_T_THROW_AI_EVENT:
case ACTION_T_THROW_AI_EVENT: //45
{
SendAIEventAround(AIEventType(action.throwEvent.eventType), pActionInvoker, 0, action.throwEvent.radius);
break;
}
case ACTION_T_SET_THROW_MASK:
case ACTION_T_SET_THROW_MASK: //46
{
m_throwAIEventMask = action.setThrowMask.eventTypeMask;
break;
}
case ACTION_T_SET_STAND_STATE:
case ACTION_T_SET_STAND_STATE: //47
{
m_creature->SetStandState(action.setStandState.standState);
break;
}
case ACTION_T_CHANGE_MOVEMENT:
case ACTION_T_CHANGE_MOVEMENT: //48
{
switch (action.changeMovement.movementType)
{
case IDLE_MOTION_TYPE:
m_creature->GetMotionMaster()->MoveIdle();
break;
case RANDOM_MOTION_TYPE:
m_creature->GetMotionMaster()->MoveRandomAroundPoint(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), float(action.changeMovement.wanderDistance));
break;
case WAYPOINT_MOTION_TYPE:
m_creature->GetMotionMaster()->MoveWaypoint();
break;
case IDLE_MOTION_TYPE:
m_creature->GetMotionMaster()->MoveIdle();
break;
case RANDOM_MOTION_TYPE:
m_creature->GetMotionMaster()->MoveRandomAroundPoint(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), float(action.changeMovement.wanderDistance));
break;
case WAYPOINT_MOTION_TYPE:
m_creature->GetMotionMaster()->MoveWaypoint();
break;
}
break;
}
@ -1104,10 +1112,10 @@ void CreatureEventAI::Reset()
break;
}
default:
// TODO: enable below code line / verify this is correct to enable events previously disabled (ex. aggro yell), instead of enable this in void Aggro()
//i->Enabled = true;
//i->Time = 0;
break;
// TODO: enable below code line / verify this is correct to enable events previously disabled (ex. aggro yell), instead of enable this in void Aggro()
//i->Enabled = true;
//i->Time = 0;
break;
}
}
}
@ -1234,7 +1242,7 @@ void CreatureEventAI::EnterCombat(Unit* enemy)
// Reset all in combat timers
case EVENT_T_TIMER_IN_COMBAT:
if (i->UpdateRepeatTimer(m_creature, event.timer.initialMin, event.timer.initialMax))
i->Enabled = true;
{ i->Enabled = true; }
break;
// All normal events need to be re-enabled and their time set to 0
default:
@ -1280,11 +1288,11 @@ void CreatureEventAI::MoveInLineOfSight(Unit* who)
// if friendly event && who is not hostile OR hostile event && who is hostile
if ((itr->Event.ooc_los.noHostile && !m_creature->IsHostileTo(who)) ||
((!itr->Event.ooc_los.noHostile) && m_creature->IsHostileTo(who)))
((!itr->Event.ooc_los.noHostile) && m_creature->IsHostileTo(who)))
{
// if range is ok and we are actually in LOS
if (m_creature->IsWithinDistInMap(who, fMaxAllowedRange) && m_creature->IsWithinLOSInMap(who))
ProcessEvent(*itr, who);
{ ProcessEvent(*itr, who); }
}
}
}
@ -1344,7 +1352,7 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
{
if (i->Time > m_EventDiff)
{
// Do not decrement timers if event can not trigger in this phase
// Do not decrement timers if event cannot trigger in this phase
if (!(i->Event.event_inverse_phase_mask & (1 << m_Phase)))
i->Time -= m_EventDiff;
}
@ -1388,7 +1396,7 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
}
else if (m_MeleeEnabled && m_creature->CanReachWithMeleeAttack(victim)
&& !(m_creature->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_NO_MELEE))
DoMeleeAttackIfReady();
{ DoMeleeAttackIfReady(); }
}
}
@ -1520,7 +1528,7 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
if (itr->Event.event_type == EVENT_T_RECEIVE_EMOTE)
{
if (itr->Event.receive_emote.emoteId != text_emote)
continue;
{ continue; }
PlayerCondition pcon(0, itr->Event.receive_emote.condition, itr->Event.receive_emote.conditionValue1, itr->Event.receive_emote.conditionValue2);
if (pcon.Meets(pPlayer, m_creature->GetMap(), m_creature, CONDITION_FROM_EVENTAI))
@ -1532,7 +1540,7 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
}
}
#define HEALTH_STEPS 3
#define HEALTH_STEPS 3
void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage)
{

View file

@ -128,7 +128,7 @@ enum EventAI_ActionType
ACTION_T_CHANGE_MOVEMENT = 48, // MovementType, WanderDistance, unused
ACTION_T_DYNAMIC_MOVEMENT = 49, // EnableDynamicMovement (1 = on; 0 = off)
ACTION_T_END,
ACTION_T_END
};
enum Target
@ -150,7 +150,9 @@ enum Target
// Hostile targets (including pets)
TARGET_T_HOSTILE_RANDOM_PLAYER = 8, // Just any random player on our threat list
TARGET_T_HOSTILE_RANDOM_NOT_TOP_PLAYER = 9 // Any random player from threat list except top threat
TARGET_T_HOSTILE_RANDOM_NOT_TOP_PLAYER = 9, // Any random player from threat list except top threat
TARGET_T_END
};
enum EventFlags
@ -439,8 +441,6 @@ struct CreatureEventAI_Action
};
};
#define AIEVENT_DEFAULT_THROW_RADIUS 30.0f
struct CreatureEventAI_Event
{
uint32 event_id;
@ -597,6 +597,9 @@ struct CreatureEventAI_Event
CreatureEventAI_Action action[MAX_ACTIONS];
};
#define AIEVENT_DEFAULT_THROW_RADIUS 30.0f
// Event_Map
typedef std::vector<CreatureEventAI_Event> CreatureEventAI_Event_Vec;
typedef UNORDERED_MAP<uint32, CreatureEventAI_Event_Vec > CreatureEventAI_Event_Map;

View file

@ -48,7 +48,7 @@ void DynamicObject::AddToWorld()
{
///- Register the dynamicObject for guid lookup
if (!IsInWorld())
GetMap()->GetObjectsStore().insert<DynamicObject>(GetObjectGuid(), (DynamicObject*)this);
{ GetMap()->GetObjectsStore().insert<DynamicObject>(GetObjectGuid(), (DynamicObject*)this); }
Object::AddToWorld();
}

View file

@ -121,7 +121,7 @@ namespace MaNGOS
{
if (u->GetTypeId() == TYPEID_UNIT && (
((Creature*)u)->IsTotem() || ((Creature*)u)->IsPet() ||
(((Creature*)u)->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_NO_XP_AT_KILL)))
(((Creature*)u)->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_NO_XP_AT_KILL)))
{ return 0; }
uint32 xp_gain = BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(pl->GetMapId(), pl->GetZoneId()));

View file

@ -39,17 +39,17 @@ void GMTicketMgr::LoadGMTickets()
m_GMTicketMap.clear(); // For reload case
QueryResult* result = CharacterDatabase.Query(
// 0 1 2 3 4
"SELECT guid, ticket_text, response_text, UNIX_TIMESTAMP(ticket_lastchange), ticket_id FROM character_ticket ORDER BY ticket_id ASC");
// 0 1 2 3 4
"SELECT guid, ticket_text, response_text, UNIX_TIMESTAMP(ticket_lastchange), ticket_id "
"FROM character_ticket "
"ORDER BY ticket_id ASC");
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded `character_ticket`, table is empty.");
sLog.outString();
return;
}
@ -80,8 +80,8 @@ void GMTicketMgr::LoadGMTickets()
while (result->NextRow());
delete result;
sLog.outString();
sLog.outString(">> Loaded " SIZEFMTD " GM tickets", GetTicketCount());
sLog.outString();
}
void GMTicketMgr::DeleteAll()

View file

@ -22,8 +22,8 @@
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#ifndef _GMTICKETMGR_H
#define _GMTICKETMGR_H
#ifndef MANGOS_H_GMTICKETMGR
#define MANGOS_H_GMTICKETMGR
#include "Policies/Singleton.h"
#include "Database/DatabaseEnv.h"

View file

@ -837,45 +837,6 @@ bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoi
(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
}
/*
bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const
{
// Not in world
if (!IsInWorld() || !u->IsInWorld())
{ return false; }
// invisible at client always
if (!GetGOInfo()->displayId)
return false;
// Transport always visible at this step implementation
if (IsTransport() && IsInMap(u))
{ return true; }
// quick check visibility false cases for non-GM-mode
if (!u->isGameMaster())
{
// despawned and then not visible for non-GM in GM-mode
if (!isSpawned())
{ return false; }
*/
// special invisibility cases
/* TODO: implement trap stealth, take look at spell 2836
if(GetGOInfo()->type == GAMEOBJECT_TYPE_TRAP && GetGOInfo()->trap.stealthed && u->IsHostileTo(GetOwner()))
{
if(check stuff here)
return false;
}*/
/*
}
// check distance
return IsWithinDistInMap(viewPoint, GetMap()->GetVisibilityDistance() +
(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
}
*/
void GameObject::Respawn()
{
if (m_spawnedByDefault && m_respawnTime > 0)
@ -2469,6 +2430,20 @@ void GameObject::ForceGameObjectHealth(int32 diff, Unit* caster)
SetGoAnimProgress(GetMaxHealth() ? m_useTimes * 255 / GetMaxHealth() : 255);
}
void GameObject::SetInUse(bool use)
{
m_isInUse = use;
if (use)
SetGoState(GO_STATE_ACTIVE);
else
SetGoState(GO_STATE_READY);
}
uint32 GameObject::GetScriptId()
{
return sScriptMgr.GetBoundScriptId(SCRIPTED_GAMEOBJECT, -int32(GetGUIDLow())) ? sScriptMgr.GetBoundScriptId(SCRIPTED_GAMEOBJECT, -int32(GetGUIDLow())) : sScriptMgr.GetBoundScriptId(SCRIPTED_GAMEOBJECT, GetEntry());
}
float GameObject::GetInteractionDistance()
{
switch (GetGoType())
@ -2486,17 +2461,4 @@ float GameObject::GetInteractionDistance()
}
}
void GameObject::SetInUse(bool use)
{
m_isInUse = use;
if (use)
SetGoState(GO_STATE_ACTIVE);
else
SetGoState(GO_STATE_READY);
}
uint32 GameObject::GetScriptId()
{
return sScriptMgr.GetBoundScriptId(SCRIPTED_GAMEOBJECT, -int32(GetGUIDLow())) ? sScriptMgr.GetBoundScriptId(SCRIPTED_GAMEOBJECT, -int32(GetGUIDLow())) : sScriptMgr.GetBoundScriptId(SCRIPTED_GAMEOBJECT, GetEntry());
}

View file

@ -600,7 +600,7 @@ struct GameObjectDataAddon
};
// For containers: [GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY -> ...
// For bobber: GO_NOT_READY ->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED-><deleted>
// For bobber: [GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED-><deleted>
// For door(closed):[GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY(close) -> ...
// For door(open): [GO_NOT_READY]->GO_READY (open) ->GO_ACTIVATED (close)->GO_JUST_DEACTIVATED->GO_READY(open) -> ...
enum LootState
@ -624,9 +624,9 @@ enum CapturePointState
enum CapturePointSliderValue
{
CAPTURE_SLIDER_ALLIANCE = 100, // full alliance
CAPTURE_SLIDER_HORDE = 0, // full horde
CAPTURE_SLIDER_MIDDLE = 50 // middle
CAPTURE_SLIDER_ALLIANCE = 100, // full alliance
CAPTURE_SLIDER_HORDE = 0, // full horde
CAPTURE_SLIDER_MIDDLE = 50 // middle
};
class Unit;
@ -638,7 +638,7 @@ struct GameObjectDisplayInfoEntry;
#define GO_ANIMPROGRESS_DEFAULT 0xFF
class GameObject : public WorldObject
class GameObject : public WorldObject
{
public:
explicit GameObject();

View file

@ -343,9 +343,9 @@ bool Guild::CheckGuildStructure()
// Allow only 1 guildmaster, set other to officer
for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
{
MemberSlot& member = itr->second;
MemberSlot &member = itr->second;
if (member.RankId == GR_GUILDMASTER && m_LeaderGuid != member.guid)
member.ChangeRank(GR_OFFICER);
{ member.ChangeRank(GR_OFFICER); }
}
return true;
@ -588,7 +588,7 @@ bool Guild::DelMember(ObjectGuid guid, bool isDisbanding)
CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", lowguid);
if (!isDisbanding)
UpdateAccountsNumber();
{ UpdateAccountsNumber(); }
// Used by Eluna
#ifdef ENABLE_ELUNA
@ -601,22 +601,22 @@ bool Guild::DelMember(ObjectGuid guid, bool isDisbanding)
bool Guild::ChangeMemberRank(ObjectGuid guid, uint8 newRank)
{
if (newRank <= GetLowestRank()) // Validate rank (allow only existing ranks)
if (MemberSlot* member = GetMemberSlot(guid))
{
member->ChangeRank(newRank);
return true;
}
if (MemberSlot* member = GetMemberSlot(guid))
{
member->ChangeRank(newRank);
return true;
}
return false;
}
void Guild::BroadcastToGuild(WorldSession* session, const std::string& msg, uint32 language)
{
if (!session)
return;
{ return; }
Player* player = session->GetPlayer();
if (!player || !HasRankRight(player->GetRank(), GR_RIGHT_GCHATSPEAK))
return;
{ return; }
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_GUILD, msg.c_str(), Language(language), player->GetChatTag(), player->GetObjectGuid(), player->GetName());
@ -626,7 +626,7 @@ void Guild::BroadcastToGuild(WorldSession* session, const std::string& msg, uint
Player* pl = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first));
if (pl && pl->GetSession() && HasRankRight(pl->GetRank(), GR_RIGHT_GCHATLISTEN) && !pl->GetSocial()->HasIgnore(player->GetObjectGuid()))
pl->GetSession()->SendPacket(&data);
{ pl->GetSession()->SendPacket(&data); }
}
}
@ -650,11 +650,11 @@ void Guild::BroadcastAddonToGuild(WorldSession* session, const std::string& msg,
void Guild::BroadcastToOfficers(WorldSession* session, const std::string& msg, uint32 language)
{
if (!session)
return;
{ return; }
Player* player = session->GetPlayer();
if (!player || !HasRankRight(player->GetRank(), GR_RIGHT_OFFCHATSPEAK))
return;
{ return; }
for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
{

View file

@ -88,7 +88,7 @@ enum Typecommand
enum CommandErrors
{
ERR_PLAYER_NO_MORE_IN_GUILD = 0x00,
ERR_PLAYER_NO_MORE_IN_GUILD = 0x00, // no message/error
ERR_GUILD_INTERNAL = 0x01,
ERR_ALREADY_IN_GUILD = 0x02,
ERR_ALREADY_IN_GUILD_S = 0x03,
@ -96,8 +96,8 @@ enum CommandErrors
ERR_ALREADY_INVITED_TO_GUILD_S = 0x05,
ERR_GUILD_NAME_INVALID = 0x06,
ERR_GUILD_NAME_EXISTS_S = 0x07,
ERR_GUILD_LEADER_LEAVE = 0x08,
ERR_GUILD_PERMISSIONS = 0x08,
ERR_GUILD_LEADER_LEAVE = 0x08, // for Typecommand 0x03
ERR_GUILD_PERMISSIONS = 0x08, // for another Typecommand
ERR_GUILD_PLAYER_NOT_IN_GUILD = 0x09,
ERR_GUILD_PLAYER_NOT_IN_GUILD_S = 0x0A,
ERR_GUILD_PLAYER_NOT_FOUND_S = 0x0B,

View file

@ -1234,6 +1234,11 @@ bool Item::IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) cons
// time.
void Item::SendTimeUpdate(Player* owner)
{
#ifdef ENABLE_PLAYERBOTS
if (!owner || !owner->IsInWorld() || owner->GetPlayerbotAI())
return;
#endif
uint32 duration = GetUInt32Value(ITEM_FIELD_DURATION);
if (!duration)
{ return; }

View file

@ -29,9 +29,10 @@
#include "Log.h"
#include "ObjectMgr.h"
#include "ProgressBar.h"
#include "Util.h"
#include <list>
#include <vector>
#include "Util.h"
struct EnchStoreItem
{
@ -92,14 +93,13 @@ void LoadRandomEnchantmentsTable()
delete result;
sLog.outString();
sLog.outString(">> Loaded %u Item Enchantment definitions", count);
}
else
{
sLog.outString();
sLog.outErrorDb(">> Loaded 0 Item Enchantment definitions. DB table `item_enchantment_template` is empty.");
}
sLog.outString();
}
uint32 GetItemEnchantMod(int32 entry)
@ -129,7 +129,7 @@ uint32 GetItemEnchantMod(int32 entry)
double dRoll = rand_chance();
float fCount = 0;
const EnchStoreList& enchantList = tab->second;
const EnchStoreList &enchantList = tab->second;
for (EnchStoreList::const_iterator ench_iter = enchantList.begin(); ench_iter != enchantList.end(); ++ench_iter)
{
fCount += ench_iter->chance;

View file

@ -22,8 +22,8 @@
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#ifndef _ITEM_ENCHANTMENT_MGR_H
#define _ITEM_ENCHANTMENT_MGR_H
#ifndef MANGOS_H_ITEM_ENCHANTMENT_MGR
#define MANGOS_H_ITEM_ENCHANTMENT_MGR
#include "Common.h"

View file

@ -22,8 +22,8 @@
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#ifndef _ITEMPROTOTYPE_H
#define _ITEMPROTOTYPE_H
#ifndef MANGOS_H_ITEMPROTOTYPE
#define MANGOS_H_ITEMPROTOTYPE
#include "Common.h"
@ -119,17 +119,17 @@ enum ItemBondingType
enum ItemPrototypeFlags
{
ITEM_FLAG_UNK0 = 0x00000001, // not used
ITEM_FLAG_CONJURED = 0x00000002,
ITEM_FLAG_CONJURED = 0x00000002, // items created by spells with SPELL_EFFECT_CREATE_ITEM
ITEM_FLAG_LOOTABLE = 0x00000004, // affect only non container items that can be "open" for loot. It or lockid set enable for client show "Right click to open". See also ITEM_DYNFLAG_UNLOCKED
ITEM_FLAG_HEROIC = 0x00000008, // heroic item version
ITEM_FLAG_UNK4 = 0x00000010, // can't repeat old note: appears red icon (like when item durability==0)
ITEM_FLAG_INDESTRUCTIBLE = 0x00000020, // used for totem. Item can not be destroyed, except by using spell (item can be reagent for spell and then allowed)
ITEM_FLAG_UNK6 = 0x00000040, // ? old note: usable
ITEM_FLAG_NO_EQUIP_COOLDOWN = 0x00000080,
ITEM_FLAG_NO_EQUIP_COOLDOWN = 0x00000080, // items without an equip cooldown (and usually a _USABLE flag)
ITEM_FLAG_UNK8 = 0x00000100, // saw this on item 47115, 49295...
ITEM_FLAG_WRAPPER = 0x00000200, // used or not used wrapper
ITEM_FLAG_IGNORE_BAG_SPACE = 0x00000400, // ignore bag space at new item creation?
ITEM_FLAG_PARTY_LOOT = 0x00000800, // determines if item is party loot or not
ITEM_FLAG_PARTY_LOOT = 0x00000800, // items which can be looted by all party members
ITEM_FLAG_REFUNDABLE = 0x00001000, // item cost can be refunded within 2 hours after purchase
ITEM_FLAG_CHARTER = 0x00002000, // arena/guild charter
ITEM_FLAG_UNK14 = 0x00004000,

View file

@ -104,8 +104,6 @@ void LootStore::LoadLootTable()
// Clearing store (for reloading case)
Clear();
sLog.outString("%s :", GetName());
// 0 1 2 3 4 5 6
QueryResult* result = WorldDatabase.PQuery("SELECT entry, item, ChanceOrQuestChance, groupid, mincountOrRef, maxcount, condition_id FROM %s", GetName());
@ -179,8 +177,8 @@ void LootStore::LoadLootTable()
Verify(); // Checks validity of the loot store
sLog.outString(">> Loaded %u loot definitions (" SIZEFMTD " templates) from table %s", count, m_LootTemplates.size(), GetName());
sLog.outString();
sLog.outString(">> Loaded %u loot definitions (" SIZEFMTD " templates)", count, m_LootTemplates.size());
}
else
{
@ -236,8 +234,12 @@ void LootStore::CheckLootRefs(LootIdSet* ref_set) const
void LootStore::ReportUnusedIds(LootIdSet const& ids_set) const
{
// all still listed ids isn't referenced
for (LootIdSet::const_iterator itr = ids_set.begin(); itr != ids_set.end(); ++itr)
{ sLog.outErrorDb("Table '%s' entry %d isn't %s and not referenced from loot, and then useless.", GetName(), *itr, GetEntryName()); }
if (!ids_set.empty())
{
for (LootIdSet::const_iterator itr = ids_set.begin(); itr != ids_set.end(); ++itr)
sLog.outErrorDb("Table '%s' entry %d isn't %s and not referenced from loot, and then useless.", GetName(), *itr, GetEntryName());
sLog.outString();
}
}
void LootStore::ReportNotExistedId(uint32 id) const
@ -428,41 +430,41 @@ bool LootItem::AllowedForPlayer(Player const* player, WorldObject const* lootTar
{
ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid);
if (!pProto)
return false;
{ return false; }
// not show loot for not own team
if ((pProto->Flags2 & ITEM_FLAG2_HORDE_ONLY) && player->GetTeam() != HORDE)
return false;
{ return false; }
if ((pProto->Flags2 & ITEM_FLAG2_ALLIANCE_ONLY) && player->GetTeam() != ALLIANCE)
return false;
{ return false; }
if (needs_quest)
{
// Checking quests for quest-only drop (check only quests requirements in this case)
if (!player->HasQuestForItem(itemid))
return false;
{ return false; }
}
else
{
// Not quest only drop (check quest starting items for already accepted non-repeatable quests)
if (pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE && !player->HasQuestForItem(itemid))
return false;
{ return false; }
}
}
else if (type == LOOT_ITEM_TYPE_CURRENCY)
{
CurrencyTypesEntry const * currency = sCurrencyTypesStore.LookupEntry(itemid);
if (!itemid)
return false;
{ return false; }
if (!player->isGameMaster())
{
if (currency->Category == CURRENCY_CATEGORY_META)
return false;
{ return false; }
if (currency->Category == CURRENCY_CATEGORY_ARCHAEOLOGY && !player->HasSkill(SKILL_ARCHAEOLOGY))
return false;
{ return false; }
}
}
@ -1274,12 +1276,12 @@ void LoadLootTemplates_Creature()
{
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
{
if (uint32 Lootid = cInfo->LootId)
if (uint32 lootid = cInfo->LootId)
{
if (ids_set.find(Lootid) == ids_set.end())
LootTemplates_Creature.ReportNotExistedId(Lootid);
if (ids_set.find(lootid) == ids_set.end())
{ LootTemplates_Creature.ReportNotExistedId(lootid); }
else
ids_setUsed.insert(Lootid);
{ ids_setUsed.insert(lootid); }
}
}
}
@ -1304,12 +1306,12 @@ void LoadLootTemplates_Disenchant()
{
if (ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i))
{
if (uint32 Lootid = proto->DisenchantID)
if (uint32 lootid = proto->DisenchantID)
{
if (ids_set.find(Lootid) == ids_set.end())
LootTemplates_Disenchant.ReportNotExistedId(Lootid);
if (ids_set.find(lootid) == ids_set.end())
{ LootTemplates_Disenchant.ReportNotExistedId(lootid); }
else
ids_setUsed.insert(Lootid);
{ ids_setUsed.insert(lootid); }
}
}
}
@ -1347,12 +1349,12 @@ void LoadLootTemplates_Gameobject()
// remove real entries and check existence loot
for (SQLStorageBase::SQLSIterator<GameObjectInfo> itr = sGOStorage.getDataBegin<GameObjectInfo>(); itr < sGOStorage.getDataEnd<GameObjectInfo>(); ++itr)
{
if (uint32 Lootid = itr->GetLootId())
if (uint32 lootid = itr->GetLootId())
{
if (ids_set.find(Lootid) == ids_set.end())
LootTemplates_Gameobject.ReportNotExistedId(Lootid);
if (ids_set.find(lootid) == ids_set.end())
{ LootTemplates_Gameobject.ReportNotExistedId(lootid); }
else
ids_setUsed.insert(Lootid);
{ ids_setUsed.insert(lootid); }
}
}
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
@ -1422,12 +1424,12 @@ void LoadLootTemplates_Pickpocketing()
{
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
{
if (uint32 Lootid = cInfo->PickpocketLootId)
if (uint32 lootid = cInfo->PickpocketLootId)
{
if (ids_set.find(Lootid) == ids_set.end())
LootTemplates_Pickpocketing.ReportNotExistedId(Lootid);
if (ids_set.find(lootid) == ids_set.end())
{ LootTemplates_Pickpocketing.ReportNotExistedId(lootid); }
else
ids_setUsed.insert(Lootid);
{ ids_setUsed.insert(lootid); }
}
}
}
@ -1488,12 +1490,12 @@ void LoadLootTemplates_Skinning()
{
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
{
if (uint32 Lootid = cInfo->SkinningLootId)
if (uint32 lootid = cInfo->SkinningLootId)
{
if (ids_set.find(Lootid) == ids_set.end())
LootTemplates_Skinning.ReportNotExistedId(Lootid);
if (ids_set.find(lootid) == ids_set.end())
{ LootTemplates_Skinning.ReportNotExistedId(lootid); }
else
ids_setUsed.insert(Lootid);
{ ids_setUsed.insert(lootid); }
}
}
}

View file

@ -511,9 +511,6 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 updateFlags) const
data->WriteGuidBytes<4, 0, 3, 5, 7, 6, 2, 1>(guid);
}
//if (updateFlags & UPDATEFLAG_ANIM_KITS)
// *data << uint16(0) << uint16(0) << uint16(0);
if (updateFlags & UPDATEFLAG_TRANSPORT)
*data << uint32(WorldTimer::getMSTime());
}
@ -1487,13 +1484,13 @@ void WorldObject::UpdateGroundPositionZ(float x, float y, float& z) const
{
float new_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z);
if (new_z > INVALID_HEIGHT)
{ z = new_z + 0.05f; } // just to be sure that we are not a few pixel under the surface
{ z = new_z + 0.05f; } // just to be sure that we are not a few pixel under the surface
}
void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap /*=NULL*/) const
{
if (!atMap)
{ atMap = GetMap(); }
{ atMap = GetMap(); }
switch (GetTypeId())
{

View file

@ -659,6 +659,7 @@ class WorldObject : public Object
GameObject* SummonGameObject(uint32 id, float x, float y, float z, float angle, uint32 despwtime);
bool IsActiveObject() const { return m_isActiveObject || m_viewPoint.hasViewers(); }
bool isActiveObject() const { return IsActiveObject(); } // This is for Eluna to build. Should be removed in the future!
void SetActiveObjectState(bool active);
ViewPoint& GetViewPoint() { return m_viewPoint; }