mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-01 07:13:45 +01:00
Add Bad Omen Effect
This commit is contained in:
parent
8b6409b7f1
commit
96ac31bec3
@ -47,15 +47,8 @@ mcl_raids.wave_definitions = {
|
||||
},
|
||||
}
|
||||
|
||||
minetest.register_chatcommand("spawn_raid", {
|
||||
privs = {
|
||||
server = true,
|
||||
},
|
||||
func = function(name)
|
||||
local wave = 1
|
||||
mcl_raids.spawn_raid = function(pos, wave)
|
||||
local illager_count = 0
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local pos = player:get_pos()
|
||||
local spawnable = false
|
||||
local r = 32
|
||||
local n = 12
|
||||
@ -87,5 +80,16 @@ minetest.register_chatcommand("spawn_raid", {
|
||||
end
|
||||
minetest.log("action", "[mcl_raids] Raid Spawned. Illager Count: " .. illager_count .. ".")
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("spawn_raid", {
|
||||
privs = {
|
||||
server = true,
|
||||
},
|
||||
func = function(name)
|
||||
local wave = 1
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local pos = player:get_pos()
|
||||
mcl_raids.spawn_raid(pos, wave)
|
||||
end
|
||||
})
|
||||
|
@ -19,6 +19,7 @@ get_chat_function["water_breathing"] = mcl_potions.water_breathing_func
|
||||
get_chat_function["leaping"] = mcl_potions.leaping_func
|
||||
get_chat_function["swiftness"] = mcl_potions.swiftness_func
|
||||
get_chat_function["heal"] = mcl_potions.healing_func
|
||||
get_chat_function["bad_omen"] = mcl_potions.bad_omen_func
|
||||
|
||||
minetest.register_chatcommand("effect",{
|
||||
params = S("<effect> <duration> [<factor>]"),
|
||||
|
@ -9,6 +9,7 @@ EF.leaping = {}
|
||||
EF.swift = {} -- for swiftness AND slowness
|
||||
EF.night_vision = {}
|
||||
EF.fire_proof = {}
|
||||
EF.bad_omen = {}
|
||||
|
||||
local EFFECT_TYPES = 0
|
||||
for _,_ in pairs(EF) do
|
||||
@ -350,6 +351,28 @@ minetest.register_globalstep(function(dtime)
|
||||
|
||||
end
|
||||
|
||||
-- Check for Bad Omen
|
||||
for player, vals in pairs(EF.bad_omen) do
|
||||
|
||||
is_player = player:is_player()
|
||||
entity = player:get_luaentity()
|
||||
|
||||
EF.bad_omen[player].timer = EF.bad_omen[player].timer + dtime
|
||||
|
||||
if player:get_pos() then mcl_potions._add_spawner(player, "#0b6138") end
|
||||
|
||||
if EF.bad_omen[player] and EF.bad_omen[player].timer >= EF.bad_omen[player].dur then
|
||||
EF.bad_omen[player] = nil
|
||||
mcl_raids.spawn_raid(player:get_pos(), 1)
|
||||
if is_player then
|
||||
meta = player:get_meta()
|
||||
meta:set_string("_had_bad_omen", minetest.serialize(EF.bad_omen[player]))
|
||||
potions_set_hud(player)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
-- Prevent damage to player with Fire Resistance enabled
|
||||
@ -386,6 +409,7 @@ function mcl_potions._clear_cached_player_data(player)
|
||||
EF.swift[player] = nil
|
||||
EF.night_vision[player] = nil
|
||||
EF.fire_proof[player] = nil
|
||||
EF.bad_omen[player] = nil
|
||||
|
||||
meta = player:get_meta()
|
||||
meta:set_int("night_vision", 0)
|
||||
@ -429,6 +453,7 @@ function mcl_potions._save_player_effects(player)
|
||||
meta:set_string("_is_swift", minetest.serialize(EF.swift[player]))
|
||||
meta:set_string("_is_cat", minetest.serialize(EF.night_vision[player]))
|
||||
meta:set_string("_is_fire_proof", minetest.serialize(EF.fire_proof[player]))
|
||||
meta:set_string("_has_bad_omen", minetest.serialize(EF.bad_omen[player]))
|
||||
|
||||
end
|
||||
|
||||
@ -480,6 +505,10 @@ function mcl_potions._load_player_effects(player)
|
||||
EF.fire_proof[player] = minetest.deserialize(meta:get_string("_is_fire_proof"))
|
||||
end
|
||||
|
||||
if minetest.deserialize(meta:get_string("_had_bad_omen")) then
|
||||
EF.bad_omen[player] = minetest.deserialize(meta:get_string("_has_bad_omen"))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Returns true if player has given effect
|
||||
@ -966,3 +995,22 @@ function mcl_potions._extinguish_nearby_fire(pos, radius)
|
||||
end
|
||||
return exting
|
||||
end
|
||||
|
||||
function mcl_potions.bad_omen_func(player, null, duration)
|
||||
|
||||
if not EF.bad_omen[player] then
|
||||
|
||||
EF.bad_omen[player] = {dur = duration, timer = 0}
|
||||
|
||||
else
|
||||
|
||||
local victim = EF.bad_omen[player]
|
||||
victim.dur = math.max(duration, victim.dur - victim.timer)
|
||||
victim.timer = 0
|
||||
end
|
||||
|
||||
if player:is_player() then
|
||||
potions_set_icons(player)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,2 +1,2 @@
|
||||
name = mcl_potions
|
||||
depends = mcl_core, mcl_farming, mcl_mobitems, mcl_fishing, mcl_bows, mcl_end, mcl_weather, playerphysics, mcl_wip
|
||||
depends = mcl_core, mcl_farming, mcl_mobitems, mcl_fishing, mcl_bows, mcl_end, mcl_weather, playerphysics, mcl_wip, mcl_raids
|
||||
|
BIN
mods/ITEMS/mcl_potions/textures/mcl_potions_effect_bad_omen.png
Normal file
BIN
mods/ITEMS/mcl_potions/textures/mcl_potions_effect_bad_omen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
Loading…
Reference in New Issue
Block a user