• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OpenTibia New NPC System

Nostradamus

Member
Joined
Jun 2, 2007
Messages
219
Reaction score
6
Hello, i am Nostradamus, a not-so-old official OpenTibia developer and i am back into this project. As my first service after my leave, i am doing a NPC system to Avesta. But, i will need some help for something like suggestions and etc. Since i don't have much time to dedicate in OpenTibia currently, i will be accept code improvements or maybe functions already done.

Roadmap

  1. Debugger Strackback (configurable tables and advanced error reporting)
  2. onTalk event with dynamic uses of talkstates and so on (sub-talkstates will be sub-arrays of the main talkstate refered to it, messages will be handled into arrays with the input and output of the NPC (message and answer subarrays)
  3. Function to list buying/selling items, teleport places and spells with filders (type of the item -> new element in array (optional): type)
  4. Easy module integration
  5. Improve Buy/Sell functions to accept containers with items
  6. End the usage using a garbage collector
  7. Messages with delay if the lenght is too big
  8. Separates modules and handler to waste less memory
  9. ratePrice should be later a global const for anything who uses money transaction
  10. Possibility to use XML file or Lua Extras
  11. OnAccept and OnDecline events
  12. Long messages splited into short messages with talk delay

Modules
  1. Promote
  2. Premium
  3. Blessing
  4. Addon
  5. Quest
  6. Bank
Notes

Ignore the returns types, after i hope all will understand why
Since this script uses object orientation with a default class, there isn't reasons to make conditions considering if there is or not a value, since it will always be called when executing this script. The array "NPC" is a global array that will handle with all NPC scripts and with all the functions of that class.

Strucuture

  • Modules (travel, shop, spell, ...)
  • Auxiliar functions (functions used by all the script)
  • Core (handler of all the system, it will call all the modules, functions, consts)
  • Config (a file to configure some uses, later, it will have some options as extras for Forgotten and the usage of LuaSQL)

NPC Example

Code:
-- Start NPC!
NPC = NPC:new()

function onCreatureAppear(cid) 
    -- soon    
end

function onThink()
    -- soon
end

function onCreatureDisappear(cid) 
    -- soon
end

function onCreatureSay(cid, type, msg)        
    -- soon
end

-- Shop example

John = Shop:new(
                    BUY_LIST =
                    {
                        ["item_name"] = {id = , price = , count = }
                    }
                )
                
-- Dialog example

Dialog = Say:new(
                    [1] = {{"hi", "hello"}, "hello, my friend"},
                    [2] = {"use function", useFunction()},
                    [3] = {"msg with delay", {"msg1", "msg2", "msg3"}, delay = 2000},
                )
                
-- Travel example

Midas = Travel:new(
                        TRAVEL_LIST =
                        {
                            ["Thais"] = {price = 100, pos = {x = 100, y = 200, z = 7}, premium = true}
                            ["Edron"] = {price = 150, pos = {x = 200, y = 100, z = 7}, premium = false}
                        }
                        
-- Quest example

Terry = Quest:new(
                        ["Warlock quest"] = {recipe = {{1234, 1}, {2312, 1}}, award = {{1254, 1}, {1256, 1}}}
                )

Who wants to help, i will be giving some access to my SVN server to commit changes.

SVN Link

svn://darghos.com/svn_root/data/branches/revnpcsys/

User: revnpcsys
Pass: 123

P.S: I hope that here there isn't a funny boy to suck the script.
P.S 2: Please put your nickname in the commit to me see who is the contribuitor
 
Last edited:
LuaSQL has been deprecated.
Also, I don't like the idea of placing everything in Lua. Sadly, but I prefer alot more the current available XML modules as buy/travel.
 
@Elf

LuaSQL has been deprecated.

Really? So what it is using for? I don`t no much about Forgotten news since i were inactive.

Also, I don't like the idea of placing everything in Lua. Sadly, but I prefer alot more the current available XML modules as buy/travel.

I saw that today, well, personaly, i did not liked. Did not saw the code, but maybe this parse should use more memory. XML files (spells.xml, name-of-your-npc.xml, ...) will be deprecated in revscriptsys)
 
@Rizz

User: revnpcsys
Pass: 123

I`ve changed and just forgot to edit topic
 
Last edited:
Back
Top