Custom Script - NPC adding levels menu

User Tag List

Results 1 to 4 of 4
  1. #1
    MrTajoli's Avatar Member
    Reputation
    1
    Join Date
    Nov 2022
    Posts
    2
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Custom Script - NPC adding levels

    Hello everyone,
    recently I entered the world of emulation and trinitycore. I compiled a version of Trinitycore and added some custom scripts (race swap, autobalance, etc).

    Now I'd like to create something custom (a custrom_script) but I haven't found any guides around that specifically talk about how the trinitycore code is structured. Only this one that is about the custom_script in general: CustomScript - TrinityCore - Confluence

    Perhaps the best idea for learning is to get started, but I would need your help to create something - hopefully - simple:

    "I would like to create a custom script, and then associate it to an NPC, which increase the level of a character (for example 80) by asking in exchange a specific object, a custom_item."

    The idea is to try to figure out how to replicate the "character changes", something similar to the commands dedicated to the GM, through an exchange (levelup, modify money, add rep, etc.)

    Can someone help me?

    PS: If you know any guides that can help me, thank you in advance for sharing the links.

    Thank you!

    These ads disappear when you log in.

  2. #2
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1599
    Join Date
    Sep 2007
    Posts
    4,519
    Thanks G/R
    143/133
    Trade Feedback
    0 (0%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The Eluna engine makes scripting quite easy. Example below:

    Eluna API

    Code:
    local NPC = {
        TimeKeeper = 10855 -- npc id
    }
    
    GOSSIP_ICON_CHATBUBBLE = 0
    GOSSIP_ICON_BAG = 1
    GOSSIP_ICON_FLY = 2
    GOSSIP_ICON_BOOK = 3
    GOSSIP_ICON_COGGEAR1 = 4
    GOSSIP_ICON_COGGEAR2 = 5
    GOSSIP_ICON_COINBAG = 6
    GOSSIP_ICON_CHATBUBBLEDOTS = 7
    GOSSIP_ICON_TABARD = 8
    GOSSIP_ICON_PVP = 9
    GOSSIP_ICON_YELLOWDOT = 10
    
    GOSSIP_EVENT_ON_HELLO                           = 1     -- // (event, player, object) - Object is the Creature/GameObject/Item. Can return false to do default action. For item gossip can return false to stop spell casting.
    GOSSIP_EVENT_ON_SELECT                          = 2     -- // (event, player, object, sender, intid, code, menu_id) - Object is the Creature/GameObject/Item/Player, menu_id is only for player gossip. Can return false to do default action.
    
    local function TimeKeeper1(event, player, pUnit)
        player:GossipAddQuests(pUnit)
        player:GossipMenuAddItem(GOSSIP_ICON_FLY, "Take me to The Corrupted Dragon [100 Scrap]", 0, 1, false, "Are you sure: The Corrupted Dragon\n[Costs 100 Scrap]?")
        player:GossipMenuAddItem(GOSSIP_ICON_FLY, "Take me to The Zangarian Dream [100 Scrap]", 0, 2, false, "Are you sure: The Zangarian Dream\n[Costs 100 Scrap]?")
        player:GossipMenuAddItem(GOSSIP_ICON_FLY, "Take me to The Crooked Warren [100 Scrap]", 0, 3, false, "Are you sure: The Crooked Warren\n[Costs 100 Scrap]?")
        player:GossipMenuAddItem(GOSSIP_ICON_FLY, "Take me to The Sacred Hallow [100 Scrap]", 0, 4, false, "Are you sure: The Sacred Hallow\n[Costs 100 Scrap]?")
        player:GossipMenuAddItem(GOSSIP_ICON_CHATBUBBLE, "Nevermind.", 0, 100)
        player:GossipSendMenu(90055, pUnit)
    end
    
    local function TimeKeeper2(event, player, pUnit, sender, id, code)
        if id == 1 then
            -- do something
        elseif id == 2 then
            -- do something
        elseif id == 3 then
            -- do something
        else
            -- do something else
        end
        player:GossipComplete()
    end
    
    RegisterCreatureGossipEvent(NPC.TimeKeeper, GOSSIP_EVENT_ON_HELLO, TimeKeeper1)
    RegisterCreatureGossipEvent(NPC.TimeKeeper, GOSSIP_EVENT_ON_SELECT, TimeKeeper2)
    Last edited by stoneharry; 11-05-2022 at 09:55 AM.

  3. #3
    MrTajoli's Avatar Member
    Reputation
    1
    Join Date
    Nov 2022
    Posts
    2
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much @stoneharry for your help!!!

    I got this version GitHub - ElunaLuaEngine/ElunaTrinityWotlk: Eluna Lua Engine merged with Trinity 3.3.5 , added the other custom scripts and compiled modules. is this okay as a starting point?

    Another question: also with LUA I can create a script which I then "assosciate" to an npc via DB as is done for custom scripts? (maybe the answer is in the link you gave me but I'm starting to read it now !! )

    Thanks again for all your help

  4. #4
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1599
    Join Date
    Sep 2007
    Posts
    4,519
    Thanks G/R
    143/133
    Trade Feedback
    0 (0%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by MrTajoli View Post
    Thank you so much @stoneharry for your help!!!

    I got this version GitHub - ElunaLuaEngine/ElunaTrinityWotlk: Eluna Lua Engine merged with Trinity 3.3.5 , added the other custom scripts and compiled modules. is this okay as a starting point?

    Another question: also with LUA I can create a script which I then "assosciate" to an npc via DB as is done for custom scripts? (maybe the answer is in the link you gave me but I'm starting to read it now !! )

    Thanks again for all your help
    Yes, that's a good starting point. For Lua scripts you don't need to register the scripts in the database, it is done in the code directly. In the example I posted this is done via the 'RegisterCreatureGossipEvent' function, which takes the NPC ID as the first argument. You just drop this as a .lua file inside your server lua_scripts folder.

Similar Threads

  1. Adding custom items/npcs/mobs
    By ArcticdeathSR in forum WoW EMU Questions & Requests
    Replies: 4
    Last Post: 01-07-2009, 06:08 PM
  2. [Release] Custom Scripted Leveling Road Mobs
    By b!atch in forum World of Warcraft Emulator Servers
    Replies: 7
    Last Post: 04-05-2008, 02:02 PM
  3. [Guide] How to make a custom C++ npc!
    By berryman13 in forum WoW EMU Guides & Tutorials
    Replies: 3
    Last Post: 12-26-2007, 01:21 PM
  4. custom/spawned npc wont save when i spawned them
    By bjorn11 in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 11-19-2007, 10:04 AM
  5. Custom teleport npcs question please help
    By friendofdar in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 09-24-2007, 09:35 PM
All times are GMT -5. The time now is 11:37 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2023 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2023 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search