Skip to content

Commit

Permalink
fix: conditions and spells
Browse files Browse the repository at this point in the history
  • Loading branch information
phacUFPE committed Dec 3, 2024
1 parent 3647df2 commit b67867b
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 22 deletions.
1 change: 1 addition & 0 deletions data-otservbr-global/lib/others/soulpit.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SoulPit = {
encounter = nil,
kickEvent = nil,
soulCores = Game.getSoulCoreItems(),
requiredLevel = 8,
playerPositions = {
Expand Down
35 changes: 19 additions & 16 deletions data-otservbr-global/scripts/actions/soulpit/soulpit_fight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ function zoneEvent.afterLeave(zone, creature)
SoulPit.encounter:reset()
SoulPit.encounter = nil
end
if SoulPit.kickEvent then
stopEvent(SoulPit.kickEvent)
end
end

for abilityName, abilityInfo in pairs(SoulPit.bossAbilities) do
Expand Down Expand Up @@ -79,6 +82,22 @@ function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isH
zone = SoulPit.zone,
})

function encounter:onReset(position)
SoulPit.zone:removeMonsters()

for _, player in pairs(SoulPit.zone:getPlayers()) do
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have defeated the core of the %s soul and unlocked its animus mastery!", monsterName))
-- Add the monster animus mastery for the player.
end

SoulPit.kickEvent = addEvent(function()
SoulPit.encounter = nil
for _, player in pairs(SoulPit.zone:getPlayers()) do
player:teleportTo(SoulPit.exit)
end
end, SoulPit.timeToKick)
end

SoulPit.encounter = encounter

local function waveStart()
Expand Down Expand Up @@ -123,22 +142,6 @@ function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isH
:autoAdvance({ delay = SoulPit.checkMonstersDelay, monstersKilled = true })
end

function encounter:onReset(position)
SoulPit.zone:removeMonsters()

for _, player in pairs(SoulPit.zone:getPlayers()) do
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have defeated the core of the %s soul and unlocked its animus mastery!", monsterName))
-- Add the monster animus mastery for the player.
end

addEvent(function()
SoulPit.encounter = nil
for _, player in pairs(SoulPit.zone:getPlayers()) do
player:teleportTo(SoulPit.exit)
end
end, SoulPit.timeToKick)
end

encounter:start()
encounter:register()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local combatFear = Combat()
combatFear:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLUE_GHOST)

local area = createCombatArea(AREA_FEAR_OPRESSOR)
combatRoot:setArea(area)
combatFear:setArea(area)

local condition = Condition(CONDITION_FEARED)
condition:setParameter(CONDITION_PARAM_TICKS, 3000)
Expand Down
4 changes: 4 additions & 0 deletions src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@ void Combat::CombatHealthFunc(const std::shared_ptr<Creature> &caster, const std
}
}

if (targetPlayer && damage.primary.type == COMBAT_HEALING) {
damage.primary.value *= targetPlayer->getBuff(BUFF_HEALINGRECEIVED) / 100.;
}

damage.damageMultiplier += attackerPlayer->wheel()->getMajorStatConditional("Divine Empowerment", WheelMajor_t::DAMAGE);
g_logger().trace("Wheel Divine Empowerment damage multiplier {}", damage.damageMultiplier);
}
Expand Down
28 changes: 25 additions & 3 deletions src/creatures/combat/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ bool Condition::executeCondition(const std::shared_ptr<Creature> &creature, int3
}

std::shared_ptr<Condition> Condition::createCondition(ConditionId_t id, ConditionType_t type, int32_t ticks, int32_t param /* = 0*/, bool buff /* = false*/, uint32_t subId /* = 0*/, bool isPersistent /* = false*/) {

std::shared_ptr<ConditionAttributes> conditionAttributes = nullptr;
switch (type) {
case CONDITION_POISON:
case CONDITION_FIRE:
Expand Down Expand Up @@ -251,6 +253,24 @@ std::shared_ptr<Condition> Condition::createCondition(ConditionId_t id, Conditio
case CONDITION_FEARED:
return std::make_shared<ConditionFeared>(id, type, ticks, buff, subId);

case CONDITION_LESSERHEX:
conditionAttributes = std::make_shared<ConditionAttributes>(id, type, ticks, buff, subId);
conditionAttributes->setParam(CONDITION_PARAM_BUFF_HEALINGRECEIVED, 50);
return conditionAttributes;

case CONDITION_INTENSEHEX:
conditionAttributes = std::make_shared<ConditionAttributes>(id, type, ticks, buff, subId);
conditionAttributes->setParam(CONDITION_PARAM_BUFF_HEALINGRECEIVED, 50);
conditionAttributes->setParam(CONDITION_PARAM_BUFF_DAMAGEDEALT, 50);
return conditionAttributes;

case CONDITION_GREATERHEX:
conditionAttributes = std::make_shared<ConditionAttributes>(id, type, ticks, buff, subId);
conditionAttributes->setParam(CONDITION_PARAM_BUFF_HEALINGRECEIVED, 50);
conditionAttributes->setParam(CONDITION_PARAM_BUFF_DAMAGEDEALT, 50);
conditionAttributes->setParam(CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, 60);
return conditionAttributes;

case CONDITION_ROOTED:
case CONDITION_INFIGHT:
case CONDITION_DRUNK:
Expand All @@ -261,9 +281,6 @@ std::shared_ptr<Condition> Condition::createCondition(ConditionId_t id, Conditio
case CONDITION_CHANNELMUTEDTICKS:
case CONDITION_YELLTICKS:
case CONDITION_POWERLESS:
case CONDITION_LESSERHEX:
case CONDITION_INTENSEHEX:
case CONDITION_GREATERHEX:
case CONDITION_PACIFIED:
return std::make_shared<ConditionGeneric>(id, type, ticks, buff, subId);
case CONDITION_BAKRAGORE:
Expand Down Expand Up @@ -1022,6 +1039,11 @@ bool ConditionAttributes::setParam(ConditionParam_t param, int32_t value) {
return true;
}

case CONDITION_PARAM_BUFF_HEALINGRECEIVED: {
buffsPercent[BUFF_HEALINGRECEIVED] = std::max<int32_t>(0, value);
return true;
}

case CONDITION_PARAM_BUFF_DAMAGEDEALT: {
buffsPercent[BUFF_DAMAGEDEALT] = std::max<int32_t>(0, value);
return true;
Expand Down
10 changes: 9 additions & 1 deletion src/creatures/combat/spells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,11 +1053,15 @@ void Spell::setLockedPZ(bool b) {

InstantSpell::InstantSpell() = default;

bool InstantSpell::playerCastInstant(const std::shared_ptr<Player> &player, std::string &param) const {
bool InstantSpell::playerCastInstant(const std::shared_ptr<Player> &player, std::string &param) {
if (!playerSpellCheck(player)) {
return false;
}

if (player->hasCondition(CONDITION_POWERLESS) && getGroup() == SPELLGROUP_ATTACK) {
return false;
}

LuaVariant var;
var.instantName = getName();
std::shared_ptr<Player> playerTarget = nullptr;
Expand Down Expand Up @@ -1379,6 +1383,10 @@ bool RuneSpell::executeUse(const std::shared_ptr<Player> &player, const std::sha
return false;
}

if (player->hasCondition(CONDITION_POWERLESS) && getGroup() == SPELLGROUP_ATTACK) {
return false;
}

LuaVariant var;
var.runeName = getName();

Expand Down
2 changes: 1 addition & 1 deletion src/creatures/combat/spells.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class Spell : public BaseSpell {
class InstantSpell final : public Spell {
public:
InstantSpell();
bool playerCastInstant(const std::shared_ptr<Player> &player, std::string &param) const;
bool playerCastInstant(const std::shared_ptr<Player> &player, std::string &param);

bool castSpell(const std::shared_ptr<Creature> &creature) override;
bool castSpell(const std::shared_ptr<Creature> &creature, const std::shared_ptr<Creature> &target) override;
Expand Down
1 change: 1 addition & 0 deletions src/creatures/creatures_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ enum ConditionParam_t {
CONDITION_PARAM_INCREASE_MANADRAINPERCENT = 80,
CONDITION_PARAM_INCREASE_DROWNPERCENT = 81,
CONDITION_PARAM_CHARM_CHANCE_MODIFIER = 82,
CONDITION_PARAM_BUFF_HEALINGRECEIVED = 83,
};

enum stats_t {
Expand Down

0 comments on commit b67867b

Please sign in to comment.