Glory Is Forever

master
benrob0329 2021-05-31 02:57:33 -04:00
parent d6d9b0a112
commit 9bcc6033cf
3 changed files with 50 additions and 25 deletions

View File

@ -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"}}

View File

@ -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},
}
})

View File

@ -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)
@ -93,9 +100,22 @@ do --[[ Staff Entity ]]--
end
local player = mobkit.get_nearby_player(self)
if player then
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)