From 2530918fe9ccd359ef7aae1e40e79a9b783888d7 Mon Sep 17 00:00:00 2001 From: Hector Franqui Date: Sat, 17 Jun 2017 12:55:50 -0400 Subject: [PATCH] Fix various bugs --- npc.lua | 2 +- relationships.lua | 33 +++++++++++++++++---------------- spawner.lua | 12 +++++++++++- textures/npc_baby_male1.png | Bin 901 -> 2189 bytes 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/npc.lua b/npc.lua index 3d3de28..9e230e8 100755 --- a/npc.lua +++ b/npc.lua @@ -898,7 +898,7 @@ mobs:register_mob("advanced_npc:npc", { stepheight = 0.6, walk_velocity = 1, run_velocity = 3, - jump = true, + jump = false, drops = { {name = "default:wood", chance = 1, min = 1, max = 3}, {name = "default:apple", chance = 2, min = 1, max = 2}, diff --git a/relationships.lua b/relationships.lua index f924f46..d4dd02f 100644 --- a/relationships.lua +++ b/relationships.lua @@ -57,7 +57,8 @@ npc.relationships.MARRIED_NPC_DIALOGUE = { response_id = 2, action = function(self, player) self.order = "stand" - minetest.chat_send_player(player:get_player_name(), S("Ok dear, I will wait here for you.")) + npc.chat(self.npc_name, player:get_player_name(), + S("Ok dear, I will wait here for you.")) end }, [3] = { @@ -66,7 +67,7 @@ npc.relationships.MARRIED_NPC_DIALOGUE = { response_id = 3, action = function(self, player) self.order = "follow" - minetest.chat_send_player(player:get_player_name(), S("Ok, let's go!")) + npc.chat(self.npc_name, player:get_player_name(), S("Ok, let's go!")) end } } @@ -114,7 +115,7 @@ function npc.relationships.get_response_for_disliked_item(item_name, sex) for i = 1, #items do minetest.log(dump(items[i])) if items[i].item == item_name then - minetest.log("Returning: "..dump(items[i].response)) + --minetest.log("Returning: "..dump(items[i].response)) return items[i].response end end @@ -350,16 +351,16 @@ local function show_receive_gift_reaction(self, item_name, modifier, clicker_nam end -- Send message -- TODO: There might be an error with getting the message... - minetest.log("Item_name: "..dump(item_name)..", sex: "..dump(self.sex)..", phase: "..dump(phase)) + --minetest.log("Item_name: "..dump(item_name)..", sex: "..dump(self.sex)..", phase: "..dump(phase)) local message_to_send = npc.relationships.get_response_for_favorite_item(item_name, self.sex, phase) - minetest.chat_send_player(clicker_name, message_to_send) + npc.chat(self.npc_name, clicker_name, message_to_send) -- Disliked items reactions elseif modifier < 0 then effect({x = pos.x, y = pos.y + 1, z = pos.z}, 8, "default_item_smoke.png") - minetest.log("Item name: "..item_name..", sex: "..self.sex) + --minetest.log("Item name: "..item_name..", sex: "..self.sex) local message_to_send = npc.relationships.get_response_for_disliked_item(item_name, self.sex) - minetest.chat_send_player(clicker_name, message_to_send) + npc.name(self.npc_name, clicker_name, message_to_send) end end @@ -381,7 +382,7 @@ function npc.relationships.receive_gift(self, clicker) -- If NPC received a gift from this person, then reject any more gifts for now if check_npc_can_receive_gift(self, clicker_name) == false then - minetest.chat_send_player(clicker_name, "Thanks, but I don't need anything for now") + npc.chat(self.npc_name, clicker_name, "Thanks, but I don't need anything for now") return false end @@ -392,9 +393,9 @@ function npc.relationships.receive_gift(self, clicker) npc.relationships.RELATIONSHIP_PHASE["phase5"].limit and self.owner ~= clicker_name and item:get_name() ~= "advanced_npc:marriage_ring" then - minetest.chat_send_player(clicker_name, + npc.chat(self.npc_name, clicker_name, "Thank you my love, but I think that you have given me") - minetest.chat_send_player(clicker_name, + npc.chat(self.npc_name, clicker_name, "enough gifts for now. Maybe we should go a step further") -- Reset gift timer reset_gift_timer(self, clicker_name) @@ -407,7 +408,7 @@ function npc.relationships.receive_gift(self, clicker) local receive_chance = math.random(1, 10) -- Receive ring and get married if receive_chance < 6 then - minetest.chat_send_player(clicker_name, + npc.chat(self.npc_name, clicker_name, "Oh, oh you make me so happy! Yes! I will marry you!") -- Get ring item:take_item() @@ -422,7 +423,7 @@ function npc.relationships.receive_gift(self, clicker) self.owner = clicker_name -- Reject ring for now else - minetest.chat_send_player(clicker_name, + npc.chat(self.npc_name, clicker_name, "Dear, I feel the same as you. But maybe not yet...") end @@ -446,7 +447,7 @@ function npc.relationships.receive_gift(self, clicker) show_receive_gift_reaction(self, item:get_name(), modifier, clicker_name, false) else -- Neutral item reaction - minetest.chat_send_player(clicker_name, "Thank you honey!") + npc.chat(self.npc_name, clicker_name, "Thank you honey!") end -- Take item item:take_item() @@ -480,9 +481,9 @@ function npc.relationships.receive_gift(self, clicker) -- if 70% local receive_chance = math.random(1,10) if receive_chance < 7 then - minetest.chat_send_player(clicker_name, "Thanks. I will find some use for this.") + npc.chat(self.npc_name, clicker_name, "Thanks. I will find some use for this.") else - minetest.chat_send_player(clicker_name, "Thank you, but no, I have no use for this.") + npc.chat(self.npc_name, clicker_name, "Thank you, but no, I have no use for this.") take = false end show_reaction = false @@ -502,7 +503,7 @@ function npc.relationships.receive_gift(self, clicker) clicker:set_wielded_item(item) end - minetest.log(dump(self)) + npc.log("DEBUG", "NPC: "..dump(self)) -- Reset gift timer reset_gift_timer(self, clicker_name) return true diff --git a/spawner.lua b/spawner.lua index f6a4ae3..2c7fb9a 100644 --- a/spawner.lua +++ b/spawner.lua @@ -463,6 +463,10 @@ end -- Also, the building is scanned for NPC-usable nodes and the amount -- of NPCs to spawn and the interval is calculated. function spawner.replace_mg_villages_plotmarker(pos) + -- Check if it is already replaced + -- if minetest.get_node(pos).name == "advanced_npc:plotmarker_auto_spawner" then + -- return + -- end -- Get the meta at the current position local meta = minetest.get_meta(pos) local village_id = meta:get_string("village_id") @@ -471,7 +475,7 @@ function spawner.replace_mg_villages_plotmarker(pos) -- Following line from mg_villages mod, protection.lua local btype = mg_villages.all_villages[village_id].to_add_data.bpos[plot_nr].btype local building_data = mg_villages.BUILDINGS[btype] - local building_type = building_data.typ + local building_type = building_data.typ -- Check if the building is of the support types for _,value in pairs(npc.spawner.mg_villages_supported_building_types) do @@ -525,6 +529,8 @@ function spawner.replace_mg_villages_plotmarker(pos) child_total = 0 } meta:set_string("npc_stats", minetest.serialize(npc_stats)) + -- Set replaced + meta:set_string("replaced", "true") -- Stop searching for building type break @@ -618,6 +624,10 @@ if minetest.get_modpath("mg_villages") ~= nil then chance = 1, --5, catch_up = true, action = function(pos, node, active_object_count, active_object_count_wider) + -- Check if replacement is needed + if minetest.get_meta(pos):get_string("replaced") == "true" then + return + end -- Check if replacement is activated if npc.spawner.replace_activated then -- Replace mg_villages:plotmarker diff --git a/textures/npc_baby_male1.png b/textures/npc_baby_male1.png index 93563989580324581cac10eaa5a91c427eaac724..9d56a1d34422a1c267d0b047119c65adcc77c731 100755 GIT binary patch delta 2188 zcmV;72y^#^2aOSs8Gi-<005$$euMx300eVFNmK|32nc)#WQYI&2t-LlK~!jg&6!PX zTvrvxe>2bTbNuGR9@}b~I3!R+NE9Ji0f|UmM6h6iDj`)7o2G(ABege8d&cu--lv|2#eaSG&3iMG87FoNN3!0% z_ndp)Isbdkx#x`wOrZB(f2AkKhM@!C`@u-rQTz+fUn@*{$2ht)LvPguFNTu_g!^KB zD-`ov4u{fTJgA^_Zg6~1{^QbZ2aJrB)2jG;LW4E`@cIt~fON<-E0|^_w{{TzQP2~b zIQ>Qlt6i~n-hV#4-iZKYox@PUP;*XB;vbew1X z_xDBag8=5RG!Xz<&^&Js{0RI=j1%4@{$c5uCZ1a%XozCC<_i!$vl@_fa+GtE_=h2- zC{F!s33j9Y>9=E%9*3m^r@$zOABF$8wBd_W-;F>k!hd!o)|=7M=r0`hoJ*T>de7p}~iL z{sRDCdFCoXug;z2pY=~+%>Hrwb}T~lomRi4-GAUYPp(*{F!^kww z@&5loA7B(9jE`P#O%=MO{*wkwE8zD;SLwy@k)IU7Q6UNphj6Vf_|3*>{-pgQ_&@mJ zHCDSKtdA0aC7WJFg}q3mLo*VfG$R3k--8pf2p;sFzqw^|bIX1x|8e>RvnUKZYO1L4 zAb${{pAGx-wkVLzNbsk!MvlA2d_Q2x_;@UT(*9BW+s@H6G=p^85znVe;(0c?KI8rV zC$&~&IP6~d*4KLgeh}b|(+j=dn@jrZ=14b>}`mU`K_)L~gByUiAco`8_(1h6$F zUH|nPe;up;Czrp`yWe()_RDu&zxj_xN`IxP!394E`1jl;08FdI`a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