moths!
parent
bc9579c1f1
commit
a850c0d660
16
petz/api.lua
16
petz/api.lua
|
@ -10,7 +10,7 @@ local creative_mode = minetest.settings:get_bool("creative_mode")
|
|||
|
||||
petz.petz_list = {"kitty", "puppy", "ducky", "lamb", "lion", "calf", "panda", --A table with all the petz names
|
||||
"grizzly", "pony", "parrot", "chicken", "piggy", "wolf", "elephant",
|
||||
"elephant_female", "pigeon"}
|
||||
"elephant_female", "pigeon", "moth"}
|
||||
|
||||
--
|
||||
--Settings
|
||||
|
@ -243,7 +243,7 @@ petz.stand = function(self)
|
|||
end
|
||||
|
||||
--
|
||||
--Misc Functions
|
||||
--Helper Functions
|
||||
--
|
||||
|
||||
function petz:split(inSplitPattern, outResults)
|
||||
|
@ -273,6 +273,15 @@ function petz.to_boolean(val)
|
|||
end
|
||||
end
|
||||
|
||||
function petz.is_night()
|
||||
local timeofday = minetest.get_timeofday() * 24000
|
||||
if (timeofday < 4500) or (timeofday > 19500) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
--The Tamagochi Mode
|
||||
--
|
||||
|
@ -1384,6 +1393,9 @@ petz.on_die = function(self)
|
|||
self.attached_squared_ball.object:set_detach()
|
||||
end
|
||||
end
|
||||
if self.can_fly then
|
||||
self.can_fly = false
|
||||
end
|
||||
--For all the mobs
|
||||
local props = self.object:get_properties()
|
||||
props.collisionbox[2] = props.collisionbox[1]
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,83 @@
|
|||
local S = ...
|
||||
|
||||
local pet_name = "moth"
|
||||
local scale_model = 0.7
|
||||
local mesh = 'petz_moth.b3d'
|
||||
local textures= {"petz_moth.png"}
|
||||
local collisionbox = {-0.35, -0.75*scale_model, -0.28, 0.35, -0.0625, 0.28}
|
||||
|
||||
minetest.register_entity("petz:"..pet_name,{
|
||||
--Petz specifics
|
||||
type = "moth",
|
||||
init_timer = false,
|
||||
is_pet = false,
|
||||
can_fly = true,
|
||||
max_height = 3,
|
||||
spawn_at_night = true,
|
||||
has_affinity = false,
|
||||
is_wild = false,
|
||||
give_orders = false,
|
||||
can_be_brushed = false,
|
||||
capture_item = "net",
|
||||
follow = petz.settings.moth_follow,
|
||||
--automatic_face_movement_dir = 0.0,
|
||||
rotate = petz.settings.rotate,
|
||||
physical = true,
|
||||
stepheight = 0.1, --EVIL!
|
||||
collide_with_objects = true,
|
||||
collisionbox = collisionbox,
|
||||
visual = petz.settings.visual,
|
||||
mesh = mesh,
|
||||
textures = textures,
|
||||
visual_size = {x=petz.settings.visual_size.x*scale_model, y=petz.settings.visual_size.y*scale_model},
|
||||
static_save = true,
|
||||
get_staticdata = mobkit.statfunc,
|
||||
-- api props
|
||||
springiness= 0,
|
||||
buoyancy = 0.5, -- portion of hitbox submerged
|
||||
max_speed = 2,
|
||||
jump_height = 2.0,
|
||||
view_range = 10,
|
||||
lung_capacity = 10, -- seconds
|
||||
max_hp = 4,
|
||||
|
||||
attack={range=0.5, damage_groups={fleshy=3}},
|
||||
animation = {
|
||||
walk={range={x=1, y=12}, speed=20, loop=true},
|
||||
run={range={x=13, y=25}, speed=20, loop=true},
|
||||
stand={
|
||||
{range={x=26, y=46}, speed=5, loop=true},
|
||||
{range={x=47, y=59}, speed=5, loop=true},
|
||||
{range={x=60, y=70}, speed=5, loop=true},
|
||||
{range={x=71, y=91}, speed=5, loop=true},
|
||||
},
|
||||
fly={range={x=92, y=98}, speed=20, loop=true},
|
||||
stand_fly={range={x=92, y=98}, speed=20, loop=true},
|
||||
},
|
||||
sounds = {
|
||||
misc = "petz_moth_chirp",
|
||||
moaning = "petz_moth_moaning",
|
||||
},
|
||||
|
||||
brainfunc = petz.herbivore_brain,
|
||||
|
||||
on_activate = function(self, staticdata, dtime_s) --on_activate, required
|
||||
mobkit.actfunc(self, staticdata, dtime_s)
|
||||
petz.set_initial_properties(self, staticdata, dtime_s)
|
||||
end,
|
||||
|
||||
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
petz.on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
end,
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
petz.on_rightclick(self, clicker)
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
mobkit.stepfunc(self, dtime) -- required
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
petz:register_egg("petz:moth", S("Moth"), "petz_spawnegg_moth.png", false)
|
|
@ -18,7 +18,7 @@ rob_mobs = false
|
|||
|
||||
##Spawn Engine
|
||||
## The interval is avg spawn attempt interval for every player
|
||||
spawn_interval = 25
|
||||
spawn_interval = 30
|
||||
## Max number of mobs in abr
|
||||
max_mobs = 30
|
||||
|
||||
|
@ -60,6 +60,7 @@ tropicalfish_spawn = true
|
|||
wolf_spawn = true
|
||||
elephant_spawn = true
|
||||
elephant_female_spawn = true
|
||||
moth_spawn = true
|
||||
|
||||
##Air Damage
|
||||
air_damage = 1
|
||||
|
@ -199,3 +200,9 @@ elephant_spawn_chance = 1.0
|
|||
elephant_spawn_biome = default
|
||||
elephant_breed = default:blueberries
|
||||
elephant_copulation_distance = 4
|
||||
|
||||
##Moth Specific
|
||||
moth_follow = default:torch
|
||||
moth_spawn_chance = 0.8
|
||||
moth_spawn_nodes = default:dirt_with_coniferous_litter
|
||||
moth_spawn_biome = default
|
||||
|
|
|
@ -154,6 +154,11 @@ petz.settings.elephant_female_spawn_biome = petz.settings.elephant_spawn_biome
|
|||
petz.settings.elephant_female_follow = petz.settings.elephant_follow
|
||||
petz.settings.elephant_female_breed = petz.settings.elephant_breed
|
||||
petz.settings.elephant_female_copulation_distance = petz.settings.elephant_copulation_distance
|
||||
petz.settings.moth_spawn = settings:get_bool("moth_spawn", true)
|
||||
petz.settings.moth_spawn_chance = tonumber(settings:get("moth_spawn_chance"))
|
||||
petz.settings.moth_spawn_nodes = settings:get("moth_spawn_nodes", "")
|
||||
petz.settings.moth_spawn_biome = settings:get("moth_spawn_biome", "default")
|
||||
petz.settings.moth_follow = settings:get("moth_follow", "")
|
||||
|
||||
if petz.settings.type_model == "mesh" then
|
||||
petz.settings.visual = "mesh"
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -38,8 +38,15 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
|
||||
local random_mob = candidates_list[math.random(1, #candidates_list)] --Get a random mob from the list of candidates
|
||||
local spawn_chance = petz.settings[random_mob.."_spawn_chance"]
|
||||
random_mob_name = "petz:" .. random_mob
|
||||
--minetest.chat_send_player("singleplayer", random_mob)
|
||||
--Firstly check if this mob spawns at night
|
||||
if minetest.registered_entities[random_mob_name] and minetest.registered_entities[random_mob_name].spawn_at_night then
|
||||
if not(petz.is_night()) then --if not at night
|
||||
return
|
||||
end
|
||||
end
|
||||
local spawn_chance = petz.settings[random_mob.."_spawn_chance"]
|
||||
if spawn_chance < 0 then
|
||||
spawn_chance = 0
|
||||
elseif spawn_chance > 1 then
|
||||
|
@ -68,10 +75,9 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
end
|
||||
end
|
||||
local pet_name = "petz:"..random_mob
|
||||
if mob_count < petz.settings.max_mobs then --check for bigger mobs:
|
||||
spawn_pos = petz.pos_to_spawn(pet_name, spawn_pos) --recalculate pos.y for bigger mobs
|
||||
minetest.add_entity(spawn_pos, pet_name)
|
||||
spawn_pos = petz.pos_to_spawn(random_mob_name, spawn_pos) --recalculate pos.y for bigger mobs
|
||||
minetest.add_entity(spawn_pos, random_mob_name)
|
||||
--minetest.chat_send_player("singleplayer", "spawned!!!")
|
||||
end
|
||||
end
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 626 B |
Loading…
Reference in New Issue