Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
beats-dh committed Mar 27, 2024
1 parent 255bb5d commit a22f39a
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 20 deletions.
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="0" 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="0" storage="0">
<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)
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)
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 @@ -749,23 +749,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 (uniform_random(1, 100) <= reflectionChance) {
if (caster && !caster->isImmune(CONDITION_PARALYZE)) {
caster->addCondition(condition->clone());
}

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
13 changes: 10 additions & 3 deletions src/creatures/players/imbuements/imbuements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ bool Imbuements::processImbuementNode(const pugi::xml_node &imbuementNode) {
return false;
}

uint16_t category = pugi::cast<uint16_t>(categorybase.value());
auto category = pugi::cast<uint16_t>(categorybase.value());
auto category_p = getCategoryByID(category);
if (category_p == nullptr) {
g_logger().warn("Category imbuement {} not exist", category);
Expand Down Expand Up @@ -184,7 +184,7 @@ bool Imbuements::processImbuementChildNodes(const pugi::xml_node &imbuementNode,
g_logger().warn("Missing item ID for imbuement name '{}'", imbuement->name);
return false;
}
uint16_t sourceId = pugi::cast<uint16_t>(attr.value());
auto sourceId = pugi::cast<uint16_t>(attr.value());

uint16_t count = 1;
if ((attr = childNode.attribute("count"))) {
Expand Down Expand Up @@ -237,7 +237,7 @@ bool Imbuements::processImbuementChildNodes(const pugi::xml_node &imbuementNode,
g_logger().warn("Missing skill bonus for imbuement name {}", imbuement->name);
return false;
}
int32_t bonus = pugi::cast<int32_t>(attr.value());
auto bonus = pugi::cast<int32_t>(attr.value());

if (skillId == UseSkillMode::NormalSkill) {
imbuement->skills[skillId] = bonus;
Expand Down Expand Up @@ -306,6 +306,13 @@ bool Imbuements::processImbuementChildNodes(const pugi::xml_node &imbuementNode,
}

imbuement->capacity = pugi::cast<uint32_t>(attr.value());
} else if (strcasecmp(effecttype.c_str(), "vibrancy") == 0) {
if (!(attr = childNode.attribute("chance"))) {
g_logger().warn("Missing chance value for imbuement name {}", imbuement->name);
return false;
}

imbuement->paralyzeReduction = pugi::cast<int32_t>(attr.value());
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/creatures/players/imbuements/imbuements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class Imbuement {
int32_t stats[STAT_LAST + 1] = {};
int32_t skills[SKILL_LAST + 1] = {};
int32_t speed = 0;
int32_t paralyzeReduction = 0;
uint32_t capacity = 0;
int16_t absorbPercent[COMBAT_COUNT] = {};
int16_t elementDamage = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/items/functions/item/item_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ void ItemParse::parseImbuement(const std::string &tmpStrValue, pugi::xml_node at
continue;
}
} else {
g_logger().warn("[ParseImbuement::initParseImbuement] - Unknown type: {}", valueAttribute.as_string());
g_logger().warn("[ParseImbuement::initParseImbuement] - Unknown type: {}, item: {}", valueAttribute.as_string(), itemType.id);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/items/functions/item/item_parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ const phmap::flat_hash_map<std::string, ImbuementTypes_t> ImbuementsTypeMap = {
{ "skillboost shielding", IMBUEMENT_SKILLBOOST_SHIELDING },
{ "skillboost distance", IMBUEMENT_SKILLBOOST_DISTANCE },
{ "skillboost magic level", IMBUEMENT_SKILLBOOST_MAGIC_LEVEL },
{ "increase capacity", IMBUEMENT_INCREASE_CAPACITY }
{ "increase capacity", IMBUEMENT_INCREASE_CAPACITY },
{ "vibrancy", IMBUEMENT_VIBRANCY_PARALYZE }
};

class ItemParse : public Items {
Expand Down
3 changes: 2 additions & 1 deletion src/items/items_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ enum ImbuementTypes_t : int64_t {
IMBUEMENT_SKILLBOOST_SHIELDING = 14,
IMBUEMENT_SKILLBOOST_DISTANCE = 15,
IMBUEMENT_SKILLBOOST_MAGIC_LEVEL = 16,
IMBUEMENT_INCREASE_CAPACITY = 17
IMBUEMENT_INCREASE_CAPACITY = 17,
IMBUEMENT_VIBRANCY_PARALYZE = 18
};

enum class ContainerCategory_t : uint8_t {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,8 @@ const ImbuementTypeNames imbuementTypeNames = {
{ "skillboost shielding", IMBUEMENT_SKILLBOOST_SHIELDING },
{ "skillboost distance", IMBUEMENT_SKILLBOOST_DISTANCE },
{ "skillboost magic level", IMBUEMENT_SKILLBOOST_MAGIC_LEVEL },
{ "increase capacity", IMBUEMENT_INCREASE_CAPACITY }
{ "increase capacity", IMBUEMENT_INCREASE_CAPACITY },
{ "vibrancy", IMBUEMENT_VIBRANCY_PARALYZE }
};

/**
Expand Down

0 comments on commit a22f39a

Please sign in to comment.