New drop system
This commit is contained in:
parent
b901a7875e
commit
86664b5cbb
@ -48,8 +48,11 @@ This mod add some functions that you can use in other mods:
|
||||
walk_velocity: the velocity when the monster is walking around
|
||||
run_velocity: the velocity when the monster is attacking a player
|
||||
damage: the damage per second
|
||||
drop: the drop item of the monster
|
||||
drop_count: the number of items that are dropped
|
||||
drops: is list of tables with the following fields:
|
||||
name: itemname
|
||||
chance: the inverted chance (same as in abm) to get the item
|
||||
min: the minimum number of items
|
||||
max: the maximum number of items
|
||||
armor: the armor (integer)(3=lowest; 1=highest)(fleshy group is used)
|
||||
drawtype: "front" or "side"
|
||||
water_damage: the damage per second if the mob is in water
|
||||
|
17
api.lua
17
api.lua
@ -15,8 +15,7 @@ function mobs:register_mob(name, def)
|
||||
light_damage = def.light_damage,
|
||||
water_damage = def.water_damage,
|
||||
lava_damage = def.lava_damage,
|
||||
drop = def.drop,
|
||||
drop_count = def.drop_count,
|
||||
drops = def.drops,
|
||||
armor = def.armor,
|
||||
drawtype = def.drawtype,
|
||||
on_rightclick = def.on_rightclick,
|
||||
@ -235,12 +234,16 @@ function mobs:register_mob(name, def)
|
||||
on_punch = function(self, hitter)
|
||||
if self.object:get_hp() <= 0 then
|
||||
if hitter and hitter:is_player() and hitter:get_inventory() then
|
||||
for i=1,math.random(0,2)-1+self.drop_count do
|
||||
hitter:get_inventory():add_item("main", ItemStack(self.drop))
|
||||
for _,drop in ipairs(self.drops) do
|
||||
if math.random(1, drop.chance) == 1 then
|
||||
hitter:get_inventory():add_item("main", ItemStack(drop.name.." "..math.random(drop.min, drop.max)))
|
||||
end
|
||||
end
|
||||
else
|
||||
for i=1,math.random(0,2)-1+self.drop_count do
|
||||
local obj = minetest.env:add_item(self.object:getpos(), self.drop)
|
||||
for _,drop in ipairs(self.drops) do
|
||||
if math.random(1, drop.chance) == 1 then
|
||||
for i=1,math.random(drop.min, drop.max) do
|
||||
local obj = minetest.env:add_item(self.object:getpos(), drop.name)
|
||||
if obj then
|
||||
obj:get_luaentity().collect = true
|
||||
local x = math.random(1, 5)
|
||||
@ -256,6 +259,8 @@ function mobs:register_mob(name, def)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
})
|
||||
|
38
init.lua
38
init.lua
@ -12,8 +12,12 @@ mobs:register_mob("mobs:dirt_monster", {
|
||||
walk_velocity = 1,
|
||||
run_velocity = 3,
|
||||
damage = 2,
|
||||
drop = "default:dirt",
|
||||
drop_count = 3,
|
||||
drops = {
|
||||
{name = "default:dirt",
|
||||
chance = 1,
|
||||
min = 3,
|
||||
max = 5,},
|
||||
},
|
||||
armor = 3,
|
||||
drawtype = "front",
|
||||
water_damage = 1,
|
||||
@ -35,8 +39,12 @@ mobs:register_mob("mobs:stone_monster", {
|
||||
walk_velocity = 0.5,
|
||||
run_velocity = 2,
|
||||
damage = 3,
|
||||
drop = "default:mossycobble",
|
||||
drop_count = 3,
|
||||
drops = {
|
||||
{name = "default:mossycobble",
|
||||
chance = 1,
|
||||
min = 3,
|
||||
max = 5,},
|
||||
},
|
||||
light_resistant = true,
|
||||
armor = 2,
|
||||
drawtype = "front",
|
||||
@ -59,8 +67,12 @@ mobs:register_mob("mobs:sand_monster", {
|
||||
walk_velocity = 1.5,
|
||||
run_velocity = 4,
|
||||
damage = 1,
|
||||
drop = "default:sand",
|
||||
drop_count = 3,
|
||||
drops = {
|
||||
{name = "default:sand",
|
||||
chance = 1,
|
||||
min = 3,
|
||||
max = 5,},
|
||||
},
|
||||
light_resistant = true,
|
||||
armor = 3,
|
||||
drawtype = "front",
|
||||
@ -80,8 +92,12 @@ mobs:register_mob("mobs:sheep", {
|
||||
makes_footstep_sound = true,
|
||||
walk_velocity = 1,
|
||||
armor = 3,
|
||||
drop = "mobs:meat_raw",
|
||||
drop_count = 2,
|
||||
drops = {
|
||||
{name = "mobs:meat_raw",
|
||||
chance = 1,
|
||||
min = 2,
|
||||
max = 3,},
|
||||
},
|
||||
drawtype = "side",
|
||||
water_damage = 1,
|
||||
lava_damage = 5,
|
||||
@ -130,8 +146,7 @@ mobs:register_mob("mobs:rat", {
|
||||
makes_footstep_sound = false,
|
||||
walk_velocity = 1,
|
||||
armor = 3,
|
||||
drop = "",
|
||||
drop_count = 0,
|
||||
drops = {},
|
||||
drawtype = "side",
|
||||
water_damage = 0,
|
||||
lava_damage = 1,
|
||||
@ -185,8 +200,7 @@ mobs:register_mob("mobs:oerkki", {
|
||||
walk_velocity = 1,
|
||||
run_velocity = 3,
|
||||
damage = 4,
|
||||
drop = "",
|
||||
drop_count = 0,
|
||||
drops = {},
|
||||
armor = 3,
|
||||
drawtype = "front",
|
||||
light_resistant = true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user