Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wheel bonuses #3058

Merged
merged 21 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4ea2a8f
fix: wheel fixes
phacUFPE Oct 31, 2024
8c481ef
Code format - (Clang-format)
github-actions[bot] Nov 3, 2024
8602ef6
Code format - (Clang-format)
github-actions[bot] Nov 3, 2024
145606f
Merge branch 'main' into fix_wheel_bonuses
phacUFPE Nov 3, 2024
2148caf
Lua code format - (Stylua)
github-actions[bot] Nov 3, 2024
4ad9eeb
Merge branch 'main' into fix_wheel_bonuses
murilo09 Nov 4, 2024
543e314
Merge branch 'fix_wheel_bonuses' of https://github.com/opentibiabr/ca…
phacUFPE Nov 4, 2024
3114db6
refactor: misspelling and function improvement
phacUFPE Nov 4, 2024
765e79d
fix: sonar duplicated code
phacUFPE Nov 5, 2024
3700fae
fix: return temporary ref
phacUFPE Nov 5, 2024
626a284
fix: remove unused function
phacUFPE Nov 5, 2024
a399a28
fix: executioners throw
phacUFPE Nov 5, 2024
daaf348
improve: simplify function logic and check nullpointers
dudantas Nov 9, 2024
97dc21b
Code format - (Clang-format)
github-actions[bot] Nov 9, 2024
553c3f2
Merge branch 'main' into fix_wheel_bonuses
phacUFPE Nov 10, 2024
a319abd
Merge branch 'main' into fix_wheel_bonuses
phacUFPE Nov 10, 2024
70bee9f
perf: use spectators to get monsters within range
phacUFPE Nov 11, 2024
7bdf9b6
Merge branch 'main' into fix_wheel_bonuses
phacUFPE Nov 11, 2024
0fd8c24
Merge branch 'main' into fix_wheel_bonuses
dudantas Nov 12, 2024
4ee9e55
fix: bad behaviour when saving the wheel without points added
phacUFPE Nov 12, 2024
bd9aa56
Merge branch 'fix_wheel_bonuses' of https://github.com/opentibiabr/ca…
phacUFPE Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/scripts/lib/register_spells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ AREA_RING1_BURST3 = {
{ 0, 0, 1, 1, 1, 1, 1, 0, 0 },
{ 0, 1, 1, 1, 1, 1, 1, 1, 0 },
{ 1, 1, 1, 0, 0, 0, 1, 1, 1 },
{ 1, 1, 1, 0, 3, 0, 1, 1, 1 },
{ 1, 1, 1, 0, 2, 0, 1, 1, 1 },
{ 1, 1, 1, 0, 0, 0, 1, 1, 1 },
{ 0, 1, 1, 1, 1, 1, 1, 1, 0 },
{ 0, 0, 1, 1, 1, 1, 1, 0, 0 },
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/spells/attack/divine_grenade.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ local explodeGrenade = function(position, playerId)
end

local var = {}
var.instantName = "Divine Grenade Explode"
var.instantName = "Divine Grenade"
var.runeName = ""
var.type = 2 -- VARIANT_POSITION
var.pos = position
Expand Down
7 changes: 3 additions & 4 deletions data/scripts/spells/attack/energy_beam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ local spell = Spell("instant")

function spell.onCastSpell(creature, var)
local player = creature:getPlayer()
if creature and player and player:instantSkillWOD("Beam Mastery") then
var.runeName = "Beam Mastery"
return combatWOD:execute(creature, var)
if not creature or not player then
return false
end
return combat:execute(creature, var)
return player:instantSkillWOD("Beam Mastery") and combatWOD:execute(creature, var) or combat:execute(creature, var)
end

spell:group("attack")
Expand Down
23 changes: 3 additions & 20 deletions data/scripts/spells/attack/executioners_throw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,11 @@ function spell.onCastSpell(creature, var)

local grade = creature:revelationStageWOD("Executioner's Throw")
if grade == 0 then
creature:sendCancelMessage("You cannot cast this spell")
creature:sendCancelMessage("You need to learn this spell first")
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

local cooldown = 0
if grade >= 3 then
cooldown = 10
elseif grade >= 2 then
cooldown = 14
elseif grade >= 1 then
cooldown = 18
end

var.instantName = "Executioner's Throw"
if combat:execute(creature, var) then
local condition = Condition(CONDITION_SPELLCOOLDOWN, CONDITIONID_DEFAULT, 261)
condition:setTicks((cooldown * 1000) / configManager.getFloat(configKeys.RATE_SPELL_COOLDOWN))
creature:addCondition(condition)
return true
end
return false
return combat:execute(creature, var)
end

spell:group("attack")
Expand All @@ -75,7 +58,7 @@ spell:range(5)
spell:needTarget(true)
spell:blockWalls(true)
spell:needWeapon(true)
spell:cooldown(1000) -- Cooldown is calculated on the casting
spell:cooldown(18 * 1000)
spell:groupCooldown(2 * 1000)
spell:needLearn(true)
spell:vocation("knight;true", "elite knight;true")
Expand Down
28 changes: 6 additions & 22 deletions data/scripts/spells/attack/great_death_beam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ end
local combat1 = createCombat(initCombat, AREA_BEAM6)
local combat2 = createCombat(initCombat, AREA_BEAM7)
local combat3 = createCombat(initCombat, AREA_BEAM8)
local combat = { combat1, combat2, combat3 }

local spell = Spell("instant")

Expand All @@ -28,32 +29,15 @@ function spell.onCastSpell(creature, var)

local grade = creature:upgradeSpellsWOD("Great Death Beam")
if grade == WHEEL_GRADE_NONE then
creature:sendCancelMessage("You cannot cast this spell")
creature:sendCancelMessage("You need to learn this spell first")
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

local cooldown = { 10, 8, 6 }
var.runeName = "Beam Mastery"
local executed = false

local combat = { combat1, combat2, combat3 }

executed = combat[grade]:execute(creature, var)

if executed then
local condition = Condition(CONDITION_SPELLCOOLDOWN, CONDITIONID_DEFAULT, 260)
local executedCooldown = cooldown[grade]
if executedCooldown ~= nil then
condition:setTicks((executedCooldown * 1000))
end
creature:addCondition(condition)
return true
end
return false
return combat[grade]:execute(creature, var)
end

spell:group("attack")
spell:group("attack", "greatbeams")
spell:id(260)
spell:name("Great Death Beam")
spell:words("exevo max mort")
Expand All @@ -62,8 +46,8 @@ spell:mana(140)
spell:isPremium(false)
spell:needDirection(true)
spell:blockWalls(true)
spell:cooldown(1000) -- Cooldown is calculated on the casting
spell:groupCooldown(2 * 1000)
spell:cooldown(10 * 1000)
spell:groupCooldown(2 * 1000, 6 * 1000)
spell:needLearn(true)
spell:vocation("sorcerer;true", "master sorcerer;true")
spell:register()
12 changes: 5 additions & 7 deletions data/scripts/spells/attack/great_energy_beam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ local spell = Spell("instant")

function spell.onCastSpell(creature, var)
local player = creature:getPlayer()
if creature and player and player:instantSkillWOD("Beam Mastery") then
var.runeName = "Beam Mastery"
return combatWOD:execute(creature, var)
if not creature or not player then
return false
end

return combat:execute(creature, var)
return player:instantSkillWOD("Beam Mastery") and combatWOD:execute(creature, var) or combat:execute(creature, var)
end

spell:group("attack")
spell:group("attack", "greatbeams")
spell:id(23)
spell:name("Great Energy Beam")
spell:words("exevo gran vis lux")
Expand All @@ -47,7 +45,7 @@ spell:isPremium(false)
spell:needDirection(true)
spell:blockWalls(true)
spell:cooldown(6 * 1000)
spell:groupCooldown(2 * 1000)
spell:groupCooldown(2 * 1000, 6 * 1000)
spell:needLearn(false)
spell:vocation("sorcerer;true", "master sorcerer;true")
spell:register()
37 changes: 7 additions & 30 deletions data/scripts/spells/attack/ice_burst.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,27 @@ combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local spell = Spell("instant")

function spell.onCastSpell(creature, var)
if not creature or not creature:isPlayer() then
return false
end

local grade = creature:revelationStageWOD("Twin Burst")
if grade == 0 then
creature:sendCancelMessage("You cannot cast this spell")
creature:sendCancelMessage("You need to learn this spell first")
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

local cooldown = 0
if grade >= 3 then
cooldown = 14
elseif grade >= 2 then
cooldown = 18
elseif grade >= 1 then
cooldown = 22
end

var.instantName = "Twin Burst"
if combat:execute(creature, var) then
-- Ice cooldown
local condition1 = Condition(CONDITION_SPELLCOOLDOWN, CONDITIONID_DEFAULT, 262)
condition1:setTicks((cooldown * 1000) / configManager.getFloat(configKeys.RATE_SPELL_COOLDOWN))
creature:addCondition(condition1)
-- Earth cooldown
local condition2 = Condition(CONDITION_SPELLCOOLDOWN, CONDITIONID_DEFAULT, 263)
condition2:setTicks((cooldown * 1000) / configManager.getFloat(configKeys.RATE_SPELL_COOLDOWN))
creature:addCondition(condition2)
return true
end
return false
return combat:execute(creature, var)
end

spell:group("attack")
spell:group("attack", "burstsofnature")
spell:id(262)
spell:name("Ice Burst")
spell:words("exevo ulus frigo")
spell:castSound(SOUND_EFFECT_TYPE_SPELL_ETERNAL_WINTER)
spell:level(300)
spell:mana(230)
spell:isPremium(true)
spell:cooldown(1000) -- Cooldown is calculated on the casting
spell:groupCooldown(2 * 1000)
spell:isSelfTarget(true)
spell:cooldown(22 * 1000)
spell:groupCooldown(2 * 1000, 22 * 1000)
spell:needLearn(true)
spell:vocation("druid;true", "elder druid;true")
spell:register()
37 changes: 7 additions & 30 deletions data/scripts/spells/attack/terra_burst.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,27 @@ combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local spell = Spell("instant")

function spell.onCastSpell(creature, var)
if not creature or not creature:isPlayer() then
return false
end

local grade = creature:revelationStageWOD("Twin Burst")
if grade == 0 then
creature:sendCancelMessage("You cannot cast this spell")
creature:sendCancelMessage("You need to learn this spell first")
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

local cooldown = 0
if grade >= 3 then
cooldown = 14
elseif grade >= 2 then
cooldown = 18
elseif grade >= 1 then
cooldown = 22
end

var.instantName = "Twin Burst"
if combat:execute(creature, var) then
-- Ice cooldown
local condition1 = Condition(CONDITION_SPELLCOOLDOWN, CONDITIONID_DEFAULT, 262)
condition1:setTicks((cooldown * 1000) / configManager.getFloat(configKeys.RATE_SPELL_COOLDOWN))
creature:addCondition(condition1)
-- Earth cooldown
local condition2 = Condition(CONDITION_SPELLCOOLDOWN, CONDITIONID_DEFAULT, 263)
condition2:setTicks((cooldown * 1000) / configManager.getFloat(configKeys.RATE_SPELL_COOLDOWN))
creature:addCondition(condition2)
return true
end
return false
return combat:execute(creature, var)
end

spell:group("attack")
spell:group("attack", "burstsofnature")
spell:id(263)
spell:name("Terra Burst")
spell:words("exevo ulus tera")
spell:castSound(SOUND_EFFECT_TYPE_SPELL_WRATH_OF_NATURE)
spell:level(300)
spell:mana(230)
spell:isPremium(true)
spell:cooldown(1000) -- Cooldown is calculated on the casting
spell:groupCooldown(2 * 1000)
spell:isSelfTarget(true)
spell:cooldown(22 * 1000)
spell:groupCooldown(2 * 1000, 22 * 1000)
spell:needLearn(true)
spell:vocation("druid;true", "elder druid;true")
spell:register()
14 changes: 1 addition & 13 deletions data/scripts/spells/support/divine_empowerment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ function spell.onCastSpell(creature, var)
return false
end

local cooldown = 0
if grade >= 3 then
cooldown = 24
elseif grade >= 2 then
cooldown = 28
elseif grade >= 1 then
cooldown = 32
end
local condition = Condition(CONDITION_SPELLCOOLDOWN, CONDITIONID_DEFAULT, 268)
condition:setTicks((cooldown * 1000) / configManager.getFloat(configKeys.RATE_SPELL_COOLDOWN))
creature:addCondition(condition)

local position = creature:getPosition()
for x = -1, 1 do
for y = -1, 1 do
Expand All @@ -63,7 +51,7 @@ spell:isPremium(true)
spell:range(7)
spell:isSelfTarget(true)
spell:isAggressive(false)
spell:cooldown(1000) -- Cooldown is calculated on the casting
spell:cooldown(32 * 1000)
spell:groupCooldown(2 * 1000)
spell:needLearn(true)
spell:vocation("paladin;true", "royal paladin;true")
Expand Down
5 changes: 0 additions & 5 deletions src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,11 +1281,6 @@ void Combat::CombatFunc(const std::shared_ptr<Creature> &caster, const Position
combatTileEffects(spectators.data(), caster, tile, params);
}

// Wheel of destiny update beam mastery damage
if (casterPlayer) {
casterPlayer->wheel()->updateBeamMasteryDamage(tmpDamage, beamAffectedTotal, beamAffectedCurrent);
}

postCombatEffects(caster, origin, pos, params);
}

Expand Down
5 changes: 5 additions & 0 deletions src/creatures/combat/spells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@ void Spell::applyCooldownConditions(const std::shared_ptr<Player> &player) const
g_logger().debug("[{}] spell name: {}, spellCooldown: {}, bonus: {}, augment {}", __FUNCTION__, name, spellCooldown, player->wheel()->getSpellBonus(name, WheelSpellBoost_t::COOLDOWN), augmentCooldownReduction);
spellCooldown -= player->wheel()->getSpellBonus(name, WheelSpellBoost_t::COOLDOWN);
spellCooldown -= augmentCooldownReduction;
const int32_t halfBaseCooldown = cooldown / 2;
spellCooldown = halfBaseCooldown > spellCooldown ? halfBaseCooldown : spellCooldown; // The cooldown should never be reduced less than half (50%) of its base cooldown
if (spellCooldown > 0) {
player->wheel()->handleTwinBurstsCooldown(player, name, spellCooldown, rateCooldown);
const auto &condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_SPELLCOOLDOWN, spellCooldown / rateCooldown, 0, false, m_spellId);
player->addCondition(condition);
}
Expand All @@ -771,7 +774,9 @@ void Spell::applyCooldownConditions(const std::shared_ptr<Player> &player) const
if (isUpgraded) {
spellSecondaryGroupCooldown -= getWheelOfDestinyBoost(WheelSpellBoost_t::SECONDARY_GROUP_COOLDOWN, spellGrade);
}
spellSecondaryGroupCooldown -= player->wheel()->getSpellBonus(name, WheelSpellBoost_t::SECONDARY_GROUP_COOLDOWN);
if (spellSecondaryGroupCooldown > 0) {
player->wheel()->handleBeamMasteryCooldown(player, name, spellSecondaryGroupCooldown, rateCooldown);
const auto &condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_SPELLGROUPCOOLDOWN, spellSecondaryGroupCooldown / rateCooldown, 0, false, secondaryGroup);
player->addCondition(condition);
}
Expand Down
2 changes: 2 additions & 0 deletions src/creatures/creatures_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ enum SpellGroup_t : uint8_t {
SPELLGROUP_CRIPPLING = 6,
SPELLGROUP_FOCUS = 7,
SPELLGROUP_ULTIMATESTRIKES = 8,
SPELLGROUP_BURSTS_OF_NATURE = 9,
SPELLGROUP_GREAT_BEAMS = 10,
};

enum ChannelEvent_t : uint8_t {
Expand Down
8 changes: 4 additions & 4 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6339,7 +6339,7 @@ uint32_t Player::getMagicLevel() const {
uint32_t magic = std::max<int32_t>(0, getLoyaltyMagicLevel() + varStats[STAT_MAGICPOINTS]);
// Wheel of destiny magic bonus
magic += m_wheelPlayer->getStat(WheelStat_t::MAGIC); // Regular bonus
magic += m_wheelPlayer->getMajorStatConditional("Positional Tatics", WheelMajor_t::MAGIC); // Revelation bonus
magic += m_wheelPlayer->getMajorStatConditional("Positional Tactics", WheelMajor_t::MAGIC); // Revelation bonus
return magic;
}

Expand Down Expand Up @@ -6397,12 +6397,12 @@ uint16_t Player::getSkillLevel(skills_t skill) const {
skillLevel += m_wheelPlayer->getStat(WheelStat_t::MELEE);
skillLevel += m_wheelPlayer->getMajorStatConditional("Battle Instinct", WheelMajor_t::MELEE);
} else if (skill == SKILL_DISTANCE) {
skillLevel += m_wheelPlayer->getMajorStatConditional("Positional Tatics", WheelMajor_t::DISTANCE);
skillLevel += m_wheelPlayer->getMajorStatConditional("Positional Tactics", WheelMajor_t::DISTANCE);
skillLevel += m_wheelPlayer->getStat(WheelStat_t::DISTANCE);
} else if (skill == SKILL_SHIELD) {
skillLevel += m_wheelPlayer->getMajorStatConditional("Battle Instinct", WheelMajor_t::SHIELD);
} else if (skill == SKILL_MAGLEVEL) {
skillLevel += m_wheelPlayer->getMajorStatConditional("Positional Tatics", WheelMajor_t::MAGIC);
skillLevel += m_wheelPlayer->getMajorStatConditional("Positional Tactics", WheelMajor_t::MAGIC);
skillLevel += m_wheelPlayer->getStat(WheelStat_t::MAGIC);
} else if (skill == SKILL_LIFE_LEECH_AMOUNT) {
skillLevel += m_wheelPlayer->getStat(WheelStat_t::LIFE_LEECH);
Expand Down Expand Up @@ -6504,7 +6504,7 @@ void Player::setPerfectShotDamage(uint8_t range, int32_t damage) {
}

int32_t Player::getSpecializedMagicLevel(CombatType_t combat, bool useCharges) const {
int32_t result = specializedMagicLevel[combatTypeToIndex(combat)];
int32_t result = specializedMagicLevel[combatTypeToIndex(combat)] + m_wheelPlayer->getSpecializedMagic(combat);
for (const auto &item : getEquippedItems()) {
const ItemType &itemType = Item::items[item->getID()];
if (!itemType.abilities) {
Expand Down
Loading
Loading