Merge pull request 'Overhaul horse' (#1620) from jordan4ibanez/MineClone2:mineclone5 into mineclone5
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/1620mineclone5
commit
8ea546abfb
|
@ -672,6 +672,14 @@ mobs.mob_step = function(self, dtime)
|
|||
if self.do_custom then
|
||||
-- when false skip going any further
|
||||
if self.do_custom(self, dtime) == false then
|
||||
--this needs to be here or the mob becomes immortal
|
||||
if self.pause_timer > 0 then
|
||||
self.pause_timer = self.pause_timer - dtime
|
||||
--perfectly reset pause_timer
|
||||
if self.pause_timer < 0 then
|
||||
self.pause_timer = 0
|
||||
end
|
||||
end
|
||||
--this overrides internal lua collision detection
|
||||
return
|
||||
end
|
||||
|
|
|
@ -39,10 +39,10 @@ mobs.collision = function(self)
|
|||
end
|
||||
|
||||
for _,object in ipairs(minetest_get_objects_inside_radius(pos, radius*1.25)) do
|
||||
if object and object ~= self.object and (object:is_player() or (object:get_luaentity() and object:get_luaentity()._cmi_is_mob == true)) then--and
|
||||
if object and object ~= self.object and (object:is_player() or (object:get_luaentity() and object:get_luaentity()._cmi_is_mob == true)) and
|
||||
--don't collide with rider, rider don't collide with thing
|
||||
--(not object:get_attach() or (object:get_attach() and object:get_attach() ~= self.object)) and
|
||||
--(not self.object:get_attach() or (self.object:get_attach() and self.object:get_attach() ~= object)) then
|
||||
(not object:get_attach() or (object:get_attach() and object:get_attach() ~= self.object)) and
|
||||
(not self.object:get_attach() or (self.object:get_attach() and self.object:get_attach() ~= object)) then
|
||||
--stop infinite loop
|
||||
collision_count = collision_count + 1
|
||||
if collision_count > 100 then
|
||||
|
|
|
@ -89,6 +89,20 @@ end
|
|||
mobs.death_logic = function(self, dtime)
|
||||
self.death_animation_timer = self.death_animation_timer + dtime
|
||||
|
||||
--get all attached entities and sort through them
|
||||
local attached_entities = self.object:get_children()
|
||||
if #attached_entities > 0 then
|
||||
for _,entity in pairs(attached_entities) do
|
||||
--kick the player off
|
||||
if entity:is_player() then
|
||||
mobs.detach(entity)
|
||||
--kick mobs off
|
||||
--if there is scaling issues, this needs an additional check
|
||||
else
|
||||
entity:set_detach()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--the final POOF of a mob despawning
|
||||
if self.death_animation_timer >= 1.25 then
|
||||
|
|
|
@ -59,3 +59,64 @@ mobs.critical_effect = function(self)
|
|||
texture = "heart.png^[colorize:black:255",
|
||||
})
|
||||
end
|
||||
|
||||
--when feeding a mob
|
||||
mobs.feed_effect = function(self)
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
local yaw = self.object:get_yaw()
|
||||
local collisionbox = self.object:get_properties().collisionbox
|
||||
|
||||
local min, max
|
||||
|
||||
if collisionbox then
|
||||
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
|
||||
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
|
||||
end
|
||||
|
||||
minetest_add_particlespawner({
|
||||
amount = 10,
|
||||
time = 0.0001,
|
||||
minpos = vector.add(pos, min),
|
||||
maxpos = vector.add(pos, max),
|
||||
minvel = vector.new(-1,1,-1),
|
||||
maxvel = vector.new(1,3,1),
|
||||
minexptime = 0.7,
|
||||
maxexptime = 1,
|
||||
minsize = 1,
|
||||
maxsize = 2,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "heart.png^[colorize:gray:255",
|
||||
})
|
||||
end
|
||||
|
||||
--hearts when tamed
|
||||
mobs.tamed_effect = function(self)
|
||||
local pos = self.object:get_pos()
|
||||
local yaw = self.object:get_yaw()
|
||||
local collisionbox = self.object:get_properties().collisionbox
|
||||
|
||||
local min, max
|
||||
|
||||
if collisionbox then
|
||||
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
|
||||
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
|
||||
end
|
||||
|
||||
minetest_add_particlespawner({
|
||||
amount = 30,
|
||||
time = 0.0001,
|
||||
minpos = vector.add(pos, min),
|
||||
maxpos = vector.add(pos, max),
|
||||
minvel = vector.new(-1,1,-1),
|
||||
maxvel = vector.new(1,3,1),
|
||||
minexptime = 0.7,
|
||||
maxexptime = 1,
|
||||
minsize = 1,
|
||||
maxsize = 2,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "heart.png",
|
||||
})
|
||||
end
|
|
@ -206,21 +206,30 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||
-- move forwards
|
||||
if ctrl.up then
|
||||
|
||||
entity.v = entity.v + entity.accel / 10
|
||||
mobs.set_velocity(entity, entity.run_velocity)
|
||||
|
||||
mobs.set_mob_animation(entity, moving_anim)
|
||||
|
||||
-- move backwards
|
||||
elseif ctrl.down then
|
||||
|
||||
if entity.max_speed_reverse == 0 and entity.v == 0 then
|
||||
return
|
||||
mobs.set_velocity(entity, -entity.run_velocity)
|
||||
|
||||
mobs.set_mob_animation(entity, moving_anim)
|
||||
|
||||
--halt
|
||||
else
|
||||
|
||||
mobs.set_velocity(entity, 0)
|
||||
|
||||
mobs.set_mob_animation(entity, stand_anim)
|
||||
end
|
||||
|
||||
entity.v = entity.v - entity.accel / 10
|
||||
end
|
||||
|
||||
-- fix mob rotation
|
||||
-- mob rotation
|
||||
entity.object:set_yaw(entity.driver:get_look_horizontal() - entity.rotate)
|
||||
entity.yaw = entity.driver:get_look_horizontal() - entity.rotate
|
||||
|
||||
--[[
|
||||
if can_fly then
|
||||
|
||||
-- fly up
|
||||
|
@ -244,32 +253,21 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||
end
|
||||
|
||||
else
|
||||
]]--
|
||||
|
||||
-- jump
|
||||
if ctrl.jump then
|
||||
|
||||
if velo.y == 0 then
|
||||
velo.y = velo.y + entity.jump_height
|
||||
acce_y = acce_y + (acce_y * 3) + 1
|
||||
end
|
||||
mobs.jump(entity)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-- if not moving then set animation and return
|
||||
if entity.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||
|
||||
if stand_anim then
|
||||
mobs:set_animation(entity, stand_anim)
|
||||
end
|
||||
|
||||
return
|
||||
--end
|
||||
end
|
||||
|
||||
--[[
|
||||
-- set moving animation
|
||||
if moving_anim then
|
||||
mobs:set_animation(entity, moving_anim)
|
||||
mobs:set_mob_animation(entity, moving_anim)
|
||||
end
|
||||
|
||||
-- Stop!
|
||||
|
@ -383,6 +381,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||
end
|
||||
|
||||
entity.v2 = v
|
||||
]]--
|
||||
end
|
||||
|
||||
|
||||
|
@ -390,6 +389,10 @@ end
|
|||
|
||||
function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
||||
|
||||
if true then
|
||||
print("succ")
|
||||
return
|
||||
end
|
||||
local ctrl = entity.driver:get_player_control()
|
||||
local velo = entity.object:get_velocity()
|
||||
local dir = entity.driver:get_look_dir()
|
||||
|
@ -440,9 +443,9 @@ function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
|||
-- change animation if stopped
|
||||
if velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||
|
||||
mobs:set_animation(entity, stand_anim)
|
||||
mobs:set_mob_animation(entity, stand_anim)
|
||||
else
|
||||
-- moving animation
|
||||
mobs:set_animation(entity, moving_anim)
|
||||
mobs:set_mob_animation(entity, moving_anim)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -165,6 +165,8 @@ Overworld regular:
|
|||
|
||||
local mobs_spawn = minetest.settings:get_bool("mobs_spawn", true) ~= false
|
||||
|
||||
mobs_spawn = false
|
||||
|
||||
-- count how many mobs are in an area
|
||||
local count_mobs = function(pos)
|
||||
local num = 0
|
||||
|
|
|
@ -87,6 +87,9 @@ local horse = {
|
|||
spawn_class = "passive",
|
||||
visual = "mesh",
|
||||
mesh = "mobs_mc_horse.b3d",
|
||||
rotate = 270,
|
||||
walk_velocity = 1,
|
||||
run_velocity = 8,
|
||||
visual_size = {x=3.0, y=3.0},
|
||||
collisionbox = {-0.69825, -0.01, -0.69825, 0.69825, 1.59, 0.69825},
|
||||
animation = {
|
||||
|
@ -96,7 +99,7 @@ local horse = {
|
|||
walk_speed = 25,
|
||||
walk_start = 0,
|
||||
walk_end = 40,
|
||||
run_speed = 60,
|
||||
run_speed = 120,
|
||||
run_start = 0,
|
||||
run_end = 40,
|
||||
},
|
||||
|
@ -181,7 +184,7 @@ local horse = {
|
|||
-- if driver present and horse has a saddle allow control of horse
|
||||
if self.driver and self._saddle then
|
||||
|
||||
mobs.drive(self, "walk", "stand", false, dtime)
|
||||
mobs.drive(self, "run", "stand", false, dtime)
|
||||
|
||||
return false -- skip rest of mob functions
|
||||
end
|
||||
|
@ -238,6 +241,7 @@ local horse = {
|
|||
self.buck_off_time = 40 -- TODO how long does it take in minecraft?
|
||||
if self.temper > 100 then
|
||||
self.tamed = true -- NOTE taming can only be finished by riding the horse
|
||||
mobs.tamed_effect(self)
|
||||
if not self.owner or self.owner == "" then
|
||||
self.owner = clicker:get_player_name()
|
||||
end
|
||||
|
@ -252,6 +256,14 @@ local horse = {
|
|||
-- If nothing happened temper_increase = 0 and addition does nothing
|
||||
self.temper = self.temper + temper_increase
|
||||
|
||||
--give the player some kind of idea
|
||||
--of what's happening with the horse's temper
|
||||
if self.temper <= 100 then
|
||||
mobs.feed_effect(self)
|
||||
else
|
||||
mobs.tamed_effect(self)
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue