Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Revscriptsys] RevNpcSys version 1.0 (lua npcs / NpcType / new npc system) #4671

Merged
merged 52 commits into from
May 30, 2024

Commits on Apr 30, 2024

  1. lua Npc's

    - adding lua npcs handling
    EvilHero90 committed Apr 30, 2024
    Configuration menu
    Copy the full SHA
    5539c3f View commit details
    Browse the repository at this point in the history
  2. tree handling talkstate

    - tree handling talkstates
    - a few bugfixes and corrections
    EvilHero90 committed Apr 30, 2024
    Configuration menu
    Copy the full SHA
    1c181d5 View commit details
    Browse the repository at this point in the history

Commits on May 1, 2024

  1. Configuration menu
    Copy the full SHA
    860580e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7814076 View commit details
    Browse the repository at this point in the history
  3. added callback

    - added callbacks to keywords
    EvilHero90 committed May 1, 2024
    Configuration menu
    Copy the full SHA
    ad194ec View commit details
    Browse the repository at this point in the history
  4. requirements

    - adding storagevalue requirements for easy checks with failure respond function
    EvilHero90 committed May 1, 2024
    Configuration menu
    Copy the full SHA
    30ea721 View commit details
    Browse the repository at this point in the history

Commits on May 2, 2024

  1. documentation and splitting in files

    - added documentation and annotations
    - split all the functions in different files for better overview and organization
    EvilHero90 committed May 2, 2024
    Configuration menu
    Copy the full SHA
    e2aa611 View commit details
    Browse the repository at this point in the history
  2. optimizations & better documentation

    - if you add a callback to a keyword it can return false and also return a string for the failure respond message
    - changed order of calling functions in events
    1) checks callback
    2) checks requirements
    3) opens shop
    now we are not opening shop even tho requirements or callback was not correct
    - added an example usage of callback in handler.lua
    - corrections in documentation
    EvilHero90 committed May 2, 2024
    Configuration menu
    Copy the full SHA
    cb5d1da View commit details
    Browse the repository at this point in the history

Commits on May 3, 2024

  1. requirements, modules & documentation

    - constants.lua
    adding more messages to MESSAGE_LIST
    - events.lua
    fixing a problem where the player could say keywords without greeting the npc first
    added requirements
    added a `help` default keyword, which will tell the player to which keywords the npc responds
    - general better documentation
    - added modules.lua
    - added requirements.lua
    - added a test example npc data/npc/lua/#test.lua
    EvilHero90 committed May 3, 2024
    Configuration menu
    Copy the full SHA
    226419c View commit details
    Browse the repository at this point in the history
  2. remove unused function & other improvements

    - removed `requireStorage` it's redundant as we have the same in requirements
    - renamed
    `setGreetRespond` -> `setGreetResponse`
    `setFarewellRespnd` -> `setFarewellResponse`
    - added
    `setGreetKeywords`
    `setFarewellKeywords`
    EvilHero90 committed May 3, 2024
    Configuration menu
    Copy the full SHA
    d004a07 View commit details
    Browse the repository at this point in the history

Commits on May 4, 2024

  1. annotations

    - fixed annotations
    EvilHero90 committed May 4, 2024
    Configuration menu
    Copy the full SHA
    d788476 View commit details
    Browse the repository at this point in the history

Commits on May 5, 2024

  1. Configuration menu
    Copy the full SHA
    eac6ea2 View commit details
    Browse the repository at this point in the history
  2. annotation fixes

    EvilHero90 committed May 5, 2024
    Configuration menu
    Copy the full SHA
    683b96b View commit details
    Browse the repository at this point in the history

Commits on May 6, 2024

  1. NpcType class

    - moved everything to NpcType
    - we don't create a NpcScriptInterface per npc created rather just load it by each NpcType
    -
    EvilHero90 committed May 6, 2024
    Configuration menu
    Copy the full SHA
    81fc9f3 View commit details
    Browse the repository at this point in the history

Commits on May 7, 2024

  1. improvements

    - we are sharing one NpcScriptInterface instead of creating one for each npc
    EvilHero90 committed May 7, 2024
    Configuration menu
    Copy the full SHA
    7b15f62 View commit details
    Browse the repository at this point in the history
  2. ~NpcEventsHandler()

    forgot to include
    
    Co-Authored-By: Sarah Wesker <sarahelizabetwesker@gmail.com>
    EvilHero90 and MillhioreBT committed May 7, 2024
    Configuration menu
    Copy the full SHA
    fe9fb0f View commit details
    Browse the repository at this point in the history
  3. clang

    the usual
    EvilHero90 committed May 7, 2024
    Configuration menu
    Copy the full SHA
    d45354c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    29a4605 View commit details
    Browse the repository at this point in the history
  5. improvements on keywords & responses

    - `keyword` and `respond` support now multiple inserts via table
    - if there is multiple keywords for the same outcome we just point to one metatable instead of creating several (memory efficient)
    EvilHero90 committed May 7, 2024
    Configuration menu
    Copy the full SHA
    ea11545 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    5acc33f View commit details
    Browse the repository at this point in the history
  7. added the missing events & callbacks

    - made all the get functions of `NpcType` into const
    - added `NpcType.onMove`,`NpcType.onPlayerCloseChannel` and `NpcType.onPlayerEndTrade` with their callback functions
    - correction for lua npcs at ~NpcEventsHandler() which caused them to have no scripting interface when an npc was removed and respawned
    EvilHero90 committed May 7, 2024
    Configuration menu
    Copy the full SHA
    ffa54e8 View commit details
    Browse the repository at this point in the history

Commits on May 8, 2024

  1. shop works with item name aswell

    - you can now use item names aswell for shop items
    EvilHero90 committed May 8, 2024
    Configuration menu
    Copy the full SHA
    df23ff9 View commit details
    Browse the repository at this point in the history
  2. error handling for shop items

    - we are sending errors in console if the item does not exist or if it doesn't have the property to be able to pick it up
    EvilHero90 committed May 8, 2024
    Configuration menu
    Copy the full SHA
    4467f40 View commit details
    Browse the repository at this point in the history

Commits on May 11, 2024

  1. more functionality and slight fixes

    - adding `NpcsHandler:farewell()` function to release focus on yourself on certain keywords.
    - fixed correct order of trying to get a failureResponse when working with callbacks
    - shows an error message if there is no set failureResponse
    EvilHero90 committed May 11, 2024
    Configuration menu
    Copy the full SHA
    477731a View commit details
    Browse the repository at this point in the history
  2. spelling mistake

    EvilHero90 committed May 11, 2024
    Configuration menu
    Copy the full SHA
    4824668 View commit details
    Browse the repository at this point in the history
  3. changing pointers from shared_ptr to unique_ptr

    - changing npcEventHandler shared_ptr to unique_ptr
    EvilHero90 committed May 11, 2024
    Configuration menu
    Copy the full SHA
    3b85b28 View commit details
    Browse the repository at this point in the history

Commits on May 12, 2024

  1. added NpcVoices & few other things

    - we can now add voices that the npc randomly talk or yell certain phrases
    - callback now when returning true can also directly return the message the npc shall respond with, if it's left empty or nil it'll fall back to the default respond message
    - few spelling fixes removeFocus -> releaseFocus
    - added NpcHandler:farewell() & NpcHandler:talk(table) functions
    EvilHero90 committed May 12, 2024
    Configuration menu
    Copy the full SHA
    bf967d4 View commit details
    Browse the repository at this point in the history
  2. sub-keywords

    - we are now able to set sub-keywords onto keywords which are triggered by storagevalues, if the player has the required storagevalue it'll move the talkState onto the sub-keyword instead of staying on the normal keyword
    - I've also changed the check order, requirements are now first load and then everything else gets executed if the check was good, if not we do an early return
    EvilHero90 committed May 12, 2024
    Configuration menu
    Copy the full SHA
    b580581 View commit details
    Browse the repository at this point in the history

Commits on May 13, 2024

  1. re work on requirements

    - we check storage/level now with string operators ">=,==,<=,<,>" in requirements
    - we can set now custom failureRespond messages for requirements ex: failureRespond(REQUIREMENTS.storage, "I don't talk to normal people") this message would appear now if storage requirements are not met
    - added REQUIREMENTS to constants.lua
    - added NpcsHandler:setStorageValue(key, value)
    EvilHero90 committed May 13, 2024
    Configuration menu
    Copy the full SHA
    69cd124 View commit details
    Browse the repository at this point in the history
  2. greeting re work

    We now have to handle greeting with keywords, this decision was made due to npcs giving different respond greetings depending on storage values, that's why I moved the entire logic into keywords now
    EvilHero90 committed May 13, 2024
    Configuration menu
    Copy the full SHA
    de5c7bc View commit details
    Browse the repository at this point in the history

Commits on May 15, 2024

  1. code cleanup & keyword fix

    - removed `__index` from keywords table, as we don't need it for that metatable
    - added `NpcsHandler:onCheckStorage` to erase some repetitive code
    EvilHero90 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    c74fb12 View commit details
    Browse the repository at this point in the history
  2. adding onAnswer() & money transfer dupe

    - onAnswer() can be used to get an answer from a player which doesn't match a keyword (transfer/deposit on a banker npc) it requires always to have a callback or it'll throw a warning message
    - added answer functions (add/get/reset)
    - fixed a bug when player transfers money to another player and the server would crash it would duplicate the money
    EvilHero90 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    b629df4 View commit details
    Browse the repository at this point in the history
  3. check for answer

    We don't reset the talkState if there is an onAnswer on this talkState
    EvilHero90 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    2b71c28 View commit details
    Browse the repository at this point in the history

Commits on May 16, 2024

  1. renamed get/add/reset answers into data

    getAnswers -> getAllData
    getAnswer -> getData
    addAnswer -> addData
    resetAnswers -> resetData
    I've also fixed the travel module and added the greet keywords
    EvilHero90 committed May 16, 2024
    Configuration menu
    Copy the full SHA
    8dae802 View commit details
    Browse the repository at this point in the history
  2. code cleanup

    - removing npc:spawn() it's redundant
    - forgot to change one shared_ptr to unique_ptr
    EvilHero90 committed May 16, 2024
    Configuration menu
    Copy the full SHA
    eba30a3 View commit details
    Browse the repository at this point in the history
  3. clang

    EvilHero90 committed May 16, 2024
    Configuration menu
    Copy the full SHA
    17d11e0 View commit details
    Browse the repository at this point in the history

Commits on May 19, 2024

  1. Update modules.lua

    EvilHero90 committed May 19, 2024
    Configuration menu
    Copy the full SHA
    37be7c5 View commit details
    Browse the repository at this point in the history
  2. idle rework

    We are now checking if npc is idle before we execute onThink this decreases cpu usage quite a lot, therefore the spectator range has been increased that the npc goes out of idle once a player is in yell range
    EvilHero90 committed May 19, 2024
    Configuration menu
    Copy the full SHA
    331e15e View commit details
    Browse the repository at this point in the history
  3. slight optimizations

    - added inline constexpr for the Viewport calculation (can be evaluated once at compile time)
    - removed the non necessary declarations which thrown compile errors
    EvilHero90 committed May 19, 2024
    Configuration menu
    Copy the full SHA
    42b6302 View commit details
    Browse the repository at this point in the history

Commits on May 21, 2024

  1. adding resetData where needed

    - now players data gets properly erased once the player leaves the conversation with the npc
    EvilHero90 committed May 21, 2024
    Configuration menu
    Copy the full SHA
    f82770e View commit details
    Browse the repository at this point in the history

Commits on May 23, 2024

  1. reworked NpcType class

    - removed info struct and moved everything to public
    EvilHero90 committed May 23, 2024
    Configuration menu
    Copy the full SHA
    cbfe62c View commit details
    Browse the repository at this point in the history
  2. improvement on voices

    - delay is now global and was removed out of the voices table, default delay is 30s and the delay can be set at handler:talk(voices, delay)
    - we check now if the voice it wants to say is the same as the last voice and then roll again until it finds another one if there are several to choose from
    EvilHero90 committed May 23, 2024
    Configuration menu
    Copy the full SHA
    75d3c85 View commit details
    Browse the repository at this point in the history

Commits on May 24, 2024

  1. syncing players money on transfer

    This now saves the player who was sending the money regardless if the receiver is online/offline and does a db query for the receiver to keep the bank balance in sync
    EvilHero90 committed May 24, 2024
    Configuration menu
    Copy the full SHA
    53dbb16 View commit details
    Browse the repository at this point in the history

Commits on May 26, 2024

  1. renaming folder

    renaming folder from evilnpcsystem to revnpcsys
    EvilHero90 committed May 26, 2024
    Configuration menu
    Copy the full SHA
    e6a1c43 View commit details
    Browse the repository at this point in the history

Commits on May 27, 2024

  1. Configuration menu
    Copy the full SHA
    4a409f6 View commit details
    Browse the repository at this point in the history
  2. merging conflicts

    EvilHero90 committed May 27, 2024
    Configuration menu
    Copy the full SHA
    ab9c994 View commit details
    Browse the repository at this point in the history
  3. another merging conflict

    EvilHero90 committed May 27, 2024
    Configuration menu
    Copy the full SHA
    a3a3e66 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    21ad5bf View commit details
    Browse the repository at this point in the history
  5. correcting parameters in onMove

    Co-Authored-By: Sarah Wesker <sarahelizabetwesker@gmail.com>
    EvilHero90 and MillhioreBT committed May 27, 2024
    Configuration menu
    Copy the full SHA
    80a793c View commit details
    Browse the repository at this point in the history
  6. NpcFocus fix

    The npc was not correctly focusing players when they talked to him, this bug is now fixed.
    
    Co-Authored-By: Sarah Wesker <sarahelizabetwesker@gmail.com>
    EvilHero90 and MillhioreBT committed May 27, 2024
    Configuration menu
    Copy the full SHA
    ff98732 View commit details
    Browse the repository at this point in the history

Commits on May 28, 2024

  1. adding vocation requirements

    now you can check in requirements for certain vocations in order to pass
    EvilHero90 committed May 28, 2024
    Configuration menu
    Copy the full SHA
    0e4362b View commit details
    Browse the repository at this point in the history

Commits on May 29, 2024

  1. final version 1.0 commit

    - added some linter corrections and additions
    - changed player:getItemCount(id, subType) -> player:getItemCount(id, subType, ignoreEquipped) that way we can exclude equipped items or not
    - added NpcsHandler:addItems(table--[[,container, inbox]])
    we can add a table of items with that, if the player doesn't have enough space or capacity then the items will be send to inbox
    - added Player.sendInboxItems(self, items, containerId)
    - re worked onStorageValue callback
    we can now set a "range" with ex:
    onStorageValue(1, ">", 10, "<")
    - re worked requirements (level & storagevalue) checks, they accept now ranged checks aswell
    level(1, ">=", 9, "<=")
    storage(10, ">", 50, "<")
    - changed NpcsHandler:teleport(pos) -> NpcsHandler:teleport(pos, magicEffectFromPos, magicEffectToPos)
    default is CONST_ME_TELEPORT
    - added NpcType:health(...) & NpcType:maxHealth(...) functions
    -added NpcRequirements:items(table) & NpcRequirements:removeItems(table)
    - added some stuff in constants.lua
    EvilHero90 committed May 29, 2024
    Configuration menu
    Copy the full SHA
    cc3b704 View commit details
    Browse the repository at this point in the history