• 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 Gossip Real Time Update

Visa

Sexy Member
Running TC 3.3.5, latest rev.

I'm trying to make a CreatureScript that will show in a gossip menu item, the remaining respawn time of a world boss.

I have so far..

Code:
[COLOR=#0066cc]class [/COLOR][COLOR=#add8e6]boss_timer[/COLOR] : [COLOR=#0066cc]public [/COLOR][COLOR=#add8e6]CreatureScript[/COLOR]
{
[COLOR=#0066cc]public[/COLOR]:
    boss_timer() : [COLOR=#add8e6]CreatureScript[/COLOR]([COLOR=#cc6633]"boss_timer"[/COLOR]) { }


    [COLOR=#0066cc]bool [/COLOR]OnGossipHello([COLOR=#add8e6]Player[/COLOR]* [COLOR=#a9a9a9]player[/COLOR], Creature* [COLOR=#a9a9a9]creature[/COLOR])
    {
        [COLOR=#add8e6]Creature[/COLOR]* target = ObjectAccessor::GetCreature(*[COLOR=#a9a9a9]player[/COLOR], [COLOR=#a9a9a9]creature[/COLOR]->GetGUID()); [COLOR=#00ff00]// Find Entry by GUID ??? How?[/COLOR]

        [COLOR=#add8e6]uint32 [/COLOR]timer = [COLOR=#add8e6]uint32[/COLOR]([COLOR=#a9a9a9]target[/COLOR]->GetRespawnTime() / 1000); [COLOR=#00ff00]// Get remaining timer for respawn of that GUID.[/COLOR]

        [COLOR=#a9a9a9]player[/COLOR]->SendUpdateWorldState(0, time([COLOR=#ee82ee]NULL[/COLOR]) + timer); [COLOR=#00ff00]// update timers ???[/COLOR]

        std::[COLOR=#add8e6]ostringstream [/COLOR]ss;
        ss << [COLOR=#cc6633]"World Boss will respawn in "[/COLOR] << timer; [COLOR=#00ff00]// add in gossip menu item[/COLOR]

        [COLOR=#a9a9a9]player[/COLOR]->[COLOR=#ee82ee]ADD_GOSSIP_ITEM[/COLOR]([COLOR=#99ccff]GOSSIP_ICON_CHAT[/COLOR], ss.str().c_str(), [COLOR=#99ccff]GOSSIP_SENDER_MAIN[/COLOR], [COLOR=#99ccff]GOSSIP_ACTION_INFO_DEF + 1[/COLOR]);
        return true;
    }

    [COLOR=#0066cc]bool [/COLOR]OnGossipSelect([COLOR=#add8e6]Player[/COLOR]* [COLOR=#a9a9a9]player[/COLOR], [COLOR=#add8e6]Creature[/COLOR]* [COLOR=#00ff00]/*creature*/[/COLOR], [COLOR=#add8e6]uint32 [/COLOR][COLOR=#00ff00]/*sender*/[/COLOR], [COLOR=#add8e6]uint32 [/COLOR][COLOR=#00ff00]/*action*/[/COLOR])
    {
        [COLOR=#a9a9a9]player[/COLOR]->[COLOR=#ee82ee]CLOSE_GOSSIP_MENU[/COLOR]();
        [COLOR=#0066cc]return true[/COLOR];
    }
};

[COLOR=#0066cc]void [/COLOR][COLOR=#add8e6]AddSC_boss_timer[/COLOR]()
{
    [COLOR=#0066cc]new [/COLOR][COLOR=#add8e6]boss_timer[/COLOR]();
}


I like colors... so. :D
 

Visa

Sexy Member
Yes. thats where I got most of the code I did, lol I referenced it all based off of that script.

But I don't understand this:

player->SendUpdateWorldState(0, time(NULL) + timer);

And how do I link a specific set creature GUID to find the respawn time remaining on it and thus print it.
 

slp13at420

Mad Scientist
But I don't understand this:

player->SendUpdateWorldState(0, time(NULL) + timer);

dunno if this will help with that. for Eluna --> http://emudevs.com/showthread.php/2691-Eluna-Extension-WorldState-methods!

I used it for keeping score, but I don't have any examples to post at this time and its been a while since I did any thing with WorldStates.

it would show top center like Arathi Basin and can be changed using Eluna --> player:SendUpdateWorldState(id, current+1);

initializing the WorldState and setting values to 0:
Code:
[COLOR="#808080"]
local function ClearScore(team_id)

Zone.Score[0] = 0;
Zone.Score[1] = 0;

	for _, v in pairs(GetPlayersInMap(Zone.Map))do

		if((v:GetZoneId() == Zone.Zone)and(v:GetAreaId() == Zone.Area))then
			v:InitializeWorldState(1, 1377, 0, 1) -- Initialize world state, score 0/0
			v:UpdateWorldState(2317, MaxScore) -- Sets correct MaxScore
			v:UpdateWorldState(2313, 0) -- Reset Alliance score when battle resets
			v:UpdateWorldState(2314, 0) -- Reset Horde score when battle resets
		end
	end
end

ClearScore();
[/COLOR]


increasing score:
Code:
[COLOR="#808080"]
local function IncreaseScore(team_id, value)

Zone.Score[team_id] = Zone.Score[team_id] + value;

	for _, v in pairs(GetPlayersInMap(Zone.Map))do

		if((v:GetZoneId() == Zone.Zone)and(v:GetAreaId() == Zone.Area))then
		
			v:UpdateWorldState(2313+team_id, Zone.Score[team_id]) -- Reset Alliance score when battle resets
		end
	end
end
[/COLOR]

this also would require adding custom WorldStates to your WorldStateUI.dbc file.
 
Last edited:

Rochet2

Moderator / Eluna Dev
Keep sending the menu to the player every second.
You can do that for example by sending it to every player within some range, and possibly if you want you can attach a list of players that have are within the radius and have clicked ongossip hello to improve the functionality.

you dont need the worldstate stuff.
 

Visa

Sexy Member
Code:
enum CreatureGUID
{
	CREATURE_GARROSH = 90000,
	CREATURE_THRALL = 90001,
	CREATURE_VOLJIN = 90002,
};

enum Texts
{
	TIME_REMAINING_1 = 100000,
	TIME_REMAINING_2 = 100001,
	TIME_REMAINING_3 = 100002,
};

class boss_timer : public CreatureScript
{
public:
	boss_timer() : CreatureScript("boss_timer") { }
	
	bool OnGossipHello(Player* player, Creature* creature) override
	{
		Creature* worldboss = ObjectAccessor::GetCreature(*player, boss_respawner);
		if (worldboss->isWorldBoss())
		{
			if (!worldboss->IsAlive() && worldboss->GetGUID() == CREATURE_GARROSH) // Garrosh
				player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Garrosh: " + TIME_REMAINING_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
			else
				player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Garrosh: Alive", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);

			if (!worldboss->IsAlive() && worldboss->GetGUID() == CREATURE_THRALL) // Thrall
				player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Thrall: " + TIME_REMAINING_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
			else
				player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Thrall: Alive", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);

			if (!worldboss->IsAlive() && worldboss->GetGUID() == CREATURE_VOLJIN) // Vo'Jin
				player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Vol'Jin: " + TIME_REMAINING_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
			else
				player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Vol'Jin: Alive", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
		}
		else
			return false;
		return true;
	}

private:
	ObjectGuid boss_respawner;
};

void AddSC_boss_timer()
{
	new boss_timer();
}

This is what I have so far lol.
 
Last edited:
Top