• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] SmartAI? How to use it properly? [TRINITY]

Status
Not open for further replies.

Andrew

ED Beta Tester
First off I want to say thank you to everyone who's replied to my threads regarding TC help whilst making my server recently. I appreciate it very much.


Now what I'd like to ask about is how to work smart AI or if there is an easier way to do what I'm trying to do which I will explain below:

  • I wish to make a VIP mall (already made it ingame blah blah not that important atm) but to limit it to only GM lvl 1 (VIP).

  • I wish to make it to where when a player who is NOT vip gets teleported to a location set by me when they click a specific NPC(s) (the main mall) (Evergrove - Blade's Edge Mountains)

  • I will however be willing to use a system that teleports people away that may have to do with doing as little as entering a specific zone (Kamagua - Howling Fjord)



If someone could help me with this so I can try to create it myself that would be nice. Also if someone would like to write something for me I would be appreciative of that as well.
 
Last edited:

Lightning Blade

BETA Tester
I would suggest using the eluna engine, much more flexible.

- - - Updated - - -

You could make a npc that have this lua script attached to it: http://pastebin.com/1mimTK3W " <-- that is only an if statment " and then use this hook RegisterCreatureEvent(creatureid, 27, function)

- - - Updated - - -

foereaper made that for me.
 

Andrew

ED Beta Tester
Lightning Blade said:
I would suggest using the eluna engine, much more flexible.

- - - Updated - - -

You could make a npc that have this lua script attached to it: http://pastebin.com/1mimTK3W " <-- that is only an if statment " and then use this hook RegisterCreatureEvent(creatureid, 27, function)


Thank you for providing the script as well as the info but I'm not comfortable with changing and learning a core I've never used seeing that our server is (for the most part) finished as far as In-game goes. Not really up for discussion either seeing that Trinity is the most stable core to my knowledge.
 

Andrew

ED Beta Tester
Lightning Blade said:
Eluna Engine is not a core but an engine you can merge with tc, It's a lua engine for Trinitycore :)

Oh, I see. I wasn't aware of that I'm still kinda new to emulation as far as development goes. Maybe I'll look into it.

Once again, thank you for the tip but I'd still like to learn how Smart AI works so I'm mainly looking for something that has to do with that.
 

Tommy

Founder
I wish to make a VIP mall (already made it ingame blah blah not that important atm) but to limit it to only GM lvl 1 (VIP).

Hmm, this depends where the mall is so players cannot go there via mount or anything. Where is it located at?

I wish to make it to where when a player who is NOT vip gets teleported to a location set by me when they click a specific NPC(s) (the main mall)

When they click any specific Npc or a gossip NPC that they have to go to?

I will however be willing to use a system that teleports people away that may have to do with doing as little as entering a specific zone (Kamagua - Howling Fjord)

I know there is a hook OnUpdateZone you could use this for, but I'm not quite familiar with SmartAI to tell you. I can give you information about SmartAI though.

I'm not sure how oudated TrinityCore's smart_scripts page is, but it seems fairly up to date since nobody has really complained about it. Here's the link: http://collab.kpsn.org/display/tc/smart_scripts

EmuDevs also has a SmartAI generator you can use with ease: http://gen.emudevs.com/index.php?p=tc_smart_ai

For one, you need to familiarize yourself with event_type, event_param1-4, action_type and action_param1-6, target_type and target_param1-3. But, I'd recommend you getting involved into like Lightning Blade mentioned, Eluna. I'm not trying to pull you away from SmartAI, but SmartAI is pretty limited on what you can do. Some of the things you want can be done in SmartAI, but I honestly haven't used much SmartAI in my TrinityCore experience. I can create you C++ scripts or Eluna scripts related to what you want though.

==============================================================================================================================
C++:

I wish to make a VIP mall (already made it ingame blah blah not that important atm) but to limit it to only GM lvl 1 (VIP).
I will however be willing to use a system that teleports people away that may have to do with doing as little as entering a specific zone (Kamagua - Howling Fjord)

Goes for the two quotes above:
Code:
class player_limit_mall : public PlayerScript
{
public:
    player_limit_mall() : PlayerScript("player_limit_mall") { }

    void OnUpdateZone(Player* player, uint32 /*newZone*/, uint32 newArea)
    {
        if (newArea == 1182) // change 1182 to your AreaID
            if (player->GetSession()->GetSecurity() < 1) // 1 = VIP - If it is less than one, players will be ported out
                player->TeleportTo(0, 3000, 3000, 3000, 1); // MapId, X, Y, Z, O - This will teleport players where you want them to go if they enter the zone when their GM level isn't high enough
    }
};

void AddSC_limited()
{
    new player_limit_mall;
}

I wish to make it to where when a player who is NOT vip gets teleported to a location set by me when they click a specific NPC(s) (the main mall)

When they click on an NPC with this script below, they will be ported out. I'm assuming you're mostly referring to vendors? Well, you can do that for vendors too.

Non-Vendor:
Code:
class npc_gossip_main : public CreatureScript
{
public:
    npc_gossip_main() : CreatureScript("npc_gossip_main") { }

    bool OnGossipHello(Player* player, Creature* creature)
    {
        if (player->GetSession()->GetSecurity() < 1) // Less than 1 = Not VIP
        {
            player->GetSession()->SendNotification("You aren't VIP!");
            player->TeleportTo(0, 3000, 3000, 3000, 1); // MapId, X, Y, Z, O
            return false;
        }
        return true;
    }
};

void AddSC_gossip_port()
{
    new npc_gossip_main;
}

Vendor:

Code:
class npc_gossip_main : public CreatureScript
{
public:
    npc_gossip_main() : CreatureScript("npc_gossip_main") { }

    bool OnGossipHello(Player* player, Creature* creature)
    {
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "I would like to browse your items.", GOSSIP_SENDER_MAIN, 1);
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Nevermind..", GOSSIP_SENDER_MAIN, 99);
        player->SEND_GOSSIP_MENU(1, creature->GetGUID());
        return true;
    }

    bool OnGossipSelect(Player* player, Creature* creature, uint32 /* sender */, uint32 actions)
    {
        player->PlayerTalkClass->ClearMenus();
        if (actions == 1)
        {
            if (player->GetSession()->GetSecurity() < 1) // Less than 1 = Not VIP
            {
                player->GetSession()->SendNotification("You aren't VIP!");
                player->TeleportTo(0, 3000, 3000, 3000, 1); // MapId, X, Y, Z, O
                player->CLOSE_GOSSIP_MENU();
                return false;
            }
            player->GetSession()->SendListInventory(creature->GetGUID());
            player->CLOSE_GOSSIP_MENU();
        }
        else if (actions == 99)
            player->CLOSE_GOSSIP_MENU();
        return true;
    }
};

void AddSC_gossip_port()
{
    new npc_gossip_main;
}

==============================================================================================================================
Eluna:

I wish to make a VIP mall (already made it ingame blah blah not that important atm) but to limit it to only GM lvl 1 (VIP).
I will however be willing to use a system that teleports people away that may have to do with doing as little as entering a specific zone (Kamagua - Howling Fjord)

Goes for the two quotes above: (http://wiki.emudevs.com/doku.php?id=eluna_hooks_registerserverhook)

RegisterServerHook(EventId, Function)
PLAYER_EVENT_ON_UPDATE_ZONE = 27, - (event, player, newZone, newArea)
player:GetGMRank() - Gets GM rank (GetSecurity)
player:Teleport(Map, X, Y, Z, O) - Teleports player to specified co - ordinates. Returns true if success and false if not

Code:
function OnUpdateZone(event, player, newZone, newArea)
    if (newArea == 1182) then -- 1182 must be changed
        if (player:GetGMRank() < 1) then
            player:Teleport(0, 3000, 3000, 3000, 1) -- Map, X, Y, Z, O
        end
    end        
end

RegisterServerHook(27, OnUpdateZone)

I wish to make it to where when a player who is NOT vip gets teleported to a location set by me when they click a specific NPC(s) (the main mall)

RegisterCreatureGossipEvent(npcId, EventId, Function)
GetGMRank() - Gets GM rank (GetSecurity)
Teleport(Map, X, Y, Z, O) - Teleports player to specified co - ordinates. Returns true if success and false if not
GOSSIP_EVENT_ON_HELLO = 1, (event, player, creature)
GOSSIP_EVENT_ON_SELECT = 2, (event, player, creature, sender, intid, code)
GossipMenuAddItem(icon, msg, sender, intid[, code, popup, money])
GossipSendMenu(npc_text, unit[, menu_id]) - If unit is a player, you need to use a menu_id. menu_id is used to hook the gossip select function to the menu
GossipComplete()
GossipClearMenu() - Clears the gossip menu of options. Pretty much only useful with player gossip. Need to use before creating a new menu for the player


Non-Vendor:

Code:
local npcId = 30000

function OnGossipHello(event, player, creature)
    if (player:GetGMRank() < 1) then
        player:SendNotification("You aren't VIP!")
        player:Teleport(0, 3000, 3000, 3000, 1) -- MapId, X, Y, Z, O
    end
end

RegisterCreatureGossipEvent(npcId, 1, OnGossipHello)

Vendor:

Code:
local npcId = 30000

function OnGossipHello(event, player, creature)
    player:GossipMenuAddItem(0, "I would like to browse your goods.", 0, 1)
    player:GossipMenuAddItem(0, "Nevermind...", 0, 99)
    player:GossipSendMenu(1, creature)
end

function OnGossipSelect(event, player, creature, sender, intid, code)
    player:GossipClearMenu()
    if (intid == 1) then
        if (player:GetGMRank() < 1) then
            player:SendNotification("You aren't VIP!")
            player:Teleport(0, 3000, 3000, 3000, 1) -- MapId, X, Y, Z, O
            player:GossipComplete()
            return
        end
        player:SendListInventory(creature)
    elseif (intid == 99) then
        player:GossipComplete()
    end
end

RegisterCreatureGossipEvent(npcId, 1, OnGossipHello)
RegisterCreatureGossipEvent(npcId, 2, OnGossipSelect)


We have plenty of C++ tutorials for you to go through: http://emudevs.com/showthread.php/32-EmuDevs-TrinityCore-Video-Tutorial-Collection. That includes how to set them up. Also, I'm assuming you're aware of our Eluna wiki http://wiki.emudevs.com/doku.php?id=eluna. Anyway, there you go. \o/
 

Tommy

Founder
No problem. Was getting worried if you was going to reply or not since I made that post. XD
 
Status
Not open for further replies.
Top