forked from VoxeLibre/VoxeLibre
Half finish horse (riding logic, etc)
This commit is contained in:
parent
f64f8e31e3
commit
189c0ad157
|
@ -672,6 +672,14 @@ mobs.mob_step = function(self, dtime)
|
||||||
if self.do_custom then
|
if self.do_custom then
|
||||||
-- when false skip going any further
|
-- when false skip going any further
|
||||||
if self.do_custom(self, dtime) == false then
|
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
|
--this overrides internal lua collision detection
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,7 +22,7 @@ mobs.set_mob_animation = function(self, anim, fixed_frame)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if (not self.animation[anim .. "_start"] or not self.animation[anim .. "_end"]) then
|
if (not self.animation[anim .. "_start"] or not self.animation[anim .. "_end"]) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,10 @@ mobs.collision = function(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,object in ipairs(minetest_get_objects_inside_radius(pos, radius*1.25)) do
|
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
|
--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 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 self.object:get_attach() or (self.object:get_attach() and self.object:get_attach() ~= object)) then
|
||||||
--stop infinite loop
|
--stop infinite loop
|
||||||
collision_count = collision_count + 1
|
collision_count = collision_count + 1
|
||||||
if collision_count > 100 then
|
if collision_count > 100 then
|
||||||
|
|
|
@ -89,6 +89,20 @@ end
|
||||||
mobs.death_logic = function(self, dtime)
|
mobs.death_logic = function(self, dtime)
|
||||||
self.death_animation_timer = self.death_animation_timer + 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
|
--the final POOF of a mob despawning
|
||||||
if self.death_animation_timer >= 1.25 then
|
if self.death_animation_timer >= 1.25 then
|
||||||
|
|
|
@ -206,21 +206,30 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||||
-- move forwards
|
-- move forwards
|
||||||
if ctrl.up then
|
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
|
-- move backwards
|
||||||
elseif ctrl.down then
|
elseif ctrl.down then
|
||||||
|
|
||||||
if entity.max_speed_reverse == 0 and entity.v == 0 then
|
mobs.set_velocity(entity, -entity.run_velocity)
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
entity.v = entity.v - entity.accel / 10
|
mobs.set_mob_animation(entity, moving_anim)
|
||||||
|
|
||||||
|
--halt
|
||||||
|
else
|
||||||
|
|
||||||
|
mobs.set_velocity(entity, 0)
|
||||||
|
|
||||||
|
mobs.set_mob_animation(entity, stand_anim)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- fix mob rotation
|
-- mob rotation
|
||||||
entity.object:set_yaw(entity.driver:get_look_horizontal() - entity.rotate)
|
entity.object:set_yaw(entity.driver:get_look_horizontal() - entity.rotate)
|
||||||
|
entity.yaw = entity.driver:get_look_horizontal() - entity.rotate
|
||||||
|
|
||||||
|
--[[
|
||||||
if can_fly then
|
if can_fly then
|
||||||
|
|
||||||
-- fly up
|
-- fly up
|
||||||
|
@ -244,32 +253,21 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
]]--
|
||||||
|
|
||||||
-- jump
|
-- jump
|
||||||
if ctrl.jump then
|
if ctrl.jump then
|
||||||
|
|
||||||
if velo.y == 0 then
|
mobs.jump(entity)
|
||||||
velo.y = velo.y + entity.jump_height
|
|
||||||
acce_y = acce_y + (acce_y * 3) + 1
|
|
||||||
end
|
|
||||||
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
|
end
|
||||||
|
|
||||||
return
|
--end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
-- set moving animation
|
-- set moving animation
|
||||||
if moving_anim then
|
if moving_anim then
|
||||||
mobs:set_animation(entity, moving_anim)
|
mobs:set_mob_animation(entity, moving_anim)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Stop!
|
-- Stop!
|
||||||
|
@ -383,6 +381,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
entity.v2 = v
|
entity.v2 = v
|
||||||
|
]]--
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -390,6 +389,10 @@ end
|
||||||
|
|
||||||
function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
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 ctrl = entity.driver:get_player_control()
|
||||||
local velo = entity.object:get_velocity()
|
local velo = entity.object:get_velocity()
|
||||||
local dir = entity.driver:get_look_dir()
|
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
|
-- change animation if stopped
|
||||||
if velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
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
|
else
|
||||||
-- moving animation
|
-- moving animation
|
||||||
mobs:set_animation(entity, moving_anim)
|
mobs:set_mob_animation(entity, moving_anim)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -165,6 +165,8 @@ Overworld regular:
|
||||||
|
|
||||||
local mobs_spawn = minetest.settings:get_bool("mobs_spawn", true) ~= false
|
local mobs_spawn = minetest.settings:get_bool("mobs_spawn", true) ~= false
|
||||||
|
|
||||||
|
mobs_spawn = false
|
||||||
|
|
||||||
-- count how many mobs are in an area
|
-- count how many mobs are in an area
|
||||||
local count_mobs = function(pos)
|
local count_mobs = function(pos)
|
||||||
local num = 0
|
local num = 0
|
||||||
|
|
|
@ -87,6 +87,9 @@ local horse = {
|
||||||
spawn_class = "passive",
|
spawn_class = "passive",
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_horse.b3d",
|
mesh = "mobs_mc_horse.b3d",
|
||||||
|
rotate = 270,
|
||||||
|
walk_velocity = 1,
|
||||||
|
run_velocity = 8,
|
||||||
visual_size = {x=3.0, y=3.0},
|
visual_size = {x=3.0, y=3.0},
|
||||||
collisionbox = {-0.69825, -0.01, -0.69825, 0.69825, 1.59, 0.69825},
|
collisionbox = {-0.69825, -0.01, -0.69825, 0.69825, 1.59, 0.69825},
|
||||||
animation = {
|
animation = {
|
||||||
|
@ -96,7 +99,7 @@ local horse = {
|
||||||
walk_speed = 25,
|
walk_speed = 25,
|
||||||
walk_start = 0,
|
walk_start = 0,
|
||||||
walk_end = 40,
|
walk_end = 40,
|
||||||
run_speed = 60,
|
run_speed = 120,
|
||||||
run_start = 0,
|
run_start = 0,
|
||||||
run_end = 40,
|
run_end = 40,
|
||||||
},
|
},
|
||||||
|
@ -181,7 +184,7 @@ local horse = {
|
||||||
-- if driver present and horse has a saddle allow control of horse
|
-- if driver present and horse has a saddle allow control of horse
|
||||||
if self.driver and self._saddle then
|
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
|
return false -- skip rest of mob functions
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue