Skip to content

Commit

Permalink
fix: add condition for taint icon
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Apr 15, 2024
1 parent 8319f29 commit 24fd8a5
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 49 deletions.
28 changes: 20 additions & 8 deletions data-otservbr-global/scripts/lib/quests/soul-war.lua
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,14 @@ local soulWarTaints = {
"taints-loss", -- Taint 5
}

local taintsToConditions = {
["taints-teleport"] = CONDITION_GOSHNARTAINT_1,
["taints-spawn"] = CONDITION_GOSHNARTAINT_2,
["taints-damage"] = CONDITION_GOSHNARTAINT_3,
["taints-heal"] = CONDITION_GOSHNARTAINT_4,
["taints-loss"] = CONDITION_GOSHNARTAINT_5,
}

GreedMonsters = {
["Greedbeast"] = Position(33744, 31666, 14),
["Soulsnatcher"] = Position(33747, 31668, 14),
Expand Down Expand Up @@ -983,10 +991,13 @@ end

function Player:addNextTaint()
local soulWarQuest = self:soulWarQuestKV()
for _, taint in ipairs(soulWarTaints) do
if not soulWarQuest:get(taint) then
soulWarQuest:set(taint, true)
self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have gained the " .. taint .. ".")
for taintName, condition in pairs(taintsToConditions) do
if not soulWarQuest:get(taintName) then
soulWarQuest:set(taintName, true)
self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have gained the " .. taintName .. ".")
local condition = Condition(condition)
condition:setTicks(14 * 24 * 60 * 60 * 1000)
self:addCondition(condition)
break
end
end
Expand All @@ -1008,10 +1019,11 @@ function Player:resetTaints()
local soulWarQuest = self:soulWarQuestKV()
local firstTaintTime = soulWarQuest:get("firstTaintTime")
if firstTaintTime and os.time() >= (firstTaintTime + TaintDurationSeconds) then
-- Reset all taints
for _, taint in ipairs(soulWarTaints) do
if soulWarQuest:get(taint) then
soulWarQuest:remove(taint)
-- Reset all taints and remove conditions
for taintName, condition in pairs(taintsToConditions) do
if soulWarQuest:get(taintName) then
soulWarQuest:remove(taintName)
self:removeCondition(condition)
end
end

Expand Down
23 changes: 23 additions & 0 deletions data/scripts/talkactions/god/add_condition.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
local taintsConditions = {
CONDITION_GOSHNARTAINT_1,
CONDITION_GOSHNARTAINT_2,
CONDITION_GOSHNARTAINT_3,
CONDITION_GOSHNARTAINT_4,
CONDITION_GOSHNARTAINT_5,
}

local talkaction = TalkAction("/testtaintconditions")

function talkaction.onSay(player, words, param)
local soulWarQuest = player:soulWarQuestKV()

Check warning on line 12 in data/scripts/talkactions/god/add_condition.lua

View workflow job for this annotation

GitHub Actions / luacheck

[luacheck] data/scripts/talkactions/god/add_condition.lua#L12

unused variable 'soulWarQuest'
Raw output
data/scripts/talkactions/god/add_condition.lua:12:8: unused variable 'soulWarQuest'
for _, condition in pairs(taintsConditions) do
local condition = Condition(condition)

Check warning on line 14 in data/scripts/talkactions/god/add_condition.lua

View workflow job for this annotation

GitHub Actions / luacheck

[luacheck] data/scripts/talkactions/god/add_condition.lua#L14

variable 'condition' was previously defined as a loop variable on line 13
Raw output
data/scripts/talkactions/god/add_condition.lua:14:9: variable 'condition' was previously defined as a loop variable on line 13
condition:setTicks(14 * 24 * 60 * 60 * 1000)
player:addCondition(condition)
end
return false
end

talkaction:separator(" ")
talkaction:groupType("god")
talkaction:register()
30 changes: 30 additions & 0 deletions src/creatures/combat/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ std::shared_ptr<Condition> Condition::createCondition(ConditionId_t id, Conditio
case CONDITION_YELLTICKS:
case CONDITION_PACIFIED:
return std::make_shared<ConditionGeneric>(id, type, ticks, buff, subId);
case CONDITION_GOSHNARTAINT_1:
return std::make_shared<ConditionGeneric>(id, type, ticks, buff, subId);
case CONDITION_GOSHNARTAINT_2:
return std::make_shared<ConditionGeneric>(id, type, ticks, buff, subId);
case CONDITION_GOSHNARTAINT_3:
return std::make_shared<ConditionGeneric>(id, type, ticks, buff, subId);
case CONDITION_GOSHNARTAINT_4:
return std::make_shared<ConditionGeneric>(id, type, ticks, buff, subId);
case CONDITION_GOSHNARTAINT_5:
return std::make_shared<ConditionGeneric>(id, type, ticks, buff, subId);

default:
return nullptr;
Expand Down Expand Up @@ -391,6 +401,26 @@ uint32_t ConditionGeneric::getIcons() const {
icons |= ICON_ROOTED;
break;

case CONDITION_GOSHNARTAINT_1:
icons |= ICON_GOSHNARTAINT_1;
break;

case CONDITION_GOSHNARTAINT_2:
icons |= ICON_GOSHNARTAINT_2;
break;

case CONDITION_GOSHNARTAINT_3:
icons |= ICON_GOSHNARTAINT_3;
break;

case CONDITION_GOSHNARTAINT_4:
icons |= ICON_GOSHNARTAINT_4;
break;

case CONDITION_GOSHNARTAINT_5:
icons |= ICON_GOSHNARTAINT_5;
break;

default:
break;
}
Expand Down
10 changes: 5 additions & 5 deletions src/creatures/creatures_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ enum ConditionType_t : uint8_t {
CONDITION_LESSERHEX = 31,
CONDITION_INTENSEHEX = 32,
CONDITION_GREATERHEX = 33,
CONDITION_GOSHNAR1 = 34,
CONDITION_GOSHNAR2 = 35,
CONDITION_GOSHNAR3 = 36,
CONDITION_GOSHNAR4 = 37,
CONDITION_GOSHNAR5 = 38,
CONDITION_GOSHNARTAINT_1 = 34,
CONDITION_GOSHNARTAINT_2 = 35,
CONDITION_GOSHNARTAINT_3 = 36,
CONDITION_GOSHNARTAINT_4 = 37,
CONDITION_GOSHNARTAINT_5 = 38,

// Need the last ever
CONDITION_COUNT = 39
Expand Down
34 changes: 3 additions & 31 deletions src/lua/functions/core/game/lua_enums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,37 +316,9 @@ void LuaEnums::initFactionEnums(lua_State* L) {
}

void LuaEnums::initConditionEnums(lua_State* L) {
registerEnum(L, CONDITION_NONE);
registerEnum(L, CONDITION_POISON);
registerEnum(L, CONDITION_FIRE);
registerEnum(L, CONDITION_ENERGY);
registerEnum(L, CONDITION_BLEEDING);
registerEnum(L, CONDITION_HASTE);
registerEnum(L, CONDITION_PARALYZE);
registerEnum(L, CONDITION_OUTFIT);
registerEnum(L, CONDITION_INVISIBLE);
registerEnum(L, CONDITION_LIGHT);
registerEnum(L, CONDITION_MANASHIELD);
registerEnum(L, CONDITION_INFIGHT);
registerEnum(L, CONDITION_DRUNK);
registerEnum(L, CONDITION_EXHAUST);
registerEnum(L, CONDITION_REGENERATION);
registerEnum(L, CONDITION_SOUL);
registerEnum(L, CONDITION_DROWN);
registerEnum(L, CONDITION_MUTED);
registerEnum(L, CONDITION_CHANNELMUTEDTICKS);
registerEnum(L, CONDITION_YELLTICKS);
registerEnum(L, CONDITION_ATTRIBUTES);
registerEnum(L, CONDITION_FREEZING);
registerEnum(L, CONDITION_DAZZLED);
registerEnum(L, CONDITION_CURSED);
registerEnum(L, CONDITION_EXHAUST_COMBAT);
registerEnum(L, CONDITION_EXHAUST_HEAL);
registerEnum(L, CONDITION_PACIFIED);
registerEnum(L, CONDITION_SPELLCOOLDOWN);
registerEnum(L, CONDITION_SPELLGROUPCOOLDOWN);
registerEnum(L, CONDITION_ROOTED);
registerEnum(L, CONDITION_FEARED);
for (auto value : magic_enum::enum_values<ConditionType_t>()) {
registerMagicEnum(L, value);
}
}

void LuaEnums::initConditionIdEnums(lua_State* L) {
Expand Down
10 changes: 5 additions & 5 deletions src/utils/utils_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ enum Icons_t {
ICON_GREATERHEX = 1 << 18,
ICON_ROOTED = 1 << 19,
ICON_FEARED = 1 << 20,
ICON_GOSHNAR1 = 1 << 21,
ICON_GOSHNAR2 = 1 << 22,
ICON_GOSHNAR3 = 1 << 23,
ICON_GOSHNAR4 = 1 << 24,
ICON_GOSHNAR5 = 1 << 25,
ICON_GOSHNARTAINT_1 = 1 << 21,
ICON_GOSHNARTAINT_2 = 1 << 22,
ICON_GOSHNARTAINT_3 = 1 << 23,
ICON_GOSHNARTAINT_4 = 1 << 24,
ICON_GOSHNARTAINT_5 = 1 << 25,
ICON_NEWMANASHIELD = 1 << 26,
};

Expand Down

0 comments on commit 24fd8a5

Please sign in to comment.