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

refactor: imbuements system #2494

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions data/XML/imbuements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<category id="15" name="Skillboost (Distance Fighting)" agressive="1" />
<category id="16" name="Skillboost (Magic Level)" agressive="1" />
<category id="17" name="Increase Capacity" agressive="0" />
<category id="18" name="Paralysis Deflection" agressive="0" />

<!-- Damage Imbuement -->
<imbuement name="Scorch" base="1" subgroup=" (Fire)" category="0" iconid="13" premium="0" storage="0" sound="2002">
Expand Down Expand Up @@ -427,4 +428,22 @@
<attribute key="item" value="25702" count="10" />
<attribute key="item" value="20205" count="5" />
</imbuement>
<imbuement name="Vibrancy" base="1" category="18" iconid="79" premium="0" storage="0">
<attribute key="description" value="deflects PvP paralysis, removes paralysis with a chance of 15%." />
<attribute key="effect" type="vibrancy" chance="15" />
<attribute key="item" value="22053" count="20" />
</imbuement>
<imbuement name="Vibrancy" base="2" category="18" iconid="80" premium="1" storage="0">
<attribute key="description" value="deflects PvP paralysis, removes paralysis with a chance of 25%." />
<attribute key="effect" type="vibrancy" chance="25" />
<attribute key="item" value="22053" count="20" />
<attribute key="item" value="23507" count="15" />
</imbuement>
<imbuement name="Vibrancy" base="3" category="18" iconid="81" premium="1" storage="46317">
<attribute key="description" value="deflects PvP paralysis, removes paralysis with a chance of 50%." />
<attribute key="effect" type="vibrancy" chance="50" />
<attribute key="item" value="22053" count="20" />
<attribute key="item" value="23507" count="15" />
<attribute key="item" value="28567" count="5" />
</imbuement>
</imbuements>
2 changes: 1 addition & 1 deletion data/items/items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8566,7 +8566,7 @@
<attribute key="life leech" value="3"/>
<attribute key="mana leech" value="3"/>
<attribute key="critical hit" value="3"/>
<attribute key="skillboost sword" value="3"/>
<attribute key="vibrancy" value="3"/>
</attribute>
<attribute key="script" value="moveevent;weapon">
<attribute key="level" value="80"/>
Expand Down
6 changes: 3 additions & 3 deletions data/scripts/runes/paralyze_rune.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_UNDEFINEDDAMAGE)

local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, 6000)
condition:setParameter(CONDITION_PARAM_TICKS, 60000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo this.

condition:setFormula(-1, 0, -1, 0)
combat:addCondition(condition)

Expand All @@ -29,8 +29,8 @@ rune:charges(1)
rune:setPzLocked(true)
rune:level(54)
rune:magicLevel(18)
rune:cooldown(6 * 1000)
rune:groupCooldown(2 * 1000)
rune:cooldown(1 * 1000)
rune:groupCooldown(1 * 1000)
Comment on lines +32 to +33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo these lines.

rune:mana(1400)
rune:needTarget(true)
rune:isBlocking(true) -- True = Solid / False = Creature
Expand Down
59 changes: 50 additions & 9 deletions src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,23 +753,64 @@ void Combat::CombatConditionFunc(std::shared_ptr<Creature> caster, std::shared_p
if (condition->getType() == CONDITION_FEARED && !checkFearConditionAffected(player)) {
return;
}
}

if (caster == target || target && !target->isImmune(condition->getType())) {
auto conditionCopy = condition->clone();
if (caster) {
conditionCopy->setParam(CONDITION_PARAM_OWNER, caster->getID());
conditionCopy->setPositionParam(CONDITION_PARAM_CASTER_POSITION, caster->getPosition());
if (condition->getType() == CONDITION_PARALYZE && target) {
if (player) {
if (reflectParalyzeCondition(caster, player, condition)) {
return;
}
}
}

// TODO: infight condition until all aggressive conditions has ended
if (target) {
target->addCombatCondition(conditionCopy, caster && caster->getPlayer() != nullptr);
if (caster == target || (target && !target->isImmune(condition->getType()))) {
auto conditionCopy = condition->clone();
if (caster) {
conditionCopy->setParam(CONDITION_PARAM_OWNER, caster->getID());
conditionCopy->setPositionParam(CONDITION_PARAM_CASTER_POSITION, caster->getPosition());
}

// TODO: infight condition until all aggressive conditions has ended
if (target) {
target->addCombatCondition(conditionCopy, caster && caster->getPlayer() != nullptr);
}
}
}
}
}

bool Combat::reflectParalyzeCondition(const std::shared_ptr<Creature> &caster, const std::shared_ptr<Player> &target, const std::shared_ptr<Condition> &condition) {
if (!target->hasCondition(CONDITION_PARALYZE)) {
target->addCondition(condition->clone());
return true;
}

int32_t reflectionChance = 0;
for (int32_t slot = CONST_SLOT_FIRST; slot <= CONST_SLOT_LAST; ++slot) {
auto item = target->getInventoryItem(static_cast<Slots_t>(slot));
if (item) {
for (uint8_t slotid = 0; slotid < item->getImbuementSlot(); ++slotid) {
ImbuementInfo imbuementInfo;
if (item->getImbuementInfo(slotid, &imbuementInfo)) {
reflectionChance = std::max(reflectionChance, imbuementInfo.imbuement->paralyzeReduction);
}
}
}
}

if (caster && !caster->isImmune(CONDITION_PARALYZE)) {
caster->addCondition(condition->clone());
}

if (uniform_random(1, 100) <= reflectionChance) {
if (target->hasCondition(CONDITION_PARALYZE)) {
target->removeCondition(CONDITION_PARALYZE);
}
return true;
}

return false;
}

void Combat::CombatDispelFunc(std::shared_ptr<Creature>, std::shared_ptr<Creature> target, const CombatParams &params, CombatDamage*) {
if (target) {
target->removeCombatCondition(params.dispelType);
Expand Down
2 changes: 2 additions & 0 deletions src/creatures/combat/combat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ class Combat {

static void combatTileEffects(const CreatureVector &spectators, std::shared_ptr<Creature> caster, std::shared_ptr<Tile> tile, const CombatParams &params);

static bool reflectParalyzeCondition(const std::shared_ptr<Creature> &caster, const std::shared_ptr<Player> &target, const std::shared_ptr<Condition> &condition);

/**
* @brief Calculate the level formula for combat.
*
Expand Down
Loading
Loading