-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Effects System:
lord_effect
: add mod backbone & register our effect…
…s for `speed`,`jump`,`health`. Relates to #1676
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
minetest.mod(function(mod) | ||
require("lord_effects").init(mod) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name = lord_effects | ||
depends = builtin, effects, physics, damage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
|
||
_G.lord_effects = { | ||
SPEED = 'speed', | ||
JUMP = 'jump', | ||
HEALTH = 'health', | ||
-- BREATH = 'breath', TODO: #1678 | ||
} | ||
|
||
|
||
local function register_effects() | ||
effects.register( | ||
effects.Effect:new(lord_effects.SPEED) | ||
:on_start(function(self, player, amount) | ||
physics.for_player(player):set({ speed = amount }) | ||
end) | ||
:on_stop(function(self, player) | ||
physics.for_player(player):set({ speed = 1 }) | ||
end) | ||
) | ||
effects.register( | ||
effects.Effect:new(lord_effects.JUMP) | ||
:on_start(function(self, player, amount) | ||
physics.for_player(player):set({ jump = amount }) | ||
end) | ||
:on_stop(function(self, player) | ||
physics.for_player(player):set({ jump = 1 }) | ||
end) | ||
) | ||
effects.register( | ||
effects.Effect:new(lord_effects.HEALTH) | ||
:on_start(function(self, player, amount, duration) | ||
damage.Periodical:for_player(player):start(damage.Type.FLESHY, amount, duration) | ||
end) | ||
:on_stop(function(self, player) | ||
-- Periodical Damage stops itself. | ||
end) | ||
) | ||
end | ||
|
||
|
||
return { | ||
--- @param mod minetest.Mod | ||
init = function(mod) | ||
register_effects() | ||
end, | ||
} |