From cd4d40fda479ca7549b18a7132bdc9265f25e36d Mon Sep 17 00:00:00 2001 From: Brandon Date: Sat, 11 Jul 2015 14:58:05 -0500 Subject: [PATCH] Add new quest --- mods/mobs/api.lua | 2 +- mods/mobs/depends.txt | 3 ++- mods/mobs/npcs/women.lua | 11 ++++++----- mods/quests/chest.lua | 33 +++++++++++++++++++++++++++++++++ mods/quests/init.lua | 3 ++- 5 files changed, 44 insertions(+), 8 deletions(-) create mode 100755 mods/quests/chest.lua diff --git a/mods/mobs/api.lua b/mods/mobs/api.lua index 8ea3a6d..3e1452e 100755 --- a/mods/mobs/api.lua +++ b/mods/mobs/api.lua @@ -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() diff --git a/mods/mobs/depends.txt b/mods/mobs/depends.txt index c2ded0b..14416ce 100755 --- a/mods/mobs/depends.txt +++ b/mods/mobs/depends.txt @@ -1,4 +1,5 @@ default fire cottages? -throwing? \ No newline at end of file +throwing? +quests? \ No newline at end of file diff --git a/mods/mobs/npcs/women.lua b/mods/mobs/npcs/women.lua index 2f880ac..248e45b 100755 --- a/mods/mobs/npcs/women.lua +++ b/mods/mobs/npcs/women.lua @@ -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, }) diff --git a/mods/quests/chest.lua b/mods/quests/chest.lua new file mode 100755 index 0000000..ca73a73 --- /dev/null +++ b/mods/quests/chest.lua @@ -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 \ No newline at end of file diff --git a/mods/quests/init.lua b/mods/quests/init.lua index 6991924..c7d5b1f 100755 --- a/mods/quests/init.lua +++ b/mods/quests/init.lua @@ -1,4 +1,5 @@ quests = {} -dofile(minetest.get_modpath("quests").."/treasure.lua") \ No newline at end of file +dofile(minetest.get_modpath("quests").."/treasure.lua") +dofile(minetest.get_modpath("quests").."/chest.lua") \ No newline at end of file