From 9bcc6033cf2a5ddb765f4d21ee94f00a6f39ddf6 Mon Sep 17 00:00:00 2001 From: benrob0329 Date: Mon, 31 May 2021 02:57:33 -0400 Subject: [PATCH] Glory Is Forever --- .luacheckrc | 5 --- mods/ikea/items.lua | 4 +-- mods/ikea_staff/init.lua | 66 +++++++++++++++++++++++++++++----------- 3 files changed, 50 insertions(+), 25 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index a0ea39c..d8710e1 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -9,8 +9,6 @@ read_globals = { "dump", "ikea", "music", - "soag", - "soal", "util", "schematic", } @@ -46,6 +44,3 @@ files["mods/ikea/api"] = {globals = {"ikea"}} files["mods/ikea_staff"] = {globals = {"staff"}} files["mods/music"] = {globals = {"music"}} - -files["mods/son_of_a_goap"] = {globals = {"soag"}} -files["mods/son_of_a_luaentitysao"] = {globals = {"soal"}} diff --git a/mods/ikea/items.lua b/mods/ikea/items.lua index 5845993..998ada3 100644 --- a/mods/ikea/items.lua +++ b/mods/ikea/items.lua @@ -5,7 +5,7 @@ minetest.register_craftitem("ikea:furniture_leg", { tool_capabilities = { full_punch_interval = 1, - damage_groups = {whacking = 10}, + damage_groups = {fleshy = 3}, } }) @@ -15,6 +15,6 @@ minetest.register_craftitem("ikea:furniture_board", { tool_capabilities = { full_punch_interval = 2, - damage_groups = {whacking = 10}, + damage_groups = {fleshy = 5}, } }) diff --git a/mods/ikea_staff/init.lua b/mods/ikea_staff/init.lua index 8f2ca05..3467b4d 100644 --- a/mods/ikea_staff/init.lua +++ b/mods/ikea_staff/init.lua @@ -36,12 +36,18 @@ do --[[ Staff Entity ]]-- self.object:set_pos({x = math.floor(pos.x + 0.5), y = pos.y, z = math.floor(pos.z + 0.5)}) self.object:set_velocity({x = 0, y = 0, z = 0}) + local height = mobkit.get_terrain_height(pos) + local npos = vector.offset(pos, 0, height, 0) + minetest.after((self.animation.die.range.y - self.animation.die.range.x) / self.animation.die.speed, function() - minetest.set_node(pos, {name = "staff:corpse", param2 = minetest.dir_to_facedir(minetest.yaw_to_dir(yaw))}) + minetest.set_node(npos, {name = "ikea_staff:corpse", param2 = minetest.dir_to_facedir(minetest.yaw_to_dir(yaw))}) self.object:remove() end) end + -- Global Memory + local player_sightings = {} + -- Entity Registration -- minetest.register_entity("ikea_staff:member", { initial_properties = { @@ -67,10 +73,10 @@ do --[[ Staff Entity ]]-- timeout = 0, buoyancy = 0, max_speed = 4.5, - jump_height = 3, + jump_height = 1, view_range = RANGE, attack = { - range = 2, + range = 1, damage_groups = {fleshy = 5}, }, @@ -82,6 +88,7 @@ do --[[ Staff Entity ]]-- -- Custom Logic -- logic = function(self) if mobkit.timer(self, 1) then + local pos = self.object:get_pos() local priority = mobkit.get_queue_priority(self) mobkit.vitals(self) @@ -91,11 +98,24 @@ do --[[ Staff Entity ]]-- die(self) return end - + local player = mobkit.get_nearby_player(self) - if player then - mobkit.hq_hunt(self, 100, player) + table.insert(player_sightings, 1, player:get_pos()) + player_sightings[101] = nil + end + + if not ikea.is_open() then + if player then + mobkit.hq_hunt(self, 100, player) + else + for i, v in ipairs(player_sightings) do + if vector.distance(v, pos) < RANGE then + mobkit.hq_goto(self, 50, v) + break + end + end + end end if mobkit.is_queue_empty_high(self) then @@ -106,7 +126,13 @@ do --[[ Staff Entity ]]-- on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage) if mobkit.is_alive(self) then - mobkit.hurt(self, tool_capabilities.damage_groups.fleshy or 0) + if time_from_last_punch and (time_from_last_punch > tool_capabilities.full_punch_interval) then + local dmg = tool_capabilities.damage_groups.fleshy or 0 + dir = vector.multiply(dir, dmg) + self.object:set_velocity(vector.new(dir.x, 2, dir.y)) + mobkit.hurt(self, dmg) + end + return true end end, @@ -118,8 +144,7 @@ do --[[ Corpse ]]-- return math.random(5, 120) end - -- Staff Corpse Node -- - minetest.register_node(":staff:corpse", { + minetest.register_node("ikea_staff:corpse", { description = "SCP-3008-2 (Deceased)", drawtype = "mesh", mesh = "ikea_staff_member_dead.obj", @@ -135,7 +160,12 @@ do --[[ Corpse ]]-- -- Corpse Mob Spawner -- on_timer = function(pos, elapsed) if not helpers.is_visible(pos, 3, RANGE) then - minetest.add_entity(helpers.randompos(pos, 5), "ikea_staff:member") + local spawnpos = helpers.randompos(pos, 5) + local height = mobkit.get_terrain_height(spawnpos) + if height then + spawnpos = vector.offset(spawnpos, 0, height, 0) + minetest.add_entity(spawnpos, "ikea_staff:member") + end end minetest.get_node_timer(pos):start(randtime()) return false @@ -150,21 +180,22 @@ do --[[ Rare "Thin Air" Spawning ]]-- local TRIES = 20 -- How many times to try finding a valid spawn point before giving up local timer = 0 - minetest.register_globalstep(function(dt) - timer = timer + dt + minetest.register_globalstep(function(dtime) + timer = timer + dtime if timer >= (5 * 60) then for _, player in pairs(minetest.get_connected_players()) do local pos = player:get_pos() local tries = 0 while tries <= TRIES do - local spawnat = helpers.randompos(pos, RANGE) - if not minetest.registered_nodes[minetest.get_node(spawnat).name].walkable then - if helpers.is_visible(spawnat, 3, RANGE) then + local testpos = helpers.randompos(pos, RANGE) + local height = mobkit.get_terrain_height(testpos) + if height then + local spawnpos = vector.offset(testpos, 0, height, 0) + if helpers.is_visible(spawnpos, 3, RANGE) then tries = tries + 1 else - spawnat.y = 2 - minetest.add_entity(spawnat, "ikea_staff:member") + minetest.add_entity(spawnpos, "ikea_staff:member") break end else @@ -172,7 +203,6 @@ do --[[ Rare "Thin Air" Spawning ]]-- end end end - timer = 0 end end)