Skip to content

Commit

Permalink
Effects System: control breath effects. Closes #1678, Closes #1676
Browse files Browse the repository at this point in the history
  • Loading branch information
alek13 committed Nov 26, 2024
1 parent e135694 commit 9062cd6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
10 changes: 6 additions & 4 deletions mods/lord/Game/lord_damage/src/lord_damage/config.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
damage.Type.FLESHY = 'fleshy'
damage.Type.FIRE = 'fire'
damage.Type.SOUL = 'soul'
damage.Type.POISON = 'poison'
damage.Type.FLESHY = 'fleshy'
damage.Type.FIRE = 'fire'
damage.Type.SOUL = 'soul'
damage.Type.POISON = 'poison'
damage.Type.SUFFOCATION = 'suffocation'


return {
Expand All @@ -10,6 +11,7 @@ return {
damage.Type.FIRE,
damage.Type.SOUL,
damage.Type.POISON,
damage.Type.SUFFOCATION,
},
particles = {
[damage.Type.FLESHY] = { amount = 10, time = 0.2 },
Expand Down
25 changes: 24 additions & 1 deletion mods/lord/Game/lord_effects/src/lord_effects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ lord_effects = {
SPEED = 'speed',
JUMP = 'jump',
HEALTH = 'health',
-- BREATH = 'breath', TODO: #1678
BREATH = 'breath',
SUFFOCATION = 'suffocation',
}


Expand Down Expand Up @@ -36,6 +37,28 @@ local function register_effects()
-- Periodical Damage stops itself.
end)
)
effects.register(
effects.Effect:new(lord_effects.BREATH)
:on_start(function(self, player, amount, duration)
player:set_breath(player.breath_max or core.PLAYER_MAX_BREATH_DEFAULT)
player:set_flags({ drowning = false, })
end)
:on_stop(function(self, player)
player:set_flags({ drowning = true, })
end)
)
effects.register(
effects.Effect:new(lord_effects.SUFFOCATION)
:on_start(function(self, player, amount, duration)
player:set_breath(0)
player:set_flags({ breathing = false, })
damage.Periodical:for_player(player):start(damage.Type.SUFFOCATION, amount, duration)
end)
:on_stop(function(self, player)
player:set_flags({ breathing = true, })
-- Periodical Damage stops itself.
end)
)
end


Expand Down
9 changes: 5 additions & 4 deletions mods/lord/Player/lord_defense/src/lord_defense.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ local armor_slots_count = equipment.Kind.get_size(equipment.Kind.ARMOR)
--- @param player Player
local function collect_defense_from_armor_equipment(player)
local defense = {
fleshy = 0,
fire = 0,
soul = 0,
poison = 0,
fleshy = 0,
fire = 0,
soul = 0,
poison = 0,
suffocation = 0,
}
local damage_avoid = 0

Expand Down

0 comments on commit 9062cd6

Please sign in to comment.