working realm and WIP asp

This commit is contained in:
archfan 2020-04-08 20:57:00 -04:00
parent 80737c8907
commit 07b577aac9
8 changed files with 65 additions and 9 deletions

View File

@ -4,3 +4,4 @@ local modpath = minetest.get_modpath(minetest.get_current_modname())
dofile(modpath.."/realm.lua")
dofile(modpath.."/items.lua")
dofile(modpath.."/mobs.lua")

View File

@ -19,7 +19,8 @@ minetest.register_craftitem("shadowrealm:escape_elixir", {
on_use = function(itemstack, user)
if user and user:is_player() and realm.is_in_shadow_realm(user:get_player_name()) then
realm.exit_shadow_realm(user)
return nil
end
return ""
end,
on_drop = function() return end,
})

50
mobs.lua Normal file
View File

@ -0,0 +1,50 @@
-- Using Termos' MobKit
-- Shadow Realm Mobs
-- Asp
minetest.register_entity("shadowrealm:asp", {
initial_properties = {
physical = true,
collisionbox = {0.5, 1, 0.5, -0.5, -2, -0.5},
visual = "mesh",
mesh = "shadowrealm_asp.b3d",
textures = {"shadowrealm_asp.png"},
visual_size = {x=3,y=3,z=3},
},
timeout = 100,
buoyancy = -0.1,
lung_capacity = 0,
max_hp = 25,
on_step = mobkit.stepfunc,
on_activate = mobkit.actfunc,
get_staticdata = mobkit.statfunc,
logic = function(self)
if not self then return end
if mobkit.timer(self,1) then
local prty = mobkit.get_queue_priority(self)
if prty < 10 then
local target = mobkit.get_nearby_player()
if target then
mobkit.hq_hunt(self, prty, target)
end
end
if mobkit.is_queue_empty_high(self) then
mobkit.hq_roam(self, prty)
end
end
end,
animation = {
walk = {range={x=1, y=10}, speed=24, loop=true},
leap = {range={x=11, y=31}, speed=24, loop=true},
},
sounds = {
hiss = "shadowrealm_hiss.ogg",
},
max_speed = 1,
jump_height = 1,
view_range = 10,
attack = {range = 2, damage_groups = {fleshy = 4}},
armor_groups = {fleshy = 5},
})

3
mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = shadowrealm
description = The realm of shadows contains many hidden horrors.
depends = mobkit

BIN
models/asp.blend Normal file

Binary file not shown.

BIN
models/shadowrealm_asp.b3d Normal file

Binary file not shown.

View File

@ -51,7 +51,7 @@ end
realm.enter_shadow_realm = function(player)
player:set_properties({
is_visible = false,
visual_size = {x=0,y=0,z=0},
})
local name = player:get_player_name()
realm.indices[name] = {}
@ -61,7 +61,7 @@ realm.enter_shadow_realm = function(player)
local index = minetest.add_particlespawner(def)
realm.indices[name][#realm.indices[name]] = index
end
for _, playername in pairs(realm.players) do
for playername, _ in pairs(realm.players) do
local object = minetest.get_player_by_name(playername)
if not object then return end
local def = realm.get_spawner_definition(object, name)
@ -72,17 +72,18 @@ realm.enter_shadow_realm = function(player)
index = minetest.add_particlespawner(def)
realm.indices[playername][#realm.indices[playername]] = index
end
realm.players[#realm.players] = name
realm.players[name] = true -- okay I guess
end
realm.exit_shadow_realm = function(object)
if object:is_player() then
player:set_properties({
is_visible = true,
object:set_properties({
visual_size = {x=1,y=1,z=1},
})
local name = player:get_player_name()
local name = object:get_player_name()
realm.players[name] = nil
if realm.indices[name] then
for _, index in realm.indices[name] do
for _, index in pairs(realm.indices[name]) do
minetest.delete_particlespawner(index)
end
-- We don't need those particlespawner indices now
@ -92,7 +93,7 @@ realm.exit_shadow_realm = function(object)
end
realm.is_in_shadow_realm = function(playername)
return realm.players[playername]
return realm.players[playername] ~= nil
end
realm.allow_underground = function()

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB