NPCs: Now spawn with 1 or 2 items from the favorite items list.
Trade: Added dialogues for buys and sells for casual trading. Dialogues: Added a 30% chance for NPC to make a trade offer. Trade: Trade offers WIP.
This commit is contained in:
@ -6,6 +6,42 @@ npc.trade.CASUAL = "casual"
|
||||
npc.trade.TRADER = "trader"
|
||||
npc.trade.NONE = "none"
|
||||
|
||||
npc.trade.OFFER_BUY = "buy"
|
||||
npc.trade.OFFER_SELL = "sell"
|
||||
|
||||
-- Casual trader NPC dialogues definition
|
||||
-- Casual buyer
|
||||
npc.trade.CASUAL_TRADE_BUY_DIALOGUE = {
|
||||
text = "I'm looking to buy some items, are you interested?",
|
||||
casual_trade_type = npc.trade.OFFER_BUY,
|
||||
responses = {
|
||||
[1] = {
|
||||
text = "Yes, let's see what are you looking for",
|
||||
action_type = "function",
|
||||
response_id = 1,
|
||||
action = function(self, player)
|
||||
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- Casual seller
|
||||
npc.trade.CASUAL_TRADE_SELL_DIALOGUE = {
|
||||
text = "I have some items to sell, are you interested?",
|
||||
casual_trade_type = npc.trade.OFFER_SELL,
|
||||
responses = {
|
||||
[1] = {
|
||||
text = "Yes, let's see what you have",
|
||||
action_type = "function",
|
||||
response_id = 1,
|
||||
action = function(self, player)
|
||||
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function npc.trade.get_random_trade_status()
|
||||
local chance = math.random(1,10)
|
||||
|
||||
@ -19,4 +55,20 @@ function npc.trade.get_random_trade_status()
|
||||
-- Trader by profession
|
||||
return npc.trade.TRADER
|
||||
end
|
||||
end
|
||||
|
||||
-- This function will return an offer object, based
|
||||
-- on the items the NPC has.
|
||||
-- Criteria: If having a near empty inventory, (< 6) NPC
|
||||
-- will offer to buy with a 70% chance.
|
||||
-- If NPC has a near full inventory (> 10 items), NPC
|
||||
-- will offer to sell. The prices will be selected using:
|
||||
-- item_price * (+/- price_item * 0.2) so item will be
|
||||
-- more or less 20% of the item price.
|
||||
function npc.trade.get_casual_trade_offer(self)
|
||||
return {
|
||||
offer_type = npc.trade.OFFER_BUY,
|
||||
item = "default:wooden_planks 10",
|
||||
price = "default:iron_lump 20"
|
||||
}
|
||||
end
|
Reference in New Issue
Block a user