Integrate more switches into internal api elements of head code
This commit is contained in:
parent
6a38198e97
commit
a8152760b9
|
@ -368,15 +368,39 @@ function mobs:register_mob(name, def)
|
|||
|
||||
|
||||
--head code variables
|
||||
--defaults are for the cow's default
|
||||
--because I don't know what else to set them
|
||||
--to :P
|
||||
|
||||
has_head = def.has_head or false,
|
||||
head_bone = def.head_bone,
|
||||
|
||||
--you must use these to adjust the mob's head positions
|
||||
|
||||
--has_head is used as a logic gate (quick easy check)
|
||||
has_head = def.has_head or false,
|
||||
--head_bone is the actual bone in the model which the head
|
||||
--is attached to for animation
|
||||
head_bone = def.head_bone or "head",
|
||||
|
||||
--this part controls the base position of the head calculations
|
||||
--localized to the mob's visual yaw when gotten (self.object:get_yaw())
|
||||
--you can enable the debug in /mob_functions/head_logic.lua by uncommenting the
|
||||
--particle spawner code
|
||||
head_height_offset = def.head_height_offset or 1.0525,
|
||||
head_direction_offset = def.head_direction_offset or 0.5,
|
||||
|
||||
--this part controls the visual of the head
|
||||
head_bone_pos_y = def.head_bone_pos_y or 3.6,
|
||||
head_bone_pos_z = def.head_bone_pos_z or -0.6,
|
||||
|
||||
--these variables are switches in case the model
|
||||
--moves the wrong way
|
||||
swap_y_with_x = def.swap_y_with_x or false,
|
||||
reverse_head_yaw = def.reverse_head_yaw or false,
|
||||
|
||||
--END HEAD CODE VARIABLES
|
||||
|
||||
--end j4i stuff
|
||||
|
||||
-- MCL2 extensions
|
||||
|
|
|
@ -832,8 +832,11 @@ mobs.mob_step = function(self, dtime)
|
|||
|
||||
|
||||
--DEBUG TIME!
|
||||
--REMEMBER TO MOVE THIS AFTER DEATH CHECK
|
||||
|
||||
if self.has_head then
|
||||
mobs.do_head_logic(self,dtime)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
@ -855,9 +858,6 @@ mobs.mob_step = function(self, dtime)
|
|||
end
|
||||
end
|
||||
|
||||
--make it so mobs do not glitch out when walking around/jumping
|
||||
mobs.swap_auto_step_height_adjust(self)
|
||||
|
||||
--color modifier which coincides with the pause_timer
|
||||
if self.old_health and self.health < self.old_health then
|
||||
self.object:set_texture_mod("^[colorize:red:120")
|
||||
|
@ -895,9 +895,6 @@ mobs.mob_step = function(self, dtime)
|
|||
|
||||
mobs.random_sound_handling(self,dtime)
|
||||
|
||||
|
||||
|
||||
|
||||
--mobs drowning mechanic
|
||||
if not self.breathes_in_water then
|
||||
|
||||
|
@ -1112,6 +1109,9 @@ mobs.mob_step = function(self, dtime)
|
|||
return false
|
||||
end
|
||||
|
||||
--make it so mobs do not glitch out when walking around/jumping
|
||||
mobs.swap_auto_step_height_adjust(self)
|
||||
|
||||
|
||||
-- can mob be pushed, if so calculate direction -- do this last (overrides everything)
|
||||
if self.pushable then
|
||||
|
|
|
@ -24,14 +24,8 @@ mobs.do_head_logic = function(self,dtime)
|
|||
local body_dir = minetest.yaw_to_dir(body_yaw)
|
||||
|
||||
|
||||
--needs to be INTERNAL(API)
|
||||
self.head_height_offset = 1.0525
|
||||
|
||||
pos.y = pos.y + self.head_height_offset
|
||||
|
||||
--needs to be INTERNAL (API)
|
||||
self.head_direction_offset = 0.5
|
||||
|
||||
local head_offset = vector.multiply(body_dir, self.head_direction_offset)
|
||||
|
||||
pos = vector.add(pos, head_offset)
|
||||
|
@ -52,12 +46,9 @@ mobs.do_head_logic = function(self,dtime)
|
|||
local bone_pos = vector_new(0,0,0)
|
||||
|
||||
|
||||
--needs to be INTERNAL (API)
|
||||
--(horizontal)
|
||||
bone_pos.y = self.head_bone_pos_y
|
||||
|
||||
|
||||
--needs to be INTERNAL (API)
|
||||
--(vertical)
|
||||
bone_pos.z = self.head_bone_pos_z
|
||||
|
||||
|
|
|
@ -84,6 +84,16 @@ local cow_def = {
|
|||
follow = mobs_mc.items.wheat,
|
||||
view_range = 10,
|
||||
fear_height = 4,
|
||||
|
||||
--head code
|
||||
has_head = true,
|
||||
head_bone = "head",
|
||||
swap_y_with_x = false,
|
||||
reverse_head_yaw = false,
|
||||
head_bone_pos_y = 3.6,
|
||||
head_bone_pos_z = -0.6,
|
||||
head_height_offset = 1.0525,
|
||||
head_direction_offset = 0.5,
|
||||
}
|
||||
|
||||
mobs:register_mob("mobs_mc:cow", cow_def)
|
||||
|
|
|
@ -54,8 +54,14 @@ mobs:register_mob("mobs_mc:creeper", {
|
|||
stop_to_explode = true,
|
||||
|
||||
--head code
|
||||
has_head = true,
|
||||
head_bone = "head",
|
||||
swap_y_with_x = true,
|
||||
reverse_head_yaw = true,
|
||||
head_bone_pos_y = 3.6,
|
||||
head_bone_pos_z = -0.6,
|
||||
head_height_offset = 1.0525,
|
||||
head_direction_offset = 0.5,
|
||||
|
||||
-- Force-ignite creeper with flint and steel and explode after 1.5 seconds.
|
||||
-- TODO: Make creeper flash after doing this as well.
|
||||
|
|
Loading…
Reference in New Issue