mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[12102] Implement ACTION_T_CHANCED_TEXT
This action allows to display a text with a chance. The Chance must be provided in param1, text(s) can be provided in param2, optionally param3
This commit is contained in:
parent
afb090f57c
commit
36cb073438
5 changed files with 66 additions and 10 deletions
|
|
@ -147,6 +147,7 @@ For all ACTION_T_RANDOM, When a Particular Param is selected for the Event... Th
|
|||
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.
|
||||
|
||||
* = 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).
|
||||
|
||||
|
|
@ -791,6 +792,30 @@ 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
|
||||
|
||||
-----------------------------------------
|
||||
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!
|
||||
|
||||
Read at bottom for documentation of creature_ai_texts-table.
|
||||
|
||||
|
||||
=========================================
|
||||
Target Types
|
||||
=========================================
|
||||
|
|
|
|||
|
|
@ -424,18 +424,30 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
switch (action.type)
|
||||
{
|
||||
case ACTION_T_TEXT:
|
||||
case ACTION_T_CHANCED_TEXT:
|
||||
{
|
||||
if (!action.text.TextId[0])
|
||||
return;
|
||||
|
||||
int32 temp = 0;
|
||||
|
||||
if (action.type == ACTION_T_TEXT)
|
||||
{
|
||||
if (action.text.TextId[1] && action.text.TextId[2])
|
||||
temp = action.text.TextId[rand() % 3];
|
||||
temp = action.text.TextId[urand(0, 2)];
|
||||
else if (action.text.TextId[1] && urand(0, 1))
|
||||
temp = action.text.TextId[1];
|
||||
else
|
||||
temp = action.text.TextId[0];
|
||||
}
|
||||
// ACTION_T_CHANCED_TEXT, chance hits
|
||||
else if (urand(0, 99) < action.chanced_text.chance)
|
||||
{
|
||||
if (action.chanced_text.TextId[0] && action.chanced_text.TextId[1])
|
||||
temp = action.chanced_text.TextId[urand(0, 1)];
|
||||
else
|
||||
temp = action.chanced_text.TextId[0];
|
||||
}
|
||||
|
||||
if (temp)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ enum EventAI_ActionType
|
|||
ACTION_T_FORCE_DESPAWN = 41, // Delay (0-instant despawn)
|
||||
ACTION_T_SET_INVINCIBILITY_HP_LEVEL = 42, // MinHpValue, format(0-flat,1-percent from max health)
|
||||
ACTION_T_MOUNT_TO_ENTRY_OR_MODEL = 43, // Creature_template entry(param1) OR ModelId (param2) (or 0 for both to unmount)
|
||||
ACTION_T_CHANCED_TEXT = 44, // Chance to display the text, TextId1, optionally TextId2. If more than just -TextId1 is defined, randomize. Negative values.
|
||||
ACTION_T_END,
|
||||
};
|
||||
|
||||
|
|
@ -387,6 +388,13 @@ struct CreatureEventAI_Action
|
|||
uint32 creatureId; // set one from fields (or 0 for both to dismount)
|
||||
uint32 modelId;
|
||||
} mount;
|
||||
|
||||
// ACTION_T_CHANCED_TEXT = 44
|
||||
struct
|
||||
{
|
||||
uint32 chance;
|
||||
int32 TextId[2];
|
||||
} chanced_text;
|
||||
// RAW
|
||||
struct
|
||||
{
|
||||
|
|
|
|||
|
|
@ -132,8 +132,11 @@ void CreatureEventAIMgr::CheckUnusedAITexts()
|
|||
switch (action.type)
|
||||
{
|
||||
case ACTION_T_TEXT:
|
||||
case ACTION_T_CHANCED_TEXT:
|
||||
{
|
||||
for (int k = 0; k < 3; ++k)
|
||||
// ACTION_T_CHANCED_TEXT contains a chance value in first param
|
||||
int k = action.type == ACTION_T_TEXT ? 0 : 1;
|
||||
for (; k < 3; ++k)
|
||||
if (action.text.TextId[k])
|
||||
idx_set.erase(action.text.TextId[k]);
|
||||
break;
|
||||
|
|
@ -511,14 +514,22 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
|
|||
{
|
||||
case ACTION_T_NONE:
|
||||
break;
|
||||
case ACTION_T_CHANCED_TEXT:
|
||||
// Check first param as chance
|
||||
if (!action.chanced_text.chance)
|
||||
sLog.outErrorDb("CreatureEventAI: Event %u Action %u has not set chance param1. Text will not be displayed", i, j + 1);
|
||||
else if (action.chanced_text.chance >= 100)
|
||||
sLog.outErrorDb("CreatureEventAI: Event %u Action %u has set chance param1 >= 100. Text will always be displayed", i, j + 1);
|
||||
// no break here to check texts
|
||||
case ACTION_T_TEXT:
|
||||
{
|
||||
bool not_set = false;
|
||||
for (int k = 0; k < 3; ++k)
|
||||
int firstTextParam = action.type == ACTION_T_TEXT ? 0 : 1;
|
||||
for (int k = firstTextParam; k < 3; ++k)
|
||||
{
|
||||
if (action.text.TextId[k])
|
||||
{
|
||||
if (k > 0 && not_set)
|
||||
if (k > firstTextParam && not_set)
|
||||
sLog.outErrorDb("CreatureEventAI: Event %u Action %u has param%d, but it follow after not set param. Required for randomized text.", i, j + 1, k + 1);
|
||||
|
||||
if (!action.text.TextId[k])
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "12101"
|
||||
#define REVISION_NR "12102"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue