Roll dice chatbar command: Added penetrating dice

Also, LLStringUtil::toLower(modifier_type), to make it case insensitive
Northspring 2014-08-30 16:11:43 +02:00
parent 197c8fd6aa
commit 85eecdad07
3 changed files with 25 additions and 7 deletions

View File

@ -1229,8 +1229,9 @@ bool cmd_line_chat(const std::string& revised_text, EChatType type, bool from_ge
if (i >> modifier_type && i >> modifier)
{
// 2d20+5, 2d20-5 / 2d20>5, 2d20<5 / 2d20!>5, 2d20!<5, 2d20!5 / 2d20r>5, 2d20r<5, 2d20r5
if (modifier < -1000 || modifier > 1000 || (modifier_type != "+" && modifier_type != "-" && modifier_type != "<" && modifier_type != ">" && modifier_type != "!>" && modifier_type != "!<" && modifier_type != "!" && modifier_type != "r" && modifier_type != "r>" && modifier_type != "r<"))
// 2d20+5, 2d20-5 / 2d20>5, 2d20<5 / 2d20!>5, 2d20!<5, 2d20!5 / 2d20!p>5, 2d20!p<5, 2d20!p5 / 2d20r>5, 2d20r<5, 2d20r5
LLStringUtil::toLower(modifier_type);
if (modifier < -1000 || modifier > 1000 || (modifier_type != "+" && modifier_type != "-" && modifier_type != "<" && modifier_type != ">" && modifier_type != "!>" && modifier_type != "!<" && modifier_type != "!" && modifier_type != "!p" && modifier_type != "!p>" && modifier_type != "!p<" && modifier_type != "r" && modifier_type != "r>" && modifier_type != "r<"))
{
modifier_error = 1;
}
@ -1252,17 +1253,23 @@ bool cmd_line_chat(const std::string& revised_text, EChatType type, bool from_ge
S32 result_per_die = 0;
S32 die_iter = 1;
S32 freeze_guard = 0;
S32 die_penetrated = 0;
while (die_iter <= dice)
{
// Each die may have a different value rolled
result_per_die = 1 + (rand() % faces);
result += result_per_die;
if (dice > 1)
if (die_penetrated == 1)
{
result_per_die -= 1;
die_penetrated = 0;
reportToNearbyChat(llformat("#%d 1d%d-1: %d.", die_iter, faces, result_per_die));
}
else
{
// For more than one die show the ordinal number in front of the result
reportToNearbyChat(llformat("#%d 1d%d: %d.", die_iter, faces, result_per_die));
}
result += result_per_die;
++die_iter;
if (modifier_type == "<")
@ -1297,6 +1304,13 @@ bool cmd_line_chat(const std::string& revised_text, EChatType type, bool from_ge
reportToNearbyChat(" ^-- " + LLTrans::getString("FSCmdLineRollDiceExploded"));
--die_iter;
}
else if ((modifier_type == "!p" && result_per_die == modifier) || (modifier_type == "!p>" && result_per_die >= modifier) || (modifier_type == "!p<" && result_per_die <= modifier))
{
// Modifier: Penetrating dice (special style of exploding dice)
reportToNearbyChat(" ^-- " + LLTrans::getString("FSCmdLineRollDicePenetrated"));
die_penetrated = 1;
--die_iter;
}
else if ((modifier_type == "r" && result_per_die == modifier) || (modifier_type == "r>" && result_per_die >= modifier) || (modifier_type == "r<" && result_per_die <= modifier))
{
// Modifier: Reroll

View File

@ -2597,8 +2597,9 @@ Try enclosing path to the editor with double quotes.
<string name="FSCmdLineRollDiceTotal">Total result for [DICE]d[FACES][MODIFIER]: [RESULT].</string>
<string name="FSCmdLineRollDiceLimits">You must provide positive values for dice (max 100) and faces (max 1000).</string>
<string name="FSCmdLineRollDiceModifiersInvalid">If you want to use a modifier, then you must provide valid modifier number and the type of modifier. Modifier must be in range from -1000 to 1000. Valid modifier types are "+" (bonuses), "-" (penalties), "&gt;", "&lt;" (successes), "r&gt;", "r&lt;", "r" (rerolls), "!&gt;", "!&lt;" and "!" (explosions). You can use only one modifier type per roll. Examples: "[COMMAND] 1 20 + 5", "[COMMAND] 5 40 &gt; 15", "[COMMAND] 10 25 ! 25", "[COMMAND] 15 25 !&lt; 10".</string>
<string name="FSCmdLineRollDiceModifiersInvalid">If you want to use a modifier, then you must provide valid modifier number and the type of modifier. Modifier must be in range from -1000 to 1000. Valid modifier types are "+" (bonuses), "-" (penalties), "&gt;", "&lt;" (successes), "r&gt;", "r&lt;", "r" (rerolls), "!p&gt;", "!p&lt;", "!p" (penetrations), "!&gt;", "!&lt;" and "!" (explosions). You can use only one modifier type per roll. Examples: "[COMMAND] 1 20 + 5", "[COMMAND] 5 40 &gt; 15", "[COMMAND] 10 25 ! 25", "[COMMAND] 15 25 !&lt; 10".</string>
<string name="FSCmdLineRollDiceExploded">Exploded</string>
<string name="FSCmdLineRollDicePenetrated">Penetrated</string>
<string name="FSCmdLineRollDiceSuccess">Success</string>
<string name="FSCmdLineRollDiceReroll">Reroll</string>
<string name="FSCmdLineRollDiceFreezeGuard">This operation cannot be completed because the viewer would freeze in an infinite rolling loop. Please change the criteria.</string>

View File

@ -5217,11 +5217,14 @@ Spróbuj załączyć ścieżkę do edytora w cytowaniu.
Musisz podać wartości dodatnie dla ilości kostek (maksymalnie 100) oraz ścianek (maksymalnie 1000).
</string>
<string name="FSCmdLineRollDiceModifiersInvalid">
Jeśli chcesz użyć modyfikatora, to musisz podać właściwą jego liczbę oraz typ. Wartość modyfikatora musi być w zakresie od -1000 do 1000. Prawidłowe typy modyfikatorów to "+" (premie), "-" (kary), "&gt;", "&lt;" (sukcesy), "r&gt;", "r&lt;", "r" (ponowne rzuty), "!&gt;", "!&lt;" oraz "!" (eksplozje). Możesz jednocześnie użyć tylko jednego typu modyfikatora. Przykłady: "[COMMAND] 1 20 + 5", "[COMMAND] 5 40 &gt; 15", "[COMMAND] 10 25 ! 25", "[COMMAND] 15 25 !&lt; 10".
Jeśli chcesz użyć modyfikatora, to musisz podać właściwą jego liczbę oraz typ. Wartość modyfikatora musi być w zakresie od -1000 do 1000. Prawidłowe typy modyfikatorów to "+" (premie), "-" (kary), "&gt;", "&lt;" (sukcesy), "r&gt;", "r&lt;", "r" (ponowne rzuty), "!p&gt;", "!p&lt;", "!p" (penetracje), "!&gt;", "!&lt;" oraz "!" (eksplozje). Możesz jednocześnie użyć tylko jednego typu modyfikatora. Przykłady: "[COMMAND] 1 20 + 5", "[COMMAND] 5 40 &gt; 15", "[COMMAND] 10 25 ! 25", "[COMMAND] 15 25 !&lt; 10".
</string>
<string name="FSCmdLineRollDiceExploded">
Eksplozja
</string>
<string name="FSCmdLineRollDicePenetrated">
Penetracja
</string>
<string name="FSCmdLineRollDiceSuccess">
Sukces
</string>