Experimenting the new mount library of mobs_api
This commit is contained in:
parent
222a00d6b4
commit
2663744a70
@ -8,7 +8,6 @@ mobs:register_mob("nssm:scrausics", {
|
|||||||
textures = {{"scrausics.png"}},
|
textures = {{"scrausics.png"}},
|
||||||
visual_size = {x=10, y=10},
|
visual_size = {x=10, y=10},
|
||||||
view_range = 35,
|
view_range = 35,
|
||||||
rotate = 270,
|
|
||||||
walk_velocity = 2,
|
walk_velocity = 2,
|
||||||
run_velocity = 3,
|
run_velocity = 3,
|
||||||
fall_speed = 0,
|
fall_speed = 0,
|
||||||
@ -37,6 +36,7 @@ mobs:register_mob("nssm:scrausics", {
|
|||||||
light_damage = 0,
|
light_damage = 0,
|
||||||
group_attack=true,
|
group_attack=true,
|
||||||
attack_animals=true,
|
attack_animals=true,
|
||||||
|
follow = {"farming:wheat"},
|
||||||
knock_back=2,
|
knock_back=2,
|
||||||
blood_texture="nssm_blood.png",
|
blood_texture="nssm_blood.png",
|
||||||
on_rightclick = nil,
|
on_rightclick = nil,
|
||||||
@ -45,6 +45,7 @@ mobs:register_mob("nssm:scrausics", {
|
|||||||
animation = {
|
animation = {
|
||||||
speed_normal = 25,
|
speed_normal = 25,
|
||||||
speed_run = 25,
|
speed_run = 25,
|
||||||
|
speed_die = 20,
|
||||||
stand_start = 220,
|
stand_start = 220,
|
||||||
stand_end = 280,
|
stand_end = 280,
|
||||||
walk_start = 140,
|
walk_start = 140,
|
||||||
@ -53,5 +54,89 @@ mobs:register_mob("nssm:scrausics", {
|
|||||||
run_end = 210,
|
run_end = 210,
|
||||||
punch_start = 20,
|
punch_start = 20,
|
||||||
punch_end = 50,
|
punch_end = 50,
|
||||||
}
|
die_start = 290,
|
||||||
|
die_end = 310,
|
||||||
|
punch2_start = 60,
|
||||||
|
punch2_end = 100,
|
||||||
|
},
|
||||||
|
do_custom = function(self, dtime)
|
||||||
|
|
||||||
|
-- set needed values if not already present
|
||||||
|
if not self.v2 then
|
||||||
|
self.v2 = 0
|
||||||
|
self.max_speed_forward = 6
|
||||||
|
self.max_speed_reverse = 2
|
||||||
|
self.accel = 6
|
||||||
|
self.terrain_type = 3
|
||||||
|
self.driver_attach_at = {x = -0.05, y = 1, z = 0}
|
||||||
|
self.driver_eye_offset = {x = 0, y = -2, z = 0}
|
||||||
|
self.driver_scale = {x = 0.09, y = 0.09}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- if driver present allow control of horse
|
||||||
|
if self.driver then
|
||||||
|
|
||||||
|
mobs.drive(self, "punch2", "stand", true, dtime)
|
||||||
|
|
||||||
|
return false -- skip rest of mob functions
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_die = function(self, pos)
|
||||||
|
|
||||||
|
-- drop saddle when horse is killed while riding
|
||||||
|
-- also detach from horse properly
|
||||||
|
if self.driver then
|
||||||
|
minetest.add_item(pos, "mobs:saddle")
|
||||||
|
mobs.detach(self.driver, {x = 1, y = 0, z = 1})
|
||||||
|
end
|
||||||
|
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_rightclick = function(self, clicker)
|
||||||
|
|
||||||
|
-- make sure player is clicking
|
||||||
|
if not clicker or not clicker:is_player() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- feed, tame or heal horse
|
||||||
|
if mobs:feed_tame(self, clicker, 10, true, true) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- make sure tamed horse is being clicked by owner only
|
||||||
|
if self.tamed and self.owner == clicker:get_player_name() then
|
||||||
|
|
||||||
|
local inv = clicker:get_inventory()
|
||||||
|
|
||||||
|
-- detatch player already riding horse
|
||||||
|
if self.driver and clicker == self.driver then
|
||||||
|
|
||||||
|
mobs.detach(clicker, {x = 1, y = 0, z = 1})
|
||||||
|
|
||||||
|
-- add saddle back to inventory
|
||||||
|
if inv:room_for_item("main", "mobs:saddle") then
|
||||||
|
inv:add_item("main", "mobs:saddle")
|
||||||
|
else
|
||||||
|
minetest.add_item(clicker.getpos(), "mobs:saddle")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- attach player to horse
|
||||||
|
elseif not self.driver
|
||||||
|
and clicker:get_wielded_item():get_name() == "mobs:saddle" then
|
||||||
|
|
||||||
|
self.object:set_properties({stepheight = 1.1})
|
||||||
|
mobs.attach(self, clicker)
|
||||||
|
|
||||||
|
-- take saddle from inventory
|
||||||
|
inv:remove_item("main", "mobs:saddle")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- used to capture horse with magic lasso
|
||||||
|
mobs:capture_mob(self, clicker, 0, 0, 80, false, nil)
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
38258
models/scrausics.x
38258
models/scrausics.x
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user