Skip to content

Commit

Permalink
Core/Spells: fixed an underflow in SPELL_EFFECT_INEBRIATE when using …
Browse files Browse the repository at this point in the history
…drinks that sober the character up (such as Starfire Espresso)
  • Loading branch information
Ovahlord committed Jul 11, 2023
1 parent ff9a23a commit 45333fc
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/server/game/Spells/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3400,23 +3400,19 @@ void Spell::EffectInebriate()
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;

if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
if (!unitTarget || !unitTarget->IsPlayer())
return;

Player* player = unitTarget->ToPlayer();
uint8 currentDrunk = player->GetDrunkValue();
uint8 drunkMod = damage;
if (currentDrunk + drunkMod > 100)
{
currentDrunk = 100;
if (rand_chance() < 25.0f)

uint8 currentDrunkValue = player->GetDrunkValue();
uint8 drunkValue = std::clamp<int32>(damage + currentDrunkValue, 0, 100);
if (currentDrunkValue == 100 && currentDrunkValue == drunkValue)
if (roll_chance_f(25.0f))
player->CastSpell(player, 67468, CastSpellExtraArgs()
.SetTriggeringSpell(this)); // Drunken Vomit
}
else
currentDrunk += drunkMod;

player->SetDrunkValue(currentDrunk, m_CastItem ? m_CastItem->GetEntry() : 0);
player->SetDrunkValue(drunkValue, m_CastItem ? m_CastItem->GetEntry() : 0);
}

void Spell::EffectFeedPet()
Expand Down

0 comments on commit 45333fc

Please sign in to comment.