Skip to content

Commit

Permalink
fix: divine grenade (#1715)
Browse files Browse the repository at this point in the history
  • Loading branch information
luan authored Oct 20, 2023
1 parent 85bc997 commit 8e3d4a0
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 8 deletions.
56 changes: 49 additions & 7 deletions src/creatures/players/wheel/player_wheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,14 @@ void PlayerWheel::registerPlayerBonusData() {
setSpellInstant("Divine Empowerment", false);
}

if (m_playerBonusData.stages.divineGrenade > 0) {
for (int i = 0; i < m_playerBonusData.stages.divineGrenade; ++i) {
setSpellInstant("Divine Grenade", true);
}
} else {
setSpellInstant("Divine Grenade", false);
}

if (m_playerBonusData.stages.drainBody > 0) {
for (int i = 0; i < m_playerBonusData.stages.drainBody; ++i) {
setSpellInstant("Drain Body", true);
Expand Down Expand Up @@ -1328,6 +1336,9 @@ void PlayerWheel::printPlayerWheelMethodsBonusData(const PlayerWheelMethodsBonus
if (bonusData.stages.divineEmpowerment > 0) {
g_logger().debug(" divineEmpowerment: {}", bonusData.stages.divineEmpowerment);
}
if (bonusData.stages.divineGrenade > 0) {
g_logger().debug(" divineGrenade: {}", bonusData.stages.divineGrenade);
}
if (bonusData.stages.blessingOfTheGrove > 0) {
g_logger().debug(" blessingOfTheGrove: {}", bonusData.stages.blessingOfTheGrove);
}
Expand Down Expand Up @@ -1435,6 +1446,7 @@ void PlayerWheel::loadRevelationPerks() {
addSpellToVector("Great Death Beam");
}
} else if (vocationEnum == Vocation_t::VOCATION_PALADIN_CIP) {
m_playerBonusData.stages.divineGrenade = redStageValue;
for (uint8_t i = 0; i < redStageValue; ++i) {
addSpellToVector("Divine Grenade");
}
Expand Down Expand Up @@ -1791,7 +1803,7 @@ bool PlayerWheel::checkCombatMastery() {

bool PlayerWheel::checkDivineEmpowerment() {
bool updateClient = false;
setOnThinkTimer(WheelOnThink_t::DIVINE_EMPOWERMENT, OTSYS_TIME() + 2000);
setOnThinkTimer(WheelOnThink_t::DIVINE_EMPOWERMENT, OTSYS_TIME() + 1000);

const auto tile = m_player.getTile();
if (!tile) {
Expand Down Expand Up @@ -1821,16 +1833,34 @@ bool PlayerWheel::checkDivineEmpowerment() {
} else if (stage >= 1) {
damageBonus = 8;
}

if (damageBonus != getMajorStat(WheelMajor_t::DAMAGE)) {
setMajorStat(WheelMajor_t::DAMAGE, damageBonus);
updateClient = true;
}
}
if (damageBonus != getMajorStat(WheelMajor_t::DAMAGE)) {
setMajorStat(WheelMajor_t::DAMAGE, damageBonus);
updateClient = true;
}

return updateClient;
}

int32_t PlayerWheel::checkDivineGrenade(std::shared_ptr<Creature> target) const {
if (!target || target == m_player.getPlayer()) {
return 0;
}

int32_t damageBonus = 0;
uint8_t stage = getStage(WheelStage_t::DIVINE_GRENADE);

if (stage >= 3) {
damageBonus = 100;
} else if (stage >= 2) {
damageBonus = 60;
} else if (stage >= 1) {
damageBonus = 30;
}

return damageBonus;
}

void PlayerWheel::checkGiftOfLife() {
// Healing
CombatDamage giftDamage;
Expand Down Expand Up @@ -2055,7 +2085,9 @@ void PlayerWheel::onThink(bool force /* = false*/) {
m_player.sendStats();
g_game().reloadCreature(m_player.getPlayer());
}
return;
if (!force) {
return;
}
}
// Battle Instinct
if (getInstant("Battle Instinct") && (force || getOnThinkTimer(WheelOnThink_t::BATTLE_INSTINCT) < OTSYS_TIME()) && checkBattleInstinct()) {
Expand Down Expand Up @@ -2297,6 +2329,12 @@ void PlayerWheel::setSpellInstant(const std::string &name, bool value) {
} else {
setStage(WheelStage_t::DIVINE_EMPOWERMENT, 0);
}
} else if (name == "Divine Grenade") {
if (value) {
setStage(WheelStage_t::DIVINE_GRENADE, getStage(WheelStage_t::DIVINE_GRENADE) + 1);
} else {
setStage(WheelStage_t::DIVINE_GRENADE, 0);
}
} else if (name == "Twin Burst") {
if (value) {
setStage(WheelStage_t::TWIN_BURST, getStage(WheelStage_t::TWIN_BURST) + 1);
Expand Down Expand Up @@ -2380,6 +2418,8 @@ uint8_t PlayerWheel::getStage(const std::string name) const {
return PlayerWheel::getStage(WheelStage_t::DRAIN_BODY);
} else if (name == "Divine Empowerment") {
return PlayerWheel::getStage(WheelStage_t::DIVINE_EMPOWERMENT);
} else if (name == "Divine Grenade") {
return PlayerWheel::getStage(WheelStage_t::DIVINE_GRENADE);
} else if (name == "Twin Burst") {
return PlayerWheel::getStage(WheelStage_t::TWIN_BURST);
} else if (name == "Executioner's Throw") {
Expand Down Expand Up @@ -2502,6 +2542,8 @@ bool PlayerWheel::getInstant(const std::string name) const {
return PlayerWheel::getStage(WheelStage_t::DRAIN_BODY);
} else if (name == "Divine Empowerment") {
return PlayerWheel::getStage(WheelStage_t::DIVINE_EMPOWERMENT);
} else if (name == "Divine Grenade") {
return PlayerWheel::getStage(WheelStage_t::DIVINE_GRENADE);
} else if (name == "Twin Burst") {
return PlayerWheel::getStage(WheelStage_t::TWIN_BURST);
} else if (name == "Executioner's Throw") {
Expand Down
4 changes: 3 additions & 1 deletion src/creatures/players/wheel/wheel_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ enum class WheelStage_t : uint8_t {
AVATAR_OF_NATURE = 9,
AVATAR_OF_STEEL = 10,
AVATAR_OF_STORM = 11,
DIVINE_GRENADE = 12,

TOTAL_COUNT = 12
TOTAL_COUNT = 13
};

enum class WheelOnThink_t : uint8_t {
Expand Down Expand Up @@ -226,6 +227,7 @@ struct PlayerWheelMethodsBonusData {
int combatMastery = 0; // Knight
int giftOfLife = 0; // Knight/Paladin/Druid/Sorcerer
int divineEmpowerment = 0; // Paladin
int divineGrenade = 0; // Paladin
int blessingOfTheGrove = 0; // Druid
int drainBody = 0; // Sorcerer
int beamMastery = 0; // Sorcerer
Expand Down
7 changes: 7 additions & 0 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6294,6 +6294,13 @@ void Game::applyWheelOfDestinyEffectsToDamage(CombatDamage &damage, std::shared_
damage.secondary.value += (damage.secondary.value * damageBonus) / 100.;
}
}
if (damage.instantSpellName == "Divine Grenade") {
int32_t damageBonus = attackerPlayer->wheel()->checkDivineGrenade(target);
if (damageBonus != 0) {
damage.primary.value += (damage.primary.value * damageBonus) / 100.;
damage.secondary.value += (damage.secondary.value * damageBonus) / 100.;
}
}
}
}

Expand Down

0 comments on commit 8e3d4a0

Please sign in to comment.