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
|
walk_velocity: the velocity when the monster is walking around
|
||||||
run_velocity: the velocity when the monster is attacking a player
|
run_velocity: the velocity when the monster is attacking a player
|
||||||
damage: the damage per second
|
damage: the damage per second
|
||||||
drop: the drop item of the monster
|
drops: is list of tables with the following fields:
|
||||||
drop_count: the number of items that are dropped
|
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)
|
armor: the armor (integer)(3=lowest; 1=highest)(fleshy group is used)
|
||||||
drawtype: "front" or "side"
|
drawtype: "front" or "side"
|
||||||
water_damage: the damage per second if the mob is in water
|
water_damage: the damage per second if the mob is in water
|
||||||
|
37
api.lua
37
api.lua
@ -15,8 +15,7 @@ function mobs:register_mob(name, def)
|
|||||||
light_damage = def.light_damage,
|
light_damage = def.light_damage,
|
||||||
water_damage = def.water_damage,
|
water_damage = def.water_damage,
|
||||||
lava_damage = def.lava_damage,
|
lava_damage = def.lava_damage,
|
||||||
drop = def.drop,
|
drops = def.drops,
|
||||||
drop_count = def.drop_count,
|
|
||||||
armor = def.armor,
|
armor = def.armor,
|
||||||
drawtype = def.drawtype,
|
drawtype = def.drawtype,
|
||||||
on_rightclick = def.on_rightclick,
|
on_rightclick = def.on_rightclick,
|
||||||
@ -235,23 +234,29 @@ function mobs:register_mob(name, def)
|
|||||||
on_punch = function(self, hitter)
|
on_punch = function(self, hitter)
|
||||||
if self.object:get_hp() <= 0 then
|
if self.object:get_hp() <= 0 then
|
||||||
if hitter and hitter:is_player() and hitter:get_inventory() then
|
if hitter and hitter:is_player() and hitter:get_inventory() then
|
||||||
for i=1,math.random(0,2)-1+self.drop_count do
|
for _,drop in ipairs(self.drops) do
|
||||||
hitter:get_inventory():add_item("main", ItemStack(self.drop))
|
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
|
end
|
||||||
else
|
else
|
||||||
for i=1,math.random(0,2)-1+self.drop_count do
|
for _,drop in ipairs(self.drops) do
|
||||||
local obj = minetest.env:add_item(self.object:getpos(), self.drop)
|
if math.random(1, drop.chance) == 1 then
|
||||||
if obj then
|
for i=1,math.random(drop.min, drop.max) do
|
||||||
obj:get_luaentity().collect = true
|
local obj = minetest.env:add_item(self.object:getpos(), drop.name)
|
||||||
local x = math.random(1, 5)
|
if obj then
|
||||||
if math.random(1,2) == 1 then
|
obj:get_luaentity().collect = true
|
||||||
x = -x
|
local x = math.random(1, 5)
|
||||||
|
if math.random(1,2) == 1 then
|
||||||
|
x = -x
|
||||||
|
end
|
||||||
|
local z = math.random(1, 5)
|
||||||
|
if math.random(1,2) == 1 then
|
||||||
|
z = -z
|
||||||
|
end
|
||||||
|
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
local z = math.random(1, 5)
|
|
||||||
if math.random(1,2) == 1 then
|
|
||||||
z = -z
|
|
||||||
end
|
|
||||||
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
|
||||||
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,
|
walk_velocity = 1,
|
||||||
run_velocity = 3,
|
run_velocity = 3,
|
||||||
damage = 2,
|
damage = 2,
|
||||||
drop = "default:dirt",
|
drops = {
|
||||||
drop_count = 3,
|
{name = "default:dirt",
|
||||||
|
chance = 1,
|
||||||
|
min = 3,
|
||||||
|
max = 5,},
|
||||||
|
},
|
||||||
armor = 3,
|
armor = 3,
|
||||||
drawtype = "front",
|
drawtype = "front",
|
||||||
water_damage = 1,
|
water_damage = 1,
|
||||||
@ -35,8 +39,12 @@ mobs:register_mob("mobs:stone_monster", {
|
|||||||
walk_velocity = 0.5,
|
walk_velocity = 0.5,
|
||||||
run_velocity = 2,
|
run_velocity = 2,
|
||||||
damage = 3,
|
damage = 3,
|
||||||
drop = "default:mossycobble",
|
drops = {
|
||||||
drop_count = 3,
|
{name = "default:mossycobble",
|
||||||
|
chance = 1,
|
||||||
|
min = 3,
|
||||||
|
max = 5,},
|
||||||
|
},
|
||||||
light_resistant = true,
|
light_resistant = true,
|
||||||
armor = 2,
|
armor = 2,
|
||||||
drawtype = "front",
|
drawtype = "front",
|
||||||
@ -59,8 +67,12 @@ mobs:register_mob("mobs:sand_monster", {
|
|||||||
walk_velocity = 1.5,
|
walk_velocity = 1.5,
|
||||||
run_velocity = 4,
|
run_velocity = 4,
|
||||||
damage = 1,
|
damage = 1,
|
||||||
drop = "default:sand",
|
drops = {
|
||||||
drop_count = 3,
|
{name = "default:sand",
|
||||||
|
chance = 1,
|
||||||
|
min = 3,
|
||||||
|
max = 5,},
|
||||||
|
},
|
||||||
light_resistant = true,
|
light_resistant = true,
|
||||||
armor = 3,
|
armor = 3,
|
||||||
drawtype = "front",
|
drawtype = "front",
|
||||||
@ -80,8 +92,12 @@ mobs:register_mob("mobs:sheep", {
|
|||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
armor = 3,
|
armor = 3,
|
||||||
drop = "mobs:meat_raw",
|
drops = {
|
||||||
drop_count = 2,
|
{name = "mobs:meat_raw",
|
||||||
|
chance = 1,
|
||||||
|
min = 2,
|
||||||
|
max = 3,},
|
||||||
|
},
|
||||||
drawtype = "side",
|
drawtype = "side",
|
||||||
water_damage = 1,
|
water_damage = 1,
|
||||||
lava_damage = 5,
|
lava_damage = 5,
|
||||||
@ -130,8 +146,7 @@ mobs:register_mob("mobs:rat", {
|
|||||||
makes_footstep_sound = false,
|
makes_footstep_sound = false,
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
armor = 3,
|
armor = 3,
|
||||||
drop = "",
|
drops = {},
|
||||||
drop_count = 0,
|
|
||||||
drawtype = "side",
|
drawtype = "side",
|
||||||
water_damage = 0,
|
water_damage = 0,
|
||||||
lava_damage = 1,
|
lava_damage = 1,
|
||||||
@ -185,8 +200,7 @@ mobs:register_mob("mobs:oerkki", {
|
|||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
run_velocity = 3,
|
run_velocity = 3,
|
||||||
damage = 4,
|
damage = 4,
|
||||||
drop = "",
|
drops = {},
|
||||||
drop_count = 0,
|
|
||||||
armor = 3,
|
armor = 3,
|
||||||
drawtype = "front",
|
drawtype = "front",
|
||||||
light_resistant = true,
|
light_resistant = true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user