Compare commits

...

24 Commits

Author SHA1 Message Date
af59d1e2b7 Merge remote-tracking branch 'upstream/master' 2022-03-05 11:24:11 +01:00
4022ae9a02 horses are good swimmers, remove water damage 2022-02-15 09:21:08 +00:00
f7ac229ccf fix typo (thx SwissaplS) 2022-02-08 18:20:38 +00:00
6d4701ca5f Merge remote-tracking branch 'upstream/master' 2022-01-22 20:01:06 +01:00
8996ad27d8 update translation checks 2022-01-20 08:57:36 +00:00
f550d5b4a1 Merge remote-tracking branch 'upstream/master' 2021-11-26 21:42:13 +01:00
9e0021a0f8 fix intllib return 2021-11-14 14:23:03 +00:00
d0ccec70cb Merge remote-tracking branch 'upstream/master' 2021-11-01 10:30:36 +01:00
7650e9ba5c tidy code, add custom spawn.lua check 2021-10-18 08:32:12 +01:00
0cbaa0b223 Merge remote-tracking branch 'upstream/master' 2021-06-20 17:11:26 +02:00
aa399a6ef9 shrink driver when riding horse to fit model 2021-06-11 14:20:55 +01:00
23ab8bddbd set lasso capture chance 100% 2021-06-10 15:54:30 +01:00
decb1c384c redo saddles and add overlay 2021-06-10 15:47:34 +01:00
e16866479f Merge remote-tracking branch 'upstream/master' 2021-05-09 21:38:19 +02:00
9130b43ef8 lower crystal horseshoe stats (too OP) 2021-04-19 21:13:43 +01:00
22f52abc6c add crystal horseshoe 2021-04-19 19:46:23 +01:00
2ac1e816ed Merge remote-tracking branch 'upstream/master' 2021-03-25 21:40:28 +01:00
d7a5b88fb4 improve stand animation set 2021-03-18 09:01:23 +00:00
d2c0afcff2 Merge remote-tracking branch 'upstream/master' 2021-03-12 12:23:24 +01:00
aa867c3fa0 add license file 2021-03-02 08:01:01 +00:00
70f40e2fb4 Merge remote-tracking branch 'upstream/master' 2021-01-23 12:53:58 +01:00
858167c386 add mod.conf 2021-01-21 10:13:07 +00:00
5f26b248b1 Merge remote-tracking branch 'upstream/master' 2020-12-15 23:24:51 +01:00
8dfead83c6 add on_punch and proper version checking (thanks MoNTE48) 2020-12-11 19:15:50 +00:00
9 changed files with 225 additions and 62 deletions

197
init.lua
View File

@ -1,23 +1,48 @@
-- Load support for intllib. -- Load support for intllib.
local MP = minetest.get_modpath(minetest.get_current_modname()) local MP = minetest.get_modpath(minetest.get_current_modname()) .. "/"
local S = minetest.get_translator and minetest.get_translator("mob_horse") or
dofile(MP .. "/intllib.lua") -- Check for translation method
local S
if minetest.get_translator ~= nil then
S = minetest.get_translator("mob_horse") -- 5.x translation function
else
if minetest.get_modpath("intllib") then
dofile(minetest.get_modpath("intllib") .. "/init.lua")
if intllib.make_gettext_pair then
gettext, ngettext = intllib.make_gettext_pair() -- new gettext method
else
gettext = intllib.Getter() -- old text file method
end
S = gettext
else -- boilerplate function
S = function(str, ...)
local args = {...}
return str:gsub("@%d+", function(match)
return args[tonumber(match:sub(2))]
end)
end
end
end
-- 0.4.17 or 5.0 check -- 0.4.17 or 5.0 check
local y_off = 20 local y_off = 20
if minetest.registered_nodes["default:permafrost"] then if minetest.features.object_independent_selectionbox then
y_off = 10 y_off = 10
end end
-- horse shoes (speed, jump, break, overlay texture)
-- horse shoes (speed, jump, brake/reverse speed, overlay texture)
local shoes = { local shoes = {
["mobs:horseshoe_steel"] = {7, 4, 2, "mobs_horseshoe_steelo.png"}, ["mobs:horseshoe_steel"] = {7, 4, 2, "mobs_horseshoe_steelo.png"},
["mobs:horseshoe_bronze"] = {7, 4, 4, "mobs_horseshoe_bronzeo.png"}, ["mobs:horseshoe_bronze"] = {7, 4, 4, "mobs_horseshoe_bronzeo.png"},
["mobs:horseshoe_mese"] = {9, 5, 8, "mobs_horseshoe_meseo.png"}, ["mobs:horseshoe_mese"] = {9, 5, 8, "mobs_horseshoe_meseo.png"},
["mobs:horseshoe_diamond"] = {10, 6, 6, "mobs_horseshoe_diamondo.png"} ["mobs:horseshoe_diamond"] = {10, 6, 6, "mobs_horseshoe_diamondo.png"},
["mobs:horseshoe_crystal"] = {11, 6, 9, "mobs_horseshoe_crystalo.png"}
} }
-- rideable horse -- rideable horse
mobs:register_mob("mob_horse:horse", { mobs:register_mob("mob_horse:horse", {
type = "animal", type = "animal",
@ -29,11 +54,16 @@ mobs:register_mob("mob_horse:horse", {
speed_normal = 15, speed_normal = 15,
speed_run = 30, speed_run = 30,
stand_start = 25, stand_start = 25,
stand_end = 75, stand_end = 50, -- 75
stand2_start = 25,
stand2_end = 25,
stand3_start = 55,
stand3_end = 75,
stand3_loop = false,
walk_start = 75, walk_start = 75,
walk_end = 100, walk_end = 100,
run_start = 75, run_start = 75,
run_end = 100, run_end = 100
}, },
textures = { textures = {
{"mobs_horse.png"}, -- textures by Mjollna {"mobs_horse.png"}, -- textures by Mjollna
@ -54,7 +84,7 @@ mobs:register_mob("mob_horse:horse", {
armor = 200, armor = 200,
lava_damage = 5, lava_damage = 5,
fall_damage = 5, fall_damage = 5,
water_damage = 1, water_damage = 0,
makes_footstep_sound = true, makes_footstep_sound = true,
drops = { drops = {
{name = "mobs:leather", chance = 1, min = 0, max = 2} {name = "mobs:leather", chance = 1, min = 0, max = 2}
@ -71,6 +101,7 @@ mobs:register_mob("mob_horse:horse", {
self.terrain_type = 3 self.terrain_type = 3
self.driver_attach_at = {x = 0, y = y_off, z = -2} self.driver_attach_at = {x = 0, y = y_off, z = -2}
self.driver_eye_offset = {x = 0, y = 3, z = 0} self.driver_eye_offset = {x = 0, y = 3, z = 0}
self.driver_scale = {x = 0.8, y = 0.8} -- shrink driver to fit model
end end
-- if driver present allow control of horse -- if driver present allow control of horse
@ -86,22 +117,28 @@ mobs:register_mob("mob_horse:horse", {
on_die = function(self, pos) on_die = function(self, pos)
-- drop saddle when horse is killed while riding -- detach player from horse properly
-- also detach from horse properly
if self.driver then if self.driver then
minetest.add_item(pos, "mobs:saddle")
mobs.detach(self.driver, {x = 1, y = 0, z = 1}) mobs.detach(self.driver, {x = 1, y = 0, z = 1})
end
self.saddle = nil -- drop saddle if found
if self.saddle then
minetest.add_item(pos, "mobs:saddle")
end end
-- drop any horseshoes added -- drop any horseshoes added
if self.shoed then if self.shoed then
minetest.add_item(pos, self.shoed) minetest.add_item(pos, self.shoed)
end end
end,
do_punch = function(self, hitter)
-- don't cut the branch you're... ah, that's not about that
if hitter ~= self.driver then
return true
end
end, end,
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
@ -121,8 +158,10 @@ mobs:register_mob("mob_horse:horse", {
return return
end end
local player_name = clicker:get_player_name()
-- make sure tamed horse is being clicked by owner only -- make sure tamed horse is being clicked by owner only
if self.tamed and self.owner == clicker:get_player_name() then if self.tamed and self.owner == player_name then
local inv = clicker:get_inventory() local inv = clicker:get_inventory()
local tool = clicker:get_wielded_item() local tool = clicker:get_wielded_item()
@ -133,29 +172,27 @@ mobs:register_mob("mob_horse:horse", {
mobs.detach(clicker, {x = 1, y = 0, z = 1}) mobs.detach(clicker, {x = 1, y = 0, z = 1})
-- add saddle back to inventory return
if inv:room_for_item("main", "mobs:saddle") then end
inv:add_item("main", "mobs:saddle")
else
minetest.add_item(clicker:get_pos(), "mobs:saddle")
end
self.saddle = nil -- attach saddle to horse
if not self.driver
-- attach player to horse and not self.child
elseif (not self.driver and not self.child and clicker:get_wielded_item():get_name() == "mobs:saddle"
and clicker:get_wielded_item():get_name() == "mobs:saddle") and not self.saddle then
or self.saddle then
self.object:set_properties({stepheight = 1.1})
mobs.attach(self, clicker)
-- take saddle from inventory
if not self.saddle then
inv:remove_item("main", "mobs:saddle")
end
self.saddle = true self.saddle = true
self.order = "stand"
self.object:set_properties({stepheight = 1.1})
-- take saddle from inventory
inv:remove_item("main", "mobs:saddle")
self.texture_mods = self.texture_mods .. "^mobs_saddle_overlay.png"
self.object:set_texture_mod(self.texture_mods)
return
end end
-- apply horseshoes -- apply horseshoes
@ -180,37 +217,62 @@ mobs:register_mob("mob_horse:horse", {
-- apply horseshoe overlay to current horse texture -- apply horseshoe overlay to current horse texture
if overlay then if overlay then
self.texture_mods = "^" .. overlay self.texture_mods = "^" .. overlay
if self.saddle then
self.texture_mods = self.texture_mods
.. "^mobs_saddle_overlay.png"
end
self.object:set_texture_mod(self.texture_mods) self.object:set_texture_mod(self.texture_mods)
end end
-- show horse speed and jump stats with shoes fitted -- show horse speed and jump stats with shoes fitted
minetest.chat_send_player(clicker:get_player_name(), minetest.chat_send_player(player_name,
S("Horse shoes fitted -") S("Horse shoes fitted -")
.. S(" speed: ") .. speed .. S(" speed: ") .. speed
.. S(" , jump height: ") .. jump .. S(" , jump height: ") .. jump
.. S(" , stop speed: ") .. reverse) .. S(" , stop speed: ") .. reverse)
tool:take_item() ; clicker:set_wielded_item(tool) tool:take_item()
clicker:set_wielded_item(tool)
return return
end end
end end
-- used to capture horse with magic lasso -- used to capture horse with magic lasso
mobs:capture_mob(self, clicker, 0, 0, 80, false, nil) if mobs:capture_mob(self, clicker, nil, nil, 100, false, nil) then return end
end,
-- ride horse if saddled
if self.saddle and self.owner == player_name then
mobs.attach(self, clicker)
end
end
}) })
mobs:spawn({
name = "mob_horse:horse", -- check for custom spawn.lua
nodes = {"default:dirt_with_grass", "ethereal:dry_dirt"}, local input = io.open(MP .. "spawn.lua", "r")
min_light = 14,
interval = 60, if input then
chance = 16000, input:close()
min_height = 10, input = nil
max_height = 31000, dofile(MP .. "spawn.lua")
day_toggle = true, else
})
mobs:spawn({
name = "mob_horse:horse",
nodes = {"default:dirt_with_grass", "ethereal:dry_dirt"},
min_light = 14,
interval = 60,
chance = 16000,
min_height = 10,
max_height = 31000,
day_toggle = true
})
end
mobs:register_egg("mob_horse:horse", S("Horse"), "wool_brown.png", 1) mobs:register_egg("mob_horse:horse", S("Horse"), "wool_brown.png", 1)
@ -226,14 +288,14 @@ minetest.register_craft({
recipe = { recipe = {
{"", "default:steelblock", ""}, {"", "default:steelblock", ""},
{"default:steel_ingot", "", "default:steel_ingot"}, {"default:steel_ingot", "", "default:steel_ingot"},
{"default:steel_ingot", "", "default:steel_ingot"}, {"default:steel_ingot", "", "default:steel_ingot"}
} }
}) })
-- bronze horseshoes -- bronze horseshoes
minetest.register_craftitem(":mobs:horseshoe_bronze", { minetest.register_craftitem(":mobs:horseshoe_bronze", {
description = S("Bronze HorseShoes (use on horse to apply)"), description = S("Bronze HorseShoes (use on horse to apply)"),
inventory_image = "mobs_horseshoe_bronze.png", inventory_image = "mobs_horseshoe_bronze.png"
}) })
minetest.register_craft({ minetest.register_craft({
@ -241,14 +303,14 @@ minetest.register_craft({
recipe = { recipe = {
{"", "default:bronzeblock", ""}, {"", "default:bronzeblock", ""},
{"default:bronze_ingot", "", "default:bronze_ingot"}, {"default:bronze_ingot", "", "default:bronze_ingot"},
{"default:bronze_ingot", "", "default:bronze_ingot"}, {"default:bronze_ingot", "", "default:bronze_ingot"}
} }
}) })
-- mese horseshoes -- mese horseshoes
minetest.register_craftitem(":mobs:horseshoe_mese", { minetest.register_craftitem(":mobs:horseshoe_mese", {
description = S("Mese HorseShoes (use on horse to apply)"), description = S("Mese HorseShoes (use on horse to apply)"),
inventory_image = "mobs_horseshoe_mese.png", inventory_image = "mobs_horseshoe_mese.png"
}) })
minetest.register_craft({ minetest.register_craft({
@ -256,14 +318,14 @@ minetest.register_craft({
recipe = { recipe = {
{"", "default:mese", ""}, {"", "default:mese", ""},
{"default:mese_crystal_fragment", "", "default:mese_crystal_fragment"}, {"default:mese_crystal_fragment", "", "default:mese_crystal_fragment"},
{"default:mese_crystal_fragment", "", "default:mese_crystal_fragment"}, {"default:mese_crystal_fragment", "", "default:mese_crystal_fragment"}
} }
}) })
-- diamond horseshoes -- diamond horseshoes
minetest.register_craftitem(":mobs:horseshoe_diamond", { minetest.register_craftitem(":mobs:horseshoe_diamond", {
description = S("Diamond HorseShoes (use on horse to apply)"), description = S("Diamond HorseShoes (use on horse to apply)"),
inventory_image = "mobs_horseshoe_diamond.png", inventory_image = "mobs_horseshoe_diamond.png"
}) })
minetest.register_craft({ minetest.register_craft({
@ -271,10 +333,30 @@ minetest.register_craft({
recipe = { recipe = {
{"", "default:diamondblock", ""}, {"", "default:diamondblock", ""},
{"default:diamond", "", "default:diamond"}, {"default:diamond", "", "default:diamond"},
{"default:diamond", "", "default:diamond"}, {"default:diamond", "", "default:diamond"}
} }
}) })
-- crystal horseshoes
if minetest.get_modpath("ethereal") then
minetest.register_craftitem(":mobs:horseshoe_crystal", {
description = S("Crystal HorseShoes (use on horse to apply)"),
inventory_image = "mobs_horseshoe_crystal.png"
})
minetest.register_craft({
output = "mobs:horseshoe_crystal",
recipe = {
{"", "ethereal:crystal_block", ""},
{"ethereal:crystal_ingot", "", "ethereal:crystal_ingot"},
{"ethereal:crystal_ingot", "", "ethereal:crystal_ingot"}
}
})
end
-- lucky blocks -- lucky blocks
if minetest.get_modpath("lucky_block") then if minetest.get_modpath("lucky_block") then
@ -283,6 +365,7 @@ lucky_block:add_blocks({
{"dro", {"mobs:horseshoe_bronze"}}, {"dro", {"mobs:horseshoe_bronze"}},
{"dro", {"mobs:horseshoe_mese"}}, {"dro", {"mobs:horseshoe_mese"}},
{"dro", {"mobs:horseshoe_diamond"}}, {"dro", {"mobs:horseshoe_diamond"}},
{"dro", {"mobs:horseshoe_crystal"}}
}) })
end end

View File

@ -1,3 +0,0 @@
-- Support for the old multi-load method
dofile(minetest.get_modpath("intllib").."/init.lua")

3
license.txt Normal file
View File

@ -0,0 +1,3 @@
Code: MIT
Textures: CC-BY-SA 3.0 by Mjollna
Model: MIT by KrupnovPavel

4
mod.conf Normal file
View File

@ -0,0 +1,4 @@
name = mob_horse
depends = mobs
optional_depends = lucky_block, intllib
description = Adds a rideable horse into game with horse shoe upgrades.

View File

@ -7,12 +7,16 @@ There are three different horse textures (white, brown, black) which will spawn
### Taming ### Taming
Horses can be tamed with 10x wheat, apple, barley, oats of corn which then allows the player to pick up the horse using a lasso and ride by right-clicking with a saddle. Horses can be tamed with 10x wheat, apple, barley, oats of corn which then allows the player to pick up the horse using a lasso and ride by right-clicking with a saddle.
---
### Saddle
Right clicking a horse with a saddle equips it and the horse will be ordered to stand still until you wish to ride.
--- ---
### Horseshoes ### Horseshoes
Horseshoes can be crafted using steel, bronze, mese and diamond (4x ingots - 2 down either side with 1x block top middle) and placed on a horse by right clicking with the item. These can make horses run faster or jump higher while riding depending on tier. Horseshoes can be crafted using steel, bronze, mese, diamond and crystal (4x ingots - 2 down either side with 1x block top middle) and placed on a horse by right clicking with the item. These can make horses run faster or jump higher while riding depending on tier.
--- ---
### Dead Horse ### Dead Horse
When riding a horse monsters will generally attack the horse first to get to player riding it, when horse dies the player is dismounted and it will drop any shoes or saddles in use as well as some horse meat. When riding a horse monsters will generally attack the horse first to get to player riding it, when horse dies the player is dismounted and it will drop any shoes or saddles in use as well as some horse meat.
#### Lucky Blocks: 4 #### Lucky Blocks: 5

72
spawn_example.lua Normal file
View File

@ -0,0 +1,72 @@
--[[ Spawn Template, defaults to values shown if line not provided
mobs:spawn({
name = "",
- Name of mob, must be provided e.g. "mymod:my_mob"
nodes = {"group:soil, "group:stone"},
- Nodes to spawn on top of.
neighbors = {"air"},
- Nodes to spawn beside.
min_light = 0,
- Minimum light level.
max_light = 15,
- Maximum light level, 15 is sunlight only.
interval = 30,
- Spawn interval in seconds.
chance = 5000,
- Spawn chance, 1 in every 5000 nodes.
active_object_count = 1,
- Active mobs of this type in area.
min_height = -31000,
- Minimum height level.
max_height = 31000,
- Maximum height level.
day_toggle = nil,
- Daytime toggle, true to spawn during day, false for night, nil for both
on_spawn = nil,
- On spawn function to run when mob spawns in world
on_map_load = nil,
- On map load, when true mob only spawns in newly generated map areas
})
]]--
-- Horse
mobs:spawn({
name = "mob_horse:horse",
nodes = {"default:dirt_with_grass", "ethereal:dry_dirt"},
min_light = 14,
interval = 60,
chance = 16000,
min_height = 10,
max_height = 31000,
day_toggle = true
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB