mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +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
|
|
@ -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.text.TextId[1] && action.text.TextId[2])
|
||||
temp = action.text.TextId[rand() % 3];
|
||||
else if (action.text.TextId[1] && urand(0, 1))
|
||||
temp = action.text.TextId[1];
|
||||
else
|
||||
temp = action.text.TextId[0];
|
||||
if (action.type == ACTION_T_TEXT)
|
||||
{
|
||||
if (action.text.TextId[1] && action.text.TextId[2])
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue