removed mobkit, wellcome kitz

master
root 2022-05-28 11:21:29 +02:00
parent 1723715bf2
commit d7c75df458
134 changed files with 2441 additions and 726 deletions

View File

@ -1,10 +1,10 @@
# Drop Functions
## mokapi.drop_item(self, item_stack)
## kitz.drop_item(self, item_stack)
Mob drops only one item.
item_stack is a former ItemStack.
## mokapi.drop_items(self, killed_by_player)
## kitz.drop_items(self, killed_by_player)
Mob drops a table list of items defined in the entity.
@ -15,13 +15,13 @@ drops = {
{name = "petz:bone", chance = 5, min = 1, max = 1,},
},
```
## mokapi.node_drop_items(pos)
## kitz.node_drop_items(pos)
Node drops the "drops" list saved in the node metadata.
# Sound Functions
## mokapi.make_misc_sound(self, chance, max_hear_distance)
## kitz.make_misc_sound(self, chance, max_hear_distance)
Make a random sound from the "misc" sound definition.
The misc definition can be a single sound or a table of sounds.
Example of the 'misc' definition:
@ -30,14 +30,14 @@ sounds = {
misc = {"petz_kitty_meow", "petz_kitty_meow2", "petz_kitty_meow3"},
},
```
## mokapi.make_sound(dest_type, dest, soundfile, max_hear_distance)
## kitz.make_sound(dest_type, dest, soundfile, max_hear_distance)
Make a sound on dest accordingly dest_type.
dest_type can be "object, "player" or "pos".
# Replace Function
## mokapi.replace(self, sound_name, max_hear_distance)
## kitz.replace(self, sound_name, max_hear_distance)
Replace a node to another. Useful for eating grass.
'sound_name' & 'max_hear_distance' are optionals.
@ -55,7 +55,7 @@ replace_what = {
# Feed & Tame Functions
## function mokapi.feed(self, clicker, feed_rate, msg_full_health, sound_type)
## function kitz.feed(self, clicker, feed_rate, msg_full_health, sound_type)
It returns true if fed.
@ -71,7 +71,7 @@ msg_full_health is optional
sound_type is the self.sound type
## function mokapi.tame(self, feed_count, owner_name, msg_tamed, limit)
## function kitz.tame(self, feed_count, owner_name, msg_tamed, limit)
It returns true if tamed.
'feed_count' is the amount of food to get the mob tamed.
@ -84,31 +84,31 @@ It returns true if tamed.
if 'max > count + 1' then the taming process is aborted.
## function mokapi.set_owner(self, owner_name)
## function kitz.set_owner(self, owner_name)
Put 'self.tamed' to true and the 'self.owner' name.
## function mokapi.remove_owner(self)
## function kitz.remove_owner(self)
Put 'self.tamed' to false and the 'self.owner' to nil.
## function mokapi.set_health(self, rate)
## function kitz.set_health(self, rate)
'rate' (from 0.0 to 1.0) is the percentage of self.max_hp
rate can be positive or negative
# Helper Functions
## function mokapi.remove_mob(self)
## function kitz.remove_mob(self)
It clears the mob HQ and LQ behaviours and then remove it from the world.
# Commands
## clear_mobs modname
It clears all the mobkit non-tamed mobs in the closest range of the player.
It clears all the kitz non-tamed mobs in the closest range of the player.
Modname is the mod of the mobs to clear.
# Server
## function mokapi.cron_clear(cron_time, modname)
## function kitz.cron_clear(cron_time, modname)
It creates a cron task to clearing all the 'modname' non-tamed mobs in the closest range of all the server's players (or game) from time to time.
If cron_time <= 0 then the cron task does not run.

View File

@ -1,4 +1,4 @@
function mokapi.clear_mobs(pos, modname)
function kitz.clear_mobs(pos, modname)
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 100)) do
local ent_name = obj:get_entity_name()
if not(obj:is_player()) and minetest.registered_entities[ent_name] then
@ -6,7 +6,7 @@ function mokapi.clear_mobs(pos, modname)
local ent_modname = string.sub(ent_name, 1, colon_pos-1)
local ent = obj:get_luaentity()
if ent_modname == modname and ent.type and not(ent.tamed) then
mokapi.remove_mob(ent)
kitz.remove_mob(ent)
end
end
end

View File

@ -12,6 +12,6 @@ minetest.register_chatcommand("clear_mobs", {
if not player_pos then
return
end
mokapi.clear_mobs(player_pos, modname)
kitz.clear_mobs(player_pos, modname)
end,
})

4
kitz/api/api_consts.lua Normal file
View File

@ -0,0 +1,4 @@
kitz.consts = {}
kitz.consts.DEFAULT_MAX_HEAR_DISTANCE = 5
kitz.consts.DEFAULT_FEED_RATE = 0.3
kitz.consts.DEFAULT_FEED_COUNT = 5

15
kitz/api/api_cron.lua Normal file
View File

@ -0,0 +1,15 @@
function kitz.cron_clear(cron_time, modname)
if cron_time > 0 then
minetest.after(cron_time, function()
kitz.cron_clear_mobs(cron_time, modname)
end, cron_time, modname)
end
end
function kitz.cron_clear_mobs(cron_time, modname)
for _, player in ipairs(minetest.get_connected_players()) do
local player_pos = player:get_pos()
kitz.clear_mobs(player_pos, modname)
end
kitz.cron_clear(cron_time, modname)
end

View File

@ -1,7 +1,7 @@
--
--Helper funtions
--
function mokapi.drop_velocity(obj)
function kitz.drop_velocity(obj)
obj:set_velocity({
x = math.random(-10, 10) / 9,
y = 6,
@ -9,9 +9,9 @@ function mokapi.drop_velocity(obj)
})
end
function mokapi.drop_object(obj)
function kitz.drop_object(obj)
if obj and obj:get_luaentity() then
mokapi.drop_velocity(obj)
kitz.drop_velocity(obj)
elseif obj then
obj:remove() -- item does not exist
end
@ -20,7 +20,7 @@ end
--
--Functions
--
function mokapi.drop_item(self, item_stack)
function kitz.drop_item(self, item_stack)
if not item_stack then
return
end
@ -31,10 +31,10 @@ function mokapi.drop_item(self, item_stack)
pos = self:get_pos()
end
local obj = minetest.add_item(pos, item_stack)
mokapi.drop_object(obj)
kitz.drop_object(obj)
end
function mokapi.drop_items(self, killed_by_player)
function kitz.drop_items(self, killed_by_player)
if not self.drops or #self.drops == 0 then -- check for nil or no drops
return
end
@ -52,13 +52,13 @@ function mokapi.drop_items(self, killed_by_player)
elseif self.drops[n].min ~= 0 then
obj = minetest.add_item(pos, ItemStack(item .. " " .. num))
end
mokapi.drop_object(obj)
kitz.drop_object(obj)
end
end
self.drops = {}
end
function mokapi.node_drop_items(pos)
function kitz.node_drop_items(pos)
local meta = minetest.get_meta(pos)
if not meta then
return
@ -75,7 +75,7 @@ function mokapi.node_drop_items(pos)
if drops[n].min ~= 0 then
obj = minetest.add_item(pos, ItemStack(item .. " " .. num))
end
mokapi.drop_object(obj)
kitz.drop_object(obj)
end
end
end

View File

@ -1,8 +1,8 @@
function mokapi.feed(self, clicker, feed_rate, msg_full_health, sound_type)
function kitz.feed(self, clicker, feed_rate, msg_full_health, sound_type)
local fed = false
local wielded_item = clicker:get_wielded_item()
local wielded_item_name = wielded_item:get_name()
if mokapi.item_in_itemlist(wielded_item_name, self.follow) then -- Can eat/tame with item in hand
if kitz.item_in_itemlist(wielded_item_name, self.follow) then -- Can eat/tame with item in hand
fed = true
local creative_mode = minetest.settings:get_bool("creative_mode")
if creative_mode == false then -- if not in creative, take item
@ -10,25 +10,25 @@ function mokapi.feed(self, clicker, feed_rate, msg_full_health, sound_type)
clicker:set_wielded_item(wielded_item)
end
--Feed-->
mokapi.set_health(self, feed_rate or mokapi.consts.DEFAULT_FEED_RATE)
kitz.set_health(self, feed_rate or kitz.consts.DEFAULT_FEED_RATE)
if self.hp >= self.max_hp then
self.hp = self.max_hp
if msg_full_health then
minetest.chat_send_player(clicker:get_player_name(), msg_full_health)
end
end
self.food_count = mobkit.remember(self, "food_count", self.food_count + 1) --increase the food count
self.food_count = kitz.remember(self, "food_count", self.food_count + 1) --increase the food count
if sound_type then
mobkit.make_sound(self, sound_type)
kitz.make_sound(self, sound_type)
end
end
return fed
end
function mokapi.tame(self, feed_count, owner_name, msg_tamed, limit)
function kitz.tame(self, feed_count, owner_name, msg_tamed, limit)
local tamed = false
if self.food_count >= (feed_count or mokapi.consts.DEFAULT_FEED_COUNT) then
self.food_count = mobkit.remember(self, "food_count", 0) --reset
if self.food_count >= (feed_count or kitz.consts.DEFAULT_FEED_COUNT) then
self.food_count = kitz.remember(self, "food_count", 0) --reset
if self.tamed == false then --if not tamed
local limit_reached = false
if limit and (limit.max >= 0) then
@ -40,37 +40,37 @@ function mokapi.tame(self, feed_count, owner_name, msg_tamed, limit)
end
if not limit_reached then
tamed = true
mokapi.set_owner(self, owner_name)
kitz.set_owner(self, owner_name)
if msg_tamed then
minetest.chat_send_player(owner_name, msg_tamed)
end
mobkit.clear_queue_high(self) -- clear behaviour (i.e. it was running away)
kitz.clear_queue_high(self) -- clear behaviour (i.e. it was running away)
end
end
end
return tamed
end
function mokapi.set_owner(self, owner_name)
self.tamed = mobkit.remember(self, "tamed", true)
self.owner = mobkit.remember(self, "owner", owner_name)
function kitz.set_owner(self, owner_name)
self.tamed = kitz.remember(self, "tamed", true)
self.owner = kitz.remember(self, "owner", owner_name)
end
function mokapi.remove_owner(self)
self.tamed = mobkit.remember(self, "tamed", false)
self.owner = mobkit.remember(self, "owner", nil)
function kitz.remove_owner(self)
self.tamed = kitz.remember(self, "tamed", false)
self.owner = kitz.remember(self, "owner", nil)
end
--Calculate heal/hurt hunger
function mokapi.set_health(self, rate)
function kitz.set_health(self, rate)
if rate > 1.0 then
rate = 1.0
end
local hp_amount = math.abs(self.max_hp * rate)
if rate >= 0 then
mobkit.heal(self, hp_amount)
kitz.heal(self, hp_amount)
else
mobkit.hurt(self, hp_amount)
kitz.hurt(self, hp_amount)
end
end

View File

@ -1,4 +1,4 @@
function mokapi.item_in_itemlist(item_name, itemlist)
function kitz.item_in_itemlist(item_name, itemlist)
local match = false
local table = false
if type(itemlist) == "table" then
@ -32,9 +32,9 @@ function mokapi.item_in_itemlist(item_name, itemlist)
end
end
function mokapi.remove_mob(self)
function kitz.remove_mob(self)
--IMPORTANT: Firstly: Delete Behaviours
mobkit.clear_queue_high(self)
mobkit.clear_queue_low(self)
kitz.clear_queue_high(self)
kitz.clear_queue_low(self)
self.object:remove()
end

11
kitz/api/api_log.lua Normal file
View File

@ -0,0 +1,11 @@
local _id = 0
function kitz.logon_mob(self)
_id = _id + 1
kitz.active_mobs[_id] = self.object
self._id = _id
end
function kitz.logout_mob(self)
kitz.active_mobs[self._id] = nil
end

View File

@ -1,4 +1,4 @@
function mokapi.delimit_number(number, range)
function kitz.delimit_number(number, range)
if not tonumber(number) then
return nil
end
@ -10,34 +10,34 @@ function mokapi.delimit_number(number, range)
return number
end
function mokapi.round(x)
function kitz.round(x)
return x>=0 and math.floor(x+0.5) or math.ceil(x-0.5)
end
--Trigonometric Functions
--converts yaw to degrees
function mokapi.degrees(yaw)
function kitz.degrees(yaw)
return(yaw * 180.0 / math.pi)
end
function mokapi.degrees_to_radians(degrees)
function kitz.degrees_to_radians(degrees)
return(degrees/180.0*math.pi)
end
--converts yaw to degrees
function mokapi.yaw_to_degrees(yaw)
function kitz.yaw_to_degrees(yaw)
return(yaw*180.0/math.pi)
end
--rounds it up to an integer
function mokapi.degree_round(degree)
function kitz.degree_round(degree)
return(degree + 0.5 - (degree + 0.5) % 1)
end
--turns radians into degrees - not redundant
--doesn't add math.pi
function mokapi.radians_to_degrees(radians)
function kitz.radians_to_degrees(radians)
return(radians*180.0/math.pi)
end

View File

@ -2,7 +2,7 @@
--Replace Engine
--
function mokapi.replace(self, sound_name, max_hear_distance)
function kitz.replace(self, sound_name, max_hear_distance)
if not self.replace_rate or not self.replace_what or self.child == true or self.object:get_velocity().y ~= 0
or math.random(1, self.replace_rate) > 1 then
return false
@ -23,8 +23,8 @@ function mokapi.replace(self, sound_name, max_hear_distance)
if #minetest.find_nodes_in_area(pos, pos, what) > 0 then
minetest.set_node(pos, {name = with})
if sound_name then
mokapi.make_sound("object", self.object, sound_name, max_hear_distance
or mokapi.consts.DEFAULT_MAX_HEAR_DISTANCE)
kitz.make_sound("object", self.object, sound_name, max_hear_distance
or kitz.consts.DEFAULT_MAX_HEAR_DISTANCE)
end
return true
else

View File

@ -2,7 +2,7 @@
--Sound System
--
function mokapi.make_misc_sound(self, chance, max_hear_distance)
function kitz.make_misc_sound(self, chance, max_hear_distance)
if self.muted == true then
return
end
@ -15,19 +15,19 @@ function mokapi.make_misc_sound(self, chance, max_hear_distance)
else
misc_sound = self.sounds['misc']
end
mokapi.make_sound("object", self.object, misc_sound, max_hear_distance or mokapi.consts.DEFAULT_MAX_HEAR_DISTANCE)
kitz.make_sound("object", self.object, misc_sound, max_hear_distance or kitz.consts.DEFAULT_MAX_HEAR_DISTANCE)
end
end
end
function mokapi.make_sound(dest_type, dest, soundfile, max_hear_distance)
function kitz.make_sound(dest_type, dest, soundfile, max_hear_distance)
if dest_type == "object" then
minetest.sound_play(soundfile, {object = dest, gain = 0.5, max_hear_distance = max_hear_distance or mokapi.consts.DEFAULT_MAX_HEAR_DISTANCE,})
minetest.sound_play(soundfile, {object = dest, gain = 0.5, max_hear_distance = max_hear_distance or kitz.consts.DEFAULT_MAX_HEAR_DISTANCE,})
elseif dest_type == "player" then
local player_name = dest:get_player_name()
--minetest.chat_send_player("singleplayer", player_name..tostring(max_hear_distance))
minetest.sound_play(soundfile, {to_player = player_name, gain = 0.5, max_hear_distance = max_hear_distance or mokapi.consts.DEFAULT_MAX_HEAR_DISTANCE,})
minetest.sound_play(soundfile, {to_player = player_name, gain = 0.5, max_hear_distance = max_hear_distance or kitz.consts.DEFAULT_MAX_HEAR_DISTANCE,})
elseif dest_type == "pos" then
minetest.sound_play(soundfile, {pos = dest, gain = 0.5, max_hear_distance = max_hear_distance or mokapi.consts.DEFAULT_MAX_HEAR_DISTANCE,})
minetest.sound_play(soundfile, {pos = dest, gain = 0.5, max_hear_distance = max_hear_distance or kitz.consts.DEFAULT_MAX_HEAR_DISTANCE,})
end
end

873
kitz/engine.lua Normal file
View File

@ -0,0 +1,873 @@
-- yaw values:
-- x+ = -pi/2
-- x- = +pi/2
-- z+ = 0
-- z- = -pi
kitz.active_mobs = {}
kitz.gravity = -9.8
kitz.friction = 0.4 -- less is more
local abs = math.abs
local pi = math.pi
local floor = math.floor
local ceil = math.ceil
local random = math.random
local sqrt = math.sqrt
local max = math.max
local min = math.min
local tan = math.tan
local pow = math.pow
local sign = function(x)
return (x<0) and -1 or 1
end
kitz.terminal_velocity = sqrt(2*-kitz.gravity*20) -- 20 meter fall = dead
kitz.safe_velocity = sqrt(2*-kitz.gravity*5) -- 5 m safe fall
local abr = tonumber(minetest.get_mapgen_setting('active_block_range')) or 3
-- UTILITY FUNCTIONS
function kitz.dot(v1,v2)
return v1.x*v2.x+v1.y*v2.y+v1.z*v2.z
end
function kitz.minmax(v,m)
return min(abs(v),m)*sign(v)
end
function kitz.pos_shift(pos,vec) -- vec components can be omitted e.g. vec={y=1}
vec.x=vec.x or 0
vec.y=vec.y or 0
vec.z=vec.z or 0
return {x=pos.x+vec.x,
y=pos.y+vec.y,
z=pos.z+vec.z}
end
function kitz.pos_translate2d(pos,yaw,dist) -- translate pos dist distance in yaw direction
return vector.add(pos,vector.multiply(minetest.yaw_to_dir(yaw),dist))
end
function kitz.is_pos_in_box(pos,bpos,box)
return pos.x > bpos.x+box[1] and pos.x < bpos.x+box[4] and
pos.y > bpos.y+box[2] and pos.y < bpos.y+box[5] and
pos.z > bpos.z+box[3] and pos.z < bpos.z+box[6]
end
-- call this instead if you want feet position.
--[[
function kitz.get_stand_pos(thing) -- thing can be luaentity or objectref.
if type(thing) == 'table' then
return kitz.pos_shift(thing.object:get_pos(),{y=thing.collisionbox[2]+0.01})
elseif type(thing) == 'userdata' then
local colbox = thing:get_properties().collisionbox
return kitz.pos_shift(thing:get_pos(),{y=colbox[2]+0.01})
end
end --]]
function kitz.get_stand_pos(thing) -- thing can be luaentity or objectref.
local pos = {}
local colbox = {}
if type(thing) == 'table' then
pos = thing.object:get_pos()
colbox = thing.object:get_properties().collisionbox
elseif type(thing) == 'userdata' then
pos = thing:get_pos()
colbox = thing:get_properties().collisionbox
else
return false
end
return kitz.pos_shift(pos,{y=colbox[2]+0.01}), pos
end
function kitz.set_acceleration(thing,vec,limit)
limit = limit or 100
if type(thing) == 'table' then thing=thing.object end
vec.x=kitz.minmax(vec.x,limit)
vec.y=kitz.minmax(vec.y,limit)
vec.z=kitz.minmax(vec.z,limit)
thing:set_acceleration(vec)
end
function kitz.nodeatpos(pos)
local node = minetest.get_node_or_nil(pos)
if node then return minetest.registered_nodes[node.name] end
end
function kitz.get_nodename_off(pos,vec)
return minetest.get_node(kitz.pos_shift(pos,vec)).name
end
function kitz.get_node_pos(pos)
return {
x=floor(pos.x+0.5),
y=floor(pos.y+0.5),
z=floor(pos.z+0.5),
}
end
function kitz.get_nodes_in_area(pos1,pos2,full)
local npos1=kitz.get_node_pos(pos1)
local npos2=kitz.get_node_pos(pos2)
local result = {}
local cnt = 0 -- safety
local sx = (pos2.x<pos1.x) and -1 or 1
local sz = (pos2.z<pos1.z) and -1 or 1
local sy = (pos2.y<pos1.y) and -1 or 1
local x=npos1.x-sx
local z=npos1.z-sz
local y=npos1.y-sy
repeat
x=x+sx
z=npos1.z-sz
repeat
z=z+sz
y=npos1.y-sy
repeat
y=y+sy
local pos = {x=x,y=y,z=z}
local node = kitz.nodeatpos(pos)
if node then
if full==true then
result[pos] = node
else
result[node] = true
end
end
cnt=cnt+1
if cnt > 125 then
minetest.chat_send_all('get_nodes_in_area: area too big ')
return result
end
until y==npos2.y
until z==npos2.z
until x==npos2.x
return result
end
function kitz.get_hitbox_bottom(self)
local y = self.collisionbox[2]
local pos = self.object:get_pos()
return {
{x=pos.x+self.collisionbox[1],y=pos.y+y,z=pos.z+self.collisionbox[3]},
{x=pos.x+self.collisionbox[1],y=pos.y+y,z=pos.z+self.collisionbox[6]},
{x=pos.x+self.collisionbox[4],y=pos.y+y,z=pos.z+self.collisionbox[3]},
{x=pos.x+self.collisionbox[4],y=pos.y+y,z=pos.z+self.collisionbox[6]},
}
end
function kitz.get_node_height(pos)
local npos = kitz.get_node_pos(pos)
local node = kitz.nodeatpos(npos)
if node == nil then return nil end
if node.walkable then
if node.drawtype == 'nodebox' then
if node.node_box and node.node_box.type == 'fixed' then
if type(node.node_box.fixed[1]) == 'number' then
return npos.y + node.node_box.fixed[5] ,0, false
elseif type(node.node_box.fixed[1]) == 'table' then
return npos.y + node.node_box.fixed[1][5] ,0, false
else
return npos.y + 0.5,1, false -- todo handle table of boxes
end
elseif node.node_box and node.node_box.type == 'leveled' then
return minetest.get_node_level(pos)/64-0.5+kitz.get_node_pos(pos).y, 0, false
else
return npos.y + 0.5,1, false -- the unforeseen
end
else
return npos.y+0.5,1, false -- full node
end
else
local liquidflag = false
if node.drawtype == 'liquid' then liquidflag = true end
return npos.y-0.5,-1,liquidflag
end
end
-- get_terrain_height
-- steps(optional) number of recursion steps; default=3
-- dir(optional) is 1=up, -1=down, 0=both; default=0
-- liquidflag(forbidden) never provide this parameter.
function kitz.get_terrain_height(pos,steps,dir,liquidflag) --dir is 1=up, -1=down, 0=both
steps = steps or 3
dir = dir or 0
local h,f,l = kitz.get_node_height(pos)
if h == nil then return nil end
if l then liquidflag = true end
if f==0 then
return h, liquidflag
end
if dir==0 or dir==f then
steps = steps - 1
if steps <=0 then return nil end
return kitz.get_terrain_height(kitz.pos_shift(pos,{y=f}),steps,f,liquidflag)
else
return h, liquidflag
end
end
function kitz.get_spawn_pos_abr(dtime,intrvl,radius,chance,reduction)
dtime = min(dtime,0.1)
local plyrs = minetest.get_connected_players()
intrvl=1/intrvl
if random()<dtime*(intrvl*#plyrs) then
local plyr = plyrs[random(#plyrs)] -- choose random player
local vel = plyr:get_player_velocity()
local spd = vector.length(vel)
chance = (1-chance) * 1/(spd*0.75+1)
local yaw
if spd > 1 then
-- spawn in the front arc
yaw = minetest.dir_to_yaw(vel) + random()*0.35 - 0.75
else
-- random yaw
yaw = random()*pi*2 - pi
end
local pos = plyr:get_pos()
local dir = vector.multiply(minetest.yaw_to_dir(yaw),radius)
local pos2 = vector.add(pos,dir)
pos2.y=pos2.y-5
local height, liquidflag = kitz.get_terrain_height(pos2,32)
if height then
local objs = minetest.get_objects_inside_radius(pos,radius*1.1)
for _,obj in ipairs(objs) do -- count mobs in abrange
if not obj:is_player() then
local lua = obj:get_luaentity()
if lua and lua.name ~= '__builtin:item' then
chance=chance + (1-chance)*reduction -- chance reduced for every mob in range
end
end
end
if chance < random() then
pos2.y = height
objs = minetest.get_objects_inside_radius(pos2,radius*0.95)
for _,obj in ipairs(objs) do -- do not spawn if another player around
if obj:is_player() then return end
end
return pos2, liquidflag
end
end
end
end
function kitz.turn2yaw(self,tyaw,rate)
tyaw = tyaw or 0 --temp
rate = rate or 6
local yaw = self.object:get_yaw()
yaw = yaw+pi
tyaw=(tyaw+pi)%(pi*2)
local step=min(self.dtime*rate,abs(tyaw-yaw)%(pi*2))
local dir = abs(tyaw-yaw)>pi and -1 or 1
dir = tyaw>yaw and dir*1 or dir * -1
local nyaw = (yaw+step*dir)%(pi*2)
self.object:set_yaw(nyaw-pi)
if nyaw==tyaw then return true, nyaw-pi
else return false, nyaw-pi end
end
function kitz.dir_to_rot(v,rot)
rot = rot or {x=0,y=0,z=0}
return {x = (v.x==0 and v.y==0 and v.z==0) and rot.x or math.atan2(v.y,vector.length({x=v.x,y=0,z=v.z})),
y = (v.x==0 and v.z==0) and rot.y or minetest.dir_to_yaw(v),
z=rot.z}
end
function kitz.rot_to_dir(rot) -- keep rot within <-pi/2,pi/2>
local dir = minetest.yaw_to_dir(rot.y)
dir.y = dir.y+tan(rot.x)*vector.length(dir)
return vector.normalize(dir)
end
function kitz.isnear2d(p1,p2,thresh)
if abs(p2.x-p1.x) < thresh and abs(p2.z-p1.z) < thresh then
return true
else
return false
end
end
-- object has reached the destination if dest is in the rear half plane.
function kitz.is_there_yet2d(pos,dir,dest) -- obj positon; facing vector; destination position
local c = -dir.x*pos.x-dir.z*pos.z -- the constant
if dir.z > 0 then
return dest.z <= (-dir.x*dest.x - c)/dir.z -- line equation
elseif dir.z < 0 then
return dest.z >= (-dir.x*dest.x - c)/dir.z
elseif dir.x > 0 then
return dest.x <= (-dir.z*dest.z - c)/dir.x
elseif dir.x < 0 then
return dest.x >= (-dir.z*dest.z - c)/dir.x
else
return false
end
end
function kitz.isnear3d(p1,p2,thresh)
if abs(p2.x-p1.x) < thresh and abs(p2.z-p1.z) < thresh and abs(p2.y-p1.y) < thresh then
return true
else
return false
end
end
function kitz.get_box_intersect_cols(pos,box)
local pmin = {x=floor(pos.x+box[1]+0.5),z=floor(pos.z+box[3]+0.5)}
local pmax = {x=floor(pos.x+box[4]+0.5),z=floor(pos.z+box[6]+0.5)}
result= {}
for x=pmin.x,pmax.x do
for z=pmin.z,pmax.z do
table.insert(result,{x=x,z=z})
end
end
return result
end
function kitz.get_box_displace_cols(pos,box,vec,dist)
local result = {{}}
-- front facing corner pos and neighbors
local fpos = {pos.y}
local xpos={pos.y}
local zpos={pos.y}
local xoff=nil
local zoff=nil
if vec.x < 0 then
fpos.x = pos.x+box[1] -- frontmost corner's x
xoff = box[4]-box[1] -- edge offset along x
else
fpos.x = pos.x+box[4]
xoff = box[1]-box[4]
end
if vec.z < 0 then
fpos.z = pos.z+box[3] -- frontmost corner's z
zoff = box[6]-box[3] -- edge offset along z
else
fpos.z = pos.z+box[6]
zoff = box[3]-box[6]
end
-- displacement vector
if dist then vec = vector.multiply(vector.normalize(vec),dist) end
-- traverse x
local xsgn = sign(vec.x)
local zsgn = sign(zoff)
local index=0
for x = floor(fpos.x+0.5)+xsgn*0.5, fpos.x+vec.x, xsgn do
index=index+1
if index > 50 then return result end
result[index] = result[index] or {}
local zcomp = vec.x == 0 and 0 or fpos.z + (x-fpos.x)*vec.z/vec.x -- z component at the intersection of x and node edge
for z = floor(zcomp+0.5), floor(zcomp+zoff+0.5), zsgn do
table.insert(result[index],{x=x+xsgn*0.5,z=z})
end
end
-- traverse z
local zsgn = sign(vec.z)
local xsgn = sign(xoff)
index=0
for z = floor(fpos.z + 0.5)+zsgn*0.5, fpos.z+vec.z, zsgn do
index=index+1
if index > 50 then return result end
result[index] = result[index] or {}
local xcomp = vec.z == 0 and 0 or fpos.x + (z-fpos.z)*vec.x/vec.z
for x = floor(xcomp+0.5), floor(xcomp+xoff+0.5), xsgn do
table.insert(result[index],{x=x,z=z+zsgn*0.5})
end
end
return result
end
function kitz.get_box_height(thing)
if type(thing) == 'table' then thing = thing.object end
local colbox = thing:get_properties().collisionbox
local height
if colbox then height = colbox[5]-colbox[2]
else height = 0.1 end
return height > 0 and height or 0.1
end
function kitz.is_alive(thing) -- thing can be luaentity or objectref.
-- if not thing then return false end
if not kitz.exists(thing) then return false end
if type(thing) == 'table' then return thing.hp > 0 end
if thing:is_player() then return thing:get_hp() > 0
else
local lua = thing:get_luaentity()
local hp = lua and lua.hp or nil
return hp and hp > 0
end
end
function kitz.exists(thing)
if not thing then return false end
if type(thing) == 'table' then thing=thing.object end
if type(thing) == 'userdata' then
if thing:is_player() then
if thing:get_look_horizontal() then return true end
else
if thing:get_yaw() then return true end
end
end
end
function kitz.hurt(luaent,dmg)
if not luaent then return false end
if type(luaent) == 'table' then
luaent.hp = max((luaent.hp or 0) - dmg,0)
end
end
function kitz.heal(luaent,dmg)
if not luaent then return false end
if type(luaent) == 'table' then
luaent.hp = min(luaent.max_hp,(luaent.hp or 0) + dmg)
end
end
function kitz.animate(self,anim)
if self.animation and self.animation[anim] then
if self._anim == anim then return end
self._anim=anim
local aparms = {}
if #self.animation[anim] > 0 then
aparms = self.animation[anim][random(#self.animation[anim])]
else
aparms = self.animation[anim]
end
aparms.frame_blend = aparms.frame_blend or 0
self.object:set_animation(aparms.range,aparms.speed,aparms.frame_blend,aparms.loop)
else
self._anim = nil
end
end
function kitz.make_sound(self, sound)
local spec = self.sounds and self.sounds[sound]
local param_table = {object=self.object}
if type(spec) == 'table' then
--pick random sound if it's a spec for random sounds
if #spec > 0 then spec = spec[random(#spec)] end
--returns value or a random value within the range [value[1], value[2])
local function in_range(value)
return type(value) == 'table' and value[1]+random()*(value[2]-value[1]) or value
end
--pick random values within a range if they're a table
param_table.gain = in_range(spec.gain)
param_table.fade = in_range(spec.fade)
param_table.pitch = in_range(spec.pitch)
return minetest.sound_play(spec.name, param_table)
end
return minetest.sound_play(spec, param_table)
end
function kitz.go_forward_horizontal(self,speed) -- sets velocity in yaw direction, y component unaffected
local y = self.object:get_velocity().y
local yaw = self.object:get_yaw()
local vel = vector.multiply(minetest.yaw_to_dir(yaw),speed)
vel.y = y
self.object:set_velocity(vel)
end
function kitz.drive_to_pos(self,tpos,speed,turn_rate,dist)
local pos=self.object:get_pos()
dist = dist or 0.2
if kitz.isnear2d(pos,tpos,dist) then return true end
local tyaw = minetest.dir_to_yaw(vector.direction(pos,tpos))
kitz.turn2yaw(self,tyaw,turn_rate)
kitz.go_forward_horizontal(self,speed)
return false
end
function kitz.timer(self,s) -- returns true approx every s seconds
local t1 = floor(self.time_total)
local t2 = floor(self.time_total+self.dtime)
if t2>t1 and t2%s==0 then return true end
end
-- Memory functions.
-- Stuff in memory is serialized, never try to remember objectrefs.
function kitz.remember(self,key,val)
self.memory[key]=val
return val
end
function kitz.forget(self,key)
self.memory[key] = nil
end
function kitz.recall(self,key)
return self.memory[key]
end
-- Queue functions
function kitz.queue_high(self,func,priority)
local maxprty = kitz.get_queue_priority(self)
if priority > maxprty then
kitz.clear_queue_low(self)
end
for i,f in ipairs(self.hqueue) do
if priority > f.prty then
table.insert(self.hqueue,i,{func=func,prty=priority})
return
end
end
table.insert(self.hqueue,{func=func,prty=priority})
end
function kitz.queue_low(self,func)
table.insert(self.lqueue,func)
end
function kitz.is_queue_empty_low(self)
if #self.lqueue == 0 then return true
else return false end
end
function kitz.clear_queue_high(self)
self.hqueue = {}
end
function kitz.clear_queue_low(self)
self.lqueue = {}
end
function kitz.get_queue_priority(self)
if #self.hqueue > 0 then
return self.hqueue[1].prty
else return 0 end
end
function kitz.is_queue_empty_high(self)
if #self.hqueue == 0 then return true
else return false end
end
function kitz.get_nearby_player(self) -- returns random player if nearby or nil
local pos = self.object:get_pos()
local range = self.view_range * 0.5
for _, obj in ipairs(minetest.get_connected_players()) do
if kitz.is_alive(obj) then
local opos = obj:get_pos()
local odist = abs(opos.x-pos.x) + abs(opos.z-pos.z)
if odist <= range then
return obj
end
end
end
return
end
function kitz.get_nearby_entity(self,name) -- returns random nearby entity of name or nil
for _,obj in ipairs(kitz.active_mobs) do
if kitz.is_alive(obj) and obj:get_luaentity().name == name then return obj end
end
return
end
function kitz.get_closest_entity(self, name) --returns closest entity of name or nil
local cobj = nil
local dist = abr*64
local pos = self.object:get_pos()
for _, obj in ipairs(kitz.active_mobs) do
local luaent = obj:get_luaentity()
if kitz.is_alive(obj) and luaent and luaent.name == name then
local opos = obj:get_pos()
local odist = abs(opos.x-pos.x) + abs(opos.z-pos.z)
if odist < dist then
dist=odist
cobj=obj
end
end
end
return cobj
end
local function execute_queues(self)
--Execute hqueue
if #self.hqueue > 0 then
local func = self.hqueue[1].func
if func(self) then
table.remove(self.hqueue,1)
self.lqueue = {}
end
end
-- Execute lqueue
if #self.lqueue > 0 then
local func = self.lqueue[1]
if func(self) then
table.remove(self.lqueue,1)
end
end
end
local function sensors()
local timer = 2
local pulse = 1
return function(self)
timer=timer-self.dtime
if timer < 0 then
pulse = pulse + 1 -- do full range every fifteenth scan
local range = self.view_range
if pulse > 15 then
pulse = 1
else
range = self.view_range*0.5
end
local pos = self.object:get_pos()
--local tim = minetest.get_us_time()
--minetest.chat_send_all(minetest.get_us_time()-tim)
timer=2
end
end
end
------------
-- CALLBACKS
------------
function kitz.default_brain(self)
if kitz.is_queue_empty_high(self) then kitz.hq_roam(self,0) end
end
function kitz.physics(self)
local vel=self.object:get_velocity()
local vnew = vector.new(vel)
-- dumb friction
if self.isonground and not self.isinliquid then
vnew = vector.new(vel.x> 0.2 and vel.x*kitz.friction or 0,
vel.y,
vel.z > 0.2 and vel.z*kitz.friction or 0)
end
-- bounciness
if self.springiness and self.springiness > 0 then
if colinfo and colinfo.collides then
for _,c in ipairs(colinfo.collisions) do
if c.old_velocity[c.axis] > 0.1 then
vnew[c.axis] = vnew[c.axis] * self.springiness * -1
end
end
elseif not colinfo then -- MT 5.2 and earlier
for _,k in ipairs({'y','z','x'}) do
if vel[k]==0 and abs(self.lastvelocity[k])> 0.1 then
vnew[k]=-self.lastvelocity[k]*self.springiness
end
end
end
end
self.object:set_velocity(vnew)
-- buoyancy
local surface = nil
local surfnodename = nil
local spos = kitz.get_stand_pos(self)
spos.y = spos.y+0.01
-- get surface height
local snodepos = kitz.get_node_pos(spos)
local surfnode = kitz.nodeatpos(spos)
while surfnode and surfnode.drawtype == 'liquid' do
surfnodename = surfnode.name
surface = snodepos.y+0.5
if surface > spos.y+self.height then break end
snodepos.y = snodepos.y+1
surfnode = kitz.nodeatpos(snodepos)
end
self.isinliquid = surfnodename
if surface then -- standing in liquid
-- self.isinliquid = true
local submergence = min(surface-spos.y,self.height)/self.height
-- local balance = self.buoyancy*self.height
local buoyacc = kitz.gravity*(self.buoyancy-submergence)
kitz.set_acceleration(self.object,
{x=-vel.x*self.water_drag,y=buoyacc-vel.y*abs(vel.y)*0.4,z=-vel.z*self.water_drag})
else
-- self.isinliquid = false
self.object:set_acceleration({x=0,y=kitz.gravity,z=0})
end
end
function kitz.vitals(self)
-- vitals: fall damage
local vel = self.object:get_velocity()
local velocity_delta = abs(self.lastvelocity.y - vel.y)
if velocity_delta > kitz.safe_velocity then
self.hp = self.hp - floor(self.max_hp * min(1, velocity_delta/kitz.terminal_velocity))
end
-- vitals: oxygen
if self.lung_capacity then
local colbox = self.object:get_properties().collisionbox
local headnode = kitz.nodeatpos(kitz.pos_shift(self.object:get_pos(),{y=colbox[5]})) -- node at hitbox top
if headnode and headnode.drawtype == 'liquid' then
self.oxygen = self.oxygen - self.dtime
else
self.oxygen = self.lung_capacity
end
if self.oxygen <= 0 then self.hp=0 end -- drown
end
end
function kitz.statfunc(self)
local tmptab={}
tmptab.memory = self.memory
tmptab.hp = self.hp
tmptab.texture_no = self.texture_no
return minetest.serialize(tmptab)
end
function kitz.actfunc(self, staticdata, dtime_s)
kitz.logon_mob(self)
self.active_time = 0
self.logic = self.logic or self.brainfunc
self.physics = self.physics or kitz.physics
self.lqueue = {}
self.hqueue = {}
self.nearby_players = {}
self.pos_history = {}
self.path_dir = 1
self.time_total = 0
self.water_drag = self.water_drag or 1
local sdata = minetest.deserialize(staticdata)
if sdata then
for k,v in pairs(sdata) do
self[k] = v
end
end
if self.textures==nil then
local prop_tex = self.object:get_properties().textures
if prop_tex then self.textures=prop_tex end
end
if not self.memory then -- this is the initial activation
self.memory = {}
-- texture variation
if #self.textures > 1 then self.texture_no = random(#self.textures) end
end
if self.timeout and ((self.timeout>0 and dtime_s > self.timeout and next(self.memory)==nil) or
(self.timeout<0 and dtime_s > abs(self.timeout))) then
self.object:remove()
end
-- apply texture
if self.textures and self.texture_no then
local props = {}
props.textures = {self.textures[self.texture_no]}
self.object:set_properties(props)
end
--hp
self.max_hp = self.max_hp or 10
self.hp = self.hp or self.max_hp
--armor
if type(self.armor_groups) ~= 'table' then
self.armor_groups={}
end
self.armor_groups.immortal = 1
self.object:set_armor_groups(self.armor_groups)
self.buoyancy = self.buoyancy or 0
self.oxygen = self.oxygen or self.lung_capacity
self.lastvelocity = {x=0,y=0,z=0}
self.sensefunc=sensors()
end
function kitz.stepfunc(self,dtime,colinfo) -- not intended to be modified
self.dtime = min(dtime,0.2)
self.colinfo = colinfo
self.height = kitz.get_box_height(self)
-- physics comes first
local vel = self.object:get_velocity()
if colinfo then
self.isonground = colinfo.touching_ground
else
if self.lastvelocity.y==0 and vel.y==0 then
self.isonground = true
else
self.isonground = false
end
end
self:physics()
if self.logic then
if self.view_range then self:sensefunc() end
self:logic()
execute_queues(self)
end
self.lastvelocity = self.object:get_velocity()
self.time_total=self.time_total+self.dtime
end
-- load example behaviors
dofile(minetest.get_modpath("kitz") .. "/engine_behaviors.lua")
minetest.register_on_mods_loaded(function()
local mbkfuns = ''
for n,f in pairs(kitz) do
if type(f) == 'function' then
mbkfuns = mbkfuns .. n .. string.split(minetest.serialize(f),'.lua')[2] or ''
end
end
local crc = minetest.sha1(mbkfuns)
-- dbg(crc)
-- if crc ~= 'a061770008fe9ecf8e1042a227dc3beabd10e481' then
-- minetest.log("error","Mobkit namespace inconsistent, has been modified by other mods.")
-- end
end)

830
kitz/engine_behaviors.lua Normal file
View File

@ -0,0 +1,830 @@
local abs = math.abs
local pi = math.pi
local floor = math.floor
local ceil = math.ceil
local random = math.random
local sqrt = math.sqrt
local max = math.max
local min = math.min
local tan = math.tan
local pow = math.pow
local dbg = minetest.chat_send_all
local abr = tonumber(minetest.get_mapgen_setting('active_block_range')) or 3
local neighbors ={
{x=1,z=0},
{x=1,z=1},
{x=0,z=1},
{x=-1,z=1},
{x=-1,z=0},
{x=-1,z=-1},
{x=0,z=-1},
{x=1,z=-1}
}
function kitz.dir2neighbor(dir)
dir.y=0
dir=vector.round(vector.normalize(dir))
for k,v in ipairs(neighbors) do
if v.x == dir.x and v.z == dir.z then return k end
end
return 1
end
function kitz.neighbor_shift(neighbor,shift) -- int shift: minus is left, plus is right
return (8+neighbor+shift-1)%8+1
end
function kitz.is_neighbor_node_reachable(self,neighbor) -- todo: take either number or pos
local offset = neighbors[neighbor]
local pos=kitz.get_stand_pos(self)
local tpos = kitz.get_node_pos(kitz.pos_shift(pos,offset))
local recursteps = ceil(self.jump_height)+1
local height, liquidflag = kitz.get_terrain_height(tpos,recursteps)
if height and abs(height-pos.y) <= self.jump_height then
tpos.y = height
height = height - pos.y
-- don't cut corners
if neighbor % 2 == 0 then -- diagonal neighbors are even
local n2 = neighbor-1 -- left neighbor never < 0
offset = neighbors[n2]
local t2 = kitz.get_node_pos(kitz.pos_shift(pos,offset))
local h2 = kitz.get_terrain_height(t2,recursteps)
if h2 and h2 - pos.y > 0.02 then return end
n2 = (neighbor+1)%8 -- right neighbor
offset = neighbors[n2]
t2 = kitz.get_node_pos(kitz.pos_shift(pos,offset))
h2 = kitz.get_terrain_height(t2,recursteps)
if h2 and h2 - pos.y > 0.02 then return end
end
-- check headroom
if tpos.y+self.height-pos.y > 1 then -- if head in next node above, else no point checking headroom
local snpos = kitz.get_node_pos(pos)
local pos1 = {x=pos.x,y=snpos.y+1,z=pos.z} -- current pos plus node up
local pos2 = {x=tpos.x,y=tpos.y+self.height,z=tpos.z} -- target head pos
local nodes = kitz.get_nodes_in_area(pos1,pos2,true)
for p,node in pairs(nodes) do
if snpos.x==p.x and snpos.z==p.z then
if node.name=='ignore' or node.walkable then return end
else
if node.name=='ignore' or
(node.walkable and kitz.get_node_height(p)>tpos.y+0.001) then return end
end
end
end
return height, tpos, liquidflag
else
return
end
end
function kitz.get_next_waypoint(self,tpos)
local pos = kitz.get_stand_pos(self)
local dir=vector.direction(pos,tpos)
local neighbor = kitz.dir2neighbor(dir)
local function update_pos_history(self,pos)
table.insert(self.pos_history,1,pos)
if #self.pos_history > 2 then table.remove(self.pos_history,#self.pos_history) end
end
local nogopos = self.pos_history[2]
local height, pos2, liquidflag = kitz.is_neighbor_node_reachable(self,neighbor)
if height and not liquidflag
and not (nogopos and kitz.isnear2d(pos2,nogopos,0.1)) then
local heightl = kitz.is_neighbor_node_reachable(self,kitz.neighbor_shift(neighbor,-1))
if heightl and abs(heightl-height)<0.001 then
local heightr = kitz.is_neighbor_node_reachable(self,kitz.neighbor_shift(neighbor,1))
if heightr and abs(heightr-height)<0.001 then
dir.y = 0
local dirn = vector.normalize(dir)
local npos = kitz.get_node_pos(kitz.pos_shift(pos,neighbors[neighbor]))
local factor = abs(dirn.x) > abs(dirn.z) and abs(npos.x-pos.x) or abs(npos.z-pos.z)
pos2=kitz.pos_shift(pos,{x=dirn.x*factor,z=dirn.z*factor})
end
end
update_pos_history(self,pos2)
return height, pos2
else
for i=1,3 do
-- scan left
local height, pos2, liq = kitz.is_neighbor_node_reachable(self,kitz.neighbor_shift(neighbor,-i*self.path_dir))
if height and not liq
and not (nogopos and kitz.isnear2d(pos2,nogopos,0.1)) then
update_pos_history(self,pos2)
return height,pos2
end
-- scan right
height, pos2, liq = kitz.is_neighbor_node_reachable(self,kitz.neighbor_shift(neighbor,i*self.path_dir))
if height and not liq
and not (nogopos and kitz.isnear2d(pos2,nogopos,0.1)) then
update_pos_history(self,pos2)
return height,pos2
end
end
--scan rear
height, pos2, liquidflag = kitz.is_neighbor_node_reachable(self,kitz.neighbor_shift(neighbor,4))
if height and not liquidflag
and not (nogopos and kitz.isnear2d(pos2,nogopos,0.1)) then
update_pos_history(self,pos2)
return height,pos2
end
end
-- stuck condition here
table.remove(self.pos_history,2)
self.path_dir = self.path_dir*-1 -- subtle change in pathfinding
end
function kitz.get_next_waypoint_fast(self,tpos,nogopos)
local pos = kitz.get_stand_pos(self)
local dir=vector.direction(pos,tpos)
local neighbor = kitz.dir2neighbor(dir)
local height, pos2, liquidflag = kitz.is_neighbor_node_reachable(self,neighbor)
if height and not liquidflag then
local fast = false
heightl = kitz.is_neighbor_node_reachable(self,kitz.neighbor_shift(neighbor,-1))
if heightl and abs(heightl-height)<0.001 then
heightr = kitz.is_neighbor_node_reachable(self,kitz.neighbor_shift(neighbor,1))
if heightr and abs(heightr-height)<0.001 then
fast = true
dir.y = 0
local dirn = vector.normalize(dir)
local npos = kitz.get_node_pos(kitz.pos_shift(pos,neighbors[neighbor]))
local factor = abs(dirn.x) > abs(dirn.z) and abs(npos.x-pos.x) or abs(npos.z-pos.z)
pos2=kitz.pos_shift(pos,{x=dirn.x*factor,z=dirn.z*factor})
end
end
return height, pos2, fast
else
for i=1,4 do
-- scan left
height, pos2, liq = kitz.is_neighbor_node_reachable(self,kitz.neighbor_shift(neighbor,-i))
if height and not liq then return height,pos2 end
-- scan right
height, pos2, liq = kitz.is_neighbor_node_reachable(self,kitz.neighbor_shift(neighbor,i))
if height and not liq then return height,pos2 end
end
end
end
function kitz.goto_next_waypoint(self,tpos)
local height, pos2 = kitz.get_next_waypoint(self,tpos)
if not height then return false end
if height <= 0.01 then
local yaw = self.object:get_yaw()
local tyaw = minetest.dir_to_yaw(vector.direction(self.object:get_pos(),pos2))
if abs(tyaw-yaw) > 1 then
kitz.lq_turn2pos(self,pos2)
end
kitz.lq_dumbwalk(self,pos2)
else
kitz.lq_turn2pos(self,pos2)
kitz.lq_dumbjump(self,height)
end
return true
end
----------------------------
-- BEHAVIORS
----------------------------
-- LOW LEVEL QUEUE FUNCTIONS
----------------------------
function kitz.lq_turn2pos(self,tpos)
local func=function(self)
local pos = self.object:get_pos()
return kitz.turn2yaw(self,
minetest.dir_to_yaw(vector.direction(pos,tpos)))
end
kitz.queue_low(self,func)
end
function kitz.lq_idle(self,duration,anim)
anim = anim or 'stand'
local init = true
local func=function(self)
if init then
kitz.animate(self,anim)
init=false
end
duration = duration-self.dtime
if duration <= 0 then return true end
end
kitz.queue_low(self,func)
end
function kitz.lq_dumbwalk(self,dest,speed_factor)
local timer = 3 -- failsafe
speed_factor = speed_factor or 1
local func=function(self)
kitz.animate(self,'walk')
timer = timer - self.dtime
if timer < 0 then return true end
local pos = kitz.get_stand_pos(self)
local y = self.object:get_velocity().y
if kitz.is_there_yet2d(pos,minetest.yaw_to_dir(self.object:get_yaw()),dest) then
-- if kitz.isnear2d(pos,dest,0.25) then
if not self.isonground or abs(dest.y-pos.y) > 0.1 then -- prevent uncontrolled fall when velocity too high
-- if abs(dest.y-pos.y) > 0.1 then -- isonground too slow for speeds > 4
self.object:set_velocity({x=0,y=y,z=0})
end
return true
end
if self.isonground then
local dir = vector.normalize(vector.direction({x=pos.x,y=0,z=pos.z},
{x=dest.x,y=0,z=dest.z}))
dir = vector.multiply(dir,self.max_speed*speed_factor)
-- self.object:set_yaw(minetest.dir_to_yaw(dir))
kitz.turn2yaw(self,minetest.dir_to_yaw(dir))
dir.y = y
self.object:set_velocity(dir)
end
end
kitz.queue_low(self,func)
end
-- initial velocity for jump height h, v= a*sqrt(h*2/a) ,add 20%
function kitz.lq_dumbjump(self,height,anim)
anim = anim or 'stand'
local jump = true
local func=function(self)
local yaw = self.object:get_yaw()
if self.isonground then
if jump then
kitz.animate(self,anim)
local dir = minetest.yaw_to_dir(yaw)
dir.y = -kitz.gravity*sqrt((height+0.35)*2/-kitz.gravity)
self.object:set_velocity(dir)
jump = false
else -- the eagle has landed
return true
end
else
local dir = minetest.yaw_to_dir(yaw)
local vel = self.object:get_velocity()
if self.lastvelocity.y < 0.9 then
dir = vector.multiply(dir,3)
end
dir.y = vel.y
self.object:set_velocity(dir)
end
end
kitz.queue_low(self,func)
end
function kitz.lq_jumpout(self)
local phase = 1
local func=function(self)
local vel=self.object:get_velocity()
if phase == 1 then
vel.y=vel.y+5
self.object:set_velocity(vel)
phase = 2
else
if vel.y < 0 then return true end
local dir = minetest.yaw_to_dir(self.object:get_yaw())
dir.y=vel.y
self.object:set_velocity(dir)
end
end
kitz.queue_low(self,func)
end
function kitz.lq_freejump(self)
local phase = 1
local func=function(self)
local vel=self.object:get_velocity()
if phase == 1 then
vel.y=vel.y+6
self.object:set_velocity(vel)
phase = 2
else
if vel.y <= 0.01 then return true end
local dir = minetest.yaw_to_dir(self.object:get_yaw())
dir.y=vel.y
self.object:set_velocity(dir)
end
end
kitz.queue_low(self,func)
end
function kitz.lq_jumpattack(self,height,target)
local init=true
local timer=0.5
local tgtbox = target:get_properties().collisionbox
local func=function(self)
if not kitz.is_alive(target) then return true end
if self.isonground then
if init then -- collision bug workaround
local vel = self.object:get_velocity()
local dir = minetest.yaw_to_dir(self.object:get_yaw())
dir=vector.multiply(dir,6)
dir.y = -kitz.gravity*sqrt(height*2/-kitz.gravity)
self.object:set_velocity(dir)
kitz.make_sound(self,'charge')
init=false
else
kitz.lq_idle(self,0.3)
return true
end
else
local tgtpos = target:get_pos()
local pos = self.object:get_pos()
-- calculate attack spot
local yaw = self.object:get_yaw()
local dir = minetest.yaw_to_dir(yaw)
local apos = kitz.pos_translate2d(pos,yaw,self.attack.range)
if kitz.is_pos_in_box(apos,tgtpos,tgtbox) then --bite
target:punch(self.object,1,self.attack)
-- bounce off
local vy = self.object:get_velocity().y
self.object:set_velocity({x=dir.x*-3,y=vy,z=dir.z*-3})
-- play attack sound if defined
kitz.make_sound(self,'attack')
return true
end
end
end
kitz.queue_low(self,func)
end
function kitz.lq_fallover(self)
local zrot = 0
local init = true
local func=function(self)
if init then
local vel = self.object:get_velocity()
self.object:set_velocity(kitz.pos_shift(vel,{y=1}))
kitz.animate(self,'stand')
init = false
end
zrot=zrot+pi*0.05
local rot = self.object:get_rotation()
self.object:set_rotation({x=rot.x,y=rot.y,z=zrot})
if zrot >= pi*0.5 then return true end
end
kitz.queue_low(self,func)
end
-----------------------------
-- HIGH LEVEL QUEUE FUNCTIONS
-----------------------------
function kitz.dumbstep(self,height,tpos,speed_factor,idle_duration)
if height <= 0.001 then
kitz.lq_turn2pos(self,tpos)
kitz.lq_dumbwalk(self,tpos,speed_factor)
else
kitz.lq_turn2pos(self,tpos)
kitz.lq_dumbjump(self,height)
end
idle_duration = idle_duration or 6
kitz.lq_idle(self,random(ceil(idle_duration*0.5),idle_duration))
end
function kitz.hq_roam(self,prty)
local func=function(self)
if kitz.is_queue_empty_low(self) and self.isonground then
local pos = kitz.get_stand_pos(self)
local neighbor = random(8)
local height, tpos, liquidflag = kitz.is_neighbor_node_reachable(self,neighbor)
if height and not liquidflag then kitz.dumbstep(self,height,tpos,0.3) end
end
end
kitz.queue_high(self,func,prty)
end
function kitz.hq_follow0(self,tgtobj) -- probably delete this one
local func = function(self)
if not tgtobj then return true end
if kitz.is_queue_empty_low(self) and self.isonground then
local pos = kitz.get_stand_pos(self)
local opos = tgtobj:get_pos()
if vector.distance(pos,opos) > 3 then
local neighbor = kitz.dir2neighbor(vector.direction(pos,opos))
if not neighbor then return true end --temp debug
local height, tpos = kitz.is_neighbor_node_reachable(self,neighbor)
if height then kitz.dumbstep(self,height,tpos)
else
for i=1,4 do --scan left
height, tpos = kitz.is_neighbor_node_reachable(self,(8+neighbor-i-1)%8+1)
if height then kitz.dumbstep(self,height,tpos)
break
end --scan right
height, tpos = kitz.is_neighbor_node_reachable(self,(neighbor+i-1)%8+1)
if height then kitz.dumbstep(self,height,tpos)
break
end
end
end
else
kitz.lq_idle(self,1)
end
end
end
kitz.queue_high(self,func,0)
end
function kitz.hq_follow(self,prty,tgtobj)
local func = function(self)
if not kitz.is_alive(tgtobj) then return true end
if kitz.is_queue_empty_low(self) and self.isonground then
local pos = kitz.get_stand_pos(self)
local opos = tgtobj:get_pos()
if vector.distance(pos,opos) > 3 then
kitz.goto_next_waypoint(self,opos)
else
kitz.lq_idle(self,1)
end
end
end
kitz.queue_high(self,func,prty)
end
function kitz.hq_goto(self,prty,tpos)
local func = function(self)
if kitz.is_queue_empty_low(self) and self.isonground then
local pos = kitz.get_stand_pos(self)
if vector.distance(pos,tpos) > 3 then
kitz.goto_next_waypoint(self,tpos)
else
return true
end
end
end
kitz.queue_high(self,func,prty)
end
function kitz.hq_runfrom(self,prty,tgtobj)
local init=true
local timer=6
local func = function(self)
if not kitz.is_alive(tgtobj) then return true end
if init then
timer = timer-self.dtime
if timer <=0 or vector.distance(self.object:get_pos(),tgtobj:get_pos()) < 8 then
kitz.make_sound(self,'scared')
init=false
end
return
end
if kitz.is_queue_empty_low(self) and self.isonground then
local pos = kitz.get_stand_pos(self)
local opos = tgtobj:get_pos()
if vector.distance(pos,opos) < self.view_range*1.1 then
local tpos = {x=2*pos.x - opos.x,
y=opos.y,
z=2*pos.z - opos.z}
kitz.goto_next_waypoint(self,tpos)
else
self.object:set_velocity({x=0,y=0,z=0})
return true
end
end
end
kitz.queue_high(self,func,prty)
end
function kitz.hq_hunt(self,prty,tgtobj)
local func = function(self)
if not kitz.is_alive(tgtobj) then return true end
if kitz.is_queue_empty_low(self) and self.isonground then
local pos = kitz.get_stand_pos(self)
local opos = tgtobj:get_pos()
local dist = vector.distance(pos,opos)
if dist > self.view_range then
return true
elseif dist > 3 then
kitz.goto_next_waypoint(self,opos)
else
kitz.hq_attack(self,prty+1,tgtobj)
end
end
end
kitz.queue_high(self,func,prty)
end
function kitz.hq_warn(self,prty,tgtobj)
local timer=0
local tgttime = 0
local init = true
local func = function(self)
if not kitz.is_alive(tgtobj) then return true end
if init then
kitz.animate(self,'stand')
init = false
end
local pos = kitz.get_stand_pos(self)
local opos = tgtobj:get_pos()
local dist = vector.distance(pos,opos)
if dist > 11 then
return true
elseif dist < 4 or timer > 12 then -- too close man
-- kitz.clear_queue_high(self)
kitz.remember(self,'hate',tgtobj:get_player_name())
kitz.hq_hunt(self,prty+1,tgtobj) -- priority
else
timer = timer+self.dtime
if kitz.is_queue_empty_low(self) then
kitz.lq_turn2pos(self,opos)
end
-- make noise in random intervals
if timer > tgttime then
kitz.make_sound(self,'warn')
-- if self.sounds and self.sounds.warn then
-- minetest.sound_play(self.sounds.warn, {object=self.object})
-- end
tgttime = timer + 1.1 + random()*1.5
end
end
end
kitz.queue_high(self,func,prty)
end
function kitz.hq_die(self)
local timer = 5
local start = true
local func = function(self)
if start then
kitz.lq_fallover(self)
self.logic = function(self) end -- brain dead as well
start=false
end
timer = timer-self.dtime
if timer < 0 then self.object:remove() end
end
kitz.queue_high(self,func,100)
end
function kitz.hq_attack(self,prty,tgtobj)
local func = function(self)
if not kitz.is_alive(tgtobj) then return true end
if kitz.is_queue_empty_low(self) then
local pos = kitz.get_stand_pos(self)
-- local tpos = tgtobj:get_pos()
local tpos = kitz.get_stand_pos(tgtobj)
local dist = vector.distance(pos,tpos)
if dist > 3 then
return true
else
kitz.lq_turn2pos(self,tpos)
local height = tgtobj:is_player() and 0.35 or tgtobj:get_luaentity().height*0.6
if tpos.y+height>pos.y then
kitz.lq_jumpattack(self,tpos.y+height-pos.y,tgtobj)
else
kitz.lq_dumbwalk(self,kitz.pos_shift(tpos,{x=random()-0.5,z=random()-0.5}))
end
end
end
end
kitz.queue_high(self,func,prty)
end
function kitz.hq_liquid_recovery(self,prty) -- scan for nearest land
local radius = 1
local yaw = 0
local func = function(self)
if not self.isinliquid then return true end
local pos=self.object:get_pos()
local vec = minetest.yaw_to_dir(yaw)
local pos2 = kitz.pos_shift(pos,vector.multiply(vec,radius))
local height, liquidflag = kitz.get_terrain_height(pos2)
if height and not liquidflag then
kitz.hq_swimto(self,prty,pos2)
return true
end
yaw=yaw+pi*0.25
if yaw>2*pi then
yaw = 0
radius=radius+1
if radius > self.view_range then
self.hp = 0
return true
end
end
end
kitz.queue_high(self,func,prty)
end
function kitz.hq_swimto(self,prty,tpos)
local box = self.object:get_properties().collisionbox
local cols = {}
local func = function(self)
if not self.isinliquid then
if self.isonground then return true end
return false
end
local pos = kitz.get_stand_pos(self)
local y=self.object:get_velocity().y
local pos2d = {x=pos.x,y=tpos.y,z=pos.z}
local dir=vector.normalize(vector.direction(pos2d,tpos))
local yaw = minetest.dir_to_yaw(dir)
if kitz.timer(self,1) then
cols = kitz.get_box_displace_cols(pos,box,dir,1)
for _,p in ipairs(cols[1]) do
p.y=pos.y
local h,l = kitz.get_terrain_height(p)
if h and h>pos.y and self.isinliquid then
kitz.lq_freejump(self)
break
end
end
elseif kitz.turn2yaw(self,yaw) then
dir.y = y
self.object:set_velocity(dir)
end
end
kitz.queue_high(self,func,prty)
end
---------------------
-- AQUATIC
---------------------
-- MACROS
local function aqua_radar_dumb(pos,yaw,range,reverse)
range = range or 4
local function okpos(p)
local node = kitz.nodeatpos(p)
if node then
if node.drawtype == 'liquid' then
local nodeu = kitz.nodeatpos(kitz.pos_shift(p,{y=1}))
local noded = kitz.nodeatpos(kitz.pos_shift(p,{y=-1}))
if (nodeu and nodeu.drawtype == 'liquid') or (noded and noded.drawtype == 'liquid') then
return true
else
return false
end
else
local h,l = kitz.get_terrain_height(p)
if h then
local node2 = kitz.nodeatpos({x=p.x,y=h+1.99,z=p.z})
if node2 and node2.drawtype == 'liquid' then return true, h end
else
return false
end
end
else
return false
end
end
local fpos = kitz.pos_translate2d(pos,yaw,range)
local ok,h = okpos(fpos)
if not ok then
local ffrom, fto, fstep
if reverse then
ffrom, fto, fstep = 3,1,-1
else
ffrom, fto, fstep = 1,3,1
end
for i=ffrom, fto, fstep do
local ok,h = okpos(kitz.pos_translate2d(pos,yaw+i,range))
if ok then return yaw+i,h end
ok,h = okpos(kitz.pos_translate2d(pos,yaw-i,range))
if ok then return yaw-i,h end
end
return yaw+pi,h
else
return yaw, h
end
end
function kitz.is_in_deep(target)
if not target then return false end
local nodepos = kitz.get_stand_pos(target)
local node1 = kitz.nodeatpos(nodepos)
nodepos.y=nodepos.y+1
local node2 = kitz.nodeatpos(nodepos)
nodepos.y=nodepos.y-2
local node3 = kitz.nodeatpos(nodepos)
if node1 and node2 and node3 and node1.drawtype=='liquid' and (node2.drawtype=='liquid' or node3.drawtype=='liquid') then
return true
end
end
-- HQ behaviors
function kitz.hq_aqua_roam(self,prty,speed)
local tyaw = 0
local init = true
local prvscanpos = {x=0,y=0,z=0}
local center = self.object:get_pos()
local func = function(self)
if init then
kitz.animate(self,'def')
init = false
end
local pos = kitz.get_stand_pos(self)
local yaw = self.object:get_yaw()
local scanpos = kitz.get_node_pos(kitz.pos_translate2d(pos,yaw,speed))
if not vector.equals(prvscanpos,scanpos) then
prvscanpos=scanpos
local nyaw,height = aqua_radar_dumb(pos,yaw,speed,true)
if height and height > pos.y then
local vel = self.object:get_velocity()
vel.y = vel.y+1
self.object:set_velocity(vel)
end
if yaw ~= nyaw then
tyaw=nyaw
kitz.hq_aqua_turn(self,prty+1,tyaw,speed)
return
end
end
if kitz.timer(self,1) then
if vector.distance(pos,center) > abr*16*0.5 then
tyaw = minetest.dir_to_yaw(vector.direction(pos,{x=center.x+random()*10-5,y=center.y,z=center.z+random()*10-5}))
else
if random(10)>=9 then tyaw=tyaw+random()*pi - pi*0.5 end
end
end
kitz.turn2yaw(self,tyaw,3)
-- local yaw = self.object:get_yaw()
kitz.go_forward_horizontal(self,speed)
end
kitz.queue_high(self,func,prty)
end
function kitz.hq_aqua_turn(self,prty,tyaw,speed)
local func = function(self)
local finished=kitz.turn2yaw(self,tyaw)
-- local yaw = self.object:get_yaw()
kitz.go_forward_horizontal(self,speed)
if finished then return true end
end
kitz.queue_high(self,func,prty)
end
function kitz.hq_aqua_attack(self,prty,tgtobj,speed)
local tyaw = 0
local prvscanpos = {x=0,y=0,z=0}
local init = true
local tgtbox = tgtobj:get_properties().collisionbox
local func = function(self)
if not kitz.is_alive(tgtobj) then return true end
if init then
kitz.animate(self,'fast')
kitz.make_sound(self,'attack')
init = false
end
local pos = kitz.get_stand_pos(self)
local yaw = self.object:get_yaw()
local scanpos = kitz.get_node_pos(kitz.pos_translate2d(pos,yaw,speed))
if not vector.equals(prvscanpos,scanpos) then
prvscanpos=scanpos
local nyaw,height = aqua_radar_dumb(pos,yaw,speed*0.5)
if height and height > pos.y then
local vel = self.object:get_velocity()
vel.y = vel.y+1
self.object:set_velocity(vel)
end
if yaw ~= nyaw then
tyaw=nyaw
kitz.hq_aqua_turn(self,prty+1,tyaw,speed)
return
end
end
local tpos = tgtobj:get_pos()
local tyaw=minetest.dir_to_yaw(vector.direction(pos,tpos))
kitz.turn2yaw(self,tyaw,3)
local yaw = self.object:get_yaw()
if kitz.timer(self,1) then
if not kitz.is_in_deep(tgtobj) then return true end
local vel = self.object:get_velocity()
if tpos.y>pos.y+0.5 then self.object:set_velocity({x=vel.x,y=vel.y+0.5,z=vel.z})
elseif tpos.y<pos.y-0.5 then self.object:set_velocity({x=vel.x,y=vel.y-0.5,z=vel.z}) end
end
if kitz.is_pos_in_box(kitz.pos_translate2d(pos,yaw,self.attack.range),tpos,tgtbox) then --bite
tgtobj:punch(self.object,1,self.attack)
kitz.hq_aqua_turn(self,prty,yaw-pi,speed)
return true
end
kitz.go_forward_horizontal(self,speed)
end
kitz.queue_high(self,func,prty)
end

View File

@ -1,5 +1,5 @@
mokapi = {} --the global variable
local modname = "mokapi" --the modname
kitz = {} --the global variable
local modname = "kitz" --the modname
local modpath = minetest.get_modpath(modname) --the modpath
--load the apis:
assert(loadfile(modpath.."/api/api_consts.lua"))()
@ -12,3 +12,5 @@ assert(loadfile(modpath.."/api/api_feed_tame.lua"))()
assert(loadfile(modpath.."/api/api_helper_functions.lua"))()
assert(loadfile(modpath.."/api/api_commands.lua"))()
assert(loadfile(modpath.."/api/api_math.lua"))()
assert(loadfile(modpath.."/api/api_log.lua"))()
assert(loadfile(modpath.."/engine.lua"))()

3
kitz/mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = kitz
description = A high level API
depends =

View File

@ -1,4 +0,0 @@
mokapi.consts = {}
mokapi.consts.DEFAULT_MAX_HEAR_DISTANCE = 5
mokapi.consts.DEFAULT_FEED_RATE = 0.3
mokapi.consts.DEFAULT_FEED_COUNT = 5

View File

@ -1,15 +0,0 @@
function mokapi.cron_clear(cron_time, modname)
if cron_time > 0 then
minetest.after(cron_time, function()
mokapi.cron_clear_mobs(cron_time, modname)
end, cron_time, modname)
end
end
function mokapi.cron_clear_mobs(cron_time, modname)
for _, player in ipairs(minetest.get_connected_players()) do
local player_pos = player:get_pos()
mokapi.clear_mobs(player_pos, modname)
end
mokapi.cron_clear(cron_time, modname)
end

View File

@ -1,3 +0,0 @@
name = mokapi
description = A high level API for mobkit
depends = mobkit

View File

@ -13,9 +13,9 @@ petz.breed = function(self, clicker, wielded_item, wielded_item_name)
wielded_item:take_item()
clicker:set_wielded_item(wielded_item)
self.is_rut = true
mobkit.remember(self, "is_rut", self.is_rut)
kitz.remember(self, "is_rut", self.is_rut)
petz.do_particles_effect(self.object, self.object:get_pos(), "heart")
mokapi.make_sound("object", self.object, "petz_"..self.type.."_moaning", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_"..self.type.."_moaning", petz.settings.max_hear_distance)
else
local player_name = clicker:get_player_name()
if self.is_rut then
@ -29,8 +29,8 @@ petz.breed = function(self, clicker, wielded_item, wielded_item_name)
end
local end_pregnancy = function(self)
self.is_pregnant = mobkit.remember(self, "is_pregnant", false)
self.pregnant_time = mobkit.remember(self, "pregnant_time", 0.0)
self.is_pregnant = kitz.remember(self, "is_pregnant", false)
self.pregnant_time = kitz.remember(self, "pregnant_time", 0.0)
end
petz.pony_breed = function(self, clicker, wielded_item, wielded_item_name)
@ -58,8 +58,8 @@ petz.pony_breed = function(self, clicker, wielded_item, wielded_item_name)
local meta = wielded_item:get_meta()
local petz_type = meta:get_string("petz_type")
if not(self.is_pregnant) and self.pregnant_count > 0 and self.type == petz_type then
self.is_pregnant = mobkit.remember(self, "is_pregnant", true)
self.pregnant_count = mobkit.remember(self, "pregnant_count", self.pregnant_count - 1)
self.is_pregnant = kitz.remember(self, "is_pregnant", true)
self.pregnant_count = kitz.remember(self, "pregnant_count", self.pregnant_count - 1)
local max_speed_forward = meta:get_int("max_speed_forward")
local max_speed_reverse = meta:get_int("max_speed_reverse")
local accel = meta:get_int("accel")
@ -67,7 +67,7 @@ petz.pony_breed = function(self, clicker, wielded_item, wielded_item_name)
father_veloc_stats["max_speed_forward"] = max_speed_forward
father_veloc_stats["max_speed_reverse"] = max_speed_reverse
father_veloc_stats["accel"] = accel
self.father_veloc_stats = mobkit.remember(self, "father_veloc_stats", father_veloc_stats)
self.father_veloc_stats = kitz.remember(self, "father_veloc_stats", father_veloc_stats)
petz.do_particles_effect(self.object, self.object:get_pos(), "pregnant".."_"..self.type)
clicker:set_wielded_item("petz:glass_syringe")
end
@ -102,14 +102,14 @@ petz.childbirth = function(self)
local baby = minetest.add_entity(pos, baby_type, minetest.serialize(baby_properties))
if baby then
end_pregnancy(self)
mokapi.make_sound("object", baby, "petz_pop_sound", petz.settings.max_hear_distance)
kitz.make_sound("object", baby, "petz_pop_sound", petz.settings.max_hear_distance)
local baby_entity = baby:get_luaentity()
baby_entity.is_baby = mobkit.remember(baby_entity, "is_baby", true)
baby_entity.is_baby = kitz.remember(baby_entity, "is_baby", true)
if not(self.owner== nil) and not(self.owner== "") then
baby_entity.tamed = true
mobkit.remember(baby_entity, "tamed", baby_entity.tamed)
kitz.remember(baby_entity, "tamed", baby_entity.tamed)
baby_entity.owner = self.owner
mobkit.remember(baby_entity, "owner", baby_entity.owner)
kitz.remember(baby_entity, "owner", baby_entity.owner)
end
return baby_entity
else
@ -118,7 +118,7 @@ petz.childbirth = function(self)
end
petz.pregnant_timer = function(self, dtime)
self.pregnant_time = mobkit.remember(self, "pregnant_time", self.pregnant_time + dtime)
self.pregnant_time = kitz.remember(self, "pregnant_time", self.pregnant_time + dtime)
if self.pregnant_time >= petz.settings.pregnancy_time then
local baby_entity = petz.childbirth(self)
if not baby_entity then
@ -151,25 +151,25 @@ petz.pregnant_timer = function(self, dtime)
new_accel = 10
end
baby_entity.max_speed_forward = new_max_speed_forward
mobkit.remember(baby_entity, "max_speed_forward", baby_entity.max_speed_forward)
kitz.remember(baby_entity, "max_speed_forward", baby_entity.max_speed_forward)
baby_entity.max_speed_reverse = new_max_speed_reverse
mobkit.remember(baby_entity, "max_speed_reverse", baby_entity.max_speed_reverse)
kitz.remember(baby_entity, "max_speed_reverse", baby_entity.max_speed_reverse)
baby_entity.accel = new_accel
mobkit.remember(baby_entity, "accel", baby_entity.accel)
kitz.remember(baby_entity, "accel", baby_entity.accel)
end
end
end
petz.growth_timer = function(self, dtime)
self.growth_time = mobkit.remember(self, "growth_time", (self.growth_time or 0) + dtime)
self.growth_time = kitz.remember(self, "growth_time", (self.growth_time or 0) + dtime)
if self.growth_time >= petz.settings.growth_time then
self.is_baby = mobkit.remember(self, "is_baby", false)
self.is_baby = kitz.remember(self, "is_baby", false)
local pos = self.object:get_pos()
pos.y = pos.y + 1.01 -- grows a litte up
self.object:set_pos(pos)
local obj
if self.parents then -- for chicken only
mokapi.remove_mob(self)
kitz.remove_mob(self)
obj = minetest.add_entity(pos, self.parents[math.random(1, #self.parents)])
else
obj = self.object
@ -183,6 +183,6 @@ petz.growth_timer = function(self, dtime)
local vel = obj:get_velocity()
vel.y=vel.y + 4.0
obj:set_velocity(vel)
mokapi.make_sound("object", obj, "petz_pop_sound", petz.settings.max_hear_distance)
kitz.make_sound("object", obj, "petz_pop_sound", petz.settings.max_hear_distance)
end
end

View File

@ -6,7 +6,7 @@ petz.brush = function(self, wielded_item_name, pet_name)
if not self.brushed then
petz.set_affinity(self, petz.settings.tamagochi_brush_rate)
self.brushed = true
mobkit.remember(self, "brushed", self.brushed)
kitz.remember(self, "brushed", self.brushed)
else
minetest.chat_send_player(self.owner, S("Your").." "..S(pet_name).." "..S("had already been brushed."))
end
@ -14,12 +14,12 @@ petz.brush = function(self, wielded_item_name, pet_name)
if not self.beaver_oil_applied then
petz.set_affinity(self, petz.settings.tamagochi_beaver_oil_rate)
self.beaver_oil_applied = true
mobkit.remember(self, "beaver_oil_applied", self.beaver_oil_applied)
kitz.remember(self, "beaver_oil_applied", self.beaver_oil_applied)
else
minetest.chat_send_player(self.owner, S("Your").." "..S(pet_name).." "..S("had already been spreaded with beaver oil."))
end
end
end
mokapi.make_sound("object", self.object, "petz_brushing", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_brushing", petz.settings.max_hear_distance)
petz.do_particles_effect(self.object, self.object:get_pos(), "star")
end

View File

@ -10,7 +10,7 @@ petz.create_pet = function(placer, itemstack, pet_name, pos)
local mob = minetest.add_entity(pos, pet_name, staticdata)
local self = mob:get_luaentity()
if not(self.is_wild) and not(self.owner) then --not monster and not owner
mokapi.set_owner(self, placer:get_player_name()) --set owner
kitz.set_owner(self, placer:get_player_name()) --set owner
petz.after_tame(self)
end
itemstack:take_item() -- since mob is unique we remove egg once spawned
@ -79,7 +79,7 @@ end
petz.capture = function(self, clicker, put_in_inventory)
self.captured = mobkit.remember(self, "captured", true) --IMPORTANT! mark as captured
self.captured = kitz.remember(self, "captured", true) --IMPORTANT! mark as captured
local new_stack = ItemStack(self.name .. "_set") -- add special mob egg with all mob information
@ -133,6 +133,6 @@ petz.capture = function(self, clicker, put_in_inventory)
petz.set_infotext_behive(meta, honey_count, bee_count)
end
petz.remove_tamed_by_owner(self, false)
mokapi.remove_mob(self)
kitz.remove_mob(self)
return stack_meta
end

View File

@ -17,5 +17,5 @@ petz.colorize = function(self, color)
local overlay_texture = "(petz_"..self.type.."_overlay.png^[colorize:"..color..":125)"
local colorized_texture = background_texture .."^"..overlay_texture
petz.set_properties(self, {textures = {colorized_texture}})
self.colorized = mobkit.remember(self, "colorized", color)
self.colorized = kitz.remember(self, "colorized", color)
end

View File

@ -3,22 +3,22 @@ local S = ...
petz.convert = function(self, player_name)
local old_pet_name = petz.first_to_upper(self.type)
self.convert_count = self.convert_count - 1
mobkit.remember(self, "convert_count", self.convert_count)
kitz.remember(self, "convert_count", self.convert_count)
if self.convert_count <= 0 then
local pos = self.object:get_pos()
local converted_pet = minetest.add_entity(pos, petz.settings[self.type.."_convert_to"])
mokapi.make_sound("object", converted_pet, "petz_pop_sound", petz.settings.max_hear_distance)
kitz.make_sound("object", converted_pet, "petz_pop_sound", petz.settings.max_hear_distance)
local converted_entity = converted_pet:get_luaentity()
converted_entity.tamed = true
mobkit.remember(converted_entity, "tamed", converted_entity.tamed)
kitz.remember(converted_entity, "tamed", converted_entity.tamed)
converted_entity.owner = player_name
mobkit.remember(converted_entity, "owner", converted_entity.owner)
mokapi.remove_mob(self)
kitz.remember(converted_entity, "owner", converted_entity.owner)
kitz.remove_mob(self)
local new_pet_name = petz.first_to_upper(converted_entity.type)
minetest.chat_send_player(player_name , S("The").." "..S(old_pet_name).." "..S("turn into").." "..S(new_pet_name))
else
minetest.chat_send_player(player_name , S("The").." "..S(old_pet_name).." "..S("is turning into another animal")..".")
mokapi.make_sound("object", self.object, "petz_"..self.type.."_moaning", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_"..self.type.."_moaning", petz.settings.max_hear_distance)
petz.do_particles_effect(self.object, self.object:get_pos(), "heart")
end
end

View File

@ -35,17 +35,17 @@ petz.put_dreamcatcher = function(self, clicker, wielded_item, wielded_item_name)
wielded_item:take_item() --quit one from player's inventory
clicker:set_wielded_item(wielded_item)
self.dreamcatcher = true
mobkit.remember(self, "dreamcatcher", self.dreamcatcher)
mokapi.make_sound("object", self.object, "petz_magical_chime", petz.settings.max_hear_distance)
kitz.remember(self, "dreamcatcher", self.dreamcatcher)
kitz.make_sound("object", self.object, "petz_magical_chime", petz.settings.max_hear_distance)
petz.do_particles_effect(self.object, self.object:get_pos(), "dreamcatcher")
end
petz.drop_dreamcatcher = function(self)
if self.dreamcatcher then --drop the dreamcatcher
minetest.add_item(self.object:get_pos(), "petz:dreamcatcher")
mokapi.make_sound("object", self.object, "petz_pop_sound", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_pop_sound", petz.settings.max_hear_distance)
self.dreamcatcher = false
mobkit.remember(self, "dreamcatcher", self.dreamcatcher)
kitz.remember(self, "dreamcatcher", self.dreamcatcher)
end
end
@ -84,7 +84,7 @@ petz.create_form_list_by_owner_dreamcatcher = function(user_name, user_pos)
local pet_pos
local pet_tag
local list_pet = false
if mobkit.is_alive(pet) and pet.dreamcatcher then -- check if alive and has a dreamcatcher
if kitz.is_alive(pet) and pet.dreamcatcher then -- check if alive and has a dreamcatcher
pet_tag = pet.tag
pet_type = pet.type
pet_pos = pet.object:get_pos()

View File

@ -1,5 +1,5 @@
petz.increase_egg_count = function(self)
self.eggs_count = mobkit.remember(self, "eggs_count", self.eggs_count+1)
self.eggs_count = kitz.remember(self, "eggs_count", self.eggs_count+1)
end
--Lay Egg
@ -13,7 +13,7 @@ petz.lay_egg = function(self)
local pos = self.object:get_pos()
if self.type_of_egg == "item" then
local lay_egg_timing = petz.settings.lay_egg_timing
if mobkit.timer(self, math.random(lay_egg_timing - (lay_egg_timing*0.2), lay_egg_timing+ (lay_egg_timing*0.2))) then
if kitz.timer(self, math.random(lay_egg_timing - (lay_egg_timing*0.2), lay_egg_timing+ (lay_egg_timing*0.2))) then
minetest.add_item(pos, "petz:"..self.type.."_egg") --chicken/duck/penguin egg!
petz.increase_egg_count(self)
end

View File

@ -3,16 +3,16 @@
--
function petz.env_damage(self, pos, prty)
local stand_pos= mobkit.get_stand_pos(self)
local stand_node_pos = mobkit.get_node_pos(stand_pos)
local stand_node = mobkit.nodeatpos(stand_node_pos)
local stand_pos= kitz.get_stand_pos(self)
local stand_node_pos = kitz.get_node_pos(stand_pos)
local stand_node = kitz.nodeatpos(stand_node_pos)
local node = minetest.get_node_or_nil(pos)
if (stand_node and (stand_node.groups.igniter))
or (node and (minetest.get_item_group(node.name, "igniter")>0)) then --if fire or lava
mobkit.hurt(self, petz.settings.igniter_damage)
kitz.hurt(self, petz.settings.igniter_damage)
local air_pos = minetest.find_node_near(stand_pos, self.view_range, "air", false)
if air_pos then
mobkit.hq_goto(self, prty, air_pos)
kitz.hq_goto(self, prty, air_pos)
end
end
if self.noxious_nodes then
@ -32,7 +32,7 @@ function petz.env_damage(self, pos, prty)
end
local node = minetest.get_node_or_nil(node_pos)
if node and node.name == noxious_node.name then
mobkit.hurt(self, noxious_node.damage or 1)
kitz.hurt(self, noxious_node.damage or 1)
end
end
end

View File

@ -46,7 +46,7 @@ end
petz.do_feed = function(self)
petz.set_affinity(self, petz.settings.tamagochi_feed_hunger_rate)
self.fed = mobkit.remember(self, "fed", true)
self.fed = kitz.remember(self, "fed", true)
end
petz.after_tame = function(self)
@ -64,9 +64,9 @@ end
petz.do_lashing = function(self)
if not self.lashed then
self.lashed = mobkit.remember(self, "lashed", true)
self.lashed = kitz.remember(self, "lashed", true)
end
mokapi.make_sound("object", self.object, "petz_"..self.type.."_moaning", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_"..self.type.."_moaning", petz.settings.max_hear_distance)
end
petz.tame_whip= function(self, hitter)
@ -76,18 +76,18 @@ petz.tame_whip= function(self, hitter)
--The mob can be tamed lashed with a whip
self.lashing_count = self.lashing_count + 1
if self.lashing_count >= petz.settings.lashing_tame_count then
self.lashing_count = mobkit.remember(self, "lashing_count", 0) --reset to 0
mokapi.set_owner(self, hitter:get_player_name())
self.lashing_count = kitz.remember(self, "lashing_count", 0) --reset to 0
kitz.set_owner(self, hitter:get_player_name())
petz.after_tame(self)
minetest.chat_send_player(self.owner, S("The").." "..S(petz.first_to_upper(self.type)).." "..S("has been tamed."))
mobkit.clear_queue_high(self) -- do not attack
kitz.clear_queue_high(self) -- do not attack
end
else
if (petz.settings.tamagochi_mode) and (self.owner == hitter:get_player_name()) then
petz.do_lashing(self)
end
end
mokapi.make_sound("object", hitter, "petz_whip", petz.settings.max_hear_distance)
kitz.make_sound("object", hitter, "petz_whip", petz.settings.max_hear_distance)
end
end
@ -95,6 +95,6 @@ end
petz.feed_queen_ant = function(self, clicker, player_name, wielded_item)
wielded_item:take_item()
clicker:set_wielded_item(wielded_item)
self.eggs_count = mobkit.remember(self, "eggs_count", 0)
self.eggs_count = kitz.remember(self, "eggs_count", 0)
minetest.chat_send_player(player_name, S("The Queen Ant will produce more eggs."))
end

View File

@ -298,25 +298,25 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
elseif fields.btn_guard then
petz.guard(pet)
elseif fields.btn_ownthing then
mobkit.clear_queue_low(pet)
kitz.clear_queue_low(pet)
petz.ownthing(pet)
elseif fields.btn_alight then
petz.alight(pet, 0, "stand")
elseif fields.btn_fly then
mobkit.clear_queue_low(pet)
mobkit.clear_queue_high(pet)
kitz.clear_queue_low(pet)
kitz.clear_queue_high(pet)
pet.status = nil
petz.hq_fly(pet, 0)
minetest.after(2.5, function()
if mobkit.is_alive(pet) then
mobkit.clear_queue_low(pet)
if kitz.is_alive(pet) then
kitz.clear_queue_low(pet)
pet.object:set_acceleration({ x = 0, y = 0, z = 0 })
pet.object:set_velocity({ x = 0, y = 0, z = 0 })
end
end, pet)
elseif fields.btn_perch_shoulder then
petz.standhere(pet)
mobkit.animate(pet, "stand")
kitz.animate(pet, "stand")
local shoulder_pos
if pet.type == "parrot" then
shoulder_pos = {x= 0.5, y= -6.25, z=0}
@ -326,15 +326,15 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
pet.object:set_attach(player, "Arm_Left", shoulder_pos, {x=0, y=0, z=180})
pet.object:set_properties({physical = false,})
minetest.after(120.0, function()
if mobkit.is_alive(pet) then
if kitz.is_alive(pet) then
pet.object:set_detach()
pet.object:set_properties({physical = true,})
end
end, pet)
elseif fields.btn_muted then
pet.muted= mobkit.remember(pet, "muted", minetest.is_yes(fields.btn_muted))
pet.muted= kitz.remember(pet, "muted", minetest.is_yes(fields.btn_muted))
elseif fields.btn_show_tag then
pet.show_tag = mobkit.remember(pet, "show_tag", minetest.is_yes(fields.btn_show_tag))
pet.show_tag = kitz.remember(pet, "show_tag", minetest.is_yes(fields.btn_show_tag))
elseif fields.btn_dreamcatcher then
petz.drop_dreamcatcher(pet)
elseif fields.btn_saddlebag then
@ -362,28 +362,28 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
elseif fields.btn_abandon then
minetest.show_formspec(player_name, "petz:abandon_form", petz.get_abandon_confirmation())
elseif fields.btn_herding then
pet.herding = mobkit.remember(pet, "herding", minetest.is_yes(fields.btn_herding))
pet.herding = kitz.remember(pet, "herding", minetest.is_yes(fields.btn_herding))
elseif fields.chk_for_sale then
pet.for_sale = mobkit.remember(pet, "for_sale", minetest.is_yes(fields.chk_for_sale))
pet.for_sale = kitz.remember(pet, "for_sale", minetest.is_yes(fields.chk_for_sale))
elseif fields.fld_exchange_item_amount or fields.txtlst_exchange_items then
local event = minetest.explode_textlist_event(fields.txtlst_exchange_items)
if event.type == "CHG" then
--minetest.chat_send_all(event.index)
pet.exchange_item_index = mobkit.remember(pet, "exchange_item_index", event.index)
pet.exchange_item_index = kitz.remember(pet, "exchange_item_index", event.index)
end
pet.exchange_item_amount = mobkit.remember(pet, "exchange_item_amount", mokapi.delimit_number( tonumber(fields.fld_exchange_item_amount), {min=1, max=99}) or 1)
pet.exchange_item_amount = kitz.remember(pet, "exchange_item_amount", kitz.delimit_number( tonumber(fields.fld_exchange_item_amount), {min=1, max=99}) or 1)
elseif fields.btn_buy then
petz.buy(pet, player, _context[player_name].seller)
elseif fields.btn_back_home then
pet.back_home= mobkit.remember(pet, "back_home", minetest.is_yes(fields.btn_back_home))
pet.back_home= kitz.remember(pet, "back_home", minetest.is_yes(fields.btn_back_home))
elseif fields.btn_set_home then
pet.home_pos= mobkit.remember(pet, "home_pos", pet.object:get_pos())
pet.home_pos= kitz.remember(pet, "home_pos", pet.object:get_pos())
create_context(player_name, 3)
minetest.show_formspec(player_name, "petz:form_orders", petz.create_form(player_name, false))
end
if fields.ipt_name then
pet.tag = minetest.formspec_escape(string.sub(fields.ipt_name, 1 , 12))
mobkit.remember(pet, "tag", pet.tag)
kitz.remember(pet, "tag", pet.tag)
if not(pet.tag == "") then
petz.insert_tamed_by_owner(pet)
else
@ -416,7 +416,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
itemstacks_table[i] = inv:get_stack("saddlebag", i):to_table()
end
ent.saddlebag_inventory = itemstacks_table
mobkit.remember(ent, "saddlebag_inventory", itemstacks_table)
kitz.remember(ent, "saddlebag_inventory", itemstacks_table)
end
end
return true
@ -527,7 +527,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
local player_name = player:get_player_name()
local pet = petz.pet[player_name]
if pet and (mobkit.is_alive(pet)) then
if pet and (kitz.is_alive(pet)) then
create_context(player_name, 1)
minetest.show_formspec(player_name, "petz:form_orders", petz.create_form(player_name, false))
end
@ -554,7 +554,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local player_name = player:get_player_name()
if fields.btn_yes then
local pet = petz.pet[player_name]
if pet and (mobkit.is_alive(pet)) then
if pet and (kitz.is_alive(pet)) then
local msg = S("You've abandoned your").." "..pet.type
petz.abandon_pet(pet, msg)
end

View File

@ -25,7 +25,7 @@ end
function petz.isinliquid(self)
local pos = self.object:get_pos()
pos.y = pos.y - 0.5
local node = mobkit.nodeatpos(pos)
local node = kitz.nodeatpos(pos)
if node and node.drawtype == 'liquid' then
return true
else

View File

@ -9,8 +9,8 @@ petz.put_horseshoe = function(self, clicker)
wielded_item:take_item()
clicker:set_wielded_item(wielded_item)
petz.horseshoes_inc_speed(self)
mokapi.make_sound("object", self.object, "petz_put_sound", petz.settings.max_hear_distance)
mokapi.make_sound("object", self.object, "petz_"..self.type.."_moaning", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_put_sound", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_"..self.type.."_moaning", petz.settings.max_hear_distance)
end
petz.speedup_change = function(self, speedup)
@ -33,7 +33,7 @@ petz.horseshoes_inc_speed = function(self)
speedup = self.horseshoes * petz.settings.horseshoe_speedup
petz.speedup_change(self, -speedup)
end
self.horseshoes = mobkit.remember(self, "horseshoes", (self.horseshoes+1)) --now inc the horseshoes
self.horseshoes = kitz.remember(self, "horseshoes", (self.horseshoes+1)) --now inc the horseshoes
speedup = self.horseshoes * petz.settings.horseshoe_speedup --new speedup
petz.speedup_change(self, speedup)
end
@ -48,9 +48,9 @@ petz.horseshoes_reset = function(self)
local pos = self.object:get_pos()
for i = 1, self.horseshoes do
obj = minetest.add_item(pos, "petz:horseshoe")
mokapi.drop_velocity(obj)
kitz.drop_velocity(obj)
end
self.horseshoes = mobkit.remember(self, "horseshoes", 0)
mokapi.make_sound("object", self.object, "petz_pop_sound", petz.settings.max_hear_distance)
self.horseshoes = kitz.remember(self, "horseshoes", 0)
kitz.make_sound("object", self.object, "petz_pop_sound", petz.settings.max_hear_distance)
end

View File

@ -146,7 +146,7 @@ end
petz.load_vars = function(self)
for key, value in pairs(petz.dyn_prop) do
self[key] = mobkit.recall(self, key) or value["default"]
self[key] = kitz.recall(self, key) or value["default"]
end
if not(self.sleep_start_time) or not(self.sleep_end_time) then
petz.calculate_sleep_times(self)
@ -185,17 +185,17 @@ function petz.set_initial_properties(self, staticdata, dtime_s)
--Define some settings ->
--Set a random gender for all the mobs (not defined in the entity definition)
if (self.is_male == nil) then
self.is_male = mobkit.remember(self, "is_male", petz.set_random_gender())
self.is_male = kitz.remember(self, "is_male", petz.set_random_gender())
end
if self.is_mountable then
if not(baby_born) then
self.max_speed_forward= mobkit.remember(self, "max_speed_forward", math.random(2, 4)) --set a random velocity for walk and run
self.max_speed_reverse= mobkit.remember(self, "max_speed_reverse", math.random(1, 2))
self.accel= mobkit.remember(self, "accel", math.random(2, 4))
self.max_speed_forward= kitz.remember(self, "max_speed_forward", math.random(2, 4)) --set a random velocity for walk and run
self.max_speed_reverse= kitz.remember(self, "max_speed_reverse", math.random(1, 2))
self.accel= kitz.remember(self, "accel", math.random(2, 4))
end
end
if self.parents then --for chicken only
self.is_baby = mobkit.remember(self, "is_baby", true)
self.is_baby = kitz.remember(self, "is_baby", true)
end
--Mobs that can have babies
if self.breed then
@ -235,7 +235,7 @@ function petz.set_initial_properties(self, staticdata, dtime_s)
self.genes["gen2"] = mutation_gen
self.texture_no = mutation_gen
end
mobkit.remember(self, "genes", self.genes)
kitz.remember(self, "genes", self.genes)
end
--ALL the mobs
--Get a texture
@ -253,7 +253,7 @@ function petz.set_initial_properties(self, staticdata, dtime_s)
end
end
if petz.settings[self.type.."_convert_count"] then
self.convert_count = mobkit.remember(self, "convert_count", petz.settings[self.type.."_convert_count"])
self.convert_count = kitz.remember(self, "convert_count", petz.settings[self.type.."_convert_count"])
end
if self.init_tamagochi_timer then
petz.init_tamagochi_timer(self)
@ -280,7 +280,7 @@ function petz.set_initial_properties(self, staticdata, dtime_s)
--3. CAPTURED MOBS
--
else
self.captured = mobkit.remember(self, "captured", false) --IMPORTANT! mark as not captured
self.captured = kitz.remember(self, "captured", false) --IMPORTANT! mark as not captured
for key, value in pairs(petz.dyn_prop) do
local prop_value
if value["type"] == "string" then
@ -294,26 +294,26 @@ function petz.set_initial_properties(self, staticdata, dtime_s)
elseif value["type"] == "player" then
prop_value = nil
end
self[key] = mobkit.remember(self, key, prop_value) or value["default"]
self[key] = kitz.remember(self, key, prop_value) or value["default"]
end
end
--Custom textures
if captured_mob or self.breed then
local texture= petz.compose_texture(self) --compose the texture
mobkit.remember(self, "texture_no", self.texture_no)
kitz.remember(self, "texture_no", self.texture_no)
petz.set_properties(self, {textures = {texture}})
end
if self.type == "bee" and self.queen then --delay to create beehive
minetest.after(math.random(120, 150), function()
if mobkit.is_alive(self.object) then
self.create_beehive = mobkit.remember(self, "create_beehive", true)
if kitz.is_alive(self.object) then
self.create_beehive = kitz.remember(self, "create_beehive", true)
end
end, self)
elseif self.type == "ant" and self.ant_type == "queen" then
minetest.after(math.random(120, 150), function()
if mobkit.is_alive(self.object) then
self.create_anthill = mobkit.remember(self, "create_anthill", true)
if kitz.is_alive(self.object) then
self.create_anthill = kitz.remember(self, "create_anthill", true)
end
end, self)
end
@ -324,8 +324,8 @@ function petz.set_initial_properties(self, staticdata, dtime_s)
end
--DELETE THIS BLOCK IN THE NEXT UPDATE -- FOR COMPATIBIITY PURPOSES FOR OLD CHICKENS ONLY>>>
if self.type == "chicken" then
self.is_baby = mobkit.remember(self, "is_baby", true)
self.texture_no = mobkit.remember(self, "texture_no", 1)
self.is_baby = kitz.remember(self, "is_baby", true)
self.texture_no = kitz.remember(self, "texture_no", 1)
petz.set_properties(self, {textures = {self.textures[1]}})
end
--<<<
@ -334,7 +334,7 @@ function petz.set_initial_properties(self, staticdata, dtime_s)
end
if self.breed then
if baby_born then
self.is_baby = mobkit.remember(self, "is_baby", true)
self.is_baby = kitz.remember(self, "is_baby", true)
end
if self.is_baby then
petz.set_properties(self, {

View File

@ -22,11 +22,11 @@ petz.lifetime_timer = function(self, lifetime, on_step_time)
if math.random(1, 2) == 1 then
variability = -variability
end
lifetime = mokapi.round(lifetime - variability)
self.lifetime = mobkit.remember(self, "lifetime", lifetime)
lifetime = kitz.round(lifetime - variability)
self.lifetime = kitz.remember(self, "lifetime", lifetime)
end
--minetest.chat_send_all(tostring(self.lifetime))
self.lifetime = mobkit.remember(self, "lifetime", self.lifetime - on_step_time)
self.lifetime = kitz.remember(self, "lifetime", self.lifetime - on_step_time)
if self.lifetime <= 0 then
petz.on_die(self)
end

View File

@ -15,14 +15,14 @@ petz.mount = function(self, clicker, wielded_item, wielded_item_name)
if self.wagon then
petz.animate_wagon(self, "stand")
end
mobkit.clear_queue_low(self)
mobkit.clear_queue_high(self)
mobkit.animate(self, "still")
kitz.clear_queue_low(self)
kitz.clear_queue_high(self)
kitz.animate(self, "still")
return false
elseif (self.saddle or self.saddlebag or self.wagon) and wielded_item_name == petz.settings.shears then
if self.wagon then
self.wagon:remove()
mokapi.drop_item(self, ItemStack("petz:wagon 1"))
kitz.drop_item(self, ItemStack("petz:wagon 1"))
self.wagon = nil
end
petz.free_saddles(self)
@ -57,14 +57,14 @@ petz.put_saddle = function(self, clicker, wielded_item, wielded_item_name)
if wielded_item_name == "petz:saddle" then
saddle_type = "saddle"
self.saddle = true
mobkit.remember(self, "saddle", self.saddle)
kitz.remember(self, "saddle", self.saddle)
if self.saddlebag then
another_saddle = "^petz_"..self.type.."_saddlebag.png"
end
else
saddle_type = "saddlebag"
self.saddlebag = true
mobkit.remember(self, "saddlebag", self.saddlebag)
kitz.remember(self, "saddlebag", self.saddlebag)
if self.saddle then
another_saddle = "^petz_"..self.type.."_saddle.png"
end
@ -74,5 +74,5 @@ petz.put_saddle = function(self, clicker, wielded_item, wielded_item_name)
petz.set_properties(self, {textures = {texture}})
wielded_item:take_item()
clicker:set_wielded_item(wielded_item)
mokapi.make_sound("object", self.object, "petz_put_sound", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_put_sound", petz.settings.max_hear_distance)
end

View File

@ -1,3 +1,4 @@
function petz.on_deactivate(self)
kitz.logout_mob(self)
petz.dreamcatcher_save_metadata(self)
end

View File

@ -3,7 +3,7 @@
--
petz.on_die = function(self)
self.dead = mobkit.remember(self, "dead", true) --a variable, useful to avoid functions
self.dead = kitz.remember(self, "dead", true) --a variable, useful to avoid functions
if self.object:get_hp() > 0 then --you can call this function directally
self.object:set_hp(0)
end
@ -13,7 +13,7 @@ petz.on_die = function(self)
petz.free_saddles(self)
--Drop horseshoes-->
if self.horseshoes and self.horseshoes > 0 then
mokapi.drop_item(self, ItemStack("petz:horseshoe".." "..tostring(self.horseshoes)))
kitz.drop_item(self, ItemStack("petz:horseshoe".." "..tostring(self.horseshoes)))
end
--If mounted, force unmount-->
if self.driver then
@ -43,8 +43,8 @@ petz.on_die = function(self)
props.collisionbox[2] = props.collisionbox[1] - 0.0625
self.object:set_properties({collisionbox=props.collisionbox})
--Drop Items-->
mokapi.drop_items(self, self.was_killed_by_player or nil)
mobkit.clear_queue_high(self)
kitz.drop_items(self, self.was_killed_by_player or nil)
kitz.clear_queue_high(self)
--Remove the owner entry for right_click formspec and close the formspec (it could be opened)-->
if petz.pet[self.owner] then
petz.pet[self.owner]= nil
@ -55,7 +55,7 @@ petz.on_die = function(self)
petz.remove_tamed_by_owner(self, false)
end
--Make Sound-->
mobkit.make_sound(self, 'die')
kitz.make_sound(self, 'die')
--Particles Effect
if petz.settings.death_effect then
minetest.add_particlespawner({
@ -76,8 +76,8 @@ petz.on_die = function(self)
texture = "petz_smoke.png",
})
end
--To finish, the Mobkit Die Function-->
mobkit.hq_die(self)
--To finish, the Kitz Die Function-->
kitz.hq_die(self)
end
petz.was_killed_by_player = function(self, puncher)

View File

@ -47,7 +47,7 @@ end
function petz.on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
local pos = self.object:get_pos() --pos of the petz
if not(mobkit.is_alive(self)) then --is petz is died
if not(kitz.is_alive(self)) then --is petz is died
return
end
--Do not punch when you are mounted on it!!!-->
@ -86,7 +86,7 @@ function petz.on_punch(self, puncher, time_from_last_punch, tool_capabilities, d
end
--Do Hurt-->
local damage = petz.calculate_damage(self, time_from_last_punch, tool_capabilities)
mobkit.hurt(self, damage)
kitz.hurt(self, damage)
--Tamagochi Mode?-->
petz.punch_tamagochi(self, puncher) --decrease affinity when in Tamagochi mode
--Check if killed by player and save it-->
@ -96,7 +96,7 @@ function petz.on_punch(self, puncher, time_from_last_punch, tool_capabilities, d
--Kickback-->
petz.kick_back(self, dir)
--Sound-->
mokapi.make_sound("object", self.object, "petz_default_punch", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_default_punch", petz.settings.max_hear_distance)
--Blood-->
petz.blood(self)
--Unmount?-->
@ -110,7 +110,7 @@ function petz.on_punch(self, puncher, time_from_last_punch, tool_capabilities, d
--Warn Attack?-->
if self.is_wild and not(self.tamed) and not(self.attack_player) then --if you hit it, will attack player
self.warn_attack = true
mobkit.clear_queue_high(self)
kitz.clear_queue_high(self)
end
--Monster Specific-->
if self.type == "mr_pumpkin" then --teleport to player's back
@ -119,7 +119,7 @@ function petz.on_punch(self, puncher, time_from_last_punch, tool_capabilities, d
if (self.hp <= self.max_hp / 2) then
petz.bh_teleport(self, pos, puncher, puncher:get_pos())
else
mokapi.make_sound("object", self.object, "petz_fireball", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_fireball", petz.settings.max_hear_distance)
petz.spawn_throw_object(self.object, 20, "petz:ent_jack_o_lantern_grenade")
end
end

View File

@ -35,8 +35,8 @@ petz.on_rightclick = function(self, clicker)
and ((wielded_item_name == "petz:hairbrush") or (wielded_item_name == "petz:beaver_oil")) then
petz.brush(self, wielded_item_name, pet_name)
--If feeded
elseif mokapi.feed(self, clicker, petz.settings.tamagochi_feed_hunger_rate, S("@1 at full health (@2)", S(petz.first_to_upper(self.type)), tostring(self.hp)), "moaning") then
if mokapi.tame(self, 5, player_name, S("@1 has been tamed!", S(petz.first_to_upper(self.type))), {max = petz.settings.max_tamed_by_owner, count= petz.count_tamed_by_owner(player_name), msg = S("You cannot tame more petz! (@1 max.)", tostring(petz.settings.max_tamed_by_owner))}) then
elseif kitz.feed(self, clicker, petz.settings.tamagochi_feed_hunger_rate, S("@1 at full health (@2)", S(petz.first_to_upper(self.type)), tostring(self.hp)), "moaning") then
if kitz.tame(self, 5, player_name, S("@1 has been tamed!", S(petz.first_to_upper(self.type))), {max = petz.settings.max_tamed_by_owner, count= petz.count_tamed_by_owner(player_name), msg = S("You cannot tame more petz! (@1 max.)", tostring(petz.settings.max_tamed_by_owner))}) then
petz.after_tame(self)
end
if self.tamed then
@ -48,7 +48,7 @@ petz.on_rightclick = function(self, clicker)
petz.refill(self) --Refill wool, milk or nothing
--convert to
elseif not(petz.str_is_empty(petz.settings[self.type.."_convert"])) and not(petz.str_is_empty(petz.settings[self.type.."_convert_to"]))
and mokapi.item_in_itemlist(wielded_item_name, petz.settings[self.type.."_convert"]) then
and kitz.item_in_itemlist(wielded_item_name, petz.settings[self.type.."_convert"]) then
petz.convert(self, player_name)
elseif petz.check_capture_items(self, wielded_item_name, clicker, true) then
if self.is_pet and (not(privs.server) and (not(petz.settings.rob_mobs) and (not(self.tamed) or (self.owner and self.owner ~= player_name)))) then
@ -56,7 +56,7 @@ petz.on_rightclick = function(self, clicker)
return
end
if self.owner== nil or self.owner== "" or (not(is_owner) and petz.settings.rob_mobs) then
mokapi.set_owner(self, player_name)
kitz.set_owner(self, player_name)
petz.after_tame(self)
end
petz.capture(self, clicker, true)

View File

@ -1,6 +1,6 @@
petz.on_step = function(self, dtime)
local on_step_time = 1
if mobkit.timer(self, on_step_time) and not(self.dead) then --Only check every 1 sec, not every step!
if kitz.timer(self, on_step_time) and not(self.dead) then --Only check every 1 sec, not every step!
if self.init_tamagochi_timer then
petz.init_tamagochi_timer(self)
end
@ -33,7 +33,7 @@ petz.on_step = function(self, dtime)
end
self.tmp_follow_texture = follow_texture --temporary property
end
if mobkit.timer(self, 2) then
if kitz.timer(self, 2) then
if (self.hp / self.max_hp) <= petz.settings.tamagochi_hungry_warning then
petz.do_particles_effect(self.object, self.object:get_pos(), "hungry", self.tmp_follow_texture)
end

View File

@ -1,14 +1,14 @@
petz.ownthing = function(self)
self.status = mobkit.remember(self, "status", nil)
self.status = kitz.remember(self, "status", nil)
if self.can_fly then
petz.hq_wanderfly(self, 0)
elseif self.can_swin and self.isinliquid then
mobkit.hq_aqua_roam(self, 0, self.max_speed)
kitz.hq_aqua_roam(self, 0, self.max_speed)
else
mobkit.hq_roam(self, 0)
kitz.hq_roam(self, 0)
end
mobkit.clear_queue_low(self)
mobkit.clear_queue_high(self)
kitz.clear_queue_low(self)
kitz.clear_queue_high(self)
end
petz.stand = function(self)
@ -17,54 +17,54 @@ petz.stand = function(self)
end
petz.standhere = function(self)
mobkit.clear_queue_high(self)
mobkit.clear_queue_low(self)
kitz.clear_queue_high(self)
kitz.clear_queue_low(self)
if self.can_fly then
if petz.node_name_in(self, "below") == "air" then
mobkit.animate(self, "fly")
kitz.animate(self, "fly")
else
mobkit.animate(self, "stand")
kitz.animate(self, "stand")
end
elseif self.can_swin and petz.isinliquid(self) then
mobkit.animate(self, "def")
kitz.animate(self, "def")
else
if self.animation["sit"] and not(petz.isinliquid(self)) then
mobkit.animate(self, "sit")
kitz.animate(self, "sit")
else
mobkit.animate(self, "stand")
kitz.animate(self, "stand")
end
end
self.status = mobkit.remember(self, "status", "stand")
--mobkit.lq_idle(self, 2400)
self.status = kitz.remember(self, "status", "stand")
--kitz.lq_idle(self, 2400)
petz.stand(self)
end
petz.guard = function(self)
self.status = mobkit.remember(self, "status", "guard")
mobkit.clear_queue_high(self)
self.status = kitz.remember(self, "status", "guard")
kitz.clear_queue_high(self)
petz.stand(self)
end
petz.follow = function(self, player)
mobkit.clear_queue_low(self)
mobkit.clear_queue_high(self)
self.status = mobkit.remember(self, "status", "follow")
kitz.clear_queue_low(self)
kitz.clear_queue_high(self)
self.status = kitz.remember(self, "status", "follow")
if self.can_fly then
mobkit.animate(self, "fly")
kitz.animate(self, "fly")
petz.hq_followliquidair(self, 100, player)
elseif self.can_swin and self.isinliquid then
mobkit.animate(self, "def")
kitz.animate(self, "def")
petz.hq_followliquidair(self, 100, player)
else
mobkit.hq_follow(self, 100, player)
kitz.hq_follow(self, 100, player)
end
end
petz.alight = function(self, prty, end_status)
mobkit.clear_queue_low(self)
mobkit.clear_queue_high(self)
kitz.clear_queue_low(self)
kitz.clear_queue_high(self)
if not(petz.node_name_in(self, "below") == "air") then
mobkit.animate(self, "fly")
kitz.animate(self, "fly")
end
petz.hq_alight(self, prty, end_status)
end

View File

@ -1,21 +1,21 @@
-- Saddlebag API functions
local function free_saddlebag(self)
mokapi.drop_item(self, ItemStack("petz:saddlebag"))
kitz.drop_item(self, ItemStack("petz:saddlebag"))
--Drop the items from petz inventory
local inv = self.saddlebag_inventory
for key, value in pairs(inv) do
mokapi.drop_item(self, ItemStack(value))
kitz.drop_item(self, ItemStack(value))
end
self.saddlebag = mobkit.remember(self, "saddlebag", false)
self.saddlebag = kitz.remember(self, "saddlebag", false)
self.saddlebag_inventory = {} --clear inventory
mokapi.make_sound("object", self.object, "petz_pop_sound", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_pop_sound", petz.settings.max_hear_distance)
end
local function free_saddle(self)
mokapi.drop_item(self, ItemStack("petz:saddle"))
self.saddle = mobkit.remember(self, "saddle", false)
mokapi.make_sound("object", self.object, "petz_pop_sound", petz.settings.max_hear_distance)
kitz.drop_item(self, ItemStack("petz:saddle"))
self.saddle = kitz.remember(self, "saddle", false)
kitz.make_sound("object", self.object, "petz_pop_sound", petz.settings.max_hear_distance)
end
function petz.free_saddles(self)

View File

@ -34,6 +34,6 @@ petz.buy = function(self, buyer, _seller_name)
petz.force_detach(self.driver)
end
petz.abandon_pet(self, S("You have sold your").." "..self.type.." "..S("to").." "..buyer_name..".")
mokapi.set_owner(self, buyer_name)
kitz.set_owner(self, buyer_name)
minetest.chat_send_player(buyer_name, S("Congratulations, you've bought a").." "..self.type)
end

View File

@ -163,7 +163,7 @@ minetest.register_craft({
petz.init_convert_to_chrysalis = function(self)
minetest.after(math.random(1200, 1500), function()
if not(mobkit.is_alive(self)) then
if not(kitz.is_alive(self)) then
return
end
local pos = self.object:get_pos()
@ -171,13 +171,13 @@ petz.init_convert_to_chrysalis = function(self)
return
end
minetest.set_node(pos, {name= "petz:cocoon"})
mokapi.remove_mob(self)
kitz.remove_mob(self)
end, self)
end
petz.init_lay_eggs = function(self)
minetest.after(math.random(150, 240), function()
if not(mobkit.is_alive(self)) then
if not(kitz.is_alive(self)) then
return
end
if self.eggs_count > 0 then
@ -185,7 +185,7 @@ petz.init_lay_eggs = function(self)
end
petz.alight(self, 0, "stand")
minetest.after(10.0, function()
if not(mobkit.is_alive(self)) then
if not(kitz.is_alive(self)) then
return
end
local pos = self.object:get_pos()
@ -206,7 +206,7 @@ petz.init_lay_eggs = function(self)
end
if spawn_egg then
minetest.set_node(pos, {name= "petz:silkworm_eggs"})
self.eggs_count = mobkit.remember(self, "eggs_count", (self.eggs_count+1)) --increase the count of eggs
self.eggs_count = kitz.remember(self, "eggs_count", (self.eggs_count+1)) --increase the count of eggs
else
petz.init_lay_eggs(self) --reinit the timer, to try to lay eggs later
end

View File

@ -28,8 +28,8 @@ petz.calculate_sleep_times = function(self)
sleep_start_time = math.random(day_start, sleep_end_time_limit - sleep_time)
sleep_end_time = sleep_start_time + sleep_time
end
self.sleep_start_time = mobkit.remember(self, "sleep_start_time", sleep_start_time)
self.sleep_end_time = mobkit.remember(self, "sleep_end_time", sleep_end_time)
self.sleep_start_time = kitz.remember(self, "sleep_start_time", sleep_start_time)
self.sleep_end_time = kitz.remember(self, "sleep_end_time", sleep_end_time)
--minetest.chat_send_player("singleplayer", "sleep_time="..tostring(sleep_time).."/sleep_start_time="..tostring(sleep_start_time).."/sleep_end_time="..tostring(sleep_end_time))
end
end
@ -61,8 +61,8 @@ petz.bh_sleep = function(self, prty)
end
petz.sleep = function(self, prty, force)
self.status = mobkit.remember(self, "status", "sleep")
mobkit.animate(self, 'sleep')
self.status = kitz.remember(self, "status", "sleep")
kitz.animate(self, 'sleep')
local texture = self.textures[self.texture_no]
self.object:set_properties(self, {textures = {texture.."^petz_"..self.type.."_sleep.png"}}) --sleeping eyes
petz.hq_sleep(self, prty, force)
@ -87,10 +87,10 @@ function petz.hq_sleep(self, prty, force)
if (self.status == "sleep") and timer < 0 --check if status did not change
and (self.sleep_at_night and not(petz.is_night())) or (self.sleep_at_day and petz.is_night())
or (timeofday < sleep_start_time) or (timeofday > sleep_end_time) then
mobkit.clear_queue_high(self) --awake
kitz.clear_queue_high(self) --awake
local texture = self.textures[self.texture_no]
self.object:set_properties(self, {textures = {texture}}) --quit sleeping eyes
self.status = mobkit.remember(self, "status", nil)
self.status = kitz.remember(self, "status", nil)
return true
else
petz.do_particles_effect(self.object, self.object:get_pos(), "sleep")
@ -101,5 +101,5 @@ function petz.hq_sleep(self, prty, force)
timer = 2
end
end
mobkit.queue_high(self,func,prty)
kitz.queue_high(self,func,prty)
end

View File

@ -13,9 +13,9 @@ function petz.spawn_is_in_deep(nodepos)
return false
end
nodepos.y = nodepos.y + 1.1
local node_1_above = mobkit.nodeatpos(nodepos)
local node_1_above = kitz.nodeatpos(nodepos)
nodepos.y= nodepos.y + 1
local node_2_above = mobkit.nodeatpos(nodepos)
local node_2_above = kitz.nodeatpos(nodepos)
if (node_1_above and node_1_above.drawtype == 'liquid') and (node_2_above and node_2_above.drawtype == 'liquid') then
return true
else
@ -119,7 +119,7 @@ petz.spawn_mob = function(spawn_pos, limit_max_mobs, abr, liquidflag)
end
end
end
if can_spawn and mokapi.item_in_itemlist(node.name, petz.settings[pet_name.."_spawn_nodes"]) then
if can_spawn and kitz.item_in_itemlist(node.name, petz.settings[pet_name.."_spawn_nodes"]) then
table.insert(candidates_list, pet_name)
end
end --end for
@ -201,10 +201,10 @@ petz.spawn_mob = function(spawn_pos, limit_max_mobs, abr, liquidflag)
end
--[[
if i > 1 then
local height, liquidflag2 = mobkit.get_terrain_height(spawn_pos, 32)
local height, liquidflag2 = kitz.get_terrain_height(spawn_pos, 32)
if height or (liquidflag2 and ent.can_swin) then
local node_below = petz.get_node_below(spawn_pos)
if not(mokapi.item_in_itemlist(node_below.name, petz.settings[random_mob.."_spawn_nodes"])) then
if not(kitz.item_in_itemlist(node_below.name, petz.settings[random_mob.."_spawn_nodes"])) then
spawn = false
end
end
@ -225,7 +225,7 @@ minetest.register_globalstep(function(dtime)
local abr = tonumber(minetest.get_mapgen_setting('active_block_range')) or 3
local radius = abr * 16 --recommended
local interval = petz.settings.spawn_interval
local spawn_pos, liquidflag = mobkit.get_spawn_pos_abr(dtime, interval, radius, petz.settings.spawn_chance, 0.2)
local spawn_pos, liquidflag = kitz.get_spawn_pos_abr(dtime, interval, radius, petz.settings.spawn_chance, 0.2)
if spawn_pos then
petz.spawn_mob(spawn_pos, true, abr, liquidflag)
end
@ -242,7 +242,7 @@ end)
--Get a random pos
--for i = 1, max_mobs do
--local spawn_pos = { x= math.random(minp.x, maxp.x), y = math.random(minp.y, maxp.y)+32, z = math.random(minp.z, maxp.z)}
--local height, liquidflag = mobkit.get_terrain_height(spawn_pos, 32)
--local height, liquidflag = kitz.get_terrain_height(spawn_pos, 32)
--local debug = "spawn pos=".. minetest.pos_to_string(spawn_pos)
--minetest.chat_send_all(debug)
--if height then

View File

@ -56,13 +56,13 @@ petz.attach_squareball = function(self, thing_ent, thing_ref, shooter_name)
self.object:set_attach(thing_ref, "head", {x=-0.0, y=0.5, z=-0.45}, {x=0, y=0, z=0})
thing_ent.square_ball_attached = true
thing_ent.attached_squared_ball = self
mobkit.remember(thing_ent, "square_ball_attached", thing_ent.square_ball_attached)
mobkit.make_sound(thing_ent, "moaning")
kitz.remember(thing_ent, "square_ball_attached", thing_ent.square_ball_attached)
kitz.make_sound(thing_ent, "moaning")
if shooter_name then
local player = minetest.get_player_by_name(shooter_name)
if player then
mobkit.clear_queue_low(thing_ent)
mobkit.hq_follow(thing_ent, 15, player)
kitz.clear_queue_low(thing_ent)
kitz.hq_follow(thing_ent, 15, player)
self.shooter_name = "" --disable de 'on_step' event
end
end
@ -103,10 +103,10 @@ minetest.register_entity("petz:ent_square_ball", {
local parent_ent = attach:get_luaentity()
parent_ent.square_ball_attached = false
parent_ent.attached_squared_ball = nil
mobkit.clear_queue_low(parent_ent)
kitz.clear_queue_low(parent_ent)
petz.ownthing(parent_ent)
self.object:remove() --remove the square ball
mobkit.clear_queue_low(parent_ent)
kitz.clear_queue_low(parent_ent)
petz.ownthing(parent_ent)
end
end,

View File

@ -23,7 +23,7 @@ petz.set_affinity = function(self, rate)
elseif new_affinity < 0 then
new_affinity = 0
end
self.affinity = mobkit.remember(self, "affinity", new_affinity)
self.affinity = kitz.remember(self, "affinity", new_affinity)
end
--The Tamagochi Timer
@ -43,7 +43,7 @@ end
petz.timer = function(self)
minetest.after(petz.settings.tamagochi_check_time, function()
if mobkit.is_alive(self) then
if kitz.is_alive(self) then
if (not(minetest.is_singleplayer())) and (petz.settings.tamagochi_check_if_player_online) then
if not minetest.player_exists(self.owner) then --if pet owner is not online
return
@ -61,25 +61,25 @@ petz.timer = function(self)
for i = 1, #petz.settings.tamagochi_safe_nodes do --loop thru all safe nodes
if node and (node.name == petz.settings.tamagochi_safe_nodes[i]) then
self.init_tamagochi_timer = true
mobkit.remember(self, "init_tamagochi_timer", self.init_tamagochi_timer)
kitz.remember(self, "init_tamagochi_timer", self.init_tamagochi_timer)
return
end
end
else --if the pos is nil, it means that the pet died before 'minetest.after_effect'
self.init_tamagochi_timer = false
mobkit.remember(self, "init_tamagochi_timer", self.init_tamagochi_timer) --so no more timer
kitz.remember(self, "init_tamagochi_timer", self.init_tamagochi_timer) --so no more timer
return
end
--Decrease health if pet has not fed
if not self.fed then
mokapi.set_health(self, -petz.settings.tamagochi_feed_hunger_rate)
kitz.set_health(self, -petz.settings.tamagochi_feed_hunger_rate)
petz.update_nametag(self)
if (self.hp > 0) and self.has_affinity then
petz.set_affinity(self, -petz.settings.tamagochi_feed_hunger_rate)
end
else
self.fed = false
mobkit.remember(self, "fed", self.fed) --Reset the variable
kitz.remember(self, "fed", self.fed) --Reset the variable
end
--If the pet has not brushed
if self.can_be_brushed then
@ -89,7 +89,7 @@ petz.timer = function(self)
end
else
self.brushed = false
mobkit.remember(self, "brushed", self.brushed) --Reset the variable
kitz.remember(self, "brushed", self.brushed) --Reset the variable
end
end
--If the petz is a lion had to been lashed
@ -98,7 +98,7 @@ petz.timer = function(self)
petz.set_affinity(self, -petz.settings.tamagochi_lashing_rate)
else
self.lashed = false
mobkit.remember(self, "lashed", self.lashed)
kitz.remember(self, "lashed", self.lashed)
end
end
--If the pet starves to death
@ -122,7 +122,7 @@ petz.abandon_pet = function(self, msg)
minetest.chat_send_player(self.owner, msg)
end
petz.delete_nametag(self)
mokapi.remove_owner(self) --the pet abandon you
kitz.remove_owner(self) --the pet abandon you
petz.remove_tamed_by_owner(self, true)
petz.drop_dreamcatcher(self)
self.init_tamagochi_timer = false -- no more timing

View File

@ -26,13 +26,13 @@ function petz.throw(self, dtime, damage, effect, particles, sound)
thing.ref:punch(thing.ref, 1.0, {full_punch_interval = 1.0, damage_groups = {fleshy=damage}}, nil)
ent_pos = thing.ref:get_pos()
if sound then
mokapi.make_sound("player", thing.ref, sound, petz.settings.max_hear_distance)
kitz.make_sound("player", thing.ref, sound, petz.settings.max_hear_distance)
end
else
mobkit.hurt(thing_ent, damage)
kitz.hurt(thing_ent, damage)
ent_pos = thing.ref:get_pos()
if sound then
mokapi.make_sound("object", thing.ref, sound, petz.settings.max_hear_distance)
kitz.make_sound("object", thing.ref, sound, petz.settings.max_hear_distance)
end
end
if effect then
@ -70,7 +70,7 @@ function petz.throw(self, dtime, damage, effect, particles, sound)
petz.do_particles_effect(nil, pos_above, "fire")
--end
end
mokapi.make_sound("pos", node_pos, "petz_firecracker", petz.settings.max_hear_distance)
kitz.make_sound("pos", node_pos, "petz_firecracker", petz.settings.max_hear_distance)
elseif effect == "cobweb" then
local pos_above = {
x = node_pos.x,

View File

@ -10,7 +10,7 @@ petz.put_wagon = function(self, clicker)
local rotation = self.object:get_rotation()
local wagon_obj = minetest.add_entity(pos, "petz:wagon", nil)
wagon_obj:set_attach(self.object, "", {x = 0, y = 0.0, z = 0}, rotation)
mokapi.make_sound("object", self.object, "petz_pop_sound", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_pop_sound", petz.settings.max_hear_distance)
wagon_obj:set_properties({
visual_size = {
x =1,

View File

@ -34,7 +34,7 @@ petz.create_form_list_by_owner = function(user_name, user_pos)
local item_list = ""
for key, pet_table in ipairs(item_list_table) do
local pet = pet_table.pet
if mobkit.is_alive(pet) and not(petz.str_is_empty(pet.tag)) then -- check if alive
if kitz.is_alive(pet) and not(petz.str_is_empty(pet.tag)) then -- check if alive
local pet_type = pet.type:gsub("^%l", string.upper)
local pet_pos = pet.object:get_pos()
local distance, pet_pos_x, pet_pos_y, pet_pos_z
@ -88,7 +88,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
}
pet.object:set_pos(pet_pos)
minetest.close_formspec(player_name, "petz:form_whistle")
mokapi.make_sound("player", player, "petz_whistle", petz.settings.max_hear_distance)
kitz.make_sound("player", player, "petz_whistle", petz.settings.max_hear_distance)
end
end
return true

View File

@ -21,10 +21,10 @@ petz.lamb_wool_regrow = function(self)
return
end
local food_count_wool = self.food_count_wool + 1
self.food_count_wool = mobkit.remember(self, "food_count_wool", food_count_wool)
self.food_count_wool = kitz.remember(self, "food_count_wool", food_count_wool)
if self.food_count_wool >= 5 then -- if lamb replaces 5x grass then it regrows wool
self.food_count_wool = mobkit.remember(self, "food_count_wool", 0)
self.shaved = mobkit.remember(self, "shaved", false)
self.food_count_wool = kitz.remember(self, "food_count_wool", 0)
self.shaved = kitz.remember(self, "shaved", false)
local lamb_texture = "petz_lamb_"..self.skin_colors[self.texture_no]..".png"
petz.set_properties(self, {textures = {lamb_texture}})
end
@ -37,7 +37,7 @@ petz.lamb_wool_shave = function(self, clicker)
color = self.skin_colors[self.texture_no]
else
color = self.colorized
self.colorized = mobkit.remember(self, "colorized", nil) --reset the color
self.colorized = kitz.remember(self, "colorized", nil) --reset the color
end
local new_stack = "wool:".. color
if inv:room_for_item("main", new_stack) then
@ -45,13 +45,13 @@ petz.lamb_wool_shave = function(self, clicker)
else
minetest.add_item(self.object:get_pos(), new_stack)
end
mokapi.make_sound("object", self.object, "petz_lamb_moaning", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_lamb_moaning", petz.settings.max_hear_distance)
local lamb_texture = "petz_lamb_shaved_"..self.skin_colors[self.texture_no]..".png"
petz.set_properties(self, {textures = {lamb_texture}})
self.shaved = mobkit.remember(self, "shaved", true)
self.food_count_wool = mobkit.remember(self, "food_count_wool", 0)
self.shaved = kitz.remember(self, "shaved", true)
self.food_count_wool = kitz.remember(self, "food_count_wool", 0)
petz.bh_afraid(self, clicker:get_pos())
mokapi.make_sound("object", self.object, "petz_pop_sound", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_pop_sound", petz.settings.max_hear_distance)
end
---
@ -60,7 +60,7 @@ end
petz.milk_refill = function(self)
if self.food_count >= 5 then -- if calf replaces 5x grass then it refill milk
self.milked = mobkit.remember(self, "milked", false)
self.milked = kitz.remember(self, "milked", false)
end
end
@ -78,11 +78,11 @@ petz.milk_milk = function(self, clicker)
clicker:set_wielded_item(wielded_item)
if inv:room_for_item("main", "petz:bucket_milk") then
inv:add_item("main","petz:bucket_milk")
mokapi.make_sound("object", self.object, "petz_"..self.type.."_moaning", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_"..self.type.."_moaning", petz.settings.max_hear_distance)
else
minetest.add_item(self.object:get_pos(), "petz:bucket_milk")
end
self.milked = mobkit.remember(self, "milked", true)
self.milked = kitz.remember(self, "milked", true)
end
---
@ -96,6 +96,6 @@ petz.cut_feather = function(self, clicker)
else
minetest.add_item(self.object:get_pos(), item_stack)
end
mokapi.make_sound("object", self.object, "petz_"..self.type.."_moaning", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_"..self.type.."_moaning", petz.settings.max_hear_distance)
petz.bh_afraid(self, clicker:get_pos())
end

View File

@ -35,7 +35,7 @@ function petz.bh_create_anthill(self, pos)
if node_entrance == "petz:anthill_entrance" then
minetest.set_node(pos_entrance, {name = node_entrance})
end
self.anthill_founded = mobkit.remember(self, "anthill_founded", true) --Mark the foundation
self.anthill_founded = kitz.remember(self, "anthill_founded", true) --Mark the foundation
pos.y = pos.y - 24 --y offset for place the queen inside the anthill
self.object:move_to(pos) --place the queen
return true

View File

@ -13,14 +13,14 @@ function petz.hq_aqua_jump(self, prty)
petz.set_velocity(self, velocity)
self.object:set_acceleration({x=1.0, y=vel_impulse, z=1.0})
self.status = "jump"
mokapi.make_sound("object", self.object, "petz_splash", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_splash", petz.settings.max_hear_distance)
minetest.after(0.5, function()
if mobkit.is_alive(self.object) then
if kitz.is_alive(self.object) then
self.status = nil
mobkit.clear_queue_high(self)
kitz.clear_queue_high(self)
end
end, self, velocity)
return true
end
mobkit.queue_high(self, func, prty)
kitz.queue_high(self, func, prty)
end

View File

@ -29,10 +29,10 @@ end
function petz.bh_climb(self, pos, prty)
if petz.check_tree(self) then
petz.hq_climb(self, prty)
mobkit.animate(self, 'climb')
kitz.animate(self, 'climb')
return true
else --search for a tree
if mobkit.timer(self, 60) then
if kitz.timer(self, 60) then
local view_range = self.view_range
local nearby_wood = minetest.find_nodes_in_area(
{x = pos.x - view_range, y = pos.y - view_range, z = pos.z - view_range},
@ -40,7 +40,7 @@ function petz.bh_climb(self, pos, prty)
{"group:wood"})
if #nearby_wood >= 1 then
local tpos = nearby_wood[1] --the first match
mobkit.hq_goto(self, prty, tpos)
kitz.hq_goto(self, prty, tpos)
return true
end
end
@ -52,16 +52,16 @@ function petz.hq_climb(self, prty)
local func=function()
if not petz.check_tree(self) then
self.status = nil
mobkit.clear_queue_high(self)
mobkit.clear_queue_low(self)
kitz.clear_queue_high(self)
kitz.clear_queue_low(self)
return true
end
if mobkit.is_queue_empty_low(self) then
if kitz.is_queue_empty_low(self) then
self.status = "climb"
petz.lq_climb(self)
end
end
mobkit.queue_high(self,func,prty)
kitz.queue_high(self,func,prty)
end
function petz.lq_climb(self)
@ -100,13 +100,13 @@ function petz.lq_climb(self)
self.object:set_pos(climb_pos)
self.status = nil
end
mobkit.clear_queue_high(self)
mobkit.clear_queue_low(self)
kitz.clear_queue_high(self)
kitz.clear_queue_low(self)
elseif node_front_top_name == "air" then
self.object:set_pos(front_top_pos)
end
self.object:set_velocity({x = 0, y = 1.0, z = 0 })
return true
end
mobkit.queue_low(self, func)
kitz.queue_low(self, func)
end

View File

@ -19,7 +19,7 @@ function petz.bh_attack_player(self, pos, prty, player)
if vector.distance(pos, player_pos) <= self.view_range then -- if player close
if (self.attack_player and not(self.avoid_player)) or (self.warn_attack) then --attack player
if self.can_swin then
mobkit.hq_aqua_attack(self, prty, player, 6)
kitz.hq_aqua_attack(self, prty, player, 6)
elseif self.can_fly then
petz.hq_flyhunt(self, prty, player)
else
@ -29,7 +29,7 @@ function petz.bh_attack_player(self, pos, prty, player)
else
if not(self.can_swin) and not(self.can_fly) then
if self.avoid_player then
mobkit.hq_runfrom(self, prty, player) -- run away from player
kitz.hq_runfrom(self, prty, player) -- run away from player
return true
else
return false
@ -48,21 +48,21 @@ end
function petz.hq_hunt(self,prty,tgtobj)
local func = function()
if not mobkit.is_alive(tgtobj) then return true end
if mobkit.is_queue_empty_low(self) and self.isonground then
local pos = mobkit.get_stand_pos(self)
if not kitz.is_alive(tgtobj) then return true end
if kitz.is_queue_empty_low(self) and self.isonground then
local pos = kitz.get_stand_pos(self)
local opos = tgtobj:get_pos()
local dist = vector.distance(pos,opos)
if dist > self.view_range then
return true
elseif dist > 3 then
mobkit.goto_next_waypoint(self,opos)
kitz.goto_next_waypoint(self,opos)
else
petz.hq_attack(self,prty+1,tgtobj)
end
end
end
mobkit.queue_high(self,func,prty)
kitz.queue_high(self,func,prty)
end
function petz.is_pos_in_box(self, pos,bpos,box)
@ -76,41 +76,41 @@ end
function petz.hq_attack(self,prty,tgtobj)
local func = function()
if not mobkit.is_alive(tgtobj) then return true end
if mobkit.is_queue_empty_low(self) then
local pos = mobkit.get_stand_pos(self)
if not kitz.is_alive(tgtobj) then return true end
if kitz.is_queue_empty_low(self) then
local pos = kitz.get_stand_pos(self)
-- local tpos = tgtobj:get_pos()
local tpos = mobkit.get_stand_pos(tgtobj)
local tpos = kitz.get_stand_pos(tgtobj)
local dist = vector.distance(pos,tpos)
if dist > 3 then
return true
else
mobkit.lq_turn2pos(self,tpos)
kitz.lq_turn2pos(self,tpos)
local height = tgtobj:is_player() and 0.35 or tgtobj:get_luaentity().height*0.6
if tpos.y+height>pos.y then
petz.lq_jumpattack(self,tpos.y+height-pos.y,tgtobj)
else
mobkit.lq_dumbwalk(self,mobkit.pos_shift(tpos,{x=math.random()-0.5,z=math.random()-0.5}))
kitz.lq_dumbwalk(self,kitz.pos_shift(tpos,{x=math.random()-0.5,z=math.random()-0.5}))
end
end
end
end
mobkit.queue_high(self,func,prty)
kitz.queue_high(self,func,prty)
end
function petz.lq_jumpattack(self,height,target)
local phase=1
local func=function()
if not mobkit.is_alive(target) then return true end
if not kitz.is_alive(target) then return true end
if self.isonground then
if phase==1 then -- collision bug workaround
local vel = self.object:get_velocity()
vel.y = -mobkit.gravity*math.sqrt(height*2/-mobkit.gravity)
vel.y = -kitz.gravity*math.sqrt(height*2/-kitz.gravity)
self.object:set_velocity(vel)
mobkit.make_sound(self,'charge')
kitz.make_sound(self,'charge')
phase=2
else
mobkit.lq_idle(self,0.3)
kitz.lq_idle(self,0.3)
return true
end
elseif phase==2 then
@ -135,12 +135,12 @@ function petz.lq_jumpattack(self,height,target)
local vy = self.object:get_velocity().y
self.object:set_velocity({x=dir.x*-3,y=vy,z=dir.z*-3})
-- play attack sound if defined
mobkit.make_sound(self,'attack')
kitz.make_sound(self,'attack')
phase=4
end
end
end
mobkit.queue_low(self,func)
kitz.queue_low(self,func)
end
---
@ -149,9 +149,9 @@ end
function petz.hq_flyhunt(self, prty, tgtobj)
local func = function()
if not mobkit.is_alive(tgtobj) then return true end
if mobkit.is_queue_empty_low(self) then
local pos = mobkit.get_stand_pos(self)
if not kitz.is_alive(tgtobj) then return true end
if kitz.is_queue_empty_low(self) then
local pos = kitz.get_stand_pos(self)
local opos = tgtobj:get_pos()
local dist = vector.distance(pos, opos)
if dist > self.view_range then
@ -164,17 +164,17 @@ function petz.hq_flyhunt(self, prty, tgtobj)
end
end
end
mobkit.queue_high(self,func,prty)
kitz.queue_high(self,func,prty)
end
function petz.hq_flyattack(self, prty, tgtobj)
local func = function()
if not mobkit.is_alive(tgtobj) then
if not kitz.is_alive(tgtobj) then
return true
end
if mobkit.is_queue_empty_low(self) then
if kitz.is_queue_empty_low(self) then
local pos = self.object:get_pos()
local tpos = mobkit.get_stand_pos(tgtobj)
local tpos = kitz.get_stand_pos(tgtobj)
local dist = vector.distance(pos,tpos)
if dist > 3 then
return true
@ -183,12 +183,12 @@ function petz.hq_flyattack(self, prty, tgtobj)
end
end
end
mobkit.queue_high(self,func,prty)
kitz.queue_high(self,func,prty)
end
function petz.lq_flyattack(self, target)
local func = function()
if not mobkit.is_alive(target) then
if not kitz.is_alive(target) then
return true
end
local tgtpos = target:get_pos()
@ -201,15 +201,15 @@ function petz.lq_flyattack(self, target)
local yaw = self.object:get_yaw()
local dir = minetest.yaw_to_dir(yaw)
self.object:set_velocity({x= dir.x*-3, y=vy, z=dir.z * -3})
mobkit.make_sound(self, 'attack') -- play attack sound if defined
kitz.make_sound(self, 'attack') -- play attack sound if defined
if self.attack_kamikaze then
self.hp = 0 --bees must to die!!!
end
else
petz.flyto(self, target)
end
mobkit.lq_idle(self, 0.3)
kitz.lq_idle(self, 0.3)
return true
end
mobkit.queue_low(self,func)
kitz.queue_low(self,func)
end

View File

@ -20,7 +20,7 @@ function petz.bh_create_beehive(self, pos)
}
if #minetest.find_nodes_in_area(minp, maxp, {"petz:beehive"}) < 1 then
minetest.set_node(pos, {name= "petz:beehive"})
mokapi.remove_mob(self)
kitz.remove_mob(self)
return true
else
return false
@ -33,14 +33,14 @@ end
function petz.hq_gotopollen(self, prty, tpos)
local func = function()
if self.pollen then
--mobkit.clear_queue_low(self)
--mobkit.clear_queue_high(self)
--kitz.clear_queue_low(self)
--kitz.clear_queue_high(self)
return true
end
mobkit.animate(self, "fly")
kitz.animate(self, "fly")
petz.lq_search_flower(self, tpos)
end
mobkit.queue_high(self, func, prty)
kitz.queue_high(self, func, prty)
end
function petz.lq_search_flower(self, tpos)
@ -54,13 +54,13 @@ function petz.lq_search_flower(self, tpos)
if (abs_y_distance > 1) and (abs_y_distance < self.view_range) then
petz.set_velocity(self, {x= 0.0, y= y_distance, z= 0.0})
end
if mobkit.drive_to_pos(self, tpos, 1.5, 6.28, 0.5) then
if kitz.drive_to_pos(self, tpos, 1.5, 6.28, 0.5) then
self.pollen = true
petz.do_particles_effect(self.object, self.object:get_pos(), "pollen")
return true
end
end
mobkit.queue_low(self, func)
kitz.queue_low(self, func)
end
function petz.hq_gotobehive(self, prty, pos)
@ -68,10 +68,10 @@ function petz.hq_gotobehive(self, prty, pos)
if not(self.pollen) or not(self.behive) then
return true
end
mobkit.animate(self, "fly")
kitz.animate(self, "fly")
petz.lq_search_behive(self)
end
mobkit.queue_high(self, func, prty)
kitz.queue_high(self, func, prty)
end
function petz.lq_search_behive(self)
@ -88,9 +88,9 @@ function petz.lq_search_behive(self)
if (abs_y_distance > 1) and (abs_y_distance < self.view_range) then
petz.set_velocity(self, {x= 0.0, y= y_distance, z= 0.0})
end
if mobkit.drive_to_pos(self, tpos, 1.5, 6.28, 1.01) then
if kitz.drive_to_pos(self, tpos, 1.5, 6.28, 1.01) then
if petz.behive_exists(self) then
mokapi.remove_mob(self)
kitz.remove_mob(self)
local meta, honey_count, bee_count = petz.get_behive_stats(self.behive)
bee_count = bee_count + 1
meta:set_int("bee_count", bee_count)
@ -101,19 +101,19 @@ function petz.lq_search_behive(self)
end
end
end
mobkit.queue_low(self, func)
kitz.queue_low(self, func)
end
function petz.hq_approach_behive(self, pos, prty)
local func = function()
if math.abs(pos.x - self.behive.x) <= (self.view_range / 2) or math.abs(pos.z - self.behive.z) <= (self.view_range / 2) then
mobkit.clear_queue_low(self)
mobkit.clear_queue_high(self)
kitz.clear_queue_low(self)
kitz.clear_queue_high(self)
return true
end
petz.lq_approach_behive(self)
end
mobkit.queue_high(self, func, prty)
kitz.queue_high(self, func, prty)
end
function petz.lq_approach_behive(self)
@ -125,10 +125,10 @@ function petz.lq_approach_behive(self)
return true
end
--local y_distance = tpos.y - pos.y
if mobkit.drive_to_pos(self, tpos, 1.5, 6.28, (self.view_range / 4) ) then
mobkit.clear_queue_high(self)
if kitz.drive_to_pos(self, tpos, 1.5, 6.28, (self.view_range / 4) ) then
kitz.clear_queue_high(self)
return true
end
end
mobkit.queue_low(self, func)
kitz.queue_low(self, func)
end

View File

@ -8,7 +8,7 @@ function petz.bh_breed(self, pos)
if self.type == "elephant" then
couple_name = couple_name.."_female"
end
local couple_obj = mobkit.get_closest_entity(self, couple_name) -- look for a couple
local couple_obj = kitz.get_closest_entity(self, couple_name) -- look for a couple
if couple_obj then
local couple = couple_obj:get_luaentity()
if couple and couple.is_rut and not(couple.is_pregnant) and not(couple.is_male) then --if couple and female and is not pregnant and is rut
@ -16,10 +16,10 @@ function petz.bh_breed(self, pos)
local copulation_distance = petz.settings[self.type.."_copulation_distance"] or 1
if vector.distance(pos, couple_pos) <= copulation_distance then --if close
--Changue some vars
self.is_rut = mobkit.remember(self, "is_rut", false)
couple.is_rut = mobkit.remember(couple, "is_rut", false)
couple.is_pregnant = mobkit.remember(couple, "is_pregnant", true)
couple.father_genes = mobkit.remember(couple, "father_genes", self.genes)
self.is_rut = kitz.remember(self, "is_rut", false)
couple.is_rut = kitz.remember(couple, "is_rut", false)
couple.is_pregnant = kitz.remember(couple, "is_pregnant", true)
couple.father_genes = kitz.remember(couple, "father_genes", self.genes)
petz.do_particles_effect(couple.object, couple.object:get_pos(), "pregnant".."_"..couple.type)
end
end

View File

@ -4,11 +4,11 @@
function petz.hq_wanderfly(self, prty)
local func=function()
if mobkit.is_queue_empty_low(self) then
if kitz.is_queue_empty_low(self) then
petz.lq_dumbfly(self, 0.6)
end
end
mobkit.queue_high(self,func,prty)
kitz.queue_high(self,func,prty)
end
--3 fly status: ascend, descend and stand right.
@ -22,11 +22,11 @@ end
function petz.lq_turn2yaw(self, yaw)
local func = function()
if mobkit.turn2yaw(self, yaw) then
if kitz.turn2yaw(self, yaw) then
return true
end
end
mobkit.queue_low(self,func)
kitz.queue_low(self,func)
end
function petz.lq_dumbfly(self, speed_factor)
@ -38,7 +38,7 @@ function petz.lq_dumbfly(self, speed_factor)
if timer < 0 then
--minetest.chat_send_player("singleplayer", tostring(timer))
local velocity
mobkit.animate(self, 'fly')
kitz.animate(self, 'fly')
local random_num = math.random(1, 5)
local yaw = self.object:get_yaw()
local rotation = self.object:get_rotation()
@ -128,7 +128,7 @@ function petz.lq_dumbfly(self, speed_factor)
end
end
end
mobkit.queue_low(self,func)
kitz.queue_low(self,func)
end
--
@ -137,18 +137,18 @@ end
function petz.hq_fly(self, prty)
local func=function()
mobkit.animate(self, "fly")
kitz.animate(self, "fly")
petz.lq_fly(self)
mobkit.clear_queue_high(self)
kitz.clear_queue_high(self)
end
mobkit.queue_high(self, func, prty)
kitz.queue_high(self, func, prty)
end
function petz.lq_fly(self)
local func=function()
self.object:set_acceleration({ x = 0, y = 1, z = 0 })
end
mobkit.queue_low(self,func)
kitz.queue_low(self,func)
end
-- Function to recover flying mobs from water
@ -162,7 +162,7 @@ function petz.hq_liquid_recovery_flying(self, prty)
return true
end
end
mobkit.queue_high(self, func, prty)
kitz.queue_high(self, func, prty)
end
--
@ -179,13 +179,13 @@ function petz.hq_alight(self, prty, end_status)
return true
else
--minetest.chat_send_player("singleplayer", "on ground")
mobkit.animate(self, end_status)
mobkit.lq_idle(self, 2400)
kitz.animate(self, end_status)
kitz.lq_idle(self, 2400)
self.status = end_status
return true
end
end
mobkit.queue_high(self, func, prty)
kitz.queue_high(self, func, prty)
end
function petz.lq_alight(self)
@ -194,5 +194,5 @@ function petz.lq_alight(self)
self.object:set_acceleration({ x = 0, y = -1, z = 0 })
return true
end
mobkit.queue_low(self, func)
kitz.queue_low(self, func)
end

View File

@ -10,12 +10,12 @@ function petz.bh_start_follow(self, pos, player, prty)
if player then
local wielded_item_name = player:get_wielded_item():get_name()
local tpos = player:get_pos()
if mokapi.item_in_itemlist(wielded_item_name, self.follow) and vector.distance(pos, tpos) <= self.view_range then
self.status = mobkit.remember(self, "status", "follow")
if kitz.item_in_itemlist(wielded_item_name, self.follow) and vector.distance(pos, tpos) <= self.view_range then
self.status = kitz.remember(self, "status", "follow")
if (self.can_fly) or (self.can_swin and self.isinliquid) then
petz.hq_followliquidair(self, prty, player)
else
mobkit.hq_follow(self, prty, player)
kitz.hq_follow(self, prty, player)
end
return true
else
@ -44,7 +44,7 @@ end
function petz.hq_followliquidair(self, prty, player)
local func=function()
local pos = mobkit.get_stand_pos(self)
local pos = kitz.get_stand_pos(self)
local tpos = player:get_pos()
if self.can_swin then
if not(petz.isinliquid(self)) then
@ -61,7 +61,7 @@ function petz.hq_followliquidair(self, prty, player)
if distance < 3 then
return
elseif (distance < self.view_range) then
if mobkit.is_queue_empty_low(self) then
if kitz.is_queue_empty_low(self) then
petz.lq_followliquidair(self, player)
end
elseif distance >= self.view_range then
@ -72,7 +72,7 @@ function petz.hq_followliquidair(self, prty, player)
return true
end
end
mobkit.queue_high(self, func, prty)
kitz.queue_high(self, func, prty)
end
function petz.lq_followliquidair(self, target)
@ -80,7 +80,7 @@ function petz.lq_followliquidair(self, target)
petz.flyto(self, target)
return true
end
mobkit.queue_low(self,func)
kitz.queue_low(self,func)
end
function petz.flyto(self, target)
@ -104,9 +104,9 @@ end
function petz.follow_parents(self, pos)
local tpos
local ent_obj = mobkit.get_closest_entity(self, self.parents[1]) -- look for the mom to join with
local ent_obj = kitz.get_closest_entity(self, self.parents[1]) -- look for the mom to join with
if not ent_obj then
ent_obj = mobkit.get_closest_entity(self, self.parents[2]) -- look for the dad to join with
ent_obj = kitz.get_closest_entity(self, self.parents[2]) -- look for the dad to join with
end
if ent_obj then
local ent = ent_obj:get_luaentity()
@ -114,7 +114,7 @@ function petz.follow_parents(self, pos)
tpos = ent_obj:get_pos()
local distance = vector.distance(pos, tpos)
if distance > 5 then
mobkit.hq_goto(self, 10, tpos)
kitz.hq_goto(self, 10, tpos)
return true
else
return false

View File

@ -17,11 +17,11 @@ function petz.hq_look_at(self, player_pos, prty)
--if random_time == 1 then --move the body to fit the head
--self.object:set_yaw(body_yaw)
--end
mobkit.animate(self, "idle")
kitz.animate(self, "idle")
minetest.after(random_time, function()
if mobkit.is_alive(self) then
mobkit.clear_queue_low(self)
mobkit.clear_queue_high(self)
if kitz.is_alive(self) then
kitz.clear_queue_low(self)
kitz.clear_queue_high(self)
petz.return_head_to_origin(self)
self.looking = false
return true
@ -30,7 +30,7 @@ function petz.hq_look_at(self, player_pos, prty)
self.looking = true
end
end
mobkit.queue_high(self, func, prty)
kitz.queue_high(self, func, prty)
end
--a movement test to move the head
@ -47,15 +47,15 @@ function petz.move_head(self, tpos)
local direction = vector.direction(pos, tpos) -- the vector direction from mob to player's eyes
local look_at_dir = vector.normalize(direction) -- important: normalize the vector
-- Functions to calculate the pitch & yaw (in degrees):
local pitch = mokapi.yaw_to_degrees(math.asin(look_at_dir.y))
local yaw =mokapi.yaw_to_degrees(math.atan2(look_at_dir.x, look_at_dir.z))
local body_yaw = mokapi.yaw_to_degrees(self.object:get_yaw()) --yaw of the body in degrees
local pitch = kitz.yaw_to_degrees(math.asin(look_at_dir.y))
local yaw =kitz.yaw_to_degrees(math.atan2(look_at_dir.x, look_at_dir.z))
local body_yaw = kitz.yaw_to_degrees(self.object:get_yaw()) --yaw of the body in degrees
local final_yaw = yaw + body_yaw --get the head yaw in reference with the body
local head_rotation = {x= pitch, y= final_yaw, z= 0} -- the head movement {pitch, yaw, roll}
self.head_rotation = vector.add(head_rotation, self.head.rotation_origin) --the offset for the rotation, depends on the blender model
self.object:set_bone_position("head", self.head.position, self.head_rotation) --set the head movement
--minetest.chat_send_all(tostring(mokapi.degrees_to_radians(yaw)))
return mokapi.degrees_to_radians(body_yaw-yaw) --returns body_yaw
--minetest.chat_send_all(tostring(kitz.degrees_to_radians(yaw)))
return kitz.degrees_to_radians(body_yaw-yaw) --returns body_yaw
end
--this sets the mob to move it's head back to pointing forwards

View File

@ -13,18 +13,18 @@ function petz.hq_terrestial_jump(self, prty)
z = self.max_speed * (self.jump_impulse/3),
}
petz.set_velocity(self, velocity)
mobkit.animate(self, 'jump')
kitz.animate(self, 'jump')
self.object:set_acceleration({x=1.0, y=self.jump_impulse, z=1.0})
self.status = "jump"
mobkit.animate(self, 'fly')
--mokapi.make_sound("object", self.object, "petz_splash", petz.settings.max_hear_distance)
kitz.animate(self, 'fly')
--kitz.make_sound("object", self.object, "petz_splash", petz.settings.max_hear_distance)
minetest.after(0.5, function()
if mobkit.is_alive(self.object) then
if kitz.is_alive(self.object) then
self.status = nil
mobkit.clear_queue_high(self)
kitz.clear_queue_high(self)
end
end, self, velocity)
return true
end
mobkit.queue_high(self, func, prty)
kitz.queue_high(self, func, prty)
end

View File

@ -8,7 +8,7 @@ function petz.bh_herding(self, pos, player)
end
local join_herd = false
local tpos
local ent_obj = mobkit.get_closest_entity(self, "petz:"..self.type) -- look for a herd to join with
local ent_obj = kitz.get_closest_entity(self, "petz:"..self.type) -- look for a herd to join with
if ent_obj then
local ent = ent_obj:get_luaentity()
if ent and ent.herding then
@ -33,7 +33,7 @@ function petz.bh_herding(self, pos, player)
end
end
if join_herd and tpos then
mobkit.hq_goto(self, 4.5, tpos)
kitz.hq_goto(self, 4.5, tpos)
return true
else
return false

View File

@ -9,7 +9,7 @@ function petz.bh_hunt(self, prty, force)
for i = 1, #preys do --loop thru all preys
--minetest.chat_send_player("singleplayer", "preys list="..preys[i])
--minetest.chat_send_player("singleplayer", "node name="..node.name)
local prey = mobkit.get_closest_entity(self, preys[i]) -- look for prey
local prey = kitz.get_closest_entity(self, preys[i]) -- look for prey
if prey then
--minetest.chat_send_player("singleplayer", "got it")
petz.hq_hunt(self, prty, prey) -- and chase it

View File

@ -61,12 +61,12 @@ function petz.hq_mountdriver(self, prty)
if not(self.driver) then
return true
else
if mobkit.is_queue_empty_low(self) then
if kitz.is_queue_empty_low(self) then
petz.lq_mountdriver(self)
end
end
end
mobkit.queue_high(self,func,prty)
kitz.queue_high(self,func,prty)
end
function petz.lq_mountdriver(self)
@ -110,7 +110,7 @@ function petz.lq_mountdriver(self)
velo.y = velo.y + (self.jump_height)*4
acce_y = acce_y *1.5
else --stand
mobkit.animate(self, "still")
kitz.animate(self, "still")
if self.wagon then
petz.animate_wagon(self, "stand")
end
@ -120,8 +120,8 @@ function petz.lq_mountdriver(self)
if ctrl.up and ctrl.sneak and not(self.gallop_exhausted) then
if not self.gallop then
self.gallop = true
mokapi.make_sound("object", self.object, "petz_horse_whinny", petz.settings.max_hear_distance)
mokapi.make_sound("object", self.object, "petz_horse_gallop", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_horse_whinny", petz.settings.max_hear_distance)
kitz.make_sound("object", self.object, "petz_horse_gallop", petz.settings.max_hear_distance)
end
velocity = velocity + self.accel
end
@ -140,12 +140,12 @@ function petz.lq_mountdriver(self)
end
-- Set position, velocity and acceleration
local new_velo = get_velocity(velocity, self.object:get_yaw() - rot_view, velo.y)
local new_acce = vector.new(0, mobkit.gravity, 0)
local new_acce = vector.new(0, kitz.gravity, 0)
self.object:set_velocity(new_velo)
if not(self.gallop) then
mobkit.animate(self, "walk") -- set animation
kitz.animate(self, "walk") -- set animation
else
mobkit.animate(self, "run")
kitz.animate(self, "run")
end
if self.wagon then
petz.animate_wagon(self, "roll")
@ -155,5 +155,5 @@ function petz.lq_mountdriver(self)
self.object:set_acceleration(new_acce)
return
end
mobkit.queue_low(self, func)
kitz.queue_low(self, func)
end

View File

@ -3,7 +3,7 @@
--
function petz.bh_replace(self)
if mokapi.replace(self, "petz_replace", petz.settings.max_hear_distance) then
if kitz.replace(self, "petz_replace", petz.settings.max_hear_distance) then
petz.refill(self) --Refill wool, milk or nothing
end
if self.lay_eggs then

View File

@ -10,11 +10,11 @@ function petz.bh_runaway_from_predator(self, pos)
for i = 1, #predators do --loop thru all preys
--minetest.chat_send_player("singleplayer", "spawn node="..spawn_nodes[i])
--minetest.chat_send_player("singleplayer", "node name="..node.name)
local predator = mobkit.get_closest_entity(self, predators[i]) -- look for predator
local predator = kitz.get_closest_entity(self, predators[i]) -- look for predator
if predator then
local predator_pos = predator:get_pos()
if predator and vector.distance(pos, predator_pos) <= self.view_range then
mobkit.hq_runfrom(self, 18, predator)
kitz.hq_runfrom(self, 18, predator)
return true
else
return false

View File

@ -7,6 +7,6 @@ function petz.bh_teleport(self, pos, player, player_pos)
if node and node == "air" then
petz.do_particles_effect(self.object, self.object:get_pos(), "pumpkin")
self.object:set_pos(back_pos)
mobkit.make_sound(self, 'laugh')
kitz.make_sound(self, 'laugh')
end
end

View File

@ -9,7 +9,7 @@
--if pos and tpos then
--local distance = vector.distance(pos, tpos)
--if distance < self.view_range and (distance >= self.view_range) then
--if mobkit.is_queue_empty_low(self) then
--if kitz.is_queue_empty_low(self) then
--petz.lq_followliquidair(self, target)
--end
--elseif distance >= self.view_range then
@ -20,7 +20,7 @@
--return true
--end
--end
--mobkit.queue_high(self, func, prty)
--kitz.queue_high(self, func, prty)
--end

View File

@ -6,7 +6,7 @@ function petz.ant_brain(self)
local pos = self.object:get_pos() --pos of the petz
mobkit.vitals(self)
kitz.vitals(self)
if self.hp <= 0 then
petz.on_die(self) -- Die Behaviour
@ -17,20 +17,20 @@ function petz.ant_brain(self)
local timer_timing = 1
if mobkit.timer(self, timer_timing) then
if kitz.timer(self, timer_timing) then
if not(self.ant_type == "queen") then --hardcoded lifetime for worker and warrior ants
petz.lifetime_timer(self, petz.settings.lay_antegg_timing, timer_timing) --each second
end
local prty = mobkit.get_queue_priority(self)
local prty = kitz.get_queue_priority(self)
if prty < 40 and self.isinliquid then
mobkit.hq_liquid_recovery(self, 40)
kitz.hq_liquid_recovery(self, 40)
return
end
local player = mobkit.get_nearby_player(self)
local player = kitz.get_nearby_player(self)
if prty < 30 then
petz.env_damage(self, pos, 30) --enviromental damage: lava, fire...
@ -42,7 +42,7 @@ function petz.ant_brain(self)
end
if prty < 13 and self.ant_type == "queen" and not(self.anthill_founded) then --if queen, try to create a colony (anthill)
if mobkit.timer(self, 10) then --try to create an anthill every 10 seconds
if kitz.timer(self, 10) then --try to create an anthill every 10 seconds
if petz.bh_create_anthill(self, pos) then
return
end
@ -68,17 +68,17 @@ function petz.ant_brain(self)
if self.eggs_count <= petz.settings.ant_population then --quick laid in the beginning
lay_antegg_timing= lay_antegg_timing / petz.settings.ant_population
end
if mobkit.timer(self, lay_antegg_timing) then
if kitz.timer(self, lay_antegg_timing) then
petz.bh_lay_antegg(self, pos)
end
end
-- Default Random Sound
mokapi.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
kitz.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
--Roam default
if mobkit.is_queue_empty_high(self) and not(self.status) then
mobkit.hq_roam(self, 0)
if kitz.is_queue_empty_high(self) and not(self.status) then
kitz.hq_roam(self, 0)
end
end

View File

@ -6,7 +6,7 @@ function petz.aquatic_brain(self)
local pos = self.object:get_pos()
mobkit.vitals(self)
kitz.vitals(self)
-- Die Behaviour
@ -21,15 +21,15 @@ function petz.aquatic_brain(self)
end
if not(self.is_mammal) and not(petz.isinliquid(self)) then --if not mammal, air suffocation
mobkit.hurt(self, petz.settings.air_damage)
kitz.hurt(self, petz.settings.air_damage)
end
petz.check_ground_suffocation(self, pos)
if mobkit.timer(self, 1) then
if kitz.timer(self, 1) then
local prty = mobkit.get_queue_priority(self)
local player = mobkit.get_nearby_player(self)
local prty = kitz.get_queue_priority(self)
local player = kitz.get_nearby_player(self)
--Follow Behaviour
if prty < 16 then
@ -53,22 +53,22 @@ function petz.aquatic_brain(self)
end
if prty < 8 then
if (self.can_jump) and not(self.status== "jump") and (mobkit.is_in_deep(self)) then
if (self.can_jump) and not(self.status== "jump") and (kitz.is_in_deep(self)) then
local random_number = math.random(1, 25)
if random_number == 1 then
--minetest.chat_send_player("singleplayer", "jump")
mobkit.clear_queue_high(self)
kitz.clear_queue_high(self)
petz.hq_aqua_jump(self, 8)
end
end
end
-- Default Random Sound
mokapi.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
kitz.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
--Roam default
if mobkit.is_queue_empty_high(self) and not(self.status) and not(self.status== "jump") then
mobkit.hq_aqua_roam(self, 0, self.max_speed)
if kitz.is_queue_empty_high(self) and not(self.status) and not(self.status== "jump") then
kitz.hq_aqua_roam(self, 0, self.max_speed)
end
end
end

View File

@ -5,7 +5,7 @@ function petz.bee_brain(self)
local pos = self.object:get_pos() --pos of the petz
mobkit.vitals(self)
kitz.vitals(self)
self.object:set_acceleration({x=0, y=0, z=0})
@ -31,23 +31,23 @@ function petz.bee_brain(self)
meta:set_int("honey_count", honey_count)
end
petz.set_infotext_behive(meta, honey_count, bee_count)
mokapi.remove_mob(self)
kitz.remove_mob(self)
return
end
end
petz.check_ground_suffocation(self, pos)
if mobkit.timer(self, 1) then
if kitz.timer(self, 1) then
local prty = mobkit.get_queue_priority(self)
local prty = kitz.get_queue_priority(self)
if prty < 40 and self.isinliquid then
mobkit.hq_liquid_recovery(self, 40)
kitz.hq_liquid_recovery(self, 40)
return
end
local player = mobkit.get_nearby_player(self)
local player = kitz.get_nearby_player(self)
if prty < 30 then
petz.env_damage(self, pos, 30) --enviromental damage: lava, fire...
@ -105,10 +105,10 @@ function petz.bee_brain(self)
end
-- Default Random Sound
mokapi.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
kitz.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
--Roam default
if mobkit.is_queue_empty_high(self) and not(self.status) then
if kitz.is_queue_empty_high(self) and not(self.status) then
petz.hq_wanderfly(self, 0)
end

View File

@ -7,7 +7,7 @@ function petz.herbivore_brain(self)
local die = false
mobkit.vitals(self)
kitz.vitals(self)
if self.hp <= 0 then
die = true
@ -32,9 +32,9 @@ function petz.herbivore_brain(self)
petz.check_ground_suffocation(self, pos)
if mobkit.timer(self, 1) then
if kitz.timer(self, 1) then
local prty = mobkit.get_queue_priority(self)
local prty = kitz.get_queue_priority(self)
if prty < 30 then
petz.env_damage(self, pos, 30) --enviromental damage: lava, fire...
@ -53,7 +53,7 @@ function petz.herbivore_brain(self)
end
end
local player = mobkit.get_nearby_player(self)
local player = kitz.get_nearby_player(self)
--if player then petz.move_head(self, player:get_pos()) end
@ -85,16 +85,16 @@ function petz.herbivore_brain(self)
--Baby petz follow their parents
if prty < 10 then
if petz.settings.parent_search and self.parents then
if mobkit.timer(self, 5) then --each 5 seconds search for parents
if kitz.timer(self, 5) then --each 5 seconds search for parents
petz.follow_parents(self, pos)
end
end
end
--if prty < 7 and self.type == "moth" and mobkit.is_queue_empty_high(self) then --search for a squareball
--if prty < 7 and self.type == "moth" and kitz.is_queue_empty_high(self) then --search for a squareball
--local pos_torch_near = minetest.find_node_near(pos, self.view_range, "default:torch")
--if pos_torch_near then
--mobkit.hq_approach_torch(self, 7, pos_torch_near)
--kitz.hq_approach_torch(self, 7, pos_torch_near)
--return
--end
--end
@ -104,7 +104,7 @@ function petz.herbivore_brain(self)
local random_number = math.random(1, self.jump_ratio)
if random_number == 1 then
--minetest.chat_send_player("singleplayer", "jump")
mobkit.clear_queue_high(self)
kitz.clear_queue_high(self)
petz.hq_terrestial_jump(self, 8)
end
end
@ -126,7 +126,7 @@ function petz.herbivore_brain(self)
--Herding
if prty < 4.5 and petz.settings.herding then
if mobkit.timer(self, petz.settings.herding_timing) then
if kitz.timer(self, petz.settings.herding_timing) then
if petz.bh_herding(self, pos, player) then
return
end
@ -143,7 +143,7 @@ function petz.herbivore_brain(self)
local tpos = nearby_nodes[1] --the first match
local distance = vector.distance(pos, tpos)
if distance > 3.0 then
mobkit.hq_goto(self, 4, tpos)
kitz.hq_goto(self, 4, tpos)
elseif distance <= 3.0 then
if petz.settings.tamagochi_mode and not(self.fed) then
petz.do_feed(self)
@ -151,7 +151,7 @@ function petz.herbivore_brain(self)
local node = minetest.get_node_or_nil(tpos)
if node and node.name == "bale:bale" then
minetest.remove_node(tpos)
mokapi.make_sound("pos", tpos, "petz_replace", 5 or mokapi.consts.DEFAULT_MAX_HEAR_DISTANCE)
kitz.make_sound("pos", tpos, "petz_replace", 5 or kitz.consts.DEFAULT_MAX_HEAR_DISTANCE)
end
end
end
@ -170,7 +170,7 @@ function petz.herbivore_brain(self)
--local tpos = obj:get_pos()
--if vector.distance(spos, tpos) > 2 then
--if tpos then
--mobkit.hq_goto(self, 5, tpos)
--kitz.hq_goto(self, 5, tpos)
--end
--else
--local meta = ent:get_meta()
@ -183,7 +183,7 @@ function petz.herbivore_brain(self)
--end
-- Default Random Sound
mokapi.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
kitz.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
if prty < 3 then
if self.is_arboreal then
@ -205,7 +205,7 @@ function petz.herbivore_brain(self)
end
--Roam default
if mobkit.is_queue_empty_high(self) and not(self.status) then
if kitz.is_queue_empty_high(self) and not(self.status) then
petz.hq_wanderfly(self, 0)
end

View File

@ -7,7 +7,7 @@ function petz.flying_brain(self)
local die = false
mobkit.vitals(self)
kitz.vitals(self)
if self.hp <= 0 then
die = true
@ -32,9 +32,9 @@ function petz.flying_brain(self)
petz.check_ground_suffocation(self, pos)
if mobkit.timer(self, 1) then
if kitz.timer(self, 1) then
local prty = mobkit.get_queue_priority(self)
local prty = kitz.get_queue_priority(self)
if prty < 30 then
petz.env_damage(self, pos, 30) --enviromental damage: lava, fire...
@ -53,7 +53,7 @@ function petz.flying_brain(self)
end
end
local player = mobkit.get_nearby_player(self)
local player = kitz.get_nearby_player(self)
--if player then petz.move_head(self, player:get_pos()) end
@ -85,16 +85,16 @@ function petz.flying_brain(self)
--Baby petz follow their parents
if prty < 10 then
if petz.settings.parent_search and self.parents then
if mobkit.timer(self, 5) then --each 5 seconds search for parents
if kitz.timer(self, 5) then --each 5 seconds search for parents
petz.follow_parents(self, pos)
end
end
end
--if prty < 7 and self.type == "moth" and mobkit.is_queue_empty_high(self) then --search for a squareball
--if prty < 7 and self.type == "moth" and kitz.is_queue_empty_high(self) then --search for a squareball
--local pos_torch_near = minetest.find_node_near(pos, self.view_range, "default:torch")
--if pos_torch_near then
--mobkit.hq_approach_torch(self, 7, pos_torch_near)
--kitz.hq_approach_torch(self, 7, pos_torch_near)
--return
--end
--end
@ -104,7 +104,7 @@ function petz.flying_brain(self)
local random_number = math.random(1, self.jump_ratio)
if random_number == 1 then
--minetest.chat_send_player("singleplayer", "jump")
mobkit.clear_queue_high(self)
kitz.clear_queue_high(self)
petz.hq_terrestial_jump(self, 8)
end
end
@ -126,7 +126,7 @@ function petz.flying_brain(self)
--Herding
if prty < 4.5 and petz.settings.herding then
if mobkit.timer(self, petz.settings.herding_timing) then
if kitz.timer(self, petz.settings.herding_timing) then
if petz.bh_herding(self, pos, player) then
return
end
@ -143,7 +143,7 @@ function petz.flying_brain(self)
local tpos = nearby_nodes[1] --the first match
local distance = vector.distance(pos, tpos)
if distance > 3.0 then
mobkit.hq_goto(self, 4, tpos)
kitz.hq_goto(self, 4, tpos)
elseif distance <= 3.0 then
if petz.settings.tamagochi_mode and not(self.fed) then
petz.do_feed(self)
@ -151,7 +151,7 @@ function petz.flying_brain(self)
local node = minetest.get_node_or_nil(tpos)
if node and node.name == "bale:bale" then
minetest.remove_node(tpos)
mokapi.make_sound("pos", tpos, "petz_replace", 5 or mokapi.consts.DEFAULT_MAX_HEAR_DISTANCE)
kitz.make_sound("pos", tpos, "petz_replace", 5 or kitz.consts.DEFAULT_MAX_HEAR_DISTANCE)
end
end
end
@ -170,7 +170,7 @@ function petz.flying_brain(self)
--local tpos = obj:get_pos()
--if vector.distance(spos, tpos) > 2 then
--if tpos then
--mobkit.hq_goto(self, 5, tpos)
--kitz.hq_goto(self, 5, tpos)
--end
--else
--local meta = ent:get_meta()
@ -183,7 +183,7 @@ function petz.flying_brain(self)
--end
-- Default Random Sound
mokapi.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
kitz.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
if prty < 3 then
if self.is_arboreal then
@ -205,7 +205,7 @@ function petz.flying_brain(self)
end
--Roam default
if mobkit.is_queue_empty_high(self) and not(self.status) then
if kitz.is_queue_empty_high(self) and not(self.status) then
petz.hq_wanderfly(self, 0)
end

View File

@ -7,7 +7,7 @@ function petz.herbivore_brain(self)
local die = false
mobkit.vitals(self)
kitz.vitals(self)
if self.hp <= 0 then
die = true
@ -34,9 +34,9 @@ function petz.herbivore_brain(self)
petz.check_ground_suffocation(self, pos)
if mobkit.timer(self, 1) then
if kitz.timer(self, 1) then
local prty = mobkit.get_queue_priority(self)
local prty = kitz.get_queue_priority(self)
if prty < 30 then
petz.env_damage(self, pos, 30) --enviromental damage: lava, fire...
@ -51,12 +51,12 @@ function petz.herbivore_brain(self)
if prty < 20 then
if self.isinliquid then
mobkit.hq_liquid_recovery(self, 20)
kitz.hq_liquid_recovery(self, 20)
return
end
end
local player = mobkit.get_nearby_player(self)
local player = kitz.get_nearby_player(self)
--if player then petz.move_head(self, player:get_pos()) end
@ -87,7 +87,7 @@ function petz.herbivore_brain(self)
local player_pos = player:get_pos()
local wielded_item_name = player:get_wielded_item():get_name()
if not(self.is_pet) and self.follow ~= wielded_item_name and vector.distance(pos, player_pos) <= self.view_range then
mobkit.hq_runfrom(self, 14, player)
kitz.hq_runfrom(self, 14, player)
return
end
end
@ -102,16 +102,16 @@ function petz.herbivore_brain(self)
--Baby petz follow their parents
if prty < 10 then
if petz.settings.parent_search and self.parents then
if mobkit.timer(self, 5) then --each 5 seconds search for parents
if kitz.timer(self, 5) then --each 5 seconds search for parents
petz.follow_parents(self, pos)
end
end
end
--if prty < 7 and self.type == "moth" and mobkit.is_queue_empty_high(self) then --search for a squareball
--if prty < 7 and self.type == "moth" and kitz.is_queue_empty_high(self) then --search for a squareball
--local pos_torch_near = minetest.find_node_near(pos, self.view_range, "default:torch")
--if pos_torch_near then
--mobkit.hq_approach_torch(self, 7, pos_torch_near)
--kitz.hq_approach_torch(self, 7, pos_torch_near)
--return
--end
--end
@ -121,7 +121,7 @@ function petz.herbivore_brain(self)
local random_number = math.random(1, self.jump_ratio)
if random_number == 1 then
--minetest.chat_send_player("singleplayer", "jump")
mobkit.clear_queue_high(self)
kitz.clear_queue_high(self)
petz.hq_terrestial_jump(self, 8)
end
end
@ -143,7 +143,7 @@ function petz.herbivore_brain(self)
--Herding
if prty < 4.5 and petz.settings.herding then
if mobkit.timer(self, petz.settings.herding_timing) then
if kitz.timer(self, petz.settings.herding_timing) then
if petz.bh_herding(self, pos, player) then
return
end
@ -161,7 +161,7 @@ function petz.herbivore_brain(self)
local tpos = nearby_nodes[1] --the first match
local distance = vector.distance(pos, tpos)
if distance > 3.0 then
mobkit.hq_goto(self, 4, tpos)
kitz.hq_goto(self, 4, tpos)
elseif distance <= 3.0 then
if petz.settings.tamagochi_mode and not(self.fed) then
petz.do_feed(self)
@ -169,7 +169,7 @@ function petz.herbivore_brain(self)
local node = minetest.get_node_or_nil(tpos)
if node and node.name == "bale:bale" then
minetest.remove_node(tpos)
mokapi.make_sound("pos", tpos, "petz_replace", 5 or mokapi.consts.DEFAULT_MAX_HEAR_DISTANCE)
kitz.make_sound("pos", tpos, "petz_replace", 5 or kitz.consts.DEFAULT_MAX_HEAR_DISTANCE)
end
end
end
@ -188,7 +188,7 @@ function petz.herbivore_brain(self)
--local tpos = obj:get_pos()
--if vector.distance(spos, tpos) > 2 then
--if tpos then
--mobkit.hq_goto(self, 5, tpos)
--kitz.hq_goto(self, 5, tpos)
--end
--else
--local meta = ent:get_meta()
@ -201,7 +201,7 @@ function petz.herbivore_brain(self)
--end
-- Default Random Sound
mokapi.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
kitz.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
if prty < 3 then
if self.is_arboreal then
@ -223,8 +223,8 @@ function petz.herbivore_brain(self)
end
--Roam default
if mobkit.is_queue_empty_high(self) and not(self.status) and not(self.wagon) then
mobkit.hq_roam(self, 0)
if kitz.is_queue_empty_high(self) and not(self.status) and not(self.wagon) then
kitz.hq_roam(self, 0)
end
end

View File

@ -6,7 +6,7 @@ function petz.monster_brain(self)
local pos = self.object:get_pos() --pos of the petz
mobkit.vitals(self)
kitz.vitals(self)
if self.hp <= 0 then -- Die Behaviour
petz.on_die(self)
@ -15,16 +15,16 @@ function petz.monster_brain(self)
petz.check_ground_suffocation(self, pos)
if mobkit.timer(self, 1) then
if kitz.timer(self, 1) then
local prty = mobkit.get_queue_priority(self)
local prty = kitz.get_queue_priority(self)
if prty < 40 and self.isinliquid then
mobkit.hq_liquid_recovery(self, 40)
kitz.hq_liquid_recovery(self, 40)
return
end
local player = mobkit.get_nearby_player(self) --get the player close
local player = kitz.get_nearby_player(self) --get the player close
if prty < 30 then
petz.env_damage(self, pos, 30) --enviromental damage: lava, fire...
@ -39,7 +39,7 @@ function petz.monster_brain(self)
for i = 1, #preys do --loop thru all preys
--minetest.chat_send_player("singleplayer", "preys list="..preys[i])
--minetest.chat_send_player("singleplayer", "node name="..node.name)
local prey = mobkit.get_closest_entity(self, preys[i]) -- look for prey
local prey = kitz.get_closest_entity(self, preys[i]) -- look for prey
if prey then
self.max_speed = 2.5
--minetest.chat_send_player("singleplayer", "got it")
@ -76,12 +76,12 @@ function petz.monster_brain(self)
end
-- Default Random Sound
mokapi.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
kitz.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
--Roam default
if mobkit.is_queue_empty_high(self) then
if kitz.is_queue_empty_high(self) then
self.max_speed = 1.5
mobkit.hq_roam(self, 0)
kitz.hq_roam(self, 0)
end
end

View File

@ -6,7 +6,7 @@ function petz.predator_brain(self)
local pos = self.object:get_pos()
mobkit.vitals(self)
kitz.vitals(self)
if self.hp <= 0 then -- Die Behaviour
petz.on_die(self)
@ -15,16 +15,16 @@ function petz.predator_brain(self)
petz.check_ground_suffocation(self, pos)
if mobkit.timer(self, 1) then
if kitz.timer(self, 1) then
local prty = mobkit.get_queue_priority(self)
local prty = kitz.get_queue_priority(self)
if prty < 40 and self.isinliquid then
mobkit.hq_liquid_recovery(self, 40)
kitz.hq_liquid_recovery(self, 40)
return
end
local player = mobkit.get_nearby_player(self) --get the player close
local player = kitz.get_nearby_player(self) --get the player close
if prty < 30 then
petz.env_damage(self, pos, 30) --enviromental damage: lava, fire...
@ -66,11 +66,11 @@ function petz.predator_brain(self)
end
-- Default Random Sound
mokapi.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
kitz.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
--Roam default
if mobkit.is_queue_empty_high(self) and not(self.status) then
mobkit.hq_roam(self, 0)
if kitz.is_queue_empty_high(self) and not(self.status) then
kitz.hq_roam(self, 0)
end
end

View File

@ -6,7 +6,7 @@ function petz.semiaquatic_brain(self)
local pos = self.object:get_pos()
mobkit.vitals(self)
kitz.vitals(self)
-- Die Behaviour
@ -24,14 +24,14 @@ function petz.semiaquatic_brain(self)
petz.check_ground_suffocation(self, pos)
end
if mobkit.timer(self, 1) then
if kitz.timer(self, 1) then
local prty = mobkit.get_queue_priority(self)
local player = mobkit.get_nearby_player(self)
local prty = kitz.get_queue_priority(self)
local player = kitz.get_nearby_player(self)
--if prty < 100 then
--if petz.isinliquid(self) then
--mobkit.hq_liquid_recovery(self, 100)
--kitz.hq_liquid_recovery(self, 100)
--end
--end
@ -59,9 +59,9 @@ function petz.semiaquatic_brain(self)
local player_pos = player:get_pos()
if vector.distance(pos, player_pos) <= self.view_range then -- if player close
if self.warn_attack then --attack player
mobkit.clear_queue_high(self) -- abandon whatever they've been doing
kitz.clear_queue_high(self) -- abandon whatever they've been doing
if petz.isinliquid(self) then
mobkit.hq_aqua_attack(self, 10, player, 6) -- get revenge
kitz.hq_aqua_attack(self, 10, player, 6) -- get revenge
else
petz.hq_hunt(self, 10, player)
end
@ -76,7 +76,7 @@ function petz.semiaquatic_brain(self)
local random_number = math.random(1, self.jump_ratio)
if random_number == 1 then
--minetest.chat_send_player("singleplayer", "jump")
mobkit.clear_queue_high(self)
kitz.clear_queue_high(self)
petz.hq_terrestial_jump(self, 8)
end
end
@ -87,18 +87,18 @@ function petz.semiaquatic_brain(self)
end
-- Default Random Sound
mokapi.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
kitz.make_misc_sound(self, petz.settings.misc_sound_chance, petz.settings.max_hear_distance)
if self.petz_type == "beaver" then --beaver's dam
petz.create_dam(self, pos)
end
--Roam default
if mobkit.is_queue_empty_high(self) and not(self.status) then
if kitz.is_queue_empty_high(self) and not(self.status) then
if petz.isinliquid(self) then
mobkit.hq_aqua_roam(self, 0, self.max_speed)
kitz.hq_aqua_roam(self, 0, self.max_speed)
else
mobkit.hq_roam(self, 0)
kitz.hq_roam(self, 0)
end
end
end

28
petz/brains/brains.lua Normal file
View File

@ -0,0 +1,28 @@
local modpath= ...
assert(loadfile(modpath .. "/brains/bh_ant.lua"))(modpath)
assert(loadfile(modpath .. "/brains/bh_aquatic.lua"))()
assert(loadfile(modpath .. "/brains/bh_arboreal.lua"))()
assert(loadfile(modpath .. "/brains/bh_attack.lua"))()
assert(loadfile(modpath .. "/brains/bh_bee.lua"))()
assert(loadfile(modpath .. "/brains/bh_breed.lua"))()
assert(loadfile(modpath .. "/brains/bh_fly.lua"))()
assert(loadfile(modpath .. "/brains/bh_follow.lua"))()
assert(loadfile(modpath .. "/brains/bh_herding.lua"))()
assert(loadfile(modpath .. "/brains/bh_herbivore.lua"))()
assert(loadfile(modpath .. "/brains/bh_hunt.lua"))()
assert(loadfile(modpath .. "/brains/bh_mount.lua"))()
assert(loadfile(modpath .. "/brains/bh_replace.lua"))()
assert(loadfile(modpath .. "/brains/bh_runaway.lua"))()
assert(loadfile(modpath .. "/brains/bh_teleport.lua"))()
assert(loadfile(modpath .. "/brains/bh_torch.lua"))()
assert(loadfile(modpath .. "/brains/br_ant.lua"))()
assert(loadfile(modpath .. "/brains/br_aquatic.lua"))()
assert(loadfile(modpath .. "/brains/br_bee.lua"))()
assert(loadfile(modpath .. "/brains/br_herbivore.lua"))()
assert(loadfile(modpath .. "/brains/br_monster.lua"))()
assert(loadfile(modpath .. "/brains/br_predator.lua"))()
assert(loadfile(modpath .. "/brains/br_semiaquatic.lua"))()
assert(loadfile(modpath .. "/brains/helper_functions.lua"))()
assert(loadfile(modpath .. "/brains/bh_head.lua"))()
assert(loadfile(modpath .. "/brains/br_flying.lua"))()

View File

@ -23,7 +23,7 @@ petz.lookat = function(self, pos2)
end
function petz.bh_check_pack(self)
if mobkit.get_closest_entity(self, "petz:"..self.type) then
if kitz.get_closest_entity(self, "petz:"..self.type) then
return true
else
return false
@ -113,13 +113,13 @@ function petz.check_ground_suffocation(self)
if self.can_fly then --some fying mobs can escape from cages by the roof
return
end
local spos = mobkit.get_stand_pos(self)
local spos = kitz.get_stand_pos(self)
spos.y = spos.y + 0.01
if self.type and mobkit.is_alive(self) and not(self.is_baby) then
if self.type and kitz.is_alive(self) and not(self.is_baby) then
local stand_pos = spos
stand_pos.y = spos.y + 0.5
local stand_node_pos = mobkit.get_node_pos(stand_pos)
local stand_node = mobkit.nodeatpos(stand_node_pos)
local stand_node_pos = kitz.get_node_pos(stand_pos)
local stand_node = kitz.nodeatpos(stand_node_pos)
if stand_node and stand_node.walkable and stand_node.drawtype == "normal" then
local new_y = stand_pos.y + self.jump_height
if new_y <= 30927 then
@ -162,7 +162,7 @@ function petz.node_name_in(self, where)
z = pos.z,
}
elseif where == "below" then
pos2 = mobkit.get_stand_pos(self)
pos2 = kitz.get_stand_pos(self)
pos2.y = pos2.y - 0.1
elseif where == "back" then
pos2 = {

View File

@ -36,9 +36,9 @@ kitty_preys = petz:mouse
But it is better to take an old already created one as template.
The better for mouse is piggy: no tamagochi, no orders.
Open 'piggy_mobkit.lua' and save as 'mouse_mobkit.lua'
Open 'piggy_kitz.lua' and save as 'mouse_kitz.lua'
3. Edit the 'mouse_mobkit.lua'.
3. Edit the 'mouse_kitz.lua'.
- Firstly you have to replace all the 'piggy' coincidences to 'mouse'
With the aid of you text editor replace:
@ -50,15 +50,15 @@ PIGGY -> MOUSE
- scale_model, mesh, textures, collisionbox, etc.
4. Save the 'mouse_mobkit.lua'
4. Save the 'mouse_kitz.lua'
5. ¡DONE!
###Extra
####If you have to create a bird use 'parrot_mobkit.lua' as template.
####If you want to create a domestic pet use 'kitty_mobkit.lua' as template.
####If you want to create a wild animal use 'lion_mobkit.lua' as template.
####If you have to create a bird use 'parrot_kitz.lua' as template.
####If you want to create a domestic pet use 'kitty_kitz.lua' as template.
####If you want to create a wild animal use 'lion_kitz.lua' as template.
###Tamagochi mode

View File

@ -28,7 +28,7 @@ assert(loadfile(modpath .. "/settings.lua"))(modpath) --Load the settings
petz.tamed_by_owner = {} --a list of tamed petz with owner
assert(loadfile(modpath .. "/api/api.lua"))(modpath, S)
assert(loadfile(modpath .. "/mobkit/mobkit.lua"))(modpath)
assert(loadfile(modpath .. "/brains/brains.lua"))(modpath)
assert(loadfile(modpath .. "/misc/misc.lua"))(modpath, S)
assert(loadfile(modpath .. "/server/cron.lua"))(modname)
@ -44,7 +44,7 @@ end
if petz.settings["remove_list"] then
for i = 1, #petz.settings["remove_list"] do
local file_name = modpath .. "/petz/"..petz.settings["remove_list"][i].."_mobkit"..".lua"
local file_name = modpath .. "/petz/"..petz.settings["remove_list"][i].."_kitz"..".lua"
if petz.file_exists(file_name) then
assert(loadfile(file_name))(S)
end
@ -52,7 +52,7 @@ if petz.settings["remove_list"] then
for j = 1, #petz.settings["petz_list"] do --load all the petz.lua files
if petz.settings["remove_list"][i] == petz.settings["petz_list"][j] then
table.remove(petz.settings["petz_list"], j)
--mokapi.remove_table_by_key(petz.settings["petz_list"], j)
--kitz.remove_table_by_key(petz.settings["petz_list"], j)
end
end
end

View File

@ -85,7 +85,7 @@ minetest.register_craftitem("petz:whip", {
inventory_image = "petz_whip.png",
wield_image = "petz_whip.png",
after_use = function(itemstack, user, node, digparams)
mokapi.make_sound("player", user, "petz_whip", petz.settings.max_hear_distance)
kitz.make_sound("player", user, "petz_whip", petz.settings.max_hear_distance)
end,
})

View File

@ -419,7 +419,7 @@ minetest.register_chatcommand("howl", {
if player then
if petz.is_werewolf(player) then
local pos = player:get_pos()
mokapi.make_sound("pos", pos, "petz_werewolf_howl", petz.settings.max_hear_distance)
kitz.make_sound("pos", pos, "petz_werewolf_howl", petz.settings.max_hear_distance)
else
return false, "Error: You are not a werewolf."
end
@ -493,7 +493,7 @@ minetest.register_entity("petz:"..pet_name,{
textures = textures,
visual_size = {x=1.0*scale_model, y=1.0*scale_model},
static_save = true,
get_staticdata = mobkit.statfunc,
get_staticdata = kitz.statfunc,
-- api props
springiness= 0,
buoyancy = 0.5, -- portion of hitbox submerged
@ -518,7 +518,7 @@ minetest.register_entity("petz:"..pet_name,{
logic = petz.monster_brain,
on_activate = function(self, staticdata, dtime_s) --on_activate, required
mobkit.actfunc(self, staticdata, dtime_s)
kitz.actfunc(self, staticdata, dtime_s)
petz.set_initial_properties(self, staticdata, dtime_s)
end,
@ -531,7 +531,7 @@ minetest.register_entity("petz:"..pet_name,{
end,
on_step = function(self, dtime)
mobkit.stepfunc(self, dtime) -- required
kitz.stepfunc(self, dtime) -- required
petz.on_step(self, dtime)
end,

View File

@ -78,9 +78,9 @@ petz.force_detach = function(player)
entity.driver = nil
end
if entity.waggon then
mobkit.clear_queue_low(entity)
mobkit.clear_queue_high(entity)
mobkit.animate(entity, "still")
kitz.clear_queue_low(entity)
kitz.clear_queue_high(entity)
kitz.animate(entity, "still")
end
player:set_detach()
player_api.player_attached[player:get_player_name()] = false
@ -115,7 +115,7 @@ function petz.gallop(self, dtime)
self.gallop_time = 0
self.gallop_exhausted = true
minetest.after(petz.settings.gallop_recover_time, function()
if mobkit.is_alive(self) then
if kitz.is_alive(self) then
self.gallop_exhausted = false
end
end, self)

View File

@ -219,8 +219,8 @@ minetest.register_node("petz:chicken_nest_egg", {
return
end
local entity = minetest.add_entity(pos_above, "petz:chicken"):get_luaentity()
entity.is_baby = mobkit.remember(entity, "is_baby", true) --it is a baby
entity.growth_time = mobkit.remember(entity, "growth_time", 0.0) --the chicken to grow
entity.is_baby = kitz.remember(entity, "is_baby", true) --it is a baby
entity.growth_time = kitz.remember(entity, "growth_time", 0.0) --the chicken to grow
minetest.set_node(pos, {name= "petz:ducky_nest"})
return true
end
@ -407,7 +407,7 @@ minetest.register_node("petz:beehive", {
end,
on_destruct = function(pos)
minetest.add_entity(pos, "petz:queen_bee")
mokapi.node_drop_items(pos)
kitz.node_drop_items(pos)
end,
on_timer = function(pos)
local meta, honey_count, bee_count = petz.get_behive_stats(pos)
@ -441,7 +441,7 @@ minetest.register_node("petz:beehive", {
if spawn_bee_pos then
local bee = minetest.add_entity(spawn_bee_pos, "petz:bee")
local bee_entity = bee:get_luaentity()
bee_entity.behive = mobkit.remember(bee_entity, "behive", pos)
bee_entity.behive = kitz.remember(bee_entity, "behive", pos)
bee_count = bee_count - 1
meta:set_int("bee_count", bee_count)
petz.set_infotext_behive(meta, honey_count, bee_count)
@ -665,8 +665,8 @@ minetest.register_node("petz:cat_basket", {
end
if not minetest.is_protected(pos, player_name) then
local ent = petz.create_pet(player, itemstack, itemstack_name:sub(1, -5) , pos_kitty)
mobkit.clear_queue_low(ent)
mobkit.clear_queue_high(ent)
kitz.clear_queue_low(ent)
kitz.clear_queue_high(ent)
petz.sleep(ent, 2, true)
end
return itemstack
@ -787,7 +787,7 @@ minetest.register_node("petz:anthill_entrance", {
local player_near = false
for _, obj in ipairs(nearby_objects) do
if obj:is_player() and mobkit.is_alive(obj) then
if obj:is_player() and kitz.is_alive(obj) then
player_near = true
break
end

View File

@ -15,7 +15,7 @@ minetest.register_entity("petz:wagon",{
hitbox = {-0.5, -1.5, -1.5, 0.5, -0.25, -3.0},
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
if self.object:get_hp() - damage <= 0 then
mokapi.drop_item(self, ItemStack("petz:wagon 1"))
kitz.drop_item(self, ItemStack("petz:wagon 1"))
end
end,
})

View File

@ -11,7 +11,7 @@ minetest.register_node("petz:jack_o_lantern_grenade", {
sounds = default.node_sound_wood_defaults(),
on_use = function(itemstack, user, pointed_thing)
local strength = 20
mokapi.make_sound("player", user, "petz_fireball", petz.settings.max_hear_distance)
kitz.make_sound("player", user, "petz_fireball", petz.settings.max_hear_distance)
if not petz.spawn_throw_object(user, strength, "petz:ent_jack_o_lantern_grenade") then
return -- something failed
end

View File

@ -1,28 +0,0 @@
local modpath= ...
assert(loadfile(modpath .. "/mobkit/bh_ant.lua"))(modpath)
assert(loadfile(modpath .. "/mobkit/bh_aquatic.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_arboreal.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_attack.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_bee.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_breed.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_fly.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_follow.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_herding.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_herbivore.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_hunt.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_mount.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_replace.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_runaway.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_teleport.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_torch.lua"))()
assert(loadfile(modpath .. "/mobkit/br_ant.lua"))()
assert(loadfile(modpath .. "/mobkit/br_aquatic.lua"))()
assert(loadfile(modpath .. "/mobkit/br_bee.lua"))()
assert(loadfile(modpath .. "/mobkit/br_herbivore.lua"))()
assert(loadfile(modpath .. "/mobkit/br_monster.lua"))()
assert(loadfile(modpath .. "/mobkit/br_predator.lua"))()
assert(loadfile(modpath .. "/mobkit/br_semiaquatic.lua"))()
assert(loadfile(modpath .. "/mobkit/helper_functions.lua"))()
assert(loadfile(modpath .. "/mobkit/bh_head.lua"))()
assert(loadfile(modpath .. "/mobkit/br_flying.lua"))()

View File

@ -1,5 +1,4 @@
name = petz
description = Cute mobs for Minetest
depends = default, mobkit, mokapi, stairs, dye, farming, vessels, wool, tnt
depends = kitz, default, stairs, dye, farming, vessels, wool, tnt
optional_depends = bonemeal, 3d_armor, crops, playerphysics, player_monoids
version = 5.23

View File

@ -23,8 +23,7 @@ tamagochi_hungry_warning = 0.5
tamagochi_check_if_player_online = true
tamagochi_safe_nodes = petz:yellow_paving,petz:gray_graving_stone
##Type of API [mobs_redo]
type_api = mobkit
type_api = kitz
##Capture Mobs
lasso = petz:lasso

View File

@ -80,7 +80,7 @@ for i=1, 3 do
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,
get_staticdata = kitz.statfunc,
springiness= 0,
buoyancy = 0.5, -- portion of hitbox submerged
max_speed = 3.5,
@ -108,7 +108,7 @@ for i=1, 3 do
logic = petz.ant_brain,
on_activate = function(self, staticdata, dtime_s) --on_activate, required
mobkit.actfunc(self, staticdata, dtime_s)
kitz.actfunc(self, staticdata, dtime_s)
petz.set_initial_properties(self, staticdata, dtime_s)
end,
@ -125,7 +125,7 @@ for i=1, 3 do
end,
on_step = function(self, dtime)
mobkit.stepfunc(self, dtime) -- required
kitz.stepfunc(self, dtime) -- required
petz.on_step(self, dtime)
end,
})

View File

@ -33,7 +33,7 @@ minetest.register_entity("petz:"..pet_name,{
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,
get_staticdata = kitz.statfunc,
-- api props
springiness= 0,
buoyancy = 0.5, -- portion of hitbox submerged
@ -64,7 +64,7 @@ minetest.register_entity("petz:"..pet_name,{
logic = petz.flying_brain,
on_activate = function(self, staticdata, dtime_s) --on_activate, required
mobkit.actfunc(self, staticdata, dtime_s)
kitz.actfunc(self, staticdata, dtime_s)
petz.set_initial_properties(self, staticdata, dtime_s)
end,
@ -81,7 +81,7 @@ minetest.register_entity("petz:"..pet_name,{
end,
on_step = function(self, dtime)
mobkit.stepfunc(self, dtime) -- required
kitz.stepfunc(self, dtime) -- required
petz.on_step(self, dtime)
end,

View File

@ -38,7 +38,7 @@ minetest.register_entity("petz:"..pet_name,{
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,
get_staticdata = kitz.statfunc,
-- api props
springiness= 0,
buoyancy = 1.1, -- portion of hitbox submerged
@ -67,7 +67,7 @@ minetest.register_entity("petz:"..pet_name,{
logic = petz.semiaquatic_brain,
on_activate = function(self, staticdata, dtime_s) --on_activate, required
mobkit.actfunc(self, staticdata, dtime_s)
kitz.actfunc(self, staticdata, dtime_s)
petz.set_initial_properties(self, staticdata, dtime_s)
end,
@ -84,7 +84,7 @@ minetest.register_entity("petz:"..pet_name,{
end,
on_step = function(self, dtime)
mobkit.stepfunc(self, dtime) -- required
kitz.stepfunc(self, dtime) -- required
petz.on_step(self, dtime)
end,

View File

@ -56,7 +56,7 @@ for i=1, 2 do
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,
get_staticdata = kitz.statfunc,
-- api props
springiness= 0,
buoyancy = 0.5, -- portion of hitbox submerged
@ -90,7 +90,7 @@ for i=1, 2 do
logic = petz.bee_brain,
on_activate = function(self, staticdata, dtime_s) --on_activate, required
mobkit.actfunc(self, staticdata, dtime_s)
kitz.actfunc(self, staticdata, dtime_s)
petz.set_initial_properties(self, staticdata, dtime_s)
end,
@ -107,7 +107,7 @@ for i=1, 2 do
end,
on_step = function(self, dtime)
mobkit.stepfunc(self, dtime) -- required
kitz.stepfunc(self, dtime) -- required
petz.on_step(self, dtime)
end,
})

View File

@ -54,7 +54,7 @@ minetest.register_entity("petz:"..pet_name, {
visual_size = visual_size,
visual_size_baby = visual_size_baby,
static_save = true,
get_staticdata = mobkit.statfunc,
get_staticdata = kitz.statfunc,
-- api props
springiness= 0,
buoyancy = 0.5, -- portion of hitbox submerged
@ -91,7 +91,7 @@ minetest.register_entity("petz:"..pet_name, {
logic = petz.herbivore_brain,
on_activate = function(self, staticdata, dtime_s) --on_activate, required
mobkit.actfunc(self, staticdata, dtime_s)
kitz.actfunc(self, staticdata, dtime_s)
petz.set_initial_properties(self, staticdata, dtime_s)
end,
@ -108,7 +108,7 @@ minetest.register_entity("petz:"..pet_name, {
end,
on_step = function(self, dtime)
mobkit.stepfunc(self, dtime) -- required
kitz.stepfunc(self, dtime) -- required
petz.on_step(self, dtime)
end,
})

View File

@ -33,7 +33,7 @@ minetest.register_entity("petz:"..pet_name,{
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,
get_staticdata = kitz.statfunc,
-- api props
springiness= 0,
buoyancy = 0.5, -- portion of hitbox submerged
@ -57,7 +57,7 @@ minetest.register_entity("petz:"..pet_name,{
logic = petz.flying_brain,
on_activate = function(self, staticdata, dtime_s) --on_activate, required
mobkit.actfunc(self, staticdata, dtime_s)
kitz.actfunc(self, staticdata, dtime_s)
petz.set_initial_properties(self, staticdata, dtime_s)
end,
@ -74,7 +74,7 @@ minetest.register_entity("petz:"..pet_name,{
end,
on_step = function(self, dtime)
mobkit.stepfunc(self, dtime) -- required
kitz.stepfunc(self, dtime) -- required
petz.on_step(self, dtime)
end,

View File

@ -56,7 +56,7 @@ minetest.register_entity("petz:"..pet_name,{
visual_size = visual_size,
visual_size_baby = visual_size_baby,
static_save = true,
get_staticdata = mobkit.statfunc,
get_staticdata = kitz.statfunc,
-- api props
springiness= 0,
buoyancy = 0.5, -- portion of hitbox submerged
@ -90,7 +90,7 @@ minetest.register_entity("petz:"..pet_name,{
logic = petz.herbivore_brain,
on_activate = function(self, staticdata, dtime_s) --on_activate, required
mobkit.actfunc(self, staticdata, dtime_s)
kitz.actfunc(self, staticdata, dtime_s)
petz.set_initial_properties(self, staticdata, dtime_s)
end,
@ -107,7 +107,7 @@ minetest.register_entity("petz:"..pet_name,{
end,
on_step = function(self, dtime)
mobkit.stepfunc(self, dtime) -- required
kitz.stepfunc(self, dtime) -- required
petz.on_step(self, dtime)
end,
})

View File

@ -60,7 +60,7 @@ minetest.register_entity("petz:"..pet_name, {
visual_size = visual_size,
visual_size_baby = visual_size_baby,
static_save = true,
get_staticdata = mobkit.statfunc,
get_staticdata = kitz.statfunc,
-- api props
springiness= 0,
buoyancy = 0.5, -- portion of hitbox submerged
@ -89,7 +89,7 @@ minetest.register_entity("petz:"..pet_name, {
logic = petz.herbivore_brain,
on_activate = function(self, staticdata, dtime_s) --on_activate, required
mobkit.actfunc(self, staticdata, dtime_s)
kitz.actfunc(self, staticdata, dtime_s)
petz.set_initial_properties(self, staticdata, dtime_s)
end,
@ -106,7 +106,7 @@ minetest.register_entity("petz:"..pet_name, {
end,
on_step = function(self, dtime)
mobkit.stepfunc(self, dtime) -- required
kitz.stepfunc(self, dtime) -- required
petz.on_step(self, dtime)
end,
})

View File

@ -105,7 +105,7 @@ for i=1, 3 do
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,
get_staticdata = kitz.statfunc,
-- api props
springiness= 0,
buoyancy = 0.5, -- portion of hitbox submerged
@ -131,7 +131,7 @@ for i=1, 3 do
logic = petz.herbivore_brain,
on_activate = function(self, staticdata, dtime_s) --on_activate, required
mobkit.actfunc(self, staticdata, dtime_s)
kitz.actfunc(self, staticdata, dtime_s)
petz.set_initial_properties(self, staticdata, dtime_s)
end,
@ -148,7 +148,7 @@ for i=1, 3 do
end,
on_step = function(self, dtime)
mobkit.stepfunc(self, dtime) -- required
kitz.stepfunc(self, dtime) -- required
petz.on_step(self, dtime)
end,
})

View File

@ -33,7 +33,7 @@ minetest.register_entity("petz:"..pet_name,{
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,
get_staticdata = kitz.statfunc,
-- api props
springiness= 0,
buoyancy = 0.5, -- portion of hitbox submerged
@ -64,7 +64,7 @@ minetest.register_entity("petz:"..pet_name,{
logic = petz.herbivore_brain,
on_activate = function(self, staticdata, dtime_s) --on_activate, required
mobkit.actfunc(self, staticdata, dtime_s)
kitz.actfunc(self, staticdata, dtime_s)
petz.set_initial_properties(self, staticdata, dtime_s)
end,
@ -81,7 +81,7 @@ minetest.register_entity("petz:"..pet_name,{
end,
on_step = function(self, dtime)
mobkit.stepfunc(self, dtime) -- required
kitz.stepfunc(self, dtime) -- required
petz.on_step(self, dtime)
end,
})

Some files were not shown because too many files have changed in this diff Show More