[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:
Schmoozerd 2012-08-17 20:56:49 +02:00 committed by Antz
parent afb090f57c
commit 36cb073438
5 changed files with 66 additions and 10 deletions

View file

@ -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)
{