Commit b279a8f6 authored by Milan's avatar Milan

add horses with modified spawnrates

parents
-= MOBS-MOD for MINETEST =- by PilzAdam and KrupnovPavel
Little has changed. Removed some bugs.
The game now many living creatures.
The sheep and the rat from MOBS-MOD
Deer by Pavel_S
All my models and change code on valid license The MIT License
The MIT License (MIT)
Copyright (c) 2014 Krupnov Pavel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\ No newline at end of file
default
mobs
-- horse functions
local function is_ground(pos)
local nn = minetest.get_node(pos).name
return minetest.get_item_group(nn, "crumbly") ~= 0
end
local function get_sign(i)
if i == 0 then
return 0
else
return i/math.abs(i)
end
end
local function get_velocity(v, yaw, y)
local x = math.cos(yaw)*v
local z = math.sin(yaw)*v
return {x=x, y=y, z=z}
end
local function get_v(v)
return math.sqrt(v.x^2+v.z^2)
end
function merge(a, b)
if type(a) == 'table' and type(b) == 'table' then
for k,v in pairs(b) do if type(v)=='table' and type(a[k] or false)=='table' then merge(a[k],v) else a[k]=v end end
end
return a
end
-- HORSE go go goooo :)
local horse = {
physical = true,
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4},
visual = "mesh",
stepheight = 1.1,
visual_size = {x=1,y=1},
mesh = "mobs_horseh1.x",
driver = nil,
v = 0,
on_rightclick = function(self, clicker)
if not clicker or not clicker:is_player() then
return
end
if self.driver and clicker == self.driver then
self.driver = nil
clicker:set_detach()
elseif not self.driver then
self.driver = clicker
clicker:set_attach(self.object, "", {x=0,y=5,z=0}, {x=0,y=0,z=0})
self.object:setyaw(clicker:get_look_yaw())
end
end,
on_activate = function(self, staticdata, dtime_s)
self.object:set_armor_groups({immortal=1})
print (self.texture, self.jmp)
end,
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, direction)
if puncher and puncher:is_player() then
puncher:get_inventory():add_item("main", self.name)
self.object:remove()
end
end,
on_step = function(self, dtime)
self.v = get_v(self.object:getvelocity())*get_sign(self.v)
if self.driver then
local ctrl = self.driver:get_player_control()
if ctrl.up then
self.v = self.v + self.jmp
end
if ctrl.down then
self.v = self.v-0.1
end
if ctrl.left then
self.object:setyaw(self.object:getyaw()+math.pi/120+dtime*math.pi/120)
end
if ctrl.right then
self.object:setyaw(self.object:getyaw()-math.pi/120-dtime*math.pi/120)
end
if ctrl.jump then
local p = self.object:getpos()
p.y = p.y-0.5
if is_ground(p) then
local pos = self.object:getpos()
pos.y = math.floor(pos.y)+4
self.object:setpos(pos)
self.object:setvelocity(get_velocity(self.v, self.object:getyaw(), 0))
end
end
end
local s = get_sign(self.v)
self.v = self.v - 0.02*s
if s ~= get_sign(self.v) then
self.object:setvelocity({x=0, y=0, z=0})
self.v = 0
return
end
if math.abs(self.v) > 4.5 then
self.v = 4.5*get_sign(self.v)
end
local p = self.object:getpos()
p.y = p.y-0.5
if not is_ground(p) then
if minetest.registered_nodes[minetest.get_node(p).name].walkable then
self.v = 0
end
self.object:setacceleration({x=0, y=-10, z=0})
self.object:setvelocity(get_velocity(self.v, self.object:getyaw(), self.object:getvelocity().y))
else
p.y = p.y+1
if is_ground(p) then
self.object:setacceleration({x=0, y=3, z=0})
local y = self.object:getvelocity().y
if y > 2 then
y = 2
end
if y < 0 then
self.object:setacceleration({x=0, y=10, z=0})
end
self.object:setvelocity(get_velocity(self.v, self.object:getyaw(), y))
else
self.object:setacceleration({x=0, y=0, z=0})
if math.abs(self.object:getvelocity().y) < 1 then
local pos = self.object:getpos()
pos.y = math.floor(pos.y)+0.5
self.object:setpos(pos)
self.object:setvelocity(get_velocity(self.v, self.object:getyaw(), 0))
else
self.object:setvelocity(get_velocity(self.v, self.object:getyaw(), self.object:getvelocity().y))
end
end
end
end,
}
--END HORSE
-- backup table
local hbak = horse
-- Brown Horse
local hrs = {
textures = {"mobs_horseh1.png"},
jmp = 2,
}
minetest.register_entity("kpgmobs:horseh1", merge(hrs, horse))
-- White Horse
horse = hbak
local peg = {
textures = {"mobs_horsepegh1.png"},
jmp = 2,
}
minetest.register_entity("kpgmobs:horsepegh1", merge(peg, horse))
-- Black Horse
horse = hbak
local ara = {
textures = {"mobs_horsearah1.png"},
jmp = 3,
}
minetest.register_entity("kpgmobs:horsearah1", merge(ara, horse))
-- tamed horse spawn eggs
mobs:register_egg("kpgmobs:horseh1", "Tamed Brown Horse", "mobs_horse_inv.png", 0)
mobs:register_egg("kpgmobs:horsepegh1", "Tamed White Horse", "mobs_horse_peg_inv.png", 0)
mobs:register_egg("kpgmobs:horsearah1", "Tamed Arabic Horse", "mobs_horse_ara_inv.png", 0)
-- saddle
minetest.register_craftitem("kpgmobs:saddle", {
description = "Saddle",
inventory_image = "mobs_saddle.png",
})
minetest.register_craft({
output = "kpgmobs:saddle",
recipe = {
{'mobs:leather', 'mobs:leather', 'mobs:leather'},
{'mobs:leather', 'default:steel_ingot', 'mobs:leather'},
{'mobs:leather', 'default:steel_ingot', 'mobs:leather'},
}
})
mobs:register_mob("kpgmobs:horse", {
type = "animal",
hp_min = 5,
hp_max = 10,
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4},
textures = {
{"mobs_horse.png"},
},
visual = "mesh",
mesh = "mobs_horse.x",
makes_footstep_sound = true,
walk_velocity = 1,
armor = 200,
drops = {
{name = "mobs:meat_raw",
chance = 1,
min = 2,
max = 3,},
},
drawtype = "front",
water_damage = 1,
lava_damage = 5,
light_damage = 0,
animation = {
speed_normal = 15,
stand_start = 25, stand_end = 75,
walk_start = 75, walk_end = 100,
},
follow = "farming:wheat",
view_range = 5,
on_rightclick = function(self, clicker)
local tool = clicker:get_wielded_item()
if tool:get_name() == "kpgmobs:saddle" then
clicker:get_inventory():remove_item("main", "kpgmobs:saddle")
local pos = self.object:getpos()
self.object:remove()
minetest.add_entity(pos, "kpgmobs:horseh1")
end
end,
})
mobs:register_spawn("kpgmobs:horse", {"default:dirt_with_grass"}, 20, 8, 200, 1, 31000)
mobs:register_mob("kpgmobs:horse2", {
type = "animal",
hp_min = 5,
hp_max = 10,
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4},
textures = {
{"mobs_horsepeg.png"},
},
visual = "mesh",
mesh = "mobs_horse.x",
makes_footstep_sound = true,
walk_velocity = 1,
armor = 200,
drops = {
{name = "mobs:meat_raw",
chance = 1,
min = 2,
max = 3,},
},
drawtype = "front",
water_damage = 1,
lava_damage = 5,
light_damage = 0,
animation = {
speed_normal = 15,
stand_start = 25, stand_end = 75,
walk_start = 75, walk_end = 100,
},
follow = "farming:wheat",
view_range = 5,
on_rightclick = function(self, clicker)
local tool = clicker:get_wielded_item()
if tool:get_name() == "kpgmobs:saddle" then
clicker:get_inventory():remove_item("main", "kpgmobs:saddle")
local pos = self.object:getpos()
self.object:remove()
minetest.add_entity(pos, "kpgmobs:horsepegh1")
end
end,
})
mobs:register_spawn("kpgmobs:horse2", {"default:dirt_with_grass"}, 20, 8, 150, 1, 31000)
mobs:register_mob("kpgmobs:horse3", {
type = "animal",
hp_min = 5,
hp_max = 10,
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4},
textures = {
{"mobs_horseara.png"},
},
visual = "mesh",
mesh = "mobs_horse.x",
makes_footstep_sound = true,
walk_velocity = 1,
armor = 200,
drops = {
{name = "mobs:meat_raw",
chance = 1,
min = 2,
max = 3,},
},
drawtype = "front",
water_damage = 1,
lava_damage = 5,
light_damage = 0,
animation = {
speed_normal = 15,
stand_start = 25, stand_end = 75,
walk_start = 75, walk_end = 100,
},
follow = "farming:wheat",
view_range = 5,
on_rightclick = function(self, clicker)
local tool = clicker:get_wielded_item()
if tool:get_name() == "kpgmobs:saddle" then
clicker:get_inventory():remove_item("main", "kpgmobs:saddle")
local pos = self.object:getpos()
self.object:remove()
minetest.add_entity(pos, "kpgmobs:horsearah1")
end
end,
})
mobs:register_spawn("kpgmobs:horse3", {"default:desert_sand"}, 20, 8, 120, 1, 31000)
-- wild horse spawn eggs
mobs:register_egg("kpgmobs:horse", "Brown Horse", "mobs_horse_inv.png", 0)
mobs:register_egg("kpgmobs:horse2", "White Horse", "mobs_horse_peg_inv.png", 0)
mobs:register_egg("kpgmobs:horse3", "Arabic Horse", "mobs_horse_ara_inv.png", 0)
if minetest.setting_get("log_mods") then
minetest.log("action", "kpgmobs loaded")
end
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment