1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-24 01:30:38 +01:00

Finish the mobs update

This commit is contained in:
Ombridride 2015-03-26 20:08:30 +01:00
parent 5f9d3c54bd
commit a291222ea6
15 changed files with 92 additions and 79 deletions

Binary file not shown.

View File

@ -29,6 +29,7 @@ This mod contains the following additions:
Changelog:
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.

View File

@ -1,4 +1,4 @@
-- Mobs Api (15th March 2015)
-- Mobs Api (24th March 2015)
mobs = {}
mobs.mod = "redo"
@ -341,76 +341,23 @@ function mobs:register_mob(name, def)
end
end
end
if self.following and self.following:is_player() and self.following:get_wielded_item():get_name() ~= self.follow then
self.following = nil
self.v_start = false
end
if self.following then
local s = self.object:getpos()
local p
if self.following.is_player and self.following:is_player() then
p = self.following:getpos()
elseif self.following.object then
p = self.following.object:getpos()
end
if p then
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
self.following = nil
self.v_start = false
else
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 dist > 2 then
if not self.v_start then
self.v_start = true
self.set_velocity(self, self.walk_velocity)
else
if self.jump and self.get_velocity(self) <= 1.5 and self.object:getvelocity().y == 0 then
local v = self.object:getvelocity()
v.y = 6
self.object:setvelocity(v)
end
self.set_velocity(self, self.walk_velocity)
end
self:set_animation("walk")
else
self.v_start = false
self.set_velocity(self, 0)
self:set_animation("stand")
end
return
end
end
end
-- horny animal can mate for 40 seconds, afterwards horny animal cannot mate again for 60 seconds
if self.horny == true and self.hornytimer < 100 and self.child == false then
-- horny animal can mate for 40 seconds, afterwards horny animal cannot mate again for 200 seconds
if self.horny == true and self.hornytimer < 240 and self.child == false then
self.hornytimer = self.hornytimer + 1
if self.hornytimer <= 40 then
effect(self.object:getpos(), 4, "heart.png")
end
if self.hornytimer >= 100 then
if self.hornytimer >= 240 then
self.hornytimer = 0
self.horny = false
end
end
-- if animal is child take 120 seconds before growing into adult
-- if animal is child take 240 seconds before growing into adult
if self.child == true then
self.hornytimer = self.hornytimer + 1
if self.hornytimer > 120 then
if self.hornytimer > 240 then
self.child = false
self.hornytimer = 0
self.object:set_properties({
@ -464,6 +411,59 @@ function mobs:register_mob(name, def)
end
end
if self.following and self.following:is_player() and self.following:get_wielded_item():get_name() ~= self.follow then
self.following = nil
self.v_start = false
end
if self.following then
local s = self.object:getpos()
local p
if self.following.is_player and self.following:is_player() then
p = self.following:getpos()
elseif self.following.object then
p = self.following.object:getpos()
end
if p then
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
self.following = nil
self.v_start = false
else
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 dist > 2 then
if not self.v_start then
self.v_start = true
self.set_velocity(self, self.walk_velocity)
else
if self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then -- 0.5 was 1.5
local v = self.object:getvelocity()
v.y = 6
self.object:setvelocity(v)
end
self.set_velocity(self, self.walk_velocity)
end
self:set_animation("walk")
else
self.v_start = false
self.set_velocity(self, 0)
self:set_animation("stand")
end
return
end
end
end
if self.state == "stand" then
-- randomly turn
if math.random(1, 4) == 1 then
@ -825,14 +825,13 @@ function mobs:register_mob(name, def)
end
end
end
-- quick fix for dog so it doesn't revert back to wolf
if self.type == "monster" and self.tamed == true then
self.type = "npc"
end
if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then
self.object:remove()
end
-- Internal check to see if player damage is still enabled
damage_enabled = minetest.setting_getbool("enable_damage")
end,
get_staticdata = function(self)

View File

@ -1,3 +1,4 @@
-- Chicken by JK Murray
mobs:register_mob("mobs:chicken", {
@ -138,7 +139,7 @@ description = "Raw Chicken",
minetest.register_craftitem("mobs:chicken_cooked", {
description = "Cooked Chicken",
inventory_image = "mobs_chicken_cooked.png",
on_use = minetest.item_eat(4),
on_use = minetest.item_eat(4), -- Modif MFF
})
minetest.register_craft({

View File

@ -61,8 +61,16 @@ mobs:register_mob("mobs:cow", {
local tool = clicker:get_wielded_item()
if tool:get_name() == "bucket:bucket_empty" and self.child == false then
if self.gotten then return end
clicker:get_inventory():remove_item("main", "bucket:bucket_empty")
clicker:get_inventory():add_item("main", "mobs:bucket_milk")
local inv = clicker:get_inventory()
inv:remove_item("main", "bucket:bucket_empty")
-- if room add bucket of milk to inventory, otherwise drop as item
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
end
if tool:get_name() == "farming:wheat" then -- and self.gotten then
@ -71,6 +79,9 @@ mobs:register_mob("mobs:cow", {
clicker:set_wielded_item(tool)
end
self.food = (self.food or 0) + 1
if self.child == true then
self.hornytimer = self.hornytimer + 10
end
if self.food >= 8 then
self.food = 0
if self.child == false then self.horny = true end
@ -93,6 +104,7 @@ minetest.register_craftitem("mobs:leather", {
description = "Leather",
inventory_image = "mobs_leather.png",
})
-- Bucket of Milk
minetest.register_craftitem("mobs:bucket_milk", {
description = "Bucket of Milk",

View File

@ -7,7 +7,7 @@ local excluded = {"nether:netherrack","default:obsidian_glass","default:obsidian
mobs:register_mob("mobs:dungeon_master", {
-- animal, monster, npc, barbarian
type = "monster",
-- aggressive, shoots fireballs at player
-- aggressive, shoots fireballs at player, deal 13 damages
passive = false,
damage = 13,
attack_type = "shoot",

View File

@ -4,7 +4,7 @@
mobs:register_mob("mobs:lava_flan", {
-- animal, monster, npc, barbarian
type = "monster",
-- aggressive, deals 3 damage to player when hit
-- aggressive, deals 5 damage to player when hit
passive = false,
attack_type = "dogfight",
damage = 5,
@ -32,7 +32,7 @@ mobs:register_mob("mobs:lava_flan", {
walk_velocity = 0.5,
run_velocity = 2,
jump = true,
-- step = 2, (ça aurait été pas mal, voir comment faire pour le remettre comme ça ?)
-- step = 2, (c'était pas mal, voir comment faire pour le remettre comme ça ?)
view_range = 16,
floats = 0,
-- chance of dropping lava orb when dead

View File

@ -4,7 +4,7 @@
mobs:register_mob("mobs:mese_monster", {
-- animal, monster, npc, barbarian
type = "monster",
-- agressive, deals 3 damage to player when hit
-- agressive, deals 9 damage to player when hit
passive = false,
damage = 9,
attack_type = "shoot",
@ -78,7 +78,7 @@ mobs:register_arrow("mobs:mese_arrow", {
player:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups = {fleshy=7},
damage_groups = {fleshy=9},
}, 0)
end,

View File

@ -9,7 +9,7 @@ mobs.npc_drops = { "farming:meat", "farming:donut", "farming:bread", "default:a
mobs:register_mob("mobs:npc", {
-- animal, monster, npc
type = "npc",
-- aggressive, deals 4 damage to player/monster when hit
-- aggressive, deals 6 damage to player/monster when hit
passive = false,
damage = 6,
attack_type = "dogfight",

View File

@ -4,7 +4,7 @@
mobs:register_mob("mobs:oerkki", {
-- animal, monster, npc, barbarian
type = "monster",
-- aggressive, deals 5 damage when player hit
-- aggressive, deals 7 damage when player hit
passive = false,
attack_type = "dogfight",
damage = 7,

View File

@ -4,7 +4,7 @@
mobs:register_mob("mobs:sand_monster", {
-- animal, monster, npc, barbarian
type = "monster",
-- aggressive, deals 3 damage to player when hit
-- aggressive, deals 5 damage to player when hit
passive = false,
attack_type = "dogfight",
damage = 5,

View File

@ -4,7 +4,7 @@
mobs:register_mob("mobs:spider", {
-- animal, monster, npc, barbarian
type = "monster",
-- agressive, does 4 damage to player when hit
-- agressive, does 6 damage to player when hit
passive = false,
attack_type = "dogfight",
damage = 6,

View File

@ -4,7 +4,7 @@
mobs:register_mob("mobs:stone_monster", {
-- animal, monster, npc, barbarian
type = "monster",
-- aggressive, deals 5 damage to player when hit
-- aggressive, deals 8 damage to player when hit
passive = false,
attack_type = "dogfight",
damage = 8,

View File

@ -4,7 +4,7 @@
mobs:register_mob("mobs:tree_monster", {
-- animal, monster, npc, barbarian
type = "monster",
-- aggressive, deals 8 damage to player when hit
-- aggressive, deals 9 damage to player when hit
passive = false,
attack_type = "dogfight",
damage = 9,

View File

@ -4,7 +4,7 @@
mobs:register_mob("mobs:pumba", {
-- animal, monster, npc, barbarian
type = "animal",
-- aggressive, deals 4 damage to player when threatened
-- aggressive, deals 5 damage to player when threatened
passive = false,
attack_type = "dogfight",
damage = 5,