Add new quest

pull/14/head
Brandon 2015-07-11 14:58:05 -05:00
parent 071737f871
commit cd4d40fda4
5 changed files with 44 additions and 8 deletions

View File

@ -710,7 +710,7 @@ function mobs:register_mob(name, def)
end
-- see if there are any NPCs to shower you with rewards
if self.type ~= "npc" then
if self.type ~= "npc" and self.type ~= "animal" then
local inradius = minetest.get_objects_inside_radius(hitter:getpos(),10)
for _, oir in pairs(inradius) do
local obj = oir:get_luaentity()

View File

@ -1,4 +1,5 @@
default
fire
cottages?
throwing?
throwing?
quests?

View File

@ -136,7 +136,7 @@ type = "npc",
water_damage = 1,
lava_damage = 5,
light_damage = 0,
on_rightclick = nil,
on_rightclick = function ( self, clicker ) quests.chest.go(self, clicker) end,
activity_level = 5,
attack_type = "dogfight",
animation = {
@ -161,9 +161,10 @@ type = "npc",
blood_amount = 35,
blood_offset = 0.25,
rewards = {
{chance=90, item="default:bread"},
{chance=40, item="experience:6_exp"},
{chance=60, item="potions:magic_replenish1"},
{chance=100, item="farming:bread 6"},
{chance=70, item="food:cheese 6"},
{chance=80, item="experience:6_exp 2"},
{chance=40, item="potions:magic_replenish1"},
},
walk_chance = 10,
walk_chance = 4,
})

33
mods/quests/chest.lua Executable file
View File

@ -0,0 +1,33 @@
quests.chest = {}
quests.chest.go = function(npc,player)
local inv = player:get_inventory()
local pos = npc.object:getpos()
if inv:contains_item("main","farming:flour") and inv:contains_item("main","food:bowl") then
inv:remove_item("main","farming:flour")
inv:remove_item("main","food:bowl")
chat.local_chat(pos,"'Thank you very much, take this as a token of my appreciation!'",6)
local lp = player:getpos()
local yaw = mobs:face_pos(npc,lp)
local vec = {x=lp.x-pos.x, y=1, z=lp.z-pos.z}
local x = math.sin(yaw) * -2
local z = math.cos(yaw) * 2
local acc = {x=x, y=-5, z=z}
if inv:contains_item("main","default:chest_locked") == false then
default.drop_item(pos,"default:chest_locked",vec,acc)
end
if npc.rewards ~= nil then
print("Get rewards")
for _, r in pairs(npc.rewards) do
print(r.item)
if math.random(0,100) < r.chance then
default.drop_item(pos,r.item, vec, acc)
end
end
end
else
chat.local_chat(pos,"'Can you help me?'",12)
minetest.after(2,chat.local_chat,pos,"'I need to finish my baking but I have ran out of flour and lost my bowl!'",12)
minetest.after(3,chat.local_chat,pos,"'Can you bring me some flour and a bowl?'",12)
end
end

View File

@ -1,4 +1,5 @@
quests = {}
dofile(minetest.get_modpath("quests").."/treasure.lua")
dofile(minetest.get_modpath("quests").."/treasure.lua")
dofile(minetest.get_modpath("quests").."/chest.lua")