Use status effects for elixirs and cold demon slow.
This commit is contained in:
parent
b486af8627
commit
e9ae30dfc9
4 changed files with 37 additions and 16 deletions
2
abms.lua
2
abms.lua
|
@ -184,6 +184,8 @@ minetest.register_globalstep(function(dtime)
|
|||
else
|
||||
fun_caves.db.status[player_name][name] = nil
|
||||
end
|
||||
elseif def.during then
|
||||
def.during(player)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
23
demon.lua
23
demon.lua
|
@ -162,10 +162,6 @@ local snow_demon = {
|
|||
walkmine_end = 219,
|
||||
},
|
||||
animation_speed = 30,
|
||||
on_die = function(self)
|
||||
self.slowed:set_physics_override({speed=1})
|
||||
self.slowed = nil
|
||||
end,
|
||||
do_custom = function(self)
|
||||
if not self.attack then
|
||||
self.fly = false
|
||||
|
@ -175,14 +171,7 @@ local snow_demon = {
|
|||
snow_effect(pos, 20)
|
||||
|
||||
if self.attack then
|
||||
self.attack:set_physics_override({speed=0.3})
|
||||
self.slowed = self.attack
|
||||
elseif self.slowed then
|
||||
local player = self.slowed
|
||||
minetest.after(20, function()
|
||||
player:set_physics_override({speed=1})
|
||||
end)
|
||||
self.slowed = nil
|
||||
fun_caves.set_status(self.attack:get_player_name(), 'slow_cold', 20)
|
||||
end
|
||||
|
||||
if not fun_caves.custom_ready(self) then
|
||||
|
@ -193,6 +182,16 @@ local snow_demon = {
|
|||
end,
|
||||
}
|
||||
|
||||
fun_caves.register_status({
|
||||
name = 'slow_cold',
|
||||
start = function(player)
|
||||
player:set_physics_override({speed=0.3})
|
||||
end,
|
||||
terminate = function(player)
|
||||
player:set_physics_override({speed=1})
|
||||
end,
|
||||
})
|
||||
|
||||
if minetest.registered_entities["mobs_yeti:yeti"] then
|
||||
snow_demon.arrow = "mobs_yeti:snowball"
|
||||
snow_demon.attack_type = 'dogshoot'
|
||||
|
|
|
@ -54,10 +54,7 @@ local function armor(user, factor)
|
|||
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy * factor)))
|
||||
user:set_armor_groups(armor)
|
||||
minetest.chat_send_player(player_name, 'Your skin feels harder...')
|
||||
fun_caves.db.status[player_name].armor_elixir = {
|
||||
remove = minetest.get_gametime() + elixir_duration,
|
||||
factor = factor,
|
||||
}
|
||||
fun_caves.set_status(player_name, 'armor_elixir', elixir_duration, {factor = factor})
|
||||
end
|
||||
|
||||
local descs = {
|
||||
|
|
23
init.lua
23
init.lua
|
@ -112,6 +112,29 @@ function fun_caves.register_status(def)
|
|||
}
|
||||
end
|
||||
|
||||
function fun_caves.set_status(player_name, status, time, param)
|
||||
local player = minetest.get_player_by_name(player_name)
|
||||
local def = fun_caves.registered_status[status]
|
||||
if not (def and player) then
|
||||
return
|
||||
end
|
||||
|
||||
if not param then
|
||||
param = {}
|
||||
end
|
||||
|
||||
if time then
|
||||
param.remove = minetest.get_gametime() + time
|
||||
end
|
||||
|
||||
if player_name and status and fun_caves.db.status[player_name] then
|
||||
fun_caves.db.status[player_name][status] = param
|
||||
if def.start then
|
||||
def.start(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--dofile(fun_caves.path .. "/recipe_list.lua")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue