Fix various bugs

This commit is contained in:
Hector Franqui 2017-06-17 12:55:50 -04:00
parent fb549e7f93
commit 2530918fe9
4 changed files with 29 additions and 18 deletions

View File

@ -898,7 +898,7 @@ mobs:register_mob("advanced_npc:npc", {
stepheight = 0.6, stepheight = 0.6,
walk_velocity = 1, walk_velocity = 1,
run_velocity = 3, run_velocity = 3,
jump = true, jump = false,
drops = { drops = {
{name = "default:wood", chance = 1, min = 1, max = 3}, {name = "default:wood", chance = 1, min = 1, max = 3},
{name = "default:apple", chance = 2, min = 1, max = 2}, {name = "default:apple", chance = 2, min = 1, max = 2},

View File

@ -57,7 +57,8 @@ npc.relationships.MARRIED_NPC_DIALOGUE = {
response_id = 2, response_id = 2,
action = function(self, player) action = function(self, player)
self.order = "stand" 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 end
}, },
[3] = { [3] = {
@ -66,7 +67,7 @@ npc.relationships.MARRIED_NPC_DIALOGUE = {
response_id = 3, response_id = 3,
action = function(self, player) action = function(self, player)
self.order = "follow" 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 end
} }
} }
@ -114,7 +115,7 @@ function npc.relationships.get_response_for_disliked_item(item_name, sex)
for i = 1, #items do for i = 1, #items do
minetest.log(dump(items[i])) minetest.log(dump(items[i]))
if items[i].item == item_name then 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 return items[i].response
end end
end end
@ -350,16 +351,16 @@ local function show_receive_gift_reaction(self, item_name, modifier, clicker_nam
end end
-- Send message -- Send message
-- TODO: There might be an error with getting the 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 = local message_to_send =
npc.relationships.get_response_for_favorite_item(item_name, self.sex, phase) 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 -- Disliked items reactions
elseif modifier < 0 then elseif modifier < 0 then
effect({x = pos.x, y = pos.y + 1, z = pos.z}, 8, "default_item_smoke.png") 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) 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
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 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 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 return false
end end
@ -392,9 +393,9 @@ function npc.relationships.receive_gift(self, clicker)
npc.relationships.RELATIONSHIP_PHASE["phase5"].limit npc.relationships.RELATIONSHIP_PHASE["phase5"].limit
and self.owner ~= clicker_name and self.owner ~= clicker_name
and item:get_name() ~= "advanced_npc:marriage_ring" then 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") "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") "enough gifts for now. Maybe we should go a step further")
-- Reset gift timer -- Reset gift timer
reset_gift_timer(self, clicker_name) reset_gift_timer(self, clicker_name)
@ -407,7 +408,7 @@ function npc.relationships.receive_gift(self, clicker)
local receive_chance = math.random(1, 10) local receive_chance = math.random(1, 10)
-- Receive ring and get married -- Receive ring and get married
if receive_chance < 6 then 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!") "Oh, oh you make me so happy! Yes! I will marry you!")
-- Get ring -- Get ring
item:take_item() item:take_item()
@ -422,7 +423,7 @@ function npc.relationships.receive_gift(self, clicker)
self.owner = clicker_name self.owner = clicker_name
-- Reject ring for now -- Reject ring for now
else 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...") "Dear, I feel the same as you. But maybe not yet...")
end end
@ -446,7 +447,7 @@ function npc.relationships.receive_gift(self, clicker)
show_receive_gift_reaction(self, item:get_name(), modifier, clicker_name, false) show_receive_gift_reaction(self, item:get_name(), modifier, clicker_name, false)
else else
-- Neutral item reaction -- Neutral item reaction
minetest.chat_send_player(clicker_name, "Thank you honey!") npc.chat(self.npc_name, clicker_name, "Thank you honey!")
end end
-- Take item -- Take item
item:take_item() item:take_item()
@ -480,9 +481,9 @@ function npc.relationships.receive_gift(self, clicker)
-- if 70% -- if 70%
local receive_chance = math.random(1,10) local receive_chance = math.random(1,10)
if receive_chance < 7 then 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 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 take = false
end end
show_reaction = false show_reaction = false
@ -502,7 +503,7 @@ function npc.relationships.receive_gift(self, clicker)
clicker:set_wielded_item(item) clicker:set_wielded_item(item)
end end
minetest.log(dump(self)) npc.log("DEBUG", "NPC: "..dump(self))
-- Reset gift timer -- Reset gift timer
reset_gift_timer(self, clicker_name) reset_gift_timer(self, clicker_name)
return true return true

View File

@ -463,6 +463,10 @@ end
-- Also, the building is scanned for NPC-usable nodes and the amount -- Also, the building is scanned for NPC-usable nodes and the amount
-- of NPCs to spawn and the interval is calculated. -- of NPCs to spawn and the interval is calculated.
function spawner.replace_mg_villages_plotmarker(pos) 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 -- Get the meta at the current position
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local village_id = meta:get_string("village_id") local village_id = meta:get_string("village_id")
@ -525,6 +529,8 @@ function spawner.replace_mg_villages_plotmarker(pos)
child_total = 0 child_total = 0
} }
meta:set_string("npc_stats", minetest.serialize(npc_stats)) meta:set_string("npc_stats", minetest.serialize(npc_stats))
-- Set replaced
meta:set_string("replaced", "true")
-- Stop searching for building type -- Stop searching for building type
break break
@ -618,6 +624,10 @@ if minetest.get_modpath("mg_villages") ~= nil then
chance = 1, --5, chance = 1, --5,
catch_up = true, catch_up = true,
action = function(pos, node, active_object_count, active_object_count_wider) 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 -- Check if replacement is activated
if npc.spawner.replace_activated then if npc.spawner.replace_activated then
-- Replace mg_villages:plotmarker -- Replace mg_villages:plotmarker

Binary file not shown.

Before

Width:  |  Height:  |  Size: 901 B

After

Width:  |  Height:  |  Size: 2.1 KiB