forked from MineClone5/MineClone5
Add in swap_y_with_x and reverse_head_yaw to flesh out head code api element
This commit is contained in:
parent
d28e81bc9f
commit
6a38198e97
|
@ -371,6 +371,12 @@ function mobs:register_mob(name, def)
|
||||||
has_head = def.has_head or false,
|
has_head = def.has_head or false,
|
||||||
head_bone = def.head_bone,
|
head_bone = def.head_bone,
|
||||||
|
|
||||||
|
--you must use these to adjust the mob's head positions
|
||||||
|
head_bone_pos_y = def.head_bone_pos_y or 3.6,
|
||||||
|
head_bone_pos_z = def.head_bone_pos_z or -0.6,
|
||||||
|
swap_y_with_x = def.swap_y_with_x or false,
|
||||||
|
reverse_head_yaw = def.reverse_head_yaw or false,
|
||||||
|
|
||||||
--end j4i stuff
|
--end j4i stuff
|
||||||
|
|
||||||
-- MCL2 extensions
|
-- MCL2 extensions
|
||||||
|
|
|
@ -54,13 +54,11 @@ mobs.do_head_logic = function(self,dtime)
|
||||||
|
|
||||||
--needs to be INTERNAL (API)
|
--needs to be INTERNAL (API)
|
||||||
--(horizontal)
|
--(horizontal)
|
||||||
self.head_bone_pos_y = 3.6
|
|
||||||
bone_pos.y = self.head_bone_pos_y
|
bone_pos.y = self.head_bone_pos_y
|
||||||
|
|
||||||
|
|
||||||
--needs to be INTERNAL (API)
|
--needs to be INTERNAL (API)
|
||||||
--(vertical)
|
--(vertical)
|
||||||
self.head_bone_pos_z = -0.6
|
|
||||||
bone_pos.z = self.head_bone_pos_z
|
bone_pos.z = self.head_bone_pos_z
|
||||||
|
|
||||||
--print(yaw)
|
--print(yaw)
|
||||||
|
@ -70,10 +68,13 @@ mobs.do_head_logic = function(self,dtime)
|
||||||
--bone_rot.x = bone_rot.x + (dtime * 10)
|
--bone_rot.x = bone_rot.x + (dtime * 10)
|
||||||
--bone_rot.z = bone_rot.z + (dtime * 10)
|
--bone_rot.z = bone_rot.z + (dtime * 10)
|
||||||
|
|
||||||
local head_yaw
|
|
||||||
|
|
||||||
|
local head_yaw
|
||||||
head_yaw = minetest.dir_to_yaw(vector.direction(pos,look_at)) - body_yaw
|
head_yaw = minetest.dir_to_yaw(vector.direction(pos,look_at)) - body_yaw
|
||||||
|
|
||||||
|
if self.reverse_head_yaw then
|
||||||
|
head_yaw = head_yaw * -1
|
||||||
|
end
|
||||||
|
|
||||||
--over rotation protection
|
--over rotation protection
|
||||||
--stops radians from going out of spec
|
--stops radians from going out of spec
|
||||||
|
@ -105,8 +106,11 @@ mobs.do_head_logic = function(self,dtime)
|
||||||
head_pitch = minetest.dir_to_yaw(vector.new(vector.distance(vector.new(pos.x,0,pos.z),vector.new(look_at.x,0,look_at.z)),0,pos.y-look_at.y))+(math.pi/2)
|
head_pitch = minetest.dir_to_yaw(vector.new(vector.distance(vector.new(pos.x,0,pos.z),vector.new(look_at.x,0,look_at.z)),0,pos.y-look_at.y))+(math.pi/2)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.object:set_bone_position("head", bone_pos, vector_new(degrees(head_pitch),0,degrees(head_yaw)))
|
if self.swap_y_with_x then
|
||||||
|
self.object:set_bone_position("head", bone_pos, vector_new(degrees(head_pitch),degrees(head_yaw),0))
|
||||||
|
else
|
||||||
|
self.object:set_bone_position("head", bone_pos, vector_new(degrees(head_pitch),0,degrees(head_yaw)))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--set_bone_position([bone, position, rotation])
|
--set_bone_position([bone, position, rotation])
|
||||||
|
|
|
@ -53,6 +53,10 @@ mobs:register_mob("mobs_mc:creeper", {
|
||||||
allow_fuse_reset = true,
|
allow_fuse_reset = true,
|
||||||
stop_to_explode = true,
|
stop_to_explode = true,
|
||||||
|
|
||||||
|
--head code
|
||||||
|
swap_y_with_x = true,
|
||||||
|
reverse_head_yaw = true,
|
||||||
|
|
||||||
-- Force-ignite creeper with flint and steel and explode after 1.5 seconds.
|
-- Force-ignite creeper with flint and steel and explode after 1.5 seconds.
|
||||||
-- TODO: Make creeper flash after doing this as well.
|
-- TODO: Make creeper flash after doing this as well.
|
||||||
-- TODO: Test and debug this code.
|
-- TODO: Test and debug this code.
|
||||||
|
|
Loading…
Reference in New Issue