master
runs 2020-05-16 05:12:54 +02:00
parent 3bcd35d151
commit 872315eee1
18 changed files with 159 additions and 18 deletions

View File

@ -9,3 +9,31 @@ function mokapi.delimit_number(number, range)
end
return number
end
--Trigonometric Functions
--converts yaw to degrees
function mokapi.degrees(yaw)
return(yaw * 180.0 / math.pi)
end
function mokapi.degrees_to_radians(degrees)
return(degrees/180.0*math.pi)
end
--converts yaw to degrees
function mokapi.yaw_to_degrees(yaw)
return(yaw*180.0/math.pi)
end
--rounds it up to an integer
function mokapi.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)
return(radians*180.0/math.pi)
end

View File

@ -351,6 +351,9 @@ function petz.set_initial_properties(self, staticdata, dtime_s)
end
end
petz.calculate_sleep_times(self) --Sleep behaviour
--self.head_rotation = {x= -90, y= 90, z= 0}
--self.whead_position = self.object:get_bone_position("parent")
--self.head_position.y = self.head_position.y + 0.25
--ALL the mobs
if self.is_pet and self.tamed then
petz.update_nametag(self)

View File

@ -27,6 +27,7 @@ Bone=Knochen
Bottle with Moth=Flasche mit Motte
Brushed=Gebürstet
Butterfly=Schmetterling
Butterfly Showcase=Schmetterling-Vitrine
Buy=Kaufen
Camel=Kamel
Cancel=Abbrechen

View File

@ -27,6 +27,7 @@ Bone=Hueso
Bottle with Moth=Botella con polilla
Brushed=Cepillado
Butterfly=Mariposa
Butterfly Showcase=Expositor de mariposas
Buy=Comprar
Camel=Camello
Cancel=Cancelar

View File

@ -27,6 +27,7 @@ Brushed=Brossé
Bone=Os
Bottle with Moth=Bouteille de papillon nocturne
Butterfly=Papillon
Butterfly Showcase=Vitrine des papillons
Buy=Acheter
Camel=Chameau
Cancel=Annuler

View File

@ -27,6 +27,7 @@ Bone= Кость
Bottle with Moth=Бутылка с мотылем
Brushed=Почищенный
Butterfly= бабочка
Butterfly Showcase=Витрина бабочки
Buy=Купить
Cancel=Отменить
Camel=Верблюд

View File

@ -1,21 +1,21 @@
local modpath, S = ...
--Pet Hairbrush
minetest.register_craftitem("petz:hairbrush", {
description = S("Hairbrush"),
inventory_image = "petz_hairbrush.png",
wield_image = "petz_hairbrush.png"
})
minetest.register_craftitem("petz:hairbrush", {
description = S("Hairbrush"),
inventory_image = "petz_hairbrush.png",
wield_image = "petz_hairbrush.png"
})
minetest.register_craft({
type = "shaped",
output = "petz:hairbrush",
recipe = {
{"", "", ""},
{"", "default:stick", "farming:string"},
{"default:stick", "", ""},
}
})
minetest.register_craft({
type = "shaped",
output = "petz:hairbrush",
recipe = {
{"", "", ""},
{"", "default:stick", "farming:string"},
{"default:stick", "", ""},
}
})
--Pet Bowl
minetest.register_node("petz:pet_bowl", {

View File

@ -646,6 +646,35 @@ minetest.register_craft({
}
})
minetest.register_node("petz:butterfly_showcase", {
description = S("Butterfly Showcase"),
drawtype = "nodebox",
walkable = true,
paramtype = "light",
paramtype2 = "facedir",
tiles = {"petz_butterfly_showcase.png"},
inventory_image = "petz_butterfly_showcase.png",
wield_image = "petz_butterfly_showcase.png",
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0.49, 0.5, 0.5, 0.5}
},
groups = {
snappy = 2, flammable = 3, oddly_breakable_by_hand = 3, choppy = 2, carpet = 1, leafdecay = 3, leaves = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_craft({
type = "shaped",
output = "petz:butterfly_showcase",
recipe = {
{"group:wood", "petz:butterfly_set", "group:wood"},
{"petz:butterfly_set", "xpanes:pane_flat", "petz:butterfly_set"},
{"group:wood", "petz:butterfly_set", "group:wood"},
}
})
minetest.register_node("petz:honey_block", {
description = S("Honey Block"),
drawtype = "nodebox",
@ -666,5 +695,4 @@ minetest.register_node("petz:honey_block", {
use_texture_alpha = true,
light_source = default.LIGHT_MAX - 1,
sounds = default.node_sound_glass_defaults(),
})

View File

@ -131,15 +131,18 @@ function petz.lq_jumpattack(self,height,target)
local yaw = self.object:get_yaw()
local dir = minetest.yaw_to_dir(yaw)
local apos = mobkit.pos_translate2d(pos,yaw,self.attack.range)
--if petz.is_pos_in_box(self,apos,tgtpos,tgtbox) then --bite
local distance = vector.distance(pos, tgtpos)
--minetest.chat_send_all(tostring(distance))
if distance < 2.0 then
--if petz.is_pos_in_box(self,apos,tgtpos,tgtbox) then --bite
target:punch(self.object,1,self.attack)
-- bounce off
-- 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
mobkit.make_sound(self,'attack')
phase=4
--end
end
end
end
mobkit.queue_low(self,func)

67
petz/mobkit/bh_head.lua Normal file
View File

@ -0,0 +1,67 @@
local modpath, S = ...
--make sure this is redefined as shown below aka
--don't run mob_rotation_degree_to_radians(rotation)
--run local radians = mob_rotation_degree_to_radians(rotation)
--or the mobs head rotation will become overwritten
local head_rotation_to_radians = function(rotation)
return{
x = 0, --roll should never be changed
y = degrees_to_radians(180 - rotation.y)*-1,
z = degrees_to_radians(90 - rotation.z)
}
end
--a movement test to move the head
petz.move_head = function(self, tpos, dtime)
local head_position, head_rotation = self.object:get_bone_position("head")
local pos = self.object:get_pos()
head_position = self.head_position
local direction = vector.direction(pos, tpos)
--local yaw = minetest.dir_to_yaw(look_at_dir)
--local body_yaw = self.object:get_yaw()
look_at_dir = vector.normalize(direction)
local yaw = 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))
--yaw = mokapi.degrees(yaw)
minetest.chat_send_all("yaw= "..tostring(yaw))
--local pitch = mokapi.yaw_to_degrees(math.asin(look_at_dir.y))
--local roll = 0
--head_rotation.y = mokapi.yaw_to_degrees(yaw)
--head_rotation.x = mokapi.yaw_to_degrees(pitch)
--head_rotation.x = head_rotation. + yaw
if yaw < 60 and yaw > -60 then
head_rotation = {x= -90, y= 90-yaw, z= 0}
minetest.chat_send_all("yes")
else
head_rotation = self.head_rotation
end
self.object:set_bone_position("head", head_position, head_rotation)
end
--void lookAt(Vec3 center)
-- Vec3 direction = (center - position).normalized;
-- pitch = asin(direction.y);
-- yaw = atan2(direction.x, direction.z);
--}
--this sets the mob to move it's head back to pointing forwards
petz.return_head_to_origin = function(self, dtime)
local head_position, head_rotation = self.object:get_bone_position("head")
--make the head yaw move back
if head_rotation.x > 0 then
head_rotation.x = head_rotation.x - 1
elseif head_rotation.x < 0 then
head_rotation.x = head_rotation.x + 1
end
--move up down (pitch) back to center
if head_rotation.z > 0 then
head_rotation.z = head_rotation.z - 1
elseif head_rotation.z < 0 then
head_rotation.z = head_rotation.z + 1
end
self.object:set_bone_position("head", head_position, head_rotation)
end

View File

@ -64,6 +64,8 @@ function petz.herbivore_brain(self)
local player = mobkit.get_nearby_player(self)
--if player then petz.move_head(self, player:get_pos()) end
--Runaway from predator
if prty < 18 then
if petz.bh_runaway_from_predator(self, pos) == true then

View File

@ -20,3 +20,4 @@ assert(loadfile(modpath .. "/mobkit/br_monster.lua"))(modpath, S)
assert(loadfile(modpath .. "/mobkit/br_predator.lua"))(modpath, S)
assert(loadfile(modpath .. "/mobkit/br_semiaquatic.lua"))(modpath, S)
assert(loadfile(modpath .. "/mobkit/helper_functions.lua"))(modpath, S)
--assert(loadfile(modpath .. "/mobkit/bh_head.lua"))(modpath, S)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -65,6 +65,9 @@ horseshoe_speedup = 0.2
##lashing
lashing_tame_count = 3
##Petz look at when they are fed, its owner...
look_at = true
##Breed System
pregnant_count = 5
pregnancy_time = 300

View File

@ -28,6 +28,8 @@ petz.settings.igniter_damage = tonumber(settings:get("igniter_damage")) --lava &
petz.settings.type_api = settings:get("type_api", "mobs_redo")
--Capture Mobs
petz.settings.rob_mobs = settings:get_bool("rob_mobs", false)
--Look at
petz.settings.look_at = settings:get_bool("look_at", true)
--Selling
petz.settings.selling = settings:get_bool("selling", false)
petz.settings.selling_exchange_items = string.split(settings:get("selling_exchange_items", ""), ",")

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB