2016-11-05 16:27:06 -04:00

303 lines
8.4 KiB
Lua

--esmobs v0.0.3
--maikerumine
--made for Extreme Survival game
--dofile(minetest.get_modpath("esmobs").."/api.lua")
--REFERENCE
--function (mod_name_here):spawn_specific(name, nodes, neighbors, min_light, max_light, interval, chance, active_object_count, min_height, max_height)
mobs.npc_drops = { "default:pick_steel", "esmobs:meat", "default:sword_steel", "default:shovel_steel", "farming:bread", "default:wood" }--Added 20151121
mobs:register_spawn("esmobs:Wilbert", {"default:dirt_with_grass","default:snowblock","default:snow_block","default:stone", "default:stonebrick","default:cobble"}, 11, -1, 9000, 1, 31000)
mobs:register_spawn("esmobs:Thelma", {"default:dirt_with_grass","default:snowblock","default:snow_block","default:stone", "default:stonebrick","default:cobble"}, 11, -1, 9000, 1, 31000)
mobs:register_mob("esmobs:Wilbert", {
type = "npc",
hp_max = 115,
collisionbox = {-0.3, -1.0, -0.3, 0.3, 0.8, 0.3},
visual = "mesh",
mesh = "3d_armor_character.x",
textures = {"man.png",
"3d_armor_trans.png",
minetest.registered_items["default:sword_steel"].inventory_image,
},
visual_size = {x=1, y=1},
makes_footstep_sound = true,
view_range = 15,
walk_velocity = 1,
run_velocity = 3,
damage = 5,
sounds = {
war_cry = "mobs_die_yell",
death = "mobs_death1",
attack = "default_punch",
},
drops = {
{name = "default:apple",
chance = 1,
min = 10,
max = 28,},
{name = "default:sword_steel",
chance = 2,
min = 1,
max = 1,},
{name = "default:stick",
chance = 2,
min = 13,
max=30,
},
},
armor = 75,
drawtype = "front",
water_damage = 10,
lava_damage = 50,
light_damage = 0,
--[[
--Maikerumine added hackish follow code
on_rightclick = function (self, clicker)
mobs:face_pos(self,clicker:getpos())
mobs:team_player(self,clicker:getpos())
if self.state ~= "path" and self.state ~= "following" then
local_chat(clicker:getpos(),"Old man: I am getting too old for this... Okay, I'll help ya!",3)
if not self.tamed then
self.tamed = true
self.follow = true
end
end
end,]]
on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item()
local_chat(clicker:getpos(),"Old man: I am getting too old for this... Okay, I'll help ya!",3)
if item:get_name() == "esmobs:meat" or item:get_name() == "farming:bread" then
local hp = self.object:get_hp()
if hp + 4 > self.hp_max then return end
if not minetest.setting_getbool("creative_mode") then
item:take_item()
clicker:set_wielded_item(item)
end
self.object:set_hp(hp+4)
-- right clicking with gold lump drops random item from mobs.npc_drops
elseif item:get_name() == "default:gold_lump" then
if not minetest.setting_getbool("creative_mode") then
item:take_item()
clicker:set_wielded_item(item)
end
local pos = self.object:getpos()
pos.y = pos.y + 0.5
minetest.add_item(pos, {name = mobs.npc_drops[math.random(1,#mobs.npc_drops)]})
else
if self.owner == "" then
self.owner = clicker:get_player_name()
else
local formspec = "size[8,4]"
formspec = formspec .. "textlist[2.85,0;2.1,0.5;dialog;What can I do for you?]"
formspec = formspec .. "button_exit[1,1;2,2;gfollow;follow]"
formspec = formspec .. "button_exit[5,1;2,2;gstand;stand]"
formspec = formspec .. "button_exit[0,2;4,4;gfandp;follow and protect]"
formspec = formspec .. "button_exit[4,2;4,4;gsandp;stand and protect]"
--formspec = formspec .. "button_exit[1,2;2,2;ggohome; go home]"
--formspec = formspec .. "button_exit[5,2;2,2;gsethome; sethome]"
minetest.show_formspec(clicker:get_player_name(), "order", formspec)
minetest.register_on_player_receive_fields(function(clicker, formname, fields)
if fields.gfollow then
self.order = "follow"
self.attacks_monsters = false
end
if fields.gstand then
self.order = "stand"
self.attacks_monsters = false
end
if fields.gfandp then
self.order = "follow"
self.attacks_monsters = true
end
if fields.gsandp then
self.order = "stand"
self.attacks_monsters = true
end
if fields.gsethome then
self.floats = self.object:getpos()
end
if fields.ggohome then
if self.floats then
self.order = "stand"
self.object:setpos(self.floats)
end
end
end)
end
end
end,
attack_type = "dogfight",
animation = {
speed_normal = 17,
speed_run = 25,
stand_start = 0,
stand_end = 40,
walk_start = 168,
walk_end = 187,
run_start = 168,
run_end = 187,
punch_start = 189,
punch_end = 191,
},
attacks_monsters = true,
peaceful = true,
group_attack = true,
step = 1,
})
mobs:register_mob("esmobs:Thelma", {
type = "npc",
hp_max = 115,
collisionbox = {-0.3, -1.0, -0.3, 0.3, 0.8, 0.3},
visual = "mesh",
mesh = "3d_armor_character.x",
textures = {"woman.png",
"3d_armor_trans.png",
minetest.registered_items["default:sword_steel"].inventory_image,
},
visual_size = {x=1, y=1},
makes_footstep_sound = true,
view_range = 15,
walk_velocity = 1,
run_velocity = 3,
damage = 5,
sounds = {
war_cry = "mobs_oerkki_attack",
death = "mobs_death1",
attack = "default_punch",
},
drops = {
{name = "default:jungletree",
chance = 1,
min = 5,
max = 23,},
{name = "default:sword_steel",
chance = 2,
min = 1,
max = 1,},
{name = "default:stick",
chance = 2,
min = 13,
max=30,
},
},
armor = 75,
drawtype = "front",
water_damage = 10,
lava_damage = 50,
light_damage = 0,
--[[
--Maikerumine added hackish follow code
on_rightclick = function (self, clicker)
mobs:face_pos(self,clicker:getpos())
mobs:team_player(self,clicker:getpos())
if self.state ~= "path" and self.state ~= "following" then
local_chat(clicker:getpos(),"Old woman: I may walk slow, but I can fight like a champ!",3)
if not self.tamed then
self.tamed = true
self.follow = true
end
end
end,]]
on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item()
local_chat(clicker:getpos(),"Old woman: I may walk slow, but I can fight like a champ!",3)
if item:get_name() == "esmobs:meat" or item:get_name() == "farming:bread" then
local hp = self.object:get_hp()
if hp + 4 > self.hp_max then return end
if not minetest.setting_getbool("creative_mode") then
item:take_item()
clicker:set_wielded_item(item)
end
self.object:set_hp(hp+4)
-- right clicking with gold lump drops random item from mobs.npc_drops
elseif item:get_name() == "default:gold_lump" then
if not minetest.setting_getbool("creative_mode") then
item:take_item()
clicker:set_wielded_item(item)
end
local pos = self.object:getpos()
pos.y = pos.y + 0.5
minetest.add_item(pos, {name = mobs.npc_drops[math.random(1,#mobs.npc_drops)]})
else
if self.owner == "" then
self.owner = clicker:get_player_name()
else
local formspec = "size[8,4]"
formspec = formspec .. "textlist[2.85,0;2.1,0.5;dialog;What can I do for you?]"
formspec = formspec .. "button_exit[1,1;2,2;gfollow;follow]"
formspec = formspec .. "button_exit[5,1;2,2;gstand;stand]"
formspec = formspec .. "button_exit[0,2;4,4;gfandp;follow and protect]"
formspec = formspec .. "button_exit[4,2;4,4;gsandp;stand and protect]"
--formspec = formspec .. "button_exit[1,2;2,2;ggohome; go home]"
--formspec = formspec .. "button_exit[5,2;2,2;gsethome; sethome]"
minetest.show_formspec(clicker:get_player_name(), "order", formspec)
minetest.register_on_player_receive_fields(function(clicker, formname, fields)
if fields.gfollow then
self.order = "follow"
self.attacks_monsters = false
end
if fields.gstand then
self.order = "stand"
self.attacks_monsters = false
end
if fields.gfandp then
self.order = "follow"
self.attacks_monsters = true
end
if fields.gsandp then
self.order = "stand"
self.attacks_monsters = true
end
if fields.gsethome then
self.floats = self.object:getpos()
end
if fields.ggohome then
if self.floats then
self.order = "stand"
self.object:setpos(self.floats)
end
end
end)
end
end
end,
attack_type = "dogfight",
animation = {
speed_normal = 17,
speed_run = 25,
stand_start = 0,
stand_end = 40,
walk_start = 168,
walk_end = 187,
run_start = 168,
run_end = 187,
punch_start = 189,
punch_end = 191,
},
attacks_monsters = true,
peaceful = true,
group_attack = true,
step = 1,
})