disable mobs and slime, update bags
@ -1,25 +1,34 @@
|
||||
local old_nodes = {"flowers:flower_seaweed"}
|
||||
local old_entities = {}
|
||||
|
||||
for _,node_name in ipairs(old_nodes) do
|
||||
minetest.register_node(":"..node_name, {
|
||||
groups = {old=1},
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:old"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
minetest.env:remove_node(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
for _,entity_name in ipairs(old_entities) do
|
||||
minetest.register_entity(":"..entity_name, {
|
||||
on_activate = function(self, staticdata)
|
||||
self.object:remove()
|
||||
end,
|
||||
})
|
||||
local old_nodes = {"flowers:flower_seaweed"}
|
||||
local old_entities = {
|
||||
"mobs:dirt_monster",
|
||||
"mobs:stone_monster",
|
||||
"mobs:sand_monster",
|
||||
"mobs:sheep",
|
||||
"mobs:meat_raw",
|
||||
"mobs:meat_rat",
|
||||
"mobs:oerkki",
|
||||
"slimes:small",
|
||||
}
|
||||
|
||||
for _,node_name in ipairs(old_nodes) do
|
||||
minetest.register_node(":"..node_name, {
|
||||
groups = {old=1},
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:old"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
minetest.env:remove_node(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
for _,entity_name in ipairs(old_entities) do
|
||||
minetest.register_entity(":"..entity_name, {
|
||||
on_activate = function(self, staticdata)
|
||||
self.object:remove()
|
||||
end,
|
||||
})
|
||||
end
|
0
mods/_disabled/init.lua
Normal file
@ -1,98 +1,98 @@
|
||||
=== MOBS-MOD for MINETEST-C55 ===
|
||||
by PilzAdam
|
||||
|
||||
Inroduction:
|
||||
This mod adds some basic hostile and friendly mobs to the game.
|
||||
|
||||
How to install:
|
||||
Unzip the archive an place it in minetest-base-directory/mods/minetest/
|
||||
if you have a windows client or a linux run-in-place client. If you have
|
||||
a linux system-wide instalation place it in ~/.minetest/mods/minetest/.
|
||||
If you want to install this mod only in one world create the folder
|
||||
worldmods/ in your worlddirectory.
|
||||
For further information or help see:
|
||||
http://wiki.minetest.com/wiki/Installing_Mods
|
||||
|
||||
How to use the mod:
|
||||
There are 4 hostile mobs that want to kill the player:
|
||||
- The dirt monster spawns at night on grass and get killed on day when
|
||||
its too light.
|
||||
- The stone monster spawns on stone and is stronger but slower than the
|
||||
dirt monster
|
||||
- The desert monster spawns in deserts and is faster but less strong
|
||||
than the dirt monster
|
||||
- The oerkki is the same as in 0.3. It spawns in realy dark caves and
|
||||
is stronger than the dirt monster.
|
||||
There are also 2 friendly mobs:
|
||||
- The sheep spawns on grass. You can get wool from it when you rightclick
|
||||
it and meat if you kill it. Meat can bee cooked in the furnace to eat it.
|
||||
- The rat is the same as in 0.3. You can cook it or replace it in the
|
||||
world if you catched it with an rightclick.
|
||||
|
||||
For developers:
|
||||
This mod add some functions that you can use in other mods:
|
||||
1. mobs:register_monster(name, def)
|
||||
This adds a monster to Minetest that will attack the player
|
||||
"name" is the name of the monster ("[modname]:[monstername]")
|
||||
"def" is a table with the following values:
|
||||
hp_max: same is in minetest.register_entity()
|
||||
physical: same is in minetest.register_entity()
|
||||
collisionbox: same is in minetest.register_entity()
|
||||
visual: same is in minetest.register_entity()
|
||||
visual_size: same is in minetest.register_entity()
|
||||
textures: same is in minetest.register_entity()
|
||||
makes_footstep_sound: same is in minetest.register_entity()
|
||||
view_range: the range in that the monster will see the player
|
||||
and follow him
|
||||
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
|
||||
light_resistant: light wont cause damage on day
|
||||
drop: the drop item of the monster
|
||||
drop_count: the number of items that are dropped
|
||||
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
|
||||
lava_damage: the damage per second if the mob is in lava
|
||||
2. mobs:register_animal(name, def)
|
||||
This adds a animal to Minetest that will just walk arround
|
||||
"name" is the name of the monster ("[modname]:[animalname]")
|
||||
"def" is the same table as in register_monster but without these values:
|
||||
-view_range
|
||||
-run_velocity
|
||||
-damage
|
||||
-light_resistant
|
||||
-armor
|
||||
and it also has the field
|
||||
-on_rightclick: its same as in minetest.register_entity()
|
||||
3. mobs:register_spawn(name, nodes, max_light, min_light, chance, mobs_per_30_block_radius)
|
||||
This function adds the spawning of an animal (without it the
|
||||
registered animals and monster won't spawn!)
|
||||
"name" is the name of the animal/monster
|
||||
"nodes" is a list of nodenames on that the animal/monster can spawn
|
||||
"max_light" is the maximum of light
|
||||
"min_light" is the minimum of light
|
||||
"chance" is same as in register_abm()
|
||||
"mobs_per_30_block_radius" is the maximum number of mobs in a 30 block
|
||||
radius arround the possible spawning pos
|
||||
|
||||
License:
|
||||
Sourcecode: WTFPL (see below)
|
||||
Grahpics: WTFPL (see below)
|
||||
|
||||
See also:
|
||||
http://minetest.net/
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
=== MOBS-MOD for MINETEST-C55 ===
|
||||
by PilzAdam
|
||||
|
||||
Inroduction:
|
||||
This mod adds some basic hostile and friendly mobs to the game.
|
||||
|
||||
How to install:
|
||||
Unzip the archive an place it in minetest-base-directory/mods/minetest/
|
||||
if you have a windows client or a linux run-in-place client. If you have
|
||||
a linux system-wide instalation place it in ~/.minetest/mods/minetest/.
|
||||
If you want to install this mod only in one world create the folder
|
||||
worldmods/ in your worlddirectory.
|
||||
For further information or help see:
|
||||
http://wiki.minetest.com/wiki/Installing_Mods
|
||||
|
||||
How to use the mod:
|
||||
There are 4 hostile mobs that want to kill the player:
|
||||
- The dirt monster spawns at night on grass and get killed on day when
|
||||
its too light.
|
||||
- The stone monster spawns on stone and is stronger but slower than the
|
||||
dirt monster
|
||||
- The desert monster spawns in deserts and is faster but less strong
|
||||
than the dirt monster
|
||||
- The oerkki is the same as in 0.3. It spawns in realy dark caves and
|
||||
is stronger than the dirt monster.
|
||||
There are also 2 friendly mobs:
|
||||
- The sheep spawns on grass. You can get wool from it when you rightclick
|
||||
it and meat if you kill it. Meat can bee cooked in the furnace to eat it.
|
||||
- The rat is the same as in 0.3. You can cook it or replace it in the
|
||||
world if you catched it with an rightclick.
|
||||
|
||||
For developers:
|
||||
This mod add some functions that you can use in other mods:
|
||||
1. mobs:register_monster(name, def)
|
||||
This adds a monster to Minetest that will attack the player
|
||||
"name" is the name of the monster ("[modname]:[monstername]")
|
||||
"def" is a table with the following values:
|
||||
hp_max: same is in minetest.register_entity()
|
||||
physical: same is in minetest.register_entity()
|
||||
collisionbox: same is in minetest.register_entity()
|
||||
visual: same is in minetest.register_entity()
|
||||
visual_size: same is in minetest.register_entity()
|
||||
textures: same is in minetest.register_entity()
|
||||
makes_footstep_sound: same is in minetest.register_entity()
|
||||
view_range: the range in that the monster will see the player
|
||||
and follow him
|
||||
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
|
||||
light_resistant: light wont cause damage on day
|
||||
drop: the drop item of the monster
|
||||
drop_count: the number of items that are dropped
|
||||
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
|
||||
lava_damage: the damage per second if the mob is in lava
|
||||
2. mobs:register_animal(name, def)
|
||||
This adds a animal to Minetest that will just walk arround
|
||||
"name" is the name of the monster ("[modname]:[animalname]")
|
||||
"def" is the same table as in register_monster but without these values:
|
||||
-view_range
|
||||
-run_velocity
|
||||
-damage
|
||||
-light_resistant
|
||||
-armor
|
||||
and it also has the field
|
||||
-on_rightclick: its same as in minetest.register_entity()
|
||||
3. mobs:register_spawn(name, nodes, max_light, min_light, chance, mobs_per_30_block_radius)
|
||||
This function adds the spawning of an animal (without it the
|
||||
registered animals and monster won't spawn!)
|
||||
"name" is the name of the animal/monster
|
||||
"nodes" is a list of nodenames on that the animal/monster can spawn
|
||||
"max_light" is the maximum of light
|
||||
"min_light" is the minimum of light
|
||||
"chance" is same as in register_abm()
|
||||
"mobs_per_30_block_radius" is the maximum number of mobs in a 30 block
|
||||
radius arround the possible spawning pos
|
||||
|
||||
License:
|
||||
Sourcecode: WTFPL (see below)
|
||||
Grahpics: WTFPL (see below)
|
||||
|
||||
See also:
|
||||
http://minetest.net/
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
@ -1,457 +1,457 @@
|
||||
mobs = {}
|
||||
function mobs:register_monster(name, def)
|
||||
minetest.register_entity(name, {
|
||||
hp_max = def.hp_max,
|
||||
physical = true,
|
||||
collisionbox = def.collisionbox,
|
||||
visual = def.visual,
|
||||
visual_size = def.visual_size,
|
||||
textures = def.textures,
|
||||
makes_footstep_sound = def.makes_footstep_sound,
|
||||
view_range = def.view_range,
|
||||
walk_velocity = def.walk_velocity,
|
||||
run_velocity = def.run_velocity,
|
||||
damage = def.damage,
|
||||
light_resistant = def.light_resistant,
|
||||
water_damage = def.water_damage,
|
||||
lava_damage = def.lava_damage,
|
||||
drop = def.drop,
|
||||
drop_count = def.drop_count,
|
||||
armor = def.armor,
|
||||
drawtype = def.drawtype,
|
||||
|
||||
timer = 0,
|
||||
attack = {player=nil, dist=nil},
|
||||
state = "stand",
|
||||
v_start = false,
|
||||
old_y = nil,
|
||||
|
||||
|
||||
set_velocity = function(self, v)
|
||||
local yaw = self.object:getyaw()
|
||||
if self.drawtype == "side" then
|
||||
yaw = yaw+(math.pi/2)
|
||||
end
|
||||
local x = math.sin(yaw) * -v
|
||||
local z = math.cos(yaw) * v
|
||||
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
||||
end,
|
||||
|
||||
get_velocity = function(self)
|
||||
local v = self.object:getvelocity()
|
||||
return (v.x^2 + v.z^2)^(0.5)
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
if self.object:getvelocity().y > 0.1 then
|
||||
local yaw = self.object:getyaw()
|
||||
if self.drawtype == "side" then
|
||||
yaw = yaw+(math.pi/2)
|
||||
end
|
||||
local x = math.sin(yaw) * -2
|
||||
local z = math.cos(yaw) * 2
|
||||
self.object:setacceleration({x=x, y=-10, z=z})
|
||||
else
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
end
|
||||
|
||||
if self.object:getvelocity().y == 0 then
|
||||
if not self.old_y then
|
||||
self.old_y = self.object:getpos().y
|
||||
else
|
||||
local d = self.old_y - self.object:getpos().y
|
||||
if d > 5 then
|
||||
local damage = d-5
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[self.armor]=1/damage}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
self.old_y = self.object:getpos().y
|
||||
end
|
||||
end
|
||||
|
||||
self.timer = self.timer+dtime
|
||||
if self.state ~= "attack" then
|
||||
if self.timer < 1 then
|
||||
return
|
||||
end
|
||||
self.timer = 0
|
||||
end
|
||||
|
||||
local do_env_damage = function(self)
|
||||
if not self.light_resistant and minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8 and minetest.env:get_node_light(self.object:getpos()) > 3 then
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[self.armor]=1/1}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
|
||||
if self.water_damage and self.water_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:water") then
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[self.armor]=1/self.water_damage}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
|
||||
if self.lava_damage and self.lava_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:lava") then
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[self.armor]=1/self.lava_damage}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
end
|
||||
|
||||
if self.state == "attack" and self.timer > 1 then
|
||||
do_env_damage(self)
|
||||
elseif self.state ~= "attack" then
|
||||
do_env_damage(self)
|
||||
end
|
||||
|
||||
for _,player in pairs(minetest.get_connected_players()) do
|
||||
local s = self.object:getpos()
|
||||
local p = player:getpos()
|
||||
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
||||
if dist < self.view_range then
|
||||
if self.attack.dist then
|
||||
if self.attack.dist < dist then
|
||||
self.state = "attack"
|
||||
self.attack.player = player
|
||||
self.attack.dist = dist
|
||||
end
|
||||
else
|
||||
self.state = "attack"
|
||||
self.attack.player = player
|
||||
self.attack.dist = dist
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.state == "stand" then
|
||||
if math.random(1, 2) == 1 then
|
||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
||||
end
|
||||
if math.random(1, 100) <= 50 then
|
||||
self.set_velocity(self, self.walk_velocity)
|
||||
self.state = "walk"
|
||||
end
|
||||
elseif self.state == "walk" then
|
||||
if math.random(1, 100) <= 30 then
|
||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
||||
self.set_velocity(self, self.get_velocity(self))
|
||||
end
|
||||
if math.random(1, 100) <= 10 then
|
||||
self.set_velocity(self, 0)
|
||||
self.state = "stand"
|
||||
end
|
||||
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
||||
local v = self.object:getvelocity()
|
||||
v.y = 5
|
||||
self.object:setvelocity(v)
|
||||
end
|
||||
elseif self.state == "attack" then
|
||||
local s = self.object:getpos()
|
||||
local p = self.attack.player:getpos()
|
||||
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
||||
if dist > self.view_range or self.attack.player:get_hp() <= 0 then
|
||||
self.state = "stand"
|
||||
self.v_start = false
|
||||
self.set_velocity(self, 0)
|
||||
self.attack = {player=nil, dist=nil}
|
||||
return
|
||||
else
|
||||
self.attack.dist = dist
|
||||
end
|
||||
|
||||
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
|
||||
local yaw = math.atan(vec.z/vec.x)+math.pi/2
|
||||
if self.drawtype == "side" then
|
||||
yaw = yaw+(math.pi/2)
|
||||
end
|
||||
if p.x > s.x then
|
||||
yaw = yaw+math.pi
|
||||
end
|
||||
self.object:setyaw(yaw)
|
||||
if self.attack.dist > 2 then
|
||||
if not self.v_start then
|
||||
self.v_start = true
|
||||
self.set_velocity(self, self.run_velocity)
|
||||
else
|
||||
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
||||
local v = self.object:getvelocity()
|
||||
v.y = 5
|
||||
self.object:setvelocity(v)
|
||||
end
|
||||
self.set_velocity(self, self.run_velocity)
|
||||
end
|
||||
else
|
||||
self.set_velocity(self, 0)
|
||||
self.v_start = false
|
||||
if self.timer > 1 then
|
||||
self.timer = 0
|
||||
local d1 = 10
|
||||
local d2 = 10
|
||||
local d3 = 10
|
||||
if self.damage > 0 then
|
||||
d3 = 1/self.damage
|
||||
end
|
||||
if self.damage > 1 then
|
||||
d2 = 1/(self.damage-1)
|
||||
end
|
||||
if self.damage > 2 then
|
||||
d1 = 1/(self.damage-2)
|
||||
end
|
||||
self.attack.player:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[1]=d1, [2]=d2, [3]=d3}},
|
||||
}
|
||||
}, vec)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
self.object:set_armor_groups({fleshy=self.armor})
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self.state = "stand"
|
||||
self.object:setvelocity({x=0, y=self.object:getvelocity().y, z=0})
|
||||
self.object:setyaw(math.random(1, 360)/180*math.pi)
|
||||
end,
|
||||
|
||||
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))
|
||||
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)
|
||||
if obj then
|
||||
obj:get_luaentity().collect = true
|
||||
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
|
||||
end
|
||||
end,
|
||||
|
||||
})
|
||||
end
|
||||
|
||||
function mobs:register_animal(name, def)
|
||||
minetest.register_entity(name, {
|
||||
hp_max = def.hp_max,
|
||||
physical = true,
|
||||
collisionbox = def.collisionbox,
|
||||
visual = def.visual,
|
||||
visual_size = def.visual_size,
|
||||
textures = def.textures,
|
||||
makes_footstep_sound = def.makes_footstep_sound,
|
||||
walk_velocity = def.walk_velocity,
|
||||
drop = def.drop,
|
||||
on_rightclick = def.on_rightclick,
|
||||
drop_count = def.drop_count,
|
||||
drawtype = def.drawtype,
|
||||
water_damage = def.water_damage,
|
||||
lava_damage = def.lava_damage,
|
||||
|
||||
timer = 0,
|
||||
state = "stand",
|
||||
old_y = nil,
|
||||
|
||||
|
||||
set_velocity = function(self, v)
|
||||
local yaw = self.object:getyaw()
|
||||
if self.drawtype == "side" then
|
||||
yaw = yaw+(math.pi/2)
|
||||
end
|
||||
local x = math.sin(yaw) * -v
|
||||
local z = math.cos(yaw) * v
|
||||
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
||||
end,
|
||||
|
||||
get_velocity = function(self)
|
||||
local v = self.object:getvelocity()
|
||||
return (v.x^2 + v.z^2)^(0.5)
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
if self.object:getvelocity().y > 0.1 then
|
||||
local yaw = self.object:getyaw()
|
||||
if self.drawtype == "side" then
|
||||
yaw = yaw+(math.pi/2)
|
||||
end
|
||||
local x = math.sin(yaw) * -2
|
||||
local z = math.cos(yaw) * 2
|
||||
self.object:setacceleration({x=x, y=-10, z=z})
|
||||
else
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
end
|
||||
|
||||
if self.object:getvelocity().y == 0 then
|
||||
if not self.old_y then
|
||||
self.old_y = self.object:getpos().y
|
||||
else
|
||||
local d = self.old_y - self.object:getpos().y
|
||||
if d > 5 then
|
||||
local damage = d-5
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[3]=1/damage}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
self.old_y = self.object:getpos().y
|
||||
end
|
||||
end
|
||||
|
||||
self.timer = self.timer+dtime
|
||||
if self.timer < 1 then
|
||||
return
|
||||
end
|
||||
self.timer = 0
|
||||
|
||||
if self.water_damage and self.water_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:water") then
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[3]=1/self.water_damage}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
|
||||
if self.lava_damage and self.lava_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:lava") then
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[3]=1/self.lava_damage}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
|
||||
if self.state == "stand" then
|
||||
if math.random(1, 2) == 1 then
|
||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
||||
end
|
||||
if math.random(1, 100) <= 50 then
|
||||
self.set_velocity(self, self.walk_velocity)
|
||||
self.state = "walk"
|
||||
end
|
||||
elseif self.state == "walk" then
|
||||
if math.random(1, 100) <= 30 then
|
||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
||||
self.set_velocity(self, self.get_velocity(self))
|
||||
end
|
||||
if math.random(1, 100) <= 10 then
|
||||
self.set_velocity(self, 0)
|
||||
self.state = "stand"
|
||||
end
|
||||
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
||||
local v = self.object:getvelocity()
|
||||
v.y = 5
|
||||
self.object:setvelocity(v)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
self.object:set_armor_groups({fleshy=3})
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self.state = "stand"
|
||||
self.object:setvelocity({x=0, y=self.object:getvelocity().y, z=0})
|
||||
self.object:setyaw(math.random(1, 360)/180*math.pi)
|
||||
end,
|
||||
|
||||
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))
|
||||
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)
|
||||
if obj then
|
||||
obj:get_luaentity().collect = true
|
||||
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
|
||||
end
|
||||
end,
|
||||
|
||||
})
|
||||
end
|
||||
|
||||
function mobs:register_spawn(name, nodes, max_light, min_light, chance, mobs_per_30_block_radius)
|
||||
minetest.register_abm({
|
||||
nodenames = nodes,
|
||||
neighbors = nodes,
|
||||
interval = 30,
|
||||
chance = chance,
|
||||
action = function(pos, node)
|
||||
pos.y = pos.y+1
|
||||
if not minetest.env:get_node_light(pos) then
|
||||
return
|
||||
end
|
||||
if minetest.env:get_node_light(pos) > max_light then
|
||||
return
|
||||
end
|
||||
if minetest.env:get_node_light(pos) < min_light then
|
||||
return
|
||||
end
|
||||
if minetest.env:get_node(pos).name ~= "air" then
|
||||
return
|
||||
end
|
||||
pos.y = pos.y+1
|
||||
if minetest.env:get_node(pos).name ~= "air" then
|
||||
return
|
||||
end
|
||||
|
||||
local count = 0
|
||||
for _,obj in pairs(minetest.env:get_objects_inside_radius(pos, 30)) do
|
||||
if obj:is_player() then
|
||||
return
|
||||
elseif obj:get_luaentity().name == name then
|
||||
count = count+1
|
||||
end
|
||||
end
|
||||
if count > mobs_per_30_block_radius then
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.setting_getbool("display_mob_spawn") then
|
||||
minetest.chat_send_all("[mobs] Add "..name.." at "..minetest.pos_to_string(pos))
|
||||
end
|
||||
minetest.env:add_entity(pos, name)
|
||||
end
|
||||
})
|
||||
end
|
||||
mobs = {}
|
||||
function mobs:register_monster(name, def)
|
||||
minetest.register_entity(name, {
|
||||
hp_max = def.hp_max,
|
||||
physical = true,
|
||||
collisionbox = def.collisionbox,
|
||||
visual = def.visual,
|
||||
visual_size = def.visual_size,
|
||||
textures = def.textures,
|
||||
makes_footstep_sound = def.makes_footstep_sound,
|
||||
view_range = def.view_range,
|
||||
walk_velocity = def.walk_velocity,
|
||||
run_velocity = def.run_velocity,
|
||||
damage = def.damage,
|
||||
light_resistant = def.light_resistant,
|
||||
water_damage = def.water_damage,
|
||||
lava_damage = def.lava_damage,
|
||||
drop = def.drop,
|
||||
drop_count = def.drop_count,
|
||||
armor = def.armor,
|
||||
drawtype = def.drawtype,
|
||||
|
||||
timer = 0,
|
||||
attack = {player=nil, dist=nil},
|
||||
state = "stand",
|
||||
v_start = false,
|
||||
old_y = nil,
|
||||
|
||||
|
||||
set_velocity = function(self, v)
|
||||
local yaw = self.object:getyaw()
|
||||
if self.drawtype == "side" then
|
||||
yaw = yaw+(math.pi/2)
|
||||
end
|
||||
local x = math.sin(yaw) * -v
|
||||
local z = math.cos(yaw) * v
|
||||
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
||||
end,
|
||||
|
||||
get_velocity = function(self)
|
||||
local v = self.object:getvelocity()
|
||||
return (v.x^2 + v.z^2)^(0.5)
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
if self.object:getvelocity().y > 0.1 then
|
||||
local yaw = self.object:getyaw()
|
||||
if self.drawtype == "side" then
|
||||
yaw = yaw+(math.pi/2)
|
||||
end
|
||||
local x = math.sin(yaw) * -2
|
||||
local z = math.cos(yaw) * 2
|
||||
self.object:setacceleration({x=x, y=-10, z=z})
|
||||
else
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
end
|
||||
|
||||
if self.object:getvelocity().y == 0 then
|
||||
if not self.old_y then
|
||||
self.old_y = self.object:getpos().y
|
||||
else
|
||||
local d = self.old_y - self.object:getpos().y
|
||||
if d > 5 then
|
||||
local damage = d-5
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[self.armor]=1/damage}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
self.old_y = self.object:getpos().y
|
||||
end
|
||||
end
|
||||
|
||||
self.timer = self.timer+dtime
|
||||
if self.state ~= "attack" then
|
||||
if self.timer < 1 then
|
||||
return
|
||||
end
|
||||
self.timer = 0
|
||||
end
|
||||
|
||||
local do_env_damage = function(self)
|
||||
if not self.light_resistant and minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8 and minetest.env:get_node_light(self.object:getpos()) > 3 then
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[self.armor]=1/1}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
|
||||
if self.water_damage and self.water_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:water") then
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[self.armor]=1/self.water_damage}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
|
||||
if self.lava_damage and self.lava_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:lava") then
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[self.armor]=1/self.lava_damage}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
end
|
||||
|
||||
if self.state == "attack" and self.timer > 1 then
|
||||
do_env_damage(self)
|
||||
elseif self.state ~= "attack" then
|
||||
do_env_damage(self)
|
||||
end
|
||||
|
||||
for _,player in pairs(minetest.get_connected_players()) do
|
||||
local s = self.object:getpos()
|
||||
local p = player:getpos()
|
||||
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
||||
if dist < self.view_range then
|
||||
if self.attack.dist then
|
||||
if self.attack.dist < dist then
|
||||
self.state = "attack"
|
||||
self.attack.player = player
|
||||
self.attack.dist = dist
|
||||
end
|
||||
else
|
||||
self.state = "attack"
|
||||
self.attack.player = player
|
||||
self.attack.dist = dist
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.state == "stand" then
|
||||
if math.random(1, 2) == 1 then
|
||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
||||
end
|
||||
if math.random(1, 100) <= 50 then
|
||||
self.set_velocity(self, self.walk_velocity)
|
||||
self.state = "walk"
|
||||
end
|
||||
elseif self.state == "walk" then
|
||||
if math.random(1, 100) <= 30 then
|
||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
||||
self.set_velocity(self, self.get_velocity(self))
|
||||
end
|
||||
if math.random(1, 100) <= 10 then
|
||||
self.set_velocity(self, 0)
|
||||
self.state = "stand"
|
||||
end
|
||||
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
||||
local v = self.object:getvelocity()
|
||||
v.y = 5
|
||||
self.object:setvelocity(v)
|
||||
end
|
||||
elseif self.state == "attack" then
|
||||
local s = self.object:getpos()
|
||||
local p = self.attack.player:getpos()
|
||||
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
||||
if dist > self.view_range or self.attack.player:get_hp() <= 0 then
|
||||
self.state = "stand"
|
||||
self.v_start = false
|
||||
self.set_velocity(self, 0)
|
||||
self.attack = {player=nil, dist=nil}
|
||||
return
|
||||
else
|
||||
self.attack.dist = dist
|
||||
end
|
||||
|
||||
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
|
||||
local yaw = math.atan(vec.z/vec.x)+math.pi/2
|
||||
if self.drawtype == "side" then
|
||||
yaw = yaw+(math.pi/2)
|
||||
end
|
||||
if p.x > s.x then
|
||||
yaw = yaw+math.pi
|
||||
end
|
||||
self.object:setyaw(yaw)
|
||||
if self.attack.dist > 2 then
|
||||
if not self.v_start then
|
||||
self.v_start = true
|
||||
self.set_velocity(self, self.run_velocity)
|
||||
else
|
||||
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
||||
local v = self.object:getvelocity()
|
||||
v.y = 5
|
||||
self.object:setvelocity(v)
|
||||
end
|
||||
self.set_velocity(self, self.run_velocity)
|
||||
end
|
||||
else
|
||||
self.set_velocity(self, 0)
|
||||
self.v_start = false
|
||||
if self.timer > 1 then
|
||||
self.timer = 0
|
||||
local d1 = 10
|
||||
local d2 = 10
|
||||
local d3 = 10
|
||||
if self.damage > 0 then
|
||||
d3 = 1/self.damage
|
||||
end
|
||||
if self.damage > 1 then
|
||||
d2 = 1/(self.damage-1)
|
||||
end
|
||||
if self.damage > 2 then
|
||||
d1 = 1/(self.damage-2)
|
||||
end
|
||||
self.attack.player:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[1]=d1, [2]=d2, [3]=d3}},
|
||||
}
|
||||
}, vec)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
self.object:set_armor_groups({fleshy=self.armor})
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self.state = "stand"
|
||||
self.object:setvelocity({x=0, y=self.object:getvelocity().y, z=0})
|
||||
self.object:setyaw(math.random(1, 360)/180*math.pi)
|
||||
end,
|
||||
|
||||
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))
|
||||
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)
|
||||
if obj then
|
||||
obj:get_luaentity().collect = true
|
||||
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
|
||||
end
|
||||
end,
|
||||
|
||||
})
|
||||
end
|
||||
|
||||
function mobs:register_animal(name, def)
|
||||
minetest.register_entity(name, {
|
||||
hp_max = def.hp_max,
|
||||
physical = true,
|
||||
collisionbox = def.collisionbox,
|
||||
visual = def.visual,
|
||||
visual_size = def.visual_size,
|
||||
textures = def.textures,
|
||||
makes_footstep_sound = def.makes_footstep_sound,
|
||||
walk_velocity = def.walk_velocity,
|
||||
drop = def.drop,
|
||||
on_rightclick = def.on_rightclick,
|
||||
drop_count = def.drop_count,
|
||||
drawtype = def.drawtype,
|
||||
water_damage = def.water_damage,
|
||||
lava_damage = def.lava_damage,
|
||||
|
||||
timer = 0,
|
||||
state = "stand",
|
||||
old_y = nil,
|
||||
|
||||
|
||||
set_velocity = function(self, v)
|
||||
local yaw = self.object:getyaw()
|
||||
if self.drawtype == "side" then
|
||||
yaw = yaw+(math.pi/2)
|
||||
end
|
||||
local x = math.sin(yaw) * -v
|
||||
local z = math.cos(yaw) * v
|
||||
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
||||
end,
|
||||
|
||||
get_velocity = function(self)
|
||||
local v = self.object:getvelocity()
|
||||
return (v.x^2 + v.z^2)^(0.5)
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
if self.object:getvelocity().y > 0.1 then
|
||||
local yaw = self.object:getyaw()
|
||||
if self.drawtype == "side" then
|
||||
yaw = yaw+(math.pi/2)
|
||||
end
|
||||
local x = math.sin(yaw) * -2
|
||||
local z = math.cos(yaw) * 2
|
||||
self.object:setacceleration({x=x, y=-10, z=z})
|
||||
else
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
end
|
||||
|
||||
if self.object:getvelocity().y == 0 then
|
||||
if not self.old_y then
|
||||
self.old_y = self.object:getpos().y
|
||||
else
|
||||
local d = self.old_y - self.object:getpos().y
|
||||
if d > 5 then
|
||||
local damage = d-5
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[3]=1/damage}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
self.old_y = self.object:getpos().y
|
||||
end
|
||||
end
|
||||
|
||||
self.timer = self.timer+dtime
|
||||
if self.timer < 1 then
|
||||
return
|
||||
end
|
||||
self.timer = 0
|
||||
|
||||
if self.water_damage and self.water_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:water") then
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[3]=1/self.water_damage}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
|
||||
if self.lava_damage and self.lava_damage ~= 0 and string.find(minetest.env:get_node(self.object:getpos()).name, "default:lava") then
|
||||
self.object:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
groupcaps={
|
||||
fleshy={times={[3]=1/self.lava_damage}},
|
||||
}
|
||||
}, nil)
|
||||
end
|
||||
|
||||
if self.state == "stand" then
|
||||
if math.random(1, 2) == 1 then
|
||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
||||
end
|
||||
if math.random(1, 100) <= 50 then
|
||||
self.set_velocity(self, self.walk_velocity)
|
||||
self.state = "walk"
|
||||
end
|
||||
elseif self.state == "walk" then
|
||||
if math.random(1, 100) <= 30 then
|
||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
|
||||
self.set_velocity(self, self.get_velocity(self))
|
||||
end
|
||||
if math.random(1, 100) <= 10 then
|
||||
self.set_velocity(self, 0)
|
||||
self.state = "stand"
|
||||
end
|
||||
if self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then
|
||||
local v = self.object:getvelocity()
|
||||
v.y = 5
|
||||
self.object:setvelocity(v)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
self.object:set_armor_groups({fleshy=3})
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self.state = "stand"
|
||||
self.object:setvelocity({x=0, y=self.object:getvelocity().y, z=0})
|
||||
self.object:setyaw(math.random(1, 360)/180*math.pi)
|
||||
end,
|
||||
|
||||
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))
|
||||
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)
|
||||
if obj then
|
||||
obj:get_luaentity().collect = true
|
||||
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
|
||||
end
|
||||
end,
|
||||
|
||||
})
|
||||
end
|
||||
|
||||
function mobs:register_spawn(name, nodes, max_light, min_light, chance, mobs_per_30_block_radius)
|
||||
minetest.register_abm({
|
||||
nodenames = nodes,
|
||||
neighbors = nodes,
|
||||
interval = 30,
|
||||
chance = chance,
|
||||
action = function(pos, node)
|
||||
pos.y = pos.y+1
|
||||
if not minetest.env:get_node_light(pos) then
|
||||
return
|
||||
end
|
||||
if minetest.env:get_node_light(pos) > max_light then
|
||||
return
|
||||
end
|
||||
if minetest.env:get_node_light(pos) < min_light then
|
||||
return
|
||||
end
|
||||
if minetest.env:get_node(pos).name ~= "air" then
|
||||
return
|
||||
end
|
||||
pos.y = pos.y+1
|
||||
if minetest.env:get_node(pos).name ~= "air" then
|
||||
return
|
||||
end
|
||||
|
||||
local count = 0
|
||||
for _,obj in pairs(minetest.env:get_objects_inside_radius(pos, 30)) do
|
||||
if obj:is_player() then
|
||||
return
|
||||
elseif obj:get_luaentity().name == name then
|
||||
count = count+1
|
||||
end
|
||||
end
|
||||
if count > mobs_per_30_block_radius then
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.setting_getbool("display_mob_spawn") then
|
||||
minetest.chat_send_all("[mobs] Add "..name.." at "..minetest.pos_to_string(pos))
|
||||
end
|
||||
minetest.env:add_entity(pos, name)
|
||||
end
|
||||
})
|
||||
end
|
@ -1 +1 @@
|
||||
default
|
||||
default
|
@ -1,182 +1,182 @@
|
||||
dofile(minetest.get_modpath("mobs").."/api.lua")
|
||||
|
||||
mobs:register_monster("mobs:dirt_monster", {
|
||||
hp_max = 5,
|
||||
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=1, y=2},
|
||||
textures = {"mobs_dirt_monster.png", "mobs_dirt_monster_back.png"},
|
||||
makes_footstep_sound = true,
|
||||
view_range = 15,
|
||||
walk_velocity = 1,
|
||||
run_velocity = 3,
|
||||
damage = 2,
|
||||
drop = "default:dirt",
|
||||
drop_count = 3,
|
||||
armor = 3,
|
||||
drawtype = "front",
|
||||
water_damage = 1,
|
||||
lava_damage = 5,
|
||||
})
|
||||
mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1, 5000, 5)
|
||||
|
||||
mobs:register_monster("mobs:stone_monster", {
|
||||
hp_max = 10,
|
||||
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=1, y=2},
|
||||
textures = {"mobs_stone_monster.png", "mobs_stone_monster_back.png"},
|
||||
makes_footstep_sound = true,
|
||||
view_range = 10,
|
||||
walk_velocity = 0.5,
|
||||
run_velocity = 2,
|
||||
damage = 3,
|
||||
drop = "default:mossycobble",
|
||||
drop_count = 3,
|
||||
light_resistant = true,
|
||||
armor = 2,
|
||||
drawtype = "front",
|
||||
water_damage = 0,
|
||||
lava_damage = 0,
|
||||
})
|
||||
mobs:register_spawn("mobs:stone_monster", {"default:stone"}, 3, -1, 5000, 5)
|
||||
|
||||
|
||||
mobs:register_monster("mobs:sand_monster", {
|
||||
hp_max = 3,
|
||||
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=1, y=2},
|
||||
textures = {"mobs_sand_monster.png", "mobs_sand_monster_back.png"},
|
||||
makes_footstep_sound = true,
|
||||
view_range = 15,
|
||||
walk_velocity = 1.5,
|
||||
run_velocity = 4,
|
||||
damage = 1,
|
||||
drop = "default:sand",
|
||||
drop_count = 3,
|
||||
light_resistant = true,
|
||||
armor = 3,
|
||||
drawtype = "front",
|
||||
water_damage = 3,
|
||||
lava_damage = 1,
|
||||
})
|
||||
mobs:register_spawn("mobs:sand_monster", {"default:desert_sand"}, 20, -1, 5000, 5)
|
||||
|
||||
mobs:register_animal("mobs:sheep", {
|
||||
hp_max = 5,
|
||||
collisionbox = {-0.6, -0.625, -0.6, 0.6, 0.625, 0.6},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=2, y=1.25},
|
||||
textures = {"mobs_sheep.png", "mobs_sheep.png"},
|
||||
makes_footstep_sound = true,
|
||||
walk_velocity = 1,
|
||||
drop = "mobs:meat_raw",
|
||||
drop_count = 2,
|
||||
drawtype = "side",
|
||||
water_damage = 1,
|
||||
lava_damage = 5,
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
if self.naked then
|
||||
return
|
||||
end
|
||||
if clicker:get_inventory() then
|
||||
self.naked = true,
|
||||
clicker:get_inventory():add_item("main", ItemStack("wool:white "..math.random(1,3)))
|
||||
self.object:set_properties({
|
||||
textures = {"mobs_sheep_naked.png", "mobs_sheep_naked.png"},
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8, 8000, 1)
|
||||
|
||||
minetest.register_craftitem("mobs:meat_raw", {
|
||||
description = "Raw Meat",
|
||||
inventory_image = "mobs_meat_raw.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("mobs:meat", {
|
||||
description = "Meat",
|
||||
inventory_image = "mobs_meat.png",
|
||||
on_use = minetest.item_eat(8),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "mobs:meat",
|
||||
recipe = "mobs:meat_raw",
|
||||
cooktime = 5,
|
||||
})
|
||||
|
||||
mobs:register_animal("mobs:rat", {
|
||||
hp_max = 1,
|
||||
collisionbox = {-0.25, -0.175, -0.25, 0.25, 0.1, 0.25},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=0.7, y=0.35},
|
||||
textures = {"mobs_rat.png", "mobs_rat.png"},
|
||||
makes_footstep_sound = false,
|
||||
walk_velocity = 1,
|
||||
drop = "",
|
||||
drop_count = 0,
|
||||
drawtype = "side",
|
||||
water_damage = 0,
|
||||
lava_damage = 1,
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
if clicker:is_player() and clicker:get_inventory() then
|
||||
clicker:get_inventory():add_item("main", "mobs:rat")
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
})
|
||||
mobs:register_spawn("mobs:rat", {"default:dirt_with_grass", "default:stone"}, 20, -1, 5000, 1)
|
||||
|
||||
minetest.register_craftitem("mobs:rat", {
|
||||
description = "Rat",
|
||||
inventory_image = "mobs_rat.png",
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.above then
|
||||
minetest.env:add_entity(pointed_thing.above, "mobs:rat")
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("mobs:rat_cooked", {
|
||||
description = "Cooked Rat",
|
||||
inventory_image = "mobs_cooked_rat.png",
|
||||
|
||||
on_use = minetest.item_eat(3),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "mobs:rat_cooked",
|
||||
recipe = "mobs:rat",
|
||||
cooktime = 5,
|
||||
})
|
||||
|
||||
mobs:register_monster("mobs:oerkki", {
|
||||
hp_max = 8,
|
||||
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=1, y=2},
|
||||
textures = {"mobs_oerkki.png", "mobs_oerkki_back.png"},
|
||||
makes_footstep_sound = false,
|
||||
view_range = 15,
|
||||
walk_velocity = 1,
|
||||
run_velocity = 3,
|
||||
damage = 4,
|
||||
drop = "",
|
||||
drop_count = 0,
|
||||
armor = 3,
|
||||
drawtype = "front",
|
||||
light_resistant = true,
|
||||
water_damage = 1,
|
||||
lava_damage = 1,
|
||||
})
|
||||
mobs:register_spawn("mobs:oerkki", {"default:stone"}, 2, -1, 5000, 5)
|
||||
dofile(minetest.get_modpath("mobs").."/api.lua")
|
||||
|
||||
mobs:register_monster("mobs:dirt_monster", {
|
||||
hp_max = 5,
|
||||
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=1, y=2},
|
||||
textures = {"mobs_dirt_monster.png", "mobs_dirt_monster_back.png"},
|
||||
makes_footstep_sound = true,
|
||||
view_range = 15,
|
||||
walk_velocity = 1,
|
||||
run_velocity = 3,
|
||||
damage = 2,
|
||||
drop = "default:dirt",
|
||||
drop_count = 3,
|
||||
armor = 3,
|
||||
drawtype = "front",
|
||||
water_damage = 1,
|
||||
lava_damage = 5,
|
||||
})
|
||||
mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1, 5000, 5)
|
||||
|
||||
mobs:register_monster("mobs:stone_monster", {
|
||||
hp_max = 10,
|
||||
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=1, y=2},
|
||||
textures = {"mobs_stone_monster.png", "mobs_stone_monster_back.png"},
|
||||
makes_footstep_sound = true,
|
||||
view_range = 10,
|
||||
walk_velocity = 0.5,
|
||||
run_velocity = 2,
|
||||
damage = 3,
|
||||
drop = "default:mossycobble",
|
||||
drop_count = 3,
|
||||
light_resistant = true,
|
||||
armor = 2,
|
||||
drawtype = "front",
|
||||
water_damage = 0,
|
||||
lava_damage = 0,
|
||||
})
|
||||
mobs:register_spawn("mobs:stone_monster", {"default:stone"}, 3, -1, 5000, 5)
|
||||
|
||||
|
||||
mobs:register_monster("mobs:sand_monster", {
|
||||
hp_max = 3,
|
||||
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=1, y=2},
|
||||
textures = {"mobs_sand_monster.png", "mobs_sand_monster_back.png"},
|
||||
makes_footstep_sound = true,
|
||||
view_range = 15,
|
||||
walk_velocity = 1.5,
|
||||
run_velocity = 4,
|
||||
damage = 1,
|
||||
drop = "default:sand",
|
||||
drop_count = 3,
|
||||
light_resistant = true,
|
||||
armor = 3,
|
||||
drawtype = "front",
|
||||
water_damage = 3,
|
||||
lava_damage = 1,
|
||||
})
|
||||
mobs:register_spawn("mobs:sand_monster", {"default:desert_sand"}, 20, -1, 5000, 5)
|
||||
|
||||
mobs:register_animal("mobs:sheep", {
|
||||
hp_max = 5,
|
||||
collisionbox = {-0.6, -0.625, -0.6, 0.6, 0.625, 0.6},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=2, y=1.25},
|
||||
textures = {"mobs_sheep.png", "mobs_sheep.png"},
|
||||
makes_footstep_sound = true,
|
||||
walk_velocity = 1,
|
||||
drop = "mobs:meat_raw",
|
||||
drop_count = 2,
|
||||
drawtype = "side",
|
||||
water_damage = 1,
|
||||
lava_damage = 5,
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
if self.naked then
|
||||
return
|
||||
end
|
||||
if clicker:get_inventory() then
|
||||
self.naked = true,
|
||||
clicker:get_inventory():add_item("main", ItemStack("wool:white "..math.random(1,3)))
|
||||
self.object:set_properties({
|
||||
textures = {"mobs_sheep_naked.png", "mobs_sheep_naked.png"},
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8, 8000, 1)
|
||||
|
||||
minetest.register_craftitem("mobs:meat_raw", {
|
||||
description = "Raw Meat",
|
||||
inventory_image = "mobs_meat_raw.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("mobs:meat", {
|
||||
description = "Meat",
|
||||
inventory_image = "mobs_meat.png",
|
||||
on_use = minetest.item_eat(8),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "mobs:meat",
|
||||
recipe = "mobs:meat_raw",
|
||||
cooktime = 5,
|
||||
})
|
||||
|
||||
mobs:register_animal("mobs:rat", {
|
||||
hp_max = 1,
|
||||
collisionbox = {-0.25, -0.175, -0.25, 0.25, 0.1, 0.25},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=0.7, y=0.35},
|
||||
textures = {"mobs_rat.png", "mobs_rat.png"},
|
||||
makes_footstep_sound = false,
|
||||
walk_velocity = 1,
|
||||
drop = "",
|
||||
drop_count = 0,
|
||||
drawtype = "side",
|
||||
water_damage = 0,
|
||||
lava_damage = 1,
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
if clicker:is_player() and clicker:get_inventory() then
|
||||
clicker:get_inventory():add_item("main", "mobs:rat")
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
})
|
||||
mobs:register_spawn("mobs:rat", {"default:dirt_with_grass", "default:stone"}, 20, -1, 5000, 1)
|
||||
|
||||
minetest.register_craftitem("mobs:rat", {
|
||||
description = "Rat",
|
||||
inventory_image = "mobs_rat.png",
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.above then
|
||||
minetest.env:add_entity(pointed_thing.above, "mobs:rat")
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("mobs:rat_cooked", {
|
||||
description = "Cooked Rat",
|
||||
inventory_image = "mobs_cooked_rat.png",
|
||||
|
||||
on_use = minetest.item_eat(3),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "mobs:rat_cooked",
|
||||
recipe = "mobs:rat",
|
||||
cooktime = 5,
|
||||
})
|
||||
|
||||
mobs:register_monster("mobs:oerkki", {
|
||||
hp_max = 8,
|
||||
collisionbox = {-0.4, -1, -0.4, 0.4, 1, 0.4},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=1, y=2},
|
||||
textures = {"mobs_oerkki.png", "mobs_oerkki_back.png"},
|
||||
makes_footstep_sound = false,
|
||||
view_range = 15,
|
||||
walk_velocity = 1,
|
||||
run_velocity = 3,
|
||||
damage = 4,
|
||||
drop = "",
|
||||
drop_count = 0,
|
||||
armor = 3,
|
||||
drawtype = "front",
|
||||
light_resistant = true,
|
||||
water_damage = 1,
|
||||
lava_damage = 1,
|
||||
})
|
||||
mobs:register_spawn("mobs:oerkki", {"default:stone"}, 2, -1, 5000, 5)
|
Before Width: | Height: | Size: 239 B After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 411 B After Width: | Height: | Size: 411 B |
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 426 B |
Before Width: | Height: | Size: 239 B After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 224 B |
Before Width: | Height: | Size: 920 B After Width: | Height: | Size: 920 B |
Before Width: | Height: | Size: 1016 B After Width: | Height: | Size: 1016 B |
Before Width: | Height: | Size: 990 B After Width: | Height: | Size: 990 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 909 B After Width: | Height: | Size: 909 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
@ -1,4 +1,4 @@
|
||||
minetest-mod-slimes
|
||||
===================
|
||||
|
||||
minetest-mod-slimes
|
||||
===================
|
||||
|
||||
This mod adds slimes to minetest-c55
|
@ -1 +1 @@
|
||||
mesecons_materials
|
||||
mesecons_materials
|
@ -1,134 +1,134 @@
|
||||
SLIME_SIZE = 0.5
|
||||
SLIME_BOX = math.sqrt(2*math.pow(SLIME_SIZE, 2))/2
|
||||
GRAVITY = 9.8
|
||||
|
||||
minetest.register_entity("slimes:small",{
|
||||
initial_properties = {
|
||||
hp_max = 4,
|
||||
visual_size = {x = SLIME_SIZE, y = SLIME_SIZE, z = SLIME_SIZE},
|
||||
visual = "cube",
|
||||
textures = {
|
||||
"slime_top.png",
|
||||
"slime_bottom.png",
|
||||
"slime_front.png",
|
||||
"slime_sides.png",
|
||||
"slime_sides.png",
|
||||
"slime_sides.png",
|
||||
},
|
||||
collisionbox = {-SLIME_BOX, -SLIME_SIZE/2, -SLIME_BOX, SLIME_BOX, SLIME_SIZE/2, SLIME_BOX},
|
||||
physical = true,
|
||||
},
|
||||
|
||||
timer = 6,
|
||||
timer2 = 1,
|
||||
timer3 = 0, --regularly check if slime touches ground and possibly set x/z velocity/acceleration to 0
|
||||
yaw = 0,
|
||||
direction = {},
|
||||
status = 2, --1 = jump, 2 = rotate
|
||||
attracts_slime = true,
|
||||
found_friend = false,
|
||||
|
||||
on_activate = function(self)
|
||||
self.object:setacceleration({x = 0, y = -GRAVITY, z = 0})
|
||||
end,
|
||||
|
||||
on_punch = function(self)
|
||||
if self.object:get_hp() <= 0 then
|
||||
minetest.env:add_item(self.object:getpos(), "mesecons_materials:glue 4")
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
self.timer2 = self.timer2 + dtime
|
||||
if self.status == 2 and (self.timer2 >= 0.5) then
|
||||
self.timer2 = 1.2
|
||||
self.status = 1
|
||||
|
||||
local pos = self.object:getpos()
|
||||
if slime_lonely(pos) and not minetest.env:find_node_near(pos, 16, "default:mese") then
|
||||
self.object:remove()
|
||||
end
|
||||
self.yaw = slime_getyaw(pos)
|
||||
if self.yaw == false then
|
||||
self.yaw = math.random() * 360
|
||||
self.found_friend = false
|
||||
else
|
||||
self.found_friend = true
|
||||
end
|
||||
self.object:setyaw(self.yaw)
|
||||
self.object:set_properties({automatic_rotate = 0})
|
||||
self.direction = {x = math.cos(self.yaw)*2, y = 6, z = math.sin(self.yaw)*2}
|
||||
end
|
||||
|
||||
|
||||
self.timer = self.timer + dtime
|
||||
self.timer3 = self.timer3 + dtime
|
||||
|
||||
if self.timer2 > 1.3 and self.object:getvelocity().y == 0 then
|
||||
self.object:setvelocity(self.direction)
|
||||
self.object:setacceleration({x = self.direction.x/5, y = -GRAVITY, z = self.direction.z/5})
|
||||
self.timer2 = 0
|
||||
end
|
||||
|
||||
if (self.timer >= 6 or (self.timer >= 1 and self.found_friend == true)) and self.object:getvelocity().y == 0 then
|
||||
self.timer = 0
|
||||
self.timer2 = 0
|
||||
|
||||
self.status = 2
|
||||
if not self.found_friend then
|
||||
self.object:set_properties({automatic_rotate = math.pi * 8})
|
||||
end
|
||||
end
|
||||
|
||||
if self.timer3 > 0.07 then
|
||||
vel = self.object:getvelocity()
|
||||
if vel.y == 0 and (vel.x ~= 0 or vel.z ~= 0) then
|
||||
self.object:setvelocity({x = 0, y = 0, z = 0})
|
||||
self.object:setacceleration({x = 0, y = -GRAVITY, z = 0})
|
||||
end
|
||||
self.timer3 = 0
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
function slime_lonely (pos)
|
||||
objs = minetest.env:get_objects_inside_radius(pos, 32)
|
||||
for i, obj in pairs(objs) do
|
||||
if obj:is_player() then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function approx(val1, val2, deviation)
|
||||
if val1 + deviation > val2
|
||||
and val1 - deviation < val2 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function slime_getyaw (pos) -- get yaw, only if objects to follow nearby
|
||||
objs = minetest.env:get_objects_inside_radius(pos, 7)
|
||||
for i, obj in ipairs(objs) do
|
||||
if obj:is_player() or obj:get_luaentity().name == "slimes:small" then
|
||||
local ppos = {x = obj:getpos().x - pos.x,
|
||||
z = obj:getpos().z - pos.z}
|
||||
if ppos.x ~= 0 and ppos.z ~= 0 then --found itself as an object
|
||||
local yaw = math.abs(math.atan(ppos.x/ppos.z) - math.pi / 2)
|
||||
if ppos.z < 0 then yaw = yaw + math.pi end
|
||||
return yaw
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:leaves"},
|
||||
interval = 10.0,
|
||||
chance = 100000,
|
||||
action = function(pos, node)
|
||||
minetest.env:add_entity({x=pos.x, y=pos.y + 1, z=pos.z}, "slimes:small")
|
||||
end,
|
||||
})
|
||||
SLIME_SIZE = 0.5
|
||||
SLIME_BOX = math.sqrt(2*math.pow(SLIME_SIZE, 2))/2
|
||||
GRAVITY = 9.8
|
||||
|
||||
minetest.register_entity("slimes:small",{
|
||||
initial_properties = {
|
||||
hp_max = 4,
|
||||
visual_size = {x = SLIME_SIZE, y = SLIME_SIZE, z = SLIME_SIZE},
|
||||
visual = "cube",
|
||||
textures = {
|
||||
"slime_top.png",
|
||||
"slime_bottom.png",
|
||||
"slime_front.png",
|
||||
"slime_sides.png",
|
||||
"slime_sides.png",
|
||||
"slime_sides.png",
|
||||
},
|
||||
collisionbox = {-SLIME_BOX, -SLIME_SIZE/2, -SLIME_BOX, SLIME_BOX, SLIME_SIZE/2, SLIME_BOX},
|
||||
physical = true,
|
||||
},
|
||||
|
||||
timer = 6,
|
||||
timer2 = 1,
|
||||
timer3 = 0, --regularly check if slime touches ground and possibly set x/z velocity/acceleration to 0
|
||||
yaw = 0,
|
||||
direction = {},
|
||||
status = 2, --1 = jump, 2 = rotate
|
||||
attracts_slime = true,
|
||||
found_friend = false,
|
||||
|
||||
on_activate = function(self)
|
||||
self.object:setacceleration({x = 0, y = -GRAVITY, z = 0})
|
||||
end,
|
||||
|
||||
on_punch = function(self)
|
||||
if self.object:get_hp() <= 0 then
|
||||
minetest.env:add_item(self.object:getpos(), "mesecons_materials:glue 4")
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
self.timer2 = self.timer2 + dtime
|
||||
if self.status == 2 and (self.timer2 >= 0.5) then
|
||||
self.timer2 = 1.2
|
||||
self.status = 1
|
||||
|
||||
local pos = self.object:getpos()
|
||||
if slime_lonely(pos) and not minetest.env:find_node_near(pos, 16, "default:mese") then
|
||||
self.object:remove()
|
||||
end
|
||||
self.yaw = slime_getyaw(pos)
|
||||
if self.yaw == false then
|
||||
self.yaw = math.random() * 360
|
||||
self.found_friend = false
|
||||
else
|
||||
self.found_friend = true
|
||||
end
|
||||
self.object:setyaw(self.yaw)
|
||||
self.object:set_properties({automatic_rotate = 0})
|
||||
self.direction = {x = math.cos(self.yaw)*2, y = 6, z = math.sin(self.yaw)*2}
|
||||
end
|
||||
|
||||
|
||||
self.timer = self.timer + dtime
|
||||
self.timer3 = self.timer3 + dtime
|
||||
|
||||
if self.timer2 > 1.3 and self.object:getvelocity().y == 0 then
|
||||
self.object:setvelocity(self.direction)
|
||||
self.object:setacceleration({x = self.direction.x/5, y = -GRAVITY, z = self.direction.z/5})
|
||||
self.timer2 = 0
|
||||
end
|
||||
|
||||
if (self.timer >= 6 or (self.timer >= 1 and self.found_friend == true)) and self.object:getvelocity().y == 0 then
|
||||
self.timer = 0
|
||||
self.timer2 = 0
|
||||
|
||||
self.status = 2
|
||||
if not self.found_friend then
|
||||
self.object:set_properties({automatic_rotate = math.pi * 8})
|
||||
end
|
||||
end
|
||||
|
||||
if self.timer3 > 0.07 then
|
||||
vel = self.object:getvelocity()
|
||||
if vel.y == 0 and (vel.x ~= 0 or vel.z ~= 0) then
|
||||
self.object:setvelocity({x = 0, y = 0, z = 0})
|
||||
self.object:setacceleration({x = 0, y = -GRAVITY, z = 0})
|
||||
end
|
||||
self.timer3 = 0
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
function slime_lonely (pos)
|
||||
objs = minetest.env:get_objects_inside_radius(pos, 32)
|
||||
for i, obj in pairs(objs) do
|
||||
if obj:is_player() then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function approx(val1, val2, deviation)
|
||||
if val1 + deviation > val2
|
||||
and val1 - deviation < val2 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function slime_getyaw (pos) -- get yaw, only if objects to follow nearby
|
||||
objs = minetest.env:get_objects_inside_radius(pos, 7)
|
||||
for i, obj in ipairs(objs) do
|
||||
if obj:is_player() or obj:get_luaentity().name == "slimes:small" then
|
||||
local ppos = {x = obj:getpos().x - pos.x,
|
||||
z = obj:getpos().z - pos.z}
|
||||
if ppos.x ~= 0 and ppos.z ~= 0 then --found itself as an object
|
||||
local yaw = math.abs(math.atan(ppos.x/ppos.z) - math.pi / 2)
|
||||
if ppos.z < 0 then yaw = yaw + math.pi end
|
||||
return yaw
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:leaves"},
|
||||
interval = 10.0,
|
||||
chance = 100000,
|
||||
action = function(pos, node)
|
||||
minetest.env:add_entity({x=pos.x, y=pos.y + 1, z=pos.z}, "slimes:small")
|
||||
end,
|
||||
})
|
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 493 B After Width: | Height: | Size: 493 B |
Before Width: | Height: | Size: 525 B After Width: | Height: | Size: 525 B |
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 496 B |
Before Width: | Height: | Size: 506 B After Width: | Height: | Size: 506 B |
@ -1,140 +1,140 @@
|
||||
--[[
|
||||
|
||||
Bags for Minetest
|
||||
|
||||
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
||||
Source Code: https://github.com/cornernote/minetest-particles
|
||||
License: GPLv3
|
||||
|
||||
]]--
|
||||
|
||||
|
||||
-- get_formspec
|
||||
local get_formspec = function(player,page)
|
||||
if page=="bags" then
|
||||
return "size[8,7.5]"
|
||||
.."list[current_player;main;0,3.5;8,4;]"
|
||||
.."button[0,0;2,0.5;main;Back]"
|
||||
.."button[0,2;2,0.5;bag1;Bag 1]"
|
||||
.."button[2,2;2,0.5;bag2;Bag 2]"
|
||||
.."button[4,2;2,0.5;bag3;Bag 3]"
|
||||
.."button[6,2;2,0.5;bag4;Bag 4]"
|
||||
.."list[detached:"..player:get_player_name().."_bags;bag1;0.5,1;1,1;]"
|
||||
.."list[detached:"..player:get_player_name().."_bags;bag2;2.5,1;1,1;]"
|
||||
.."list[detached:"..player:get_player_name().."_bags;bag3;4.5,1;1,1;]"
|
||||
.."list[detached:"..player:get_player_name().."_bags;bag4;6.5,1;1,1;]"
|
||||
end
|
||||
for i=1,4 do
|
||||
if page=="bag"..i then
|
||||
local image = player:get_inventory():get_stack("bag"..i, 1):get_definition().inventory_image
|
||||
return "size[8,8.5]"
|
||||
.."list[current_player;main;0,4.5;8,4;]"
|
||||
.."button[0,0;2,0.5;main;Main]"
|
||||
.."button[2,0;2,0.5;bags;Bags]"
|
||||
.."image[7,0;1,1;"..image.."]"
|
||||
.."list[current_player;bag"..i.."contents;0,1;8,3;]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- register_on_player_receive_fields
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields.bags then
|
||||
inventory_plus.set_inventory_formspec(player, get_formspec(player,"bags"))
|
||||
return
|
||||
end
|
||||
for i=1,4 do
|
||||
local page = "bag"..i
|
||||
if fields[page] then
|
||||
if player:get_inventory():get_stack(page, 1):get_definition().groups.bagslots==nil then
|
||||
page = "bags"
|
||||
end
|
||||
inventory_plus.set_inventory_formspec(player, get_formspec(player,page))
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- register_on_joinplayer
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
inventory_plus.register_button(player,"bags","Bags")
|
||||
local player_inv = player:get_inventory()
|
||||
local bags_inv = minetest.create_detached_inventory(player:get_player_name().."_bags",{
|
||||
on_put = function(inv, listname, index, stack, player)
|
||||
player:get_inventory():set_stack(listname, index, stack)
|
||||
player:get_inventory():set_size(listname.."contents", stack:get_definition().groups.bagslots)
|
||||
end,
|
||||
on_take = function(inv, listname, index, stack, player)
|
||||
player:get_inventory():set_stack(listname, index, nil)
|
||||
end,
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
if stack:get_definition().groups.bagslots then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
allow_take = function(inv, listname, index, stack, player)
|
||||
if player:get_inventory():is_empty(listname.."contents")==true then
|
||||
return stack:get_size(listname)
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||
return 0
|
||||
end,
|
||||
})
|
||||
for i=1,4 do
|
||||
local bag = "bag"..i
|
||||
player_inv:set_size(bag, 1)
|
||||
bags_inv:set_size(bag, 1)
|
||||
bags_inv:set_stack(bag,1,player_inv:get_stack(bag,1))
|
||||
end
|
||||
end)
|
||||
|
||||
-- register bag tools
|
||||
minetest.register_tool("bags:small", {
|
||||
description = "Small Bag",
|
||||
inventory_image = "bags_small.png",
|
||||
groups = {bagslots=8},
|
||||
})
|
||||
minetest.register_tool("bags:medium", {
|
||||
description = "Medium Bag",
|
||||
inventory_image = "bags_medium.png",
|
||||
groups = {bagslots=16},
|
||||
})
|
||||
minetest.register_tool("bags:large", {
|
||||
description = "Large Bag",
|
||||
inventory_image = "bags_large.png",
|
||||
groups = {bagslots=24},
|
||||
})
|
||||
|
||||
-- register bag crafts
|
||||
minetest.register_craft({
|
||||
output = "bags:small",
|
||||
recipe = {
|
||||
{"", "default:stick", ""},
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "bags:medium",
|
||||
recipe = {
|
||||
{"", "default:stick", ""},
|
||||
{"bags:small", "bags:small", "bags:small"},
|
||||
{"bags:small", "bags:small", "bags:small"},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "bags:large",
|
||||
recipe = {
|
||||
{"", "default:stick", ""},
|
||||
{"bags:medium", "bags:medium", "bags:medium"},
|
||||
{"bags:medium", "bags:medium", "bags:medium"},
|
||||
},
|
||||
})
|
||||
|
||||
-- log that we started
|
||||
--[[
|
||||
|
||||
Bags for Minetest
|
||||
|
||||
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
||||
Source Code: https://github.com/cornernote/minetest-particles
|
||||
License: GPLv3
|
||||
|
||||
]]--
|
||||
|
||||
|
||||
-- get_formspec
|
||||
local get_formspec = function(player,page)
|
||||
if page=="bags" then
|
||||
return "size[8,7.5]"
|
||||
.."list[current_player;main;0,3.5;8,4;]"
|
||||
.."button[0,0;2,0.5;main;Back]"
|
||||
.."button[0,2;2,0.5;bag1;Bag 1]"
|
||||
.."button[2,2;2,0.5;bag2;Bag 2]"
|
||||
.."button[4,2;2,0.5;bag3;Bag 3]"
|
||||
.."button[6,2;2,0.5;bag4;Bag 4]"
|
||||
.."list[detached:"..player:get_player_name().."_bags;bag1;0.5,1;1,1;]"
|
||||
.."list[detached:"..player:get_player_name().."_bags;bag2;2.5,1;1,1;]"
|
||||
.."list[detached:"..player:get_player_name().."_bags;bag3;4.5,1;1,1;]"
|
||||
.."list[detached:"..player:get_player_name().."_bags;bag4;6.5,1;1,1;]"
|
||||
end
|
||||
for i=1,4 do
|
||||
if page=="bag"..i then
|
||||
local image = player:get_inventory():get_stack("bag"..i, 1):get_definition().inventory_image
|
||||
return "size[8,8.5]"
|
||||
.."list[current_player;main;0,4.5;8,4;]"
|
||||
.."button[0,0;2,0.5;main;Main]"
|
||||
.."button[2,0;2,0.5;bags;Bags]"
|
||||
.."image[7,0;1,1;"..image.."]"
|
||||
.."list[current_player;bag"..i.."contents;0,1;8,3;]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- register_on_player_receive_fields
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields.bags then
|
||||
inventory_plus.set_inventory_formspec(player, get_formspec(player,"bags"))
|
||||
return
|
||||
end
|
||||
for i=1,4 do
|
||||
local page = "bag"..i
|
||||
if fields[page] then
|
||||
if player:get_inventory():get_stack(page, 1):get_definition().groups.bagslots==nil then
|
||||
page = "bags"
|
||||
end
|
||||
inventory_plus.set_inventory_formspec(player, get_formspec(player,page))
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- register_on_joinplayer
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
inventory_plus.register_button(player,"bags","Bags")
|
||||
local player_inv = player:get_inventory()
|
||||
local bags_inv = minetest.create_detached_inventory(player:get_player_name().."_bags",{
|
||||
on_put = function(inv, listname, index, stack, player)
|
||||
player:get_inventory():set_stack(listname, index, stack)
|
||||
player:get_inventory():set_size(listname.."contents", stack:get_definition().groups.bagslots)
|
||||
end,
|
||||
on_take = function(inv, listname, index, stack, player)
|
||||
player:get_inventory():set_stack(listname, index, nil)
|
||||
end,
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
if stack:get_definition().groups.bagslots then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
allow_take = function(inv, listname, index, stack, player)
|
||||
if player:get_inventory():is_empty(listname.."contents")==true then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||
return 0
|
||||
end,
|
||||
})
|
||||
for i=1,4 do
|
||||
local bag = "bag"..i
|
||||
player_inv:set_size(bag, 1)
|
||||
bags_inv:set_size(bag, 1)
|
||||
bags_inv:set_stack(bag,1,player_inv:get_stack(bag,1))
|
||||
end
|
||||
end)
|
||||
|
||||
-- register bag tools
|
||||
minetest.register_tool("bags:small", {
|
||||
description = "Small Bag",
|
||||
inventory_image = "bags_small.png",
|
||||
groups = {bagslots=8},
|
||||
})
|
||||
minetest.register_tool("bags:medium", {
|
||||
description = "Medium Bag",
|
||||
inventory_image = "bags_medium.png",
|
||||
groups = {bagslots=16},
|
||||
})
|
||||
minetest.register_tool("bags:large", {
|
||||
description = "Large Bag",
|
||||
inventory_image = "bags_large.png",
|
||||
groups = {bagslots=24},
|
||||
})
|
||||
|
||||
-- register bag crafts
|
||||
minetest.register_craft({
|
||||
output = "bags:small",
|
||||
recipe = {
|
||||
{"", "default:stick", ""},
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "bags:medium",
|
||||
recipe = {
|
||||
{"", "default:stick", ""},
|
||||
{"bags:small", "bags:small", "bags:small"},
|
||||
{"bags:small", "bags:small", "bags:small"},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "bags:large",
|
||||
recipe = {
|
||||
{"", "default:stick", ""},
|
||||
{"bags:medium", "bags:medium", "bags:medium"},
|
||||
{"bags:medium", "bags:medium", "bags:medium"},
|
||||
},
|
||||
})
|
||||
|
||||
-- log that we started
|
||||
minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded from "..minetest.get_modpath(minetest.get_current_modname()))
|