- Posts: 138
- Thank you received: 7
Critical heals not factoring HAPPY_HEAL during bonus
- Nero
-
Topic Author
- Offline
- Premium Member
-
Less
More
2 weeks 4 days ago #10347
by Nero
Critical heals not factoring HAPPY_HEAL during bonus was created by Nero
I noticed tonight math seems to be off when a heal crits it does not factor in the healing bonus when HAPPY_HEAL is active.
I am not sure if I am missing the order of operations when it crits or what
It seems to work when it non-crits but I am not sure exactly how to write it for it to work during crits
Example:If there's a +20 HAPPY_HEAL Bonus and the player has +99 to healing stats with their gear and buffs and a heal light heals for +60 hp.
However, currently when a heal crits its just calculating dam as 60 + GET_SPELL_MODS(ch, DMG_INCREASE_HEAL) which only equals 159.
That divided by 100 is 15.9 and its only healing for 174-175 hp.
I am not sure if I am missing the order of operations when it crits or what
It seems to work when it non-crits but I am not sure exactly how to write it for it to work during crits
case SPELL_HEAL_LIGHT:
crit_percent = ((rand_number(1,100)) + (GET_SPELL_MODS(ch, DMG_INCREASE_CRITPER)));
if (affected_by_spell(ch, SPELL_BEACON_OF_HOPE)) {
crit_percent += 50;
if (crit_percent > 100) {
crit_percent = 100;
}
}
if (crit_percent <= 99) {
if ((IS_HAPPYHOUR && IS_HAPPYHEAL) && (!IS_NPC(ch))) {
victim_add_hits = (60 + (GET_SPELL_MODS(ch, DMG_INCREASE_HEAL)));
victim_add_hits += HAPPY_HEAL;
}
if ((IS_HAPPYHOUR && !IS_HAPPYHEAL) && (!IS_NPC(ch))) {
victim_add_hits = (60 + (GET_SPELL_MODS(ch, DMG_INCREASE_HEAL)));
}
if ((!IS_HAPPYHOUR) || (IS_NPC(ch))) {
victim_add_hits = (60 + (GET_SPELL_MODS(ch, DMG_INCREASE_HEAL)));
}
send_to_char(victim, "A warm feeling fills your body.\r\n");
if (victim != ch) {
act("You heal $N.", FALSE, ch, 0, victim, TO_CHAR);
}
to_room = "$n heals $N.";
}
if (crit_percent >= 100) {
dam = (60 + (GET_SPELL_MODS(ch, DMG_INCREASE_HEAL)));
crit_damage = ((dam * (GET_SPELL_MODS(ch, DMG_INCREASE_CRITDMG))) / 100);
total_damage = (dam + crit_damage);
if ((IS_HAPPYHOUR && IS_HAPPYHEAL) && (!IS_NPC(ch))) {
victim_add_hits = (total_damage + HAPPY_HEAL);
}
if ((IS_HAPPYHOUR && !IS_HAPPYHEAL) && (!IS_NPC(ch))) {
victim_add_hits = total_damage;
}
if ((!IS_HAPPYHOUR) || (IS_NPC(ch))) {
victim_add_hits = total_damage;
}
send_to_char(victim, "@Y*CRITICAL*@n A warm feeling fills your body.\r\n");
if (victim != ch) {
act("@Y*CRITICAL*@n You heal $N.", FALSE, ch, 0, victim, TO_CHAR);
}
to_room = "$n heals $N.";
}
break;
Example:If there's a +20 HAPPY_HEAL Bonus and the player has +99 to healing stats with their gear and buffs and a heal light heals for +60 hp.
- Calculate the base healing amount with the bonus (dam): dam = 60 + GET_SPELL_MODS(ch, DMG_INCREASE_HEAL) + HAPPY_HEAL = 60 + 99 + 20 (assuming GET_SPELL_MODS(ch, DMG_INCREASE_HEAL) is 99 and there's a +20 bonus) dam = 179
- Calculate the critical damage bonus (crit_damage): crit_damage = (dam * GET_SPELL_MODS(ch, DMG_INCREASE_CRITDMG)) / 100 crit_damage = (179 * 10) / 100 crit_damage = 17.9 (rounded to 18 since healing amounts are typically integers)
- Calculate the total critical healing amount (total_damage): total_damage = dam + crit_damage total_damage = 179 + 18 total_damage = 197
However, currently when a heal crits its just calculating dam as 60 + GET_SPELL_MODS(ch, DMG_INCREASE_HEAL) which only equals 159.
That divided by 100 is 15.9 and its only healing for 174-175 hp.
Please Log in or Create an account to join the conversation.
- thomas
-
- Offline
- Administrator
-
Less
More
- Posts: 818
- Thank you received: 159
1 week 5 days ago #10348
by thomas
Replied by thomas on topic Critical heals not factoring HAPPY_HEAL during bonus
Well, I tried to just go by your description and started out with a bit of pseudocode.
This is how it ended up (note: browser code):
// calculate the base damage
// if crit
// calculate the critical damage bonus
// calculate the critical healing amount
// otherwise
// just heal without crit
This is how it ended up (note: browser code):
case SPELL_HEAL_LIGHT:
// calculate the base damage
victim_add_hits = 60 + GET_SPELL_MODS(ch, DMG_INCREASE_HEAL); // default value if no special things happen.
if ((IS_HAPPYHOUR && IS_HAPPYHEAL) && (!IS_NPC(ch))) {
victim_add_hits += HAPPY_HEAL;
}
crit_percent = ((rand_number(1,100)) + (GET_SPELL_MODS(ch, DMG_INCREASE_CRITPER)));
if (affected_by_spell(ch, SPELL_BEACON_OF_HOPE)) {
crit_percent += 50;
}
if (crit_percent >= 100) {
// wow! you surpassed the crit limit!
// calculate the critical damage bonus
crit_damage = (int)(((float)victim_add_points * GET_SPELL_MODS(ch, DMG_INCREASE_CRITDMG)) / 100);
// calculate the critical healing amount
victim_add_points += crit_damage;
send_to_char(victim, "@Y*CRITICAL*@n A warm feeling fills your body.\r\n");
if (victim != ch) {
act("@Y*CRITICAL*@n You heal $N.", FALSE, ch, 0, victim, TO_CHAR);
}
to_room = "$n heals $N.";
} else {
// sorry, no crit
// just heal without crit
send_to_char(victim, "A warm feeling fills your body.\r\n");
if (victim != ch) {
act("You heal $N.", FALSE, ch, 0, victim, TO_CHAR);
}
to_room = "$n heals $N.";
}
break;
Please Log in or Create an account to join the conversation.
Time to create page: 0.099 seconds