Hello, i've been working on a new system, that let's you create all npc-scripts in just one file.
With this you don't need to create a file for each npc in folder data/npc/scripts...
All npcs will use the same file, but the actions will change of course (transcripts, trade, travel, etc)
Basically, you only need to specify the npc name, outfit and others parameters in the file and then when the server starts, it'll create the npc (Creating the .xml file in folder data/npc) and after creating it, reloading the NPCS and then the new npcs will be added to your server.
This is an example (Using Yasir)
What do you think about something like this?
With this you don't need to create a file for each npc in folder data/npc/scripts...
All npcs will use the same file, but the actions will change of course (transcripts, trade, travel, etc)
Basically, you only need to specify the npc name, outfit and others parameters in the file and then when the server starts, it'll create the npc (Creating the .xml file in folder data/npc) and after creating it, reloading the NPCS and then the new npcs will be added to your server.
This is an example (Using Yasir)
Lua:
Yasir = Npc:new("Yasir")
Yasir.type = 146
Yasir.head = 85
Yasir.body = 7
Yasir.legs = 12
Yasir.feet = 19
Yasir.addons = 2
Yasir.walkinterval = 4000
Yasir.speed = 100
Yasir.floorchange = 0
Yasir.access = 3
Yasir.healthnow = 300
Yasir.healthmax = 300
Yasir.MESSAGE_GREET = "Yasu me halaka. <greets you friendly>"
Yasir.MESSAGE_FAREWELL = "Si, jema ze harun. <waves>"
Yasir:setTradeList(YasirTrade)
Yasir:onSell(function (cid, item, subType, amount)
local shop = {}
for _, it in ipairs(Yasir.tradelist) do
shop[it.id] = {sell = it.sell, name = (it.name or getItemNameById(it.id))}
end
if getPlayerItemCount(cid, item) >= amount and doPlayerRemoveItem(cid, item, amount) then
doPlayerAddMoney(cid, amount * shop[item].sell)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sold x" .. amount .. " " .. shop[item].name .. " for " .. shop[item].sell * amount .. " gold.")
else
return doPlayerSendCancel(cid, "You do not have that item.")
end
end)
Yasir.onThink = function(npc)
return doCreatureSay(npc, "Thinking!", TALKTYPE_SAY) --Example
end
Yasir.onThinkInterval = 30
int = Behaviour:new()
int.words = {"trade", "ariki"}
int.response = "Si! Haneka ariki!"
int.action = function (cid, type, msg)
if doPlayerAddAchievement then
doPlayerAddAchievement(cid, "Si, Ariki!", true)
end
openShopWindow(cid, Yasir.tradelist, Yasir.onBuy, Yasir.onSell)
end
Yasir:addBehaviour(int)
int = Behaviour:new()
int.words = {"name"}
int.response = "Me Yasir." --or you can use "Me $npcname."
int.npcChannel = true
Yasir:addBehaviour(int)
int = Behaviour:new()
int.words = {"job"}
int.response = "Tje hari ku ne finjala. {Ariki}?"
Yasir:addBehaviour(int)
int = Behaviour:new()
int.words = {"passage"}
int.response = "Soso yana. <shakes his head>"
Yasir:addBehaviour(int)
int = Behaviour:new()
int.words = {"my name"}
int.response = "Your name is $playername and my name is $this.name" --Testing some format-variables (Can use |NPCNAME|, $npcname and $this.name)
Yasir:addBehaviour(int)
Yasir:print() ---Creates npc and reloads the server
What do you think about something like this?
Last edited: