First of all you need to create a new monster.
I will show you an example on how it should look like:
Code: Select all
cloneObject{
name = "npcGoromorg",
baseObject = "goromorg",
evasion = 100000,
onAttack = function(self, dir)
return false
end,
onMove = function(self, dir)
return false
end,
}
Then just place the NPC anywhere into your dungeon.
The next things are optional!
I used this NPC to create an merchant so I created 2 alcoves and a button.
One is for the offer and the other one is for the item which you will get.
Then I wrote a short lua script and connected the checkAlcoveForItems() function with the button (most of it was already done by other persons)
Code: Select all
-- Optional I justed wanted a little bit of dialogue :)
traded = false
function Merchant1()
if traded == false then
hudPrint("Hello traveler!")
hudPrint("I'm a merchant and I would really like to trade with you.")
hudPrint("If you give me your torch I will give you nice loot!")
else
hudPrint("At the moment I have nothing to offer")
end
end
function checkAlcoveForItems()
-- Offer
local itemName = "torch_everburning"
-- offer alcove
local alcoveID = alcove_offer
-- checks if the offer alcove has an item
if alcoveID:getItemCount() == 0 then
hudPrint("First you have to place an item into the alcove!")
end
-- checks if the offer is equal to the item you want
for i in alcoveID:containedItems() do
if i.name == itemName then
hudPrint("The trade was successful!")
-- spawns the item which you will get
alcove_win:addItem(spawn("boots_valor"))
-- spawns a secret door in front of the offer alcove so that you cant get the offer back
spawn("dungeon_secret_door", party.level, 14, 14, 0)
traded = true
else
hudPrint("The trade was not successful!")
end
end
end
DONE!
Here is a little map I made to show you how it works:
https://rapidshare.com/files/865757490/Npcs.rar