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

TrinityCore 3.3.5 Teleportstone requirements/cooldown

yvoms

Exalted Member
Greetings emudevs,

I've created an iconized teleporter stone, its working as it should however i'm not quite sure on how to add a faction check, since alliance players shouldn't be able to teleport to horde locations, also Shattarath(60) and Dalaran(75) shouldn't be shown unless the required level is set, the pvp areas should also require level 40+ can i hide that entire menu untill that level is met, and last but most likely hardest of all, "Send Home" is casting the hearthstone spell on the player, is there some way i can set the cooldown on it to 30 minutes?

Current script :
Code:
#include "Define.h"
#include "GossipDef.h"
#include "Item.h"
#include "Player.h"
#include "ScriptedGossip.h"
#include "ScriptMgr.h"
#include "Spell.h"
//
// check for alliance | horde locations
// check for pvp areans level > 40 only.
// Send me home 30 minute cooldown
// shattrath level 60 - dalaran level 75 requirement

class teleportstone : public ItemScript
{
public:
	teleportstone() : ItemScript("teleportstone") { }

	bool OnUse(Player* player, Item* item, SpellCastTargets const& targets) override
	{
		if (player->IsInCombat())
		{
			player->GetSession()->SendNotification("You are in combat!");
			player->CLOSE_GOSSIP_MENU();
			return false;
		}
		player->PlayerTalkClass->ClearMenus();
		player->ADD_GOSSIP_ITEM(0, "|cff1C6224|TInterface\\icons\\INV_Misc_Bag_FelclothBag:30|t Send Me Home|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
		player->ADD_GOSSIP_ITEM(0, "|cff4169E1|TInterface\\icons\\Achievement_Leader_King_Varian_Wrynn:30|t Alliance Capital Cities|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 20);
		player->ADD_GOSSIP_ITEM(0, "|cffFF0000|TInterface\\icons\\Achievement_Leader_Sylvanas:30|t Horde Capital Cities|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 40);
		player->ADD_GOSSIP_ITEM(0, "|cffFF0000|TInterface\\icons\\Achievement_FeatsOfStrength_Gladiator_10:30|t PvP Areas|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 60);
		player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, item->GetGUID());
		return true;
	}

	void OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action) override
	{
		switch (action)
		{
		case GOSSIP_ACTION_INFO_DEF + 1: //Use Hearthstone.
			player->CLOSE_GOSSIP_MENU();
			player->CastSpell(player, 8690, true);
			player->GetSession()->SendNotification("You have been sent home.");
			break;

		case GOSSIP_ACTION_INFO_DEF + 20: //alliance locations
			player->PlayerTalkClass->ClearMenus();
			player->ADD_GOSSIP_ITEM(2, "|cff4169E1|TInterface\\icons\\Achievement_Leader_King_Varian_Wrynn.png:30|t Stormwind|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21);
			player->ADD_GOSSIP_ITEM(2, "|cff4169E1|TInterface\\icons\\Achievement_Leader_King_Magni_Bronzebeard.png:30|t Ironforge|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 22);
			player->ADD_GOSSIP_ITEM(2, "|cff4169E1|TInterface\\icons\\Achievement_Leader_Tyrande_Whisperwind.png:30|t Darnassus|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 23);
			player->ADD_GOSSIP_ITEM(2, "|cff4169E1|TInterface\\icons\\Achievement_Leader_Prophet_Velen.png:30|t The Exodar|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 24);
			player->ADD_GOSSIP_ITEM(2, "|cffCC00CC|TInterface\\icons\\Ability_Druid_TwilightsWrath.png:30|t Shattrath City|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 25);
			player->ADD_GOSSIP_ITEM(2, "|cffCC00CC|TInterface\\icons\\Ability_Mount_RocketMount.png:30|t Dalaran|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 26);
			player->ADD_GOSSIP_ITEM(1, "|cffFF0000<- Close Menu", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 999);
			player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, item->GetGUID());
			break;

		case GOSSIP_ACTION_INFO_DEF + 40: //horde locations
			player->PlayerTalkClass->ClearMenus();
			player->ADD_GOSSIP_ITEM(2, "|cffFF0000|TInterface\\icons\\Achievement_Leader_ Thrall.png:30|t Orgrimmar|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 41);
			player->ADD_GOSSIP_ITEM(2, "|cffFF0000|TInterface\\icons\\Achievement_Leader_Sylvanas.png:30|t Undercity|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 42);
			player->ADD_GOSSIP_ITEM(2, "|cffFF0000|TInterface\\icons\\Achievement_Leader_Cairne Bloodhoof.png:30|t Thunder Bluff|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 43);
			player->ADD_GOSSIP_ITEM(2, "|cffFF0000|TInterface\\icons\\Achievement_Leader_Lorthemar_Theron .png:30|t Silvermoon|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 44);
			player->ADD_GOSSIP_ITEM(2, "|cffCC00CC|TInterface\\icons\\Ability_Druid_TwilightsWrath.png:30|t Shattrath City|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 45);
			player->ADD_GOSSIP_ITEM(2, "|cffCC00CC|TInterface\\icons\\Ability_Mount_RocketMount.png:30|t Dalaran|r", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 46);
			player->ADD_GOSSIP_ITEM(1, "|cffFF0000<- Close Menu", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 999);
			player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, item->GetGUID());
			break;

		case GOSSIP_ACTION_INFO_DEF + 60: //pvp areas
			player->PlayerTalkClass->ClearMenus();
			player->ADD_GOSSIP_ITEM(2, "|TInterface\\icons\\Ability_Rogue_Ambush.png:30|t Gurubashi Arena", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 61);
			player->ADD_GOSSIP_ITEM(2, "|TInterface\\icons\\Ability_Rogue_MurderSpree.png:30|t Circle of Blood Arena", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 62);
			player->ADD_GOSSIP_ITEM(1, "|TInterface\\icons\\Ability_TheBlackArrow.png:30|t The Ring of Trials", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 63);
			player->ADD_GOSSIP_ITEM(1, "|cffFF0000<- Close Menu", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 999);
			player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, item->GetGUID());
			break;

			//Alliance locations
		case GOSSIP_ACTION_INFO_DEF + 21: // Stormwind
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(0, -8833.38f, 628.628f, 94.0066f, 1.06535f);
			break;
		case GOSSIP_ACTION_INFO_DEF + 22: // Ironforge
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(0, -4918.88f, -940.406f, 501.564f, 5.42347f);
			break;
		case GOSSIP_ACTION_INFO_DEF + 23: // Darnassus
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(1, 9949.56f, 2284.21f, 1341.4f, 1.59587f);
			break;
		case GOSSIP_ACTION_INFO_DEF + 24: // Exodar
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(530, -3965.7f, -11653.6f, -138.844f, 0.852154f);
			break;
		case GOSSIP_ACTION_INFO_DEF + 25: // Shattrath city
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(530, -1838.16f, 5301.79f, -12.428f, 5.9517f);
			break;
		case GOSSIP_ACTION_INFO_DEF + 26: // Dalaran
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(571, 5804.15f, 624.771f, 647.767f, 1.64f);
			break;

			//Horde locations
		case GOSSIP_ACTION_INFO_DEF + 41: // Orgrimmar
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(1, 1629.36f, -4373.39f, 31.2564f, 3.54839f);
			break;
		case GOSSIP_ACTION_INFO_DEF + 42: // Undercity
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(0, 1584.07f, 241.987f, -52.1534f, 0.049647f);
			break;
		case GOSSIP_ACTION_INFO_DEF + 43: // Thunderbluff
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(1, -1277.37f, 124.804f, 131.287f, 5.22274f);
			break;
		case GOSSIP_ACTION_INFO_DEF + 44: // Silvermoon
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(530, 9487.69f, -7279.2f, 14.2866f, 6.16478f);
			break;
		case GOSSIP_ACTION_INFO_DEF + 45: // Shattrath city
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(530, -1838.16f, 5301.79f, -12.428f, 5.9517f);
			break;
		case GOSSIP_ACTION_INFO_DEF + 46: // Dalaran
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(571, 5804.15f, 624.771f, 647.767f, 1.64f);
			break;
			//Pvp Areas
		case GOSSIP_ACTION_INFO_DEF + 61: //Gurubashi arena
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(0, -13277.4f, 127.372f, 26.1418f, 1.11878f);
			break;
		case GOSSIP_ACTION_INFO_DEF + 62: //Circle of Blood
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(530, 2839.44f, 5930.17f, 11.1002f, 3.16284f);
			break;
		case GOSSIP_ACTION_INFO_DEF + 63: // The Ring of Trials
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(530, -1999.94f, 6581.71f, 11.32f, 2.36528f);
			break;

			//Misc
		case GOSSIP_ACTION_INFO_DEF + 999://menu sluit als dit uitgevoerd word.
			player->CLOSE_GOSSIP_MENU();
			break;
		}
	}
};

void AddSC_teleportstone()
{
	new teleportstone();
}
 

Tommy

Founder
Faction check is easy.

Searching through TrinityCore on Github is an easy way to see how things are done.

https://github.com/TrinityCore/TrinityCore/search?utf8=✓&q=getLevel
https://github.com/TrinityCore/TrinityCore/search?utf8=✓&q=GetTeam()&type=Code

Main enumerator types:

HORDE
ALLIANCE

Code:
if (player->GetTeam() == ALLIANCE)
{
    // Alliance stuff
}
else
{
    // Horde Stuff
}

// Or you can do it the other way around (doesn't matter)
if (player->GetTeam() == HORDE)
{
    // Horde stuff
}
else
{
    // Alliance Stuff
}

Checking player level:

Code:
if (player->getLevel() == 60)
{
    // Do stuff
}

I'm confused about the hearthstone. Why not let people use their actual hearthstone item instead having a menu for it?
 

yvoms

Exalted Member
I'm confused about the hearthstone. Why not let people use their actual hearthstone item instead having a menu for it?
This is an itemscript thats being set to the hearthstone, "Enchanted Hearthstone" more options etc.
Anyways, thanks for the help i think i can put a timer on it or something ^^
 

Tommy

Founder
This is an itemscript thats being set to the hearthstone, "Enchanted Hearthstone" more options etc.
Anyways, thanks for the help i think i can put a timer on it or something ^^

Could just put some type of debuff on the player after they use it and don't let them use it again if they have the aura. Timer is pointless when you can do it that way.

Little tip:

Code:
player->PlayerTalkClass->ClearMenus();

Take the code above out of the cases you put it in and call it where it is below:

Code:
    void OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action) override
    {
        [COLOR="#00FF00"]player->PlayerTalkClass->ClearMenus();[/COLOR]
        switch (action)
        {
 

yvoms

Exalted Member
There should be a column that puts the item on cooldown for x amount of time in the item_template table
True, however it would set the entire stone unuseable, i just wish to set a subcategory to be used once in x minutes thanks for the heads up tho!

Could just put some type of debuff on the player after they use it and don't let them use it again if they have the aura. Timer is pointless when you can do it that way.

Little tip:

Code:
player->PlayerTalkClass->ClearMenus();

Take the code above out of the cases you put it in and call it where it is below:

Code:
    void OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action) override
    {
        [COLOR="#00FF00"]player->PlayerTalkClass->ClearMenus();[/COLOR]
        switch (action)
        {
Hmm that idea is even better thank you, and also thank you for the headsup!
 

slp13at420

Mad Scientist
you would only need to store the time when you need to use the timer then check the stored time against the current time when needed so other features of the item are still available.

if you want to apply a timer to the teleport feature then when it comes time to teleport the player just check if the (stored time + delay is less than the current time) then teleport and store the current time keyed to the player.

Code:
[COLOR="#808080"]
            if((TeleTime[player->GetGUID()] + delay) > GameTime())
                    // do something say timer error 
            else
            {
			//Alliance locations
		case GOSSIP_ACTION_INFO_DEF + 21: // Stormwind
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(0, -8833.38f, 628.628f, 94.0066f, 1.06535f);
   			break;
		case GOSSIP_ACTION_INFO_DEF + 22: // Ironforge
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(0, -4918.88f, -940.406f, 501.564f, 5.42347f);

			//Horde locations
		case GOSSIP_ACTION_INFO_DEF + 41: // Orgrimmar
			player->CLOSE_GOSSIP_MENU();
			player->TeleportTo(1, 1629.36f, -4373.39f, 31.2564f, 3.54839f);
			break;
                                     TeleTime[player->GetGUID()] = GameTime();
                       }
[/COLOR]

just an un-tested rough-draft just to give you an idea how to add the delay use.
 
Last edited:
Top