Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
PrairieWind | d61f9a2ab6 | |
PrairieWind | f54d7aada7 | |
PrairieWind | 9aa29241b9 | |
PrairieWind | 34fb72fd16 | |
PrairieWind | 983056cdb0 | |
PrairieWind | f551b51c14 |
|
@ -0,0 +1,161 @@
|
|||
-- mcl_raids
|
||||
|
||||
mcl_raids = {}
|
||||
|
||||
-- Define the amount of illagers to spawn each wave.
|
||||
mcl_raids.wave_definitions = {
|
||||
-- Pillager
|
||||
{
|
||||
illager_name = "mobs_mc:pillager",
|
||||
wave_1 = 5,
|
||||
wave_2 = 4,
|
||||
wave_3 = 4,
|
||||
wave_4 = 5,
|
||||
wave_5 = 5,
|
||||
extra_wave = 5,
|
||||
},
|
||||
-- Vindicator aka Angry Axeman
|
||||
{
|
||||
illager_name = "mobs_mc:vindicator",
|
||||
wave_1 = 1,
|
||||
wave_2 = 3,
|
||||
wave_3 = 1,
|
||||
wave_4 = 2,
|
||||
wave_5 = 5,
|
||||
extra_wave = 5,
|
||||
},
|
||||
--{"mobs_mc:ravager", 0, 0, 1, 0, 0, 2},
|
||||
-- Witch
|
||||
{
|
||||
illager_name = "mobs_mc:witch",
|
||||
wave_1 = 0,
|
||||
wave_2 = 0,
|
||||
wave_3 = 1,
|
||||
wave_4 = 3,
|
||||
wave_5 = 1,
|
||||
extra_wave = 1,
|
||||
},
|
||||
-- Evoker
|
||||
{
|
||||
illager_name = "mobs_mc:evoker",
|
||||
wave_1 = 0,
|
||||
wave_2 = 0,
|
||||
wave_3 = 0,
|
||||
wave_4 = 0,
|
||||
wave_5 = 1,
|
||||
extra_wave = 1,
|
||||
},
|
||||
}
|
||||
|
||||
mcl_raids.spawn_raid = function(pos, wave)
|
||||
local illager_count = 0
|
||||
local spawnable = false
|
||||
local r = 32
|
||||
local n = 12
|
||||
local i = math.random(1, n)
|
||||
local raid_pos = vector.offset(pos,r * math.cos(((i-1)/n) * (2*math.pi)),0, r * math.sin(((i-1)/n) * (2*math.pi)))
|
||||
local sn = minetest.find_nodes_in_area_under_air(vector.offset(raid_pos,0,100,0), vector.offset(raid_pos,0,-100,0), {"group:grass_block", "group:grass_block_snow", "group:snow_cover", "group:sand"})
|
||||
if sn and #sn > 0 then
|
||||
local spawn_pos = sn[1]
|
||||
if spawn_pos then
|
||||
minetest.log("action", "[mcl_raids] Raid Spawn Position chosen at " .. minetest.pos_to_string(spawn_pos) .. ".")
|
||||
spawnable = true
|
||||
else
|
||||
minetest.log("action", "[mcl_raids] Raid Spawn Postion not chosen.")
|
||||
end
|
||||
elseif not sn then
|
||||
minetest.log("action", "[mcl_raids] Raid Spawn Position error, no appropriate site found.")
|
||||
end
|
||||
if spawnable and spawn_pos then
|
||||
for _, raiddefs in pairs(mcl_raids.wave_definitions) do
|
||||
local wave_count = raiddefs.wave_1
|
||||
for i = 0, wave_count do
|
||||
local entity = minetest.add_entity(spawn_pos, raiddefs.illager_name)
|
||||
if entity then
|
||||
local l = entity:get_luaentity()
|
||||
l.raidmember = true
|
||||
illager_count = illager_count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
minetest.log("action", "[mcl_raids] Raid Spawned. Illager Count: " .. illager_count .. ".")
|
||||
end
|
||||
end
|
||||
|
||||
mcl_raids.find_villager = function(pos)
|
||||
local obj = minetest.get_objects_inside_radius(pos, 8)
|
||||
for _, objects in ipairs(obj) do
|
||||
local object = objects:get_luaentity()
|
||||
if object then
|
||||
if object.name ~= "mobs_mc:villager" then
|
||||
return
|
||||
elseif object.name == "mobs_mc:villager" then
|
||||
minetest.log("action", "[mcl_raids] Villager Found.")
|
||||
return true
|
||||
else
|
||||
minetest.log("action", "[mcl_raids] No Villager Found.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mcl_raids.find_bed = function(pos)
|
||||
local beds = minetest.find_nodes_in_area(vector.offset(pos, -8, -8, -8), vector.offset(pos, 8, 8, 8), "mcl_beds:bed_red_bottom")
|
||||
if beds[1] then
|
||||
minetest.log("action", "[mcl_raids] Bed Found.")
|
||||
return true
|
||||
else
|
||||
minetest.log("action", "[mcl_raids] No Bed Found.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
mcl_raids.find_village = function(pos)
|
||||
local bed = mcl_raids.find_bed(pos)
|
||||
local villager = mcl_raids.find_villager(pos)
|
||||
local raid_started = false
|
||||
|
||||
if (bed and villager) and raid_started == false then
|
||||
local raid = mcl_raids.spawn_raid(pos, 1)
|
||||
if raid then
|
||||
minetest.log("action", "[mcl_raids] Village found, starting raid.")
|
||||
raid_started = true
|
||||
else
|
||||
minetest.log("action", "[mcl_raids] Village found.")
|
||||
end
|
||||
return true
|
||||
elseif raid_started == true then
|
||||
minetest.log("action", "[mcl_raids] Raid already started.")
|
||||
return
|
||||
else
|
||||
minetest.log("action", "[mcl_raids] Village not found, raid is not starting.")
|
||||
return false
|
||||
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
|
||||
})
|
||||
|
||||
local etime = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
etime = dtime + etime
|
||||
if etime < 10 then return end
|
||||
etime = 0
|
||||
for _,pl in pairs(minetest.get_connected_players()) do
|
||||
if pl:get_meta():get_string("_has_bad_omen") then
|
||||
mcl_raids.find_village(pl:get_pos())
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
|
@ -0,0 +1 @@
|
|||
name = mcl_raids
|
|
@ -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,26 @@ minetest.register_globalstep(function(dtime)
|
|||
|
||||
end
|
||||
|
||||
-- Check for Bad Omen
|
||||
for player, vals in pairs(EF.bad_omen) do
|
||||
|
||||
is_player = player:is_player()
|
||||
|
||||
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
|
||||
if is_player then
|
||||
meta = player:get_meta()
|
||||
meta:set_string("_has_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 +407,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 +451,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 +503,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("_has_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 +993,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
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
Loading…
Reference in New Issue