forked from mtcontrib/mobs_redo
Version MFF.
This commit is contained in:
parent
4921956b60
commit
904780573c
68
README.txt
Executable file
68
README.txt
Executable file
|
@ -0,0 +1,68 @@
|
|||
-= MOBS-MOD for MINETEST =-
|
||||
by PilzAdam, KrupnovPavel, Zeg9 and TenPlus1
|
||||
|
||||
|
||||
https://forum.minetest.net/viewtopic.php?f=9&t=9917
|
||||
|
||||
This mod contains the following additions:
|
||||
|
||||
- Giant Spiders (found in desert caves, drop string when killed)
|
||||
- Bee's (found around flowers, drop honey when killed, right-click to pick up, also Beehives)
|
||||
- Chicken (lays eggs, added fried egg, raw & cooked chicken, right-click to pick up)
|
||||
- Cow (right-click with empty bucket to get bucket of milk, feed 8 wheat to replenish milk)
|
||||
- Sheep (right-click for wool, feed 8 wheat to replenish wool)
|
||||
- Warthog (the local pig that gives raw and cooked port)
|
||||
- Rats (right-click to pick up and place, cook for a tasty treat)
|
||||
- Sand, Dirt, Stone, Tree Monsters, Oerkki and Dungeon Masters as standard
|
||||
- Lava Flan, Mese Monsters added to spice things up a bit
|
||||
- Cook milk in furnace to get cheese wedge, 9 wedges make 1 cheese block
|
||||
|
||||
..with the following new features:
|
||||
|
||||
- Hitting a mob has knock-back effect like in minecraft, and with blood effect
|
||||
- Mobs float in water, so monsters can still chase you
|
||||
- Mobs can die from falling from a height
|
||||
- Mobs have better health and drops
|
||||
- Hitting a mob also puts them into fight mode (apart from animals)
|
||||
- Compatible with Ethereal mod, mobs now spawn on ethereal worlds
|
||||
|
||||
Changelog:
|
||||
|
||||
1.27- Added new sheep, lava flan and spawn egg textures. New Lava Pick tool smelts what you dig. New atan checking function.
|
||||
1.26- Pathfinding feature added thanks to rnd, when monsters attack they become scary smart in finding you :) also, beehive produces honey now :)
|
||||
1.25- Mobs no longer spawn within 12 blocks of player or despawn within same range, spawners now have player detection, Code tidy and tweak.
|
||||
1.24- Added feature where certain animals run away when punched (runaway = true in mob definition)
|
||||
1.23- Added mob spawner block for admin to setup spawners in-game (place and right click to enter settings)
|
||||
1.22- Added ability to name tamed animals and npc using nametags, also npc will attack anyone who punches them apart from owner
|
||||
1.21- Added some more error checking to reduce serialize.h error and added height checks for falling off cliffs (thanks cmdskp)
|
||||
1.20- Error checking added to remove bad mobs, out of map limit mobs and stop serialize.h error
|
||||
1.19- Chickens now drop egg items instead of placing the egg, also throwing eggs result in 1/8 chance of spawning chick
|
||||
1.18- Added docile_by_day flag so that monsters will not attack automatically during daylight hours unless hit first
|
||||
1.17- Added 'dogshoot' attack type, shoots when out of reach, melee attack when in reach, also api tweaks and self.reach added
|
||||
1.16- Mobs follow multiple items now, Npc's can breed
|
||||
1.15- Added Feeding/Taming/Breeding function, right-click to pick up any sheep with X mark on them and replace with new one to fix compatibility.
|
||||
1.14- All .self variables saved in staticdata, Fixed self.health bug
|
||||
1.13- Added capture function (thanks blert2112) chance of picking up mob with hand; net; magic lasso, replaced some .x models with newer .b3d one's
|
||||
1.12- Added animal ownership so that players cannot steal your tamed animals
|
||||
1.11- Added flying mobs (and swimming), fly=true and fly_in="air" or "deafult:water_source" for fishy
|
||||
1,10- Footstep removed (use replace), explosion routine added for exploding mobs.
|
||||
1.09- reworked breeding routine, added mob rotation value, added footstep feature, added jumping mobs with sounds feature, added magic lasso for picking up animals
|
||||
1.08- Mob throwing attack has been rehauled so that they can damage one another, also drops and on_die function added
|
||||
1.07- Npc's can now be set to follow player or stand by using self.order and self.owner variables
|
||||
beta- Npc mob added, kills monsters, attacks player when punched, right click with food to heal or gold lump for drop
|
||||
1.06- Changed recovery times after breeding, and time taken to grow up (can be sped up by feeding baby animal)
|
||||
1.05- Added ExeterDad's bunny's which can be picked up and tamed with 4 carrots from farming redo or farming_plus, also shears added to get wool from sheep and lastly Jordach/BSD's kitten
|
||||
1.04- Added mating for sheep, cows and hogs... feed animals to make horny and hope for a baby which is half size, will grow up quick though :)
|
||||
1.03- Added mob drop/replace feature so that chickens can drop eggs, cow/sheep can eat grass/wheat etc.
|
||||
1.02- Sheared sheep are remembered and spawn shaven, Warthogs will attack when threatened, Api additions
|
||||
1.01- Mobs that suffer fall damage or die in water/lava/sunlight will now drop items
|
||||
1.0 - more work on Api so that certain mobs can float in water while some sink like a brick :)
|
||||
0.9 - Spawn eggs added for all mobs (admin only, cannot be placed in protected areas)... Api tweaked
|
||||
0.8 - Added sounds to monster mobs (thanks Cyberpangolin for the sfx) and also chicken sound
|
||||
0.7 - mobs.protected switch added to api.lua, when set to 1 mobs no longer spawn in protected areas, also bug fixes
|
||||
0.6 - Api now supports multi-textured mobs, e.g oerkki, dungeon master, rats and chickens have random skins when spawning (sheep fix TODO), also new Honey block
|
||||
0.5 - Mobs now float in water, die from falling, and some code improvements
|
||||
0.4 - Dungeon Masters and Mese Monsters have much better aim due to shoot_offset, also they can both shoot through nodes that aren't walkable (flowers, grass etc) plus new sheep sound :)
|
||||
0.3 - Added LOTT's Spider mob, made Cobwebs, added KPavel's Bee with Honey and Beehives (made texture), Warthogs now have sound and can be tamed, taming of shaved sheep or milked cow with 8 wheat so it will not despawn, many bug fixes :)
|
||||
0.2 - Cooking bucket of milk into cheese now returns empty bucket
|
||||
0.1 - Initial Release
|
389
api.lua
Normal file → Executable file
389
api.lua
Normal file → Executable file
|
@ -1,6 +1,4 @@
|
|||
|
||||
-- Mobs Api (15th April 2016)
|
||||
|
||||
-- Mobs Api (4th March 2016)
|
||||
mobs = {}
|
||||
mobs.mod = "redo"
|
||||
|
||||
|
@ -79,8 +77,6 @@ set_animation = function(self, type)
|
|||
|
||||
self.animation.current = self.animation.current or ""
|
||||
|
||||
self.animation.speed_normal = self.animation.speed_normal or 15
|
||||
|
||||
if type == "stand"
|
||||
and self.animation.current ~= "stand" then
|
||||
|
||||
|
@ -121,7 +117,7 @@ set_animation = function(self, type)
|
|||
self.object:set_animation({
|
||||
x = self.animation.run_start,
|
||||
y = self.animation.run_end},
|
||||
(self.animation.speed_run or self.animation.speed_normal), 0)
|
||||
self.animation.speed_run, 0)
|
||||
|
||||
self.animation.current = "run"
|
||||
end
|
||||
|
@ -136,7 +132,7 @@ set_animation = function(self, type)
|
|||
self.object:set_animation({
|
||||
x = self.animation.punch_start,
|
||||
y = self.animation.punch_end},
|
||||
(self.animation.speed_punch or self.animation.speed_normal), 0)
|
||||
self.animation.speed_normal, 0)
|
||||
|
||||
self.animation.current = "punch"
|
||||
end
|
||||
|
@ -172,19 +168,17 @@ function line_of_sight_water(self, pos1, pos2, stepsize)
|
|||
end
|
||||
|
||||
-- particle effects
|
||||
function effect(pos, amount, texture, max_size, radius)
|
||||
|
||||
radius = radius or 2
|
||||
function effect(pos, amount, texture, max_size)
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = amount,
|
||||
time = 0.25,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minvel = {x = -radius, y = -radius, z = -radius},
|
||||
maxvel = {x = radius, y = radius, z = radius},
|
||||
minacc = {x = -radius, y = -radius, z = -radius},
|
||||
maxacc = {x = radius, y = radius, z = radius},
|
||||
minvel = {x = -0, y = -2, z = -0},
|
||||
maxvel = {x = 2, y = 2, z = 2},
|
||||
minacc = {x = -4, y = -4, z = -4},
|
||||
maxacc = {x = 4, y = 4, z = 4},
|
||||
minexptime = 0.1,
|
||||
maxexptime = 1,
|
||||
minsize = 0.5,
|
||||
|
@ -221,15 +215,17 @@ end
|
|||
-- check if mob is dead or only hurt
|
||||
function check_for_death(self)
|
||||
|
||||
-- has health actually changed?
|
||||
if self.health == self.old_health then
|
||||
return
|
||||
-- return if no change
|
||||
local hp = self.object:get_hp()
|
||||
|
||||
if hp == self.health then
|
||||
return false
|
||||
end
|
||||
|
||||
self.old_health = self.health
|
||||
|
||||
-- still got some health? play hurt sound
|
||||
if self.health > 0 then
|
||||
if hp > 0 then
|
||||
|
||||
self.health = hp
|
||||
|
||||
if self.sounds.damage then
|
||||
|
||||
|
@ -240,11 +236,6 @@ function check_for_death(self)
|
|||
})
|
||||
end
|
||||
|
||||
-- make sure health isn't higher than max
|
||||
if self.health > self.hp_max then
|
||||
self.health = self.hp_max
|
||||
end
|
||||
|
||||
update_tag(self)
|
||||
|
||||
return false
|
||||
|
@ -375,7 +366,7 @@ do_env_damage = function(self)
|
|||
and self.time_of_day < 0.8
|
||||
and (minetest.get_node_light(pos) or 0) > 12 then
|
||||
|
||||
self.health = self.health - self.light_damage
|
||||
self.object:set_hp(self.object:get_hp() - self.light_damage)
|
||||
|
||||
effect(pos, 5, "tnt_smoke.png")
|
||||
end
|
||||
|
@ -396,7 +387,7 @@ do_env_damage = function(self)
|
|||
if self.water_damage ~= 0
|
||||
and nodef.groups.water then
|
||||
|
||||
self.health = self.health - self.water_damage
|
||||
self.object:set_hp(self.object:get_hp() - self.water_damage)
|
||||
|
||||
effect(pos, 5, "bubble.png")
|
||||
end
|
||||
|
@ -407,7 +398,7 @@ do_env_damage = function(self)
|
|||
or self.standing_in == "fire:basic_flame"
|
||||
or self.standing_in == "fire:permanent_flame") then
|
||||
|
||||
self.health = self.health - self.lava_damage
|
||||
self.object:set_hp(self.object:get_hp() - self.lava_damage)
|
||||
|
||||
effect(pos, 5, "fire_basic_flame.png")
|
||||
end
|
||||
|
@ -456,9 +447,8 @@ do_jump = function(self)
|
|||
|
||||
--print ("in front:", nod.name, pos.y + 0.5)
|
||||
|
||||
if (minetest.registered_items[nod.name].walkable
|
||||
if minetest.registered_items[nod.name].walkable
|
||||
and not nod.name:find("fence")
|
||||
and not nod.name:find("gate"))
|
||||
or self.walk_chance == 0 then
|
||||
|
||||
local v = self.object:getvelocity()
|
||||
|
@ -485,6 +475,26 @@ do_jump = function(self)
|
|||
end
|
||||
end
|
||||
|
||||
function calc_velocity(pos1, pos2, old_vel, power) --MFF we use this function
|
||||
-- If the two positions are equal the vector will contain nan and crash the game
|
||||
if (pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z) then
|
||||
return {
|
||||
x = 0,
|
||||
y = 0,
|
||||
z = 0
|
||||
}
|
||||
end
|
||||
|
||||
local vel = vector.direction(pos1, pos2)
|
||||
vel = vector.normalize(vel)
|
||||
vel = vector.multiply(vel, power)
|
||||
local dist = vector.distance(pos1, pos2)
|
||||
dist = math.max(dist, 1)
|
||||
vel = vector.divide(vel, dist)
|
||||
vel = vector.add(vel, old_vel)
|
||||
return vel
|
||||
end
|
||||
|
||||
-- this is a faster way to calculate distance
|
||||
local get_distance = function(a, b)
|
||||
|
||||
|
@ -494,33 +504,27 @@ local get_distance = function(a, b)
|
|||
end
|
||||
|
||||
-- blast damage to entities nearby (modified from TNT mod)
|
||||
function entity_physics(pos, radius)
|
||||
function entity_physics(pos, radius, self) --/MFF (Crabman|06/23/2015)add self to use punch function
|
||||
|
||||
radius = radius * 2
|
||||
|
||||
local objs = minetest.get_objects_inside_radius(pos, radius)
|
||||
local obj_pos, dist
|
||||
local obj_pos, obj_vel, dist
|
||||
|
||||
for _, obj in pairs(objs) do
|
||||
|
||||
obj_pos = obj:getpos()
|
||||
|
||||
dist = math.max(1, get_distance(pos, obj_pos))
|
||||
|
||||
local damage = math.floor((4 / dist) * radius)
|
||||
local ent = obj:get_luaentity()
|
||||
|
||||
if obj:is_player() then
|
||||
obj:set_hp(obj:get_hp() - damage)
|
||||
|
||||
else --if ent.health then
|
||||
|
||||
obj:punch(obj, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = damage},
|
||||
}, nil)
|
||||
|
||||
end
|
||||
--MFF DEBUT pumpkins
|
||||
obj_vel = obj:getvelocity()
|
||||
if obj_vel ~= nil then
|
||||
if not (obj:get_entity_name() == "__builtin:item" and self.do_not_project_items) then
|
||||
obj:setvelocity(calc_velocity(pos, obj_pos, obj_vel, radius * 10))
|
||||
end
|
||||
end --MFF FIN pumpkins
|
||||
--dist = math.max(1, get_distance(pos, obj_pos))
|
||||
--local damage = math.floor((4 / dist) * radius)
|
||||
--obj:set_hp(obj:get_hp() - damage)
|
||||
obj:punch(self.object, 1.0,{full_punch_interval=1.0, damage_groups = {fleshy=self.damage} })--/MFF (Crabman|06/23/2015) use punch
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -882,13 +886,9 @@ function smart_mobs(self, s, p, dist, dtime)
|
|||
end
|
||||
end
|
||||
|
||||
mobs.spawning_mobs = {}
|
||||
|
||||
-- register mob function
|
||||
function mobs:register_mob(name, def)
|
||||
|
||||
mobs.spawning_mobs[name] = true
|
||||
|
||||
minetest.register_entity(name, {
|
||||
|
||||
stepheight = def.stepheight or 0.6,
|
||||
|
@ -938,7 +938,7 @@ minetest.register_entity(name, {
|
|||
--fov = def.fov or 120,
|
||||
passive = def.passive or false,
|
||||
recovery_time = def.recovery_time or 0.5,
|
||||
knock_back = def.knock_back or 3,
|
||||
knock_back = def.knock_back or 1, --Modif MFF, default value is "or 3",
|
||||
blood_amount = def.blood_amount or 5,
|
||||
blood_texture = def.blood_texture or "mobs_blood.png",
|
||||
shoot_offset = def.shoot_offset or 0,
|
||||
|
@ -958,6 +958,7 @@ minetest.register_entity(name, {
|
|||
health = 0,
|
||||
reach = def.reach or 3,
|
||||
htimer = 0,
|
||||
do_not_project_items = def.do_not_project_items or false, --MFF pumpkins
|
||||
child_texture = def.child_texture,
|
||||
docile_by_day = def.docile_by_day or false,
|
||||
time_of_day = 0.5,
|
||||
|
@ -965,8 +966,6 @@ minetest.register_entity(name, {
|
|||
runaway = def.runaway,
|
||||
runaway_timer = 0,
|
||||
pathfinding = def.pathfinding,
|
||||
immune_to = def.immune_to or {},
|
||||
explosion_radius = def.explosion_radius,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
|
||||
|
@ -1048,8 +1047,7 @@ minetest.register_entity(name, {
|
|||
|
||||
if d > 5 then
|
||||
|
||||
--self.object:set_hp(self.object:get_hp() - math.floor(d - 5))
|
||||
self.health = self.health - math.floor(d - 5)
|
||||
self.object:set_hp(self.object:get_hp() - math.floor(d - 5))
|
||||
|
||||
effect(pos, 5, "tnt_smoke.png")
|
||||
|
||||
|
@ -1192,6 +1190,7 @@ minetest.register_entity(name, {
|
|||
and self.state ~= "attack" then
|
||||
|
||||
local s = self.object:getpos()
|
||||
local p, dist --MFF
|
||||
local obj = nil
|
||||
|
||||
for _, oir in pairs(minetest.get_objects_inside_radius(s, self.view_range)) do
|
||||
|
@ -1499,10 +1498,10 @@ minetest.register_entity(name, {
|
|||
local dist = get_distance(p, s)
|
||||
|
||||
-- stop attacking if player or out of range
|
||||
if dist > self.view_range
|
||||
if (dist > self.view_range
|
||||
or not self.attack
|
||||
or not self.attack:getpos()
|
||||
or self.attack:get_hp() <= 0 then
|
||||
or self.attack:get_hp() <= 0) and not self.exploding then -- MFF
|
||||
|
||||
--print(" ** stop attacking **", dist, self.view_range)
|
||||
self.state = "stand"
|
||||
|
@ -1536,7 +1535,7 @@ minetest.register_entity(name, {
|
|||
self.object:setyaw(yaw)
|
||||
end
|
||||
|
||||
if dist > self.reach then
|
||||
if dist > self.reach and not self.exploding then
|
||||
|
||||
if not self.v_start then
|
||||
|
||||
|
@ -1560,7 +1559,8 @@ minetest.register_entity(name, {
|
|||
end
|
||||
|
||||
set_animation(self, "run")
|
||||
else
|
||||
else -- MFF(Mg|06/10/2016) #509
|
||||
self.exploding = true --MFF
|
||||
set_velocity(self, 0)
|
||||
self.timer = self.timer + dtime
|
||||
self.blinktimer = (self.blinktimer or 0) + dtime
|
||||
|
@ -1581,10 +1581,9 @@ minetest.register_entity(name, {
|
|||
if self.timer > 3 then
|
||||
|
||||
local pos = self.object:getpos()
|
||||
local radius = self.explosion_radius or 1
|
||||
|
||||
-- hurt player/mobs caught in blast area
|
||||
entity_physics(pos, radius)
|
||||
entity_physics(pos, 3, self) --/MFF (Crabman|06/23/2015)add self to use punch function
|
||||
|
||||
-- dont damage anything if area protected or next to water
|
||||
if minetest.find_node_near(pos, 1, {"group:water"})
|
||||
|
@ -1608,7 +1607,7 @@ minetest.register_entity(name, {
|
|||
|
||||
pos.y = pos.y - 1
|
||||
|
||||
mobs:explosion(pos, radius, 0, 1, self.sounds.explode)
|
||||
mobs:explosion(pos, 2, 0, 1, self.sounds.explode)
|
||||
|
||||
self.object:remove()
|
||||
|
||||
|
@ -1839,14 +1838,14 @@ minetest.register_entity(name, {
|
|||
local obj = minetest.add_entity(p, self.arrow)
|
||||
local ent = obj:get_luaentity()
|
||||
local amount = (vec.x * vec.x + vec.y * vec.y + vec.z * vec.z) ^ 0.5
|
||||
local v = ent.velocity or 1 -- or set to default
|
||||
local v = ent.velocity
|
||||
ent.switch = 1
|
||||
|
||||
-- offset makes shoot aim accurate
|
||||
vec.y = vec.y + self.shoot_offset
|
||||
vec.x = vec.x * (v / amount)
|
||||
vec.y = vec.y * (v / amount)
|
||||
vec.z = vec.z * (v / amount)
|
||||
vec.x = vec.x * v / amount
|
||||
vec.y = vec.y * v / amount
|
||||
vec.z = vec.z * v / amount
|
||||
|
||||
obj:setvelocity(vec)
|
||||
end
|
||||
|
@ -1861,45 +1860,17 @@ minetest.register_entity(name, {
|
|||
dir = dir or {x = 0, y = 0, z = 0}
|
||||
|
||||
-- weapon wear
|
||||
local attach = hitter:get_attach()
|
||||
if attach and attach:get_luaentity() then
|
||||
local luaentity = attach:get_luaentity()
|
||||
if luaentity.driver then
|
||||
luaentity.driver = nil
|
||||
end
|
||||
hitter:set_detach() --MFF (crabman|27/7/2015) anti usebug, immortal if attached
|
||||
end
|
||||
local weapon = hitter:get_wielded_item()
|
||||
local punch_interval = 1.4
|
||||
|
||||
-- calculate mob damage
|
||||
local damage = 0
|
||||
local armor = self.object:get_armor_groups() or {}
|
||||
local tmp
|
||||
|
||||
-- quick error check incase it ends up 0 (serialize.h check test)
|
||||
if tflp == 0 then
|
||||
tflp = 0.2
|
||||
end
|
||||
|
||||
for group,_ in pairs(tool_capabilities.damage_groups) do
|
||||
|
||||
tmp = tflp / (tool_capabilities.full_punch_interval or 1.4)
|
||||
|
||||
if tmp < 0 then
|
||||
tmp = 0.0
|
||||
elseif tmp > 1 then
|
||||
tmp = 1.0
|
||||
end
|
||||
|
||||
damage = damage + (tool_capabilities.damage_groups[group] or 0)
|
||||
* tmp * ((armor[group] or 0) / 100.0)
|
||||
end
|
||||
|
||||
-- check for tool immunity or special damage
|
||||
for _, no in pairs(self.immune_to) do
|
||||
|
||||
if no[1] == weapon:get_name() then
|
||||
damage = no[2] or 0
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- print ("Mob Damage is", damage)
|
||||
|
||||
-- add weapon wear
|
||||
if tool_capabilities then
|
||||
punch_interval = tool_capabilities.full_punch_interval or 1.4
|
||||
end
|
||||
|
@ -1927,23 +1898,11 @@ minetest.register_entity(name, {
|
|||
})
|
||||
end
|
||||
|
||||
-- do damage
|
||||
self.health = self.health - math.floor(damage)
|
||||
|
||||
-- exit here if dead
|
||||
if check_for_death(self) then
|
||||
return
|
||||
end
|
||||
|
||||
-- add healthy afterglow when hit
|
||||
core.after(0.1, function()
|
||||
self.object:settexturemod("^[colorize:#c9900070")
|
||||
|
||||
core.after(0.3, function()
|
||||
self.object:settexturemod("")
|
||||
end)
|
||||
end)
|
||||
|
||||
-- blood_particles
|
||||
if self.blood_amount > 0
|
||||
and not disable_blood then
|
||||
|
@ -1955,9 +1914,8 @@ minetest.register_entity(name, {
|
|||
effect(pos, self.blood_amount, self.blood_texture)
|
||||
end
|
||||
|
||||
-- knock back effect (only on full punch)
|
||||
if self.knock_back > 0
|
||||
and tflp > punch_interval then
|
||||
-- knock back effect
|
||||
if self.knock_back > 0 then
|
||||
|
||||
local v = self.object:getvelocity()
|
||||
local r = 1.4 - math.min(punch_interval, 1.4)
|
||||
|
@ -2119,9 +2077,9 @@ minetest.register_entity(name, {
|
|||
self.path.stuck_timer = 0 -- if stuck for too long search for path
|
||||
-- end init
|
||||
|
||||
self.object:set_armor_groups({immortal = 1, fleshy = self.armor})
|
||||
self.object:set_hp(self.health)
|
||||
self.object:set_armor_groups({fleshy = self.armor})
|
||||
self.old_y = self.object:getpos().y
|
||||
self.old_health = self.health
|
||||
self.object:setyaw((math.random(0, 360) - 180) / 180 * pi)
|
||||
self.sounds.distance = self.sounds.distance or 10
|
||||
self.textures = textures
|
||||
|
@ -2183,8 +2141,68 @@ end -- END mobs:register_mob function
|
|||
|
||||
-- global functions
|
||||
|
||||
mobs.spawning_mobs = {}
|
||||
|
||||
function mobs:spawn_special(name, nodes, neighbors, interval, chance, active_object_count) -- MFF to special mobs
|
||||
mobs.spawning_mobs[name] = true
|
||||
-- chance override in minetest.conf for registered mob
|
||||
local new_chance = tonumber(minetest.setting_get(name .. "_chance"))
|
||||
if new_chance ~= nil then
|
||||
if new_chance == 0 then
|
||||
return
|
||||
end
|
||||
chance = new_chance
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = nodes,
|
||||
neighbors = neighbors,
|
||||
interval = interval,
|
||||
chance = chance,
|
||||
action = function(pos, node, _, active_object_count_wider)
|
||||
-- do not spawn if too many active entities in area
|
||||
local count = 0
|
||||
local objs = minetest.get_objects_inside_radius(pos, 60)
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_luaentity() ~= nil and obj:get_luaentity().name == name then
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
if count > active_object_count then
|
||||
return
|
||||
end
|
||||
-- spawn above node
|
||||
pos.y = pos.y + 1
|
||||
-- only spawn away from player
|
||||
local objs = minetest.get_objects_inside_radius(pos, 10)
|
||||
for _,oir in pairs(objs) do
|
||||
if oir:is_player() then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- are we spawning inside solid nodes?
|
||||
if minetest.registered_nodes[node_ok(pos).name].walkable == true then
|
||||
return
|
||||
end
|
||||
|
||||
pos.y = pos.y + 1
|
||||
if minetest.registered_nodes[node_ok(pos).name].walkable == true then
|
||||
return
|
||||
end
|
||||
|
||||
-- spawn mob half block higher than ground
|
||||
pos.y = pos.y - 0.5
|
||||
minetest.add_entity(pos, name)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||
interval, chance, active_object_count, min_height, max_height, day_toggle)
|
||||
interval, chance, active_object_count, min_height, max_height, spawn_in_area, day_toggle) --MFF crabman "spawn_in_area"
|
||||
|
||||
mobs.spawning_mobs[name] = true
|
||||
|
||||
-- chance override in minetest.conf for registered mob
|
||||
local new_chance = tonumber(minetest.setting_get(name .. "_chance"))
|
||||
|
@ -2192,7 +2210,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
|||
if new_chance ~= nil then
|
||||
|
||||
if new_chance == 0 then
|
||||
print("[Mobs Redo] " .. name .. " has spawning disabled")
|
||||
--print("[Mobs Redo] " .. name .. " has spawning disabled")
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -2209,11 +2227,12 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
|||
interval = interval,
|
||||
chance = chance,
|
||||
|
||||
action = function(pos, node, aoc, active_object_count_wider)
|
||||
action = function(pos, node, _, active_object_count_wider)
|
||||
|
||||
-- do not spawn if too many active entities in area
|
||||
if active_object_count_wider > active_object_count
|
||||
or not mobs.spawning_mobs[name] then
|
||||
or not mobs.spawning_mobs[name]
|
||||
or not pos then --MFF fix crash
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -2250,7 +2269,8 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
|||
|
||||
-- mobs cannot spawn in protected areas when enabled
|
||||
if spawn_protected == 1
|
||||
and minetest.is_protected(pos, "") then
|
||||
and minetest.is_protected(pos, "")
|
||||
and not spawn_in_area then --MFF crabman
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -2294,10 +2314,10 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
|||
end
|
||||
|
||||
-- compatibility with older mob registration
|
||||
function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height, day_toggle)
|
||||
function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height, spawn_in_area, day_toggle)
|
||||
|
||||
mobs:spawn_specific(name, nodes, {"air"}, min_light, max_light, 30,
|
||||
chance, active_object_count, -31000, max_height, day_toggle)
|
||||
chance, active_object_count, -31000, max_height, spawn_in_area, day_toggle)
|
||||
end
|
||||
|
||||
-- set content id's
|
||||
|
@ -2349,7 +2369,8 @@ function mobs:explosion(pos, radius, fire, smoke, sound)
|
|||
p.y = pos.y + y
|
||||
p.z = pos.z + z
|
||||
|
||||
if (x * x) + (y * y) + (z * z) <= (radius * radius) + pr:next(-radius, radius)
|
||||
if p.y >= -19600 --MFF
|
||||
and(x * x) + (y * y) + (z * z) <= (radius * radius) + pr:next(-radius, radius)
|
||||
and data[vi] ~= c_air
|
||||
and data[vi] ~= c_ignore
|
||||
and data[vi] ~= c_obsidian
|
||||
|
@ -2360,8 +2381,48 @@ function mobs:explosion(pos, radius, fire, smoke, sound)
|
|||
local on_blast = minetest.registered_nodes[n].on_blast
|
||||
|
||||
if on_blast then
|
||||
return on_blast(p)
|
||||
else
|
||||
local drops = on_blast(p) or {} -- MFF(Lymkwi) : Chests and bones return their drops now
|
||||
for _, name in ipairs(drops) do
|
||||
local obj = minetest.add_item(p, ItemStack(name))
|
||||
if obj then
|
||||
obj:setvelocity({
|
||||
x = math.random(-2, 2),
|
||||
y = 7,
|
||||
z = math.random(-2, 2)
|
||||
})
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not minetest.is_protected(p, "") --/MFF (Crabman|06/23/2015) re-added node protected in areas
|
||||
and minetest.get_item_group(n, "unbreakable") ~= 1
|
||||
and minetest.get_item_group(n, "nether") == 0 then
|
||||
|
||||
-- if chest then drop items inside
|
||||
if n == "default:chest"
|
||||
or n == "3dchest:chest"
|
||||
or n == "bones:bones" then
|
||||
|
||||
local meta = minetest.get_meta(p)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
for i = 1, inv:get_size("main") do
|
||||
|
||||
local m_stack = inv:get_stack("main", i)
|
||||
local obj = minetest.add_item(p, m_stack)
|
||||
|
||||
if obj then
|
||||
|
||||
obj:setvelocity({
|
||||
x = math.random(-2, 2),
|
||||
y = 7,
|
||||
z = math.random(-2, 2)
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- after effects
|
||||
if fire > 0
|
||||
and (minetest.registered_nodes[n].groups.flammable
|
||||
|
@ -2420,13 +2481,6 @@ function mobs:register_arrow(name, def)
|
|||
return
|
||||
end
|
||||
|
||||
-- does arrow have a tail (fireball)
|
||||
if def.tail
|
||||
and def.tail == 1
|
||||
and def.tail_texture then
|
||||
effect(pos, 1, def.tail_texture, 10, 0)
|
||||
end
|
||||
|
||||
if self.hit_node then
|
||||
|
||||
local node = node_ok(pos).name
|
||||
|
@ -2488,30 +2542,20 @@ function mobs:register_arrow(name, def)
|
|||
end
|
||||
|
||||
-- Spawn Egg
|
||||
function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
||||
|
||||
local grp = {}
|
||||
|
||||
-- do NOT add this egg to creative inventory (e.g. dungeon master)
|
||||
if creative and no_creative == true then
|
||||
grp = {not_in_creative_inventory = 1}
|
||||
end
|
||||
function mobs:register_egg(mob, desc, background, addegg)
|
||||
|
||||
local invimg = background
|
||||
|
||||
if addegg == 1 then
|
||||
invimg = "mobs_chicken_egg.png^(" .. invimg ..
|
||||
"^[mask:mobs_chicken_egg_overlay.png)"
|
||||
invimg = invimg .. "^mobs_egg_inv.png" -- MFF
|
||||
end
|
||||
|
||||
minetest.register_craftitem(mob, {
|
||||
|
||||
description = desc,
|
||||
inventory_image = invimg,
|
||||
groups = grp,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
|
||||
local pos = pointed_thing.above
|
||||
|
||||
if pos
|
||||
|
@ -2523,11 +2567,6 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
|||
local mob = minetest.add_entity(pos, mob)
|
||||
local ent = mob:get_luaentity()
|
||||
|
||||
if not ent then
|
||||
mob:remove()
|
||||
return
|
||||
end
|
||||
|
||||
if ent.type ~= "monster" then
|
||||
-- set owner and tame if not monster
|
||||
ent.owner = placer:get_player_name()
|
||||
|
@ -2774,41 +2813,3 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
|
||||
end
|
||||
end)
|
||||
|
||||
-- used to drop items inside a chest or container
|
||||
local drop_items = function(pos, invstring)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
for i = 1, inv:get_size(invstring) do
|
||||
|
||||
local m_stack = inv:get_stack(invstring, i)
|
||||
local obj = minetest.add_item(pos, m_stack)
|
||||
|
||||
if obj then
|
||||
|
||||
obj:setvelocity({
|
||||
x = math.random(-10, 10) / 9,
|
||||
y = 3,
|
||||
z = math.random(-10, 10) / 9
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- override chest node so it drops items on explode
|
||||
minetest.override_item("default:chest", {
|
||||
|
||||
on_blast = function(p)
|
||||
|
||||
minetest.after(0, function()
|
||||
|
||||
drop_items(p, "main")
|
||||
|
||||
minetest.remove_node(p)
|
||||
end)
|
||||
end,
|
||||
|
||||
})
|
||||
|
|
190
bee.lua
Executable file
190
bee.lua
Executable file
|
@ -0,0 +1,190 @@
|
|||
|
||||
-- Bee by KrupnoPavel
|
||||
|
||||
mobs:register_mob("mobs:bee", {
|
||||
-- animal, monster, npc, barbarian
|
||||
type = "animal",
|
||||
-- it is aggressive
|
||||
passive = true,
|
||||
-- health & armor
|
||||
hp_min = 1,
|
||||
hp_max = 2,
|
||||
armor = 200,
|
||||
-- textures and model
|
||||
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.2, 0.2},
|
||||
visual = "mesh",
|
||||
mesh = "mobs_bee.x",
|
||||
textures = {
|
||||
{"mobs_bee.png"},
|
||||
},
|
||||
-- sounds
|
||||
makes_footstep_sound = false,
|
||||
sounds = {
|
||||
random = "mobs_bee",
|
||||
},
|
||||
walk_velocity = 1,
|
||||
jump = true,
|
||||
-- drops honey when killed
|
||||
drops = {
|
||||
{name = "mobs:honey", chance = 1, min = 1, max = 2},
|
||||
},
|
||||
-- damage
|
||||
water_damage = 1,
|
||||
lava_damage = 1,
|
||||
light_damage = 0,
|
||||
fall_damage = 0,
|
||||
fall_speed = -3,
|
||||
-- model animation
|
||||
animation = {
|
||||
speed_normal = 15,
|
||||
stand_start = 0,
|
||||
stand_end = 30,
|
||||
walk_start = 35,
|
||||
walk_end = 65,
|
||||
},
|
||||
-- right click to pick up bee
|
||||
on_rightclick = function(self, clicker)
|
||||
mobs:capture_mob(self, clicker, 25, 80, 0, true, nil)
|
||||
end,
|
||||
})
|
||||
-- spawn on group:flowers between 4 and 20 light, 1 in 8000 chance, 1 bee in area up to 31000 in height
|
||||
mobs:spawn_specific("mobs:bee", {"group:flower"}, {"air"}, 4, 20, 30, 8000, 2, -31000, 31000, true, true)
|
||||
-- register spawn egg
|
||||
mobs:register_egg("mobs:bee", "Bee", "mobs_bee_inv.png", 1)
|
||||
|
||||
-- honey
|
||||
minetest.register_craftitem("mobs:honey", {
|
||||
description = "Honey",
|
||||
inventory_image = "mobs_honey_inv.png",
|
||||
on_use = minetest.item_eat(6),
|
||||
})
|
||||
|
||||
-- beehive (when placed spawns bee)
|
||||
minetest.register_node("mobs:beehive", {
|
||||
description = "Beehive",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tiles = {"mobs_beehive.png"},
|
||||
inventory_image = "mobs_beehive.png",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = true,
|
||||
groups = {fleshy=3,dig_immediate=3},
|
||||
on_use = minetest.item_eat(4),
|
||||
sounds = default.node_sound_defaults(),
|
||||
|
||||
on_construct = function(pos)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
meta:set_string("formspec", "size[8,6]"
|
||||
..default.gui_bg..default.gui_bg_img..default.gui_slots
|
||||
.. "image[3,0.8;0.8,0.8;mobs_bee_inv.png]"
|
||||
.. "list[current_name;beehive;4,0.5;1,1;]"
|
||||
.. "list[current_player;main;0,2.35;8,4;]"
|
||||
.. "listring[]")
|
||||
|
||||
meta:get_inventory():set_size("beehive", 1)
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
|
||||
if placer:is_player() then
|
||||
|
||||
minetest.set_node(pos, {name = "mobs:beehive", param2 = 1})
|
||||
|
||||
if math.random(1, 5) == 1 then
|
||||
minetest.add_entity(pos, "mobs:bee")
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
on_punch = function(pos, node, puncher)
|
||||
|
||||
-- yep, bee's don't like having their home punched by players
|
||||
puncher:set_hp(puncher:get_hp() - 4)
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
|
||||
if listname == "beehive" then
|
||||
return 0
|
||||
end
|
||||
|
||||
return stack:get_count()
|
||||
end,
|
||||
|
||||
can_dig = function(pos,player)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
-- only dig beehive if no honey inside
|
||||
return meta:get_inventory():is_empty("beehive")
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mobs:beehive",
|
||||
recipe = {
|
||||
{"mobs:bee","mobs:bee","mobs:bee"},
|
||||
}
|
||||
})
|
||||
|
||||
-- honey block
|
||||
minetest.register_node("mobs:honey_block", {
|
||||
description = "Honey Block",
|
||||
tiles = {"mobs_honey_block.png"},
|
||||
groups = {snappy = 3, flammable = 2},
|
||||
sounds = default.node_sound_dirt_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mobs:honey_block",
|
||||
recipe = {
|
||||
{"mobs:honey", "mobs:honey", "mobs:honey"},
|
||||
{"mobs:honey", "mobs:honey", "mobs:honey"},
|
||||
{"mobs:honey", "mobs:honey", "mobs:honey"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mobs:honey 9",
|
||||
recipe = {
|
||||
{"mobs:honey_block"},
|
||||
}
|
||||
})
|
||||
|
||||
-- beehive workings
|
||||
minetest.register_abm({
|
||||
nodenames = {"mobs:beehive"},
|
||||
interval = 6,
|
||||
chance = 5,
|
||||
catch_up = false,
|
||||
action = function(pos, node)
|
||||
|
||||
-- bee's only make honey during the day
|
||||
local tod = (minetest.get_timeofday() or 0) * 24000
|
||||
|
||||
if tod < 4500 or tod > 19500 then
|
||||
return
|
||||
end
|
||||
|
||||
-- find flowers in area around hive
|
||||
local flowers = minetest.find_nodes_in_area_under_air(
|
||||
{x = pos.x - 10, y = pos.y - 5, z = pos.z - 10},
|
||||
{x = pos.x + 10, y = pos.y + 5, z = pos.z + 10},
|
||||
"group:flower")
|
||||
|
||||
-- no flowers no honey, nuff said!
|
||||
if #flowers > 3 then
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
-- error check just incase it's an old beehive
|
||||
if meta then
|
||||
meta:get_inventory():add_item("beehive", "mobs:honey")
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
93
bunny.lua
Executable file
93
bunny.lua
Executable file
|
@ -0,0 +1,93 @@
|
|||
|
||||
-- Bunny by ExeterDad
|
||||
|
||||
mobs:register_mob("mobs:bunny", {
|
||||
-- animal, monster, npc
|
||||
type = "animal",
|
||||
-- is it aggressive
|
||||
passive = true,
|
||||
reach = 1,
|
||||
-- health & armor
|
||||
hp_min = 3,
|
||||
hp_max = 6,
|
||||
armor = 200,
|
||||
-- textures and model
|
||||
collisionbox = {-0.268, -0.5, -0.268, 0.268, 0.167, 0.268},
|
||||
visual = "mesh",
|
||||
mesh = "mobs_bunny.b3d",
|
||||
drawtype = "front",
|
||||
textures = {
|
||||
{"mobs_bunny_grey.png"},
|
||||
{"mobs_bunny_brown.png"},
|
||||
{"mobs_bunny_white.png"},
|
||||
},
|
||||
-- sounds
|
||||
sounds = {},
|
||||
makes_footstep_sound = false,
|
||||
-- speed and jump
|
||||
walk_velocity = 1,
|
||||
run_velocity = 2,
|
||||
runaway = true,
|
||||
jump = true,
|
||||
-- drops meat when dead
|
||||
drops = {
|
||||
{name = "mobs:meat_raw", chance = 1, min = 1, max = 2},
|
||||
},
|
||||
-- damaged by
|
||||
water_damage = 1,
|
||||
lava_damage = 4,
|
||||
light_damage = 0,
|
||||
fear_height = 2,
|
||||
-- model animation
|
||||
animation = {
|
||||
speed_normal = 15,
|
||||
stand_start = 1,
|
||||
stand_end = 15,
|
||||
walk_start = 16,
|
||||
walk_end = 24,
|
||||
punch_start = 16,
|
||||
punch_end = 24,
|
||||
},
|
||||
-- follows carrot from farming redo
|
||||
follow = {"farming:carrot", "farming_plus:carrot_item"},
|
||||
view_range = 8,
|
||||
-- eat carrots
|
||||
replace_rate = 10,
|
||||
replace_what = {"farming:carrot_7", "farming:carrot_8", "farming_plus:carrot"},
|
||||
replace_with = "air",
|
||||
-- right click to pick up rabbit
|
||||
on_rightclick = function(self, clicker)
|
||||
|
||||
-- feed or tame
|
||||
if mobs:feed_tame(self, clicker, 4, true, true) then
|
||||
return
|
||||
end
|
||||
|
||||
-- Monty Python tribute
|
||||
local item = clicker:get_wielded_item()
|
||||
|
||||
if item:get_name() == "mobs:lava_orb" then
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
item:take_item()
|
||||
clicker:set_wielded_item(item)
|
||||
end
|
||||
|
||||
self.object:set_properties({
|
||||
textures = {"mobs_bunny_evil.png"},
|
||||
})
|
||||
|
||||
self.type = "monster"
|
||||
self.object:set_hp(20)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
mobs:capture_mob(self, clicker, 30, 50, 80, false, nil)
|
||||
end,
|
||||
|
||||
attack_type = "dogfight",
|
||||
damage = 5,
|
||||
})
|
||||
mobs:spawn_specific("mobs:bunny", {"default:dirt_with_grass"}, {"air"}, 8, 20, 30, 15000, 2, -31000, 31000, true, true)
|
||||
mobs:register_egg("mobs:bunny", "Bunny", "mobs_bunny_inv.png", 1)
|
261
chicken.lua
Executable file
261
chicken.lua
Executable file
|
@ -0,0 +1,261 @@
|
|||
|
||||
-- Chicken by JK Murray
|
||||
|
||||
mobs:register_mob("mobs:chicken", {
|
||||
-- animal, monster, npc, barbarian
|
||||
type = "animal",
|
||||
-- is it aggressive
|
||||
passive = true,
|
||||
-- health & armor
|
||||
hp_min = 4,
|
||||
hp_max = 8,
|
||||
armor = 200,
|
||||
-- textures and model
|
||||
collisionbox = {-0.3, -0.75, -0.3, 0.3, 0.1, 0.3},
|
||||
visual = "mesh",
|
||||
mesh = "mobs_chicken.x",
|
||||
-- seems a lot of textures but this fixes the problem with the model
|
||||
textures = {
|
||||
{"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png",
|
||||
"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png"},
|
||||
{"mobs_chicken_black.png", "mobs_chicken_black.png", "mobs_chicken_black.png", "mobs_chicken_black.png",
|
||||
"mobs_chicken_black.png", "mobs_chicken_black.png", "mobs_chicken_black.png", "mobs_chicken_black.png", "mobs_chicken_black.png"},
|
||||
},
|
||||
child_texture = {
|
||||
{"mobs_chick.png", "mobs_chick.png", "mobs_chick.png", "mobs_chick.png",
|
||||
"mobs_chick.png", "mobs_chick.png", "mobs_chick.png", "mobs_chick.png", "mobs_chick.png"},
|
||||
},
|
||||
blood_texture = "mobs_blood.png",
|
||||
-- sounds
|
||||
makes_footstep_sound = true,
|
||||
sounds = {
|
||||
random = "mobs_chicken",
|
||||
},
|
||||
-- speed and jump
|
||||
walk_velocity = 1,
|
||||
run_velocity = 2,
|
||||
runaway = true,
|
||||
jump = true,
|
||||
-- drops raw chicken when dead
|
||||
drops = {
|
||||
{name = "mobs:chicken_raw", chance = 1, min = 2, max = 2},
|
||||
},
|
||||
-- damaged by
|
||||
water_damage = 1,
|
||||
lava_damage = 5,
|
||||
light_damage = 0,
|
||||
fall_damage = 0,
|
||||
fall_speed = -8,
|
||||
fear_height = 5,
|
||||
-- model animation
|
||||
animation = {
|
||||
speed_normal = 15,
|
||||
stand_start = 0,
|
||||
stand_end = 1, -- 20
|
||||
walk_start = 20,
|
||||
walk_end = 40,
|
||||
},
|
||||
-- follows wheat
|
||||
follow = {"farming:seed_wheat", "farming:seed_cotton"},
|
||||
view_range = 5,
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
|
||||
if mobs:feed_tame(self, clicker, 8, true, true) then
|
||||
return
|
||||
end
|
||||
|
||||
mobs:capture_mob(self, clicker, 30, 50, 80, false, nil)
|
||||
end,
|
||||
|
||||
do_custom = function(self)
|
||||
|
||||
if not self.child
|
||||
and math.random(1, 500) == 1 then
|
||||
|
||||
local pos = self.object:getpos()
|
||||
|
||||
minetest.add_item(pos, "mobs:egg")
|
||||
|
||||
minetest.sound_play("default_place_node_hard", {
|
||||
pos = pos,
|
||||
gain = 1.0,
|
||||
max_hear_distance = 5,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
-- spawn on default or bamboo grass between 8 and 20 light, 1 in 15000 change, 1 chicken in area up to 31000 in height
|
||||
mobs:spawn_specific("mobs:chicken", {"default:dirt_with_grass"}, {"air"}, 8, 20, 30, 15000, 2, -31000, 31000, true, true)
|
||||
-- register spawn egg
|
||||
mobs:register_egg("mobs:chicken", "Chicken", "mobs_chicken_inv.png", 1)
|
||||
-- egg entity
|
||||
|
||||
mobs:register_arrow("mobs:egg_entity", {
|
||||
visual = "sprite",
|
||||
visual_size = {x=.5, y=.5},
|
||||
textures = {"mobs_chicken_egg.png"},
|
||||
velocity = 6,
|
||||
|
||||
hit_player = function(self, player)
|
||||
player:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = 1},
|
||||
}, nil)
|
||||
end,
|
||||
|
||||
hit_mob = function(self, player)
|
||||
player:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = 1},
|
||||
}, nil)
|
||||
end,
|
||||
|
||||
hit_node = function(self, pos, node)
|
||||
|
||||
local num = math.random(1, 10)
|
||||
|
||||
if num == 1 then
|
||||
|
||||
pos.y = pos.y + 1
|
||||
|
||||
local nod = minetest.get_node_or_nil(pos)
|
||||
|
||||
if not nod
|
||||
or not minetest.registered_nodes[nod.name]
|
||||
or minetest.registered_nodes[nod.name].walkable == true then
|
||||
return
|
||||
end
|
||||
|
||||
local mob = minetest.add_entity(pos, "mobs:chicken")
|
||||
local ent2 = mob:get_luaentity()
|
||||
|
||||
mob:set_properties({
|
||||
textures = ent2.child_texture[1],
|
||||
visual_size = {
|
||||
x = ent2.base_size.x / 2,
|
||||
y = ent2.base_size.y / 2
|
||||
},
|
||||
collisionbox = {
|
||||
ent2.base_colbox[1] / 2,
|
||||
ent2.base_colbox[2] / 2,
|
||||
ent2.base_colbox[3] / 2,
|
||||
ent2.base_colbox[4] / 2,
|
||||
ent2.base_colbox[5] / 2,
|
||||
ent2.base_colbox[6] / 2
|
||||
},
|
||||
})
|
||||
|
||||
ent2.child = true
|
||||
ent2.tamed = true
|
||||
ent2.owner = self.playername
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- egg throwing item
|
||||
|
||||
local egg_GRAVITY = 9
|
||||
local egg_VELOCITY = 19
|
||||
|
||||
-- shoot egg
|
||||
local mobs_shoot_egg = function (item, player, pointed_thing)
|
||||
|
||||
local playerpos = player:getpos()
|
||||
|
||||
minetest.sound_play("default_place_node_hard", {
|
||||
pos = playerpos,
|
||||
gain = 1.0,
|
||||
max_hear_distance = 5,
|
||||
})
|
||||
|
||||
local obj = minetest.add_entity({
|
||||
x = playerpos.x,
|
||||
y = playerpos.y +1.5,
|
||||
z = playerpos.z
|
||||
}, "mobs:egg_entity")
|
||||
|
||||
local ent = obj:get_luaentity()
|
||||
local dir = player:get_look_dir()
|
||||
|
||||
ent.velocity = egg_VELOCITY -- needed for api internal timing
|
||||
ent.switch = 1 -- needed so that egg doesn't despawn straight away
|
||||
|
||||
obj:setvelocity({
|
||||
x = dir.x * egg_VELOCITY,
|
||||
y = dir.y * egg_VELOCITY,
|
||||
z = dir.z * egg_VELOCITY
|
||||
})
|
||||
|
||||
obj:setacceleration({
|
||||
x = dir.x * -3,
|
||||
y = -egg_GRAVITY,
|
||||
z = dir.z * -3
|
||||
})
|
||||
|
||||
-- pass player name to egg for chick ownership
|
||||
local ent2 = obj:get_luaentity()
|
||||
ent2.playername = player:get_player_name()
|
||||
|
||||
item:take_item()
|
||||
|
||||
return item
|
||||
end
|
||||
|
||||
-- egg
|
||||
minetest.register_node("mobs:egg", {
|
||||
description = "Chicken Egg",
|
||||
tiles = {"mobs_chicken_egg.png"},
|
||||
inventory_image = "mobs_chicken_egg.png",
|
||||
visual_scale = 0.7,
|
||||
drawtype = "plantlike",
|
||||
wield_image = "mobs_chicken_egg.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
is_ground_content = true,
|
||||
sunlight_propagates = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
|
||||
},
|
||||
groups = {snappy = 2, dig_immediate = 3},
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
if placer:is_player() then
|
||||
minetest.set_node(pos, {name = "mobs:egg", param2 = 1})
|
||||
end
|
||||
end,
|
||||
on_use = mobs_shoot_egg
|
||||
})
|
||||
|
||||
-- fried egg
|
||||
minetest.register_craftitem("mobs:chicken_egg_fried", {
|
||||
description = "Fried Egg",
|
||||
inventory_image = "mobs_chicken_egg_fried.png",
|
||||
on_use = minetest.item_eat(2),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
recipe = "mobs:egg",
|
||||
output = "mobs:chicken_egg_fried",
|
||||
})
|
||||
|
||||
-- raw chicken
|
||||
minetest.register_craftitem("mobs:chicken_raw", {
|
||||
description = "Raw Chicken",
|
||||
inventory_image = "mobs_chicken_raw.png",
|
||||
on_use = minetest.item_eat(2),
|
||||
})
|
||||
|
||||
-- cooked chicken
|
||||
minetest.register_craftitem("mobs:chicken_cooked", {
|
||||
description = "Cooked Chicken",
|
||||
inventory_image = "mobs_chicken_cooked.png",
|
||||
on_use = minetest.item_eat(4), -- Modif MFF
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
recipe = "mobs:chicken_raw",
|
||||
output = "mobs:chicken_cooked",
|
||||
})
|
193
cow.lua
Executable file
193
cow.lua
Executable file
|
@ -0,0 +1,193 @@
|
|||
|
||||
-- Cow by Krupnovpavel
|
||||
|
||||
mobs:register_mob("mobs:cow", {
|
||||
-- animal, monster, npc, barbarian
|
||||
type = "animal",
|
||||
-- aggressive, does 5 damage to player when threatened
|
||||
passive = false,
|
||||
group_attack = true,
|
||||
attack_type = "dogfight",
|
||||
reach = 2,
|
||||
damage = 4,
|
||||
-- health & armor
|
||||
hp_min = 15,
|
||||
hp_max = 20,
|
||||
armor = 200,
|
||||
-- textures and model
|
||||
collisionbox = {-0.8, 0, -0.8, 0.8, 1.6, 0.8}, --Modif MFF (debug)
|
||||
visual = "mesh",
|
||||
mesh = "mobs_cow.b3d",
|
||||
textures = {
|
||||
{"mobs_cow_lightbrown.png"},
|
||||
{"mobs_cow_brown.png"},
|
||||
{"mobs_cow_white.png"},
|
||||
},
|
||||
blood_texture = "mobs_blood.png",
|
||||
-- sounds
|
||||
makes_footstep_sound = true,
|
||||
sounds = {
|
||||
random = "mobs_cow",
|
||||
},
|
||||
-- speed and jump
|
||||
walk_velocity = 1,
|
||||
run_velocity = 2,
|
||||
jump = true,
|
||||
-- drops raw meat when dead
|
||||
drops = {
|
||||
{name = "mobs:meat_raw", chance = 1, min = 5, max = 10},
|
||||
{name = "mobs:leather", chance = 1, min = 0, max = 3},
|
||||
{name = "maptools:silver_coin", chance = 10, min = 1, max = 1,},
|
||||
},
|
||||
-- damaged by
|
||||
water_damage = 1,
|
||||
lava_damage = 5,
|
||||
light_damage = 0,
|
||||
-- model animation
|
||||
animation = {
|
||||
speed_normal = 15,
|
||||
speed_run = 15,
|
||||
stand_start = 0,
|
||||
stand_end = 30,
|
||||
walk_start = 35,
|
||||
walk_end = 65,
|
||||
run_start = 105,
|
||||
run_end = 135,
|
||||
punch_start = 70,
|
||||
punch_end = 100,
|
||||
},
|
||||
follow = "farming:wheat",
|
||||
view_range = 7,
|
||||
replace_rate = 100,
|
||||
replace_what = {"default:grass_3", "default:grass_4", "default:grass_5", "farming:wheat_8"},
|
||||
replace_with = "mobs:dung",
|
||||
fear_height = 2,
|
||||
on_rightclick = function(self, clicker)
|
||||
|
||||
-- feed or tame
|
||||
if mobs:feed_tame(self, clicker, 8, true, true) then
|
||||
return
|
||||
end
|
||||
|
||||
local tool = clicker:get_wielded_item()
|
||||
|
||||
-- milk cow with empty bucket
|
||||
if tool:get_name() == "bucket:bucket_empty" then
|
||||
|
||||
--if self.gotten == true
|
||||
if self.child == true then
|
||||
return
|
||||
end
|
||||
|
||||
if self.gotten == true then
|
||||
minetest.chat_send_player(clicker:get_player_name(),
|
||||
"Cow already milked!")
|
||||
return
|
||||
end
|
||||
|
||||
local inv = clicker:get_inventory()
|
||||
|
||||
inv:remove_item("main", "bucket:bucket_empty")
|
||||
|
||||
if inv:room_for_item("main", {name = "mobs:bucket_milk"}) then
|
||||
clicker:get_inventory():add_item("main", "mobs:bucket_milk")
|
||||
else
|
||||
local pos = self.object:getpos()
|
||||
pos.y = pos.y + 0.5
|
||||
minetest.add_item(pos, {name = "mobs:bucket_milk"})
|
||||
end
|
||||
|
||||
self.gotten = true -- milked
|
||||
|
||||
return
|
||||
end
|
||||