From 8b70d6cd7c9f450f513327d52c0409c3e49f702b Mon Sep 17 00:00:00 2001 From: Alexsandro Percy Date: Tue, 28 Dec 2021 10:42:25 -0300 Subject: [PATCH] spawn improvements --- init.lua | 54 ++++++++++++++++++++++++++++++--- textures/zombiestrd_target.png | Bin 0 -> 5568 bytes 2 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 textures/zombiestrd_target.png diff --git a/init.lua b/init.lua index 1ee98d1..5912d3c 100644 --- a/init.lua +++ b/init.lua @@ -18,7 +18,7 @@ local sign = math.sign local time = os.time -local zombiestrd_spawn_chance = 0.8 --0.6 +local zombiestrd_spawn_chance = 0.6 --0.6 local spawn_rate = 1 - max(min(minetest.settings:get('zombiestrd_spawn_chance') or zombiestrd_spawn_chance,1),0) local spawn_reduction = minetest.settings:get('zombiestrd_spawn_reduction') or 0.4 @@ -168,10 +168,51 @@ local function shark_brain(self) end if mobkit.is_queue_empty_high(self) then mobkit.hq_aqua_roam(self,10,5) end end + +minetest.register_node("zombiestrd:display_target", { + tiles = {"zombiestrd_target.png"}, + use_texture_alpha = true, + walkable = false, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-.55,-.55,-.55, .55,.55,.55}, + }, + }, + selection_box = { + type = "regular", + }, + paramtype = "light", + groups = {dig_immediate = 3, not_in_creative_inventory = 1}, + drop = "", +}) + +minetest.register_entity("zombiestrd:target", { + physical = false, + collisionbox = {0, 0, 0, 0, 0, 0}, + visual = "wielditem", + -- wielditem seems to be scaled to 1.5 times original node size + visual_size = {x = 0.67, y = 0.67}, + textures = {"zombiestrd:display_target"}, + timer = 0, + glow = 10, + + on_step = function(self, dtime) + + self.timer = self.timer + dtime + + -- remove after set number of seconds + if self.timer > 1 then + self.object:remove() + end + end, +}) + + -- spawning is too specific to be included in the api, this is an example. -- a modder will want to refer to specific names according to games/mods they're using -- in order for mobs not to spawn on treetops, certain biomes etc. - local function spawnstep(dtime) for _,plyr in ipairs(minetest.get_connected_players()) do @@ -188,14 +229,17 @@ local function spawnstep(dtime) yaw = random()*pi*2 - pi end local pos = plyr:get_pos() - local distance_multiplier = 2 --16 - local dir = vector.multiply(minetest.yaw_to_dir(yaw),abr*distance_multiplier) + local distance_multiplier = 10 --16 + --local dir = vector.multiply(minetest.yaw_to_dir(yaw),abr*distance_multiplier) + local dir = vector.multiply(minetest.yaw_to_dir(yaw),distance_multiplier) local pos2 = vector.add(pos,dir) + --minetest.add_entity(pos2, "zombiestrd:target") --debug target pos2.y=pos2.y-5 local height, liquidflag = mobkit.get_terrain_height(pos2,32) if areas then - for id, area in pairs(areas:getAreasAtPos(pos2)) do + local areasAtPos = areas:getAreasAtPos(pos2) + for id, area in pairs(areasAtPos) do --minetest.chat_send_all(dump(area.name)) if area.name == "cemetery" or area.name == "Cemetery" or area.name == "zbd" then diff --git a/textures/zombiestrd_target.png b/textures/zombiestrd_target.png new file mode 100644 index 0000000000000000000000000000000000000000..d1a399cdd44d4ececd65f6dac7e0a5eb16784983 GIT binary patch literal 5568 zcmeHLdt4J&77nO@h+-?CwkR>y7cj}>MKWn3k$2QUfG8-wCNmQVCYd;ykiaS`6%`*S z*!rrixNfUe(IR!VmR78wA}Y4Et%CSK@L6ALTWyiDcLHMEb?y4w^*`a4kbCcUzH{z( z&pDS&fhIn-xAz;~EEcP`DlRGs{O!xUyga~r(EWCl#d3d;qfMogP&?Z~k$QuXVAI(a zf=xIKdKSx3e{0Ru)y>0w@-Iw^UOn%v1yvLreiiqel*>KSvh&7mmA+WsyykqQ<%**z%1J_@M;oF#^V?_1``zE0)rXq(m-t^UmXm8P$G6C; zv#z~;biZ%iLR|AnNX3F|FV(q}aN)}PJEZ<83w^&0I3z9TPQTT1tb1O??DNo!*#Xz0 zn~#i~J+Xc8oYyzrB-SKMzA|p8&sTGlzkm5Kt!Ya^%gM#lgVv6YnB$*)^0u|`{>{u| z8qsur|3i@<{L&}TH;&u7XPI8=k2RE*WbY_*i(df^&RFiv-+EkGAe*pWlyzb2km{;; zdMm8h*|7eXzwZ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