diff --git a/doc/AuctionHouseBot.md b/doc/AuctionHouseBot.md new file mode 100644 index 000000000..f004a54a2 --- /dev/null +++ b/doc/AuctionHouseBot.md @@ -0,0 +1,22 @@ +Auction house bot +----------------- +For testing purposes and low population home servers, *mangos-zero* provides an +auction house bot, which will provide a set of items on the auction houses based +on various configuration settings. + +Configuration +------------- +Edit `ahbot.conf` to match your requirements. You can fine tune the amount of +items, the pricing, the range of item quality, and many other settings. + +Please note that the default auction house bot settings will disable auction +generation. This is done by intention to prevent putting up a wrong range of +auctions for your server. + +Notes +----- +The following rules apply when using the auction house bot: + +* If an auction expires, auctions are deleted quietly. +* the bot will not buy its own items, and will not receive mail from the AH or + receive returned mails. diff --git a/doc/AuctionHouseBot.txt b/doc/AuctionHouseBot.txt deleted file mode 100644 index 7818ed89d..000000000 --- a/doc/AuctionHouseBot.txt +++ /dev/null @@ -1,16 +0,0 @@ -Auction Houses Bot populates the auction houses with items. -It makes the game feel a bit more active in auction usage part -specially for low-populated servers. Items and prices are chosen -randomly based on the parameters you define. If an auction expires, auctions -are deleted quietly. AHBot will not buy it's own items, and will not receive -mail from the AH or get returned mail. - -=============================================================================== -~~HOW TO CONFIGURE~~ -=============================================================================== - -You must copy config file template as ahbot.conf from src/game/AuctionHouseBot/ahbot.conf.dist.in -to directory wher use store mangosd.conf file, and modify values to appropriate for you state. -Read ahbot.conf option descriptions for details. - -Note: But default AHBot disabled by provided config options values diff --git a/doc/DocStructure.dox b/doc/DocStructure.dox index 30eba4308..afc2608ad 100644 --- a/doc/DocStructure.dox +++ b/doc/DocStructure.dox @@ -3,12 +3,63 @@ * \section intro_sec Introduction and links * This is the source documentation for the \b %MaNGOS (Massive Network Game %Object Server) project.\n * %MaNGOS is an object-oriented Massively Multiplayer Online Role-Playing Game Server (MMORPGS).\n - * The project documentation and the bug tracker can be found on the %MaNGOS wiki. + * The project documentation can be found on the %MaNGOS wiki. + * The project bug tracker can be found on the %MaNGOS website. * * \section begin Where to begin? * If you are interested in understanding the source code of this project you can begin - * - On the wiki to get an overview of the different modules of the server + * - On the wiki to get an overview of the different modules of the server * - In this source doumentation, starting at the module hierarchy + * + * \section conventions Naming/Coding conventions + * When using a singleton to access something a define along the following lines is often used: + * \code{.cpp} + * #define sAuctionBot MaNGOS::Singleton::Instance() + * \endcode + * Notice the small s prepending the variable name, this is important and is used often throughout + * the source. When using a pointer is it often prepended with a small p, ie: + * \code{.cpp} + * OneClass* pOneClass = NULL; + * \endcode + * + * Member variables in a class are prepended with m_VarName, functions are name with CamelCase but with + * a capital first letter. Indentation is done as follows: + * \code{.cpp} + * class MyNiceClass + * { + * public: + * MyNiceClass(); + * virtual ~MyNiceClass(); + * + * void Function(); + * private: + * uint32 m_CoolStuff; + * AnotherClass* m_pOtherClass; + * }; + * + * MyNiceClass::MyNiceClass() + * {} + * + * void MyNiceClass::Function() + * { + * if(m_CoolStuff == 10) + * exit(EXIT_SUCCESS); + * else + * { + * std::cout << "Cool stuff" << std::endl; + * } + * } + * \endcode + * + * When working with iterators and loops in general always use the prefix ++ or -- operator as it's + * faster, ie: + * \code{.cpp} + * for (std::list::const_iterator it = list.begin(); it != list.end(); ++it); + * \endcode + * + * + * \todo Move the naming conventions to their own file when it's finished + * \todo Add more examples of how the code should look, there was an example in the Wiki before */ /*! \defgroup realmd Realm Daemon @@ -28,3 +79,11 @@ /*! \defgroup world The World \ingroup mangos */ + +/*! \defgroup auctionhouse The Auction House + \ingroup mangos + */ + +/*! \defgroup auctionbot The Auction House Bot + \ingroup auctionhouse + */ diff --git a/doc/EventAI.md b/doc/EventAI.md new file mode 100644 index 000000000..981986bde --- /dev/null +++ b/doc/EventAI.md @@ -0,0 +1,998 @@ +mangos EventAI scripting +======================== +**Last Updated**: September 25, 2013 + +*mangos-zero* provides a simple scripting feature through a set of event-based +commands from with the database. + +Introduction +------------ +Enhancing creatures with dynamic features instead of just a few spells can be +achieved without knowing any programming language, and only requires basic +[SQL][1] knowledge, and a database editor of your choice. + +*EventAI* scripts are based on in-game events, and attached to specific creature +templates, which means they are valid for every spawn of a creature. + +Database documentation +---------------------- +All scripts and related information are stored within the database tables +`creature_ai_scripts`, `creature_ai_summons` and `creature_ai_texts`. + +For the AI to be used, you must first make sure to set AIname for each creature that should use this AI. + + UPDATE creature_template SET AIName = 'EventAI' WHERE entry IN (...); + +Basic Structure of creature_ai_scripts +========================================= + +Field_Name | Description +------------------------------| ----------- +id | This value is merely an incrementing counter of the current Event number. Required for sql queries. (ACID Standards: CreatureID+Additional 2 digit Increment Starting with 01) +creature_id | Creature ID which should trigger this event (This is entry value from `creature_template` table). +event_type | The type of event you want to script. (see "Event Types" below for different values) +event_inverse_phase_mask | Mask with phases this event should NOT trigger in [^1] +event_chance | Percentage chance of triggering the event (1 - 100) +event_flags | Event Flags (Used to select Repeatable or Dungeon Heroic Mode)... See "Event Flags" Below For Defined Values +event_param1 | Variables for the event (depends on event_type) +event_param2 | Variables for the event (depends on event_type) +event_param3 | Variables for the event (depends on event_type) +event_param4 | Variables for the event (depends on event_type) +action1_type | Action #1 to take when the Event occurs (see "Action types" below) +action1_param1 | Variables used by Action1 (depends on action_type) +action1_param2 | Variables used by Action1 (depends on action_type) +action1_param3 | Variables used by Action1 (depends on action_type) +action2_type | Action #2 to take when the Event occurs (see "Action types" below) +action2_param1 | Variables used by Action1 (depends on action_type) +action2_param2 | Variables used by Action1 (depends on action_type) +action2_param3 | Variables used by Action1 (depends on action_type) +action3_type | Action #3 to take when the Event occurs (see "Action types" below) +action3_param1 | Variables used by Action1 (depends on action_type) +action3_param2 | Variables used by Action1 (depends on action_type) +action3_param3 | Variables used by Action1 (depends on action_type) + +All parameters are signed 32-bit values (+/- 2147483647). Time values are always in milliseconds. +In case of a percentage value, use value/100 (ie. param = 500 then that means 500%, -50 = -50%) + +[*] Phase mask is a bitmask of phases which shouldn't trigger this event. (ie. Phase mask of value 12 (binary 1100) results in triggering this event in phases 0, 1 and all others with exception for phases 2 and 3 (counting from 0). +[*] Phase 0 is default so this will occur in all phases unless specified. (1101 = Triggers in Phase 1 of 3, 1011 = Triggers in Phase 2 of 3, 0111 = Triggers in Phase 3 of 3, 0011 = Triggers in Both Phase 2 and 3). +[*] Take Desired Binary Configuration and convert into Decimal and this is your event_inverse_phase_mask to use in your script. + +========================================= +Event Types +=========== +This is the list of available Event Types EventAI is able to handle. +Each event type has its own specific interpretation of the parameters that accompany it. +Parameters are always read in the ascending order (from Param1 to Param3). + +NOTE: Events will not repeat until the creature exits combat or unless EFLAG_REPEATABLE value is set in Event Flags. +Some events such as EVENT_T_AGGRO, EVENT_T_DEATH, EVENT_T_SPAWNED, and EVENT_T_EVADE cannot repeat even if EFLAG_REPEATABLE value is set. + +# | Internal Name | Event Param Usage (Param1, Param2, Param3, Param4) | Description +---| ----------------------------- | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- +0 | EVENT_T_TIMER_IN_COMBAT | InitialMin, InitialMax, RepeatMin, RepeatMax | Expires at first between (Param1) and (Param2) and then will repeat between every (Param3) and (Param4), EXPIRES ONLY IN COMBAT. +1 | EVENT_T_TIMER_OOC | InitialMin, InitialMax, RepeatMin, RepeatMax | Expires at first between (Param1) and (Param2) and then will repeat between every (Param3) and (Param4), EXPIRES ONLY OUT OF COMBAT BUT NOT DURING EVADE. +2 | EVENT_T_HP | HPMax%, HPMin%, RepeatMin, RepeatMax | Expires when the NPC's HP% is between (Param1) and (Param2). Will repeat between every (Param3) and (Param4) If Event Conditions Are Still Met. +3 | EVENT_T_MANA | ManaMax%, ManaMin%, RepeatMin, RepeatMax | Expires when the NPC's Mana% is between (Param1) and (Param2). Will repeat between every (Param3) and (Param4) If Event Conditions Are Still Met. +4 | EVENT_T_AGGRO | NONE | Expires ONLY upon the NPC's INITIAL Aggro at the Start of Combat (Does NOT Repeat) and Only Resets on Spawn or Evade. +5 | EVENT_T_KILL | RepeatMin, RepeatMax | Expires upon Killing a Player. Will Repeat Check between (Param1) and (Param2). This Event Will Not Trigger Again Until Repeat Timer Expires +6 | EVENT_T_DEATH | NONE | Expires on the NPC's Death. (This Triggers At The Moment The NPC Dies) +7 | EVENT_T_EVADE | NONE | Expires at the moment the Creature EnterEvadeMode() and Exits Combat. +8 | EVENT_T_SPELLHIT | SpellID, Schoolmask, RepeatMin, RepeatMax | Expires upon Spell Hit of the NPC. When (param1) is set, it is the specific Spell ID used as the trigger. With (param2) specified, the expiration is limited to specific spell schools (-1 for all) and Spell ID value is ignored. Will repeat Event Conditions Check between every (Param3) and (Param4). Only A Spell ID or Spell School may be Specified but NOT both. +9 | EVENT_T_RANGE | MinDist, MaxDist, RepeatMin, RepeatMax | Expires when the Highest Threat Target Distance is Greater than (Param1) and Less than (Param2). Will repeat between every (Param3) and (Param4) if Event Conditions Are Still Met. +10 | EVENT_T_OOC_LOS | Hostile-or-Not, MaxAllowedRange, RepeatMin, RepeatMax | Expires when a unit moves within distance (MaxAllowedRange) of the NPC. If (Param1) is 0 it will expire only when unit is hostile, If (Param1) is 1 it will expire only when unit is friendly. This depends generally on faction relations. Will repeat every (Param3) and (Param4). Does NOT expire when the NPC is in combat. +11 | EVENT_T_SPAWNED | NONE | Expires on initial spawn and respawn of the NPC (Useful for setting Ranged Movement/Summoning Pets/Applying Buffs). +12 | EVENT_T_TARGET_HP | HPMax%, HPMin%, RepeatMin, RepeatMax | Expires when current target's HP% is between (Param1) and (Param2). Will repeat every (Param3) and (Param4)If Event Conditions Are Still Met. +13 | EVENT_T_TARGET_CASTING | RepeatMin, RepeatatMax | Expires when the current target is casting a spell. Will repeat every (Param1) and (Param2) If Event Conditions Are Still Met. +14 | EVENT_T_FRIENDLY_HP | HPDeficit, Radius, RepeatMin, RepeatMax | Expires when a friendly unit in (Radius) has at least (Param1) HP points missing. Will repeat every (Param3) and (Param4) If Event Conditions Are Still Met. +15 | EVENT_T_FRIENDLY_IS_CC | DispelType, Radius, RepeatMin, RepeatMax | Expires when a friendly unit is crowd controlled within the given Radius (Param2). Will repeat every (Param3) and (Param4). +16 | EVENT_T_FRIENDLY_MISSING_BUFF | SpellId, Radius, RepeatMin, RepeatMax | Expires when a friendly unit is missing aura(s) given by a spell (Param1) within Radius (Param2). Will repeat every (Param3) and (Param4) If Event Conditions Are Still Met. +17 | EVENT_T_SUMMONED_UNIT | CreatureId, RepeatMin, RepeatMax | Expires after creature with entry = (Param1) is spawned (Param1 = 0 means all spawns). Will repeat every (Param2) and (Param3). +18 | EVENT_T_TARGET_MANA | ManaMax%, ManaMin%, RepeatMin, RepeatMax | Expires when current target's Mana% is between (Param1) and (Param2). Will repeat every (Param3) and (Param4) If Event Conditions Are Still Met. +21 | EVENT_T_REACHED_HOME | NONE | Expires when a creature reaches it's home (spawn) location after evade. This is commonly used for NPC's who Stealth once reaching their Spawn Location +22 | EVENT_T_RECEIVE_EMOTE | EmoteId, Condition, CondValue1, CondValue2 | Expires when a creature receives an emote with emote text id ("enum TextEmotes" from SharedDefines.h in Mangos Source) in (Param1). Conditions can be defined (Param2) with optional values (Param3,Param4), see (enum ConditionType) in ObjectMgr.h (Mangos Source). +23 | EVENT_T_AURA | SpellID, AmountInStack, RepeatMin, RepeatMax | Expires when a creature has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4) If Event Conditions Are Still Met. +24 | EVENT_T_TARGET_BUFFED | SpellID, AmountInStack, RepeatMin, RepeatMax | Expires when a target unit has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4) If Event Conditions Are Still Met. +25 | EVENT_T_SUMMONED_JUST_DIED | CreatureId, RepeatMin, RepeatMax | Expires after creature with entry = (Param1) is die (Param1 = 0 means all spawns). Will repeat every (Param2) and (Param3). +26 | EVENT_T_SUMMONED_JUST_DESPAWN | CreatureId, RepeatMin, RepeatMax | Expires before creature with entry = (Param1) is despawn (Param1 = 0 means all spawns). Will repeat every (Param2) and (Param3). +27 | EVENT_T_MISSING_AURA | SpellID, AmountInStack, RepeatMin, RepeatMax | Expires when a creature not has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4). +28 | EVENT_T_TARGET_MISSING_AURA | SpellID, AmountInStack, RepeatMin, RepeatMax | Expires when a target unit not has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4). +29 | EVENT_T_TIMER_GENERIC | InitialMin, InitialMax, RepeatMin, RepeatMax | Expires at first between (Param1) and (Param2) and then will repeat between every (Param3) and (Param4). +30 | EVENT_T_RECEIVE_AI_EVENT | AIEventType, Sender-Entry, unused, unused | Expires when the creature receives an AIEvent of type (Param1), sent by creature (Param2 != 0). If (Param2 = 0) then sent by any creature + +Action Types +============ +This is a list of action types that EventAI is able to handle. +Each event type has it's own specific interpretation of it's parameters, just like Events. +For all ACTION_T_RANDOM Actions, When a Particular Param is selected for the Event... The SAME Param # is selected for all 3 actions when Event is triggered. + +# | Internal name | Param usage | Description +-- | ------------------------------------ | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------- +0 | ACTION_T_NONE | No Action | Does nothing. +1 | ACTION_T_TEXT | -TextId1, -TextId2, -TextId3 | Displays the specified -TextId. When -TextId2 and -TextId3 are specified, the selection will be Randomized between 1,2 or 3. Text ID's are defined, along with other options for the text, in creature_ai_texts table. Below is detailed Text Information. All text ID values for EventAI MUST be negative. +2 | ACTION_T_SET_FACTION | FactionId, Flags | Changes faction for a creature. When param1 is zero, creature will revert to it's default faction. Flags will determine when faction is restored to default (evade, respawn etc) +3 | ACTION_T_MORPH_TO_ENTRY_OR_MODEL | CreatureEntry, ModelId | Sets either model from creature_template.entry (Param1) OR explicit modelId (Param2) for the NPC. If (Param1) AND (Param2) are both 0, NPC will demorph and revert to the default model (as specified in creature_template). +4 | ACTION_T_SOUND | SoundId | NPC Plays a specified Sound ID. +5 | ACTION_T_EMOTE | EmoteId | NPC Does a specified Emote ID. +6 | UNUSED | UNUSED | UNUSED +7 | UNUSED | UNUSED | UNUSED +8 | UNUSED | UNUSED | UNUSED +9 | ACTION_T_RANDOM_SOUND | SoundId1, SoundId2, SoundId3 | NPC Plays a Random Sound ID (Random Selects Param1, Param2 or Param3) [^2] +10 | ACTION_T_RANDOM_EMOTE | EmoteId1, EmoteId2, EmoteId3 | NPC Emotes a Random Emote ID (Random Selects Param1, Param2 or Param3) [^2] +11 | ACTION_T_CAST | SpellId, Target, CastFlags | Casts spell (Param1) on a target (Param2) using cast flags (Param3) --> Specified Below +12 | ACTION_T_SUMMON | CreatureID, Target, Duration | Summons a Creature ID (Param1) for (Param3) duration after Evade (In MS) and orders it to attack (Param2) target (specified below). Spawns on top of NPC who summons it. +13 | ACTION_T_THREAT_SINGLE_PCT | Threat%, Target | Modifies a threat by (Param1) percent on a target (Param2). +14 | ACTION_T_THREAT_ALL_PCT | Threat% | Modifies a threat by (Param1) on all targets in the threat list (using -100% here will result in full aggro dump). +15 | ACTION_T_QUEST_EVENT | QuestID, Target | Calls AreaExploredOrEventHappens with (Param1) for a target in (Param2). +16 | ACTION_T_QUEST_CASTCREATUREGO | CreatureID, SpellId, Target | Sends CastCreatureOrGo for a creature specified by CreatureId (Param1) with provided spell id (Param2) for a target in (Param3). +17 | ACTION_T_SET_UNIT_FIELD | Field_Number, Value, Target | Sets a unit field (Param1) to provided value (Param2) on a target in (Param3). +18 | ACTION_T_SET_UNIT_FLAG | Flags, Target | Sets flag (flags can be used together to modify multiple flags at once) on a target (Param2). +19 | ACTION_T_REMOVE_UNIT_FLAG | Flags, Target | Removes flag on a target (Param2). +20 | ACTION_T_AUTO_ATTACK | AllowAutoAttack | Stop melee attack when (Param1) is zero, otherwise continue attacking / allow melee attack. +21 | ACTION_T_COMBAT_MOVEMENT | AllowCombatMovement | Stop combat based movement when (Param1) is zero, otherwise continue/allow combat based movement (targeted movement generator). +22 | ACTION_T_SET_PHASE | Phase | Sets the current phase to (Param1). +23 | ACTION_T_INC_PHASE | Value | Increments the phase by (Param1). May be negative to decrement, but should not be zero. +24 | ACTION_T_EVADE | No parameters | Forces the creature to evade, wiping all threat and dropping combat. +25 | ACTION_T_FLEE_FOR_ASSIST | No parameters | Causes the creature to flee for assistance (often at low health). +26 | ACTION_T_QUEST_EVENT_ALL | QuestId | Calls GroupEventHappens with (Param1). Only used if it's _expected_ event should call quest completion for all players in a current party. +27 | ACTION_T_CASTCREATUREGO_ALL | QuestId, SpellId | Calls CastedCreatureOrGo for all players on the threat list with quest id specified in (Param1) and spell id in (Param2). +28 | ACTION_T_REMOVEAURASFROMSPELL | Target, Spellid | Removes all auras on a target (Param1) caused by a spell (Param2). +29 | ACTION_T_RANGED_MOVEMENT | Distance, Angle | Changes the movement generator to a ranged type. (note: default melee type can still be set by using 0 as angle and 0 as distance). +30 | ACTION_T_RANDOM_PHASE | PhaseId1, PhaseId2, PhaseId3 | Sets a phase to a specified id(s) [^2] +31 | ACTION_T_RANDOM_PHASE_RANGE | PhaseMin, PhaseMax | Sets a phase to a random id (Phase = PhaseMin + rnd % PhaseMin-PhaseMax). PhaseMax must be greater than PhaseMin. +32 | ACTION_T_SUMMON_ID | CreatureID, Target, SummonID | Summons a creature (Param1) to attack target (Param2) at location specified by EventAI_Summons (Param3). +33 | ACTION_T_KILLED_MONSTER | CreatureID, Target | Calls KilledMonster (Param1) for a target (Param2). +34 | ACTION_T_SET_INST_DATA | Field, Data | Calls ScriptedInstance::SetData with field (Param1) and data (Param2). +35 | ACTION_T_SET_INST_DATA64 | Field, Target | Calls ScriptedInstance::SetData64 with field (Param1) and target's GUID (Param2). +36 | ACTION_T_UPDATE_TEMPLATE | TemplateId, Team | Changes a creature's template to (Param1) with team = Alliance or Horde when (Param2) is either false or true respectively. +37 | ACTION_T_DIE | No parameters | Kills the creature +38 | ACTION_T_ZONE_COMBAT_PULSE | No parameters | Puts all players within an instance into combat with the creature. Only works when a creature is already in combat. Doesn't work outside instances. +39 | ACTION_T_CALL_FOR_HELP | Radius | Call any friendly out-of-combat creatures in a radius (Param1) to attack current creature's target. +40 | ACTION_T_SET_SHEATH | Sheath | Sets sheath state for a creature (0 = no weapon, 1 = melee weapon, 2 = ranged weapon). +41 | ACTION_T_FORCE_DESPAWN | Delay | Despawns the creature, if delay = 0 immediate otherwise will despawn after delay time set in Param1 (in ms). +42 | ACTION_T_SET_INVINCIBILITY_HP_LEVEL | HP_Level, HP_Percent | Set min. health level for creature that can be set at damage as flat value or percent from max health +43 | ACTION_T_MOUNT_TO_ENTRY_OR_MODEL | CreatureEntry, ModelId | Set mount model from creature_template.entry (Param1) OR explicit modelId (Param2). If (Param1) AND (Param2) are both 0, unmount. +44 | ACTION_T_CHANCED_TEXT | Chance, -TextId1, -TextId2 | Displays by Chance (1..100) the specified -TextId. When -TextId2 is specified, the selection will be randomized. Text types are defined, along with other options for the text, in a table below. Param2 and Param3 needs to be negative. +45 | ACTION_T_THROW_AI_EVENT | EventType, Radius | Throws an AIEvent of type (Param1) to nearby friendly Npcs in range of (Param2) +46 | ACTION_T_SET_THROW_MASK | EventTypeMask | Marks for which AIEvents the npc will throw AIEvents on its own. +47 ACTION_T_SUMMON_UNIQUE CreatureID, Target, SummonID Only summons a creature when not already spawned (Param1) to attack target (Param2) at location specified by EventAI_Summons (Param3). Preventing multiple spawns of unique creatures. +48 ACTION_T_EMOTE_TARGET EmoteId, TargetGuid NPC faces to creature (Param2) and does a specified emote id (Param1). + +* = Use -1 where the param is expected to do nothing. Random constant is generated for each event, so if you have a random yell and a random sound, they will be linked up with each other (ie. param2 with param2). + + +============================================== +Event Types: Expanded and Detailed Information +---------------------------------------------- +* COMBAT ONLY - Means that this event will only trigger during combat. +* OUT OF COMBAT ONLY - Means that this event will only trigger while out of combat. +* BOTH - This event can trigger both in and out of combat. + +Events that do not have labels on them are events that are directly involved with the in and out of combat state. + +0 = EVENT_T_TIMER_IN_COMBAT +--------------------------- +* Parameter 1: InitialMin - Minimum Time used to calculate Random Initial Expire +* Parameter 2: InitialMax - Maximum Time used to calculate Random Initial Expire +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +COMBAT ONLY - Expires first between (Param1) and (Param2) and then between every (Param3) and (Param4) from then on. +This is commonly used for spells that repeat cast during combat (Simulates Spell Cool-down). + +1 = EVENT_T_TIMER_OOC +--------------------- +* Parameter 1: InitialMin - Minimum Time used to calculate Random Initial Event Expire +* Parameter 2: InitialMax - Maximum Time used to calculate Random Initial Event Expire +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Event Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Event Expire + +OUT OF COMBAT ONLY (Not while evading) - Expires first between (Param1) and (Param2) and then between every (Param3) and (Param4) from then on. +This is commonly used for events that occur and repeat outside of combat like random NPC Say or Random Emotes. + +2 = EVENT_T_HP +-------------- +* Parameter 1: HPMax% - Maximum HP% That will trigger this Event to Expire +* Parameter 2: HPMin% - Minimum HP% That will trigger this Event to Expire +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Event Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Event Expire + +BOTH - Expires when HP is between (Param1) and (Param2). Will repeat every (Param3) and (Param4). +This is commonly used for events that occur at a specific HP% Range (Such as Heal/Enrage Spells or NPC's that Flee). +NOTE: For Repeat Events the Repeat Timer ONLY Re-Check's Event Conditions to see If HP% Is Between Max and Min. If it is then Event will Expire again. + +3 = EVENT_T_MANA +---------------- +* Parameter 1: ManaMax% - Maximum Mana% That will trigger this Event to Expire +* Parameter 2: ManaMin% - Minimum Mana% That will trigger this Event to Expire +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Event Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Event Expire + +BOTH - Expires once Mana% is between (Param1) and (Param2). Will repeat every (Param3) and (Param4). +This is commonly used for events where an NPC low on Mana will do something (Such as stop casting spells and switch to melee). + +4 = EVENT_T_AGGRO +----------------- +**COMBAT ONLY** - This Event Expires upon Initial Aggro (This Event does not occur again until NPC either Evades/Re-spawns and then Enters Combat Again). + +5 = EVENT_T_KILL +---------------- +* Parameter 1: RepeatMin - Minimum Time used to calculate Random Repeat Event Expire +* Parameter 2: RepeatMax - Maximum Time used to calculate Random Repeat Event Expire + +COMBAT ONLY - Expires upon killing a player. Will repeat every (Param1) and (Param2). +This Event Expires upon killing a player. It is commonly used for NPC's who yell or do something after killing a player. Normally use a short repeating timer is advisable. +NOTE: For Repeat Events the Repeat Timer ONLY Re-Check's Event Conditions to see If another Player Kill has occurred. So After Repeat Min/Max Player Kill Event can occur again. + +6 = EVENT_T_DEATH +----------------- +BOTH - This Event Expires upon Death of the Scripted NPC. This is normally only used in combat though. +This is commonly used for NPC's who have a Yell or Spell Cast when they Die. + +7 = EVENT_T_EVADE +----------------- +COMBAT ONLY - This Event Expires when the Scripted NPC Evades Combat (EnterEvadeMode). +This is commonly used for NPC's who use phases, allows you to reset their phase to 0 on evade to prevent possible strange behavior on Re-Aggro. + +8 = EVENT_T_SPELLHIT +-------------------- +* Parameter 1: SpellID - The Spell ID that will trigger the Event to occur (NOTE: If you use Spell School as the trigger ALWAYS set this value to 0) +* Parameter 2: School - Spell School to trigger the Event (NOTE: If you use a SpellID then ALWAYS set this value to -1) - *See Below for Spell School Bit mask Values* +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Event Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Event Expire + +BOTH - Expires on Spell-hit. If (param1) is set it will only expire on that SPECIFIC Spell OR If (param2) is set it will only expire on Spells of that School. Will repeat every (Param3) and (Param4). +This Event is commonly used for NPC's who can do special things when you cast a spell (Or specific spell) on them. +NOTE: For Repeat Events the Repeat Timer ONLY Re-Check's Event Conditions to see If another Spell-hit has occurred. So After Repeat Min/Max expires Spell-hit Event can occur again. + +Name | School | School Bit mask Values +--------------------| ------ | --------------- +SPELL_SCHOOL_NORMAL | 0 | 1 +SPELL_SCHOOL_HOLY | 1 | 2 +SPELL_SCHOOL_FIRE | 2 | 4 +SPELL_SCHOOL_NATURE | 3 | 8 +SPELL_SCHOOL_FROST | 4 | 16 +SPELL_SCHOOL_SHADOW | 5 | 32 +SPELL_SCHOOL_ARCANE | 6 | 64 + +Use These Bit mask Values For Schoolmask (Param2) or Any Combinations Of These School Bit masks for Multiple Schools. + +9 = EVENT_T_RANGE +----------------- +* Parameter 1: MinDist - This Distance is the Minimum Distance between the NPC and it's target to allow this Event to Expire +* Parameter 2: MaxDist - This Distance is the Maximum Distance between the NPC and it's target to allow this Event to Expire +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +COMBAT ONLY - Expires when the highest threat target distance is greater than (Param1) and less than (Param2). Will repeat every (Param3) and (Param4). +This Event is commonly used for NPC's who have Ranged Combat and will Throw/Shoot between a certain distance. + +10 = EVENT_T_OOC_LOS +-------------------- +* Parameter 1: Hostile-or-Not - This will expire if Unit are hostile. If Param1=1 it will only expire if Unit are not Hostile(generally determined by faction) +* Parameter 2: MaxAllowedRange - Expires when a Unit moves within this distance to creature +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +OUT OF COMBAT ONLY +This Event is commonly used for NPC's who do something or say something to you when you walk past them Out of Combat. + +11 = EVENT_T_SPAWNED +-------------------- +Expires at initial spawn and at creature respawn. +This Event is commonly used for setting ranged movement type or Summoning a Pet on Spawn + +* Parameter 1: 0: works always, 1: works on map in Parameter 2, 2: works on zone/sub-zone in Parameter 2 +* Parameter 2: depends on Parameter 1: for 1 it is map ID, for 2 it is area ID to check + +BOTH - Expires in or out of combat when the NPC Spawns +This Event is commonly used for NPC's who cast a spell or do something special when they spawn. This event is not repeatable so it is a one time event on Spawn. + +12 = EVENT_T_TARGET_HP +---------------------- +* Parameter 1: HPMax% - Maximum HP% That this Event will Expire +* Parameter 2: HPMin% - Minimum HP% That this Event will Expire +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +COMBAT ONLY - Expires when Current NPC's Target's HP is between (Param1) and (Param2). Will repeat every (Param3) and (Param4). +This Event is commonly used for NPC's who have a special ability (Like Execute) that only casts when a Player HP is low. + +13 = EVENT_T_TARGET_CASTING +--------------------------- +* Parameter 1: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 2: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +COMBAT ONLY - Expires when the current target is casting a spell. Will repeat every (Param1) and (Param2). +This event is commonly used for NPC's who will cast a counter spell when their target starts to cast a spell. + +14 = EVENT_T_FRIENDLY_HP +------------------------ +* Parameter 1: HPDeficit - This is the Amount of HP Missing from Full HP to trigger this event (You would need to calculate the amount of HP the event happens and subtract that from Full HP Value to get this number) +* Parameter 2: Radius - This is the Range in Yards the NPC will scan for nearby Friendlies (Faction is Friendly To) for the missing amount of HP in Param1. +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +COMBAT ONLY - Expires when a friendly unit in radius(param2) has at least (param1) hp missing. Will repeat every (Param3) and (Param4). +This is commonly used when an NPC in Combat will heal a nearby Friendly NPC in Combat with a Heal/Renew Spell. + +15 = EVENT_T_FRIENDLY_IS_CC +--------------------------- +* Parameter 1: DispelType - Dispel Type to trigger the event - *See Below for Dispel Bit mask Values* +* Parameter 2: Radius - This is the Range in Yards the NPC will scan for nearby Friendlies being Crowd Controlled +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +COMBAT ONLY - Expires when a friendly unit is Crowd controlled within the given radius (param2). Will repeat every (Param3) and (Param4). +This is commonly used for NPC's who can come to the rescue of other Friendly NPC's if being Crowd Controlled + +16 = EVENT_T_FRIENDLY_MISSING_BUFF +---------------------------------- +* Parameter 1: SpellId - This is the SpellID That the Aura Check will look for (If it is missing this Aura) +* Parameter 2: Radius - This is the Range in Yards the NPC will scan for nearby Friendlies (Faction is Friendly To) for the missing Aura. +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +BOTH - Expires when a friendly unit is missing aura's given by spell (param1) within radius (param2). Will repeat every (Param3) and (Param4). +This is commonly used for NPC's who watch friendly units for a debuff to end so they can recast it on them again. + +17 = EVENT_T_SUMMONED_UNIT +-------------------------- +* Parameter 1: CreatureId - The CreatureID that the NPC is watching to spawn to trigger this event +* Parameter 2: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 3: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +BOTH - Expires after creature with entry(Param1) is spawned or for all spawns if param1 = 0. Will repeat every (Param2) and (Param3) . +This is commonly used for NPC's who will do something special once another NPC is summoned. Usually used is Complex Scripts or Special Events. + +21 = EVENT_T_REACHED_HOME +------------------------- +Expires only when creature has returned to it's home location after Evade. Out of combat event. +Most commonly used to cast spells that can not be casted in EVENT_T_EVADE and other effects that does not fit in while still running back to spawn/home location. + +22 = EVENT_T_RECEIVE_EMOTE +-------------------------- +* Parameter 1: EmoteId - Valid text emote ID from Mangos source (SharedDefines.h - enum TextEmotes) +* Parameter 2: Condition - Conditions based on /src/game/ObjectMgr.h - enum ConditionType +* Parameter 3: CondValue1 - +* Parameter 4: CondValue2 - + +Expires only when creature receive emote from player. Valid text emote id's are in Mangos source (SharedDefines.h - enum TextEmotes) +Event does not require any conditions to process, however many are expected to have condition. + +23 = EVENT_T_AURA +----------------- +* Parameter 1: SpellId - This is the SpellID That the Aura Check will look for +* Parameter 2: Amount - This is the amount of SpellID's auras at creature required for event expire. +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +24 = EVENT_T_TARGET_BUFFED +-------------------------- +* Parameter 1: SpellId - This is the SpellID That the Aura Check will look for +* Parameter 2: Amount - This is the amount of SpellID's auras at target unit required for event expire. +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +EventAI use conditions from available in Mangos (enum ConditionType) + +**Current implemented conditions** + +Condition | Object | Value +----------------------------- | ----------- | ---------------------------------- +CONDITION_NONE (0) | 0 | 0 +CONDITION_AURA (1) | spell_id | effindex +CONDITION_ITEM (2) | item_id | count +CONDITION_ITEM_EQUIPPED (3) | item_id | count +CONDITION_ZONEID (4) | zone_id | 0 +CONDITION_REPUTATION_RANK (5) | faction_id | min_rank +CONDITION_TEAM (6) | player_team | 0 (469-Alliance / 67-Horde) +CONDITION_SKILL (7) | skill_id | min_skill_value +CONDITION_QUESTREWARDED (8) | quest_id | 0, if quest are rewarded +CONDITION_QUESTTAKEN (9) | quest_id | 0, while quest active(incomplete) +CONDITION_ACTIVE_EVENT (12) | event_id | 0, note this is id from dbc, also defined in Mangos source(enum HolidayIds) NOT id of game_event in database + +25 = EVENT_T_SUMMONED_JUST_DIED +------------------------------- +* Parameter 1: CreatureId - The CreatureID that the NPC is watching die to trigger this event +* Parameter 2: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 3: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +BOTH - Expires after creature with entry(Param1) is die or for all spawns if param1 = 0. Will repeat every (Param2) and (Param3) . +This is commonly used for NPC's who will do something special once another NPC is die. Usually used is Complex Scripts or Special Events. + +26 = EVENT_T_SUMMONED_JUST_DESPAWN +---------------------------------- +* Parameter 1: CreatureId - The CreatureID that the NPC is watching despawn to trigger this event +* Parameter 2: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 3: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +BOTH - Expires before creature with entry(Param1) is despawned or for all spawns if param1 = 0. Will repeat every (Param2) and (Param3) . +This is commonly used for NPC's who will do something special once another NPC is despawn. Usually used is Complex Scripts or Special Events. +NOTE: called before despawn happens, so summoned creature still in world at expire moment. + +27 = EVENT_T_MISSING_BUFF +------------------------- +* Parameter 1: SpellId - This is the SpellID That the Aura Check will look for to be missing +* Parameter 2: Amount - This is the amount or less of SpellID's auras at creature required for event expire. +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +28 = EVENT_T_TARGET_MISSING_AURA +-------------------------------- +* Parameter 1: SpellId - This is the SpellID That the Aura Check will look for to be missing +* Parameter 2: Amount - This is the amount or less of SpellID's auras at creature required for event expire. +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +29 = EVENT_T_TIMER_GENERIC +-------------------------- +* Parameter 1: InitialMin - Minimum Time used to calculate Random Initial Expire +* Parameter 2: InitialMax - Maximum Time used to calculate Random Initial Expire +* Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire +* Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire + +IN COMBAT and OUT OF COMBAT - Expires first between (Param1) and (Param2) and then between every (Param3) and (Param4) from then on. + +30 = EVENT_T_RECEIVE_AI_EVENT +----------------------------- +* Parameter 1: AIEventType - Only expire when an AIEvent of this type is received. Supported types see CreatureAI.h enum AIEventType +* Parameter 2: Sender-Entry - If != 0 then only expire when the AIEvent is received from a creature of this entry + +Note: This is the only EVENT where the target-type TARGET_T_EVENT_SENDER (10) is defined + +Action types +============ + +1 = ACTION_T_TEXT +------------------ +* Parameter 1: The entry of the text that the NPC should use from eventai_texts table. Optionally a entry from other tables can be used (such as custom_texts). + Entry are required to be negative and exist in a *_texts-table. The type text to be displayed are defined in the texts-table itself (Say, Yell, Whisper, Emote Text, Boss Whisper, Boss Emote) + Other options are also to be defined in the texts-table, such as a sound to be heard with the text and the language used in output (common, dwarvish, etc). + In case this entry has a localized version of the text, the localized text will be displayed in client that support this locale. +* Parameter 2: Optional. TextId can be defined in addition. The same apply to this as explained above, however eventAI will randomize between the two. +* Parameter 3: Optional, if Parameter 2 exist. In this case, eventAI will randomize between three. + +Read at bottom for documentation of creature_ai_texts-table. + +2 = ACTION_T_SET_FACTION +------------------------- +* Parameter 1: FactionId from Faction.dbc OR 0. Changes faction for creature. If 0, creature will revert to it's default faction if previously changed. +* Parameter 2: When Parameter 1 is not 0, flags can be used to restore default faction at certain events. Current supported, from enum TemporaryFactionFlags: + TEMPFACTION_NONE = 0x00, // A persistent faction change and will require manual change to default/another faction when changed once + TEMPFACTION_RESTORE_RESPAWN = 0x01, // Default faction will be restored at respawn + TEMPFACTION_RESTORE_COMBAT_STOP = 0x02, // ... at CombatStop() (happens at creature death, at evade or custom scripte among others) + TEMPFACTION_RESTORE_REACH_HOME = 0x04, // ... at reaching home in home movement (evade), if not already done at CombatStop() + +3 = ACTION_T_MORPH_TO_ENTRY_OR_MODEL +------------------------------------- +* Parameter 1: Creature entry from creature_template. Action will then change to the model this creature are using. +* Parameter 2: If parameter 1 is 0, then this modelId will be used (in case parameter 1 exist, parameter 2 will not be used) + +If both parameter 1 and 2 is 0, the creature will DeMorph, and use it's default model. + +4 = ACTION_T_SOUND +------------------- +* Parameter 1: The Sound ID to be played. (Sound IDs are contained in the DBC files.) + +The creature will play the specified sound. +This is commonly used for Bosses who Yell and then also have a Voice for the same thing. + +5 = ACTION_T_EMOTE +------------------- +* Parameter 1: The Emote ID that the creature should perform. (Emote IDs are also contained in the DBC but they can be found in the mangos source as well). + +The creature will perform a visual emote. Unlike a text emote, a visual emote is one where the creature will actually move or perform a gesture. +This is commonly used for NPC's who may perform a special action (Salute, Roar, etc...). Not all player emotes work for creature models. + +6 = ACTION_T_RANDOM_SAY +------------------------ +UNUSED Can be reused to create new action type + +7 = ACTION_T_RANDOM_YELL +------------------------- +UNUSED Can be reused to create new action type + +8 = ACTION_T_RANDOM_TEXTEMOTE +------------------------------ +UNUSED Can be reused to create new action type + +9 = ACTION_T_RANDOM_SOUND +-------------------------- +* Parameter 1: The Sound ID to be played as Random Choice #1. +* Parameter 2: The Sound ID to be played as Random Choice #2. +* Parameter 3: The Sound ID to be played as Random Choice #3. + +Similar to the ACTION_T_SOUND action, it will choose at random a sound to play. + +10 = ACTION_T_RANDOM_EMOTE +--------------------------- +* Parameter 1: The Emote ID to be played as Random Choice #1. +* Parameter 2: The Emote ID to be played as Random Choice #2. +* Parameter 3: The Emote ID to be played as Random Choice #3. + +Similar to the ACTION_T_EMOTE action, it will choose at random an Emote to Visually Perform. + +11 = ACTION_T_CAST +------------------- +* Parameter 1: SpellId - The Spell ID to use for the NPC to cast. The value used in this field needs to be a valid Spell ID. +* Parameter 2: Target - The Target Type defining who the creature should cast the spell at. The value in this field needs to be a valid Target Type as specified in the reference tables below. +* Parameter 3: CastFlags - See Table Below for Cast Flag Bit mask Values. If you are unsure what to set this value at leave it at 0. + +The creature will cast a spell specified by a spell ID on a target specified by the target type. +If the spell is normal cast, random target types will select only targets within LOS and in spell range +This is commonly used for NPC's who cast spells. + +12 = ACTION_T_SUMMON +--------------------- +* Parameter 1: CreatureID - The Creature Template ID to be Summoned. The value here needs to be a valid Creature Template ID. +* Parameter 2: Target - The Target Type defining who the Summoned creature will attack once spawned. The value in this field needs to be a valid Target Type as specified in the reference tables below. +* Parameter 3: Duration - The duration until the summoned creature should be unsummoned AFTER Combat ends. The value in this field is in milliseconds or 0. + +The NPC will Summon another cast flag 0 will work for you creature at the same spot as itself that will attack the specified target. + +*NOTE*: Almost all Creature Summons have proper Summon Spells that should be used when possible. This Action is a powerful last resort option only to be used if nothing else works. +*NOTE*: Using Target Type 0 will cause the Summoned creature to not attack anyone. +*NOTE*: If Duration is set at 0, then the summoned creature will not despawn until it has died. + +This is used as a manual way to force an NPC to Summon. + +NOTE: THIS ONLY WORKS IN COMBAT + +13 = ACTION_T_THREAT_SINGLE_PCT +-------------------------------- +* Parameter 1: Threat% - Threat percent that should be modified. The value in this field can range from -100 to +100. If it is negative, threat will be taken away and if positive, threat will be added. +* Parameter 2: Target - The Target Type defining on whom the threat change should occur. The value in this field needs to be a valid target type as specified in the reference tables below. + +This action will modify the threat of a target in the creature's threat list by the specified percent. +This is commonly used to allow an NPC to adjust the Threat to a single player. + +14 = ACTION_T_THREAT_ALL_PCT +----------------------------- +* Parameter 1: Threat% - The percent that should be used in modifying everyone's threat in the creature's threat list. The value here can range from -100 to +100. + +This action will modify the threat for everyone in the creature's threat list by the specified percent. + +NOTE: Using -100 will cause the creature to reset everyone's threat to 0 so that everyone has the same amount of threat. It will NOT remove anyone from the threat list. + +This is commonly used to allow an NPC to drop threat for all players to zero. + +15 = ACTION_T_QUEST_EVENT +-------------------------- +* Parameter 1: QuestID - The Quest Template ID. The value here must be a valid quest template ID. Furthermore, the quest should have SpecialFlags | 2 as it would need to be completed by an external event which is the activation of this action. +* Parameter 2: Target - The Target Type defining whom the quest should be completed for. The value in this field needs to be a valid target type as specified in the reference tables below. + +This action will satisfy the external completion requirement for the quest for the specified target defined by the target type. +NOTE: This action can only be used with player targets so it must be ensured that the target type will point to a player. +This is commonly used for Quests where only ONE player will gain credit for the quest. + +16 = ACTION_T_CASTCREATUREGO +----------------------------- +* Parameter 1: CreatureID - The Creature Template ID to be Summoned. The value here needs to be a valid Creature Template ID. +* Parameter 2: SpellID - The Spell ID to use to simulate the cast. The value used in this field needs to be a valid Spell ID. +* Parameter 3: Target - The Target Type defining whom the quest credit should be given to. The value in this field needs to be a valid target type as specified in the reference tables below. + +This action will call CastedCreatureOrGO() function for the player. It can be used to give quest credit for casting a spell on the creature. +This is commonly used for NPC's who have a special requirement to have a Spell cast on them to complete a quest. + +17 = ACTION_T_SET_UNIT_FIELD +----------------------------- +* Parameter 1: Field_Number - The index of the Field Number to be changed. Use (http://wiki.udbforums.org/index.php/Character_data) for a list of indexes and what they control. Creatures only contain the OBJECT_FIELD_* and UNIT_FIELD_* fields. They do not contain the PLAYER_FIELD_* fields. +* Parameter 2: Value - The new value to be put in the field. +* Parameter 3: Target - The Target Type defining for whom the unit field should be changed. The value in this field needs to be a valid target type as specified in the reference tables below. + +When activated, this action can change the target's unit field values. More information on the field value indexes can be found at (http://wiki.udbforums.org/index.php/Character_data) + +18 = ACTION_T_SET_UNIT_FLAG +---------------------------- +* Parameter 1: Flags - The flag(s) to be set. Multiple flags can be set by using bitwise-OR on them (adding them together). +* Parameter 2: Target - The Target Type defining for whom the flags should be changed. The value in this field needs to be a valid Target Type as specified in the reference tables below. + +When activated, this action changes the target's flags by adding (turning on) more flags. For example, this action can make the creature unattackable/unselectable if the right flags are used. + +19 = ACTION_T_REMOVE_UNIT_FLAG +------------------------------- +* Parameter 1: Flags - The flag(s) to be removed. Multiple flags can be set by using bitwise-OR on them (adding them together). +* Parameter 2: Target - The target type defining for whom the flags should be changed. The value in this field needs to be a valid Target Type as specified in the reference tables below. + +When activated, this action changes the target's flags by removing (turning off) flags. For example, this action can make the creature normal after it was unattackable/unselectable if the right flags are used. + +20 = ACTION_T_AUTO_ATTACK +-------------------------- +* Parameter 1: AllowAutoAttack - If zero, then the creature will stop its melee attacks. If non-zero, then the creature will either continue its melee attacks (the action would then have no effect) or it will start its melee attacks on the target with the top threat if its melee attacks were previously stopped. + +This action controls whether or not the creature should stop or start the auto melee attack. +NOTE: The ACID Dev Team has conformed to using either 0 or 1 for the Param values (0 = Stop Melee, 1 = Start Melee). +This is commonly used in combination with EVENT_T_RANGE and ACTION_T_COMBAT_MOVEMENT for Ranged Combat for Mages and Spell Casters. + +21 = ACTION_T_COMBAT_MOVEMENT +------------------------------ +* Parameter 1: If zero, then the creature will stop moving towards its victim (if its victim gets out of melee range) and will be stationary. If non-zero, then the creature will either continue to follow its victim (the action would have no effect) or it will start to follow the target with the top threat if its movement was disabled before. +* Parameter 2: If non-zero, then stop melee combat state (if param1=0) or start melee combat state (if param1!=0) and creature in combat with selected target. + +This action controls whether or not the creature will always move towards its target. +NOTE: The ACID Dev Team has conformed to using either 0 or 1 for the Param values. (0 = Stop Movement, 1 = Start Movement) +This is commonly used with EVENT_T_RANGE and ACTION_T_AUTO_ATTACK for NPC's who engage in Ranged Combat (Either Spells or Ranged Attacks) +Parameter 2 specially used for ranged combat proper client side visual show ranged weapon in proper state. + +22 = ACTION_T_SET_PHASE +------------------------ +* Parameter 1: The new phase to set the creature in. This number must be an integer between 0 and 31. Numbers outside of that range will result in an error. + +When activated, this action sets the creature's event to the specified value. +NOTE: The creature's current Phase is NOT reset at creature evade. You must manually set the phase back to 0 at EVENT_T_RESET. +NOTE: The value used for the Param is the actual Phase Number (Not The Event_Inverse_Phase_Mask) +This is commonly used for complex scripts with several phases and you need to switch to a different phase. + +23 = ACTION_T_INC_PHASE +------------------------ +* Parameter 1: Value - The number of phases to increase or decrease. Use negative values to decrease the current phase. + +When activated, this action will increase (or decrease) the current creature's phase. +NOTE: After increasing or decreasing the phase by this action, the current phase must NOT be lower than 0 or exceed 31. +This can be used instead of ACTION_T_SET_PHASE to change phases in scripts. Just a user friendly option for changing phases. + +24 = ACTION_T_EVADE +-------------------- +When activated, the creature will immediately exit out of combat, clear its threat list, and move back to its spawn point. Basically, this action will reset the whole encounter. +NOTE: All Param Values Are 0 for this Action. + +25 = ACTION_T_FLEE +------------------- +When activated, the creature will flee from combat for assistance from nearby NPC's if possible. +NOTE: All Param Values Are 0 for this Action. + +26 = ACTION_T_QUEST_EVENT_ALL +------------------------------ +* Parameter 1: QuestId - The quest ID to finish for everyone. + +This action does the same thing as the ACTION_T_QUEST_EVENT does but it does it for all players in the creature's threat list. +NOTE: If a player is not in the NPC's threat list for whatever reason, he/she won't get the quest completed. + +27 = ACTION_T_CASTCREATUREGO_ALL +--------------------------------- +* Parameter 1: QuestId - The quest template ID. +* Parameter 2: SpellId - The spell ID used to simulate the cast. + +This action does the same thing as the ACTION_T_CASTCREATUREGO does but it does it for all players in the creature's threat list. +NOTE: If a player is not in its threat list for whatever reason, he/she won't receive the cast emulation. + +28 = ACTION_T_REMOVEAURASFROMSPELL +----------------------------------- +* Parameter 1: Target - The target type defining for whom the unit field should be changed. The value in this field needs to be a valid target type as specified in the reference tables below. +* Parameter 2: SpellId - The spell ID whose auras will be removed. + +This action will remove all auras from a specific spell from the target. +This is commonly used for NPC's who have an OOC Aura that is removed at combat start or a similar idea (Like Stealth or Shape Shift) + +29 = ACTION_T_RANGED_MOVEMENT +------------------------------ +* Parameter 1: Distance - The distance the mob should keep between it and its target. +* Parameter 2: Angle - The angle the mob should use. + +This action changes the movement type generator to ranged type using the specified values for angle and distance. +NOTE: Specifying zero angle and distance will make it just melee instead. +This is commonly used for NPC's who always attack at range and you can specify the distance they will maintain from the target. + +30 = ACTION_T_RANDOM_PHASE +--------------------------- +* Parameter 1: PhaseId1 - A possible random phase choice. +* Parameter 2: PhaseId2 - A possible random phase choice. +* Parameter 3: PhaseId3 - A possible random phase choice. + +Randomly sets the phase to one from the three parameter choices. +NOTE: Use -1 to specify that if this param is picked to do nothing. Random is constant between actions within an event. So if you have a random Yell and a random Sound they will match up (ex: param2 with param2) +NOTE 2: PLEASE NOTE THAT EACH OF THE PARAM VALUES ARE ACTUAL PHASE NUMBERS NOT THE INVERSE PHASE MASK VALUE. +This is commonly used for Spell casting NPC's who on Aggro may select at random a school of spells to use for the fight. Use this if you have up to 3 phases used, otherwise use Action 31 for more then 3 phases. + +31 = ACTION_T_RANDOM_PHASE_RANGE +--------------------------------- +* Parameter 1: PhaseMin - The minimum of the phase range. +* Parameter 2: PhaseMax - The maximum of the phase range. The number here must be greater than PhaseMin. + +Randomly sets the phase between a range of phases controlled by the parameters. Sets the phase to a random id (Phase = PhaseMin + rnd % PhaseMin-PhaseMax). +NOTE: PhaseMax must be greater than PhaseMin. +NOTE 2: PLEASE NOTE THAT EACH OF THE PARAM VALUES ARE ACTUAL PHASE NUMBERS NOT THE INVERSE PHASE MASK VALUE. +This is commonly used for Spell casting NPC's who on Aggro may select at random a school of spells to use for the fight. Use this if you have MORE then 3 phases used, otherwise use Action 30. + +32 = ACTION_T_SUMMON +--------------------- +* Parameter 1: CreatureID - The creature template ID to be summoned. The value here needs to be a valid creature template ID. +* Parameter 2: Target - The target type defining who the summoned creature will attack. The value in this field needs to be a valid target type as specified in the reference tables below. NOTE: Using target type 0 will cause the summoned creature to not attack anyone. +* Parameter 3: SummonID - The summon ID from the creature_ai_summons table controlling the position (and spawn time) where the summoned mob should be spawned at. + +Summons creature (param1) to attack target (param2) at location specified by creature_ai_summons (param3). +NOTE: Param3 Value is the ID Value used for the entry used in creature_ai_summons for this action. You MUST have an creature_ai_summons entry to use this action. +This is commonly used for NPC's who need to Summon a creature at a specific location. (Normally used for complex events) + +33 = ACTION_T_KILLED_MONSTER +----------------------------- +* Parameter 1: CreatureID - The creature template ID. The value here must be a valid creature template ID. +* Parameter 2: Target - The target type defining whom the quest kill count should be given to. The value in this field needs to be a valid target type as specified in the reference tables below. + +When activated, this action will call KilledMonster() function for the player. It can be used to give creature credit for killing a creature. In general if the quest is set to be accomplished on different creatures (e.g. "Credit" templates). +NOTE: It can be ANY creature including certain quest specific triggers +This is commonly used for giving the player Quest Credits for NPC kills (Many NPC's may use the same CreatureID for the Kill Credit) + +34 = ACTION_T_SET_INST_DATA +---------------------------- +* Parameter 1: Field - The field to change in the instance script. Again, this field needs to be a valid field that has been already defined in the instance's script. +* Parameter 2: Data - The value to put at that field index. + +Sets data for the instance. Note that this will only work when the creature is inside an instantiable zone that has a valid script (ScriptedInstance) assigned. +This is commonly used to link an EventAI script with a existing Script Library C++ Script. You make make things happen like opening doors on specific events that happen. + +Field Values: +These are located in there SD2 Instance File (Example: blackrock_depths.h) And Are Clearly Defined For Specific Events Scripted In The Instance. + +Name | Value +----------- | ----- +NOT_STARTED | 0 +IN_PROGRESS | 1 +FAIL | 2 +DONE | 3 +SPECIAL | 4 + +35 = ACTION_T_SET_INST_DATA64 +------------------------------ +* Parameter 1: Field - The field to change in the instance script. Again, this field needs to be a valid field that has been already defined in the instance's script. +* Parameter 2: Target - The target type to use to get the GUID that will be stored at the field index. The value in this field needs to be a valid target type as specified in the reference tables below. + +Sets GUID (64 bits) data for the instance based on the target. Note that this will only work when the creature is inside an instantiable zone that has a valid script (ScriptedInstance) assigned. +Calls ScriptedInstance::SetData64 with field (param1) and data (param2) target's GUID. + +36 = ACTION_T_UPDATE_TEMPLATE +------------------------------ +* Parameter 1: TemplateId - The creature template ID. The value here must be a valid creature template ID. +* Parameter 2: Team - Use model_id from team : Alliance(0) or Horde (1). + +This function temporarily changes creature entry to new entry, display is changed, loot is changed, but AI is not changed. At respawn creature will be reverted to original entry. +Changes the creature to a new creature template of (param1) with team = Alliance if (param2) = false or Horde if (param2) = true + +37 = ACTION_T_DIE +------------------ +Kills the creature + +This is commonly used if you need to Instakill the creature for one reason or another. + +38 = ACTION_T_ZONE_COMBAT_PULSE +-------------------------------- +Places all players within the instance into combat with the creature. Only works in combat and only works inside of instances. + +39 = ACTION_T_CALL_FOR_HELP +---------------------------- +* Parameter 1: Radius - All friendly (not only same faction) creatures will go to help + +Call any friendly creatures (if its not in combat/etc) in radius attack creature target. +Mostly used when call to help more wide that normal aggro radius or auto-used call for assistance, and need apply at some event. + +40 ACTION_T_SET_SHEATH +------------------------- +* Parameter 1: Set Sheath State + +Value | Name | Description +----- | -------------------- | ---------------------------------------------- +0 | SHEATH_STATE_UNARMED | Set No Weapon Displayed (Not Usually Used By Creatures) +1 | SHEATH_STATE_MELEE | Set Melee Weapon Displayed +2 | SHEATH_STATE_RANGED | Set Ranged Weapon Displayed + +Set Sheath State For NPC. +Note: SHEATH_STATE_RANGED case work in combat state only if combat not start as melee commands. +This possible setup by set at event AI start (single used EVENT_T_TIMER_OOC or set ACTION_T_COMBAT_MOVEMENT 0 for creature that preferred ranged attack) + +41 ACTION_T_FORCE_DESPAWN +---------------------------- +Despawns The NPC with optional delay time (Works In or Out of Combat) + +* Parameter 1: `Delay` - Sets delay time until Despawn occurs after triggering the action. Time is in (ms). + +42 ACTION_T_SET_INVINCIBILITY_HP_LEVEL +----------------------------------------- +* Parameter 1: Minimum Health Level That NPC Can Reach (NPC Will Not Go Below This Value). +* Parameter 2: Sets Format of Parameter 1 Value. + 0 = Sets Parameter 1 as an exact HP value, + 1 = Sets Parameter 1 as a HP Percent (0..100) of the creature's max health + +NOTE: To cancel invincible You Need To Set Script For Either 0% HP or 0 HP So Then NPC Can Be Killed Again + +43 ACTION_T_MOUNT_TO_ENTRY_OR_MODEL +----------------------------------------- +* Parameter 1, Optional: Set mount model from creature_template.entry +* Parameter 2, Optional: Set mount model by explicit modelId + +If (Param1) AND (Param2) are both 0, unmount. + +44 = ACTION_T_CHANCED_TEXT +--------------------------- +* Parameter 1: Chance with which a text will be displayed (must be between 1 and 99) +* Parameter 2: The entry of the text that the NPC should use from eventai_texts table. Optionally a entry from other tables can be used (such as custom_texts). + Entry are required to be negative and exist in a *_texts-table. The type text to be displayed are defined in the texts-table itself (Say, Yell, Whisper, Emote Text, Boss Whisper, Boss Emote) + Other options are also to be defined in the texts-table, such as a sound to be heard with the text and the language used in output (common, dwarvish, etc). + In case this entry has a localized version of the text, the localized text will be displayed in client that support this locale. +* Parameter 3: Optional TextId can be defined in addition. The same apply to this as explained above, however eventAI will randomize between the two. + +Also remark that the chance also depends on the chance of the event. And remark that a chance of 100 is useless and in this case ACTION_T_TEXT should be used. + +Read at bottom for documentation of creature_ai_texts-table. + +45 = ACTION_T_THROW_AI_EVENT +----------------------------- +* Parameter 1: `EventType` - What AIEvent to throw, supported types see CreatureAI.h enum AIEventType +* Parameter 2: `Radius` - Throw the AIEvent to nearby friendly creatures within this range + +46 = ACTION_T_SET_THROW_MASK +----------------------------- +* Parameter 1: `EventTypeMask` - Which AIEvents to throw, supported types see CreatureAI.h enum AIEventType (mask-value is 2^type) + +This action sets which AIEvents a npc will throw automatically. + +Mask name | Value | Involed creatures | Source +-------------------------- | ----------------- | ------------------------------------------- | ----------------------------------- +AI_EVENT_JUST_DIED | MaskValue: 0x01 | Sender = Killed Npc, Invoker = Killer | Sent when npc dies +AI_EVENT_CRITICAL_HEALTH | MaskValue: 0x02 | Sender = Hurt Npc, Invoker = DamageDealer | Sent when damaged below 10% health +AI_EVENT_LOST_HEALTH | MaskValue: 0x04 | Sender = Hurt Npc, Invoker = DamageDealer | Sent when damaged below 50% health +AI_EVENT_LOST_SOME_HEALTH | MaskValue: 0x08 | Sender = Hurt Npc, Invoker = DamageDealer | Sent when damaged below 90% health +AI_EVENT_GOT_FULL_HEALTH | MaskValue: 0x10 | Sender = Healed Npc, Invoker = Healer | Sent when healed to full health + +So if you want an npc to throw AIEvents automatically on death and on critical health, you would set its EventTypeMask to 0x03 + +----------------------------- +47 = ACTION_T_SUMMON_UNIQUE +----------------------------- +* Parameter 1: CreatureID - The creature template ID to be summoned. The value here needs to be a valid creature template ID. +* Parameter 2: Target - The target type defining who the summoned creature will attack. The value in this field needs to be a valid target type as specified in the reference tables below. NOTE: Using target type 0 will cause the summoned creature to not attack anyone. +* Parameter 3: SummonID - The summon ID from the creature_ai_summons table controlling the position (and spawn time) where the summoned mob should be spawned at. + +Only summons a creature when not already spawned (Param1) to attack target (Param2) at location specified by EventAI_Summons (Param3). Preventing multiple spawns of unique creatures. + +----------------------------- +48 = ACTION_T_EMOTE_TARGET +----------------------------- +Parameter 1: The Emote ID that the creature should perform. (Emote IDs are also contained in the DBC but they can be found in the mangos source as well). +Parameter 2: Creature guid, to which emote dealer will performed. + +The creature will perform a visual emote. Unlike a text emote, a visual emote is one where the creature will actually move or perform a gesture. +This is commonly used for NPC's who may perform a special action (Salute, Roar, ect...). Not all player emotes work for creature models. + +Target types +------------ +Below is the list of current Target types that EventAI can handle. +Target types are used by certain actions and may effect actions differently + +# | Internal Name | Description +-- | -------------------------------------- | ----------- +0 | TARGET_T_SELF | Self Cast +1 | TARGET_T_HOSTILE | Current Target (ie: Highest Aggro) +2 | TARGET_T_HOSTILE_SECOND_AGGRO | Second Highest Aggro (Generally used for Cleaves and some special attacks) +3 | TARGET_T_HOSTILE_LAST_AGGRO | Dead Last on Aggro (no idea what this could be used for) +4 | TARGET_T_HOSTILE_RANDOM | Random Target on The Threat List +5 | TARGET_T_HOSTILE_RANDOM_NOT_TOP | Any Random Target Except Top Threat +6 | TARGET_T_ACTION_INVOKER | Unit Who Caused This Event to Occur (only works for EVENT_T_AGGRO, EVENT_T_KILL, EVENT_T_DEATH, EVENT_T_SPELLHIT, EVENT_T_OOC_LOS, EVENT_T_FRIENDLY_HP, EVENT_T_FRIENDLY_IS_CC, EVENT_T_FRIENDLY_MISSING_BUFF, EVENT_T_RECEIVE_EMOTE, EVENT_T_RECEIVE_AI_EVENT) +7 | TARGET_T_ACTION_INVOKER_OWNER | Unit who is responsible for Event to occur (only works for EVENT_T_AGGRO, EVENT_T_KILL, EVENT_T_DEATH, EVENT_T_SPELLHIT, EVENT_T_OOC_LOS, EVENT_T_FRIENDLY_HP, EVENT_T_FRIENDLY_IS_CC, EVENT_T_FRIENDLY_MISSING_BUFF, EVENT_T_RECEIVE_EMOTE, EVENT_T_RECEIVE_AI_EVENT) +8 | TARGET_T_HOSTILE_RANDOM_PLAYER | Random Player on The Threat List +9 | TARGET_T_HOSTILE_RANDOM_NOT_TOP_PLAYER | Any Random Player Except Top Threat +10 | TARGET_T_EVENT_SENDER | Creature who sent a received AIEvent - only triggered by EVENT_T_RECEIVE_AI_EVENT + +Cast flags +---------- +Below is the list of current Cast Flags that EventAI's spell casting can handle. +Cast flags are handled bitwise. Bit 0 is Interrupt Previous, bit 1 is triggered, etc. +So for example the number "3" (11 in Binary, selecting first 2 options) would mean that this cast has both CAST_INTURRUPT_PREVIOUS and CAST_TRIGGERED. +Another example: the number "5" (101 in Binary, selecting first and third options) would mean that this cast has CAST_INTURRUPT_PREVIOUS and CAST_FORCE_CAST. + +# | Decimal | Internal Name | Description +- | ------- | ----------------------- | ----------- +0 | 1 | CAST_INTURRUPT_PREVIOUS | Interrupts any previous spell casting (basically makes sure that this spell goes off) +1 | 2 | CAST_TRIGGERED | Forces the spell to be instant cast and require no mana/reagents. +2 | 4 | CAST_FORCE_CAST | Forces spell to cast even if the target is possibly out of range or the creature is possibly out of mana +3 | 8 | CAST_NO_MELEE_IF_OOM | Prevents creature from entering melee if out of mana or out of range +4 | 16 | CAST_FORCE_TARGET_SELF | Forces the target to cast this spell on itself +5 | 32 | CAST_AURA_NOT_PRESENT | Only casts the spell on the target if the target does not have the aura from that spell on itself already. + +NOTE: You can add the numbers in the decimal column to combine flags. + For example if you wanted to use CAST_NO_MELEE_IF_OOM(8) and CAST_TRIGGERED(2) you would simply use 10 in the cast flags field (8 + 2 = 10). + +Event flags +----------- +Below is the list of current Event Flags that EventAI can handle. Event flags are handled bitwise. + +# Decimal Internal Name Description +------------------------------------------------------------ +0 1 EFLAG_REPEATABLE Event repeats (Does not repeat if this flag is not set) +1 2 EFLAG_DIFFICULTY_0 Event occurs in instance difficulty 0 (will not occur if not set) +2 4 EFLAG_DIFFICULTY_1 Event occurs in instance difficulty 1 (will not occur if not set) +3 8 EFLAG_DIFFICULTY_2 Event occurs in instance difficulty 2 (will not occur if not set) +4 16 EFLAG_DIFFICULTY_3 Event occurs in instance difficulty 3 (will not occur if not set) +5 32 EFLAG_RANDOM_ACTION At event occur execute one random action from event actions instead all actions. +6 64 +7 128 EFLAG_DEBUG_ONLY Prevents events from occuring on Release builds. Useful for testing new features. + +NOTE: You can add the numbers in the decimal column to combine flags. + + * PLEASE NOTE THE DIFFERENCES BETWEEN DUNGEON INSTANCE DIFFICULTY LEVELS AND RAID Instance SIZE/DIFFICULTY LEVELS - PLEASE CHECK "MapDifficulty.dbc" For Information * + +Dungeons: +--------- +EFLAG_DIFFICULTY_0 Event occurs in DUNGEON_DIFFICULTY_NORMAL +EFLAG_DIFFICULTY_1 Event occurs in DUNGEON_DIFFICULTY_HEROIC +EFLAG_DIFFICULTY_2 None (Not Implimented) +EFLAG_DIFFICULTY_3 None (Not Implimented) + +10/25 Man Raids: +---------------- +EFLAG_DIFFICULTY_0 Event Occurs in RAID_DIFFICULTY_10MAN_NORMAL <--- Use This Difficulty Setting For Raids Designed For Single Man Size (Whatever Size It Is) +EFLAG_DIFFICULTY_1 Event Occurs in RAID_DIFFICULTY_25MAN_NORMAL +EFLAG_DIFFICULTY_2 Event Occurs in RAID_DIFFICULTY_10MAN_HEROIC (ONLY IF SUPPORTED BY RAID INSTANCE) <--- NOTE: Currently Only a Couple Raids Support This Mode +EFLAG_DIFFICULTY_3 Event Occurs in RAID_DIFFICULTY_25MAN_HEROIC (ONLY IF SUPPORTED BY RAID INSTANCE) <--- NOTE: Currently Only a Couple Raids Support This Mode + + +* Currently Only: Trial of the Crusader and Icecrown Citadel and Ruby Sanctum Raids Support Heroic Modes * + +========================================= +Basic Structure of creature_ai_texts +========================================= +Below is a the list of current fields within the texts tables. + +Field_Name Description +----------------------------------------------------------- +entry This value is mearly an NEGATIVE identifier of the current text number. Required for sql queries. Valid range are -1 to -999999 +content_default This is the actual text presented in the default language (English). + +content_loc1 This is the actual text presented in the Localization #1 Clients (Korean) +content_loc2 This is the actual text presented in the Localization #2 Clients (French) +content_loc3 This is the actual text presented in the Localization #3 Clients (German) +content_loc4 This is the actual text presented in the Localization #4 Clients (Chinese) +content_loc5 This is the actual text presented in the Localization #5 Clients (Taiwanese) +content_loc6 This is the actual text presented in the Localization #6 Clients (Spanish) +content_loc7 This is the actual text presented in the Localization #7 Clients (Spanish Mexico) +content_loc8 This is the actual text presented in the Localization #8 Clients (Russian) + +sound This value is the Sound ID that corresponds to the actual text used. +type Variables used to define type of text (Say/Yell/TextEmote/Whisper). +language This value is the Language that the text is native in. +emote Value from enum Emote. Only source of text will play this emote (not target, if target are defined in DoScriptText) +comment This is a comment regarding the text entry + +Note: Fields `content_loc1` to `content_loc8` are NULL values by default and are normally handled by seperate localization projects. + +========================================= +Text Types (type) +========================================= +Below is the list of current Text types that texts tables can handle. These were previously seperate Actions in ACID. + +# Internal Name Description +----------------------------------------------------------- +0 CHAT_TYPE_SAY This type sets the text to be displayed as a Say (Speech Bubble). +1 CHAT_TYPE_YELL This type sets the text to be displayed as a Yell (Red Speech Bubble) and usually has a matching Sound ID. +2 CHAT_TYPE_TEXT_EMOTE This type sets the text to be displayed as a text emote in orange in the chat log. +3 CHAT_TYPE_BOSS_EMOTE This type sets the text to be displayed as a text emote in orange in the chat log (Used only for specific Bosses). +4 CHAT_TYPE_WHISPER This type sets the text to be displayed as a whisper to the player in the chat log. +5 CHAT_TYPE_BOSS_WHISPER This type sets the text to be displayed as a whisper to the player in the chat log (Used only for specific Bosses). +6 CHAT_TYPE_ZONE_YELL Same as CHAT_TYPE_YELL but will display to all players in current zone. + +========================================= +Language Types (language) +========================================= +Below is the list of current Language types that are allowed. +This is the Race Language that the text is native to (So it will display properly) + +# Internal Name Description +----------------------------------------------------------- +0 UNIVERSAL Text in this language is understood by ALL Races. +1 ORCISH Text in this language is understood ONLY by Horde Races. +2 DARNASSIAN Text in this language is understood ONLY by the Night Elf Race. +3 TAURAHE Text in this language is understood ONLY by the Tauren Race. +6 DWARVISH Text in this language is understood ONLY by the Dwarf Race. +7 COMMON Text in this language is understood ONLY by Alliance Races. +8 DEMONIC Text in this language is understood ONLY by the Demon Race (Not Implimented). +9 TITAN This language was used by Sargeras to speak with other Titians (Not Implemented). +10 THALASSIAN Text in this language is understood ONLY by the Blood Elf Race. +11 DRACONIC Text in this language is understood ONLY by the Dragon Race. +12 KALIMAG Text will display as Kalimag (not readable by players, language of all elementals) +13 GNOMISH Text in this language is understood ONLY by the Gnome Race. +14 TROLL Text in this language is understood ONLY by the Troll Race. +33 GUTTERSPEAK Text in this language is understood ONLY by the Undead Race. +35 DRAENEI Text in this language is understood ONLY by the Draenai Race. +36 ZOMBIE (not currently used?) +37 GNOMISH BINARY Binary language used by Alliance when drinking Binary Brew +38 GOBLIN BINARY Binary language used by Horce when drinking Binary Brew diff --git a/doc/EventAI.txt b/doc/EventAI.txt deleted file mode 100644 index 0fcc3220c..000000000 --- a/doc/EventAI.txt +++ /dev/null @@ -1,1058 +0,0 @@ -=========================================================================== -MaNGOS EventAI (Creature_AI) Documentation: (Last Updated: August 22, 2012) -=========================================================================== - -EventAI allows users to create new creature scripts entirely within the database. - -For the AI to be used, you must first make sure to set AIname for each creature that should use this AI. -UPDATE creature_template SET AIName = 'EventAI' WHERE entry IN (...); - - -========================================= -Basic Structure of EventAI -========================================= - -EventAI follows a basic IF (Event) then DO (Action) format. -Below is the list of current fields of the creature_ai_scripts table. - -Field_Name Description -------------------------------------------- -id This value is merely an incrementing counter of the current Event number. Required for sql queries. (ACID Standards: CreatureID+Additional 2 digit Incriment Starting with 01) -creature_id Creature ID which should trigger this event (This is entry value from `creature_template` table). - -event_type The type of event you want to script. (see "Event Types" below for different values) -event_inverse_phase_mask Mask with phases this event should NOT trigger in* (See footnote for more details on using any other value then 0) -event_chance Percentage chance of triggering the event (1 - 100) -event_flags Event Flags (Used to select Repeatable or Dungeon/Raid Difficulty Level)... See "Event Flags" Below For Defined Values -event_param1 Variables for the event (depends on event_type) -event_param2 Variables for the event (depends on event_type) -event_param3 Variables for the event (depends on event_type) -event_param4 Variables for the event (depends on event_type) - -action1_type Action #1 to take when the Event occurs (see "Action types" below) -action1_param1 Variables used by Action1 (depends on action_type) -action1_param2 Variables used by Action1 (depends on action_type) -action1_param3 Variables used by Action1 (depends on action_type) - -action2_type Action #2 to take when the Event occurs (see "Action types" below) -action2_param1 Variables used by Action1 (depends on action_type) -action2_param2 Variables used by Action1 (depends on action_type) -action2_param3 Variables used by Action1 (depends on action_type) - -action3_type Action #3 to take when the Event occurs (see "Action types" below) -action3_param1 Variables used by Action1 (depends on action_type) -action3_param2 Variables used by Action1 (depends on action_type) -action3_param3 Variables used by Action1 (depends on action_type) - -All params are signed 32-bit values (+/- 2147483647). Time values are always in milliseconds. -In case of a percentage value, use value/100 (ie. param = 500 then that means 500%, -50 = -50%) - -[*] Phase mask is a bitmask of phases which shouldn't trigger this event. (ie. Phase mask of value 12 (binary 1100) results in triggering this event in phases 0, 1 and all others with exception for phases 2 and 3 (counting from 0). -[*] Phase 0 is default so this will occur in all phases unless specified. (1101 = Triggers in Phase 1 of 3, 1011 = Triggers in Phase 2 of 3, 0111 = Triggers in Phase 3 of 3, 0011 = Triggers in Both Phase 2 and 3). -[*] Take Desired Binary Configuration and convert into Decimal and this is your event_inverse_phase_mask to use in your script. - -========================================= -Event Types -========================================= - -This is the list of available Event Types EventAI is able to handle. -Each event type has its own specific interpretation of the params that accompany it. -Params are always read in the ascending order (from Param1 to Param3). - -NOTE: Events will not repeat until the creature exits combat or unless EFLAG_REPEATABLE value is set in Event Flags. -Some events such as EVENT_T_AGGRO, EVENT_T_DEATH, EVENT_T_SPAWNED, and EVENT_T_EVADE cannot repeat even if EFLAG_REPEATABLE value is set. - -# Internal Name Event Param Usage (Param1, Param2, Param3, Param4) Description ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -0 EVENT_T_TIMER_IN_COMBAT InitialMin, InitialMax, RepeatMin, RepeatMax Expires at first between (Param1) and (Param2) and then will repeat between every (Param3) and (Param4), EXPIRES ONLY IN COMBAT. -1 EVENT_T_TIMER_OOC InitialMin, InitialMax, RepeatMin, RepeatMax Expires at first between (Param1) and (Param2) and then will repeat between every (Param3) and (Param4), EXPIRES ONLY OUT OF COMBAT BUT NOT DURING EVADE. -2 EVENT_T_HP HPMax%, HPMin%, RepeatMin, RepeatMax Expires when the NPC's HP% is between (Param1) and (Param2). Will repeat between every (Param3) and (Param4) If Event Conditions Are Still Met. -3 EVENT_T_MANA ManaMax%, ManaMin%, RepeatMin, RepeatMax Expires when the NPC's Mana% is between (Param1) and (Param2). Will repeat between every (Param3) and (Param4) If Event Conditions Are Still Met. -4 EVENT_T_AGGRO NONE Expires ONLY upon the NPC's INITIAL Aggro at the Start of Combat (Does NOT Repeat) and Only Resets on Spawn or Evade. -5 EVENT_T_KILL RepeatMin, RepeatMax Expires upon Killing a Player. Will Repeat Check between (Param1) and (Param2). This Event Will Not Trigger Again Until Repeat Timer Expires -6 EVENT_T_DEATH NONE Expires on the NPC's Death. (This Triggers At The Moment The NPC Dies) -7 EVENT_T_EVADE NONE Expires at the moment the Creature EnterEvadeMode() and Exits Combat. -8 EVENT_T_SPELLHIT SpellID, Schoolmask, RepeatMin, RepeatMax Expires upon Spell Hit of the NPC. When (param1) is set, it is the specific Spell ID used as the trigger. With (param2) specified, the expiration is limited to specific spell schools (-1 for all) and Spell ID value is ignored. Will repeat Event Conditions Check between every (Param3) and (Param4). Only A Spell ID or Spell School may be Specified but NOT both. -9 EVENT_T_RANGE MinDist, MaxDist, RepeatMin, RepeatMax Expires when the Highest Threat Target Distance is Greater than (Param1) and Less than (Param2). Will repeat between every (Param3) and (Param4) if Event Conditions Are Still Met. -10 EVENT_T_OOC_LOS Hostile-or-Not, MaxAllowedRange, RepeatMin, RepeatMax Expires when a unit moves within distance (MaxAllowedRange) of the NPC. If (Param1) is 0 it will expire only when unit is hostile, If (Param1) is 1 it will expire only when unit is friendly. This depends generally on faction relations. Will repeat every (Param3) and (Param4). Does NOT expire when the NPC is in combat. -11 EVENT_T_SPAWNED NONE Expires on initial spawn and respawn of the NPC (Useful for setting Ranged Movement/Summoning Pets/Applying Buffs). -12 EVENT_T_TARGET_HP HPMax%, HPMin%, RepeatMin, RepeatMax Expires when current target's HP% is between (Param1) and (Param2). Will repeat every (Param3) and (Param4)If Event Conditions Are Still Met. -13 EVENT_T_TARGET_CASTING RepeatMin, RepeatatMax Expires when the current target is casting a spell. Will repeat every (Param1) and (Param2) If Event Conditions Are Still Met. -14 EVENT_T_FRIENDLY_HP HPDeficit, Radius, RepeatMin, RepeatMax Expires when a friendly unit in (Radius) has at least (Param1) HP points missing. Will repeat every (Param3) and (Param4) If Event Conditions Are Still Met. -15 EVENT_T_FRIENDLY_IS_CC DispelType, Radius, RepeatMin, RepeatMax Expires when a friendly unit is crowd controlled within the given Radius (Param2). Will repeat every (Param3) and (Param4). -16 EVENT_T_FRIENDLY_MISSING_BUFF SpellId, Radius, RepeatMin, RepeatMax Expires when a friendly unit is missing aura(s) given by a spell (Param1) within Radius (Param2). Will repeat every (Param3) and (Param4) If Event Conditions Are Still Met. -17 EVENT_T_SUMMONED_UNIT CreatureId, RepeatMin, RepeatMax Expires after creature with entry = (Param1) is spawned (Param1 = 0 means all spawns). Will repeat every (Param2) and (Param3). -18 EVENT_T_TARGET_MANA ManaMax%, ManaMin%, RepeatMin, RepeatMax Expires when current target's Mana% is between (Param1) and (Param2). Will repeat every (Param3) and (Param4) If Event Conditions Are Still Met. -21 EVENT_T_REACHED_HOME NONE Expires when a creature reaches it's home (spawn) location after evade. This is commonly used for NPC's who Stealth once reaching their Spawn Location -22 EVENT_T_RECEIVE_EMOTE EmoteId, Condition, CondValue1, CondValue2 Expires when a creature receives an emote with emote text id ("enum TextEmotes" from SharedDefines.h in Mangos Source) in (Param1). Conditions can be defined (Param2) with optional values (Param3,Param4), see (enum ConditionType) in ObjectMgr.h (Mangos Source). -23 EVENT_T_AURA SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when a creature has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4) If Event Conditions Are Still Met. -24 EVENT_T_TARGET_BUFFED SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when a target unit has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4) If Event Conditions Are Still Met. -25 EVENT_T_SUMMONED_JUST_DIED CreatureId, RepeatMin, RepeatMax Expires after creature with entry = (Param1) is die (Param1 = 0 means all spawns). Will repeat every (Param2) and (Param3). -26 EVENT_T_SUMMONED_JUST_DESPAWN CreatureId, RepeatMin, RepeatMax Expires before creature with entry = (Param1) is despawn (Param1 = 0 means all spawns). Will repeat every (Param2) and (Param3). -27 EVENT_T_MISSING_AURA SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when a creature not has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4). -28 EVENT_T_TARGET_MISSING_AURA SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when a target unit not has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4). -29 EVENT_T_TIMER_GENERIC InitialMin, InitialMax, RepeatMin, RepeatMax Expires at first between (Param1) and (Param2) and then will repeat between every (Param3) and (Param4). -30 EVENT_T_RECEIVE_AI_EVENT AIEventType, Sender-Entry, unused, unused Expires when the creature receives an AIEvent of type (Param1), sent by creature (Param2 != 0). If (Param2 = 0) then sent by any creature - -========================================= -Action Types -========================================= - -This is a list of action types that EventAI is able to handle. -Each event type has it's own specific interpretation of it's params, just like Events. -For all ACTION_T_RANDOM Actions, When a Particular Param is selected for the Event... The SAME Param # is selected for all 3 actions when Event is triggered. - -# Internal name Param usage Description -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -0 ACTION_T_NONE No Action Does nothing. -1 ACTION_T_TEXT -TextId1, -TextId2, -TextId3 Displays the specified -TextId. When -TextId2 and -TextId3 are specified, the selection will be Randomized between 1,2 or 3. Text ID's are defined, along with other options for the text, in creature_ai_texts table. Below is detailed Text Information. All text ID values for EventAI MUST be negative. -2 ACTION_T_SET_FACTION FactionId, Flags Changes faction for a creature. When param1 is zero, creature will revert to it's default faction. Flags will determine when faction is restored to default (evade, respawn etc) -3 ACTION_T_MORPH_TO_ENTRY_OR_MODEL CreatureEntry, ModelId Sets either model from creature_template.entry (Param1) OR explicit modelId (Param2) for the NPC. If (Param1) AND (Param2) are both 0, NPC will demorph and revert to the default model (as specified in creature_template). -4 ACTION_T_SOUND SoundId NPC Plays a specified Sound ID. -5 ACTION_T_EMOTE EmoteId NPC Does a specified Emote ID. -6 UNUSED UNUSED UNUSED -7 UNUSED UNUSED UNUSED -8 UNUSED UNUSED UNUSED -9 ACTION_T_RANDOM_SOUND SoundId1, SoundId2, SoundId3 NPC Plays a Random Sound ID (Random Selects Param1, Param2 or Param3) * -10 ACTION_T_RANDOM_EMOTE EmoteId1, EmoteId2, EmoteId3 NPC Emotes a Random Emote ID (Random Selects Param1, Param2 or Param3) * -11 ACTION_T_CAST SpellId, Target, CastFlags Casts spell (Param1) on a target (Param2) using cast flags (Param3) --> Specified Below -12 ACTION_T_SUMMON CreatureID, Target, Duration Summons a Creature ID (Param1) for (Param3) duration after Evade (In MS) and orders it to attack (Param2) target (specified below). Spawns on top of NPC who summons it. -13 ACTION_T_THREAT_SINGLE_PCT Threat%, Target Modifies a threat by (Param1) percent on a target (Param2). -14 ACTION_T_THREAT_ALL_PCT Threat% Modifies a threat by (Param1) on all targets in the threat list (using -100% here will result in full aggro dump). -15 ACTION_T_QUEST_EVENT QuestID, Target Calls AreaExploredOrEventHappens with (Param1) for a target in (Param2). -16 ACTION_T_QUEST_CASTCREATUREGO CreatureID, SpellId, Target Sends CastCreatureOrGo for a creature specified by CreatureId (Param1) with provided spell id (Param2) for a target in (Param3). -17 ACTION_T_SET_UNIT_FIELD Field_Number, Value, Target Sets a unit field (Param1) to provided value (Param2) on a target in (Param3). -18 ACTION_T_SET_UNIT_FLAG Flags, Target Sets flag (flags can be used together to modify multiple flags at once) on a target (Param2). -19 ACTION_T_REMOVE_UNIT_FLAG Flags, Target Removes flag on a target (Param2). -20 ACTION_T_AUTO_ATTACK AllowAutoAttack Stop melee attack when (Param1) is zero, otherwise continue attacking / allow melee attack. -21 ACTION_T_COMBAT_MOVEMENT AllowCombatMovement Stop combat based movement when (Param1) is zero, otherwise continue/allow combat based movement (targeted movement generator). -22 ACTION_T_SET_PHASE Phase Sets the current phase to (Param1). -23 ACTION_T_INC_PHASE Value Increments the phase by (Param1). May be negative to decrement, but should not be zero. -24 ACTION_T_EVADE No Params Forces the creature to evade, wiping all threat and dropping combat. -25 ACTION_T_FLEE_FOR_ASSIST No Params Causes the creature to flee for assistence (often at low health). -26 ACTION_T_QUEST_EVENT_ALL QuestId Calls GroupEventHappens with (Param1). Only used if it's _expected_ event should call quest completion for all players in a current party. -27 ACTION_T_CASTCREATUREGO_ALL QuestId, SpellId Calls CastedCreatureOrGo for all players on the threat list with quest id specified in (Param1) and spell id in (Param2). -28 ACTION_T_REMOVEAURASFROMSPELL Target, Spellid Removes all auras on a target (Param1) caused by a spell (Param2). -29 ACTION_T_RANGED_MOVEMENT Distance, Angle Changes the movement generator to a ranged type. (note: default melee type can still be set by using 0 as angle and 0 as distance). -30 ACTION_T_RANDOM_PHASE PhaseId1, PhaseId2, PhaseId3 Sets a phase to a specified id(s)* -31 ACTION_T_RANDOM_PHASE_RANGE PhaseMin, PhaseMax Sets a phase to a random id (Phase = PhaseMin + rnd % PhaseMin-PhaseMax). PhaseMax must be greater than PhaseMin. -32 ACTION_T_SUMMON_ID CreatureID, Target, SummonID Summons a creature (Param1) to attack target (Param2) at location specified by EventAI_Summons (Param3). -33 ACTION_T_KILLED_MONSTER CreatureID, Target Calls KilledMonster (Param1) for a target (Param2). -34 ACTION_T_SET_INST_DATA Field, Data Calls ScriptedInstance::SetData with field (Param1) and data (Param2). -35 ACTION_T_SET_INST_DATA64 Field, Target Calls ScriptedInstance::SetData64 with field (Param1) and target's GUID (Param2). -36 ACTION_T_UPDATE_TEMPLATE TemplateId, Team Changes a creature's template to (Param1) with team = Alliance or Horde when (Param2) is either false or true respectively. -37 ACTION_T_DIE No Params Kills the creature -38 ACTION_T_ZONE_COMBAT_PULSE No Params Puts all players within an instance into combat with the creature. Only works when a creature is already in combat. Doesn't work outside instances. -39 ACTION_T_CALL_FOR_HELP Radius Call any friendly out-of-combat creatures in a radius (Param1) to attack current creature's target. -40 ACTION_T_SET_SHEATH Sheath Sets sheath state for a creature (0 = no weapon, 1 = melee weapon, 2 = ranged weapon). -41 ACTION_T_FORCE_DESPAWN Delay Despawns the creature, if delay = 0 immediate otherwise will despawn after delay time set in Param1 (in ms). -42 ACTION_T_SET_INVINCIBILITY_HP_LEVEL HP_Level, HP_Percent Set min. health level for creature that can be set at damage as flat value or percent from max health -43 ACTION_T_MOUNT_TO_ENTRY_OR_MODEL CreatureEntry, ModelId Set mount model from creature_template.entry (Param1) OR explicit modelId (Param2). If (Param1) AND (Param2) are both 0, unmount. -44 ACTION_T_CHANCED_TEXT Chance, -TextId1, -TextId2 Displays by Chance (1..100) the specified -TextId. When -TextId2 is specified, the selection will be randomized. Text types are defined, along with other options for the text, in a table below. Param2 and Param3 needs to be negative. -45 ACTION_T_THROW_AI_EVENT EventType, Radius Throws an AIEvent of type (Param1) to nearby friendly Npcs in range of (Param2) -46 ACTION_T_SET_THROW_MASK EventTypeMask Marks for which AIEvents the npc will throw AIEvents on its own. -47 ACTION_T_SUMMON_UNIQUE CreatureID, Target, SummonID Only summons a creature when not already spawned (Param1) to attack target (Param2) at location specified by EventAI_Summons (Param3). Preventing multiple spawns of unique creatures. -48 ACTION_T_EMOTE_TARGET EmoteId, TargetGuid NPC faces to creature (Param2) and does a specified emote id (Param1). - -* = Use -1 where the param is expected to do nothing. Random constant is generated for each event, so if you have a random yell and a random sound, they will be linked up with each other (ie. param2 with param2). - - -============================================== -Event Types: Expanded and Detailed Information -============================================== -Note: -COMBAT ONLY - Means that this event will only trigger durring combat. -OUT OF COMBAT ONLY - Means that this event will only trigger while out of combat. -BOTH - This event can trigger both in and out of combat. - -Events that do not have lables on them are events that are directly involved with the in and out of combat state. - ------------------- -0 = EVENT_T_TIMER_IN_COMBAT: ------------------- -Parameter 1: InitialMin - Minumum Time used to calculate Random Initial Expire -Parameter 2: InitialMax - Maximum Time used to calculate Random Initial Expire -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire - -COMBAT ONLY - Expires first between (Param1) and (Param2) and then between every (Param3) and (Param4) from then on. -This is commonly used for spells that repeat cast during combat (Simulates Spell Cooldown). - ----------------------- -1 = EVENT_T_TIMER_OOC: ----------------------- -Parameter 1: InitialMin - Minimum Time used to calculate Random Initial Event Expire -Parameter 2: InitialMax - Maximum Time used to calculate Random Initial Event Expire -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Event Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Event Expire - -OUT OF COMBAT ONLY (Not while evading) - Expires first between (Param1) and (Param2) and then between every (Param3) and (Param4) from then on. -This is commonly used for events that occur and repeat outside of combat like random NPC Say or Random Emotes. - ---------------- -2 = EVENT_T_HP: ---------------- -Parameter 1: HPMax% - Maximum HP% That will trigger this Event to Expire -Parameter 2: HPMin% - Minimum HP% That will trigger this Event to Expire -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Event Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Event Expire - -BOTH - Expires when HP is between (Param1) and (Param2). Will repeat every (Param3) and (Param4). -This is commonly used for events that occur at a specific HP% Range (Such as Heal/Enrage Spells or NPC's that Flee). -NOTE: For Repeat Events the Repeat Timer ONLY Re-Check's Event Conditions to see If HP% Is Between Max and Min. If it is then Event will Expire again. - ------------------ -3 = EVENT_T_MANA: ------------------ -Parameter 1: ManaMax% - Maximum Mana% That will trigger this Event to Expire -Parameter 2: ManaMin% - Minimum Mana% That will trigger this Event to Expire -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Event Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Event Expire - -BOTH - Expires once Mana% is between (Param1) and (Param2). Will repeat every (Param3) and (Param4). -This is commonly used for events where an NPC low on Mana will do something (Such as stop casting spells and switch to melee). - ------------------- -4 = EVENT_T_AGGRO: ------------------- -COMBAT ONLY - This Event Expires upon Initial Aggro (This Event does not occur again until NPC either Evades/Respawns and then Enters Combat Again). - ------------------ -5 = EVENT_T_KILL: ------------------ -Parameter 1: RepeatMin - Minimum Time used to calculate Random Repeat Event Expire -Parameter 2: RepeatMax - Maximum Time used to calculate Random Repeat Event Expire - -COMBAT ONLY - Expires upon killing a player. Will repeat every (Param1) and (Param2). -This Event Expires upon killing a player. It is commonly used for NPC's who yell or do something after killing a player. Normally use a short repeating timer is advisable. -NOTE: For Repeat Events the Repeat Timer ONLY Re-Check's Event Conditions to see If another Player Kill has occured. So After Repeat Min/Max Player Kill Event can occur again. - ------------------- -6 = EVENT_T_DEATH: ------------------- -BOTH - This Event Expires upon Death of the Scripted NPC. This is normally only used in combat though. -This is commonly used for NPC's who have a Yell or Spell Cast when they Die. - ------------------- -7 = EVENT_T_EVADE: ------------------- -COMBAT ONLY - This Event Expires when the Scripted NPC Evades Combat (EnterEvadeMode). -This is commonly used for NPC's who use phases, allows you to reset their phase to 0 on evade to prevent possible strange behavior on Re-Aggro. - ---------------------- -8 = EVENT_T_SPELLHIT: ---------------------- -Parameter 1: SpellID - The Spell ID that will trigger the Event to occur (NOTE: If you use Spell School as the trigger ALWAYS set this value to 0) -Parameter 2: School - Spell School to trigger the Event (NOTE: If you use a SpellID then ALWAYS set this value to -1) - *See Below for Spell School Bitmask Values* -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Event Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Event Expire - -BOTH - Expires on Spellhit. If (param1) is set it will only expire on that SPECIFIC Spell OR If (param2) is set it will only expire on Spells of that School. Will repeat every (Param3) and (Param4). -This Event is commonly used for NPC's who can do special things when you cast a spell (Or specific spell) on them. -NOTE: For Repeat Events the Repeat Timer ONLY Re-Check's Event Conditions to see If another Spellhit has occured. So After Repeat Min/Max expires Spellhit Event can occur again. - -(Name ==> School ==> School Bitmask Values) -------------------------------------------- -SPELL_SCHOOL_NORMAL = 0 ==> 1 -SPELL_SCHOOL_HOLY = 1 ==> 2 -SPELL_SCHOOL_FIRE = 2 ==> 4 -SPELL_SCHOOL_NATURE = 3 ==> 8 -SPELL_SCHOOL_FROST = 4 ==> 16 -SPELL_SCHOOL_SHADOW = 5 ==> 32 -SPELL_SCHOOL_ARCANE = 6 ==> 64 -Use These Bitmask Values For Schoolmask (Param2) or Any Combinations Of These School Bitmasks for Multiple Schools. - ------------------- -9 = EVENT_T_RANGE: ------------------- -Parameter 1: MinDist - This Distance is the Minimum Distance between the NPC and it's target to allow this Event to Expire -Parameter 2: MaxDist - This Distance is the Maximum Distance between the NPC and it's target to allow this Event to Expire -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire - -COMBAT ONLY - Expires when the highest threat target distance is greater than (Param1) and less than (Param2). Will repeat every (Param3) and (Param4). -This Event is commonly used for NPC's who have Ranged Combat and will Throw/Shoot between a certian distance. - ---------------------- -10 = EVENT_T_OOC_LOS: ---------------------- -Parameter 1: Hostile-or-Not - This will expire if Unit are hostile. If Param1=1 it will only expire if Unit are not Hostile(generally determined by faction) -Parameter 2: MaxAllowedRange - Expires when a Unit moves within this distance to creature -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire - -OUT OF COMBAT ONLY -This Event is commonly used for NPC's who do something or say something to you when you walk past them Out of Combat. - ---------------------- -11 = EVENT_T_SPAWNED: ---------------------- -Expires at initial spawn and at creature respawn. -This Event is commonly used for setting ranged movement type or Summoning a Pet on Spawn -Parameter 1: 0: works always, 1: works on map in Parameter 2, 2: works on zone/subzone in Parameter 2 -Parameter 2: depends on Parameter 1: for 1 it is map ID, for 2 it is area ID to check - -BOTH - Expires in or out of combat when the NPC Spawns -This Event is commonly used for NPC's who cast a spell or do something special when they spawn. This event is not repeatable so it is a one time event on Spawn. - ------------------------ -12 = EVENT_T_TARGET_HP: ------------------------ -Parameter 1: HPMax% - Maximum HP% That this Event will Expire -Parameter 2: HPMin% - Minimum HP% That this Event will Expire -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire - -COMBAT ONLY - Expires when Current NPC's Target's HP is between (Param1) and (Param2). Will repeat every (Param3) and (Param4). -This Event is commonly used for NPC's who have a special ability (Like Execute) that only casts when a Player HP is low. - ----------------------------- -13 = EVENT_T_TARGET_CASTING: ----------------------------- -Parameter 1: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 2: RepeatMax - Maximum Time used to calculate Random Repeat Expire - -COMBAT ONLY - Expires when the current target is casting a spell. Will repeat every (Param1) and (Param2). -This event is commonly used for NPC's who will cast a counter spell when their target starts to cast a spell. - -------------------------- -14 = EVENT_T_FRIENDLY_HP: -------------------------- -Parameter 1: HPDeficit - This is the Amount of HP Missing from Full HP to trigger this event (You would need to calculate the amount of HP the event happens and subtract that from Full HP Value to get this number) -Parameter 2: Radius - This is the Range in Yards the NPC will scan for nearby Friendlies (Faction is Friendly To) for the missing amount of HP in Param1. -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire - -COMBAT ONLY - Expires when a friendly unit in radius(param2) has at least (param1) hp missing. Will repeat every (Param3) and (Param4). -This is commonly used when an NPC in Combat will heal a nearby Friendly NPC in Combat with a Heal/Renew Spell. - ----------------------------- -15 = EVENT_T_FRIENDLY_IS_CC: ----------------------------- -Parameter 1: DispelType - Dispel Type to trigger the event - *See Below for Dispel Bitmask Values* -Parameter 2: Radius - This is the Range in Yards the NPC will scan for nearby Friendlies being Crowd Controlled -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire - -COMBAT ONLY - Expires when a friendly unit is Crowd controlled within the given radius (param2). Will repeat every (Param3) and (Param4). -This is commonly used for NPC's who can come to the resule of other Friendly NPC's if being Crowd Controlled - ------------------------------------ -16 = EVENT_T_FRIENDLY_MISSING_BUFF: ------------------------------------ -Parameter 1: SpellId - This is the SpellID That the Aura Check will look for (If it is missing this Aura) -Parameter 2: Radius - This is the Range in Yards the NPC will scan for nearby Friendlies (Faction is Friendly To) for the missing Aura. -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire - -BOTH - Expires when a friendly unit is missing aura's given by spell (param1) within radius (param2). Will repeat every (Param3) and (Param4). -This is commonly used for NPC's who watch friendly units for a debuff to end so they can recast it on them again. - ---------------------------- -17 = EVENT_T_SUMMONED_UNIT: ---------------------------- -Parameter 1: CreatureId - The CreatureID that the NPC is watching to spawn to trigger this event -Parameter 2: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 3: RepeatMax - Maximum Time used to calculate Random Repeat Expire - -BOTH - Expires after creature with entry(Param1) is spawned or for all spawns if param1 = 0. Will repeat every (Param2) and (Param3) . -This is commonly used for NPC's who will do something special once another NPC is summoned. Usually used is Complex Scripts or Special Events. - ---------------------------- -21 = EVENT_T_REACHED_HOME: ---------------------------- -Expires only when creature has returned to it's home location after Evade. Out of combat event. -Most commonly used to cast spells that can not be casted in EVENT_T_EVADE and other effects that does not fit in while still running back to spawn/home location. - ---------------------------- -22 = EVENT_T_RECEIVE_EMOTE: ---------------------------- -Parameter 1: EmoteId - Valid text emote ID from Mangos source (SharedDefines.h - enum TextEmotes) -Parameter 2: Condition - Conditions based on /src/game/ObjectMgr.h - enum ConditionType -Parameter 3: CondValue1 - -Parameter 4: CondValue2 - - -Expires only when creature receive emote from player. Valid text emote id's are in Mangos source (SharedDefines.h - enum TextEmotes) -Event does not require any conditions to process, however many are expected to have condition. - ---------------------------- -23 = EVENT_T_AURA: ---------------------------- -Parameter 1: SpellId - This is the SpellID That the Aura Check will look for -Parameter 2: Amount - This is the amount of SpellID's auras at creature required for event expire. -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire - ---------------------------- -24 = EVENT_T_TARGET_BUFFED: ---------------------------- -Parameter 1: SpellId - This is the SpellID That the Aura Check will look for -Parameter 2: Amount - This is the amount of SpellID's auras at target unit required for event expire. -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire - -EventAI use conditions from available in Mangos (enum ConditionType) -Current implemented conditions: -CONDITION_NONE (0) 0 0 -CONDITION_AURA (1) spell_id effindex -CONDITION_ITEM (2) item_id count -CONDITION_ITEM_EQUIPPED (3) item_id count -CONDITION_ZONEID (4) zone_id 0 -CONDITION_REPUTATION_RANK (5) faction_id min_rank -CONDITION_TEAM (6) player_team 0 (469-Alliance / 67-Horde) -CONDITION_SKILL (7) skill_id min_skill_value -CONDITION_QUESTREWARDED (8) quest_id 0, if quest are rewarded -CONDITION_QUESTTAKEN (9) quest_id 0, while quest active(incomplete) -CONDITION_ACTIVE_EVENT (12) event_id 0, note this is id from dbc, also defined in Mangos source(enum HolidayIds) NOT id of game_event in database - --------------------------------- -25 = EVENT_T_SUMMONED_JUST_DIED: --------------------------------- -Parameter 1: CreatureId - The CreatureID that the NPC is watching die to trigger this event -Parameter 2: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 3: RepeatMax - Maximum Time used to calculate Random Repeat Expire - -BOTH - Expires after creature with entry(Param1) is die or for all spawns if param1 = 0. Will repeat every (Param2) and (Param3) . -This is commonly used for NPC's who will do something special once another NPC is die. Usually used is Complex Scripts or Special Events. - ------------------------------------ -26 = EVENT_T_SUMMONED_JUST_DESPAWN: ------------------------------------ -Parameter 1: CreatureId - The CreatureID that the NPC is watching despawn to trigger this event -Parameter 2: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 3: RepeatMax - Maximum Time used to calculate Random Repeat Expire - -BOTH - Expires before creature with entry(Param1) is despawned or for all spawns if param1 = 0. Will repeat every (Param2) and (Param3) . -This is commonly used for NPC's who will do something special once another NPC is despawn. Usually used is Complex Scripts or Special Events. -NOTE: called before despawn happens, so summoned creature still in world at expire moment. - --------------------------- -27 = EVENT_T_MISSING_BUFF: --------------------------- -Parameter 1: SpellId - This is the SpellID That the Aura Check will look for to be missing -Parameter 2: Amount - This is the amount or less of SpellID's auras at creature required for event expire. -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire - ---------------------------------- -28 = EVENT_T_TARGET_MISSING_AURA: ---------------------------------- -Parameter 1: SpellId - This is the SpellID That the Aura Check will look for to be missing -Parameter 2: Amount - This is the amount or less of SpellID's auras at creature required for event expire. -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire - ---------------------------- -29 = EVENT_T_TIMER_GENERIC: ---------------------------- -Parameter 1: InitialMin - Minumum Time used to calculate Random Initial Expire -Parameter 2: InitialMax - Maximum Time used to calculate Random Initial Expire -Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire -Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire - -IN COMBAT and OUT OF COMBAT - Expires first between (Param1) and (Param2) and then between every (Param3) and (Param4) from then on. - ------------------------------- -30 = EVENT_T_RECEIVE_AI_EVENT: ------------------------------- -Parameter 1: AIEventType - Only expire when an AIEvent of this type is received. Supported types see CreatureAI.h enum AIEventType -Parameter 2: Sender-Entry - If != 0 then only expire when the AIEvent is received from a creature of this entry - -Note: This is the only EVENT where the target-type TARGET_T_EVENT_SENDER (10) is defined - -========================================= -Action Types -========================================= - ------------------- -1 = ACTION_T_TEXT: ------------------- -Parameter 1: The entry of the text that the NPC should use from eventai_texts table. Optionally a entry from other tables can be used (such as custom_texts). - Entry are required to be negative and exist in a *_texts-table. The type text to be displayed are defined in the texts-table itself (Say, Yell, Whisper, Emote Text, Boss Whisper, Boss Emote) - Other options are also to be defined in the texts-table, such as a sound to be heard with the text and the language used in output (common, dwarvish, etc). - In case this entry has a localized version of the text, the localized text will be displayed in client that support this locale. - -Parameter 2: Optional. TextId can be defined in addition. The same apply to this as explained above, however eventAI will randomize between the two. -Parameter 3: Optional, if Parameter 2 exist. In this case, eventAI will randomize between three. - -Read at bottom for documentation of creature_ai_texts-table. - -------------------------- -2 = ACTION_T_SET_FACTION: -------------------------- -Parameter 1: FactionId from Faction.dbc OR 0. Changes faction for creature. If 0, creature will revert to it's default faction if previously changed. -Parameter 2: When Parameter 1 is not 0, flags can be used to restore default faction at certain events. Current supported, from enum TemporaryFactionFlags: - TEMPFACTION_NONE = 0x00, // A persistent faction change and will require manual change to default/another faction when changed once - TEMPFACTION_RESTORE_RESPAWN = 0x01, // Default faction will be restored at respawn - TEMPFACTION_RESTORE_COMBAT_STOP = 0x02, // ... at CombatStop() (happens at creature death, at evade or custom scripte among others) - TEMPFACTION_RESTORE_REACH_HOME = 0x04, // ... at reaching home in home movement (evade), if not already done at CombatStop() - -------------------------------------- -3 = ACTION_T_MORPH_TO_ENTRY_OR_MODEL: -------------------------------------- -Parameter 1: Creature entry from creature_template. Action will then change to the model this creature are using. -Parameter 2: If parameter 1 is 0, then this modelId will be used (in case parameter 1 exist, parameter 2 will not be used) - -If both parameter 1 and 2 is 0, the creature will DeMorph, and use it's default model. - -------------------- -4 = ACTION_T_SOUND: -------------------- -Parameter 1: The Sound ID to be played. (Sound IDs are contained in the DBC files.) - -The creature will play the specified sound. -This is commonly used for Bosses who Yell and then also have a Voice for the same thing. - -------------------- -5 = ACTION_T_EMOTE: -------------------- -Parameter 1: The Emote ID that the creature should perform. (Emote IDs are also contained in the DBC but they can be found in the mangos source as well). - -The creature will perform a visual emote. Unlike a text emote, a visual emote is one where the creature will actually move or perform a gesture. -This is commonly used for NPC's who may perform a special action (Salute, Roar, ect...). Not all player emotes work for creature models. - ------------------------- -6 = ACTION_T_RANDOM_SAY: ------------------------- -UNUSED Can be reused to create new action type - -------------------------- -7 = ACTION_T_RANDOM_YELL: -------------------------- -UNUSED Can be reused to create new action type - ------------------------------- -8 = ACTION_T_RANDOM_TEXTEMOTE: ------------------------------- -UNUSED Can be reused to create new action type - --------------------------- -9 = ACTION_T_RANDOM_SOUND: --------------------------- -Parameter 1: The Sound ID to be played as Random Choice #1. -Parameter 2: The Sound ID to be played as Random Choice #2. -Parameter 3: The Sound ID to be played as Random Choice #3. - -Similar to the ACTION_T_SOUND action, it will choose at random a sound to play. - ---------------------------- -10 = ACTION_T_RANDOM_EMOTE: ---------------------------- -Parameter 1: The Emote ID to be played as Random Choice #1. -Parameter 2: The Emote ID to be played as Random Choice #2. -Parameter 3: The Emote ID to be played as Random Choice #3. - -Similar to the ACTION_T_EMOTE action, it will choose at random an Emote to Visually Perform. - -------------------- -11 = ACTION_T_CAST: -------------------- -Parameter 1: SpellId - The Spell ID to use for the NPC to cast. The value used in this field needs to be a valid Spell ID. -Parameter 2: Target - The Target Type defining who the creature should cast the spell at. The value in this field needs to be a valid Target Type as specified in the reference tables below. -Parameter 3: CastFlags - See Table Below for Cast Flag Bitmask Values. If you are unsure what to set this value at leave it at 0. - -The creature will cast a spell specified by a spell ID on a target specified by the target type. -If the spell is normal cast, random target types will select only targets within LOS and in spell range -This is commonly used for NPC's who cast spells. - ---------------------- -12 = ACTION_T_SUMMON: ---------------------- -Parameter 1: CreatureID - The Creature Template ID to be Summoned. The value here needs to be a valid Creature Template ID. -Parameter 2: Target - The Target Type defining who the Summoned creature will attack once spawned. The value in this field needs to be a valid Target Type as specified in the reference tables below. -Parameter 3: Duration - The duration until the summoned creature should be unsummoned AFTER Combat ends. The value in this field is in milliseconds or 0. - -The NPC will Summon another cast flag 0 will work for you treature at the same spot as itself that will attack the specified target. -NOTE: Almost all Creature Summons have proper Summon Spells that should be used when possible. This Action is a powerful last resort option only to be used if nothing else works. -NOTE: Using Target Type 0 will cause the Summoned creature to not attack anyone. -NOTE: If Duration is set at 0, then the summoned creature will not despawn until it has died. -This is used as a manual way to force an NPC to Summon. - -NOTE: THIS ONLY WORKS IN COMBAT - --------------------------------- -13 = ACTION_T_THREAT_SINGLE_PCT: --------------------------------- -Parameter 1: Threat% - Threat percent that should be modified. The value in this field can range from -100 to +100. If it is negative, threat will be taken away and if positive, threat will be added. -Parameter 2: Target - The Target Type defining on whom the threat change should occur. The value in this field needs to be a valid target type as specified in the reference tables below. - -This action will modify the threat of a target in the creature's threat list by the specified percent. -This is commonly used to allow an NPC to adjust the Threat to a single player. - ------------------------------ -14 = ACTION_T_THREAT_ALL_PCT: ------------------------------ -Parameter 1: Threat% - The percent that should be used in modifying everyone's threat in the creature's threat list. The value here can range from -100 to +100. - -This action will modify the threat for everyone in the creature's threat list by the specified percent. -NOTE: Using -100 will cause the creature to reset everyone's threat to 0 so that everyone has the same amount of threat. It will NOT remove anyone from the threat list. -This is commonly used to allow an NPC to drop threat for all players to zero. - --------------------------- -15 = ACTION_T_QUEST_EVENT: --------------------------- -Parameter 1: QuestID - The Quest Template ID. The value here must be a valid quest template ID. Furthermore, the quest should have SpecialFlags | 2 as it would need to be completed by an external event which is the activation of this action. -Parameter 2: Target - The Target Type defining whom the quest should be completed for. The value in this field needs to be a valid target type as specified in the reference tables below. - -This action will satisfy the external completion requirement for the quest for the specified target defined by the target type. -NOTE: This action can only be used with player targets so it must be ensured that the target type will point to a player. -This is commonly used for Quests where only ONE player will gain credit for the quest. - ------------------------------ -16 = ACTION_T_CASTCREATUREGO: ------------------------------ -Parameter 1: CreatureID - The Creature Template ID to be Summoned. The value here needs to be a valid Creature Template ID. -Parameter 2: SpellID - The Spell ID to use to simulate the cast. The value used in this field needs to be a valid Spell ID. -Parameter 3: Target - The Target Type defining whom the quest credit should be given to. The value in this field needs to be a valid target type as specified in the reference tables below. - -This action will call CastedCreatureOrGO() function for the player. It can be used to give quest credit for casting a spell on the creature. -This is commonly used for NPC's who have a special requirement to have a Spell cast on them to complete a quest. - ------------------------------ -17 = ACTION_T_SET_UNIT_FIELD: ------------------------------ -Parameter 1: Field_Number - The index of the Field Number to be changed. Use (http://wiki.udbforums.org/index.php/Character_data) for a list of indeces and what they control. Creatures only contain the OBJECT_FIELD_* and UNIT_FIELD_* fields. They do not contain the PLAYER_FIELD_* fields. -Parameter 2: Value - The new value to be put in the field. -Parameter 3: Target - The Target Type defining for whom the unit field should be changed. The value in this field needs to be a valid target type as specified in the reference tables below. - -When activated, this action can change the target's unit field values. More information on the field value indeces can be found at (http://wiki.udbforums.org/index.php/Character_data) - ----------------------------- -18 = ACTION_T_SET_UNIT_FLAG: ----------------------------- -Parameter 1: Flags - The flag(s) to be set. Multiple flags can be set by using bitwise-OR on them (adding them together). -Parameter 2: Target - The Target Type defining for whom the flags should be changed. The value in this field needs to be a valid Target Type as specified in the reference tables below. - -When activated, this action changes the target's flags by adding (turning on) more flags. For example, this action can make the creature unattackable/unselectable if the right flags are used. - -------------------------------- -19 = ACTION_T_REMOVE_UNIT_FLAG: -------------------------------- -Parameter 1: Flags - The flag(s) to be removed. Multiple flags can be set by using bitwise-OR on them (adding them together). -Parameter 2: Target - The target type defining for whom the flags should be changed. The value in this field needs to be a valid Target Type as specified in the reference tables below. - -When activated, this action changes the target's flags by removing (turning off) flags. For example, this action can make the creature normal after it was unattackable/unselectable if the right flags are used. - --------------------------- -20 = ACTION_T_AUTO_ATTACK: --------------------------- -Parameter 1: AllowAutoAttack - If zero, then the creature will stop its melee attacks. If non-zero, then the creature will either continue its melee attacks (the action would then have no effect) or it will start its melee attacks on the target with the top threat if its melee attacks were previously stopped. - -This action controls whether or not the creature should stop or start the auto melee attack. -NOTE: The ACID Dev Team has conformed to using either 0 or 1 for the Param values (0 = Stop Melee, 1 = Start Melee). -This is commonly used in combination with EVENT_T_RANGE and ACTION_T_COMBAT_MOVEMENT for Ranged Combat for Mages and Spell Casters. - ------------------------------- -21 = ACTION_T_COMBAT_MOVEMENT: ------------------------------- -Parameter 1: If zero, then the creature will stop moving towards its victim (if its victim gets out of melee range) and will be stationary. If non-zero, then the creature will either continue to follow its victim (the action would have no effect) or it will start to follow the target with the top threat if its movement was disabled before. -Parameter 2: If non-zero, then stop melee combat state (if param1=0) or start melee combat state (if param1!=0) and creature in combat with selected target. - -This action controls whether or not the creature will always move towards its target. -NOTE: The ACID Dev Team has conformed to using either 0 or 1 for the Param values. (0 = Stop Movement, 1 = Start Movement) -This is commonly used with EVENT_T_RANGE and ACTION_T_AUTO_ATTACK for NPC's who engage in Ranged Comabt (Either Spells or Ranged Attacks) -Parameter 2 specialy used for ranged combat proper client side visual show ranged weapon in proper state. - ------------------------- -22 = ACTION_T_SET_PHASE: ------------------------- -Parameter 1: The new phase to set the creature in. This number must be an integer between 0 and 31. Numbers outside of that range will result in an error. - -When activated, this action sets the creature's event to the specified value. -NOTE: The creature's current Phase is NOT reset at creature evade. You must manually set the phase back to 0 at EVENT_T_RESET. -NOTE: The value used for the Param is the actual Phase Number (Not The Event_Inverse_Phase_Mask) -This is commonly used for complex scripts with several phases and you need to switch to a different phase. - ------------------------- -23 = ACTION_T_INC_PHASE: ------------------------- -Parameter 1: Value - The number of phases to increase or decrease. Use negative values to decrease the current phase. - -When activated, this action will increase (or decrease) the current creature's phase. -NOTE: After increasing or decreasing the phase by this action, the current phase must NOT be lower than 0 or exceed 31. -This can be used instead of ACTION_T_SET_PHASE to change phases in scripts. Just a user friendly option for changing phases. - --------------------- -24 = ACTION_T_EVADE: --------------------- -When activated, the creature will immediately exit out of combat, clear its threat list, and move back to its spawn point. Basically, this action will reset the whole encounter. -NOTE: All Param Values Are 0 for this Action. - -------------------- -25 = ACTION_T_FLEE: -------------------- -When activated, the creature will flee from combat for assistance from nearby NPC's if possible. -NOTE: All Param Values Are 0 for this Action. - ------------------------------- -26 = ACTION_T_QUEST_EVENT_ALL: ------------------------------- -Parameter 1: QuestId - The quest ID to finish for everyone. - -This action does the same thing as the ACTION_T_QUEST_EVENT does but it does it for all players in the creature's threat list. -NOTE: If a player is not in the NPC's threat list for whatever reason, he/she won't get the quest completed. - ---------------------------------- -27 = ACTION_T_CASTCREATUREGO_ALL: ---------------------------------- -Parameter 1: QuestId - The quest template ID. -Parameter 2: SpellId - The spell ID used to simulate the cast. - -This action does the same thing as the ACTION_T_CASTCREATUREGO does but it does it for all players in the creature's threat list. -NOTE: If a player is not in its threat list for whatever reason, he/she won't receive the cast emulation. - ------------------------------------ -28 = ACTION_T_REMOVEAURASFROMSPELL: ------------------------------------ -Parameter 1: Target - The target type defining for whom the unit field should be changed. The value in this field needs to be a valid target type as specified in the reference tables below. -Parameter 2: SpellId - The spell ID whose auras will be removed. - -This action will remove all auras from a specific spell from the target. -This is commonly used for NPC's who have an OOC Aura that is removed at combat start or a similar idea (Like Stealth or Shape Shift) - ------------------------------- -29 = ACTION_T_RANGED_MOVEMENT: ------------------------------- -Parameter 1: Distance - The distance the mob should keep between it and its target. -Parameter 2: Angle - The angle the mob should use. - -This action changes the movement type generator to ranged type using the specified values for angle and distance. -NOTE: Specifying zero angle and distance will make it just melee instead. -This is commonly used for NPC's who always attack at range and you can specify the distance they will maintain from the target. - ---------------------------- -30 = ACTION_T_RANDOM_PHASE: ---------------------------- -Parameter 1: PhaseId1 - A possible random phase choice. -Parameter 2: PhaseId2 - A possible random phase choice. -Parameter 3: PhaseId3 - A possible random phase choice. - -Randomly sets the phase to one from the three parameter choices. -NOTE: Use -1 to specify that if this param is picked to do nothing. Random is constant between actions within an event. So if you have a random Yell and a random Sound they will match up (ex: param2 with param2) -NOTE 2: PLEASE NOTE THAT EACH OF THE PARAM VALUES ARE ACTUAL PHASE NUMBERS NOT THE INVERSE PHASE MASK VALUE. -This is commonly used for Spellcasting NPC's who on Aggro may select at random a school of spells to use for the fight. Use this if you have up to 3 phases used, otherwise use Action 31 for more then 3 phases. - ---------------------------------- -31 = ACTION_T_RANDOM_PHASE_RANGE: ---------------------------------- -Parameter 1: PhaseMin - The minimum of the phase range. -Parameter 2: PhaseMax - The maximum of the phase range. The number here must be greater than PhaseMin. - -Randomly sets the phase between a range of phases controlled by the parameters. Sets the phase to a random id (Phase = PhaseMin + rnd % PhaseMin-PhaseMax). -NOTE: PhaseMax must be greater than PhaseMin. -NOTE 2: PLEASE NOTE THAT EACH OF THE PARAM VALUES ARE ACTUAL PHASE NUMBERS NOT THE INVERSE PHASE MASK VALUE. -This is commonly used for Spellcasting NPC's who on Aggro may select at random a school of spells to use for the fight. Use this if you have MORE then 3 phases used, otherwise use Action 30. - ---------------------- -32 = ACTION_T_SUMMON: ---------------------- -Parameter 1: CreatureID - The creature template ID to be summoned. The value here needs to be a valid creature template ID. -Parameter 2: Target - The target type defining who the summoned creature will attack. The value in this field needs to be a valid target type as specified in the reference tables below. NOTE: Using target type 0 will cause the summoned creature to not attack anyone. -Parameter 3: SummonID - The summon ID from the creature_ai_summons table controlling the position (and spawntime) where the summoned mob should be spawned at. - -Summons creature (param1) to attack target (param2) at location specified by creature_ai_summons (param3). -NOTE: Param3 Value is the ID Value used for the entry used in creature_ai_summons for this action. You MUST have an creature_ai_summons entry to use this action. -This is commonly used for NPC's who need to Summon a creature at a specific location. (Normally used for complex events) - ------------------------------ -33 = ACTION_T_KILLED_MONSTER: ------------------------------ -Parameter 1: CreatureID - The creature template ID. The value here must be a valid creature template ID. -Parameter 2: Target - The target type defining whom the quest kill count should be given to. The value in this field needs to be a valid target type as specified in the reference tables below. - -When activated, this action will call KilledMonster() function for the player. It can be used to give creature credit for killing a creature. In general if the quest is set to be accompished on different creatures (e.g. "Credit" templates). -NOTE: It can be ANY creature including certain quest specific triggers -This is commonly used for giving the player Quest Credits for NPC kills (Many NPC's may use the same CreatureID for the Kill Credit) - ----------------------------- -34 = ACTION_T_SET_INST_DATA: ----------------------------- -Parameter 1: Field - The field to change in the instance script. Again, this field needs to be a valid field that has been already defined in the instance's script. -Parameter 2: Data - The value to put at that field index. - -Sets data for the instance. Note that this will only work when the creature is inside an instantiable zone that has a valid script (ScriptedInstance) assigned. -This is commonly used to link an EventAI script with a existing Script Library C++ Script. You make make things happen like opening doors on specific events that happen. - -Field Values: -These are located in there SD2 Instance File (Example: blackrock_depths.h) And Are Clearly Defined For Specific Events Scripted In The Instance. - -Data Values: -NOT_STARTED = 0 -IN_PROGRESS = 1 -FAIL = 2 -DONE = 3 -SPECIAL = 4 - ------------------------------- -35 = ACTION_T_SET_INST_DATA64: ------------------------------- -Parameter 1: Field - The field to change in the instance script. Again, this field needs to be a valid field that has been already defined in the instance's script. -Parameter 2: Target - The target type to use to get the GUID that will be stored at the field index. The value in this field needs to be a valid target type as specified in the reference tables below. - -Sets GUID (64 bits) data for the instance based on the target. Note that this will only work when the creature is inside an instantiable zone that has a valid script (ScriptedInstance) assigned. -Calls ScriptedInstance::SetData64 with field (param1) and data (param2) target's GUID. - ------------------------------- -36 = ACTION_T_UPDATE_TEMPLATE: ------------------------------- -Parameter 1: TemplateId - The creature template ID. The value here must be a valid creature template ID. -Parameter 2: Team - Use model_id from team : Alliance(0) or Horde (1). - -This function temporarily changes creature entry to new entry, display is changed, loot is changed, but AI is not changed. At respawn creature will be reverted to original entry. -Changes the creature to a new creature template of (param1) with team = Alliance if (param2) = false or Horde if (param2) = true - ------------------- -37 = ACTION_T_DIE: ------------------- -Kills the creature -This is commonly used if you need to Instakill the creature for one reason or another. - --------------------------------- -38 = ACTION_T_ZONE_COMBAT_PULSE: --------------------------------- -Places all players within the instance into combat with the creature. Only works in combat and only works inside of instances. - ----------------------------- -39 = ACTION_T_CALL_FOR_HELP: ----------------------------- -Parameter 1: Radius - All friendly (not only same faction) creatures will go to help - -Call any friendly creatures (if its not in combat/etc) in radius attack creature target. -Mostly used when call to help more wide that normal aggro radius or auto-used call for assistance, and need apply at some event. - -------------------------- -40 ACTION_T_SET_SHEATH: -------------------------- -Parameter 1: Set Sheath State -0 = SHEATH_STATE_UNARMED Set No Weapon Displayed (Not Usually Used By Creatures) -1 = SHEATH_STATE_MELEE Set Melee Weapon Displayed -2 = SHEATH_STATE_RANGED Set Ranged Weapon Displayed - -Set Sheath State For NPC. -Note: SHEATH_STATE_RANGED case work in combat state only if combat not start as melee commands. -This possible setup by set at event AI start (single used EVENT_T_TIMER_OOC or set ACTION_T_COMBAT_MOVEMENT 0 for creature that prefered ranged attack) - ----------------------------- -41 ACTION_T_FORCE_DESPAWN: ----------------------------- -Despawns The NPC with optional delay time (Works In or Out of Combat) -Parameter 1: Delay - Sets delay time until Despawn occurs after triggering the action. Time is in (ms). - ------------------------------------------ -42 ACTION_T_SET_INVINCIBILITY_HP_LEVEL: ------------------------------------------ -Parameter 1: Minimum Health Level That NPC Can Reach (NPC Will Not Go Below This Value). -Parameter 2: Sets Format of Paramater 1 Value -0 = Sets Paramater 1 as an exact HP value -1 = Sets Paramater 1 as a HP Percent (0..100) of the creature's max health - -NOTE: To Cancel Invincible You Need To Set Script For Either 0% HP or 0 HP So Then NPC Can Be Killed Again - ------------------------------------------ -43 ACTION_T_MOUNT_TO_ENTRY_OR_MODEL: ------------------------------------------ -Parameter 1, Optional: Set mount model from creature_template.entry -Parameter 2, Optional: Set mount model by explicit modelId - -If (Param1) AND (Param2) are both 0, unmount. - ---------------------------- -44 = ACTION_T_CHANCED_TEXT: ---------------------------- -Parameter 1: Chance with which a text will be displayed (must be between 1 and 99) - -Parameter 2: The entry of the text that the NPC should use from eventai_texts table. Optionally a entry from other tables can be used (such as custom_texts). - Entry are required to be negative and exist in a *_texts-table. The type text to be displayed are defined in the texts-table itself (Say, Yell, Whisper, Emote Text, Boss Whisper, Boss Emote) - Other options are also to be defined in the texts-table, such as a sound to be heard with the text and the language used in output (common, dwarvish, etc). - In case this entry has a localized version of the text, the localized text will be displayed in client that support this locale. - -Parameter 3: Optional TextId can be defined in addition. The same apply to this as explained above, however eventAI will randomize between the two. - -Also remark that the chance also depends on the chance of the event. And remark that a chance of 100 is useless and in this case ACTION_T_TEXT should be used. - -Read at bottom for documentation of creature_ai_texts-table. - ------------------------------ -45 = ACTION_T_THROW_AI_EVENT: ------------------------------ -Parameter 1: EventType - What AIEvent to throw, supported types see CreatureAI.h enum AIEventType -Parameter 2: Radius - Throw the AIEvent to nearby friendly creatures within this range - ------------------------------ -46 = ACTION_T_SET_THROW_MASK: ------------------------------ -Parameter 1: EventTypeMask - Which AIEvents to throw, supported types see CreatureAI.h enum AIEventType (mask-value is 2^type) - -This action sets which AIEvents a npc will throw automatically. -Currently supported are: - AI_EVENT_JUST_DIED | MaskValue: 0x01 | Sender = Killed Npc, Invoker = Killer | Sent when npc dies - AI_EVENT_CRITICAL_HEALTH | MaskValue: 0x02 | Sender = Hurt Npc, Invoker = DamageDealer | Sent when damaged below 10% health - AI_EVENT_LOST_HEALTH | MaskValue: 0x04 | Sender = Hurt Npc, Invoker = DamageDealer | Sent when damaged below 50% health - AI_EVENT_LOST_SOME_HEALTH | MaskValue: 0x08 | Sender = Hurt Npc, Invoker = DamageDealer | Sent when damaged below 90% health - AI_EVENT_GOT_FULL_HEALTH | MaskValue: 0x10 | Sender = Healed Npc, Invoker = Healer | Sent when healed to full health - -So if you want an npc to throw AIEvents automatically on death and on critical health, you would set its EventTypeMask to 0x03 - ------------------------------ -47 = ACTION_T_SUMMON_UNIQUE ------------------------------ -* Parameter 1: CreatureID - The creature template ID to be summoned. The value here needs to be a valid creature template ID. -* Parameter 2: Target - The target type defining who the summoned creature will attack. The value in this field needs to be a valid target type as specified in the reference tables below. NOTE: Using target type 0 will cause the summoned creature to not attack anyone. -* Parameter 3: SummonID - The summon ID from the creature_ai_summons table controlling the position (and spawn time) where the summoned mob should be spawned at. - -Only summons a creature when not already spawned (Param1) to attack target (Param2) at location specified by EventAI_Summons (Param3). Preventing multiple spawns of unique creatures. - ------------------------------ -48 = ACTION_T_EMOTE_TARGET ------------------------------ -Parameter 1: The Emote ID that the creature should perform. (Emote IDs are also contained in the DBC but they can be found in the mangos source as well). -Parameter 2: Creature guid, to which emote dealer will performed. - -The creature will perform a visual emote. Unlike a text emote, a visual emote is one where the creature will actually move or perform a gesture. -This is commonly used for NPC's who may perform a special action (Salute, Roar, ect...). Not all player emotes work for creature models. - -========================================= -Target Types -========================================= -Below is the list of current Target types that EventAI can handle. -Target types are used by certain actions and may effect actions differently - -# Internal Name Description ---------------------------------------------------- -0 TARGET_T_SELF Self Cast -1 TARGET_T_HOSTILE Current Target (ie: Highest Aggro) -2 TARGET_T_HOSTILE_SECOND_AGGRO Second Highest Aggro (Generaly used for Cleaves and some special attacks) -3 TARGET_T_HOSTILE_LAST_AGGRO Dead Last on Aggro (no idea what this could be used for) -4 TARGET_T_HOSTILE_RANDOM Random Target on The Threat List -5 TARGET_T_HOSTILE_RANDOM_NOT_TOP Any Random Target Except Top Threat -6 TARGET_T_ACTION_INVOKER Unit Who Caused This Event to Occur (only works for EVENT_T_AGGRO, EVENT_T_KILL, EVENT_T_DEATH, EVENT_T_SPELLHIT, EVENT_T_OOC_LOS, EVENT_T_FRIENDLY_HP, EVENT_T_RECEIVE_AI_EVENT) -7 TARGET_T_ACTION_INVOKER_OWNER Unit who is responsible for Event to occur (only works for EVENT_T_AGGRO, EVENT_T_KILL, EVENT_T_DEATH, EVENT_T_SPELLHIT, EVENT_T_OOC_LOS, EVENT_T_FRIENDLY_HP, EVENT_T_FRIENDLY_IS_CC, EVENT_T_FRIENDLY_MISSING_BUFF) -8 TARGET_T_HOSTILE_RANDOM_PLAYER Random Player on The Threat List -9 TARGET_T_HOSTILE_RANDOM_NOT_TOP_PLAYER Any Random Player Except Top Threat -10 TARGET_T_EVENT_SENDER Creature who sent a received AIEvent - only triggered by EVENT_T_RECEIVE_AI_EVENT - -========================================= -Cast Flags -========================================= -Below is the list of current Cast Flags that EventAI's spell casting can handle. -Cast flags are handled bitwise. Bit 0 is Interrupt Previous, bit 1 is triggered, etc. -So for example the number "3" (11 in Binary, selecting first 2 options) would mean that this cast has both CAST_INTURRUPT_PREVIOUS and CAST_TRIGGERED. -Another example: the number "5" (101 in Binary, selecting first and third options) would mean that this cast has CAST_INTURRUPT_PREVIOUS and CAST_FORCE_CAST. - -# Decimal Internal Name Description --------------------------------------------------------------- -0 1 CAST_INTURRUPT_PREVIOUS Interrupts any previous spell casting (basicaly makes sure that this spell goes off) -1 2 CAST_TRIGGERED Forces the spell to be instant cast and require no mana/reagents. -2 4 CAST_FORCE_CAST Forces spell to cast even if the target is possibly out of range or the creature is possibly out of mana -3 8 CAST_NO_MELEE_IF_OOM Prevents creature from entering melee if out of mana or out of range -4 16 CAST_FORCE_TARGET_SELF Forces the target to cast this spell on itself -5 32 CAST_AURA_NOT_PRESENT Only casts the spell on the target if the target does not have the aura from that spell on itself already. - -NOTE: You can add the numbers in the decimal column to combine flags. - For example if you wanted to use CAST_NO_MELEE_IF_OOM(8) and CAST_TRIGGERED(2) you would simply use 10 in the cast flags field (8 + 2 = 10). - -========================================= -Event Flags -========================================= -Below is the list of current Event Flags that EventAI can handle. Event flags are handled bitwise. - -# Decimal Internal Name Description ------------------------------------------------------------- -0 1 EFLAG_REPEATABLE Event repeats (Does not repeat if this flag is not set) -1 2 EFLAG_DIFFICULTY_0 Event occurs in instance difficulty 0 (will not occur if not set) -2 4 EFLAG_DIFFICULTY_1 Event occurs in instance difficulty 1 (will not occur if not set) -3 8 EFLAG_DIFFICULTY_2 Event occurs in instance difficulty 2 (will not occur if not set) -4 16 EFLAG_DIFFICULTY_3 Event occurs in instance difficulty 3 (will not occur if not set) -5 32 EFLAG_RANDOM_ACTION At event occur execute one random action from event actions instead all actions. -6 64 -7 128 EFLAG_DEBUG_ONLY Prevents events from occuring on Release builds. Useful for testing new features. - -NOTE: You can add the numbers in the decimal column to combine flags. - - * PLEASE NOTE THE DIFFERENCES BETWEEN DUNGEON INSTANCE DIFFICULTY LEVELS AND RAID Instance SIZE/DIFFICULTY LEVELS - PLEASE CHECK "MapDifficulty.dbc" For Information * - -Dungeons: ---------- -EFLAG_DIFFICULTY_0 Event occurs in DUNGEON_DIFFICULTY_NORMAL -EFLAG_DIFFICULTY_1 Event occurs in DUNGEON_DIFFICULTY_HEROIC -EFLAG_DIFFICULTY_2 None (Not Implimented) -EFLAG_DIFFICULTY_3 None (Not Implimented) - -10/25 Man Raids: ----------------- -EFLAG_DIFFICULTY_0 Event Occurs in RAID_DIFFICULTY_10MAN_NORMAL <--- Use This Difficulty Setting For Raids Designed For Single Man Size (Whatever Size It Is) -EFLAG_DIFFICULTY_1 Event Occurs in RAID_DIFFICULTY_25MAN_NORMAL -EFLAG_DIFFICULTY_2 Event Occurs in RAID_DIFFICULTY_10MAN_HEROIC (ONLY IF SUPPORTED BY RAID INSTANCE) <--- NOTE: Currently Only a Couple Raids Support This Mode -EFLAG_DIFFICULTY_3 Event Occurs in RAID_DIFFICULTY_25MAN_HEROIC (ONLY IF SUPPORTED BY RAID INSTANCE) <--- NOTE: Currently Only a Couple Raids Support This Mode - - -* Currently Only: Trial of the Crusader and Icecrown Citadel and Ruby Sanctum Raids Support Heroic Modes * - -========================================= -Basic Structure of creature_ai_texts -========================================= -Below is a the list of current fields within the texts tables. - -Field_Name Description ------------------------------------------------------------ -entry This value is mearly an NEGATIVE identifier of the current text number. Required for sql queries. Valid range are -1 to -999999 -content_default This is the actual text presented in the default language (English). - -content_loc1 This is the actual text presented in the Localization #1 Clients (Korean) -content_loc2 This is the actual text presented in the Localization #2 Clients (French) -content_loc3 This is the actual text presented in the Localization #3 Clients (German) -content_loc4 This is the actual text presented in the Localization #4 Clients (Chinese) -content_loc5 This is the actual text presented in the Localization #5 Clients (Taiwanese) -content_loc6 This is the actual text presented in the Localization #6 Clients (Spanish) -content_loc7 This is the actual text presented in the Localization #7 Clients (Spanish Mexico) -content_loc8 This is the actual text presented in the Localization #8 Clients (Russian) - -sound This value is the Sound ID that corresponds to the actual text used. -type Variables used to define type of text (Say/Yell/TextEmote/Whisper). -language This value is the Language that the text is native in. -emote Value from enum Emote. Only source of text will play this emote (not target, if target are defined in DoScriptText) -comment This is a comment regarding the text entry - -Note: Fields `content_loc1` to `content_loc8` are NULL values by default and are normally handled by seperate localization projects. - -========================================= -Text Types (type) -========================================= -Below is the list of current Text types that texts tables can handle. These were previously seperate Actions in ACID. - -# Internal Name Description ------------------------------------------------------------ -0 CHAT_TYPE_SAY This type sets the text to be displayed as a Say (Speech Bubble). -1 CHAT_TYPE_YELL This type sets the text to be displayed as a Yell (Red Speech Bubble) and usually has a matching Sound ID. -2 CHAT_TYPE_TEXT_EMOTE This type sets the text to be displayed as a text emote in orange in the chat log. -3 CHAT_TYPE_BOSS_EMOTE This type sets the text to be displayed as a text emote in orange in the chat log (Used only for specific Bosses). -4 CHAT_TYPE_WHISPER This type sets the text to be displayed as a whisper to the player in the chat log. -5 CHAT_TYPE_BOSS_WHISPER This type sets the text to be displayed as a whisper to the player in the chat log (Used only for specific Bosses). -6 CHAT_TYPE_ZONE_YELL Same as CHAT_TYPE_YELL but will display to all players in current zone. - -========================================= -Language Types (language) -========================================= -Below is the list of current Language types that are allowed. -This is the Race Language that the text is native to (So it will display properly) - -# Internal Name Description ------------------------------------------------------------ -0 UNIVERSAL Text in this language is understood by ALL Races. -1 ORCISH Text in this language is understood ONLY by Horde Races. -2 DARNASSIAN Text in this language is understood ONLY by the Night Elf Race. -3 TAURAHE Text in this language is understood ONLY by the Tauren Race. -6 DWARVISH Text in this language is understood ONLY by the Dwarf Race. -7 COMMON Text in this language is understood ONLY by Alliance Races. -8 DEMONIC Text in this language is understood ONLY by the Demon Race (Not Implimented). -9 TITAN This language was used by Sargeras to speak with other Titians (Not Implemented). -10 THALASSIAN Text in this language is understood ONLY by the Blood Elf Race. -11 DRACONIC Text in this language is understood ONLY by the Dragon Race. -12 KALIMAG Text will display as Kalimag (not readable by players, language of all elementals) -13 GNOMISH Text in this language is understood ONLY by the Gnome Race. -14 TROLL Text in this language is understood ONLY by the Troll Race. -33 GUTTERSPEAK Text in this language is understood ONLY by the Undead Race. -35 DRAENEI Text in this language is understood ONLY by the Draenai Race. -36 ZOMBIE (not currently used?) -37 GNOMISH BINARY Binary language used by Alliance when drinking Binary Brew -38 GOBLIN BINARY Binary language used by Horce when drinking Binary Brew diff --git a/doc/ScriptCommands.md b/doc/ScriptCommands.md new file mode 100644 index 000000000..b64edff62 --- /dev/null +++ b/doc/ScriptCommands.md @@ -0,0 +1,181 @@ +Database script processing +========================== +In addition to *EventAI*, *mangos-zero* provides script processing for various +types of game content. These scripts can be executed when creatures move or die, +when events are executed, and game object spawns/templates are used, on gossip +menu selections, when starting and completing quests, and when casting spells. + +Database structure +------------------ +All script tables share a common structure, to store parameterized commands for +the various types of game content. + +`id` column +----------- +* `dbscripts_on_creature_death`: Creature entry +* `dbscripts_on_creature_movement`: DB project self defined id +* `dbscripts_on_event`: Event id. Several sources: spell effect 61, taxi/transport nodes, game object_template data +* `dbscripts_on_go_use`: Game object guid +* `dbscripts_on_go_template_use`: Game object entry +* `dbscripts_on_gossip`: DB project self defined id +* `dbscripts_on_quest_end`: DB project self defined id (generally quest entry) +* `dbscripts_on_quest_start`: DB project self defined id (generally quest entry) +* `dbscripts_on_spell`: Spell id + +`delay` column +-------------- +Delay in seconds. Defines the order in which steps are executed. + +`command` column +---------------- +The action to execute. + +`datalong` columns +------------------ +2 multipurpose fields, storing raw data as unsigned integer values. + +`buddy_entry` column +-------------------- +1 field to store the entry of a "buddy". Depending on the command used this can +can point to a game object template or and creature template entry. + +`search_radius` column +---------------------- +Range in which the buddy defined in `buddy_entry` will be searched. In case of +`SCRIPT_FLAG_BUDDY_BY_GUID` this field is the buddy's guid! + +`data_flags` column +------------------- +Field which holds a combination of these flags: + +Value | Name | Notes +----- | ------------------------------- | ------------------------------------ +1 | SCRIPT_FLAG_BUDDY_AS_TARGET | +2 | SCRIPT_FLAG_REVERSE_DIRECTION | +4 | SCRIPT_FLAG_SOURCE_TARGETS_SELF | +8 | SCRIPT_FLAG_COMMAND_ADDITIONAL | (Only for some commands possible) +16 | SCRIPT_FLAG_BUDDY_BY_GUID | (Interpret search_radius as buddy's guid) +32 | SCRIPT_FLAG_BUDDY_IS_PET | (Do not search for an NPC, but for a pet) + +`dataint` columns +----------------- +4 multipurpose fields, storing raw data as signed integer values. + +*Note*: currently used only for text ids for the command `SCRIPT_COMMAND_TALK`, +and in relation with the command `SCRIPT_COMMAND_TERMINATE_SCRIPT`. + +`x`, `y`, `z` and `o` columns +----------------------------- +Map coordinates for commands that require coordinates + +Origin of script and source/target in scripts +--------------------------------------------- + +* `dbscripts_on_creature_death`: Creature death. + Source: creature. Target: Unit (player/creature) +* `dbscripts_on_creature_movement`: `creature_movement` and `creature_movement_template`. + Source: creature. Target: creature +* `dbscripts_on_event`: Flight path with source: player and target: player, + transport path with source: transport game object and target transport game + object, `gameobject_template` with source: user (player/creature) and target: + game object, spells having effect 61 with source: caster and target: target. +* `dbscripts_on_go_use`, `dbscripts_on_go_template_use`: game object use with + source: user: and target: game object. +* `dbscripts_on_gossip`: `gossip_menu_option`, `gossip_menu` with source: creature + and target: player in case of NPC-Gossip, or with source: player and target: + game object in case of GO-Gossip. +* `dbscripts_on_quest_end`: `quest_template` with source: quest taker (creature/GO) + and target: player. +* `dbscripts_on_quest_start`: `quest_template` with source: quest giver (creature/GO) + and target: player. +* `dbscripts_on_spell`: spell with effect 77(SCRIPT_EFFECT), spells with effect 3 + (DUMMY), spells with effect 64 (TRIGGER_SPELL, with non-existing triggered spell) + having source: caster: and target: target of spell (Unit). + +Buddy concept +------------- +Commands except the ones requiring a player (like KILL_CREDIT) have support +for the buddy concept. This means that if an entry for `buddy_entry` is +provided, aside from source and target as listed above also a "buddy" is +available. + +Which one on the three (`originalSource`, `originalTarget`, `buddy`) will +be used in the command, depends on the `data_flags` settings. + +Note that some commands (like EMOTE) use only the resulting source for an +action. + +Possible combinations of the flags: + +* `SCRIPT_FLAG_BUDDY_AS_TARGET`: 0x01 +* `SCRIPT_FLAG_REVERSE_DIRECTION`: 0x02 +* `SCRIPT_FLAG_SOURCE_TARGETS_SELF`: 0x04 + +are + +* 0: originalSource / buddyIfProvided -> originalTarget +* 1: originalSource -> buddy +* 2: originalTarget -> originalSource / buddyIfProvided +* 3: buddy -> originalSource +* 4: originalSource / buddyIfProvided -> originalSource / buddyIfProvided +* 5: originalSource -> originalSource +* 6: originalTarget -> originalTarget +* 7: buddy -> buddy + +where `A -> B` means that the command is executed from A with B as target. + +Commands and their parameters +----------------------------- + +ID | Name | Parameters +-- | -------------------------------------- | ------------------------------------- +0 | SCRIPT_COMMAND_TALK | resultingSource = WorldObject, resultingTarget = Unit/none, `dataint` = text entry from db_script_string -table. `dataint2`-`dataint4` optionally, for random selection of text +1 | SCRIPT_COMMAND_EMOTE | resultingSource = Unit, resultingTarget = Unit/none, `datalong` = emote_id, dataint1-dataint4 = optionally for random selection of emote +2 | SCRIPT_COMMAND_FIELD_SET | source = any, `datalong` = field_id, `datalong2` = field value +3 | SCRIPT_COMMAND_MOVE_TO | resultingSource = Creature. If position is very near to current position, or x=y=z=0, then only orientation is changed. `datalong2` = travel_speed*100 (use 0 for creature default movement). `data_flags` & SCRIPT_FLAG_COMMAND_ADDITIONAL: teleport unit to position `x`/`y`/`z`/`o` +4 | SCRIPT_COMMAND_FLAG_SET | source = any. `datalong` = field_id, `datalong2` = bit mask +5 | SCRIPT_COMMAND_FLAG_REMOVE | source = any. `datalong` = field_id, `datalong2` = bit mask +6 | SCRIPT_COMMAND_TELEPORT_TO | source or target with Player. `datalong` = map_id, x/y/z +7 | SCRIPT_COMMAND_QUEST_EXPLORED | one from source or target must be Player, another GO/Creature. `datalong` = quest_id, `datalong2` = distance or 0 +8 | SCRIPT_COMMAND_KILL_CREDIT | source or target with Player. `datalong` = creature entry, or 0; If 0 the entry of the creature source or target is used, `datalong2` = bool (0=personal credit, 1=group credit) +9 | SCRIPT_COMMAND_RESPAWN_GAMEOBJECT | source = any, target = any. `datalong`=db_guid (can be skipped for buddy), `datalong2` = despawn_delay +10 | SCRIPT_COMMAND_TEMP_SUMMON_CREATURE | source = any, target = any. `datalong` = creature entry, `datalong2` = despawn_delay, `data_flags` & SCRIPT_FLAG_COMMAND_ADDITIONAL: summon as active object +11 | SCRIPT_COMMAND_OPEN_DOOR | source = any. `datalong` = db_guid (can be skipped for buddy), `datalong2` = reset_delay +12 | SCRIPT_COMMAND_CLOSE_DOOR | source = any. `datalong` = db_guid (can be skipped for buddy), `datalong2` = reset_delay +13 | SCRIPT_COMMAND_ACTIVATE_OBJECT | source = unit, target=GO. +14 | SCRIPT_COMMAND_REMOVE_AURA | resultingSource = Unit. `datalong` = spell_id +15 | SCRIPT_COMMAND_CAST_SPELL | resultingSource = Unit, cast spell at resultingTarget = Unit. `datalong` = spell id, `data_flags` & SCRIPT_FLAG_COMMAND_ADDITIONAL: cast triggered +16 | SCRIPT_COMMAND_PLAY_SOUND | source = any object, target=any/player. `datalong` = sound_id, `datalong2` (bit mask: 0/1=target-player, 0/2=with distance dependent, 0/4=map wide, 0/8=zone wide; so 1|2 = 3 is target with distance dependent) +17 | SCRIPT_COMMAND_CREATE_ITEM | source or target must be player. `datalong` = item entry, `datalong2` = amount +18 | SCRIPT_COMMAND_DESPAWN_SELF | resultingSource = Creature. `datalong` = despawn delay +19 | SCRIPT_COMMAND_PLAY_MOVIE | target can only be a player. `datalong` = movie id +20 | SCRIPT_COMMAND_MOVEMENT | resultingSource = Creature. `datalong` = MovementType (0:idle, 1:random or 2:waypoint), `datalong2` = wanderDistance (for random movement), `data_flags` & SCRIPT_FLAG_COMMAND_ADDITIONAL: RandomMovement around current position +21 | SCRIPT_COMMAND_SET_ACTIVEOBJECT | resultingSource = Creature. `datalong` = bool 0=off, 1=on +22 | SCRIPT_COMMAND_SET_FACTION | resultingSource = Creature. `datalong` = factionId OR 0 to restore original faction from creature_template, `datalong2` = enum TemporaryFactionFlags +23 | SCRIPT_COMMAND_MORPH_TO_ENTRY_OR_MODEL | resultingSource = Creature. `datalong` = creature entry/modelid (depend on data_flags) OR 0 to demorph, `data_flags` & SCRIPT_FLAG_COMMAND_ADDITIONAL: use datalong value as modelid explicit +24 | SCRIPT_COMMAND_MOUNT_TO_ENTRY_OR_MODEL | resultingSource = Creature. `datalong` = creature entry/modelid (depend on data_flags) OR 0 to dismount, `data_flags` & SCRIPT_FLAG_COMMAND_ADDITIONAL: use datalong value as modelid explicit +25 | SCRIPT_COMMAND_SET_RUN | resultingSource = Creature. `datalong` = bool 0=off, 1=on +26 | SCRIPT_COMMAND_ATTACK_START | resultingSource = Creature, resultingTarget = Unit. +27 | SCRIPT_COMMAND_GO_LOCK_STATE | resultingSource = GO. `datalong` = flag_go_lock = 0x01, flag_go_unlock = 0x02, flag_go_nonInteract = 0x04, flag_go_interact = 0x08 +28 | SCRIPT_COMMAND_STAND_STATE | resultingSource = Creature. `datalong` = stand state (enum UnitStandStateType) +29 | SCRIPT_COMMAND_MODIFY_NPC_FLAGS | resultingSource = Creature. `datalong` = NPCFlags, `datalong2` = 0x00=toggle, 0x01=add, 0x02=remove +30 | SCRIPT_COMMAND_SEND_TAXI_PATH | resultingTarget or Source must be Player. `datalong` = taxi path id +31 | SCRIPT_COMMAND_TERMINATE_SCRIPT | `datalong` = search for npc entry if provided, `datalong2` = search distance, `!(data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL)`: if npc not alive found, terminate script, `data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL`: if npc alive found, terminate script, `dataint` = change of waittime (MILLISECONDS) of a current waypoint movement type (negative values will decrease time) +32 | SCRIPT_COMMAND_PAUSE_WAYPOINTS | resultingSource must be Creature. `datalong` = 0/1 unpause/pause waypoint movement +33 | SCRIPT_COMMAND_RESERVED_1 | reserved for 3.x and later. Do not use! +34 | SCRIPT_COMMAND_TERMINATE_COND | `datalong` = condition_id, `datalong2` = fail-quest (if provided this quest will be failed for a player), `!(data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL)`: terminate when condition is true, `data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL`: terminate when condition is false +35 | SCRIPT_COMMAND_SEND_AI_EVENT_AROUND | resultingSource = Creature, resultingTarget = Unit, datalong = AIEventType - limited only to EventAI supported events, datalong2 = radius +36 | SCRIPT_COMMAND_TURN_TO | resultingSource = Creature, resultingTarget = Unit/none. + +TemporaryFactionFlags +--------------------- +* `TEMPFACTION_NONE`: 0x00, when no flag is used in temporary faction change, faction will be persistent. It will then require manual change back to default/another faction when changed once +* `TEMPFACTION_RESTORE_RESPAWN`: 0x01, default faction will be restored at respawn +* `TEMPFACTION_RESTORE_COMBAT_STOP`: 0x02, ... at CombatStop() (happens at creature death, at evade or custom script among others) +* `TEMPFACTION_RESTORE_REACH_HOME`: 0x04, ... at reaching home in home movement (evade), if not already done at CombatStop() + +The next three allow to remove unit_flags combined with a faction change (also these flags will be reapplied when the faction is changed back) + +* `TEMPFACTION_TOGGLE_NON_ATTACKABLE`: 0x08, remove UNIT_FLAG_NON_ATTACKABLE(0x02) when faction is changed (reapply when temp-faction is removed) +* `TEMPFACTION_TOGGLE_OOC_NOT_ATTACK`: 0x10, remove UNIT_FLAG_OOC_NOT_ATTACKABLE(0x100) when faction is changed (reapply when temp-faction is removed) +* `TEMPFACTION_TOGGLE_PASSIVE`: 0x20, remove UNIT_FLAG_PASSIVE(0x200) diff --git a/doc/script_commands.txt b/doc/script_commands.txt deleted file mode 100644 index 56a11992d..000000000 --- a/doc/script_commands.txt +++ /dev/null @@ -1,290 +0,0 @@ --- -------------------------- -## Script processing --- -------------------------- - -This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS. - --- -------------------------- -## id --- -------------------------- - -dbscripts_on_creature_death Creature entry -dbscripts_on_creature_movement DB project self defined id -dbscripts_on_event Event id. Several sources: spell effect 61, taxi/transport nodes, gameobject_template data -dbscripts_on_go_use Gameobject guid -dbscripts_on_go_template_use Gameobject entry -dbscripts_on_gossip DB project self defined id -dbscripts_on_quest_end DB project self defined id (generally quest entry) -dbscripts_on_quest_start DB project self defined id (generally quest entry) -dbscripts_on_spell Spell id - --- -------------------------- -## delay --- -------------------------- - -Delay in seconds -The order of which each step are executed. - --- -------------------------- -## command --- -------------------------- - -The action to execute. - --- -------------------------- -## datalong --- -------------------------- - -2 multipurpose fields, store raw data as unsigned values - --- -------------------------- -## buddy_entry --- -------------------------- - -1 field to store the entry of a "buddy" (depending on command can be both GameObject and Creature entry) - --- -------------------------- -## search_radius --- -------------------------- - -Range in which the buddy defined in buddy_entry will be searched -In case of SCRIPT_FLAG_BUDDY_BY_GUID this field is the buddy's guid! - --- -------------------------- -## data_flags --- -------------------------- - -Field which holds a combination of these flags: - - SCRIPT_FLAG_BUDDY_AS_TARGET = 0x01 - SCRIPT_FLAG_REVERSE_DIRECTION = 0x02 - SCRIPT_FLAG_SOURCE_TARGETS_SELF = 0x04 - - SCRIPT_FLAG_COMMAND_ADDITIONAL = 0x08 (Only for some commands possible) - SCRIPT_FLAG_BUDDY_BY_GUID = 0x10 (Interpret search_radius as buddy's guid) - SCRIPT_FLAG_BUDDY_IS_PET = 0x20 (Do not search for an npc, but for a pet) - -Detailed meaning described below! - --- -------------------------- -## dataint --- -------------------------- - -4 multipurpose fields, store raw data as signed values -Note: currently used only for text ids SCRIPT_COMMAND_TALK (0), - and in relation with SCRIPT_COMMAND_TERMINATE_SCRIPT (31) - --- -------------------------- -## x y z o --- -------------------------- - -Map coordinates for commands that need it. - --- -------------------------- -## origin of script and source/target in scripts --- -------------------------- - -dbscripts_on_creature_death - Creature death - Source: creature. Target: Unit (player/creature) -dbscripts_on_creature_movement - `creature_movement` `creature_movement_template` - Source: creature. Target: creature -dbscripts_on_event - Flight path - Source: player. Target: player - Transport path - Source: transport GO. Target: Transport GO - `gameobject_template` - Source: User (player/creature). Target: GO - Spell (effect 61) - Source: caster. Target: Target -dbscripts_on_go_use -dbscripts_on_go_template_use - Gameobject use - Source: user: Target: GO -dbscripts_on_gossip - `gossip_menu_option`, `gossip_menu` - Source: creature. Target: player (in case of NPC-Gossip) - Source: player. Target: GO (in case of GO-Gossip) -dbscripts_on_quest_end - `quest_template` - Source: quest taker (creature/GO). Target: player -dbscripts_on_quest_start - `quest_template` - Source: quest giver (creature/GO). Target: player -dbscripts_on_spell - Spell (effect 77 - SCRIPT_EFFECT) - Spell (effect 3 - DUMMY) - Spell (effect 64 - TRIGGER_SPELL, with non-existing triggered spell) - Source: caster: Target: target of spell (Unit) - --- -------------------------- -## Buddy concept --- -------------------------- - -Commands except the ones requiring a player (like KILL_CREDIT) have support for the buddy concept. -This means that if an entry for buddy_entry is provided, -aside from source and target as listed above also a "buddy" is available. - -Which one on the three (originalSource, originalTarget, buddy) will be used in the command, depends on the data_flags -Note that some commands (like EMOTE) use only the resulting source for an action. - -Possible combinations of the flags - SCRIPT_FLAG_BUDDY_AS_TARGET = 0x01 - SCRIPT_FLAG_REVERSE_DIRECTION = 0x02 - SCRIPT_FLAG_SOURCE_TARGETS_SELF = 0x04 -are: -0: originalSource / buddyIfProvided -> originalTarget -1: originalSource -> buddy -2: originalTarget -> originalSource / buddyIfProvided -3: buddy -> originalSource -4: originalSource / buddyIfProvided -> originalSource / buddyIfProvided -5: originalSource -> originalSource -6: originalTarget -> originalTarget -7: buddy -> buddy -Where "A -> B" means that the command is executed from A with B as target. - --- -------------------------- -## Each command has different parameters, and are as follows: --- -------------------------- - - 0 SCRIPT_COMMAND_TALK resultingSource = WorldObject, resultingTarget = Unit/none - * dataint = text entry from db_script_string -table. dataint2-dataint4 optionally, for random selection of text - - 1 SCRIPT_COMMAND_EMOTE resultingSource = Unit, resultingTarget = Unit/none - * datalong = emote_id - - 2 SCRIPT_COMMAND_FIELD_SET source = any - * datalong = field_id - * datalong2 = field value - - 3 SCRIPT_COMMAND_MOVE_TO resultingSource = Creature - If position is very near to current position, or x=y=z=0, then only orientation is changed - * datalong2 = travel_speed*100 (use 0 for creature default movement) - * data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL: teleport unit to position - * x/y/z/o - - 4 SCRIPT_COMMAND_FLAG_SET source = any - * datalong = field_id - * datalong2 = bitmask - - 5 SCRIPT_COMMAND_FLAG_REMOVE source = any - * datalong = field_id - * datalong2 = bitmask - - 6 SCRIPT_COMMAND_TELEPORT_TO source or target with Player - * datalong = map_id - * x/y/z - - 7 SCRIPT_COMMAND_QUEST_EXPLORED one from source or target must be Player, another GO/Creature - * datalong = quest_id - * datalong2 = distance or 0 - - 8 SCRIPT_COMMAND_KILL_CREDIT source or target with Player - * datalong = creature entry, or 0; If 0 the entry of the creature source or target is used - * datalong2 = bool (0=personal credit, 1=group credit) - - 9 SCRIPT_COMMAND_RESPAWN_GAMEOBJECT source = any, target = any - * datalong=db_guid (can be skipped for buddy) - * datalong2 = despawn_delay - -10 SCRIPT_COMMAND_TEMP_SUMMON_CREATURE source = any, target = any - * datalong = creature entry - * datalong2 = despawn_delay - * data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL: summon as active object - -11 SCRIPT_COMMAND_OPEN_DOOR source = any - * datalong = db_guid (can be skipped for buddy) - * datalong2 = reset_delay - -12 SCRIPT_COMMAND_CLOSE_DOOR source = any - * datalong = db_guid (can be skipped for buddy) - * datalong2 = reset_delay - -13 SCRIPT_COMMAND_ACTIVATE_OBJECT source = unit, target=GO - -14 SCRIPT_COMMAND_REMOVE_AURA resultingSource = Unit - * datalong = spell_id - -15 SCRIPT_COMMAND_CAST_SPELL resultingSource = Unit, cast spell at resultingTarget = Unit - * datalong = spell id - * data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL: cast triggered - -16 SCRIPT_COMMAND_PLAY_SOUND source = any object, target=any/player - * datalong = sound_id - * datalong2 (bitmask: 0/1=target-player, 0/2=with distance dependent, 0/4=map wide, 0/8=zone wide; - so 1|2 = 3 is target with distance dependent) - -17 SCRIPT_COMMAND_CREATE_ITEM source or target must be player - * datalong = item entry - * datalong2 = amount - -18 SCRIPT_COMMAND_DESPAWN_SELF resultingSource = Creature - * datalong = despawn delay - -19 SCRIPT_COMMAND_PLAY_MOVIE target can only be a player - * datalog = movie id - -20 SCRIPT_COMMAND_MOVEMENT resultingSource = Creature - * datalong = MovementType (0:idle, 1:random or 2:waypoint) - * datalong2 = wanderDistance (for random movement) - * data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL: RandomMovement around current position - -21 SCRIPT_COMMAND_SET_ACTIVEOBJECT resultingSource = Creature - * datalong=bool 0=off, 1=on - -22 SCRIPT_COMMAND_SET_FACTION resultingSource = Creature - * datalong=factionId OR 0 to restore original faction from creature_template - * datalong2=enum TemporaryFactionFlags - TEMPFACTION_NONE = 0x00, // When no flag is used in temporary faction change, faction will be persistent. It will then require manual change back to default/another faction when changed once - TEMPFACTION_RESTORE_RESPAWN = 0x01, // Default faction will be restored at respawn - TEMPFACTION_RESTORE_COMBAT_STOP = 0x02, // ... at CombatStop() (happens at creature death, at evade or custom scripte among others) - TEMPFACTION_RESTORE_REACH_HOME = 0x04, // ... at reaching home in home movement (evade), if not already done at CombatStop() - // The next three allow to remove unit_flags combined with a faction change (also these flags will be reapplied when the faction is changed back) - TEMPFACTION_TOGGLE_NON_ATTACKABLE = 0x08, // Remove UNIT_FLAG_NON_ATTACKABLE(0x02) when faction is changed (reapply when temp-faction is removed) - TEMPFACTION_TOGGLE_OOC_NOT_ATTACK = 0x10, // Remove UNIT_FLAG_OOC_NOT_ATTACKABLE(0x100) when faction is changed (reapply when temp-faction is removed) - TEMPFACTION_TOGGLE_PASSIVE = 0x20, // Remove UNIT_FLAG_PASSIVE(0x200) - -23 SCRIPT_COMMAND_MORPH_TO_ENTRY_OR_MODEL resultingSource = Creature - * datalong=creature entry/modelid (depend on data_flags) OR 0 to demorph - * data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL: use datalong value as modelid explicit - -24 SCRIPT_COMMAND_MOUNT_TO_ENTRY_OR_MODEL resultingSource = Creature - * datalong=creature entry/modelid (depend on data_flags) OR 0 to dismount - * data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL: use datalong value as modelid explicit - -25 SCRIPT_COMMAND_SET_RUN resultingSource = Creature - * datalong= bool 0=off, 1=on - -26 SCRIPT_COMMAND_ATTACK_START resultingSource = Creature, resultingTarget = Unit - -27 SCRIPT_COMMAND_GO_LOCK_STATE resultingSource = GO - * datalong = flag_go_lock = 0x01, flag_go_unlock = 0x02, - flag_go_nonInteract = 0x04, flag_go_interact = 0x08 - -28 SCRIPT_COMMAND_STAND_STATE resultingSource = Creature - * datalong = stand state (enum UnitStandStateType) - -29 SCRIPT_COMMAND_MODIFY_NPC_FLAGS resultingSource = Creature - * datalong=NPCFlags - * datalong2= 0x00=toggle, 0x01=add, 0x02=remove - -30 SCRIPT_COMMAND_SEND_TAXI_PATH resultingTarget or Source must be Player - * datalong = taxi path id - -31 SCRIPT_COMMAND_TERMINATE_SCRIPT * datalong = search for npc entry if provided - * datalong2= search distance - * !(data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL): if npc not alive found, terminate script - data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL: if npc alive found, terminate script - * dataint = change of waittime (MILLIESECONDS) of a current waypoint movement type (negative values will decrease time) - -32 SCRIPT_COMMAND_PAUSE_WAYPOINTS resultingSource must be Creature - * datalong: 0/1 unpause/pause waypoint movement - -33 SCRIPT_COMMAND_XP_USER source or target with Player - * datalong=bool 0=off, 1=on - -34 SCRIPT_COMMAND_TERMINATE_COND * datalong = condition_id, datalong2 = fail-quest (if provided this quest will be failed for a player) - * !(data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL): terminate when condition is true - data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL: terminate when condition is false diff --git a/icons/FORUM.gif b/icons/FORUM.gif new file mode 100644 index 000000000..3aa631526 Binary files /dev/null and b/icons/FORUM.gif differ diff --git a/icons/TOOLS.gif b/icons/TOOLS.gif new file mode 100644 index 000000000..f6d5fed3c Binary files /dev/null and b/icons/TOOLS.gif differ diff --git a/icons/TRACKER.gif b/icons/TRACKER.gif new file mode 100644 index 000000000..d85f34a28 Binary files /dev/null and b/icons/TRACKER.gif differ diff --git a/icons/WIKI.gif b/icons/WIKI.gif new file mode 100644 index 000000000..3e2a0a2ae Binary files /dev/null and b/icons/WIKI.gif differ diff --git a/sql/Install_DB.cmd b/sql/Install_DB.cmd new file mode 100644 index 000000000..b4e66fcf5 --- /dev/null +++ b/sql/Install_DB.cmd @@ -0,0 +1,273 @@ +@ECHO OFF + +set createcharDB=YES +set createworldDB=YES +set createrealmDB=YES + +set loadcharDB=YES +set loadworldDB=YES +set loadrealmDB=YES +rem -- Change the values below to match your server -- +set mysql=_tools\ +set svr=localhost +set user=mangos +set pass= +set port=3306 +set wdb=mangos1 +set cdb=character1 +set rdb=realmd + +rem -- Don't change past this point -- + +:main +color 0e +CLS +echo __ __ _ _ ___ ___ ___ +echo ^| \/ ^|__ _^| \^| ^|/ __^|/ _ \/ __^| +echo ^| ^|\/^| / _` ^| .` ^| (_ ^| (_) \__ \ +echo ^|_^| ^|_\__,_^|_^|\_^|\___^|\___/^|___/ +echo. +echo For help and support please visit: +echo Website: https://getmangos.eu +echo Wiki: http://github.com/mangoswiki +echo ======================================= +echo == Database Creator and Loader v0.01 == +echo ======================================= + +ECHO Create Character Database : %createcharDB% +ECHO Load SQL into Character Database : %loadcharDB% +ECHO. +ECHO Create World Database : %createworldDB% +ECHO Load SQL into World Database : %loadworldDB% +ECHO. +ECHO Create Realm Database : %createrealmDB% +ECHO Load SQL into Realm Database : %loadrealmDB% +ECHO. + + +echo V - Toggle Creating Character DB +echo E - Toggle Creating World DB +echo T - Toggle Creating Realm DB +echo. +echo C - Toggle Loading Character DB +echo W - Toggle Loading World DB +echo R - Toggle Loading Realm DB +echo. +echo N - Next Step +echo X - Exit +echo. +set /p activity=Please select an activity ? : +if %activity% == V goto ToggleCharDB: +if %activity% == v goto ToggleCharDB: +if %activity% == E goto ToggleWorldDB: +if %activity% == e goto ToggleWorldDB: +if %activity% == T goto ToggleRealmDB: +if %activity% == t goto ToggleRealmDB: +if %activity% == C goto LoadCharDB: +if %activity% == c goto LoadCharDB: +if %activity% == W goto LoadWorldDB: +if %activity% == w goto LoadWorldDB: +if %activity% == R goto LoadRealmDB: +if %activity% == r goto LoadRealmDB: + +if %activity% == N goto Step1: +if %activity% == n goto Step1: + +if %activity% == X goto done: +if %activity% == x goto done: +goto main + +:ToggleCharDB +if %createcharDB% == NO goto ToggleCharDBNo: +if %createcharDB% == YES goto ToggleCharDBYes: +goto main: + +:ToggleCharDBNo +set createcharDB=YES +goto main: + +:ToggleCharDBYes +set createcharDB=NO +goto main: + +:ToggleWorldDB +if %createworldDB% == NO goto ToggleWorldDBNo: +if %createworldDB% == YES goto ToggleWorldDBYes: +goto main: + +:ToggleWorldDBNo +set createworldDB=YES +goto main: + +:ToggleWorldDBYes +set createworldDB=NO +goto main: + +:ToggleRealmDB +if %createrealmDB% == NO goto ToggleRealmDBNo: +if %createrealmDB% == YES goto ToggleRealmDBYes: +goto main: + +:ToggleRealmDBNo +set createrealmDB=YES +goto main: + +:ToggleRealmDBYes +set createrealmDB=NO +goto main: + +:LoadCharDB +if %loadcharDB% == NO goto LoadCharDBNo: +if %loadcharDB% == YES goto LoadCharDBYes: +goto main: + +:LoadCharDBNo +set loadcharDB=YES +goto main: + +:LoadCharDBYes +set loadcharDB=NO +goto main: + +:LoadWorldDB +if %loadworldDB% == NO goto LoadWorldDBNo: +if %loadworldDB% == YES goto LoadWorldDBYes: +goto main: + +:LoadWorldDBNo +set loadworldDB=YES +goto main: + +:LoadWorldDBYes +set loadworldDB=NO +goto main: + +:LoadRealmDB +if %loadrealmDB% == NO goto LoadRealmDBNo: +if %loadrealmDB% == YES goto LoadRealmDBYes: +goto main: + +:LoadRealmDBNo +set loadrealmDB=YES +goto main: + +:LoadRealmDBYes +set loadrealmDB=NO +goto main: + +:Step1 +if not exist %mysql%\mysql.exe then goto patherror +color 08 +CLS +echo __ __ _ _ ___ ___ ___ +echo ^| \/ ^|__ _^| \^| ^|/ __^|/ _ \/ __^| +echo ^| ^|\/^| / _` ^| .` ^| (_ ^| (_) \__ \ +echo ^|_^| ^|_\__,_^|_^|\_^|\___^|\___/^|___/ +echo. +echo =========================================================== +echo . +set /p svr=What is your MySQL host name? [localhost] : +if %svr%. == . set svr=localhost +set /p user=What is your MySQL user name? [mangos] : +if %user%. == . set user=mangos +set /p pass=What is your MySQL password? [ ] : +if %pass%. == . set pass= +set /p port=What is your MySQL port? [3306] : +if %port%. == . set port=3306 +set /p cdb=What is your Character database name? [character1] : +if %cdb%. == . set cdb=character1 +set /p wdb=What is your World database name? [mangos1] : +if %wdb%. == . set wdb=mangos1 +set /p rdb=What is your Realm database name? [realmd] : +if %rdb%. == . set rdb=realmd + +color 02 + +:WorldDB +REM ##### IF createworlddb = YES then create the DB +if %createworldDB% == YES goto WorldDB1: + +:WorldDB2 +REM ##### IF loadworlddb = YES then load the DB +if %loadworldDB% == YES goto WorldDB3: + +:CharDB +REM ##### IF createchardb = YES then create the DB +if %createcharDB% == YES goto CharDB1: + +:CharDB2 +REM ##### IF loadchardb = YES then load the DB +if %loadcharDB% == YES goto CharDB3: + +:RealmDB +REM ##### IF createrealmdb = YES then create the DB +if %createrealmDB% == YES goto RealmDB1: + +:RealmDB2 +REM ##### IF loadrealmdb = YES then load the DB +if %loadrealmDB% == YES goto RealmDB3: + +goto done: + +:WorldDB1 +echo Creating World Database %wdb% +%mysql%mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% -e "create database %wdb%"; +goto WorldDB2: + +:WorldDB3 +echo Loading world Database %wdb% +%mysql%mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% %wdb% < mangos.sql +%mysql%mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% %wdb% < scripts/scriptdev2_create_structure_mysql.sql +goto CharDB: + +:CharDB1 +echo Creating Character Database %cdb% +%mysql%mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% -e "create database %cdb%"; +goto CharDB2: + +:CharDB3 +echo Loading Character Database %cdb% +%mysql%mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% %cdb% < characters.sql +goto RealmDB: + +:RealmDB1 +echo Creating Realm Database %rdb% +%mysql%mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% -e "create database %rdb%"; +goto RealmDB2: + +:RealmDB3 +echo Loading Realm Database %rdb% +%mysql%mysql -q -s -h %svr% --user=%user% --password=%pass% --port=%port% %rdb% < realmd.sql +goto done: + + + +:patherror +echo Cannot find required files. +pause +goto :error + + +:error +echo ======================================= +echo == Install Database Process Failed == +echo ======================================= + +goto finish: + +:done +color 08 +echo __ __ _ _ ___ ___ ___ +echo ^| \/ ^|__ _^| \^| ^|/ __^|/ _ \/ __^| +echo ^| ^|\/^| / _` ^| .` ^| (_ ^| (_) \__ \ +echo ^|_^| ^|_\__,_^|_^|\_^|\___^|\___/^|___/ +echo. +echo ======================================= +echo = Database Creation and Load complete = +echo ======================================= +echo. +echo Done :) +echo. +:finish +pause +pause \ No newline at end of file diff --git a/sql/README.md b/sql/README.md deleted file mode 100644 index b23e4b39a..000000000 --- a/sql/README.md +++ /dev/null @@ -1,69 +0,0 @@ --- FOLDERS: - -updates - contains updates for characters, mangos and realmd databases. - -tools - contains additional useful queries. - --- SQL QUERIES: - - -characters.sql - creates database in MySQL/PostgreSQL, which holds important every player character data. - - -create_mysql.sql - creates initial databases structure for MaNGOS server in MySQL server. -This query will create three databases: "characters" (its characters database), "mangos" (its world database) and "realmd" (its accounts database) - databases. Also will created new MySQL user - "mangos", which is default in MaNGOS server. - - -drop_mysql.sql - drops "characters", "realmd", "mangos" databases and user, created by create_mysql.sql query (if exists in MySQL server). - - -mangos.sql - creates empty world database. Mostly used by developers, to coordinate basic world database structure. - - -mangos_spell_check.sql - contain expected by code spell properties from simple existence to spell family mask and icons. -This data let easy detect spell properties change at client version support switch and update or drop problematic code associated with checked -spell data. Sql file not required for server work but expected to be applied to MaNGOS DB if you plan use .debug spellcheck command in console. */ - - -postgre_compatibility_addon.sql - contains queries for PostgreSQL users. Its need apply single time after DB creating or later (safe reapply) and let -correctly execute SQL queries with UNIX_TIMESTAMP/FROM_UNIXTIME functions uses in mangos/realmd code. - - -realmd.sql - creates database in MySQL/PostgreSQL, which holds player game account information. -NOTE: for testing purposes, this sql query contains four accounts data by default: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
usernamepasswordsecurity levelcomment
ADMINISTRATORADMINISTRATOR3has almost all administrator features
GAMEMASTERGAMEMASTER2has limited access
MODERATORMODERATOR1has moderator access features (chat, tickets...)
PLAYERPLAYER0its simple player account, has no access to gm commands
- -If you still want to use a clear realmd database, make sure that on these accounts no characters were created. If there is, truncate or reimport characters.sql and execute all these queries on realmd database - "truncate table account; truncate table realmcharacters;" (without quotes). diff --git a/sql/_tools/mysql.exe b/sql/_tools/mysql.exe new file mode 100644 index 000000000..9edbdae6b Binary files /dev/null and b/sql/_tools/mysql.exe differ diff --git a/sql/_tools/mysqldump.exe b/sql/_tools/mysqldump.exe new file mode 100644 index 000000000..e2dc107f9 Binary files /dev/null and b/sql/_tools/mysqldump.exe differ diff --git a/sql/characters.sql b/sql/characters.sql index 2b5cea590..afd21b130 100644 --- a/sql/characters.sql +++ b/sql/characters.sql @@ -1,20 +1,8 @@ +-- MySQL dump 10.13 Distrib 5.5.34, for debian-linux-gnu (x86_64) -- --- Copyright (C) 2005-2014 MaNGOS --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- +-- Host: localhost Database: characters +-- ------------------------------------------------------ +-- Server version 5.5.34-0ubuntu0.13.10.1 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -27,6 +15,29 @@ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `character_db_version` +-- + +DROP TABLE IF EXISTS `character_db_version`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `character_db_version` ( + `required_12712_01_characters_characters` bit(1) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `character_db_version` +-- + +LOCK TABLES `character_db_version` WRITE; +/*!40000 ALTER TABLE `character_db_version` DISABLE KEYS */; +INSERT INTO `character_db_version` VALUES +(NULL); +/*!40000 ALTER TABLE `character_db_version` ENABLE KEYS */; +UNLOCK TABLES; -- -- Table structure for table `account_data` -- @@ -60,16 +71,16 @@ DROP TABLE IF EXISTS `arena_team`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `arena_team` ( - `arenateamid` int(10) unsigned NOT NULL DEFAULT '0', + `arenateamid` int(10) unsigned NOT NULL default '0', `name` char(255) NOT NULL, - `captainguid` int(10) unsigned NOT NULL DEFAULT '0', - `type` tinyint(3) unsigned NOT NULL DEFAULT '0', - `BackgroundColor` int(10) unsigned NOT NULL DEFAULT '0', - `EmblemStyle` int(10) unsigned NOT NULL DEFAULT '0', - `EmblemColor` int(10) unsigned NOT NULL DEFAULT '0', - `BorderStyle` int(10) unsigned NOT NULL DEFAULT '0', - `BorderColor` int(10) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`arenateamid`) + `captainguid` int(10) unsigned NOT NULL default '0', + `type` tinyint(3) unsigned NOT NULL default '0', + `BackgroundColor` int(10) unsigned NOT NULL default '0', + `EmblemStyle` int(10) unsigned NOT NULL default '0', + `EmblemColor` int(10) unsigned NOT NULL default '0', + `BorderStyle` int(10) unsigned NOT NULL default '0', + `BorderColor` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`arenateamid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -90,14 +101,14 @@ DROP TABLE IF EXISTS `arena_team_member`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `arena_team_member` ( - `arenateamid` int(10) unsigned NOT NULL DEFAULT '0', - `guid` int(10) unsigned NOT NULL DEFAULT '0', - `played_week` int(10) unsigned NOT NULL DEFAULT '0', - `wons_week` int(10) unsigned NOT NULL DEFAULT '0', - `played_season` int(10) unsigned NOT NULL DEFAULT '0', - `wons_season` int(10) unsigned NOT NULL DEFAULT '0', - `personal_rating` int(10) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`arenateamid`,`guid`) + `arenateamid` int(10) unsigned NOT NULL default '0', + `guid` int(10) unsigned NOT NULL default '0', + `played_week` int(10) unsigned NOT NULL default '0', + `wons_week` int(10) unsigned NOT NULL default '0', + `played_season` int(10) unsigned NOT NULL default '0', + `wons_season` int(10) unsigned NOT NULL default '0', + `personal_rating` int(10) UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (`arenateamid`,`guid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -118,14 +129,14 @@ DROP TABLE IF EXISTS `arena_team_stats`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `arena_team_stats` ( - `arenateamid` int(10) unsigned NOT NULL DEFAULT '0', - `rating` int(10) unsigned NOT NULL DEFAULT '0', - `games_week` int(10) unsigned NOT NULL DEFAULT '0', - `wins_week` int(10) unsigned NOT NULL DEFAULT '0', - `games_season` int(10) unsigned NOT NULL DEFAULT '0', - `wins_season` int(10) unsigned NOT NULL DEFAULT '0', - `rank` int(10) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`arenateamid`) + `arenateamid` int(10) unsigned NOT NULL default '0', + `rating` int(10) unsigned NOT NULL default '0', + `games_week` int(10) unsigned NOT NULL default '0', + `wins_week` int(10) unsigned NOT NULL default '0', + `games_season` int(10) unsigned NOT NULL default '0', + `wins_season` int(10) unsigned NOT NULL default '0', + `rank` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`arenateamid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -185,7 +196,7 @@ CREATE TABLE `bugreport` ( `type` longtext NOT NULL, `content` longtext NOT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Debug System'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Debug System'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -426,29 +437,6 @@ LOCK TABLES `character_currencies` WRITE; /*!40000 ALTER TABLE `character_currencies` ENABLE KEYS */; UNLOCK TABLES; --- --- Table structure for table `character_db_version` --- - -DROP TABLE IF EXISTS `character_db_version`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `character_db_version` ( - `required_12712_01_characters_characters` bit(1) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `character_db_version` --- - -LOCK TABLES `character_db_version` WRITE; -/*!40000 ALTER TABLE `character_db_version` DISABLE KEYS */; -INSERT INTO `character_db_version` (`required_12712_01_characters_characters`) VALUES -(NULL); -/*!40000 ALTER TABLE `character_db_version` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `character_declinedname` -- @@ -457,13 +445,13 @@ DROP TABLE IF EXISTS `character_declinedname`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `character_declinedname` ( - `guid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier', - `genitive` varchar(15) NOT NULL DEFAULT '', - `dative` varchar(15) NOT NULL DEFAULT '', - `accusative` varchar(15) NOT NULL DEFAULT '', - `instrumental` varchar(15) NOT NULL DEFAULT '', - `prepositional` varchar(15) NOT NULL DEFAULT '', - PRIMARY KEY (`guid`) + `guid` int(11) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier', + `genitive` varchar(15) NOT NULL default '', + `dative` varchar(15) NOT NULL default '', + `accusative` varchar(15) NOT NULL default '', + `instrumental` varchar(15) NOT NULL default '', + `prepositional` varchar(15) NOT NULL default '', + PRIMARY KEY (`guid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; @@ -702,14 +690,14 @@ DROP TABLE IF EXISTS `character_pet_declinedname`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `character_pet_declinedname` ( - `id` int(11) unsigned NOT NULL DEFAULT '0', - `owner` int(11) unsigned NOT NULL DEFAULT '0', - `genitive` varchar(12) NOT NULL DEFAULT '', - `dative` varchar(12) NOT NULL DEFAULT '', - `accusative` varchar(12) NOT NULL DEFAULT '', - `instrumental` varchar(12) NOT NULL DEFAULT '', - `prepositional` varchar(12) NOT NULL DEFAULT '', - PRIMARY KEY (`id`), + `id` int(11) unsigned NOT NULL default '0', + `owner` int(11) unsigned NOT NULL default '0', + `genitive` varchar(12) NOT NULL default '', + `dative` varchar(12) NOT NULL default '', + `accusative` varchar(12) NOT NULL default '', + `instrumental` varchar(12) NOT NULL default '', + `prepositional` varchar(12) NOT NULL default '', + PRIMARY KEY (`id`), KEY `owner_key` (`owner`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; @@ -792,8 +780,8 @@ DROP TABLE IF EXISTS `character_queststatus_daily`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `character_queststatus_daily` ( - `guid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier', - `quest` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Quest Identifier', + `guid` int(11) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier', + `quest` int(11) unsigned NOT NULL default '0' COMMENT 'Quest Identifier', PRIMARY KEY (`guid`,`quest`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Player System'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -1013,10 +1001,10 @@ CREATE TABLE `character_stats` ( `parryPct` float unsigned NOT NULL DEFAULT '0', `critPct` float unsigned NOT NULL DEFAULT '0', `rangedCritPct` float unsigned NOT NULL DEFAULT '0', - `spellCritPct` float unsigned NOT NULL DEFAULT '0', + `spellCritPct` float UNSIGNED NOT NULL default '0', `attackPower` int(10) unsigned NOT NULL DEFAULT '0', `rangedAttackPower` int(10) unsigned NOT NULL DEFAULT '0', - `spellPower` int(10) unsigned NOT NULL DEFAULT '0', + `spellPower` int(10) UNSIGNED NOT NULL default '0', PRIMARY KEY (`guid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -1161,10 +1149,10 @@ CREATE TABLE `characters` ( `zone` int(11) unsigned NOT NULL DEFAULT '0', `death_expire_time` bigint(20) unsigned NOT NULL DEFAULT '0', `taxi_path` text, - `totalKills` int(10) unsigned NOT NULL DEFAULT '0', - `todayKills` smallint(5) unsigned NOT NULL DEFAULT '0', - `yesterdayKills` smallint(5) unsigned NOT NULL DEFAULT '0', - `chosenTitle` int(10) unsigned NOT NULL DEFAULT '0', + `totalKills` int(10) UNSIGNED NOT NULL default '0', + `todayKills` smallint(5) UNSIGNED NOT NULL default '0', + `yesterdayKills` smallint(5) UNSIGNED NOT NULL default '0', + `chosenTitle` int(10) UNSIGNED NOT NULL default '0', `watchedFaction` int(10) unsigned NOT NULL DEFAULT '0', `drunk` tinyint(3) unsigned NOT NULL DEFAULT '0', `health` int(10) unsigned NOT NULL DEFAULT '0', @@ -1270,7 +1258,7 @@ DROP TABLE IF EXISTS `game_event_status`; CREATE TABLE `game_event_status` ( `event` smallint(6) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`event`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Game event system'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Game event system'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1417,7 +1405,7 @@ CREATE TABLE `guild` ( `info` text NOT NULL, `motd` varchar(255) NOT NULL DEFAULT '', `createdate` bigint(20) unsigned NOT NULL DEFAULT '0', - `BankMoney` bigint(20) unsigned NOT NULL DEFAULT '0', + `BankMoney` bigint(20) unsigned NOT NULL default '0', PRIMARY KEY (`guildid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Guild System'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -1498,12 +1486,13 @@ DROP TABLE IF EXISTS `guild_bank_right`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `guild_bank_right` ( - `guildid` int(11) unsigned NOT NULL DEFAULT '0', - `TabId` tinyint(1) unsigned NOT NULL DEFAULT '0', - `rid` int(11) unsigned NOT NULL DEFAULT '0', - `gbright` tinyint(3) unsigned NOT NULL DEFAULT '0', - `SlotPerDay` int(11) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`guildid`,`TabId`,`rid`) + `guildid` int(11) unsigned NOT NULL default '0', + `TabId` tinyint(1) unsigned NOT NULL default '0', + `rid` int(11) unsigned NOT NULL default '0', + `gbright` tinyint(3) unsigned NOT NULL default '0', + `SlotPerDay` int(11) unsigned NOT NULL default '0', + PRIMARY KEY (`guildid`,`TabId`,`rid`), + KEY `guildid_key` (`guildid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -1524,12 +1513,13 @@ DROP TABLE IF EXISTS `guild_bank_tab`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `guild_bank_tab` ( - `guildid` int(11) unsigned NOT NULL DEFAULT '0', - `TabId` tinyint(1) unsigned NOT NULL DEFAULT '0', - `TabName` varchar(100) NOT NULL DEFAULT '', - `TabIcon` varchar(100) NOT NULL DEFAULT '', + `guildid` int(11) unsigned NOT NULL default '0', + `TabId` tinyint(1) unsigned NOT NULL default '0', + `TabName` varchar(100) NOT NULL default '', + `TabIcon` varchar(100) NOT NULL default '', `TabText` text, - PRIMARY KEY (`guildid`,`TabId`) + PRIMARY KEY (`guildid`,`TabId`), + KEY `guildid_key` (`guildid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -1586,21 +1576,22 @@ CREATE TABLE `guild_member` ( `rank` tinyint(2) unsigned NOT NULL DEFAULT '0', `pnote` varchar(255) NOT NULL DEFAULT '', `offnote` varchar(255) NOT NULL DEFAULT '', - `BankResetTimeMoney` int(11) unsigned NOT NULL DEFAULT '0', - `BankRemMoney` int(11) unsigned NOT NULL DEFAULT '0', - `BankResetTimeTab0` int(11) unsigned NOT NULL DEFAULT '0', - `BankRemSlotsTab0` int(11) unsigned NOT NULL DEFAULT '0', - `BankResetTimeTab1` int(11) unsigned NOT NULL DEFAULT '0', - `BankRemSlotsTab1` int(11) unsigned NOT NULL DEFAULT '0', - `BankResetTimeTab2` int(11) unsigned NOT NULL DEFAULT '0', - `BankRemSlotsTab2` int(11) unsigned NOT NULL DEFAULT '0', - `BankResetTimeTab3` int(11) unsigned NOT NULL DEFAULT '0', - `BankRemSlotsTab3` int(11) unsigned NOT NULL DEFAULT '0', - `BankResetTimeTab4` int(11) unsigned NOT NULL DEFAULT '0', - `BankRemSlotsTab4` int(11) unsigned NOT NULL DEFAULT '0', - `BankResetTimeTab5` int(11) unsigned NOT NULL DEFAULT '0', - `BankRemSlotsTab5` int(11) unsigned NOT NULL DEFAULT '0', + `BankResetTimeMoney` int(11) unsigned NOT NULL default '0', + `BankRemMoney` int(11) unsigned NOT NULL default '0', + `BankResetTimeTab0` int(11) unsigned NOT NULL default '0', + `BankRemSlotsTab0` int(11) unsigned NOT NULL default '0', + `BankResetTimeTab1` int(11) unsigned NOT NULL default '0', + `BankRemSlotsTab1` int(11) unsigned NOT NULL default '0', + `BankResetTimeTab2` int(11) unsigned NOT NULL default '0', + `BankRemSlotsTab2` int(11) unsigned NOT NULL default '0', + `BankResetTimeTab3` int(11) unsigned NOT NULL default '0', + `BankRemSlotsTab3` int(11) unsigned NOT NULL default '0', + `BankResetTimeTab4` int(11) unsigned NOT NULL default '0', + `BankRemSlotsTab4` int(11) unsigned NOT NULL default '0', + `BankResetTimeTab5` int(11) unsigned NOT NULL default '0', + `BankRemSlotsTab5` int(11) unsigned NOT NULL default '0', UNIQUE KEY `guid_key` (`guid`), + KEY `guildid_key` (`guildid`), KEY `guildid_rank_key` (`guildid`,`rank`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Guild System'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -1626,7 +1617,7 @@ CREATE TABLE `guild_rank` ( `rid` int(11) unsigned NOT NULL, `rname` varchar(255) NOT NULL DEFAULT '', `rights` int(3) unsigned NOT NULL DEFAULT '0', - `BankMoneyPerDay` int(11) unsigned NOT NULL DEFAULT '0', + `BankMoneyPerDay` int(11) unsigned NOT NULL default '0', PRIMARY KEY (`guildid`,`rid`), KEY `Idx_rid` (`rid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Guild System'; @@ -1652,7 +1643,7 @@ CREATE TABLE `instance` ( `id` int(11) unsigned NOT NULL DEFAULT '0', `map` int(11) unsigned NOT NULL DEFAULT '0', `resettime` bigint(40) unsigned NOT NULL DEFAULT '0', - `difficulty` tinyint(1) unsigned NOT NULL DEFAULT '0', + `difficulty` tinyint(1) unsigned NOT NULL default '0', `encountersMask` int(10) unsigned NOT NULL DEFAULT '0', `data` longtext, PRIMARY KEY (`id`), @@ -1732,7 +1723,7 @@ CREATE TABLE `item_loot` ( `owner_guid` int(11) unsigned NOT NULL DEFAULT '0', `itemid` int(11) unsigned NOT NULL DEFAULT '0', `amount` int(11) unsigned NOT NULL DEFAULT '0', - `suffix` int(11) unsigned NOT NULL DEFAULT '0', + `suffix` int(11) unsigned NOT NULL default '0', `property` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`guid`,`itemid`), KEY `idx_owner_guid` (`owner_guid`) @@ -2003,3 +1994,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +-- Dump completed diff --git a/sql/tools/README b/sql/cleanup/README similarity index 100% rename from sql/tools/README rename to sql/cleanup/README diff --git a/sql/tools/characters_item_duplicates_remove.sql b/sql/cleanup/characters_item_duplicates_remove.sql similarity index 100% rename from sql/tools/characters_item_duplicates_remove.sql rename to sql/cleanup/characters_item_duplicates_remove.sql diff --git a/sql/tools/characters_mail_items_cleanup.sql b/sql/cleanup/characters_mail_items_cleanup.sql similarity index 100% rename from sql/tools/characters_mail_items_cleanup.sql rename to sql/cleanup/characters_mail_items_cleanup.sql diff --git a/sql/tools/characters_pet_data_cleanup.sql b/sql/cleanup/characters_pet_data_cleanup.sql similarity index 100% rename from sql/tools/characters_pet_data_cleanup.sql rename to sql/cleanup/characters_pet_data_cleanup.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 54c137293..e6f177cb5 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -1,20 +1,8 @@ +-- MySQL dump 10.13 Distrib 5.5.34, for debian-linux-gnu (x86_64) -- --- Copyright (C) 2005-2014 MaNGOS --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- +-- Host: localhost Database: mangos +-- ------------------------------------------------------ +-- Server version 5.5.34-0ubuntu0.13.10.1 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -21547,7 +21535,7 @@ CREATE TABLE `world_template` ( `map` smallint(5) unsigned NOT NULL, `ScriptName` varchar(128) NOT NULL DEFAULT '', PRIMARY KEY (`map`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21568,3 +21556,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +-- Dump completed diff --git a/sql/updates/README b/sql/updates/README deleted file mode 100644 index 5181f2ddd..000000000 --- a/sql/updates/README +++ /dev/null @@ -1,59 +0,0 @@ -= MaNGOS -- README = - -This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS. - -See the COPYING file for copying conditions. - -== Database Updates == - -This folder contains SQL files which will apply required updates to your MySQL -database, whenever the MaNGOS database structure has been changed or extended. - -To see if you need an update, the file names have been given a fixed structure -that should enable you to see if you need an update or not. - -=== File Name Description === - -File names are divided into two parts. - -First part is the revision and counter that shows the commit revision that -will be compatible with the database after apply that particular update. -Counter sets the order to apply sql updates for the same revision. - -The second part of the name is the database and the table that needs an update or has been added. - -See an example below: - - 6936_01_mangos_spell_chain.sql - | | | | - | | | | - | | | The table `spell_chain` - | | | will need an update. - | | | - | | Name of affected DB (default recommended name) - | | Can be: characters, mangos, realmd - | | - | Counter show number of sql updates in updates list for provided revision - | and set proper order for sql updates for same revision - | - MaNGOS commit revision related to sql update. - It included in commit description in form [6936] as you can see at http://github.com/mangosthree/server/commits/master - -After applying an update the DB is compatible with the mangos revision of this sql update. -SQL updates include special protection against multiple and wrong order of update application. - -Attempts to apply sql updates to an older DB without previous SQL updates in list for the database -or to DB with already applied this or later SQL update will generate an error and not be applied. - -=== For Commiters ==== - -MaNGOS sources include special tool ( contrib/git_id ) for generation revision info -in commit notes and in src/shared/revision_nr.h file. It have option '-s' that let set -correct sql update names with revision number, generate sql update order guard queries, -and update version fields in mangos.sql/etc. For it use name sql updates in form -01_mangos_spell_chain.sql or 9999_01_mangos_spell_chain.sql (counter can be _01_, _02_, and etc, -dependent from sql updates amount in commit) and _not_ add to sql updates -guard queries. Include sql updates in commit. After commit adding to local repo call git_id -with -s option (and another, note: -s option not work propertly with -l option). Other steps -tool will do by self and apply changes to commit. After tool use commit with sql updates ready -to push. diff --git a/sql/updates/12335_01_creature_template_spells-patch.sql b/sql/updates/Rel18/12335_01_creature_template_spells-patch.sql similarity index 100% rename from sql/updates/12335_01_creature_template_spells-patch.sql rename to sql/updates/Rel18/12335_01_creature_template_spells-patch.sql diff --git a/sql/updates/12388_01_mangos_creature_template.sql b/sql/updates/Rel18/12388_01_mangos_creature_template.sql similarity index 100% rename from sql/updates/12388_01_mangos_creature_template.sql rename to sql/updates/Rel18/12388_01_mangos_creature_template.sql diff --git a/sql/updates/12389_01_mangos_creature_template.sql b/sql/updates/Rel18/12389_01_mangos_creature_template.sql similarity index 100% rename from sql/updates/12389_01_mangos_creature_template.sql rename to sql/updates/Rel18/12389_01_mangos_creature_template.sql diff --git a/sql/updates/12447_01_characters_calendar_events.sql b/sql/updates/Rel18/12447_01_characters_calendar_events.sql similarity index 100% rename from sql/updates/12447_01_characters_calendar_events.sql rename to sql/updates/Rel18/12447_01_characters_calendar_events.sql diff --git a/sql/updates/12447_02_characters_calendar_invites.sql b/sql/updates/Rel18/12447_02_characters_calendar_invites.sql similarity index 100% rename from sql/updates/12447_02_characters_calendar_invites.sql rename to sql/updates/Rel18/12447_02_characters_calendar_invites.sql diff --git a/sql/updates/12453_01_mangos_command.sql b/sql/updates/Rel18/12453_01_mangos_command.sql similarity index 100% rename from sql/updates/12453_01_mangos_command.sql rename to sql/updates/Rel18/12453_01_mangos_command.sql diff --git a/sql/updates/12458_01_mangos_dbscripts_on_creature_death.sql b/sql/updates/Rel18/12458_01_mangos_dbscripts_on_creature_death.sql similarity index 100% rename from sql/updates/12458_01_mangos_dbscripts_on_creature_death.sql rename to sql/updates/Rel18/12458_01_mangos_dbscripts_on_creature_death.sql diff --git a/sql/updates/12466_01_mangos_spell_script_target.sql b/sql/updates/Rel18/12466_01_mangos_spell_script_target.sql similarity index 100% rename from sql/updates/12466_01_mangos_spell_script_target.sql rename to sql/updates/Rel18/12466_01_mangos_spell_script_target.sql diff --git a/sql/updates/12472_01_mangos_npc_vendor.sql b/sql/updates/Rel18/12472_01_mangos_npc_vendor.sql similarity index 100% rename from sql/updates/12472_01_mangos_npc_vendor.sql rename to sql/updates/Rel18/12472_01_mangos_npc_vendor.sql diff --git a/sql/updates/12472_02_mangos_npc_vendor_template.sql b/sql/updates/Rel18/12472_02_mangos_npc_vendor_template.sql similarity index 100% rename from sql/updates/12472_02_mangos_npc_vendor_template.sql rename to sql/updates/Rel18/12472_02_mangos_npc_vendor_template.sql diff --git a/sql/updates/12484_01_mangos_string.sql b/sql/updates/Rel18/12484_01_mangos_string.sql similarity index 100% rename from sql/updates/12484_01_mangos_string.sql rename to sql/updates/Rel18/12484_01_mangos_string.sql diff --git a/sql/updates/12484_01_realmd_account.sql b/sql/updates/Rel18/12484_01_realmd_account.sql similarity index 100% rename from sql/updates/12484_01_realmd_account.sql rename to sql/updates/Rel18/12484_01_realmd_account.sql diff --git a/sql/updates/12484_02_realmd_account_access.sql b/sql/updates/Rel18/12484_02_realmd_account_access.sql similarity index 100% rename from sql/updates/12484_02_realmd_account_access.sql rename to sql/updates/Rel18/12484_02_realmd_account_access.sql diff --git a/sql/updates/12552_01_mangos_item_enchantment_template.sql b/sql/updates/Rel18/12552_01_mangos_item_enchantment_template.sql similarity index 99% rename from sql/updates/12552_01_mangos_item_enchantment_template.sql rename to sql/updates/Rel18/12552_01_mangos_item_enchantment_template.sql index 3df718fd9..10d448b9d 100644 --- a/sql/updates/12552_01_mangos_item_enchantment_template.sql +++ b/sql/updates/Rel18/12552_01_mangos_item_enchantment_template.sql @@ -1,3 +1,3 @@ -ALTER TABLE db_version CHANGE COLUMN required_c12484_01_mangos_string required_c12552_01_mangos_item_enchantment_template bit; - +ALTER TABLE db_version CHANGE COLUMN required_c12484_01_mangos_string required_c12552_01_mangos_item_enchantment_template bit; + ALTER TABLE item_enchantment_template MODIFY COLUMN entry mediumint(8) NOT NULL DEFAULT '0'; \ No newline at end of file diff --git a/sql/updates/12564_01_mangos_spell_template.sql b/sql/updates/Rel18/12564_01_mangos_spell_template.sql similarity index 100% rename from sql/updates/12564_01_mangos_spell_template.sql rename to sql/updates/Rel18/12564_01_mangos_spell_template.sql diff --git a/sql/updates/12594_01_mangos_spell_template.sql b/sql/updates/Rel18/12594_01_mangos_spell_template.sql similarity index 100% rename from sql/updates/12594_01_mangos_spell_template.sql rename to sql/updates/Rel18/12594_01_mangos_spell_template.sql diff --git a/sql/updates/12601_01_mangos_spell_area.sql b/sql/updates/Rel18/12601_01_mangos_spell_area.sql similarity index 100% rename from sql/updates/12601_01_mangos_spell_area.sql rename to sql/updates/Rel18/12601_01_mangos_spell_area.sql diff --git a/sql/updates/12602_01_mangos_npc_spellclick_spells.sql b/sql/updates/Rel18/12602_01_mangos_npc_spellclick_spells.sql similarity index 100% rename from sql/updates/12602_01_mangos_npc_spellclick_spells.sql rename to sql/updates/Rel18/12602_01_mangos_npc_spellclick_spells.sql diff --git a/sql/updates/12631_01_characters_corpse.sql b/sql/updates/Rel18/12631_01_characters_corpse.sql similarity index 100% rename from sql/updates/12631_01_characters_corpse.sql rename to sql/updates/Rel18/12631_01_characters_corpse.sql diff --git a/sql/updates/12631_01_mangos_creature.sql b/sql/updates/Rel18/12631_01_mangos_creature.sql similarity index 100% rename from sql/updates/12631_01_mangos_creature.sql rename to sql/updates/Rel18/12631_01_mangos_creature.sql diff --git a/sql/updates/12631_02_mangos_gameobject.sql b/sql/updates/Rel18/12631_02_mangos_gameobject.sql similarity index 100% rename from sql/updates/12631_02_mangos_gameobject.sql rename to sql/updates/Rel18/12631_02_mangos_gameobject.sql diff --git a/sql/updates/12654_01_mangos_command.sql b/sql/updates/Rel18/12654_01_mangos_command.sql similarity index 100% rename from sql/updates/12654_01_mangos_command.sql rename to sql/updates/Rel18/12654_01_mangos_command.sql diff --git a/sql/updates/12662_01_mangos_hotfix_data.sql b/sql/updates/Rel18/12662_01_mangos_hotfix_data.sql similarity index 100% rename from sql/updates/12662_01_mangos_hotfix_data.sql rename to sql/updates/Rel18/12662_01_mangos_hotfix_data.sql diff --git a/sql/updates/12697_01_characters_characters.sql b/sql/updates/Rel18/12697_01_characters_characters.sql similarity index 100% rename from sql/updates/12697_01_characters_characters.sql rename to sql/updates/Rel18/12697_01_characters_characters.sql diff --git a/sql/updates/12712_01_characters_characters.sql b/sql/updates/Rel18/12712_01_characters_characters.sql similarity index 100% rename from sql/updates/12712_01_characters_characters.sql rename to sql/updates/Rel18/12712_01_characters_characters.sql diff --git a/sql/updates/12712_01_mangos.sql b/sql/updates/Rel18/12712_01_mangos.sql similarity index 100% rename from sql/updates/12712_01_mangos.sql rename to sql/updates/Rel18/12712_01_mangos.sql diff --git a/sql/updates/12712_02_mangos_command.sql b/sql/updates/Rel18/12712_02_mangos_command.sql similarity index 100% rename from sql/updates/12712_02_mangos_command.sql rename to sql/updates/Rel18/12712_02_mangos_command.sql diff --git a/sql/updates/12738_01_mangos_spell_template.sql b/sql/updates/Rel18/12738_01_mangos_spell_template.sql similarity index 100% rename from sql/updates/12738_01_mangos_spell_template.sql rename to sql/updates/Rel18/12738_01_mangos_spell_template.sql diff --git a/sql/updates/12741_01_mangos.sql b/sql/updates/Rel18/12741_01_mangos.sql similarity index 100% rename from sql/updates/12741_01_mangos.sql rename to sql/updates/Rel18/12741_01_mangos.sql diff --git a/sql/updates/12751_01_mangos_phase.sql b/sql/updates/Rel18/12751_01_mangos_phase.sql similarity index 100% rename from sql/updates/12751_01_mangos_phase.sql rename to sql/updates/Rel18/12751_01_mangos_phase.sql diff --git a/sql/updates/12752_01_mangos_reputation_spillover_template.sql b/sql/updates/Rel18/12752_01_mangos_reputation_spillover_template.sql similarity index 100% rename from sql/updates/12752_01_mangos_reputation_spillover_template.sql rename to sql/updates/Rel18/12752_01_mangos_reputation_spillover_template.sql diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index 8b0704c57..1472822d2 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -1,5 +1,4 @@ -# -# This file is part of the MaNGOS Project. See AUTHORS file for Copyright information +# This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,7 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# set(LIBRARY_NAME framework) @@ -102,17 +100,14 @@ source_group("Utilities\\LinkedReference" ) include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${ACE_INCLUDE_DIR} + "${CMAKE_CURRENT_SOURCE_DIR}" + "${ACE_INCLUDE_DIR}" ) add_library(${LIBRARY_NAME} STATIC ${LIBRARY_SRCS} ) -if(NOT TBB_USE_EXTERNAL) - add_dependencies(${LIBRARY_NAME} TBB_Project) -endif() if(NOT ACE_USE_EXTERNAL) add_dependencies(${LIBRARY_NAME} ACE_Project) endif() diff --git a/src/framework/Dynamic/FactoryHolder.h b/src/framework/Dynamic/FactoryHolder.h index 0e1e1ca7e..c2c3f8f55 100644 --- a/src/framework/Dynamic/FactoryHolder.h +++ b/src/framework/Dynamic/FactoryHolder.h @@ -30,37 +30,85 @@ #include "ObjectRegistry.h" #include "Policies/Singleton.h" -/** FactoryHolder holds a factory object of a specific type - */ template < class T, class Key = std::string > +/** + * @brief FactoryHolder holds a factory object of a specific type + * + */ class MANGOS_DLL_DECL FactoryHolder { public: + /** + * @brief + * + */ typedef ObjectRegistry, Key > FactoryHolderRegistry; + /** + * @brief + * + */ typedef MaNGOS::Singleton FactoryHolderRepository; + /** + * @brief + * + * @param k + */ FactoryHolder(Key k) : i_key(k) {} + /** + * @brief + * + */ virtual ~FactoryHolder() {} + /** + * @brief + * + * @return Key + */ inline Key key() const { return i_key; } + /** + * @brief + * + */ void RegisterSelf(void) { FactoryHolderRepository::Instance().InsertItem(this, i_key); } + /** + * @brief + * + */ void DeregisterSelf(void) { FactoryHolderRepository::Instance().RemoveItem(this, false); } - /// Abstract Factory create method + /** + * @brief Abstract Factory create method + * + * @param data + * @return T + */ virtual T* Create(void* data = NULL) const = 0; private: - Key i_key; + Key i_key; /**< TODO */ }; -/** Permissible is a classic way of letting the object decide - * whether how good they handle things. This is not retricted - * to factory selectors. - */ template +/** + * @brief Permissible is a classic way of letting the object decide whether how good they handle things. + * + * This is not retricted to factory selectors. + */ class Permissible { public: + /** + * @brief + * + */ virtual ~Permissible() {} + /** + * @brief + * + * @param + * @return int + */ virtual int Permit(const T*) const = 0; }; #endif diff --git a/src/framework/Dynamic/ObjectRegistry.h b/src/framework/Dynamic/ObjectRegistry.h index f1f268cb9..4a7206fb0 100644 --- a/src/framework/Dynamic/ObjectRegistry.h +++ b/src/framework/Dynamic/ObjectRegistry.h @@ -33,29 +33,47 @@ #include #include -/** ObjectRegistry holds all registry item of the same type - */ template < class T, class Key = std::string > +/** + * @brief ObjectRegistry holds all registry item of the same type + * + */ class MANGOS_DLL_DECL ObjectRegistry { public: + /** + * @brief + * + */ typedef std::map RegistryMapType; - /// Returns a registry item + /** + * @brief Returns a registry item + * + * @param key + * @return const T + */ const T* GetRegistryItem(Key key) const { typename RegistryMapType::const_iterator iter = i_registeredObjects.find(key); - return (iter == i_registeredObjects.end() ? NULL : iter->second); + return(iter == i_registeredObjects.end() ? NULL : iter->second); } - /// Inserts a registry item + /** + * @brief Inserts a registry item + * + * @param obj + * @param key + * @param replace + * @return bool + */ bool InsertItem(T* obj, Key key, bool replace = false) { typename RegistryMapType::iterator iter = i_registeredObjects.find(key); if (iter != i_registeredObjects.end()) { if (!replace) - return false; + { return false; } delete iter->second; i_registeredObjects.erase(iter); } @@ -64,50 +82,76 @@ class MANGOS_DLL_DECL ObjectRegistry return true; } - /// Removes a registry item + /** + * @brief Removes a registry item + * + * @param key + * @param delete_object + */ void RemoveItem(Key key, bool delete_object = true) { typename RegistryMapType::iterator iter = i_registeredObjects.find(key); if (iter != i_registeredObjects.end()) { if (delete_object) - delete iter->second; + { delete iter->second; } i_registeredObjects.erase(iter); } } - /// Returns true if registry contains an item + /** + * @brief Returns true if registry contains an item + * + * @param key + * @return bool + */ bool HasItem(Key key) const { return (i_registeredObjects.find(key) != i_registeredObjects.end()); } - /// Inefficiently return a vector of registered items + /** + * @brief Inefficiently return a vector of registered items + * + * @param l + * @return unsigned int + */ unsigned int GetRegisteredItems(std::vector& l) const { unsigned int sz = l.size(); l.resize(sz + i_registeredObjects.size()); for (typename RegistryMapType::const_iterator iter = i_registeredObjects.begin(); iter != i_registeredObjects.end(); ++iter) - l[sz++] = iter->first; + { l[sz++] = iter->first; } return i_registeredObjects.size(); } - /// Return the map of registered items + /** + * @brief Return the map of registered items + * + * @return const RegistryMapType + */ RegistryMapType const& GetRegisteredItems() const { return i_registeredObjects; } private: - RegistryMapType i_registeredObjects; + RegistryMapType i_registeredObjects; /**< TODO */ friend class MaNGOS::OperatorNew >; - // protected for friend use since it should be a singleton + /** + * @brief protected for friend use since it should be a singleton + * + */ ObjectRegistry() {} + /** + * @brief + * + */ ~ObjectRegistry() { for (typename RegistryMapType::iterator iter = i_registeredObjects.begin(); iter != i_registeredObjects.end(); ++iter) - delete iter->second; + { delete iter->second; } i_registeredObjects.clear(); } }; diff --git a/src/framework/GameSystem/Grid.h b/src/framework/GameSystem/Grid.h index 980ecbbaa..97c5fb4ca 100644 --- a/src/framework/GameSystem/Grid.h +++ b/src/framework/GameSystem/Grid.h @@ -25,17 +25,6 @@ #ifndef MANGOS_GRID_H #define MANGOS_GRID_H -/* - @class Grid - Grid is a logical segment of the game world represented inside MaNGOS. - Grid is bind at compile time to a particular type of object which - we call it the object of interested. There are many types of loader, - specially, dynamic loader, static loader, or on-demand loader. There's - a subtle difference between dynamic loader and on-demand loader but - this is implementation specific to the loader class. From the - Grid's perspective, the loader meets its API requirement is suffice. -*/ - #include "Platform/Define.h" #include "Policies/ThreadingModel.h" #include "TypeContainer.h" @@ -50,6 +39,16 @@ class ACTIVE_OBJECT, class WORLD_OBJECT_TYPES, class GRID_OBJECT_TYPES > +/** + * @brief Grid is a logical segment of the game world represented inside MaNGOS. + * + * Grid is bind at compile time to a particular type of object which + * we call it the object of interested. There are many types of loader, + * specially, dynamic loader, static loader, or on-demand loader. There's + * a subtle difference between dynamic loader and on-demand loader but + * this is implementation specific to the loader class. From the + * Grid's perspective, the loader meets its API requirement is suffice. + */ class MANGOS_DLL_DECL Grid { // allows the GridLoader to access its internals @@ -57,78 +56,111 @@ class MANGOS_DLL_DECL Grid public: - /** destructor to clean up its resources. This includes unloading the - grid if it has not been unload. - */ + /** + * @brief destructor to clean up its resources. This includes unloading + * the grid if it has not been unload. + * + */ ~Grid() {} - /** an object of interested enters the grid - */ template + /** + * @brief an object of interested enters the grid + * + * @param obj + * @return bool + */ bool AddWorldObject(SPECIFIC_OBJECT* obj) { return i_objects.template insert(obj); } - /** an object of interested exits the grid - */ template + /** + * @brief an object of interested exits the grid + * + * @param obj + * @return bool + */ bool RemoveWorldObject(SPECIFIC_OBJECT* obj) { return i_objects.template remove(obj); } - /** Grid visitor for grid objects - */ template + /** + * @brief Grid visitor for grid objects + * + * @param TypeContainerVisitor >& visitor) { visitor.Visit(i_container); } - /** Grid visitor for world objects - */ template + /** + * @brief Grid visitor for world objects + * + * @param TypeContainerVisitor >& visitor) { visitor.Visit(i_objects); } - /** Returns the number of object within the grid. + /** + * @brief Returns the number of object within the grid. + * + * @return uint32 */ uint32 ActiveObjectsInGrid() const { return m_activeGridObjects.size() + i_objects.template Count(); } - /** Inserts a container type object into the grid. - */ template + /** + * @brief Inserts a container type object into the grid. + * + * @param obj + * @return bool + */ bool AddGridObject(SPECIFIC_OBJECT* obj) { if (obj->isActiveObject()) - m_activeGridObjects.insert(obj); + { m_activeGridObjects.insert(obj); } return i_container.template insert(obj); } - /** Removes a containter type object from the grid - */ template + /** + * @brief Removes a container type object from the grid + * + * @param obj + * @return bool + */ bool RemoveGridObject(SPECIFIC_OBJECT* obj) { if (obj->isActiveObject()) - m_activeGridObjects.erase(obj); + { m_activeGridObjects.erase(obj); } return i_container.template remove(obj); } private: - TypeMapContainer i_container; - TypeMapContainer i_objects; + TypeMapContainer i_container; /**< TODO */ + TypeMapContainer i_objects; /**< TODO */ + /** + * @brief + * + */ typedef std::set ActiveGridObjects; - ActiveGridObjects m_activeGridObjects; + ActiveGridObjects m_activeGridObjects; /**< TODO */ }; #endif diff --git a/src/framework/GameSystem/GridLoader.h b/src/framework/GameSystem/GridLoader.h index f7c244782..2b4dbf5dc 100644 --- a/src/framework/GameSystem/GridLoader.h +++ b/src/framework/GameSystem/GridLoader.h @@ -25,17 +25,6 @@ #ifndef MANGOS_GRIDLOADER_H #define MANGOS_GRIDLOADER_H -/** - @class GridLoader - The GridLoader is working in conjuction with the Grid and responsible - for loading and unloading object-types (one or more) when objects - enters a grid. Unloading is scheduled and might be canceled if - an interested object re-enters. GridLoader does not do the actuall - loading and unloading but implements as a template pattern that - delicate its loading and unloading for the actualy loader and unloader. - GridLoader manages the grid (both local and remote). - */ - #include "Platform/Define.h" #include "Grid.h" #include "TypeContainerVisitor.h" @@ -46,29 +35,57 @@ class ACTIVE_OBJECT, class WORLD_OBJECT_TYPES, class GRID_OBJECT_TYPES > +/** + * @brief The GridLoader is working in conjuction with the Grid and responsible + * for loading and unloading object-types (one or more) when objects + * enters a grid. + * Unloading is scheduled and might be canceled if an interested object re-enters. + * GridLoader does not do the actual loading and unloading but implements as a + * template pattern that delicate its loading and unloading for the actually + * loader and unloader. GridLoader manages the grid (both local and remote). + * + */ class MANGOS_DLL_DECL GridLoader { public: - /** Loads the grid - */ template + /** + * @brief Loads the grid + * + * @param Grid& grid, LOADER& loader) { loader.Load(grid); } - /** Stop the grid - */ template + /** + * @brief Stop the grid + * + * @param Grid& grid, STOPER& stoper) { stoper.Stop(grid); } - /** Unloads the grid - */ template + /** + * @brief Unloads the grid + * + * @param Grid& grid, UNLOADER& unloader) { unloader.Unload(grid); diff --git a/src/framework/GameSystem/GridRefManager.h b/src/framework/GameSystem/GridRefManager.h index 76a65e84e..8bba95f04 100644 --- a/src/framework/GameSystem/GridRefManager.h +++ b/src/framework/GameSystem/GridRefManager.h @@ -30,25 +30,63 @@ template class GridReference; template +/** + * @brief + * + */ class GridRefManager : public RefManager, OBJECT> { public: + /** + * @brief + * + */ typedef LinkedListHead::Iterator< GridReference > iterator; + /** + * @brief + * + * @return GridReference + */ GridReference* getFirst() { return (GridReference*)RefManager, OBJECT>::getFirst(); } + /** + * @brief + * + * @return GridReference + */ GridReference* getLast() { return (GridReference*)RefManager, OBJECT>::getLast(); } + /** + * @brief + * + * @return iterator + */ iterator begin() { return iterator(getFirst()); } + /** + * @brief + * + * @return iterator + */ iterator end() { return iterator(NULL); } + /** + * @brief + * + * @return iterator + */ iterator rbegin() { return iterator(getLast()); } + /** + * @brief + * + * @return iterator + */ iterator rend() { return iterator(NULL); } }; #endif diff --git a/src/framework/GameSystem/GridReference.h b/src/framework/GameSystem/GridReference.h index 0b264ccfc..e328851a5 100644 --- a/src/framework/GameSystem/GridReference.h +++ b/src/framework/GameSystem/GridReference.h @@ -22,18 +22,26 @@ * and lore are copyrighted by Blizzard Entertainment, Inc. */ -#ifndef _GRIDREFERENCE_H -#define _GRIDREFERENCE_H +#ifndef MANGOS_H_GRIDREFERENCE +#define MANGOS_H_GRIDREFERENCE #include "Utilities/LinkedReference/Reference.h" template class GridRefManager; template +/** + * @brief + * + */ class MANGOS_DLL_SPEC GridReference : public Reference, OBJECT> { protected: + /** + * @brief + * + */ void targetObjectBuildLink() override { // called from link() @@ -41,13 +49,21 @@ class MANGOS_DLL_SPEC GridReference : public Reference, O this->getTarget()->incSize(); } + /** + * @brief + * + */ void targetObjectDestroyLink() override { // called from unlink() if (this->isValid()) - this->getTarget()->decSize(); + { this->getTarget()->decSize(); } } + /** + * @brief + * + */ void sourceObjectDestroyLink() override { // called from invalidate() @@ -55,17 +71,29 @@ class MANGOS_DLL_SPEC GridReference : public Reference, O } public: - + /** + * @brief + * + */ GridReference() : Reference, OBJECT>() { } + /** + * @brief + * + */ ~GridReference() { this->unlink(); } + /** + * @brief + * + * @return GridReference + */ GridReference* next() { return (GridReference*)Reference, OBJECT>::next(); diff --git a/src/framework/GameSystem/NGrid.h b/src/framework/GameSystem/NGrid.h index b8e66da94..d681b3884 100644 --- a/src/framework/GameSystem/NGrid.h +++ b/src/framework/GameSystem/NGrid.h @@ -25,51 +25,104 @@ #ifndef MANGOS_NGRID_H #define MANGOS_NGRID_H -/** NGrid is nothing more than a wrapper of the Grid with an NxN cells - */ - #include "GameSystem/Grid.h" #include "GameSystem/GridReference.h" #include "Timer.h" #include +/** + * @brief NGrid is nothing more than a wrapper of the Grid with an NxN cells + * + */ class GridInfo { public: + /** + * @brief + * + */ GridInfo() : i_timer(0), i_unloadActiveLockCount(0), i_unloadExplicitLock(false) { } + /** + * @brief + * + * @param expiry + * @param unload + */ GridInfo(time_t expiry, bool unload = true) : i_timer(expiry), i_unloadActiveLockCount(0), i_unloadExplicitLock(!unload) { } + /** + * @brief + * + * @return const TimeTracker + */ const TimeTracker& getTimeTracker() const { return i_timer; } + /** + * @brief + * + * @return bool + */ bool getUnloadLock() const { return i_unloadActiveLockCount || i_unloadExplicitLock; } + /** + * @brief + * + * @param on + */ void setUnloadExplicitLock(bool on) { i_unloadExplicitLock = on; } + /** + * @brief + * + */ void incUnloadActiveLock() { ++i_unloadActiveLockCount; } - void decUnloadActiveLock() { if (i_unloadActiveLockCount) --i_unloadActiveLockCount; } + /** + * @brief + * + */ + void decUnloadActiveLock() { if (i_unloadActiveLockCount) { --i_unloadActiveLockCount; } } + /** + * @brief + * + * @param pTimer + */ void setTimer(const TimeTracker& pTimer) { i_timer = pTimer; } + /** + * @brief + * + * @param interval + */ void ResetTimeTracker(time_t interval) { i_timer.Reset(interval); } + /** + * @brief + * + * @param diff + */ void UpdateTimeTracker(time_t diff) { i_timer.Update(diff); } private: - TimeTracker i_timer; - uint16 i_unloadActiveLockCount : 16; // lock from active object spawn points (prevent clone loading) - bool i_unloadExplicitLock : 1; // explicit manual lock or config setting + TimeTracker i_timer; /**< TODO */ + uint16 i_unloadActiveLockCount : 16; /**< lock from active object spawn points (prevent clone loading) */ + bool i_unloadExplicitLock : 1; /**< explicit manual lock or config setting */ }; +/** + * @brief + * + */ typedef enum { GRID_STATE_INVALID = 0, @@ -86,18 +139,42 @@ uint32 N, class WORLD_OBJECT_TYPES, class GRID_OBJECT_TYPES > +/** + * @brief + * + */ class MANGOS_DLL_DECL NGrid { public: + /** + * @brief + * + */ typedef Grid GridType; + /** + * @brief + * + * @param id + * @param x + * @param y + * @param expiry + * @param unload + */ NGrid(uint32 id, uint32 x, uint32 y, time_t expiry, bool unload = true) : i_gridId(id), i_x(x), i_y(y), i_cellstate(GRID_STATE_INVALID), i_GridObjectDataLoaded(false) { i_GridInfo = GridInfo(expiry, unload); } + /** + * @brief + * + * @param x + * @param y + * @return const GridType &operator + */ const GridType& operator()(uint32 x, uint32 y) const { assert(x < N); @@ -105,6 +182,13 @@ class MANGOS_DLL_DECL NGrid return i_cells[x][y]; } + /** + * @brief + * + * @param x + * @param y + * @return GridType &operator + */ GridType& operator()(uint32 x, uint32 y) { assert(x < N); @@ -112,73 +196,208 @@ class MANGOS_DLL_DECL NGrid return i_cells[x][y]; } + /** + * @brief + * + * @return const uint32 + */ const uint32& GetGridId() const { return i_gridId; } + /** + * @brief + * + * @param id + */ void SetGridId(const uint32 id) { i_gridId = id; } + /** + * @brief + * + * @return grid_state_t + */ grid_state_t GetGridState() const { return i_cellstate; } + /** + * @brief + * + * @param s + */ void SetGridState(grid_state_t s) { i_cellstate = s; } + /** + * @brief + * + * @return uint32 + */ uint32 getX() const { return i_x; } + /** + * @brief + * + * @return uint32 + */ uint32 getY() const { return i_y; } + /** + * @brief + * + * @param GridRefManager >* pTo) { i_Reference.link(pTo, this); } + /** + * @brief + * + * @return bool + */ bool isGridObjectDataLoaded() const { return i_GridObjectDataLoaded; } + /** + * @brief + * + * @param pLoaded + */ void setGridObjectDataLoaded(bool pLoaded) { i_GridObjectDataLoaded = pLoaded; } + /** + * @brief + * + * @return GridInfo + */ GridInfo* getGridInfoRef() { return &i_GridInfo; } + /** + * @brief + * + * @return const TimeTracker + */ const TimeTracker& getTimeTracker() const { return i_GridInfo.getTimeTracker(); } + /** + * @brief + * + * @return bool + */ bool getUnloadLock() const { return i_GridInfo.getUnloadLock(); } + /** + * @brief + * + * @param on + */ void setUnloadExplicitLock(bool on) { i_GridInfo.setUnloadExplicitLock(on); } + /** + * @brief + * + */ void incUnloadActiveLock() { i_GridInfo.incUnloadActiveLock(); } + /** + * @brief + * + */ void decUnloadActiveLock() { i_GridInfo.decUnloadActiveLock(); } + /** + * @brief + * + * @param interval + */ void ResetTimeTracker(time_t interval) { i_GridInfo.ResetTimeTracker(interval); } + /** + * @brief + * + * @param diff + */ void UpdateTimeTracker(time_t diff) { i_GridInfo.UpdateTimeTracker(diff); } template + /** + * @brief + * + * @param x + * @param y + * @param obj + */ void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT* obj) { getGridType(x, y).AddWorldObject(obj); } template + /** + * @brief + * + * @param x + * @param y + * @param obj + */ void RemoveWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT* obj) { getGridType(x, y).RemoveWorldObject(obj); } template + /** + * @brief + * + * @param TypeContainerVisitor >& visitor) { for (uint32 x = 0; x < N; ++x) for (uint32 y = 0; y < N; ++y) - i_cells[x][y].Visit(visitor); + { i_cells[x][y].Visit(visitor); } } template + /** + * @brief + * + * @param x + * @param y + * @param TypeContainerVisitor >& visitor) { getGridType(x, y).Visit(visitor); } + /** + * @brief + * + * @return uint32 + */ uint32 ActiveObjectsInGrid() const { uint32 count = 0; for (uint32 x = 0; x < N; ++x) for (uint32 y = 0; y < N; ++y) - count += i_cells[x][y].ActiveObjectsInGrid(); + { count += i_cells[x][y].ActiveObjectsInGrid(); } return count; } template + /** + * @brief + * + * @param x + * @param y + * @param obj + * @return bool + */ bool AddGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT* obj) { return getGridType(x, y).AddGridObject(obj); } template + /** + * @brief + * + * @param x + * @param y + * @param obj + * @return bool + */ bool RemoveGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT* obj) { return getGridType(x, y).RemoveGridObject(obj); @@ -186,6 +405,13 @@ class MANGOS_DLL_DECL NGrid private: + /** + * @brief + * + * @param x + * @param y + * @return GridType + */ GridType& getGridType(const uint32& x, const uint32& y) { assert(x < N); @@ -193,14 +419,14 @@ class MANGOS_DLL_DECL NGrid return i_cells[x][y]; } - uint32 i_gridId; - GridInfo i_GridInfo; - GridReference > i_Reference; - uint32 i_x; - uint32 i_y; - grid_state_t i_cellstate; - GridType i_cells[N][N]; - bool i_GridObjectDataLoaded; + uint32 i_gridId; /**< TODO */ + GridInfo i_GridInfo; /**< TODO */ + GridReference > i_Reference; /**< TODO */ + uint32 i_x; /**< TODO */ + uint32 i_y; /**< TODO */ + grid_state_t i_cellstate; /**< TODO */ + GridType i_cells[N][N]; /**< TODO */ + bool i_GridObjectDataLoaded; /**< TODO */ }; #endif diff --git a/src/framework/GameSystem/TypeContainer.h b/src/framework/GameSystem/TypeContainer.h index b9eb711fc..937261fc6 100644 --- a/src/framework/GameSystem/TypeContainer.h +++ b/src/framework/GameSystem/TypeContainer.h @@ -39,41 +39,78 @@ #include "GameSystem/GridRefManager.h" template +/** + * @brief + * + */ struct ContainerUnorderedMap { - UNORDERED_MAP _element; + UNORDERED_MAP _element; /**< TODO */ }; template +/** + * @brief + * + */ struct ContainerUnorderedMap { }; template +/** + * @brief + * + */ struct ContainerUnorderedMap< TypeList, KEY_TYPE > { - ContainerUnorderedMap _elements; - ContainerUnorderedMap _TailElements; + ContainerUnorderedMap _elements; /**< TODO */ + ContainerUnorderedMap _TailElements; /**< TODO */ }; template < class OBJECT_TYPES, class KEY_TYPE = OBJECT_HANDLE > +/** + * @brief + * + */ class TypeUnorderedMapContainer { public: template + /** + * @brief + * + * @param handle + * @param obj + * @return bool + */ bool insert(KEY_TYPE handle, SPECIFIC_TYPE* obj) { return TypeUnorderedMapContainer::insert(i_elements, handle, obj); } template + /** + * @brief + * + * @param handle + * @param + * @return bool + */ bool erase(KEY_TYPE handle, SPECIFIC_TYPE* /*obj*/) { return TypeUnorderedMapContainer::erase(i_elements, handle, (SPECIFIC_TYPE*)NULL); } template + /** + * @brief + * + * @param hdl + * @param + * @return SPECIFIC_TYPE + */ SPECIFIC_TYPE* find(KEY_TYPE hdl, SPECIFIC_TYPE* /*obj*/) { return TypeUnorderedMapContainer::find(i_elements, hdl, (SPECIFIC_TYPE*)NULL); @@ -81,11 +118,19 @@ class TypeUnorderedMapContainer private: - ContainerUnorderedMap i_elements; + ContainerUnorderedMap i_elements; /**< TODO */ // Helpers - // Insert helpers template + /** + * @brief Insert helpers + * + * @param ContainerUnorderedMap& elements, KEY_TYPE handle, SPECIFIC_TYPE* obj) { typename UNORDERED_MAP::iterator i = elements._element.find(handle); @@ -102,18 +147,46 @@ class TypeUnorderedMapContainer } template + /** + * @brief + * + * @param ContainerUnorderedMap& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/) { return false; } template + /** + * @brief + * + * @param ContainerUnorderedMap& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/) { return false; } template + /** + * @brief + * + * @param ContainerUnorderedMap + * @param elements + * @param handle + * @param obj + * @return bool + */ static bool insert(ContainerUnorderedMap< TypeList, KEY_TYPE >& elements, KEY_TYPE handle, SPECIFIC_TYPE* obj) { bool ret = TypeUnorderedMapContainer::insert(elements._elements, handle, obj); @@ -122,28 +195,65 @@ class TypeUnorderedMapContainer // Find helpers template + /** + * @brief + * + * @param ContainerUnorderedMap& elements, KEY_TYPE hdl, SPECIFIC_TYPE* /*obj*/) { typename UNORDERED_MAP::iterator i = elements._element.find(hdl); if (i == elements._element.end()) - return NULL; + { return NULL; } else - return i->second; + { return i->second; } } template + /** + * @brief + * + * @param ContainerUnorderedMap& /*elements*/, KEY_TYPE /*hdl*/, SPECIFIC_TYPE* /*obj*/) { return NULL; } template + /** + * @brief + * + * @param ContainerUnorderedMap& /*elements*/, KEY_TYPE /*hdl*/, SPECIFIC_TYPE* /*obj*/) { return NULL; } template + /** + * @brief + * + * @param ContainerUnorderedMap + * @param elements + * @param hdl + * @param + * @return SPECIFIC_TYPE + */ static SPECIFIC_TYPE* find(ContainerUnorderedMap< TypeList, KEY_TYPE >& elements, KEY_TYPE hdl, SPECIFIC_TYPE* /*obj*/) { SPECIFIC_TYPE* ret = TypeUnorderedMapContainer::find(elements._elements, hdl, (SPECIFIC_TYPE*)NULL); @@ -152,6 +262,15 @@ class TypeUnorderedMapContainer // Erase helpers template + /** + * @brief + * + * @param ContainerUnorderedMap& elements, KEY_TYPE handle, SPECIFIC_TYPE* /*obj*/) { elements._element.erase(handle); @@ -160,18 +279,46 @@ class TypeUnorderedMapContainer } template + /** + * @brief + * + * @param ContainerUnorderedMap& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/) { return false; } template + /** + * @brief + * + * @param ContainerUnorderedMap& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/) { return false; } template + /** + * @brief + * + * @param ContainerUnorderedMap + * @param elements + * @param handle + * @param + * @return bool + */ static bool erase(ContainerUnorderedMap< TypeList, KEY_TYPE >& elements, KEY_TYPE handle, SPECIFIC_TYPE* /*obj*/) { bool ret = TypeUnorderedMapContainer::erase(elements._elements, handle, (SPECIFIC_TYPE*)NULL); @@ -179,68 +326,103 @@ class TypeUnorderedMapContainer } }; -/* - * @class ContainerMapList is a mulit-type container for map elements +template +/** + * @brief ontainerMapList is a multi-type container for map elements + * * By itself its meaningless but collaborate along with TypeContainers, * it become the most powerfully container in the whole system. + * */ -template struct ContainerMapList { - GridRefManager _element; + GridRefManager _element; /**< TODO */ }; template<> +/** + * @brief + * + */ struct ContainerMapList /* nothing is in type null */ { }; template +/** + * @brief + * + */ struct ContainerMapList > { - ContainerMapList _elements; - ContainerMapList _TailElements; + ContainerMapList _elements; /**< TODO */ + ContainerMapList _TailElements; /**< TODO */ }; #include "TypeContainerFunctions.h" -/* - * @class TypeMapContainer contains a fixed number of types and is - * determined at compile time. This is probably the most complicated - * class and do its simplest thing, that is, holds objects - * of different types. - */ - template +/** + * @brief TypeMapContainer contains a fixed number of types and is determined at compile time. + * + * This is probably the most complicated class and do its simplest thing: holds + * objects of different types. + * + */ class MANGOS_DLL_DECL TypeMapContainer { public: template + /** + * @brief + * + * @return size_t + */ size_t Count() const { return MaNGOS::Count(i_elements, (SPECIFIC_TYPE*)NULL); } - /// inserts a specific object into the container template + /** + * @brief inserts a specific object into the container + * + * @param obj + * @return bool + */ bool insert(SPECIFIC_TYPE* obj) { SPECIFIC_TYPE* t = MaNGOS::Insert(i_elements, obj); return (t != NULL); } - /// Removes the object from the container, and returns the removed object template + /** + * @brief Removes the object from the container, and returns the removed object + * + * @param obj + * @return bool + */ bool remove(SPECIFIC_TYPE* obj) { SPECIFIC_TYPE* t = MaNGOS::Remove(i_elements, obj); return (t != NULL); } + /** + * @brief + * + * @return ContainerMapList + */ ContainerMapList& GetElements() { return i_elements; } + /** + * @brief + * + * @return const ContainerMapList + */ const ContainerMapList& GetElements() const { return i_elements;} private: - ContainerMapList i_elements; + ContainerMapList i_elements; /**< TODO */ }; #endif diff --git a/src/framework/GameSystem/TypeContainerFunctions.h b/src/framework/GameSystem/TypeContainerFunctions.h index c427bf5ce..052a19cf6 100644 --- a/src/framework/GameSystem/TypeContainerFunctions.h +++ b/src/framework/GameSystem/TypeContainerFunctions.h @@ -38,32 +38,68 @@ namespace MaNGOS { /* ContainerMapList Helpers */ - // count functions template + /** + * @brief count functions + * + * @param elements + * @param + * @return size_t + */ size_t Count(const ContainerMapList& elements, SPECIFIC_TYPE* /*fake*/) { return elements._element.getSize(); } template + /** + * @brief + * + * @param + * @param + * @return size_t + */ size_t Count(const ContainerMapList& /*elements*/, SPECIFIC_TYPE* /*fake*/) { return 0; } template + /** + * @brief + * + * @param + * @param + * @return size_t + */ size_t Count(const ContainerMapList& /*elements*/, SPECIFIC_TYPE* /*fake*/) { return 0; } template + /** + * @brief + * + * @param ContainerMapList >& elements, SPECIFIC_TYPE* fake) { return Count(elements._elements, fake); } template + /** + * @brief + * + * @param ContainerMapList >& elements, SPECIFIC_TYPE* fake) { return Count(elements._TailElements, fake); @@ -71,6 +107,13 @@ namespace MaNGOS // non-const insert functions template + /** + * @brief + * + * @param elements + * @param obj + * @return SPECIFIC_TYPE + */ SPECIFIC_TYPE* Insert(ContainerMapList& elements, SPECIFIC_TYPE* obj) { // elements._element[hdl] = obj; @@ -79,28 +122,54 @@ namespace MaNGOS } template + /** + * @brief + * + * @param + * @param + * @return SPECIFIC_TYPE + */ SPECIFIC_TYPE* Insert(ContainerMapList& /*elements*/, SPECIFIC_TYPE* /*obj*/) { return NULL; } - // this is a missed template + /** + * @brief this is a missed + * + * @param + * @param + * @return SPECIFIC_TYPE + */ SPECIFIC_TYPE* Insert(ContainerMapList& /*elements*/, SPECIFIC_TYPE* /*obj*/) { return NULL; // a missed } - // Recursion template + /** + * @brief Recursion + * + * @param ContainerMapList >& elements, SPECIFIC_TYPE* obj) { SPECIFIC_TYPE* t = Insert(elements._elements, obj); return (t != NULL ? t : Insert(elements._TailElements, obj)); } - // non-const remove method template + /** + * @brief non-const remove method + * + * @param + * @param obj + * @return SPECIFIC_TYPE + */ SPECIFIC_TYPE* Remove(ContainerMapList& /*elements*/, SPECIFIC_TYPE* obj) { obj->GetGridRef().unlink(); @@ -108,19 +177,40 @@ namespace MaNGOS } template + /** + * @brief + * + * @param + * @param + * @return SPECIFIC_TYPE + */ SPECIFIC_TYPE* Remove(ContainerMapList& /*elements*/, SPECIFIC_TYPE* /*obj*/) { return NULL; } - // this is a missed template + /** + * @brief this is a missed + * + * @param + * @param + * @return SPECIFIC_TYPE + */ SPECIFIC_TYPE* Remove(ContainerMapList& /*elements*/, SPECIFIC_TYPE* /*obj*/) { return NULL; // a missed } template + /** + * @brief + * + * @param ContainerMapList >& elements, SPECIFIC_TYPE* obj) { // The head element is bad diff --git a/src/framework/GameSystem/TypeContainerVisitor.h b/src/framework/GameSystem/TypeContainerVisitor.h index 6b3a69b46..3fbe38624 100644 --- a/src/framework/GameSystem/TypeContainerVisitor.h +++ b/src/framework/GameSystem/TypeContainerVisitor.h @@ -37,55 +37,101 @@ // forward declaration template class TypeContainerVisitor; -// visitor helper template +/** + * @brief visitor helper + * + * @param v + * @param c + */ void VisitorHelper(VISITOR& v, TYPE_CONTAINER& c) { v.Visit(c); } -// terminate condition container map list template +/** + * @brief terminate condition container map list + * + * @param + * @param + */ void VisitorHelper(VISITOR& /*v*/, ContainerMapList& /*c*/) { } template +/** + * @brief + * + * @param v + * @param c + */ void VisitorHelper(VISITOR& v, ContainerMapList& c) { v.Visit(c._element); } -// recursion container map list template +/** + * @brief recursion container map list + * + * @param v + * @param ContainerMapList >& c) { VisitorHelper(v, c._elements); VisitorHelper(v, c._TailElements); } -// for TypeMapContainer template +/** + * @brief for TypeMapContainer + * + * @param v + * @param c + */ void VisitorHelper(VISITOR& v, TypeMapContainer& c) { VisitorHelper(v, c.GetElements()); } template +/** + * @brief + * + */ class MANGOS_DLL_DECL TypeContainerVisitor { public: + /** + * @brief + * + * @param v + */ TypeContainerVisitor(VISITOR& v) : i_visitor(v) { } + /** + * @brief + * + * @param c + */ void Visit(TYPE_CONTAINER& c) { VisitorHelper(i_visitor, c); } + /** + * @brief + * + * @param c + */ void Visit(const TYPE_CONTAINER& c) const { VisitorHelper(i_visitor, c); @@ -93,7 +139,7 @@ class MANGOS_DLL_DECL TypeContainerVisitor private: - VISITOR& i_visitor; + VISITOR& i_visitor; /**< TODO */ }; #endif diff --git a/src/framework/Platform/CompilerDefs.h b/src/framework/Platform/CompilerDefs.h index 552fe947e..dd1637750 100644 --- a/src/framework/Platform/CompilerDefs.h +++ b/src/framework/Platform/CompilerDefs.h @@ -44,11 +44,11 @@ # define PLATFORM PLATFORM_UNIX #endif -#define COMPILER_MICROSOFT 0 -#define COMPILER_GNU 1 -#define COMPILER_BORLAND 2 -#define COMPILER_INTEL 3 -#define COMPILER_CLANG 4 +#define COMPILER_MICROSOFT 0 +#define COMPILER_GNU 1 +#define COMPILER_BORLAND 2 +#define COMPILER_INTEL 3 +#define COMPILER_CLANG 4 #ifdef _MSC_VER # define COMPILER COMPILER_MICROSOFT @@ -64,10 +64,10 @@ # pragma error "FATAL ERROR: Unknown compiler." #endif -#if COMPILER == COMPILER_CLANG -#define COMPILE_ASSERT(exp, name) _Static_assert((exp), #name) +#if defined(__cplusplus) && __cplusplus == 201103L +# define COMPILER_HAS_CPP11_SUPPORT 1 #else -#define COMPILE_ASSERT(exp, name) static_assert((exp), #name) +# define COMPILER_HAS_CPP11_SUPPORT 0 #endif #endif diff --git a/src/framework/Platform/Define.h b/src/framework/Platform/Define.h index 27b7c87dc..f5a262870 100644 --- a/src/framework/Platform/Define.h +++ b/src/framework/Platform/Define.h @@ -45,6 +45,10 @@ # endif // ACE_BYTE_ORDER #endif // MANGOS_ENDIAN +/** + * @brief + * + */ typedef ACE_SHLIB_HANDLE MANGOS_LIBRARY_HANDLE; #define MANGOS_SCRIPT_NAME "mangosscript" @@ -105,23 +109,73 @@ typedef ACE_SHLIB_HANDLE MANGOS_LIBRARY_HANDLE; #if COMPILER == COMPILER_GNU || COMPILER == COMPILER_CLANG # define ATTR_NORETURN __attribute__((noreturn)) -# define ATTR_PRINTF(F,V) __attribute__ ((format (printf, F, V))) -#else // COMPILER != COMPILER_GNU +# define ATTR_PRINTF(F, V) __attribute__ ((format (printf, F, V))) +# define ATTR_DEPRECATED __attribute__((deprecated)) +#else //COMPILER != COMPILER_GNU # define ATTR_NORETURN -# define ATTR_PRINTF(F,V) -#endif // COMPILER == COMPILER_GNU +# define ATTR_PRINTF(F, V) +# define ATTR_DEPRECATED +#endif //COMPILER == COMPILER_GNU +#if COMPILER_HAS_CPP11_SUPPORT +# define OVERRIDE override +# define FINAL final +#else +# define OVERRIDE +# define FINAL +#endif //COMPILER_HAS_CPP11_SUPPORT + +/** + * @brief A signed integer of 64 bits + * + */ typedef ACE_INT64 int64; +/** + * @brief A signed integer of 32 bits + * + */ typedef ACE_INT32 int32; +/** + * @brief A signed integer of 16 bits + * + */ typedef ACE_INT16 int16; +/** + * @brief A signed integer of 8 bits + * + */ typedef ACE_INT8 int8; +/** + * @brief An unsigned integer of 64 bits + * + */ typedef ACE_UINT64 uint64; +/** + * @brief An unsigned integer of 32 bits + * + */ typedef ACE_UINT32 uint32; +/** + * @brief An unsigned integer of 16 bits + * + */ typedef ACE_UINT16 uint16; +/** + * @brief An unsigned integer of 8 bits + * + */ typedef ACE_UINT8 uint8; #if COMPILER != COMPILER_MICROSOFT +/** + * @brief An unsigned integer of 16 bits, only for Win + * + */ typedef uint16 WORD; +/** + * @brief An unsigned integer of 32 bits, only for Win + * + */ typedef uint32 DWORD; #endif // COMPILER @@ -134,12 +188,21 @@ typedef uint32 DWORD; # define override # define static_assert(a, b) STATIC_ASSERT_WORKAROUND(a, b) # endif +#elif COMPILER == COMPILER_CLANG +# ifndef __cxx_static_assert +# define override +# define static_assert(a, b) STATIC_ASSERT_WORKAROUND(a, b) +# endif #elif COMPILER == COMPILER_MICROSOFT # if _MSC_VER < 1600 # define static_assert(a, b) STATIC_ASSERT_WORKAROUND(a, b) # endif #endif +/** + * @brief + * + */ typedef uint64 OBJECT_HANDLE; enum FieldFormat diff --git a/src/framework/Policies/CreationPolicy.h b/src/framework/Policies/CreationPolicy.h index 8ae6bdf2f..c29b74ef7 100644 --- a/src/framework/Policies/CreationPolicy.h +++ b/src/framework/Policies/CreationPolicy.h @@ -30,54 +30,85 @@ namespace MaNGOS { - /** - * OperatorNew policy creates an object on the heap using new. - */ template + /** + * @brief OperatorNew policy creates an object on the heap using new. + * + */ class MANGOS_DLL_DECL OperatorNew { public: + /** + * @brief + * + * @return T + */ static T* Create() { return (new T); } + /** + * @brief + * + * @param obj + */ static void Destroy(T* obj) { delete obj; } }; - /** - * LocalStaticCreation policy creates an object on the stack - * the first time call Create. - */ template + /** + * @brief LocalStaticCreation policy creates an object on the stack the first time call Create. + * + */ class MANGOS_DLL_DECL LocalStaticCreation { + /** + * @brief + * + */ union MaxAlign { - char t_[sizeof(T)]; - short int shortInt_; - int int_; - long int longInt_; - float float_; - double double_; - long double longDouble_; + char t_[sizeof(T)]; /**< TODO */ + short int shortInt_; /**< TODO */ + int int_; /**< TODO */ + long int longInt_; /**< TODO */ + float float_; /**< TODO */ + double double_; /**< TODO */ + long double longDouble_; /**< TODO */ struct Test; - int Test::* pMember_; + int Test::* pMember_; /**< TODO */ + /** + * @brief + * + * @param Test::pMemberFn_)(int + * @return int + */ int (Test::*pMemberFn_)(int); }; public: + /** + * @brief + * + * @return T + */ static T* Create() { static MaxAlign si_localStatic; return new(&si_localStatic) T; } + /** + * @brief + * + * @param obj + */ static void Destroy(T* obj) { obj->~T(); @@ -88,20 +119,34 @@ namespace MaNGOS * CreateUsingMalloc by pass the memory manger. */ template + /** + * @brief + * + */ class MANGOS_DLL_DECL CreateUsingMalloc { public: + /** + * @brief + * + * @return T + */ static T* Create() { void* p = malloc(sizeof(T)); if (!p) - return NULL; + { return NULL; } return new(p) T; } + /** + * @brief + * + * @param p + */ static void Destroy(T* p) { p->~T(); @@ -109,18 +154,29 @@ namespace MaNGOS } }; - /** - * CreateOnCallBack creates the object base on the call back. - */ template + /** + * @brief CreateOnCallBack creates the object base on the call back. + * + */ class MANGOS_DLL_DECL CreateOnCallBack { public: + /** + * @brief + * + * @return T + */ static T* Create() { return CALL_BACK::createCallBack(); } + /** + * @brief + * + * @param p + */ static void Destroy(T* p) { CALL_BACK::destroyCallBack(p); diff --git a/src/framework/Policies/ObjectLifeTime.h b/src/framework/Policies/ObjectLifeTime.h index e42e5dd6f..3df07d312 100644 --- a/src/framework/Policies/ObjectLifeTime.h +++ b/src/framework/Policies/ObjectLifeTime.h @@ -28,26 +28,52 @@ #include #include "Platform/Define.h" +/** + * @brief + * + */ typedef void (* Destroyer)(void); namespace MaNGOS { + /** + * @brief + * + * @param (func)() + */ void MANGOS_DLL_SPEC at_exit(void (*func)()); template + /** + * @brief + * + */ class MANGOS_DLL_DECL ObjectLifeTime { public: + /** + * @brief + * + * @param (destroyer)() + */ static void ScheduleCall(void (*destroyer)()) { at_exit(destroyer); } + /** + * @brief + * + */ DECLSPEC_NORETURN static void OnDeadReference() ATTR_NORETURN; }; template + /** + * @brief We don't handle Dead Reference for now + * + */ void ObjectLifeTime::OnDeadReference() // We don't handle Dead Reference for now { throw std::runtime_error("Dead Reference"); diff --git a/src/framework/Policies/Singleton.h b/src/framework/Policies/Singleton.h index 7ec94aa45..cdd8ab7be 100644 --- a/src/framework/Policies/Singleton.h +++ b/src/framework/Policies/Singleton.h @@ -42,40 +42,74 @@ namespace MaNGOS class CreatePolicy = MaNGOS::OperatorNew, class LifeTimePolicy = MaNGOS::ObjectLifeTime > + /** + * @brief + * + */ class MANGOS_DLL_DECL Singleton { public: + /** + * @brief + * + * @return T + */ static T& Instance(); protected: + /** + * @brief + * + */ Singleton() { } private: - // Prohibited actions...this does not prevent hijacking. + /** + * @brief Prohibited actions...this does not prevent hijacking. + * + * @param + */ Singleton(const Singleton&); + /** + * @brief + * + * @param + * @return Singleton &operator + */ Singleton& operator=(const Singleton&); - // Singleton Helpers + /** + * @brief Singleton Helpers + * + */ static void DestroySingleton(); - // data structure + /** + * @brief data structure + * + */ typedef typename ThreadingModel::Lock Guard; - static T* si_instance; - static bool si_destroyed; + static T* si_instance; /**< TODO */ + static bool si_destroyed; /**< TODO */ }; template - T* Singleton::si_instance = NULL; + T* Singleton::si_instance = NULL; /**< TODO */ template - bool Singleton::si_destroyed = false; + bool Singleton::si_destroyed = false; /**< TODO */ template + /** + * @brief + * + * @return T &MaNGOS::Singleton + */ T& MaNGOS::Singleton::Instance() { if (!si_instance) @@ -100,6 +134,10 @@ namespace MaNGOS } template + /** + * @brief + * + */ void MaNGOS::Singleton::DestroySingleton() { CreatePolicy::Destroy(si_instance); diff --git a/src/framework/Policies/ThreadingModel.h b/src/framework/Policies/ThreadingModel.h index 5e67692f0..54440fa87 100644 --- a/src/framework/Policies/ThreadingModel.h +++ b/src/framework/Policies/ThreadingModel.h @@ -35,16 +35,29 @@ namespace MaNGOS { template + /** + * @brief + * + */ class MANGOS_DLL_DECL GeneralLock { public: + /** + * @brief + * + * @param m + */ GeneralLock(MUTEX& m) : i_mutex(m) { i_mutex.acquire(); } + /** + * @brief + * + */ ~GeneralLock() { i_mutex.release(); @@ -52,36 +65,77 @@ namespace MaNGOS private: + /** + * @brief + * + * @param + */ GeneralLock(const GeneralLock&); + /** + * @brief + * + * @param + * @return GeneralLock &operator + */ GeneralLock& operator=(const GeneralLock&); - MUTEX& i_mutex; + MUTEX& i_mutex; /**< TODO */ }; template + /** + * @brief + * + */ class MANGOS_DLL_DECL SingleThreaded { public: - struct Lock // empty object + /** + * @brief empty object + * + */ + struct Lock { + /** + * @brief + * + */ Lock() { } + /** + * @brief + * + * @param + */ Lock(const T&) { } - Lock(const SingleThreaded&) // for single threaded we ignore this + /** + * @brief for single threaded we ignore this + * + * @param + */ + Lock(const SingleThreaded&) { } }; }; template + /** + * @brief + * + */ class MANGOS_DLL_DECL ObjectLevelLockable { public: + /** + * @brief + * + */ ObjectLevelLockable() : i_mtx() { @@ -89,10 +143,20 @@ namespace MaNGOS friend class Lock; + /** + * @brief + * + */ class Lock { public: + /** + * @brief + * + * @param ObjectLevelLockable& host) : i_lock(host.i_mtx) { @@ -100,48 +164,91 @@ namespace MaNGOS private: - GeneralLock i_lock; + GeneralLock i_lock; /**< TODO */ }; private: - // prevent the compiler creating a copy construct + /** + * @brief prevent the compiler creating a copy construct + * + * @param ObjectLevelLockable&); + /** + * @brief + * + * @param ObjectLevelLockable + */ ObjectLevelLockable& operator=(const ObjectLevelLockable&); - MUTEX i_mtx; + MUTEX i_mtx; /**< TODO */ }; template + /** + * @brief + * + */ class MANGOS_DLL_DECL ClassLevelLockable { public: + /** + * @brief + * + */ ClassLevelLockable() { } friend class Lock; + /** + * @brief + * + */ class Lock { public: + /** + * @brief + * + * @param + */ Lock(const T& /*host*/) { ClassLevelLockable::si_mtx.acquire(); } + /** + * @brief + * + * @param ClassLevelLockable&) { ClassLevelLockable::si_mtx.acquire(); } + /** + * @brief + * + */ Lock() { ClassLevelLockable::si_mtx.acquire(); } + /** + * @brief + * + */ ~Lock() { ClassLevelLockable::si_mtx.release(); @@ -150,12 +257,12 @@ namespace MaNGOS private: - static MUTEX si_mtx; + static MUTEX si_mtx; /**< TODO */ }; } -template MUTEX MaNGOS::ClassLevelLockable::si_mtx; +template MUTEX MaNGOS::ClassLevelLockable::si_mtx; /**< TODO */ #define INSTANTIATE_CLASS_MUTEX(CTYPE, MUTEX) \ template class MANGOS_DLL_DECL MaNGOS::ClassLevelLockable diff --git a/src/framework/Utilities/ByteConverter.h b/src/framework/Utilities/ByteConverter.h index 045cb91bb..9f1904452 100644 --- a/src/framework/Utilities/ByteConverter.h +++ b/src/framework/Utilities/ByteConverter.h @@ -25,26 +25,47 @@ #ifndef MANGOS_BYTECONVERTER_H #define MANGOS_BYTECONVERTER_H -/** ByteConverter reverse your byte order. This is use - for cross platform where they have different endians. +/** + * ByteConverter reverse your byte order. This is used for cross platform + * where they have different endians. */ -#include +#include "Platform/Define.h" #include namespace ByteConverter { template + /** + * @brief + * + * @param val + */ inline void convert(char* val) { std::swap(*val, *(val + T - 1)); convert < T - 2 > (val + 1); } + /** + * @brief + * + * @param + */ template<> inline void convert<0>(char*) {} - template<> inline void convert<1>(char*) {} // ignore central byte + /** + * @brief ignore central byte + * + * @param + */ + template<> inline void convert<1>(char*) {} template + /** + * @brief + * + * @param val + */ inline void apply(T* val) { convert((char*)(val)); @@ -52,19 +73,59 @@ namespace ByteConverter } #if MANGOS_ENDIAN == MANGOS_BIGENDIAN +/** + * @brief + * + * @param val + */ template inline void EndianConvert(T& val) { ByteConverter::apply(&val); } +/** + * @brief + * + * @param + */ template inline void EndianConvertReverse(T&) { } #else template inline void EndianConvert(T&) { } template inline void EndianConvertReverse(T& val) { ByteConverter::apply(&val); } #endif -template void EndianConvert(T*); // will generate link error -template void EndianConvertReverse(T*); // will generate link error +/** + * @brief will generate link error + * + * @param + */ +template void EndianConvert(T*); +/** + * @brief will generate link error + * + * @param + */ +template void EndianConvertReverse(T*); +/** + * @brief + * + * @param + */ inline void EndianConvert(uint8&) { } +/** + * @brief + * + * @param + */ inline void EndianConvert(int8&) { } +/** + * @brief + * + * @param + */ inline void EndianConvertReverse(uint8&) { } +/** + * @brief + * + * @param + */ inline void EndianConvertReverse(int8&) { } #endif diff --git a/src/framework/Utilities/Callback.h b/src/framework/Utilities/Callback.h index f8abc0ade..aa94925e2 100644 --- a/src/framework/Utilities/Callback.h +++ b/src/framework/Utilities/Callback.h @@ -48,34 +48,68 @@ #define PARAMS_9 PARAMS_8, T9 param9 #define PARAMS_10 PARAMS_9, T10 param10 -// empty struct to use in templates instead of void type +/** + * @brief empty struct to use in templates instead of void type + * + */ struct null { null() {} }; /// ------------ BASE CLASSES ------------ namespace MaNGOS { template < class Class, typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void, typename ParamType4 = void > + /** + * @brief + * + */ class _Callback { protected: + /** + * @brief + * + */ typedef void (Class::*Method)(ParamType1, ParamType2, ParamType3, ParamType4); - Class* m_object; - Method m_method; - ParamType1 m_param1; - ParamType2 m_param2; - ParamType3 m_param3; - ParamType4 m_param4; + Class* m_object; /**< TODO */ + Method m_method; /**< TODO */ + ParamType1 m_param1; /**< TODO */ + ParamType2 m_param2; /**< TODO */ + ParamType3 m_param3; /**< TODO */ + ParamType4 m_param4; /**< TODO */ + /** + * @brief + * + */ void _Execute() { (m_object->*m_method)(m_param1, m_param2, m_param3, m_param4); } public: + /** + * @brief + * + * @param object + * @param method + * @param param1 + * @param param2 + * @param param3 + * @param param4 + */ _Callback(Class* object, Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3, ParamType4 param4) : m_object(object), m_method(method), m_param1(param1), m_param2(param2), m_param3(param3), m_param4(param4) { } + /** + * @brief + * + * @param const_Callback const& cb) : m_object(cb.m_object), m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3), m_param4(cb.m_param4) @@ -84,25 +118,54 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class _Callback { protected: + /** + * @brief + * + */ typedef void (Class::*Method)(ParamType1, ParamType2, ParamType3); - Class* m_object; - Method m_method; - ParamType1 m_param1; - ParamType2 m_param2; - ParamType3 m_param3; + Class* m_object; /**< TODO */ + Method m_method; /**< TODO */ + ParamType1 m_param1; /**< TODO */ + ParamType2 m_param2; /**< TODO */ + ParamType3 m_param3; /**< TODO */ + /** + * @brief + * + */ void _Execute() { (m_object->*m_method)(m_param1, m_param2, m_param3); } public: + /** + * @brief + * + * @param object + * @param method + * @param param1 + * @param param2 + * @param param3 + */ _Callback(Class* object, Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3) : m_object(object), m_method(method), m_param1(param1), m_param2(param2), m_param3(param3) { } + /** + * @brief + * + * @param const_Callback const& cb) : m_object(cb.m_object), m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3) @@ -111,25 +174,52 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class _Callback { protected: + /** + * @brief + * + */ typedef void (Class::*Method)(ParamType1, ParamType2); - Class* m_object; - Method m_method; - ParamType1 m_param1; - ParamType2 m_param2; + Class* m_object; /**< TODO */ + Method m_method; /**< TODO */ + ParamType1 m_param1; /**< TODO */ + ParamType2 m_param2; /**< TODO */ + /** + * @brief + * + */ void _Execute() { (m_object->*m_method)(m_param1, m_param2); } public: + /** + * @brief + * + * @param object + * @param method + * @param param1 + * @param param2 + */ _Callback(Class* object, Method method, ParamType1 param1, ParamType2 param2) : m_object(object), m_method(method), m_param1(param1), m_param2(param2) { } + /** + * @brief + * + * @param const_Callback const& cb) : m_object(cb.m_object), m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2) @@ -138,24 +228,49 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class _Callback { protected: + /** + * @brief + * + */ typedef void (Class::*Method)(ParamType1); - Class* m_object; - Method m_method; - ParamType1 m_param1; + Class* m_object; /**< TODO */ + Method m_method; /**< TODO */ + ParamType1 m_param1; /**< TODO */ + /** + * @brief + * + */ void _Execute() { (m_object->*m_method)(m_param1); } public: + /** + * @brief + * + * @param object + * @param method + * @param param1 + */ _Callback(Class* object, Method method, ParamType1 param1) : m_object(object), m_method(method), m_param1(param1) { } + /** + * @brief + * + * @param const_Callback const& cb) : m_object(cb.m_object), m_method(cb.m_method), m_param1(cb.m_param1) @@ -164,20 +279,43 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class _Callback { protected: + /** + * @brief + * + */ typedef void (Class::*Method)(); - Class* m_object; - Method m_method; + Class* m_object; /**< TODO */ + Method m_method; /**< TODO */ + /** + * @brief + * + */ void _Execute() { (m_object->*m_method)(); } public: + /** + * @brief + * + * @param object + * @param method + */ _Callback(Class* object, Method method) : m_object(object), m_method(method) { } + /** + * @brief + * + * @param cb + */ _Callback(_Callback const& cb) : m_object(cb.m_object), m_method(cb.m_method) { @@ -187,26 +325,55 @@ namespace MaNGOS /// ---- Statics ---- template < typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void, typename ParamType4 = void > + /** + * @brief + * + */ class _SCallback { protected: + /** + * @brief + * + */ typedef void (*Method)(ParamType1, ParamType2, ParamType3, ParamType4); - Method m_method; - ParamType1 m_param1; - ParamType2 m_param2; - ParamType3 m_param3; - ParamType4 m_param4; + Method m_method; /**< TODO */ + ParamType1 m_param1; /**< TODO */ + ParamType2 m_param2; /**< TODO */ + ParamType3 m_param3; /**< TODO */ + ParamType4 m_param4; /**< TODO */ + /** + * @brief + * + */ void _Execute() { (*m_method)(m_param1, m_param2, m_param3, m_param4); } public: + /** + * @brief + * + * @param method + * @param param1 + * @param param2 + * @param param3 + * @param param4 + */ _SCallback(Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3, ParamType4 param4) : m_method(method), m_param1(param1), m_param2(param2), m_param3(param3), m_param4(param4) { } + /** + * @brief + * + * @param const_SCallback const& cb) : m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3), m_param4(cb.m_param4) @@ -215,23 +382,50 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class _SCallback { protected: + /** + * @brief + * + */ typedef void (*Method)(ParamType1, ParamType2, ParamType3); - Method m_method; - ParamType1 m_param1; - ParamType2 m_param2; - ParamType3 m_param3; + Method m_method; /**< TODO */ + ParamType1 m_param1; /**< TODO */ + ParamType2 m_param2; /**< TODO */ + ParamType3 m_param3; /**< TODO */ + /** + * @brief + * + */ void _Execute() { (*m_method)(m_param1, m_param2, m_param3); } public: + /** + * @brief + * + * @param method + * @param param1 + * @param param2 + * @param param3 + */ _SCallback(Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3) : m_method(method), m_param1(param1), m_param2(param2), m_param3(param3) { } + /** + * @brief + * + * @param const_SCallback const& cb) : m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3) @@ -240,23 +434,48 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class _SCallback { protected: + /** + * @brief + * + */ typedef void (*Method)(ParamType1, ParamType2); - Method m_method; - ParamType1 m_param1; - ParamType2 m_param2; + Method m_method; /**< TODO */ + ParamType1 m_param1; /**< TODO */ + ParamType2 m_param2; /**< TODO */ + /** + * @brief + * + */ void _Execute() { (*m_method)(m_param1, m_param2); } public: + /** + * @brief + * + * @param method + * @param param1 + * @param param2 + */ _SCallback(Method method, ParamType1 param1, ParamType2 param2) : m_method(method), m_param1(param1), m_param2(param2) { } + /** + * @brief + * + * @param const_SCallback const& cb) : m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2) @@ -265,22 +484,45 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class _SCallback { protected: + /** + * @brief + * + */ typedef void (*Method)(ParamType1); - Method m_method; - ParamType1 m_param1; + Method m_method; /**< TODO */ + ParamType1 m_param1; /**< TODO */ + /** + * @brief + * + */ void _Execute() { (*m_method)(m_param1); } public: + /** + * @brief + * + * @param method + * @param param1 + */ _SCallback(Method method, ParamType1 param1) : m_method(method), m_param1(param1) { } + /** + * @brief + * + * @param cb + */ _SCallback(_SCallback const& cb) : m_method(cb.m_method), m_param1(cb.m_param1) @@ -289,21 +531,43 @@ namespace MaNGOS }; template<> + /** + * @brief + * + */ class _SCallback<> { protected: + /** + * @brief + * + */ typedef void (*Method)(); - Method m_method; + Method m_method; /**< TODO */ + /** + * @brief + * + */ void _Execute() { (*m_method)(); } public: + /** + * @brief + * + * @param method + */ _SCallback(Method method) : m_method(method) { } + /** + * @brief + * + * @param cb + */ _SCallback(_SCallback<> const& cb) : m_method(cb.m_method) { @@ -315,34 +579,77 @@ namespace MaNGOS namespace MaNGOS { + /** + * @brief + * + */ class ICallback { public: + /** + * @brief + * + */ virtual void Execute() = 0; + /** + * @brief + * + */ virtual ~ICallback() {} }; template + /** + * @brief + * + */ class _ICallback : public CB, public ICallback { public: + /** + * @brief + * + * @param cb + */ _ICallback(CB const& cb) : CB(cb) { } + /** + * @brief + * + */ void Execute() { CB::_Execute(); } }; template < class Class, typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void, typename ParamType4 = void > + /** + * @brief + * + */ class Callback : public _ICallback<_Callback > { private: + /** + * @brief + * + */ typedef _Callback C4; public: + /** + * @brief + * + * @param object + * @param method + * @param param1 + * @param param2 + * @param param3 + * @param param4 + */ Callback(Class* object, typename C4::Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3, ParamType4 param4) : _ICallback(C4(object, method, param1, param2, param3, param4)) { @@ -350,13 +657,30 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class Callback : public _ICallback<_Callback > { private: + /** + * @brief + * + */ typedef _Callback C3; public: + /** + * @brief + * + * @param object + * @param method + * @param param1 + * @param param2 + * @param param3 + */ Callback(Class* object, typename C3::Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3) : _ICallback(C3(object, method, param1, param2, param3)) { @@ -364,13 +688,29 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class Callback : public _ICallback<_Callback > { private: + /** + * @brief + * + */ typedef _Callback C2; public: + /** + * @brief + * + * @param object + * @param method + * @param param1 + * @param param2 + */ Callback(Class* object, typename C2::Method method, ParamType1 param1, ParamType2 param2) : _ICallback(C2(object, method, param1, param2)) { @@ -378,14 +718,29 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class Callback : public _ICallback<_Callback > { private: + /** + * @brief + * + */ typedef _Callback C1; public: + /** + * @brief + * + * @param object + * @param method + * @param param1 + */ Callback(Class* object, typename C1::Method method, ParamType1 param1) : _ICallback(C1(object, method, param1)) { @@ -393,14 +748,28 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class Callback : public _ICallback<_Callback > { private: + /** + * @brief + * + */ typedef _Callback C0; public: + /** + * @brief + * + * @param object + * @param method + */ Callback(Class* object, typename C0::Method method) : _ICallback(C0(object, method)) { @@ -414,39 +783,102 @@ class QueryResult; namespace MaNGOS { + /** + * @brief + * + */ class IQueryCallback { public: + /** + * @brief + * + */ virtual void Execute() = 0; + /** + * @brief + * + */ virtual ~IQueryCallback() {} + /** + * @brief + * + * @param result + */ virtual void SetResult(QueryResult* result) = 0; + /** + * @brief + * + * @return QueryResult + */ virtual QueryResult* GetResult() = 0; }; template + /** + * @brief + * + */ class _IQueryCallback : public CB, public IQueryCallback { public: + /** + * @brief + * + * @param cb + */ _IQueryCallback(CB const& cb) : CB(cb) { } + /** + * @brief + * + */ void Execute() { CB::_Execute(); } + /** + * @brief + * + * @param result + */ void SetResult(QueryResult* result) { CB::m_param1 = result; } + /** + * @brief + * + * @return QueryResult + */ QueryResult* GetResult() { return CB::m_param1; } }; template < class Class, typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void > + /** + * @brief + * + */ class QueryCallback : public _IQueryCallback<_Callback > { private: + /** + * @brief + * + */ typedef _Callback QC3; public: + /** + * @brief + * + * @param object + * @param method + * @param result + * @param param1 + * @param param2 + * @param param3 + */ QueryCallback(Class* object, typename QC3::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2, ParamType3 param3) : _IQueryCallback(QC3(object, method, result, param1, param2, param3)) { @@ -454,14 +886,31 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class QueryCallback : public _IQueryCallback<_Callback > { private: + /** + * @brief + * + */ typedef _Callback QC2; public: + /** + * @brief + * + * @param object + * @param method + * @param result + * @param param1 + * @param param2 + */ QueryCallback(Class* object, typename QC2::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2) : _IQueryCallback(QC2(object, method, result, param1, param2)) { @@ -469,14 +918,30 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class QueryCallback : public _IQueryCallback<_Callback > { private: + /** + * @brief + * + */ typedef _Callback QC1; public: + /** + * @brief + * + * @param object + * @param method + * @param result + * @param param1 + */ QueryCallback(Class* object, typename QC1::Method method, QueryResult* result, ParamType1 param1) : _IQueryCallback(QC1(object, method, result, param1)) { @@ -484,13 +949,28 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class QueryCallback : public _IQueryCallback<_Callback > { private: + /** + * @brief + * + */ typedef _Callback QC0; public: + /** + * @brief + * + * @param object + * @param method + * @param result + */ QueryCallback(Class* object, typename QC0::Method method, QueryResult* result) : _IQueryCallback(QC0(object, method, result)) { @@ -500,14 +980,31 @@ namespace MaNGOS /// ---- Statics ---- template < typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void > + /** + * @brief + * + */ class SQueryCallback : public _IQueryCallback<_SCallback > { private: + /** + * @brief + * + */ typedef _SCallback QC3; public: + /** + * @brief + * + * @param method + * @param result + * @param param1 + * @param param2 + * @param param3 + */ SQueryCallback(typename QC3::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2, ParamType3 param3) : _IQueryCallback(QC3(method, result, param1, param2, param3)) { @@ -515,14 +1012,30 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class SQueryCallback < ParamType1, ParamType2 > : public _IQueryCallback<_SCallback > { private: + /** + * @brief + * + */ typedef _SCallback QC2; public: + /** + * @brief + * + * @param method + * @param result + * @param param1 + * @param param2 + */ SQueryCallback(typename QC2::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2) : _IQueryCallback(QC2(method, result, param1, param2)) { @@ -530,14 +1043,29 @@ namespace MaNGOS }; template + /** + * @brief + * + */ class SQueryCallback : public _IQueryCallback<_SCallback > { private: + /** + * @brief + * + */ typedef _SCallback QC1; public: + /** + * @brief + * + * @param method + * @param result + * @param param1 + */ SQueryCallback(typename QC1::Method method, QueryResult* result, ParamType1 param1) : _IQueryCallback(QC1(method, result, param1)) { @@ -545,14 +1073,28 @@ namespace MaNGOS }; template<> + /** + * @brief + * + */ class SQueryCallback<> : public _IQueryCallback<_SCallback > { private: + /** + * @brief + * + */ typedef _SCallback QC0; public: + /** + * @brief + * + * @param method + * @param result + */ SQueryCallback(QC0::Method method, QueryResult* result) : _IQueryCallback(QC0(method, result)) { diff --git a/src/framework/Utilities/EventProcessor.cpp b/src/framework/Utilities/EventProcessor.cpp index 9af06b808..f36ed12cf 100644 --- a/src/framework/Utilities/EventProcessor.cpp +++ b/src/framework/Utilities/EventProcessor.cpp @@ -82,19 +82,19 @@ void EventProcessor::KillAllEvents(bool force) delete i_old->second; if (!force) // need per-element cleanup - m_events.erase(i_old); + { m_events.erase(i_old); } } } // fast clear event list (in force case) if (force) - m_events.clear(); + { m_events.clear(); } } void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime) { if (set_addtime) - Event->m_addTime = m_time; + { Event->m_addTime = m_time; } Event->m_execTime = e_time; m_events.insert(std::pair(e_time, Event)); diff --git a/src/framework/Utilities/EventProcessor.h b/src/framework/Utilities/EventProcessor.h index 9e7d9d5e0..fa6d301e3 100644 --- a/src/framework/Utilities/EventProcessor.h +++ b/src/framework/Utilities/EventProcessor.h @@ -22,64 +22,127 @@ * and lore are copyrighted by Blizzard Entertainment, Inc. */ -#ifndef __EVENTPROCESSOR_H -#define __EVENTPROCESSOR_H +#ifndef MANGOS_H_EVENTPROCESSOR +#define MANGOS_H_EVENTPROCESSOR #include "Platform/Define.h" #include -// Note. All times are in milliseconds here. - +/** + * @brief Note. All times are in milliseconds here. + * + */ class BasicEvent { public: + /** + * @brief + * + */ BasicEvent() : to_Abort(false) { } - virtual ~BasicEvent() // override destructor to perform some actions on event removal + /** + * @brief override destructor to perform some actions on event removal + * + */ + virtual ~BasicEvent() { }; - // this method executes when the event is triggered - // return false if event does not want to be deleted - // e_time is execution time, p_time is update interval + + /** + * @brief this method executes when the event is triggered + * + * @param uint64 e_time is execution time + * @param uint32 p_time is update interval + * @return bool return false if event does not want to be deleted + */ virtual bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) { return true; } - virtual bool IsDeletable() const { return true; } // this event can be safely deleted + /** + * @brief this event can be safely deleted + * + * @return bool + */ + virtual bool IsDeletable() const { return true; } - virtual void Abort(uint64 /*e_time*/) {} // this method executes when the event is aborted + /** + * @brief this method executes when the event is aborted + * + * @param uint64 + */ + virtual void Abort(uint64 /*e_time*/) {} - bool to_Abort; // set by externals when the event is aborted, aborted events don't execute - // and get Abort call when deleted + bool to_Abort; /**< set by externals when the event is aborted, aborted events don't execute and get Abort call when deleted */ // these can be used for time offset control - uint64 m_addTime; // time when the event was added to queue, filled by event handler - uint64 m_execTime; // planned time of next execution, filled by event handler + uint64 m_addTime; /**< time when the event was added to queue, filled by event handler */ + uint64 m_execTime; /**< planned time of next execution, filled by event handler */ }; +/** + * @brief + * + */ typedef std::multimap EventList; +/** + * @brief + * + */ class EventProcessor { public: + /** + * @brief + * + */ EventProcessor(); + /** + * @brief + * + */ ~EventProcessor(); + /** + * @brief + * + * @param p_time + */ void Update(uint32 p_time); + /** + * @brief + * + * @param force + */ void KillAllEvents(bool force); + /** + * @brief + * + * @param Event + * @param e_time + * @param set_addtime + */ void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true); + /** + * @brief + * + * @param t_offset + * @return uint64 + */ uint64 CalculateTime(uint64 t_offset); protected: - uint64 m_time; - EventList m_events; - bool m_aborting; + uint64 m_time; /**< TODO */ + EventList m_events; /**< TODO */ + bool m_aborting; /**< TODO */ }; #endif diff --git a/src/framework/Utilities/LinkedList.h b/src/framework/Utilities/LinkedList.h index bd3f0f96f..7a15d31b9 100644 --- a/src/framework/Utilities/LinkedList.h +++ b/src/framework/Utilities/LinkedList.h @@ -30,34 +30,105 @@ //============================================ class LinkedListHead; +/** + * @brief + * + */ class LinkedListElement { private: friend class LinkedListHead; - LinkedListElement* iNext; - LinkedListElement* iPrev; + LinkedListElement* iNext; /**< TODO */ + LinkedListElement* iPrev; /**< TODO */ public: + /** + * @brief + * + */ LinkedListElement() { iNext = NULL; iPrev = NULL; } + /** + * @brief + * + */ ~LinkedListElement() { delink(); } + /** + * @brief + * + * @return bool + */ bool hasNext() const { return (iNext->iNext != NULL); } + /** + * @brief + * + * @return bool + */ bool hasPrev() const { return (iPrev->iPrev != NULL); } + /** + * @brief + * + * @return bool + */ bool isInList() const { return (iNext != NULL && iPrev != NULL); } + /** + * @brief + * + * @return LinkedListElement + */ LinkedListElement* next() { return hasNext() ? iNext : NULL; } + /** + * @brief + * + * @return const LinkedListElement + */ LinkedListElement const* next() const { return hasNext() ? iNext : NULL; } + /** + * @brief + * + * @return LinkedListElement + */ LinkedListElement* prev() { return hasPrev() ? iPrev : NULL; } + /** + * @brief + * + * @return const LinkedListElement + */ LinkedListElement const* prev() const { return hasPrev() ? iPrev : NULL; } + /** + * @brief + * + * @return LinkedListElement + */ LinkedListElement* nocheck_next() { return iNext; } + /** + * @brief + * + * @return const LinkedListElement + */ LinkedListElement const* nocheck_next() const { return iNext; } + /** + * @brief + * + * @return LinkedListElement + */ LinkedListElement* nocheck_prev() { return iPrev; } + /** + * @brief + * + * @return const LinkedListElement + */ LinkedListElement const* nocheck_prev() const { return iPrev; } + /** + * @brief + * + */ void delink() { if (isInList()) @@ -69,6 +140,11 @@ class LinkedListElement } } + /** + * @brief + * + * @param pElem + */ void insertBefore(LinkedListElement* pElem) { pElem->iNext = this; @@ -77,6 +153,11 @@ class LinkedListElement iPrev = pElem; } + /** + * @brief + * + * @param pElem + */ void insertAfter(LinkedListElement* pElem) { pElem->iPrev = this; @@ -88,16 +169,24 @@ class LinkedListElement //============================================ +/** + * @brief + * + */ class LinkedListHead { private: - LinkedListElement iFirst; - LinkedListElement iLast; - uint32 iSize; + LinkedListElement iFirst; /**< TODO */ + LinkedListElement iLast; /**< TODO */ + uint32 iSize; /**< TODO */ public: + /** + * @brief + * + */ LinkedListHead() { // create empty list @@ -107,24 +196,64 @@ class LinkedListHead iSize = 0; } + /** + * @brief + * + * @return bool + */ bool isEmpty() const { return (!iFirst.iNext->isInList()); } + /** + * @brief + * + * @return LinkedListElement + */ LinkedListElement* getFirst() { return (isEmpty() ? NULL : iFirst.iNext); } + /** + * @brief + * + * @return const LinkedListElement + */ LinkedListElement const* getFirst() const { return (isEmpty() ? NULL : iFirst.iNext); } + /** + * @brief + * + * @return LinkedListElement + */ LinkedListElement* getLast() { return (isEmpty() ? NULL : iLast.iPrev); } + /** + * @brief + * + * @return const LinkedListElement + */ LinkedListElement const* getLast() const { return (isEmpty() ? NULL : iLast.iPrev); } + /** + * @brief + * + * @param pElem + */ void insertFirst(LinkedListElement* pElem) { iFirst.insertAfter(pElem); } + /** + * @brief + * + * @param pElem + */ void insertLast(LinkedListElement* pElem) { iLast.insertBefore(pElem); } + /** + * @brief + * + * @return uint32 + */ uint32 getSize() const { if (!iSize) @@ -141,62 +270,141 @@ class LinkedListHead return result; } else - return iSize; + { return iSize; } } + /** + * @brief + * + */ void incSize() { ++iSize; } + /** + * @brief + * + */ void decSize() { --iSize; } template + /** + * @brief + * + */ class Iterator { public: + /** + * @brief + * + */ typedef std::bidirectional_iterator_tag iterator_category; + /** + * @brief + * + */ typedef _Ty value_type; + /** + * @brief + * + */ typedef ptrdiff_t difference_type; + /** + * @brief + * + */ typedef ptrdiff_t distance_type; + /** + * @brief + * + */ typedef _Ty* pointer; + /** + * @brief + * + */ typedef _Ty const* const_pointer; + /** + * @brief + * + */ typedef _Ty& reference; + /** + * @brief + * + */ typedef _Ty const& const_reference; - + /** + * @brief + * + */ Iterator() : _Ptr(0) { // construct with null node pointer } + /** + * @brief + * + * @param _Pnode + */ Iterator(pointer _Pnode) : _Ptr(_Pnode) { // construct with node pointer _Pnode } + /** + * @brief + * + * @param _Right + * @return Iterator &operator + */ Iterator& operator=(Iterator const& _Right) { return (*this) = _Right._Ptr; } + /** + * @brief + * + * @param _Right + * @return Iterator &operator + */ Iterator& operator=(const_pointer const& _Right) { _Ptr = (pointer)_Right; return (*this); } + /** + * @brief + * + * @return reference operator + */ reference operator*() { // return designated value return *_Ptr; } + /** + * @brief + * + * @return pointer operator -> + */ pointer operator->() { // return pointer to class object return _Ptr; } + /** + * @brief + * + * @return Iterator &operator + */ Iterator& operator++() { // preincrement @@ -204,6 +412,12 @@ class LinkedListHead return (*this); } + /** + * @brief + * + * @param int + * @return Iterator operator + */ Iterator operator++(int) { // postincrement @@ -212,6 +426,11 @@ class LinkedListHead return (_Tmp); } + /** + * @brief + * + * @return Iterator &operator + */ Iterator& operator--() { // predecrement @@ -219,6 +438,12 @@ class LinkedListHead return (*this); } + /** + * @brief + * + * @param int + * @return Iterator operator + */ Iterator operator--(int) { // postdecrement @@ -227,42 +452,83 @@ class LinkedListHead return (_Tmp); } + /** + * @brief + * + * @param _Right + * @return bool operator + */ bool operator==(Iterator const& _Right) const { // test for iterator equality return (_Ptr == _Right._Ptr); } + /** + * @brief + * + * @param _Right + * @return bool operator + */ bool operator!=(Iterator const& _Right) const { // test for iterator inequality return (!(*this == _Right)); } + /** + * @brief + * + * @param _Right + * @return bool operator + */ bool operator==(pointer const& _Right) const { // test for pointer equality return (_Ptr != _Right); } + /** + * @brief + * + * @param _Right + * @return bool operator + */ bool operator!=(pointer const& _Right) const { // test for pointer equality return (!(*this == _Right)); } + /** + * @brief + * + * @param _Right + * @return bool operator + */ bool operator==(const_reference _Right) const { // test for reference equality return (_Ptr == &_Right); } + /** + * @brief + * + * @param _Right + * @return bool operator + */ bool operator!=(const_reference _Right) const { // test for reference equality return (_Ptr != &_Right); } + /** + * @brief + * + * @return pointer + */ pointer _Mynode() { // return node pointer @@ -271,9 +537,13 @@ class LinkedListHead protected: - pointer _Ptr; // pointer to node + pointer _Ptr; /**< pointer to node */ }; + /** + * @brief + * + */ typedef Iterator iterator; }; diff --git a/src/framework/Utilities/LinkedReference/RefManager.h b/src/framework/Utilities/LinkedReference/RefManager.h index 208267983..932ed754c 100644 --- a/src/framework/Utilities/LinkedReference/RefManager.h +++ b/src/framework/Utilities/LinkedReference/RefManager.h @@ -22,8 +22,8 @@ * and lore are copyrighted by Blizzard Entertainment, Inc. */ -#ifndef _REFMANAGER_H -#define _REFMANAGER_H +#ifndef MANGOS_H_REFMANAGER +#define MANGOS_H_REFMANAGER //===================================================== @@ -31,24 +31,84 @@ #include "Utilities/LinkedReference/Reference.h" template +/** + * @brief + * + */ class RefManager : public LinkedListHead { public: + /** + * @brief + * + */ typedef LinkedListHead::Iterator > iterator; + /** + * @brief + * + */ RefManager() {} + /** + * @brief + * + */ virtual ~RefManager() { clearReferences(); } + /** + * @brief + * + * @return Reference + */ Reference* getFirst() { return ((Reference*) LinkedListHead::getFirst()); } + /** + * @brief + * + * @return const Reference + */ Reference const* getFirst() const { return ((Reference const*) LinkedListHead::getFirst()); } + /** + * @brief + * + * @return Reference + */ Reference* getLast() { return ((Reference*) LinkedListHead::getLast()); } + /** + * @brief + * + * @return const Reference + */ Reference const* getLast() const { return ((Reference const*) LinkedListHead::getLast()); } + /** + * @brief + * + * @return iterator + */ iterator begin() { return iterator(getFirst()); } + /** + * @brief + * + * @return iterator + */ iterator end() { return iterator(NULL); } + /** + * @brief + * + * @return iterator + */ iterator rbegin() { return iterator(getLast()); } + /** + * @brief + * + * @return iterator + */ iterator rend() { return iterator(NULL); } + /** + * @brief + * + */ void clearReferences() { LinkedListElement* ref; diff --git a/src/framework/Utilities/LinkedReference/Reference.h b/src/framework/Utilities/LinkedReference/Reference.h index 60dca19a1..3538f7e8d 100644 --- a/src/framework/Utilities/LinkedReference/Reference.h +++ b/src/framework/Utilities/LinkedReference/Reference.h @@ -22,47 +22,73 @@ * and lore are copyrighted by Blizzard Entertainment, Inc. */ -#ifndef _REFERENCE_H -#define _REFERENCE_H +#ifndef MANGOS_H_REFERENCE +#define MANGOS_H_REFERENCE #include "Utilities/LinkedList.h" //===================================================== template +/** + * @brief + * + */ class Reference : public LinkedListElement { private: - TO* iRefTo; - FROM* iRefFrom; + TO* iRefTo; /**< TODO */ + FROM* iRefFrom; /**< TODO */ protected: - // Tell our refTo (target) object that we have a link + /** + * @brief Tell our refTo (target) object that we have a link + * + */ virtual void targetObjectBuildLink() = 0; - // Tell our refTo (taget) object, that the link is cut + /** + * @brief Tell our refTo (taget) object, that the link is cut + * + */ virtual void targetObjectDestroyLink() = 0; - // Tell our refFrom (source) object, that the link is cut (Target destroyed) + /** + * @brief Tell our refFrom (source) object, that the link is cut (Target destroyed) + * + */ virtual void sourceObjectDestroyLink() = 0; public: + /** + * @brief + * + */ Reference() : iRefTo(NULL), iRefFrom(NULL) { } + /** + * @brief + * + */ virtual ~Reference() {} - // Create new link + /** + * @brief Create new link + * + * @param toObj + * @param fromObj + */ void link(TO* toObj, FROM* fromObj) { assert(fromObj); // fromObj MUST not be NULL if (isValid()) - unlink(); + { unlink(); } if (toObj != NULL) { @@ -72,8 +98,13 @@ class Reference : public LinkedListElement } } - // We don't need the reference anymore. Call comes from the refFrom object - // Tell our refTo object, that the link is cut + /** + * @brief We don't need the reference anymore. + * + * Call comes from the refFrom object. Tell our refTo object, that the + * link is cut. + * + */ void unlink() { targetObjectDestroyLink(); @@ -82,8 +113,13 @@ class Reference : public LinkedListElement iRefFrom = NULL; } - // Link is invalid due to destruction of referenced target object. Call comes from the refTo object - // Tell our refFrom object, that the link is cut + /** + * @brief Link is invalid due to destruction of referenced target object. + * + * Call comes from the refTo object. Tell our refFrom object, that the + * link is cut. + * + */ void invalidate() // the iRefFrom MUST remain!! { sourceObjectDestroyLink(); @@ -91,24 +127,84 @@ class Reference : public LinkedListElement iRefTo = NULL; } + /** + * @brief + * + * @return bool + */ bool isValid() const // Only check the iRefTo { return iRefTo != NULL; } - Reference* next() { return ((Reference*) LinkedListElement::next()); } - Reference const* next() const { return ((Reference const*) LinkedListElement::next()); } - Reference* prev() { return ((Reference*) LinkedListElement::prev()); } - Reference const* prev() const { return ((Reference const*) LinkedListElement::prev()); } + /** + * @brief + * + * @return Reference + */ + Reference* next() { return((Reference*) LinkedListElement::next()); } + /** + * @brief + * + * @return const Reference + */ + Reference const* next() const { return((Reference const*) LinkedListElement::next()); } + /** + * @brief + * + * @return Reference + */ + Reference* prev() { return((Reference*) LinkedListElement::prev()); } + /** + * @brief + * + * @return const Reference + */ + Reference const* prev() const { return((Reference const*) LinkedListElement::prev()); } - Reference* nocheck_next() { return ((Reference*) LinkedListElement::nocheck_next()); } - Reference const* nocheck_next() const { return ((Reference const*) LinkedListElement::nocheck_next()); } - Reference* nocheck_prev() { return ((Reference*) LinkedListElement::nocheck_prev()); } - Reference const* nocheck_prev() const { return ((Reference const*) LinkedListElement::nocheck_prev()); } - + /** + * @brief + * + * @return Reference + */ + Reference* nocheck_next() { return((Reference*) LinkedListElement::nocheck_next()); } + /** + * @brief + * + * @return const Reference + */ + Reference const* nocheck_next() const { return((Reference const*) LinkedListElement::nocheck_next()); } + /** + * @brief + * + * @return Reference + */ + Reference* nocheck_prev() { return((Reference*) LinkedListElement::nocheck_prev()); } + /** + * @brief + * + * @return const Reference + */ + Reference const* nocheck_prev() const { return((Reference const*) LinkedListElement::nocheck_prev()); } + + /** + * @brief + * + * @return TO *operator -> + */ TO* operator->() const { return iRefTo; } + /** + * @brief + * + * @return TO + */ TO* getTarget() const { return iRefTo; } + /** + * @brief + * + * @return FROM + */ FROM* getSource() const { return iRefFrom; } }; diff --git a/src/framework/Utilities/TypeList.h b/src/framework/Utilities/TypeList.h index 1c6b75e89..9407c4056 100644 --- a/src/framework/Utilities/TypeList.h +++ b/src/framework/Utilities/TypeList.h @@ -25,18 +25,26 @@ #ifndef MANGOS_TYPELIST_H #define MANGOS_TYPELIST_H -/* - @struct TypeList - TypeList is the most simple but yet the most powerfull class of all. It holds - at compile time the different type of objects in a linked list. - */ - class TypeNull; template +/** + * @brief TypeList is the most simple but yet the most powerfull class of all. + * + * It holds at compile time the different type of objects in a linked list. + * + */ struct TypeList { + /** + * @brief + * + */ typedef HEAD Head; + /** + * @brief + * + */ typedef TAIL Tail; }; diff --git a/src/framework/Utilities/UnorderedMapSet.h b/src/framework/Utilities/UnorderedMapSet.h index 8470aca6e..c132c632f 100644 --- a/src/framework/Utilities/UnorderedMapSet.h +++ b/src/framework/Utilities/UnorderedMapSet.h @@ -96,9 +96,14 @@ HASH_NAMESPACE_END # define HASH_NAMESPACE_END } using std::hash_map; using std::hash_set; -#elif COMPILER == COMPILER_CLANG +#elif COMPILER == COMPILER_CLANG && defined(__FreeBSD__) # define UNORDERED_MAP std::unordered_map # define UNORDERED_SET std::unordered_set +# define HASH_NAMESPACE_START namespace std { namespace __1 { +# define HASH_NAMESPACE_END } } +#elif COMPILER == COMPILER_CLANG +# define UNORDERED_MAP std::tr1::unordered_map +# define UNORDERED_SET std::tr1::unordered_set # define HASH_NAMESPACE_START namespace std { namespace tr1 { # define HASH_NAMESPACE_END } } #elif COMPILER == COMPILER_GNU && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3) diff --git a/src/game/AuctionHouseBot/AuctionHouseBot.h b/src/game/AuctionHouseBot/AuctionHouseBot.h index 1f89cd6d5..9e2cf4b2c 100644 --- a/src/game/AuctionHouseBot/AuctionHouseBot.h +++ b/src/game/AuctionHouseBot/AuctionHouseBot.h @@ -31,7 +31,27 @@ #include "SharedDefines.h" #include "Item.h" -// shadow of ItemQualities with skipped ITEM_QUALITY_HEIRLOOM, anything after ITEM_QUALITY_ARTIFACT(6) in fact +/** + * This is the AuctionHouseBot and it is used to make less populated servers + * appear more populated than they actually are by having auctions created by + * the mangos daemon itself instead of by players. + * + * This bot can both create auctions and buyout/bid on auctions to create a feel + * of a very active AH. The key classes for creating and buying auctions are + * \ref AuctionBotBuyer for buying and \ref AuctionBotSeller for selling. + * + * \todo Describe more of how it all works, ie algorithms etc. + */ + +/** \addtogroup auctionbot + * @{ + * \file + */ + +/** + * @brief shadow of ItemQualities with skipped ITEM_QUALITY_HEIRLOOM, anything after ITEM_QUALITY_ARTIFACT(6) in fact + * + */ enum AuctionQuality { AUCTION_QUALITY_GREY = ITEM_QUALITY_POOR, @@ -40,11 +60,15 @@ enum AuctionQuality AUCTION_QUALITY_BLUE = ITEM_QUALITY_RARE, AUCTION_QUALITY_PURPLE = ITEM_QUALITY_EPIC, AUCTION_QUALITY_ORANGE = ITEM_QUALITY_LEGENDARY, - AUCTION_QUALITY_YELLOW = ITEM_QUALITY_ARTIFACT, + AUCTION_QUALITY_YELLOW = ITEM_QUALITY_ARTIFACT }; #define MAX_AUCTION_QUALITY 7 +/** + * @brief + * + */ enum AuctionBotConfigUInt32Values { CONFIG_UINT32_AHBOT_MAXTIME, @@ -104,6 +128,10 @@ enum AuctionBotConfigUInt32Values CONFIG_UINT32_AHBOT_UINT32_COUNT }; +/** + * @brief + * + */ enum AuctionBotConfigBoolValues { CONFIG_BOOL_AHBOT_BUYER_ALLIANCE_ENABLED, @@ -127,103 +155,369 @@ enum AuctionBotConfigBoolValues CONFIG_UINT32_AHBOT_BOOL_COUNT }; -// All basic config data used by other AHBot classes for self-configure. +/** + * @brief All basic config data used by other AHBot classes for self-configure. + * + */ class AuctionBotConfig { public: + /** + * @brief + * + */ AuctionBotConfig(); + /** + * @brief + * + * @param filename + */ void SetConfigFileName(char const* filename) { m_configFileName = filename; } + /** + * @brief + * + * @return bool + */ bool Initialize(); + /** + * @brief + * + * @return const char + */ const char* GetAHBotIncludes() const { return m_AHBotIncludes.c_str(); } + /** + * @brief + * + * @return const char + */ const char* GetAHBotExcludes() const { return m_AHBotExcludes.c_str(); } + /** + * @brief + * + * @param index + * @return uint32 + */ uint32 getConfig(AuctionBotConfigUInt32Values index) const { return m_configUint32Values[index]; } + /** + * @brief + * + * @param index + * @return bool + */ bool getConfig(AuctionBotConfigBoolValues index) const { return m_configBoolValues[index]; } + /** + * @brief + * + * @param index + * @param value + */ void setConfig(AuctionBotConfigBoolValues index, bool value) { m_configBoolValues[index] = value; } + /** + * @brief + * + * @param index + * @param value + */ void setConfig(AuctionBotConfigUInt32Values index, uint32 value) { m_configUint32Values[index] = value; } + + /** + * @brief Gets the ratio of items to sell for a given auctionhouse type + * + * @param houseType Type of the house. + * @return uint32 a value between 0 and 10000 probably representing 0%-100% + */ uint32 getConfigItemAmountRatio(AuctionHouseType houseType) const; + /** + * @brief Gets if a buyer is enabled for the given auctionhouse type + * + * @param houseType Type of the house, ie: alliance/horde/neutral + * @return bool true if a buyer is enabled, false otherwise + */ bool getConfigBuyerEnabled(AuctionHouseType houseType) const; + /** + * @brief Gets the ratio for the amount of items of a certain quality to be sold + * + * @param quality quality of the item you want to know the ratio for + * @return uint32 probably a value between 0 and 10000 representing 0%-100% as the config values seem to be capped at this + */ uint32 getConfigItemQualityAmount(AuctionQuality quality) const; + /** + * @brief + * + * @return uint32 + */ uint32 GetItemPerCycleBoost() const { return m_ItemsPerCycleBoost; } + /** + * @brief + * + * @return uint32 + */ uint32 GetItemPerCycleNormal() const { return m_ItemsPerCycleNormal; } + /** + * @brief Reloads the AhBot config. + * + * @return bool true if the config was successfully reloaded, false otherwise + */ bool Reload(); + /** + * @brief Gets the name of the item class. + * + * @param itemclass class of the item you want to lookup name for + * @return const char a string describing the name of the item class + * \see ItemClass + */ static char const* GetItemClassName(ItemClass itemclass); + + /** + * @brief Does the same thing as \ref AuctionBotConfig::GetItemClassName converts a enum + * value to a readable string + * + * @param houseType the housetype you would like to "translate" + * @return const char the string representation of the num value + */ static char const* GetHouseTypeName(AuctionHouseType houseType); private: - std::string m_configFileName; - std::string m_AHBotIncludes; - std::string m_AHBotExcludes; - Config m_AhBotCfg; - uint32 m_ItemsPerCycleBoost; - uint32 m_ItemsPerCycleNormal; + std::string m_configFileName; /**< TODO */ + std::string m_AHBotIncludes; /**< TODO */ + std::string m_AHBotExcludes; /**< TODO */ + Config m_AhBotCfg; /**< TODO */ + uint32 m_ItemsPerCycleBoost; /**< TODO */ + uint32 m_ItemsPerCycleNormal; /**< TODO */ - uint32 m_configUint32Values[CONFIG_UINT32_AHBOT_UINT32_COUNT]; - bool m_configBoolValues[CONFIG_UINT32_AHBOT_BOOL_COUNT]; + uint32 m_configUint32Values[CONFIG_UINT32_AHBOT_UINT32_COUNT]; /**< TODO */ + bool m_configBoolValues[CONFIG_UINT32_AHBOT_BOOL_COUNT]; /**< TODO */ + /** + * @brief + * + * @param AHBotIncludes + */ void SetAHBotIncludes(const std::string& AHBotIncludes) { m_AHBotIncludes = AHBotIncludes; } + /** + * @brief + * + * @param AHBotExcludes + */ void SetAHBotExcludes(const std::string& AHBotExcludes) { m_AHBotExcludes = AHBotExcludes; } + /** + * @brief Sets a certain config value to the given default value + * + * @param index index to set + * @param fieldname name of the field to set, ie: how it is represented in the config file + * @param defvalue the default value for the field + */ void setConfig(AuctionBotConfigUInt32Values index, char const* fieldname, uint32 defvalue); + /** + * @brief Sets a certain config value to given default value and a max it can have that it will cap at + * + * @param index index to set + * @param fieldname name of the field to set, ie: how it is represented in the config file + * @param defvalue the default value for the field + * @param maxvalue the maximum value this config can have + */ void setConfigMax(AuctionBotConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 maxvalue); + /** + * @brief Sets a certain config value to given default value and a max it can have that it will cap at + * + * @param index index to set + * @param fieldname name of the field to set, ie: how it is represented in the config file + * @param defvalue the default value for the field + * @param minvalue the minimal value this config can have + * @param maxvalue the maximum value this config can have + */ void setConfigMinMax(AuctionBotConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue, uint32 maxvalue); + /** + * @brief Sets a certain config value to the given default value + * + * @param index index to set + * @param fieldname name of the field to set, ie: how it is represented in the config file + * @param defvalue the default value for this field + */ void setConfig(AuctionBotConfigBoolValues index, char const* fieldname, bool defvalue); + /** + * @brief Retrieves the configuration for the \ref AuctionHouseBot from a configuration file. + * + */ void GetConfigFromFile(); }; #define sAuctionBotConfig MaNGOS::Singleton::Instance() +/** + * @brief This is the base interface for the \ref AuctionBotSeller and \ref AuctionBotBuyer classes + * which in itself only provides the possibility to use dynamic_cast in some of the + * \ref AuctionHouseBot methods, ie: \ref AuctionHouseBot::SetItemsRatio uses it to cast it's + * member AuctionHouseBot::m_Seller to a \ref AuctionBotSeller. + * + */ class AuctionBotAgent { public: + /** + * @brief + * + */ AuctionBotAgent() {} + /** + * @brief + * + */ virtual ~AuctionBotAgent() {} public: + /** + * @brief Initializes this agent/bot and makes sure that there's anything to actually do for it. + * If there's not it will return false and there's really no interest in keeping it for + * the moment, otherwise returns true and has atleast one active house where it will do + * business. + * + * @return bool true if we intialized with at least one auction house to do business in, false otherwise + */ virtual bool Initialize() = 0; + + /** + * @brief This method updates what's going on on the AH for the bots, ie: if this is called for the + * \ref AuctionBotBuyer it will place bids on items etc if there's a config file for it. If + * the \ref AuctionBotSeller is called instead it would put up some new items if there's a + * config file for it. + * + * @param houseType the house type we should work with while updating + * @return bool true if any update was actually done, ie: we put some items up/bought some, false otherwise + */ virtual bool Update(AuctionHouseType houseType) = 0; }; +/** + * @brief Structure used in \ref AuctionHouseBot::PrepareStatusInfos to show how many items there + * are in each auction house and how many of each quality there are that were created by + * one of the 2 agents \ref AuctionBotBuyer and \ref AuctionBotSeller + * \see AuctionQuality + * + */ struct AuctionHouseBotStatusInfoPerType { - uint32 ItemsCount; - uint32 QualityInfo[MAX_AUCTION_QUALITY]; + uint32 ItemsCount; /**< How many items there are totally in this AH */ + uint32 QualityInfo[MAX_AUCTION_QUALITY]; /**< How many items of each quality there are */ }; +/** + * @brief Used to get an array with all possible Action Houses, ie: neutral,ally,horde. + * + */ typedef AuctionHouseBotStatusInfoPerType AuctionHouseBotStatusInfo[MAX_AUCTION_HOUSE_TYPE]; -// This class handle both Selling and Buying method -// (holder of AuctionBotBuyer and AuctionBotSeller objects) +/** + * @brief This class handle both Selling and Buying method + * (holder of AuctionBotBuyer and AuctionBotSeller objects) + * (Taken from comments in source) + * + * \todo Better description here perhaps + */ class AuctionHouseBot { public: + /** + * @brief Initializes a new instance of the \ref AuctionHouseBot class. + * + */ AuctionHouseBot(); + /** + * @brief Finalizes an instance of the \ref AuctionHouseBot class. + * + */ ~AuctionHouseBot(); + /** + * @brief Updates the \ref AuctionHouseBot by checking if either the \ref AuctionBotSeller or + * \ref AuctionBotBuyer wants to sell/buy anything and in that case lets one of them do + * that and the other one will have to wait until the next call to \ref AuctionHouseBot::Update + * + */ void Update(); + /** + * @brief Initializes this instance. + * + */ void Initialize(); // Followed method is mainly used by level3.cpp for ingame/console command + /** + * @brief Sets the items ratio which probably decides how many items should + * appear in each of the auction houses + * + * @param al The alliance house ratio + * @param ho The horde house ratio + * @param ne The neutral house ratio + */ void SetItemsRatio(uint32 al, uint32 ho, uint32 ne); + /** + * @brief Sets the items ratio for a specific house, like \ref AuctionHouseBot::SetItemsRatio but + * only for one house. + * + * @param house The house + * @param val The new ratio + */ void SetItemsRatioForHouse(AuctionHouseType house, uint32 val); + /** + * @brief Sets the items amount. + * + * @param (vals)[] The vals. + */ void SetItemsAmount(uint32(&vals) [MAX_AUCTION_QUALITY]); + /** + * @brief Changes the ratio for how often a certain quality of items should show up at the + * AH. A specialised version of \ref AuctionHouseBot::SetItemsAmount + * + * @param quality quality of the items you want to change the ratio for + * @param val the new ratio you want as a value between 0-10000 probably representing 0%-100% + * \see AuctionQuality + */ void SetItemsAmountForQuality(AuctionQuality quality, uint32 val); + /** + * @brief Reloads all the configurations, for the AH bot and for both \ref AuctionBotBuyer and + * \ref AuctionBotSeller and ourselves + * + * @return bool true if it went well, false otherwise + */ bool ReloadAllConfig(); + /** + * @brief Expires all the items currently created by the AH bot and they'll be replaced later on + * again. If parameter all is false only auctions without a bid are removed. + * + * @param all Whether to expire all auctions or only those without a bid + */ void Rebuild(bool all); + /** + * @brief Fills a status info structure with data about how many items of each there + * currently are in the auction house that the auction bot has created + * + * @param statusInfo the structure to fill with data + */ void PrepareStatusInfos(AuctionHouseBotStatusInfo& statusInfo); private: + /** + * @brief Initializes the agents, ie: the \ref AuctionBotBuyer and \ref AuctionBotSeller + * + */ void InitilizeAgents(); - AuctionBotAgent* m_Buyer; - AuctionBotAgent* m_Seller; + AuctionBotAgent* m_Buyer; /**< The buyer (\ref AuctionBotBuyer) for this \ref AuctionHouseBot */ + AuctionBotAgent* m_Seller; /**< The seller (\ref AuctionBotSeller) for this \ref AuctionHouseBot */ - uint32 m_OperationSelector; // 0..2*MAX_AUCTION_HOUSE_TYPE-1 + uint32 m_OperationSelector; /**< 0..2*MAX_AUCTION_HOUSE_TYPE-1 */ }; + +///Convenience to easily access the singleton for the \ref AuctionHouseBot #define sAuctionBot MaNGOS::Singleton::Instance() +/** @} */ + #endif diff --git a/src/game/AuctionHouseBot/CMakeLists.txt b/src/game/AuctionHouseBot/CMakeLists.txt index 6101cd3b2..2bb29fe5a 100644 --- a/src/game/AuctionHouseBot/CMakeLists.txt +++ b/src/game/AuctionHouseBot/CMakeLists.txt @@ -14,5 +14,5 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ahbot.conf.dist.in ${CMAKE_CURRENT_BINARY_DIR}/ahbot.conf.dist) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ahbot.conf.dist DESTINATION ${CONF_DIR}) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ahbot.conf.dist.in" "${CMAKE_CURRENT_BINARY_DIR}/ahbot.conf.dist") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ahbot.conf.dist" DESTINATION "${CONF_DIR}") diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index cad931652..b1c9b9f93 100644 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -42,6 +42,11 @@ #include "Policies/Singleton.h" +/** \addtogroup auctionhouse + * @{ + * \file + */ + INSTANTIATE_SINGLETON_1(AuctionHouseMgr); AuctionHouseMgr::AuctionHouseMgr() @@ -54,10 +59,11 @@ AuctionHouseMgr::~AuctionHouseMgr() delete itr->second; } + AuctionHouseObject* AuctionHouseMgr::GetAuctionsMap(AuctionHouseEntry const* house) { if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) - return &mAuctions[AUCTION_HOUSE_NEUTRAL]; + { return &mAuctions[AUCTION_HOUSE_NEUTRAL]; } // team have linked auction houses switch (GetAuctionHouseTeam(house)) @@ -68,6 +74,8 @@ AuctionHouseObject* AuctionHouseMgr::GetAuctionsMap(AuctionHouseEntry const* hou } } + + uint64 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item* pItem) { double deposit = float(pItem->GetProto()->SellPrice * pItem->GetCount() * (time / MIN_AUCTION_TIME)); @@ -77,7 +85,7 @@ uint64 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 float min_deposit = float(sWorld.getConfig(CONFIG_UINT32_AUCTION_DEPOSIT_MIN)); if (deposit < min_deposit) - deposit = min_deposit; + { deposit = min_deposit; } return uint64(deposit * sWorld.getConfig(CONFIG_FLOAT_RATE_AUCTION_DEPOSIT)); } @@ -87,7 +95,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction) { Item* pItem = GetAItem(auction->itemGuidLow); if (!pItem) - return; + { return; } ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder); Player* bidder = sObjectMgr.GetPlayer(bidder_guid); @@ -116,7 +124,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction) if (bidder_security > SEC_PLAYER) // not do redundant DB requests { if (!sObjectMgr.GetPlayerNameByGUID(bidder_guid, bidder_name)) - bidder_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN); + { bidder_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN); } } } @@ -126,7 +134,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction) if (auction_owner) owner_name = auction_owner->GetName(); else if (ownerGuid && !sObjectMgr.GetPlayerNameByGUID(ownerGuid, owner_name)) - owner_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN); + { owner_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN); } uint32 owner_accid = sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid); @@ -189,7 +197,7 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction) uint32 owner_accId = 0; if (!owner) - owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid); + { owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid); } // owner exist if (owner || owner_accId) @@ -238,7 +246,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction) uint32 owner_accId = 0; if (!owner) - owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid); + { owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid); } // owner exist if (owner || owner_accId) @@ -490,7 +498,7 @@ bool AuctionHouseMgr::RemoveAItem(uint32 id) void AuctionHouseMgr::Update() { for (int i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i) - mAuctions[i].Update(); + { mAuctions[i].Update(); } } uint32 AuctionHouseMgr::GetAuctionHouseTeam(AuctionHouseEntry const* house) @@ -540,13 +548,13 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(Unit* unit) { FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId); if (!u_entry) - houseid = 7; // goblin auction house + { houseid = 7; } // goblin auction house else if (u_entry->ourMask & FACTION_MASK_ALLIANCE) - houseid = 1; // human auction house + { houseid = 1; } // human auction house else if (u_entry->ourMask & FACTION_MASK_HORDE) - houseid = 6; // orc auction house + { houseid = 6; } // orc auction house else - houseid = 7; // goblin auction house + { houseid = 7; } // goblin auction house break; } } @@ -555,7 +563,7 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(Unit* unit) { Player* player = (Player*)unit; if (player->GetAuctionAccessMode() > 0) - houseid = 7; + { houseid = 7; } else { switch (((Player*)unit)->GetTeam()) @@ -624,7 +632,7 @@ void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player, if (Aentry->bidder == player->GetGUIDLow()) { if (itr->second->BuildAuctionInfo(data)) - ++count; + { ++count; } ++totalcount; } } @@ -640,7 +648,7 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, if (Aentry->owner == player->GetGUIDLow()) { if (Aentry->BuildAuctionInfo(data)) - ++count; + { ++count; } ++totalcount; } } @@ -812,7 +820,7 @@ void WorldSession::BuildListAuctionItems(std::vector const& aucti continue; Item* item = sAuctionMgr.GetAItem(Aentry->itemGuidLow); if (!item) - continue; + { continue; } if (isFull) { @@ -824,16 +832,16 @@ void WorldSession::BuildListAuctionItems(std::vector const& aucti ItemPrototype const* proto = item->GetProto(); if (itemClass != 0xffffffff && proto->Class != itemClass) - continue; + { continue; } if (itemSubClass != 0xffffffff && proto->SubClass != itemSubClass) - continue; + { continue; } if (inventoryType != 0xffffffff && proto->InventoryType != inventoryType) - continue; + { continue; } if (quality != 0xffffffff && proto->Quality < quality) - continue; + { continue; } if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax))) continue; @@ -845,7 +853,7 @@ void WorldSession::BuildListAuctionItems(std::vector const& aucti sObjectMgr.GetItemLocaleStrings(proto->ItemId, loc_idx, &name); if (!wsearchedname.empty() && !Utf8FitTo(name, wsearchedname)) - continue; + { continue; } if (count < 50 && totalcount >= listfrom) { @@ -920,7 +928,7 @@ AuctionEntry* AuctionHouseObject::AddAuction(AuctionHouseEntry const* auctionHou AH->SaveToDB(); if (pl) - pl->SaveInventoryAndGoldToDB(); + { pl->SaveInventoryAndGoldToDB(); } CharacterDatabase.CommitTransaction(); @@ -971,7 +979,7 @@ uint64 AuctionEntry::GetAuctionOutBid() const { uint64 outbid = (bid / 100) * 5; if (!outbid) - outbid = 1; + { outbid = 1; } return outbid; } @@ -996,7 +1004,7 @@ void AuctionEntry::AuctionBidWinning(Player* newbidder) CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("UPDATE auction SET itemguid = 0, moneyTime = '" UI64FMTD "', buyguid = '%u', lastbid = '" UI64FMTD "' WHERE id = '%u'", (uint64)moneyDeliveryTime, bidder, bid, Id); if (newbidder) - newbidder->SaveInventoryAndGoldToDB(); + { newbidder->SaveInventoryAndGoldToDB(); } CharacterDatabase.CommitTransaction(); sAuctionMgr.SendAuctionWonMail(this); @@ -1008,7 +1016,7 @@ bool AuctionEntry::UpdateBid(uint64 newbid, Player* newbidder /*=NULL*/) // bid can't be greater buyout if (buyout && newbid > buyout) - newbid = buyout; + { newbid = buyout; } if (newbidder && newbidder->GetGUIDLow() == bidder) { @@ -1020,7 +1028,7 @@ bool AuctionEntry::UpdateBid(uint64 newbid, Player* newbidder /*=NULL*/) newbidder->ModifyMoney(-int64(newbid)); if (bidder) // return money to old bidder if present - WorldSession::SendAuctionOutbiddedMail(this); + { WorldSession::SendAuctionOutbiddedMail(this); } } bidder = newbidder ? newbidder->GetGUIDLow() : 0; @@ -1035,7 +1043,7 @@ bool AuctionEntry::UpdateBid(uint64 newbid, Player* newbidder /*=NULL*/) CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("UPDATE auction SET buyguid = '%u', lastbid = '" UI64FMTD "' WHERE id = '%u'", bidder, bid, Id); if (newbidder) - newbidder->SaveInventoryAndGoldToDB(); + { newbidder->SaveInventoryAndGoldToDB(); } CharacterDatabase.CommitTransaction(); return true; } @@ -1045,3 +1053,5 @@ bool AuctionEntry::UpdateBid(uint64 newbid, Player* newbidder /*=NULL*/) return false; } } + +/** @} */ diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 5e75982b5..53875cdc9 100755 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -137,7 +137,7 @@ typedef UNORDERED_MAP < uint32/*(mapid,spawnMode) pair*/, CellObjectGuidsMap > M #define MAX_CREATURE_AI_TEXT_STRING_ID (-1000000) // Anything below MAX_CREATURE_AI_TEXT_STRING_ID is handled by the external script lib -COMPILE_ASSERT(MAX_DB_SCRIPT_STRING_ID < ACE_INT32_MAX, "Must scope with int32 range"); +static_assert(MAX_DB_SCRIPT_STRING_ID < ACE_INT32_MAX, "Must scope with int32 range"); struct MangosStringLocale { diff --git a/src/game/Player.cpp b/src/game/Player.cpp index bca06e330..e06168a73 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -16199,8 +16199,6 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) // restore remembered power/health values (but not more max values) uint32 savedhealth = fields[46].GetUInt32(); SetHealth(savedhealth > GetMaxHealth() ? GetMaxHealth() : savedhealth); - - COMPILE_ASSERT(MAX_STORED_POWERS == 5, "Query not updated."); for (uint32 i = 0; i < MAX_STORED_POWERS; ++i) { uint32 savedpower = fields[47 + i].GetUInt32(); @@ -16223,7 +16221,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) case 1: SetGameMaster(true); break; // enable case 2: // save state if (extraflags & PLAYER_EXTRA_GM_ON) - SetGameMaster(true); + { SetGameMaster(true); } break; } @@ -17631,7 +17629,6 @@ void Player::SaveToDB() uberInsert.addUInt32(GetHealth()); - COMPILE_ASSERT(MAX_STORED_POWERS == 5, "Query not updated."); for (uint32 i = 0; i < MAX_STORED_POWERS; ++i) uberInsert.addUInt32(GetPowerByIndex(i)); @@ -18312,14 +18309,13 @@ void Player::_SaveStats() stmt.addUInt32(GetGUIDLow()); stmt.addUInt32(GetMaxHealth()); - COMPILE_ASSERT(MAX_STORED_POWERS == 5, "Query not updated."); for (uint32 i = 0; i < MAX_STORED_POWERS; ++i) stmt.addUInt32(GetMaxPowerByIndex(i)); for (int i = 0; i < MAX_STATS; ++i) - stmt.addFloat(GetStat(Stats(i))); + { stmt.addFloat(GetStat(Stats(i))); } // armor + school resistances for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) - stmt.addUInt32(GetResistance(SpellSchools(i))); + { stmt.addUInt32(GetResistance(SpellSchools(i))); } stmt.addFloat(GetFloatValue(PLAYER_BLOCK_PERCENTAGE)); stmt.addFloat(GetFloatValue(PLAYER_DODGE_PERCENTAGE)); stmt.addFloat(GetFloatValue(PLAYER_PARRY_PERCENTAGE)); @@ -18337,7 +18333,7 @@ void Player::outDebugStatsValues() const { // optimize disabled debug output if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG) || sLog.HasLogFilter(LOG_FILTER_PLAYER_STATS)) - return; + { return; } sLog.outDebug("HP is: \t\t\t%u\t\tMP is: \t\t\t%u", GetMaxHealth(), GetMaxPower(POWER_MANA)); sLog.outDebug("AGILITY is: \t\t%f\t\tSTRENGTH is: \t\t%f", GetStat(STAT_AGILITY), GetStat(STAT_STRENGTH)); diff --git a/src/game/Unit.h b/src/game/Unit.h index c20020dad..e51f22a64 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -154,7 +154,7 @@ enum SpellFacingFlags /** * byte value (UNIT_FIELD_BYTES_1,0). - * + * * This is not to be used as a bitmask but as one value * each, ie: you can't be standing and sitting down at * the same time. @@ -252,6 +252,10 @@ enum Swing TWOHANDEDSWING = 2 }; +/** + * This seems to be the state a target of an attack can be in. + * \todo Document more + */ enum VictimState { VICTIMSTATE_UNAFFECTED = 0, // seen in relation with HITINFO_MISS @@ -266,9 +270,10 @@ enum VictimState }; /** - * TODO: Rename the LEFTSWING and NORMALSWING/2 to: * OFFSWING and BASESWING/2 or MAINSWING/2 to be more * in line with what is used in the other parts? + * + * \todo Rename the LEFTSWING and NORMALSWING/2 to: */ enum HitInfo { @@ -407,8 +412,6 @@ enum UnitMods UNIT_MOD_POWER_END = UNIT_MOD_ALTERNATIVE + 1 }; -COMPILE_ASSERT(UNIT_MOD_POWER_END - UNIT_MOD_POWER_START == MAX_POWERS, "Power-related UnitMods are not updated."); - enum BaseModGroup { CRIT_PERCENTAGE, @@ -428,14 +431,16 @@ enum BaseModType enum DeathState { - ALIVE = 0, // show as alive - JUST_DIED = 1, // temporary state at die, for creature auto converted to CORPSE, for player at next update call - CORPSE = 2, // corpse state, for player this also meaning that player not leave corpse - DEAD = 3, // for creature despawned state (corpse despawned), for player CORPSE/DEAD not clear way switches (FIXME), and use m_deathtimer > 0 check for real corpse state - JUST_ALIVED = 4, // temporary state at resurrection, for creature auto converted to ALIVE, for player at next update call + ALIVE = 0, ///< show as alive + JUST_DIED = 1, ///< temporary state at die, for creature auto converted to CORPSE, for player at next update call + CORPSE = 2, ///< corpse state, for player this also meaning that player not leave corpse + DEAD = 3, ///< for creature despawned state (corpse despawned), for player CORPSE/DEAD not clear way switches (FIXME), and use m_deathtimer > 0 check for real corpse state + JUST_ALIVED = 4 ///< temporary state at resurrection, for creature auto converted to ALIVE, for player at next update call }; -// internal state flags for some auras and movement generators, other. +/** + * internal state flags for some auras and movement generators, other. (Taken from comment) + */ enum UnitState { // persistent state (applied by aura/etc until expire) @@ -2217,35 +2222,284 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void EnergizeBySpell(Unit* pVictim, uint32 SpellID, uint32 Damage, Powers powertype); uint32 SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage); void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + /** + * Casts a spell simple and square, outputs some debugging info for some reasons, ie: if the + * spellInfo is NULL it is logged and the function won't do anything. If the spell is triggered + * by an \ref Aura and there's no originalCaster it is updated to be the cast of the \ref Aura + * and the triggeredBy is set to be the \ref Aura s \ref SpellEntry. Some work is done to + * work out if we should set a destination and/or source for the spell and it is then cast. + * + * Also, linked spells seem to be taken care of in here, but only the ones that should be + * removed on cast, ie: \ref SpellLinkedType::SPELL_LINKED_TYPE_REMOVEONCAST. See + * \ref SpellLinkedEntry for more info and \ref SpellLinkedType + * + * Finally calls \ref Spell::prepare on the \ref Spell and that's where it continues the + * execution. + * + * @param Victim victim that should be hit by the spell + * @param spellInfo info about the spell to cast + * @param triggered whether this was triggered by some outside circumstance or used as a button + * press on your action bar, true means triggered by outside circumstance + * @param castItem the \ref Item that cast the spell if any, usually NULL + * @param triggeredByAura the \ref Aura that triggered the spell if any + * @param originalCaster usually just \ref ObjectGuid constructor + * @param triggeredBy the \ref SpellEntry that triggered this spell if any + * \see Spell + * \see SpellCastTargets + * \todo What's the original caster? + * \todo Document the spell linked + */ void CastSpell(Unit* Victim, SpellEntry const* spellInfo, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + /** + * Does pretty much the same thing as \ref Unit::CastSpell but uses the three bp0-bp2 variables + * to change the \ref Spell s \ref Spell::m_currentBasePoints for the different + * \ref SpellEffectIndexes. This also works as the first version of \ref Unit::CastSpell which + * just does some checks and then calls the other one. + * + * @param Victim victim that should be hit by the spell + * @param spellId id of the spell to be cast + * @param bp0 this will change the \ref Spell s member \ref Spell::m_currentBasePoints for + * \ref SpellEffectIndex::EFFECT_INDEX_0 to this value if it's not NULL. + * @param bp1 this will change the \ref Spell s member \ref Spell::m_currentBasePoints for + * \ref SpellEffectIndex::EFFECT_INDEX_1 to this value if it's not NULL. + * @param bp2 this will change the \ref Spell s member \ref Spell::m_currentBasePoints for + * \ref SpellEffectIndex::EFFECT_INDEX_2 to this value if it's not NULL. + * @param triggered whether this was triggered by some outside circumstance or used as a button + * press on your action bar, true means triggered by outside circumstance + * @param castItem the \ref Item that cast this if any + * @param triggeredByAura the \ref Aura that triggered this + * @param originalCaster the original caster if any + * @param triggeredBy the \ref SpellEntry that triggered this cast, if any + * \todo What's the original caster? + */ void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + /** + * Same idea for this one as for \ref Unit::CastCustomSpell with a change to the spellid being + * exchanged for a \ref SpellEntry instead + * + * @param Victim victim that should be hit by the spell + * @param spellInfo info about the spell to cast + * @param bp0 this will change the \ref Spell s member \ref Spell::m_currentBasePoints for + * \ref SpellEffectIndex::EFFECT_INDEX_0 to this value if it's not NULL. + * @param bp1 this will change the \ref Spell s member \ref Spell::m_currentBasePoints for + * \ref SpellEffectIndex::EFFECT_INDEX_1 to this value if it's not NULL. + * @param bp2 this will change the \ref Spell s member \ref Spell::m_currentBasePoints for + * \ref SpellEffectIndex::EFFECT_INDEX_2 to this value if it's not NULL. + * @param triggered whether this was triggered by some outside circumstance or used as a button + * press on your action bar, true means triggered by outside circumstance + * @param castItem the \ref Item that cast this if any + * @param triggeredByAura the \ref Aura that triggered this + * @param originalCaster the original caster if any + * @param triggeredBy the \ref SpellEntry that triggered this cast, if any + * \todo What's the original caster? + */ void CastCustomSpell(Unit* Victim, SpellEntry const* spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + /** + * Same idea as for \ref Unit::CastSpell, but with the parameters x, y, z telling the + * destination and source of the \ref SpellCastTargets depending on if the + * \ref SpellEntry::Targets bitflags have the + * \ref SpellCastTargetFlags::TARGET_FLAG_DEST_LOCATION set for destination and + * \ref SpellCastTargetFlags::TARGET_FLAG_SOURCE_LOCATION set for location + * + * @param x coord for source/dest + * @param y coord for source/dest + * @param z coord for source/dest + * @param spellId id of the spell that was cast + * @param triggered whether this was triggered by some outside circumstance or used as a button + * press on your action bar, true means triggered by outside circumstance + * @param castItem the \ref Item that cast this if any + * @param triggeredByAura the \ref Aura that triggered this + * @param originalCaster the original caster if any + * @param triggeredBy the \ref SpellEntry that triggered this cast, if any + */ void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + /** + * Same idea as for \ref Unit::CastSpell, but with the parameters x, y, z telling the + * destination and source of the \ref SpellCastTargets depending on if the + * \ref SpellEntry::Targets bitflags have the + * \ref SpellCastTargetFlags::TARGET_FLAG_DEST_LOCATION set for destination and + * \ref SpellCastTargetFlags::TARGET_FLAG_SOURCE_LOCATION set for location + * + * @param x coord for source/dest + * @param y coord for source/dest + * @param z coord for source/dest + * @param spellInfo info about the spell to cast + * @param triggered whether this was triggered by some outside circumstance or used as a button + * press on your action bar, true means triggered by outside circumstance + * @param castItem the \ref Item that cast this if any + * @param triggeredByAura the \ref Aura that triggered this + * @param originalCaster the original caster if any + * @param triggeredBy the \ref SpellEntry that triggered this cast, if any + */ void CastSpell(float x, float y, float z, SpellEntry const* spellInfo, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + /** + * Changes the display id for this \ref Unit to the native one that it usually has. + * This is done by calling \ref Unit::SetDisplayId and \ref Unit::GetNativeDisplayId + * like so: + * \code{.cpp} + * SetDisplayId(GetNativeDisplayId()); + * \endcode + */ void DeMorph(); + /** + * This sends an AttackStateUpdate, some info about damage that you've done etc. + * @param damageInfo the damage info used for knowing what to send + * \see OpcodesList::SMSG_ATTACKERSTATEUPDATE + * \todo Find out when and why this is sent + */ void SendAttackStateUpdate(CalcDamageInfo* damageInfo); + /** + * The same thing as \ref Unit::SendAttackStateUpdate but you send along all the parameters + * that are needed instead of giving them through \ref CalcDamageInfo + * @param HitInfo hit information as in the \ref CalcDamageInfo::HitInfo + * @param target the target of the attack + * @param SwingType the swingtype, need to know what this is + * @param damageSchoolMask the damageschoolmask as the one from: + * \ref CalcDamageInfo::damageSchoolMask + * @param Damage the damage that was done + * @param AbsorbDamage how much of the damage that was absorbed + * @param Resist how much of the damage that was resisted + * @param TargetState the \ref VictimState of the target + * @param BlockedAmount how much of the damage that was blocked + * \todo What's the swingtype for? + */ void SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount); + /** + * Used to send a update to the combat log for all \ref Player/\ref Unit s in the vicinity. + * @param log Info about who/what did damage to who and how etc, data needed for the packet + * \see OpcodesList::SMSG_SPELLNONMELEEDAMAGELOG + * \todo Is this actually for the combat log? + */ void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log); + /** + * Same idea as for \ref Unit::SendSpellNonMeleeDamageLog but without the helping + * \ref SpellNonMeleeDamage. This will set the \ref SpellNonMeleeDamage::HitInfo member to + * the following before sending the packet: + * \code {.cpp} + * \ref HitInfo::SPELL_HIT_TYPE_UNK1 | \ref HitInfo::SPELL_HIT_TYPE_UNK3 | \ref HitInfo::SPELL_HIT_TYPE_UNK6 + * \endcode + * + * And if the \a CriticalHit parameter is true then it will add the flag + * \ref HitInfo::SPELL_HIT_TYPE_CRIT + * + * @param target the target of the spell + * @param SpellID id of the spell that was used + * @param Damage the damage done including the damage that was resisted/absorbed/blocked etc. + * Ie: damage + absorbed + resisted. This will be subtracted to the bare damage when inserted + * into the \ref SpellNonMeleeDamage struct + * @param damageSchoolMask mask for which kind of damage this is, see \ref SpellSchools for + * possible values, the first set bit out of this mask will be used a the \ref SpellSchools + * @param AbsorbedDamage how much of the damage that was absorbed + * @param Resist how much of the damage that was resisted + * @param PhysicalDamage whether or not this was physical damage + * @param Blocked how much of the damage that was blocked + * @param CriticalHit whether it was a critical hit or not + * \see HitInfo + * \see OpcodesList::SMSG_SPELLNONMELEEDAMAGELOG + * \todo Is this actually for the combat log? + */ void SendSpellNonMeleeDamageLog(Unit* target, uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false); + /** + * Sends some data to the combat log about the periodic effects of an \ref Aura, it might be + * periodic healing/damage etc. Perhaps it increases the amount of power you have as a rogue + * and such. For more info on what exactly is sent etc see + * \ref OpcodesList::SMSG_PERIODICAURALOG. + * @param pInfo Info about the periodic effect of the \ref Aura + * \see OpcodesList::SMSG_PERIODICAURALOG + * \todo Is this actually for the combat log? + */ void SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* pInfo); + /** + * Sends some data to the combat log about a spell that missed someone else. For more info + * on what's sent see \ref OpcodesList::SMSG_SPELLLOGMISS + * @param target the target of the \ref Spell that missed + * @param spellID id of the spell that missed + * @param missInfo info about how the spell actually missed ie: resisted/blocked/reflected etc. + */ void SendSpellMiss(Unit* target, uint32 spellID, SpellMissInfo missInfo); + /** + * Teleports a \ref Creature or \ref Player to some coordinates within the same \ref Map, + * hence the name. If it's a \ref Creature that's being teleported it needs to have it's + * \ref MovementGenerator interrupted before the teleport and then reset afterwards. See + * \ref MovementGenerator::Reset and \ref MovementGenerator::Interrupt. Also, after moving + * a \ref Creature a hearbeat needs to be sent to inform the clients about the new location, + * this is done using \ref Unit::SendHeartBeat and the actual move of the \ref Creature is + * done with \ref Map::CreatureRelocation + * @param x the new x coord + * @param y the new y coord + * @param z the new z coord + * @param orientation the orientation after teleport, 0 is north and it's measured in radians + * @param casting used to decide whether a spell cast should be interrupted if a \ref Player + * is going to be teleported, see \ref TeleportToOptions::TELE_TO_SPELL, the idea is that + * you don't interrupt spellcasting at teleport if the spell is meant to teleport you as + * that would defeat the purpose of trying to teleport one self :) + */ void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false); + /** + * Moves this \ref Unit to the given position in x,y,z coordinates. we can choose whether or + * not we want to generate a path to the target or just move straight there and if we would + * like to force the destination when creating the \ref PathFinder, only interesting + * if we have set generatePath to true. + * + * Taken from comments: recommend use \ref Unit::MonsterMove / \ref Unit::MonsterMoveWithSpeed + * for most case that correctly work with movegens, mmaps + * @param x the x coord to move to + * @param y the y coord to move to + * @param z the z coord to move to + * @param speed at which speed the \ref Unit should move + * @param generatePath whether a real path should be generated using a \ref PathFinder which + * will try to create a smooth path. if false we just go from current pos to given pos + * @param forceDestination if this is true it seems that we will try to get to our target + * even if there's something in the way. Otherwise we stop before we get there if there + * are obstacles + * \todo In what is the speed expressed? What is normal walking/running speed? + * \todo Is the dox about forceDestination correct? + */ void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath = false, bool forceDestination = false); // recommend use MonsterMove/MonsterMoveWithSpeed for most case that correctly work with movegens // if used additional args in ... part then floats must explicitly casted to double + /** + * Tells nearby \ref Unit s and such that this \ref Unit has moved to a new position using + * \ref OpcodesList::MSG_MOVE_HEARTBEAT which will send the new position to all clients etc + * in the same \ref Cell + */ void SendHeartBeat(); bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_LEVITATING); } bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_WALK_MODE); } bool IsRooted() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_ROOT); } virtual void SetRoot(bool /*enabled*/) {} + /** + * Changes this \ref Unit s ability to walk on water. + * @param enabled whether this \ref Unit should be able to walk on water (true) or not + * be able to (false) + * \see Player::SetWaterWalk + */ virtual void SetWaterWalk(bool /*enabled*/) {} + /** + * Turns this \ref Unit towards the given one. + * @param target the \ref Unit we want to be turned towards + * \see WorldObject::SetOrientation + * \see WorldObejct::GetAngle + */ void SetInFront(Unit const* target); + /** + * Sets this \ref Unit to face a certain angle. + * @param ori where we should start facing, measured in radians, 0 = north pi/2 = east etc. + * \todo is pi/2 = east or west? Logic says east? + */ void SetFacingTo(float ori); + /** + * Does pretty much the same thing as \ref Unit::SetInFront but calls \ref Unit::SetFacingTo + * instead, which uses a \ref MoveSplineInit instead of just changing the angle. + * @param pObject the \ref WorldObject we should be facing + * \todo What difference does it make to use \ref MoveSplineInit instead of just directly + * changing the angle? Is it smoother? + */ void SetFacingToObject(WorldObject* pObject); void SendHighestThreatUpdate(HostileReference* pHostileReference); @@ -2280,27 +2534,80 @@ class MANGOS_DLL_SPEC Unit : public WorldObject Pet* GetMiniPet() const; void SetMiniPet(Unit* pet) { SetCritterGuid(pet ? pet->GetObjectGuid() : ObjectGuid()); } + /** + * Gets either the current charmer (ie mind control) or the owner of this \ref Unit + * @return the \ref ObjectGuid of either the charmer of this \ref Unit or the owner of it + */ ObjectGuid const& GetCharmerOrOwnerGuid() const { return GetCharmerGuid() ? GetCharmerGuid() : GetOwnerGuid(); } + /** + * Same thing as \ref Unit::GetCharmerOrOwnerGuid but with the exception that it returns + * it's own \ref ObjectGuid if it has no owner or charmer. + * @return either the charmers, owners or it's own \ref ObjectGuid + */ ObjectGuid const& GetCharmerOrOwnerOrOwnGuid() const { if (ObjectGuid const& guid = GetCharmerOrOwnerGuid()) - return guid; + { return guid; } return GetObjectGuid(); } + /** + * Checks if the charmer or owner is a \ref Player + * @return true if the charmer or owner is a \ref Player, false otherwise + * \see ObjectGuid::IsPlayer + */ bool isCharmedOwnedByPlayerOrPlayer() const { return GetCharmerOrOwnerOrOwnGuid().IsPlayer(); } + /** + * Get's the \ref Player that owns the \ref SpellModifier for this \ref Unit, if this + * \ref Unit is a \ref Player it's the owner, but if it's a \ref Pet och \ref Totem then + * then owner of the totem is returned if it's a \ref Player + * @return The \ref SpellModifier owner for this \ref Unit + */ Player* GetSpellModOwner() const; + /** + * Returns the \ref Unit that owns this \ref Unit if any + * @return the \ref Unit that owns this one, NULL if there is no owner + * \see Unit::GetOwnerGuid + */ Unit* GetOwner() const; + /** + * Returns the \ref Pet for this \ref Unit if any + * @return the \ref Pet that is associated with this \ref Unit if any, NULL if there is none + * \see Unit::GetPetGuid + */ Pet* GetPet() const; + /** + * Returns the \ref Unit that's currently charming this one if any. + * @return the \ref Unit that's charming this one, NULL if there is none + */ Unit* GetCharmer() const; + /** + * Returns the \ref Unit that this one is currently charming + * @return the \ref Unit that this one is charming, NULL if there is none + */ Unit* GetCharm() const; + /** + * Removes all \ref Aura s causing this \ref Unit to be charmed/possessed, the \ref Aura s + * that cause this are: + * - \ref AuraType::SPELL_AURA_MOD_CHARM + * - \ref AuraType::SPELL_AURA_MOD_POSSESS + * - \ref AuraType::SPELL_AURA_MOD_POSSESS_PET + */ void Uncharm(); + /** + * Does the same as \ref Unit::GetCharmerOrOwnerGuid but returns the \ref Unit for that instead + * @return the \ref Unit that's charming this one or owning it, NULL if there is none + */ Unit* GetCharmerOrOwner() const { return GetCharmerGuid() ? GetCharmer() : GetOwner(); } + /** + * Does the same a \ref Unit::GetCharmerOrOwner but if there is none of those it returns itself + * @return a \ref Unit that's either owning or charming this one or just itself. + */ Unit* GetCharmerOrOwnerOrSelf() { if (Unit* u = GetCharmerOrOwner()) - return u; + { return u; } return this; } @@ -2308,65 +2615,300 @@ class MANGOS_DLL_SPEC Unit : public WorldObject Player* GetCharmerOrOwnerPlayerOrPlayerItself(); Player const* GetCharmerOrOwnerPlayerOrPlayerItself() const; + /** + * Set's the current \ref Pet for this \ref Unit + * @param pet The \ref Pet to add to this \ref Unit + */ void SetPet(Pet* pet); + /** + * Set's who we're currently charming + * @param pet The \ref Unit to set as charmed by us + */ void SetCharm(Unit* pet); + /** + * Adds a guardian to this \ref Unit which will generally defend this \ref Unit when on a + * threat list. + * @param pet the guardian to add + * \see Unit::m_guardianPets + */ void AddGuardian(Pet* pet); + /** + * Removes a guardian from this \ref Unit + * @param pet the guardian to remove + * \see Unit::m_guardianPets + */ void RemoveGuardian(Pet* pet); + /** + * Removes all current guardians from this \ref Unit + */ void RemoveGuardians(); + /** + * Finds a guardian by it's entry, this is the entry in character.character_pet + * @param entry the entry to find + * @return the guardian/\ref Pet found or NULL if there's no such entry in the db + * \todo Is it the correct entry + */ Pet* FindGuardianWithEntry(uint32 entry); Pet* GetProtectorPet(); // expected single case in guardian list + /** + * Is this \ref Unit charmed? + * @return true if the \ref Unit has a charmer, false otherwise + * \see Unit::GetCharmerGuid + */ bool isCharmed() const { return !GetCharmerGuid().IsEmpty(); } + /** + * There's only \ref CharmInfo available if this \ref Unit is in fact charmed by someone + * @return The \ref CharmInfo for this \ref Unit if any, NULL otherwise + */ CharmInfo* GetCharmInfo() { return m_charmInfo; } + /** + * Init the \ref CharmInfo struct with data about the \ref Unit that will be charmed + * @param charm the \ref Unit that is to be charmed + * @return the created \ref CharmInfo + * \todo Is the charm param really the unit to be charmed? + */ CharmInfo* InitCharmInfo(Unit* charm); + /** + * Get's the \ref ObjectGuid for a certain totem type that this \ref Unit has spawned + * @param slot the slot to get the \ref ObjectGuid for + * @return the \ref ObjectGuid for the given totem slot + */ ObjectGuid const& GetTotemGuid(TotemSlot slot) const { return m_TotemSlot[slot]; } + /** + * Gets a certain \ref Totem that this \ref Unit has spawned + * @param slot the slot to get the \ref Totem for + * @return The requested totem if there is any spawned, NULL otherwise + */ Totem* GetTotem(TotemSlot slot) const; + /** + * @return True if all totems slots are used (spawned), false otherwise + */ bool IsAllTotemSlotsUsed() const; + /** + * This is internal code that should only be called from the \ref Totem summon code + * @param slot + * @param totem + * \internal + */ void _AddTotem(TotemSlot slot, Totem* totem); // only for call from Totem summon code + /** + * This is internal code that should only be called from the \ref Totem class. + * @param totem + * \internal + */ void _RemoveTotem(Totem* totem); // only for call from Totem class + /** + * This will call the given function for all controlled \ref Unit s, for an example of + * how one such function could look please have a look at \ref CallForAllControlledUnitsExample + * + * The functors operator() should have the following signature: + * \code{.cpp} + * void operator()(Unit* unit) { ... }; + * \endcode + * @param func the functor object used to call for each \ref Unit that we will find matching + * the mask + * @param controlledMask a mask telling which of the controlled \ref Unit s we want to call + * the functor for + */ template void CallForAllControlledUnits(Func const& func, uint32 controlledMask); + /** + * Works pretty much the same way as \ref Unit::CallForAllControlledUnits but instead + * the functors operator() should have the following signature: + * \code{.cpp} + * bool operator()(Unit* unit) { ... }; + * \endcode + * @param func a functor object used to call for each \ref Unit that we will find matching + * the mask + * @param controlledMask a mask telling which of the controlled \ref Unit s we want to call + * the functor for + * @return true if the functor returned true for one of the \ref Unit s included by the + * controlledMask, false if none of them returned true + * \see Unit::isAttackingPlayer + */ template bool CheckAllControlledUnits(Func const& func, uint32 controlledMask) const; + /** + * Adds a \ref SpellAuraHolder + * @param holder the holder to add + * @return true if the holder was added, false otherwise + */ bool AddSpellAuraHolder(SpellAuraHolder* holder); + /** + * Adds a \ref Aura to \ref Unit::m_modAuras + * @param aura the \ref Aura to add + */ void AddAuraToModList(Aura* aura); - - // removing specific aura stack + + + /** + * Removes an \ref Aura and sets the reason for removal inside the \ref Aura. + * + * removing specific aura stack (From old comment) + * @param aura the \ref Aura to remove + * @param mode the reason why it is being removed + * \see Aura::SetRemoveMode + */ void RemoveAura(Aura* aura, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); + /** + * Removes an \ref Aura by spell id and the effect index for that spell to find out + * which \ref Aura to remove. + * @param spellId id of the spell which has the sought \ref Aura somewhere + * @param effindex the effect index for the spell to find the right \ref Aura + * @param except if != NULL we will not remove this \ref Aura if found + */ void RemoveAura(uint32 spellId, SpellEffectIndex effindex, Aura* except = NULL); + /** + * Removes a \ref SpellAuraHolder from this \ref Unit. This will remove all the effects that + * are currently stored in the \ref SpellAuraHolder. + * @param holder holder to be removed + * @param mode reason for removal + */ void RemoveSpellAuraHolder(SpellAuraHolder* holder, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); + /** + * Removes a single \ref Aura from a \ref SpellAuraHolder to cancel out just one effect of a + * \ref Spell. + * @param holder the holder to remove the \ref Aura from + * @param index the effect index to tell which \ref Aura we want to remove + * @param mode the reason for removing it + */ void RemoveSingleAuraFromSpellAuraHolder(SpellAuraHolder* holder, SpellEffectIndex index, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); + /** + * Does the same thing as \ref Unit::RemoveSingleAuraFromSpellAuraHolder but with spell id + * instead of a \ref SpellAuraHolder + * @param id id of the spell to find the \ref Aura in + * @param index the effect index to tell which \ref Aura we want to remove + * @param casterGuid guid of the caster to filter it out to just one \ref Aura to remove + * @param mode reason for removal + */ void RemoveSingleAuraFromSpellAuraHolder(uint32 id, SpellEffectIndex index, ObjectGuid casterGuid, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); - // removing specific aura stacks by diff reasons and selections + /** + * Removes all \ref Aura s that a certain spell would cause via it's effects (up to 3 of them + * per \ref Aura). + * + * From old doc: removing specific aura stacka by diff reasons and selections + * @param spellId id of the spell causing the \ref Aura s you would like to remove + * @param except a spell that shouldn't be included in the removal + * @param mode reason for removal + * \see SpellEntry::Effect + */ void RemoveAurasDueToSpell(uint32 spellId, SpellAuraHolder* except = NULL, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); + /** + * Removes all \ref Aura s that a certain spell cast by a certain \ref Item would cause via + * it's effects (up to 3 of them per \ref Aura). + * @param castItem the \ref Item that cast the spell + * @param spellId id of the spell causing the \ref Aura s you would like to remove + */ void RemoveAurasDueToItemSpell(Item* castItem, uint32 spellId); + /** + * Removes all \ref Aura s that a certain spell cast by a certain \ref Player / \ref Unit + * would cause via it's effects (up to 3 of them per \ref Aura) + * @param spellId id of the \ref Spell causing the \ref Aura s you would like to remove + * @param casterGuid \ref ObjectGuid of the caster + * @param mode reason for removal + */ void RemoveAurasByCasterSpell(uint32 spellId, ObjectGuid casterGuid, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, Unit* stealer); + /** + * Removes all \ref Aura s caused by a certain spell because it was canceled. + * @param spellId id of the \ref Spell causing the \ref Aura s you would like to remove + */ void RemoveAurasDueToSpellByCancel(uint32 spellId); // removing unknown aura stacks by diff reasons and selections + /** + * From old doc: removing unknown aura stacks by diff reasons and selections + * \todo Document and find out what it does + */ void RemoveNotOwnTrackedTargetAuras(uint32 newPhase = 0x0); + /** + * Removes all \ref SpellAuraHolder s that have the given \ref Mechanics mask which is created + * by doing something like the following if we want a mask for \ref Mechanics::MECHANIC_SAPPED: + * \code{.cpp} + * uint32 mask = 1 << (MECHANIC_SAPPED - 1); + * \endcode + * @param mechMask a mask of \ref Mechanics, see \ref MECHANIC_NOT_REMOVED_BY_SHAPESHIFT, + * \ref IMMUNE_TO_ROOT_AND_SNARE_MASK for examples + * @param exceptSpellId id of a \ref Spell that shouldn't be removed + * @param non_positive if we should remove non positive \ref Aura s or not, defaults to false + */ void RemoveAurasAtMechanicImmunity(uint32 mechMask, uint32 exceptSpellId, bool non_positive = false); + /** + * Removes all \ref Spell s that cause the given \ref AuraType + * @param auraType the type of auras we would like to remove spells for + */ void RemoveSpellsCausingAura(AuraType auraType); + /** + * Same as \ref Unit::RemoveSpellsCausingAura but with an exception + * for a \ref SpellAuraHolder that shouldn't be removed + * @param auraType the type of auras we would like to remove spells for + * @param except this will be excepted from removal + */ void RemoveSpellsCausingAura(AuraType auraType, SpellAuraHolder* except); + /** + * Same as \ref Unit::RemoveSpellsCausingAura but for a matching caster aswell. + * @param auraType the type of auras we would like to remove spells for + * @param casterGuid remove the aura only if the caster is equal to this guid + */ void RemoveSpellsCausingAura(AuraType auraType, ObjectGuid casterGuid); + /** + * Removes all ranks of the given \ref Spell, ie: if the spellid of rank 1 inner fire is + * given all the ranks of it will be removed. + * @param spellId id of the spell we want to remove all ranks for + */ void RemoveRankAurasDueToSpell(uint32 spellId); + /** + * + * @param holder + * @return true if we could remove something (and did), false otherwise + * \todo Document what this does and break into smaller functions! + */ bool RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder* holder); + /** + * Removes all \ref Aura s that have the given interrupt flags + * @param flags see \ref AuraInterruptFlags for possible flags + */ void RemoveAurasWithInterruptFlags(uint32 flags); + /** + * Removes all \ref Aura s that have the given attributes + * @param flags see \ref SpellAttributes for possible values + */ void RemoveAurasWithAttribute(uint32 flags); + /** + * Removes all \ref Aura s which can be dispelled by the given \ref DispelType + * @param type the given type that you want to remove all \ref Aura s for + * @param casterGuid if this isn't 0 it will be checked that the caster of the \ref Spell is + * the same as the given guid before removal. + */ void RemoveAurasWithDispelType(DispelType type, ObjectGuid casterGuid = ObjectGuid()); + /** + * Removes all \ref Aura s. + * @param mode the reason for removal + */ void RemoveAllAuras(AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveArenaAuras(bool onleave = false); + /** + * Removes all \ref Aura s on this \ref Unit s death. Removes all visible \ref Aura s and + * disabled the mods for the passive ones (taken from old docs). The reason used is + * \ref AuraRemoveMode::AURA_REMOVE_BY_DEATH + * \todo Where does it remove the passive ones? + */ void RemoveAllAurasOnDeath(); + /** + * used when evading to remove all auras except some special auras. Linked and flying + * \ref Aura s shouldn't be removed on evade. + * \todo Are linked and flying auras really not removed on evade? + */ void RemoveAllAurasOnEvade(); - + // removing specific aura FROM stack by diff reasons and selections void RemoveAuraHolderFromStack(uint32 spellId, uint32 stackAmount = 1, ObjectGuid casterGuid = ObjectGuid(), AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount, ObjectGuid casterGuid, Unit* dispeller); @@ -2535,6 +3077,13 @@ class MANGOS_DLL_SPEC Unit : public WorldObject SpellAuraHolderMap& GetSpellAuraHolderMap() { return m_spellAuraHolders; } SpellAuraHolderMap const& GetSpellAuraHolderMap() const { return m_spellAuraHolders; } + /** + * Get's a list of all the \ref Aura s of the given \ref AuraType that are currently + * affecting this \ref Unit. + * @param type the aura type we want to find + * @return A list of the auras currently applied to the \ref Unit with the given \ref AuraType + * \see Unit::m_modAuras + */ AuraList const& GetAurasByType(AuraType type) const { return m_modAuras[type]; } void ApplyAuraProcTriggerDamage(Aura* aura, bool apply); @@ -2751,7 +3300,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject AttackerSet m_attackers; Unit* m_attacking; - DeathState m_deathState; + DeathState m_deathState; ///< The current state of life/death for this \ref Unit SpellAuraHolderMap m_spellAuraHolders; SpellAuraHolderMap::iterator m_spellAuraHoldersUpdateIterator; // != end() in Unit::m_spellAuraHolders update and point to next element @@ -2857,50 +3406,51 @@ void Unit::CallForAllControlledUnits(Func const& func, uint32 controlledMask) { if (controlledMask & CONTROLLED_PET) if (Pet* pet = GetPet()) - func(pet); + { func(pet); } if (controlledMask & CONTROLLED_MINIPET) if (Pet* mini = GetMiniPet()) - func(mini); + { func(mini); } if (controlledMask & CONTROLLED_GUARDIANS) { for (GuidSet::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end();) if (Pet* guardian = _GetPet(*(itr++))) - func(guardian); + { func(guardian); } } if (controlledMask & CONTROLLED_TOTEMS) { for (int i = 0; i < MAX_TOTEM_SLOT; ++i) if (Unit* totem = _GetTotem(TotemSlot(i))) - func(totem); + { func(totem); } } if (controlledMask & CONTROLLED_CHARM) if (Unit* charm = GetCharm()) - func(charm); + { func(charm); } } + template bool Unit::CheckAllControlledUnits(Func const& func, uint32 controlledMask) const { if (controlledMask & CONTROLLED_PET) if (Pet const* pet = GetPet()) if (func(pet)) - return true; + { return true; } if (controlledMask & CONTROLLED_MINIPET) if (Pet const* mini = GetMiniPet()) if (func(mini)) - return true; + { return true; } if (controlledMask & CONTROLLED_GUARDIANS) { for (GuidSet::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end();) if (Pet const* guardian = _GetPet(*(itr++))) if (func(guardian)) - return true; + { return true; } } if (controlledMask & CONTROLLED_TOTEMS) @@ -2908,13 +3458,13 @@ bool Unit::CheckAllControlledUnits(Func const& func, uint32 controlledMask) cons for (int i = 0; i < MAX_TOTEM_SLOT; ++i) if (Unit const* totem = _GetTotem(TotemSlot(i))) if (func(totem)) - return true; + { return true; } } if (controlledMask & CONTROLLED_CHARM) if (Unit const* charm = GetCharm()) if (func(charm)) - return true; + { return true; } return false; } diff --git a/src/game/movement/MoveSpline.cpp b/src/game/movement/MoveSpline.cpp index 8291f7cdb..a848b2235 100644 --- a/src/game/movement/MoveSpline.cpp +++ b/src/game/movement/MoveSpline.cpp @@ -40,7 +40,7 @@ namespace Movement float u = 1.f; int32 seg_time = spline.length(point_Idx, point_Idx + 1); if (seg_time > 0) - u = (time_passed - spline.length(point_Idx)) / (float)seg_time; + { u = (time_passed - spline.length(point_Idx)) / (float)seg_time; } Location c; c.orientation = initialOrientation; spline.evaluate_percent(point_Idx, u, c); @@ -50,14 +50,14 @@ namespace Movement else if (splineflags.parabolic) computeParabolicElevation(c.z); else if (splineflags.falling) - computeFallElevation(c.z); + { computeFallElevation(c.z); } if (splineflags.done && splineflags.isFacing()) { if (splineflags.final_angle) - c.orientation = facing.angle; + { c.orientation = facing.angle; } else if (splineflags.final_point) - c.orientation = atan2(facing.f.y - c.y, facing.f.x - c.x); + { c.orientation = atan2(facing.f.y - c.y, facing.f.x - c.x); } // nothing to do for MoveSplineFlag::Final_Target flag } else @@ -93,9 +93,9 @@ namespace Movement float z_now = spline.getPoint(spline.first()).z - Movement::computeFallElevation(MSToSec(time_passed)); float final_z = FinalDestination().z; if (z_now < final_z) - el = final_z; + { el = final_z; } else - el = z_now; + { el = z_now; } } inline uint32 computeDuration(float length, float velocity) @@ -294,11 +294,11 @@ namespace Movement str << "spline Id: " << GetId() << std::endl; str << "flags: " << splineflags.ToString() << std::endl; if (splineflags.final_angle) - str << "facing angle: " << facing.angle; + { str << "facing angle: " << facing.angle; } else if (splineflags.final_target) - str << "facing target: " << facing.target; + { str << "facing target: " << facing.target; } else if (splineflags.final_point) - str << "facing point: " << facing.f.x << " " << facing.f.y << " " << facing.f.z; + { str << "facing point: " << facing.f.x << " " << facing.f.y << " " << facing.f.z; } str << std::endl; str << "time passed: " << time_passed << std::endl; str << "total time: " << Duration() << std::endl; @@ -319,7 +319,7 @@ namespace Movement { int32 point = point_Idx_offset + point_Idx - spline.first() + (int)Finalized(); if (isCyclic()) - point = point % (spline.last() - spline.first()); + { point = point % (spline.last() - spline.first()); } return point; } } diff --git a/src/game/movement/MoveSpline.h b/src/game/movement/MoveSpline.h index e32ab0c66..8e7c94bc7 100644 --- a/src/game/movement/MoveSpline.h +++ b/src/game/movement/MoveSpline.h @@ -32,21 +32,56 @@ namespace Movement { struct Location : public Vector3 { + /** + * @brief + * + */ Location() : orientation(0) {} + /** + * @brief + * + * @param x + * @param y + * @param z + * @param o + */ Location(float x, float y, float z, float o) : Vector3(x, y, z), orientation(o) {} + /** + * @brief + * + * @param v + */ Location(const Vector3& v) : Vector3(v), orientation(0) {} + /** + * @brief + * + * @param v + * @param o + */ Location(const Vector3& v, float o) : Vector3(v), orientation(o) {} - float orientation; + float orientation; /**< TODO */ }; - // MoveSpline represents smooth catmullrom or linear curve and point that moves belong it - // curve can be cyclic - in this case movement will be cyclic - // point can have vertical acceleration motion componemt(used in fall, parabolic movement) + /** + * @brief MoveSpline represents smooth catmullrom or linear curve and point that moves belong it + * + * curve can be cyclic - in this case movement will be cyclic + * point can have vertical acceleration motion componemt(used in fall, parabolic movement) + * + */ class MoveSpline { public: + /** + * @brief + * + */ typedef Spline MySpline; + /** + * @brief + * + */ enum UpdateResult { Result_None = 0x01, @@ -56,77 +91,206 @@ namespace Movement }; friend class PacketBuilder; protected: - MySpline spline; + MySpline spline; /**< TODO */ - FacingInfo facing; + FacingInfo facing; /**< TODO */ - uint32 m_Id; + uint32 m_Id; /**< TODO */ - MoveSplineFlag splineflags; + MoveSplineFlag splineflags; /**< TODO */ - int32 time_passed; + int32 time_passed; /**< TODO */ // currently duration mods are unused, but its _currently_ // float duration_mod; // float duration_mod_next; float vertical_acceleration; float initialOrientation; int32 effect_start_time; - int32 point_Idx; - int32 point_Idx_offset; + int32 point_Idx; /**< TODO */ + int32 point_Idx_offset; /**< TODO */ + /** + * @brief + * + * @param args + */ void init_spline(const MoveSplineInitArgs& args); protected: + /** + * @brief + * + * @return const MySpline::ControlArray + */ const MySpline::ControlArray& getPath() const { return spline.getPoints();} void computeParabolicElevation(float& el) const; + /** + * @brief + * + * @param el + */ void computeFallElevation(float& el) const; + /** + * @brief + * + * @param ms_time_diff + * @return UpdateResult + */ UpdateResult _updateState(int32& ms_time_diff); + /** + * @brief + * + * @return int32 + */ int32 next_timestamp() const { return spline.length(point_Idx + 1);} + /** + * @brief + * + * @return int32 + */ int32 segment_time_elapsed() const { return next_timestamp() - time_passed;} + /** + * @brief + * + * @return int32 + */ int32 timeElapsed() const { return Duration() - time_passed;} + /** + * @brief + * + * @return int32 + */ int32 timePassed() const { return time_passed;} public: + /** + * @brief + * + * @return const MySpline + */ const MySpline& _Spline() const { return spline;} + /** + * @brief + * + * @return int32 + */ int32 _currentSplineIdx() const { return point_Idx;} + /** + * @brief + * + */ void _Finalize(); + /** + * @brief + * + */ void _Interrupt() { splineflags.done = true;} public: + /** + * @brief + * + * @param + */ void Initialize(const MoveSplineInitArgs&); + /** + * @brief + * + * @return bool + */ bool Initialized() const { return !spline.empty();} + /** + * @brief + * + */ explicit MoveSpline(); template + /** + * @brief + * + * @param difftime + * @param handler + */ void updateState(int32 difftime, UpdateHandler& handler) { MANGOS_ASSERT(Initialized()); do - handler(_updateState(difftime)); + { handler(_updateState(difftime)); } while (difftime > 0); } + /** + * @brief + * + * @param difftime + */ void updateState(int32 difftime) { MANGOS_ASSERT(Initialized()); - do _updateState(difftime); + do { _updateState(difftime); } while (difftime > 0); } + /** + * @brief + * + * @return Location + */ Location ComputePosition() const; + /** + * @brief + * + * @return uint32 + */ uint32 GetId() const { return m_Id;} + /** + * @brief + * + * @return bool + */ bool Finalized() const { return splineflags.done; } + /** + * @brief + * + * @return bool + */ bool isCyclic() const { return splineflags.cyclic;} + /** + * @brief + * + * @return const Vector3 + */ const Vector3 FinalDestination() const { return Initialized() ? spline.getPoint(spline.last()) : Vector3();} + /** + * @brief + * + * @return const Vector3 + */ const Vector3 CurrentDestination() const { return Initialized() ? spline.getPoint(point_Idx + 1) : Vector3();} + /** + * @brief + * + * @return int32 + */ int32 currentPathIdx() const; + /** + * @brief + * + * @return int32 + */ int32 Duration() const { return spline.length();} + /** + * @brief + * + * @return std::string + */ std::string ToString() const; }; } diff --git a/src/game/movement/MoveSplineFlag.h b/src/game/movement/MoveSplineFlag.h index efb43f567..9816b53a7 100644 --- a/src/game/movement/MoveSplineFlag.h +++ b/src/game/movement/MoveSplineFlag.h @@ -36,9 +36,17 @@ namespace Movement #pragma pack(push,1) #endif + /** + * @brief + * + */ class MoveSplineFlag { public: + /** + * @brief + * + */ enum eFlags { None = 0x00000000, @@ -83,11 +91,35 @@ namespace Movement Mask_Unused = No_Spline | Enter_Cycle | Frozen | FallingSlow | Unknown2 | Unknown3 | Unknown4 | SmoothGroundPath | Unknown6 | Unknown7 | Unknown8 | Unknown9, }; - inline uint32& raw() { return (uint32&)*this;} - inline const uint32& raw() const { return (const uint32&)*this;} + /** + * @brief + * + * @return uint32 + */ + inline uint32& raw() { return (uint32&) * this;} + /** + * @brief + * + * @return const uint32 + */ + inline const uint32& raw() const { return (const uint32&) * this;} + /** + * @brief + * + */ MoveSplineFlag() { raw() = 0; } + /** + * @brief + * + * @param f + */ MoveSplineFlag(uint32 f) { raw() = f; } + /** + * @brief + * + * @param f + */ MoveSplineFlag(const MoveSplineFlag& f) { raw() = f.raw(); } // Constant interface @@ -100,12 +132,33 @@ namespace Movement bool hasAllFlags(uint32 f) const { return (raw() & f) == f;} bool hasFlag(uint32 f) const { return (raw() & f) != 0;} uint32 operator & (uint32 f) const { return (raw() & f);} + /** + * @brief + * + * @param f + * @return uint32 operator + */ uint32 operator | (uint32 f) const { return (raw() | f);} + /** + * @brief + * + * @return std::string + */ std::string ToString() const; // Not constant interface + /** + * @brief + * + * @param f + */ void operator &= (uint32 f) { raw() &= f;} + /** + * @brief + * + * @param f + */ void operator |= (uint32 f) { raw() |= f;} void EnableAnimation(uint8 anim) { raw() = (raw() & ~(Mask_Animations | Falling | Trajectory | FallingSlow)) | Animation | (anim & Mask_Animations);} @@ -113,8 +166,16 @@ namespace Movement void EnableFalling() { raw() = (raw() & ~(Mask_Animations | Trajectory | Animation))| Falling;} void EnableCatmullRom() { raw() = (raw() & ~SmoothGroundPath) | Catmullrom | UncompressedPath; } void EnableFacingPoint() { raw() = (raw() & ~Mask_Final_Facing) | Final_Point;} - void EnableFacingAngle() { raw() = (raw() & ~Mask_Final_Facing) | Final_Angle;} - void EnableFacingTarget() { raw() = (raw() & ~Mask_Final_Facing) | Final_Target;} + /** + * @brief + * + */ + void EnableFacingAngle() { raw() = (raw() & ~Mask_Final_Facing) | Final_Angle;} + /** + * @brief + * + */ + void EnableFacingTarget() { raw() = (raw() & ~Mask_Final_Facing) | Final_Target;} void EnableBoardVehicle() { raw() = (raw() & ~(Catmullrom | ExitVehicle)) | BoardVehicle; } void EnableExitVehicle() { raw() = (raw() & ~BoardVehicle) | ExitVehicle; } diff --git a/src/game/movement/MoveSplineInit.cpp b/src/game/movement/MoveSplineInit.cpp index dcce35456..529bc8779 100644 --- a/src/game/movement/MoveSplineInit.cpp +++ b/src/game/movement/MoveSplineInit.cpp @@ -42,9 +42,9 @@ namespace Movement else if (moveFlags & MOVEFLAG_SWIMMING) { if (moveFlags & MOVEFLAG_BACKWARD /*&& speed_obj.swim >= speed_obj.swim_back*/) - return MOVE_SWIM_BACK; + { return MOVE_SWIM_BACK; } else - return MOVE_SWIM; + { return MOVE_SWIM; } } else if (moveFlags & MOVEFLAG_WALK_MODE) { @@ -52,7 +52,7 @@ namespace Movement return MOVE_WALK; } else if (moveFlags & MOVEFLAG_BACKWARD /*&& speed_obj.run >= speed_obj.run_back*/) - return MOVE_RUN_BACK; + { return MOVE_RUN_BACK; } return MOVE_RUN; } diff --git a/src/game/movement/MoveSplineInit.h b/src/game/movement/MoveSplineInit.h index b624f4cc4..300b1f8b7 100644 --- a/src/game/movement/MoveSplineInit.h +++ b/src/game/movement/MoveSplineInit.h @@ -39,17 +39,25 @@ namespace Movement ToFly = 2, // 458 = ToFly FlyToGround = 3, // 463 = FlyToGround }; - - /* Initializes and launches spline movement + /** + * @brief Initializes and launches spline movement + * */ class MANGOS_DLL_SPEC MoveSplineInit { public: + /** + * @brief + * + * @param m + */ explicit MoveSplineInit(Unit& m); - /* Final pass of initialization that launches spline movement. - * @return duration - estimated travel time + /** + * @brief Final pass of initialization that launches spline movement. + * + * @return int32 duration - estimated travel time */ int32 Launch(); @@ -64,27 +72,53 @@ namespace Movement */ void SetAnimation(AnimType anim); - /* Adds final facing animation - * sets unit's facing to specified point/angle after all path done + /** + * @brief Adds final facing animation + * sets unit's facing to specified point/angle after all path done. * you can have only one final facing: previous will be overriden + * + * @param angle */ void SetFacing(float angle); + /** + * @brief + * + * @param point + */ void SetFacing(Vector3 const& point); + /** + * @brief + * + * @param target + */ void SetFacing(const Unit* target); - /* Initializes movement by path - * @param path - array of points, shouldn't be empty - * @param pointId - Id of fisrt point of the path. Example: when third path point will be done it will notify that pointId + 3 done + /** + * @brief Initializes movement by path + * + * @param path array of points, shouldn't be empty + * @param pointId Id of fisrt point of the path. Example: when third path point will be done it will notify that pointId + 3 done */ void MovebyPath(const PointsArray& path, int32 pointId = 0); - /* Initializes simple A to B mition, A is current unit's position, B is destination + /** + * @brief Initializes simple A to B mition, A is current unit's position, B is destination + * + * @param destination + * @param generatePath + * @param forceDestination + * @param maxPathRange */ void MoveTo(const Vector3& destination, bool generatePath = false, bool forceDestination = false); void MoveTo(float x, float y, float z, bool generatePath = false, bool forceDestination = false); - /* Sets Id of fisrt point of the path. When N-th path point will be done ILisener will notify that pointId + N done + /** + * @brief Sets Id of fisrt point of the path + * + * When N-th path point will be done ILisener will notify that pointId + N done * Needed for waypoint movement where path splitten into parts + * + * @param pointId */ void SetFirstPointId(int32 pointId) { args.path_Idx_offset = pointId; } @@ -95,13 +129,20 @@ namespace Movement /* Enables CatmullRom spline interpolation mode, enables flying animation. Disabled by default */ void SetFly(); - /* Enables walk mode. Disabled by default + /** + * @brief Enables walk mode. Disabled by default + * + * @param enable */ void SetWalk(bool enable); - /* Makes movement cyclic. Disabled by default + /** + * @brief Makes movement cyclic. Disabled by default + * */ void SetCyclic(); - /* Enables falling mode. Disabled by default + /** + * @brief Enables falling mode. Disabled by default + * */ void SetFall(); /* Inverses unit model orientation. Disabled by default @@ -114,7 +155,8 @@ namespace Movement /* Sets the velocity (in case you want to have custom movement velocity) * if no set, speed will be selected based on unit's speeds and current movement mode * Has no effect if falling mode enabled - * velocity shouldn't be negative + * + * @param velocity velocity shouldn't be negative */ void SetVelocity(float velocity); @@ -125,26 +167,43 @@ namespace Movement /* Sets ExitVehicle flag */ void SetExitVehicle(); - PointsArray& Path() { return args.path; } - protected: - MoveSplineInitArgs args; - Unit& unit; + MoveSplineInitArgs args; /**< TODO */ + Unit& unit; /**< TODO */ }; - inline void MoveSplineInit::SetFly() { args.flags.flying = true; } + /** + * @brief + * + */ + inline void MoveSplineInit::SetFly() { args.flags.flying = true;} inline void MoveSplineInit::SetWalk(bool enable) { args.flags.walkmode = enable;} inline void MoveSplineInit::SetSmooth() { args.flags.EnableCatmullRom();} inline void MoveSplineInit::SetCyclic() { args.flags.cyclic = true;} + /** + * @brief + * + */ inline void MoveSplineInit::SetFall() { args.flags.EnableFalling();} - inline void MoveSplineInit::SetVelocity(float vel) { args.velocity = vel;} + /** + * @brief + * + * @param vel + */ + inline void MoveSplineInit::SetVelocity(float vel) { args.velocity = vel;} inline void MoveSplineInit::SetOrientationInversed() { args.flags.orientationInversed = true;} inline void MoveSplineInit::SetOrientationFixed(bool enable) { args.flags.orientationFixed = enable;} inline void MoveSplineInit::SetBoardVehicle() { args.flags.EnableBoardVehicle(); } inline void MoveSplineInit::SetExitVehicle() { args.flags.EnableExitVehicle(); } + /** + * @brief + * + * @param controls + * @param path_offset + */ inline void MoveSplineInit::MovebyPath(const PointsArray& controls, int32 path_offset) { args.path_Idx_offset = path_offset; diff --git a/src/game/movement/MoveSplineInitArgs.h b/src/game/movement/MoveSplineInitArgs.h index 1d47ae173..459067900 100644 --- a/src/game/movement/MoveSplineInitArgs.h +++ b/src/game/movement/MoveSplineInitArgs.h @@ -32,22 +32,52 @@ class Unit; namespace Movement { + /** + * @brief + * + */ typedef std::vector PointsArray; + /** + * @brief + * + */ union FacingInfo { + /** + * @brief + * + */ struct { - float x, y, z; - } f; - uint64 target; - float angle; + float x, y, z; /**< TODO */ + } f; /**< TODO */ + uint64 target; /**< TODO */ + float angle; /**< TODO */ + /** + * @brief + * + * @param o + */ FacingInfo(float o) : angle(o) {} + /** + * @brief + * + * @param t + */ FacingInfo(uint64 t) : target(t) {} + /** + * @brief + * + */ FacingInfo() {} }; + /** + * @brief + * + */ struct MoveSplineInitArgs { MoveSplineInitArgs(size_t path_capacity = 16) : path_Idx_offset(0), @@ -56,19 +86,29 @@ namespace Movement path.reserve(path_capacity); } - PointsArray path; - FacingInfo facing; - MoveSplineFlag flags; - int32 path_Idx_offset; - float velocity; + PointsArray path; /**< TODO */ + FacingInfo facing; /**< TODO */ + MoveSplineFlag flags; /**< TODO */ + int32 path_Idx_offset; /**< TODO */ + float velocity; /**< TODO */ float parabolic_amplitude; float time_perc; - uint32 splineId; + uint32 splineId; /**< TODO */ float initialOrientation; - /** Returns true to show that the arguments were configured correctly and MoveSpline initialization will succeed. */ + /** + * @brief Returns true to show that the arguments were configured correctly and MoveSpline initialization will succeed. + * + * @param unit + * @return bool + */ bool Validate(Unit* unit) const; private: + /** + * @brief + * + * @return bool + */ bool _checkPathBounds() const; }; } diff --git a/src/game/movement/packet_builder.cpp b/src/game/movement/packet_builder.cpp index 5831a02ec..4cd22d9e3 100644 --- a/src/game/movement/packet_builder.cpp +++ b/src/game/movement/packet_builder.cpp @@ -146,12 +146,12 @@ namespace Movement if (splineflags & MoveSplineFlag::UncompressedPath) { if (splineflags.cyclic) - WriteCatmullRomCyclicPath(spline, data); + { WriteCatmullRomCyclicPath(spline, data); } else - WriteCatmullRomPath(spline, data); + { WriteCatmullRomPath(spline, data); } } else - WriteLinearPath(spline, data); + { WriteLinearPath(spline, data); } } void PacketBuilder::WriteCreateBits(const MoveSpline& move_spline, ByteBuffer& data) diff --git a/src/game/movement/packet_builder.h b/src/game/movement/packet_builder.h index 094c835d6..c9093f6f6 100644 --- a/src/game/movement/packet_builder.h +++ b/src/game/movement/packet_builder.h @@ -31,12 +31,34 @@ class WorldPacket; namespace Movement { class MoveSpline; + /** + * @brief + * + */ class PacketBuilder { + /** + * @brief + * + * @param mov + * @param data + */ static void WriteCommonMonsterMovePart(const MoveSpline& mov, WorldPacket& data); public: + /** + * @brief + * + * @param mov + * @param data + */ static void WriteMonsterMove(const MoveSpline& mov, WorldPacket& data); + /** + * @brief + * + * @param mov + * @param data + */ static void WriteCreateBits(const MoveSpline& mov, ByteBuffer& data); static void WriteCreateBytes(const MoveSpline& mov, ByteBuffer& data); }; diff --git a/src/game/movement/spline.cpp b/src/game/movement/spline.cpp index f6051f87d..cfa783f4d 100644 --- a/src/game/movement/spline.cpp +++ b/src/game/movement/spline.cpp @@ -233,9 +233,9 @@ namespace Movement // first and last two indexes are space for special 'virtual points' // these points are required for proper C_Evaluate and C_Evaluate_Derivative methtod work if (cyclic) - points[count] = controls[cyclic_point]; + { points[count] = controls[cyclic_point]; } else - points[count] = controls[count - 1]; + { points[count] = controls[count - 1]; } index_lo = 0; index_hi = cyclic ? count : (count - 1); @@ -257,9 +257,9 @@ namespace Movement if (cyclic) { if (cyclic_point == 0) - points[0] = controls[count - 1]; + { points[0] = controls[count - 1]; } else - points[0] = controls[0].lerp(controls[1], -1); + { points[0] = controls[0].lerp(controls[1], -1); } points[high_index + 1] = controls[cyclic_point]; points[high_index + 2] = controls[cyclic_point + 1]; @@ -303,7 +303,7 @@ namespace Movement str << "mode: " << mode_str[mode()] << std::endl; str << "points count: " << count << std::endl; for (index_type i = 0; i < count; ++i) - str << "point " << i << " : " << points[i].toString() << std::endl; + { str << "point " << i << " : " << points[i].toString() << std::endl; } return str.str(); } diff --git a/src/game/movement/spline.h b/src/game/movement/spline.h index 56d5daaad..79e790ec4 100644 --- a/src/game/movement/spline.h +++ b/src/game/movement/spline.h @@ -27,16 +27,33 @@ #include "typedefs.h" #include +#include namespace Movement { + /** + * @brief + * + */ class SplineBase { public: + /** + * @brief + * + */ typedef int index_type; + /** + * @brief + * + */ typedef std::vector ControlArray; + /** + * @brief + * + */ enum EvaluationMode { ModeLinear, @@ -47,143 +64,400 @@ namespace Movement }; protected: - ControlArray points; + ControlArray points; /**< TODO */ - index_type index_lo; - index_type index_hi; + index_type index_lo; /**< TODO */ + index_type index_hi; /**< TODO */ - uint8 m_mode; - bool cyclic; + uint8 m_mode; /**< TODO */ + bool cyclic; /**< TODO */ + /** + * @brief + * + */ enum { // could be modified, affects segment length evaluation precision // lesser value saves more performance in cost of lover precision // minimal value is 1 // client's value is 20, blizzs use 2-3 steps to compute length - STEPS_PER_SEGMENT = 3, + STEPS_PER_SEGMENT = 3 }; - COMPILE_ASSERT(STEPS_PER_SEGMENT > 0, "shouldn't be lesser than 1"); + static_assert(STEPS_PER_SEGMENT > 0, "shouldn't be lesser than 1"); protected: + /** + * @brief + * + * @param index_type + * @param float + * @param + */ void EvaluateLinear(index_type, float, Vector3&) const; + /** + * @brief + * + * @param index_type + * @param float + * @param + */ void EvaluateCatmullRom(index_type, float, Vector3&) const; + /** + * @brief + * + * @param index_type + * @param float + * @param + */ void EvaluateBezier3(index_type, float, Vector3&) const; + /** + * @brief + * + */ typedef void (SplineBase::*EvaluationMethtod)(index_type, float, Vector3&) const; - static EvaluationMethtod evaluators[ModesEnd]; + static EvaluationMethtod evaluators[ModesEnd]; /**< TODO */ + /** + * @brief + * + * @param index_type + * @param float + * @param + */ void EvaluateDerivativeLinear(index_type, float, Vector3&) const; + /** + * @brief + * + * @param index_type + * @param float + * @param + */ void EvaluateDerivativeCatmullRom(index_type, float, Vector3&) const; + /** + * @brief + * + * @param index_type + * @param float + * @param + */ void EvaluateDerivativeBezier3(index_type, float, Vector3&) const; - static EvaluationMethtod derivative_evaluators[ModesEnd]; + static EvaluationMethtod derivative_evaluators[ModesEnd]; /**< TODO */ + /** + * @brief + * + * @param index_type + * @return float + */ float SegLengthLinear(index_type) const; + /** + * @brief + * + * @param index_type + * @return float + */ float SegLengthCatmullRom(index_type) const; + /** + * @brief + * + * @param index_type + * @return float + */ float SegLengthBezier3(index_type) const; + /** + * @brief + * + */ typedef float(SplineBase::*SegLenghtMethtod)(index_type) const; - static SegLenghtMethtod seglengths[ModesEnd]; + static SegLenghtMethtod seglengths[ModesEnd]; /**< TODO */ + /** + * @brief + * + * @param + * @param index_type + * @param bool + * @param index_type + */ void InitLinear(const Vector3*, index_type, bool, index_type); + /** + * @brief + * + * @param + * @param index_type + * @param bool + * @param index_type + */ void InitCatmullRom(const Vector3*, index_type, bool, index_type); + /** + * @brief + * + * @param + * @param index_type + * @param bool + * @param index_type + */ void InitBezier3(const Vector3*, index_type, bool, index_type); + /** + * @brief + * + */ typedef void (SplineBase::*InitMethtod)(const Vector3*, index_type, bool, index_type); - static InitMethtod initializers[ModesEnd]; + static InitMethtod initializers[ModesEnd]; /**< TODO */ + /** + * @brief + * + */ void UninitializedSpline() const { MANGOS_ASSERT(false);} public: + /** + * @brief + * + */ explicit SplineBase() : index_lo(0), index_hi(0), m_mode(UninitializedMode), cyclic(false) {} - /** Caclulates the position for given segment Idx, and percent of segment length t - @param t - percent of segment length, assumes that t in range [0, 1] - @param Idx - spline segment index, should be in range [first, last) + /** + * @brief Calculates the position for given segment Idx, and percent of segment length t + * + * @param Idx spline segment index, should be in range [first, last) + * @param u percent of segment length, assumes that t in range [0, 1] + * @param c */ void evaluate_percent(index_type Idx, float u, Vector3& c) const {(this->*evaluators[m_mode])(Idx, u, c);} - /** Caclulates derivation in index Idx, and percent of segment length t - @param Idx - spline segment index, should be in range [first, last) - @param t - percent of spline segment length, assumes that t in range [0, 1] + /** + * @brief Calculates derivation in index Idx, and percent of segment length t + * + * @param Idx spline segment index, should be in range [first, last) + * @param u percent of spline segment length, assumes that t in range [0, 1] + * @param hermite */ void evaluate_derivative(index_type Idx, float u, Vector3& hermite) const {(this->*derivative_evaluators[m_mode])(Idx, u, hermite);} - /** Bounds for spline indexes. All indexes should be in range [first, last). */ + /** + * @brief Bounds for spline indexes. All indexes should be in range [first, last). + * + * @return index_type + */ index_type first() const { return index_lo;} + /** + * @brief + * + * @return index_type + */ index_type last() const { return index_hi;} + /** + * @brief + * + * @return bool + */ bool empty() const { return index_lo == index_hi;} + /** + * @brief + * + * @return EvaluationMode + */ EvaluationMode mode() const { return (EvaluationMode)m_mode;} + /** + * @brief + * + * @return bool + */ bool isCyclic() const { return cyclic;} + /** + * @brief + * + * @return const ControlArray + */ const ControlArray& getPoints() const { return points;} + /** + * @brief + * + * @return index_type + */ index_type getPointCount() const { return points.size();} + /** + * @brief + * + * @param i + * @return const Vector3 + */ const Vector3& getPoint(index_type i) const { return points[i];} - /** Initializes spline. Don't call other methods while spline not initialized. */ + /** + * @brief Initializes spline. Don't call other methods while spline not initialized. + * + * @param controls + * @param count + * @param m + */ void init_spline(const Vector3* controls, index_type count, EvaluationMode m); + /** + * @brief + * + * @param controls + * @param count + * @param m + * @param cyclic_point + */ void init_cyclic_spline(const Vector3* controls, index_type count, EvaluationMode m, index_type cyclic_point); - /** As i can see there are a lot of ways how spline can be initialized - would be no harm to have some custom initializers. */ + /** + * @brief As i can see there are a lot of ways how spline can be + * initialized would be no harm to have some custom initializers. + * + * @param initializer + */ template inline void init_spline(Init& initializer) { initializer(m_mode, cyclic, points, index_lo, index_hi); } + /** + * @brief + * + */ void clear(); - /** Calculates distance between [i; i+1] points, assumes that index i is in bounds. */ + /** + * @brief Calculates distance between [i; i+1] points, assumes that index i is in bounds. + * + * @param i + * @return float + */ float SegLength(index_type i) const { return (this->*seglengths[m_mode])(i);} + /** + * @brief + * + * @return std::string + */ std::string ToString() const; }; template + /** + * @brief + * + */ class Spline : public SplineBase { public: + /** + * @brief + * + */ typedef length_type LengthType; + /** + * @brief + * + */ typedef std::vector LengthArray; protected: - LengthArray lengths; + LengthArray lengths; /**< TODO */ + /** + * @brief + * + * @param length + * @return index_type + */ index_type computeIndexInBounds(length_type length) const; public: + /** + * @brief + * + */ explicit Spline() {} - /** Calculates the position for given t - @param t - percent of spline's length, assumes that t in range [0, 1]. */ + /** + * @brief Calculates the position for given t + * + * @param t percent of spline's length, assumes that t in range [0, 1]. + * @param c + */ void evaluate_percent(float t, Vector3& c) const; - /** Calculates derivation for given t - @param t - percent of spline's length, assumes that t in range [0, 1]. */ + /** + * @brief Calculates derivation for given t + * + * @param t percent of spline's length, assumes that t in range [0, 1]. + * @param hermite + */ void evaluate_derivative(float t, Vector3& hermite) const; - /** Calculates the position for given segment Idx, and percent of segment length t - @param t = partial_segment_length / whole_segment_length - @param Idx - spline segment index, should be in range [first, last). */ + /** + * @brief Calculates the position for given segment Idx, and percent of segment length t + * + * @param Idx spline segment index, should be in range [first, last). + * @param u partial_segment_length / whole_segment_length + * @param c + */ void evaluate_percent(index_type Idx, float u, Vector3& c) const { SplineBase::evaluate_percent(Idx, u, c);} - /** Caclulates derivation for index Idx, and percent of segment length t - @param Idx - spline segment index, should be in range [first, last) - @param t - percent of spline segment length, assumes that t in range [0, 1]. */ + /** + * @brief Caclulates derivation for index Idx, and percent of segment length t + * + * @param Idx spline segment index, should be in range [first, last) + * @param u percent of spline segment length, assumes that t in range [0, 1]. + * @param c + */ void evaluate_derivative(index_type Idx, float u, Vector3& c) const { SplineBase::evaluate_derivative(Idx, u, c);} - // Assumes that t in range [0, 1] + /** + * @brief + * + * @param t Assumes that t in range [0, 1] + * @return index_type + */ index_type computeIndexInBounds(float t) const; + /** + * @brief + * + * @param t + * @param out_idx + * @param out_u + */ void computeIndex(float t, index_type& out_idx, float& out_u) const; - /** Initializes spline. Don't call other methods while spline not initialized. */ + /** + * @brief Initializes spline. Don't call other methods while spline not initialized. + * + * @param controls + * @param count + * @param m + */ void init_spline(const Vector3* controls, index_type count, EvaluationMode m) { SplineBase::init_spline(controls, count, m);} + /** + * @brief + * + * @param controls + * @param count + * @param m + * @param cyclic_point + */ void init_cyclic_spline(const Vector3* controls, index_type count, EvaluationMode m, index_type cyclic_point) { SplineBase::init_cyclic_spline(controls, count, m, cyclic_point);} - /** Initializes lengths with SplineBase::SegLength method. */ + /** + * @brief Initializes lengths with SplineBase::SegLength method. + * + */ void initLengths(); - /** Initializes lengths in some custom way - Note that value returned by cacher must be greater or equal to previous value. */ + /** + * @brief Initializes lengths in some custom way + * Note that value returned by cacher must be greater or equal to previous value. + * + * @param cacher + */ template inline void initLengths(T& cacher) { index_type i = index_lo; @@ -192,6 +466,10 @@ namespace Movement while (i < index_hi) { new_length = cacher(*this, i); + + if (new_length < 0) // length overflowed, assign to max positive value (stop case only?) + new_length = std::numeric_limits::max(); + lengths[++i] = new_length; MANGOS_ASSERT(prev_length <= new_length); @@ -199,13 +477,39 @@ namespace Movement } } - /** Returns length of the whole spline. */ + /** + * @brief Returns length of the whole spline. + * + * @return length_type + */ length_type length() const { return lengths[index_hi];} - /** Returns length between given nodes. */ + /** + * @brief Returns length between given nodes. + * + * @param first + * @param last + * @return length_type + */ length_type length(index_type first, index_type last) const { return lengths[last] - lengths[first];} + /** + * @brief + * + * @param Idx + * @return length_type + */ length_type length(index_type Idx) const { return lengths[Idx];} + /** + * @brief + * + * @param i + * @param length + */ void set_length(index_type i, length_type length) { lengths[i] = length;} + /** + * @brief + * + */ void clear(); }; } diff --git a/src/game/movement/spline.impl.h b/src/game/movement/spline.impl.h index 766e282d9..bc41dc290 100644 --- a/src/game/movement/spline.impl.h +++ b/src/game/movement/spline.impl.h @@ -24,6 +24,12 @@ namespace Movement { + /** + * @brief + * + * @param t + * @param c + */ template void Spline::evaluate_percent(float t, Vector3& c) const { index_type Index; @@ -32,6 +38,12 @@ namespace Movement evaluate_percent(Index, u, c); } + /** + * @brief + * + * @param t + * @param hermite + */ template void Spline::evaluate_derivative(float t, Vector3& hermite) const { index_type Index; @@ -40,9 +52,15 @@ namespace Movement evaluate_derivative(Index, u, hermite); } + /** + * @brief + * + * @param length_ + * @return SplineBase::index_type Spline + */ template SplineBase::index_type Spline::computeIndexInBounds(length_type length_) const { -// Temporary disabled: causes infinite loop with t = 1.f + // Temporary disabled: causes infinite loop with t = 1.f /* index_type hi = index_hi; index_type lo = index_lo; @@ -62,11 +80,18 @@ namespace Movement index_type i = index_lo; index_type N = index_hi; while (i + 1 < N && lengths[i + 1] < length_) - ++i; + { ++i; } return i; } + /** + * @brief + * + * @param t + * @param index + * @param u + */ template void Spline::computeIndex(float t, index_type& index, float& u) const { MANGOS_ASSERT(t >= 0.f && t <= 1.f); @@ -76,12 +101,22 @@ namespace Movement u = (length_ - length(index)) / (float)length(index, index + 1); } + /** + * @brief + * + * @param t + * @return SplineBase::index_type Spline + */ template SplineBase::index_type Spline::computeIndexInBounds(float t) const { MANGOS_ASSERT(t >= 0.f && t <= 1.f); return computeIndexInBounds(t * length()); } + /** + * @brief + * + */ template void Spline::initLengths() { index_type i = index_lo; @@ -94,6 +129,10 @@ namespace Movement } } + /** + * @brief + * + */ template void Spline::clear() { SplineBase::clear(); diff --git a/src/game/movement/typedefs.h b/src/game/movement/typedefs.h index 2f1f19e15..563a7921c 100644 --- a/src/game/movement/typedefs.h +++ b/src/game/movement/typedefs.h @@ -40,38 +40,81 @@ namespace Movement using G3D::Vector3; using G3D::Vector4; + /** + * @brief + * + * @param sec + * @return uint32 + */ inline uint32 SecToMS(float sec) { return static_cast(sec * 1000.f); } + /** + * @brief + * + * @param ms + * @return float + */ inline float MSToSec(uint32 ms) { return ms / 1000.f; } template + /** + * @brief + * + */ class counter { public: + /** + * @brief + * + */ counter() { init();} + + /** + * @brief + * + */ void Increase() { if (m_counter == limit) - init(); + { init(); } else - ++m_counter; + { ++m_counter; } } + /** + * @brief + * + * @return T + */ T NewId() { Increase(); return m_counter;} + /** + * @brief + * + * @return T + */ T getCurrent() const { return m_counter;} private: + /** + * @brief + * + */ void init() { m_counter = 0; } - T m_counter; + T m_counter; /**< TODO */ }; + /** + * @brief + * + */ typedef counter UInt32Counter; extern double gravity; diff --git a/src/game/movement/util.cpp b/src/game/movement/util.cpp index c20b55586..edd97f5e6 100644 --- a/src/game/movement/util.cpp +++ b/src/game/movement/util.cpp @@ -41,22 +41,22 @@ namespace Movement float computeFallTime(float path_length, bool isSafeFall) { if (path_length < 0.f) - return 0.f; + { return 0.f; } float time; if (isSafeFall) { if (path_length >= terminal_savefall_length) - time = (path_length - terminal_savefall_length) / terminalSavefallVelocity + terminalSavefallVelocity / gravity; + { time = (path_length - terminal_savefall_length) / terminalSavefallVelocity + terminalSavefallVelocity / gravity; } else - time = sqrtf(2.f * path_length / gravity); + { time = sqrtf(2.f * path_length / gravity); } } else { if (path_length >= terminal_length) - time = (path_length - terminal_length) / terminalVelocity + terminalFallTime; + { time = (path_length - terminal_length) / terminalVelocity + terminalFallTime; } else - time = sqrtf(2.f * path_length / gravity); + { time = sqrtf(2.f * path_length / gravity); } } return time; @@ -68,12 +68,12 @@ namespace Movement float result; if (isSafeFall) - termVel = terminalSavefallVelocity; + { termVel = terminalSavefallVelocity; } else - termVel = terminalVelocity; + { termVel = terminalVelocity; } if (start_velocity > termVel) - start_velocity = termVel; + { start_velocity = termVel; } float terminal_time = terminalFallTime - start_velocity / gravity; // the time that needed to reach terminalVelocity @@ -83,7 +83,7 @@ namespace Movement start_velocity * terminal_time + gravity * terminal_time * terminal_time * 0.5f; } else - result = t_passed * (start_velocity + t_passed * gravity * 0.5f); + { result = t_passed * (start_velocity + t_passed * gravity * 0.5f); } return result; } @@ -99,7 +99,7 @@ namespace Movement result = terminalVelocity * (t_passed - terminalFallTime) + terminal_length; } else - result = t_passed * t_passed * gravity * 0.5f; + { result = t_passed * t_passed * gravity * 0.5f; } return result; } @@ -201,7 +201,7 @@ namespace Movement for (int i = 0; i < N; ++i) { if ((t & (Flags)(1 << i)) && names[i] != NULL) - str.append(" ").append(names[i]); + { str.append(" ").append(names[i]); } } }