TrinityCore/TrinityCore — Issue #3615: [Brewfest] Welcome Areatrigger
Author: Discover-
Created: 2011-10-21 22:41:23+00:00
State: open

Just porting from forums now that I have some spare time..

```cpp
/*######
## at_brewfest
######*/

enum Brewfest
{
NPC_TAPPER_SWINDLEKEG = 24711,
NPC_IPFELKOFER_IRONKEG = 24710,

AT_BREWFEST_DUROTAR = 4829,
AT_BREWFEST_DUN_MOROGH = 4820,

SAY_WELCOME = 4,

AREATRIGGER_TALK_COOLDOWN = 5, // in seconds
};

class AreaTrigger_at_brewfest : public AreaTriggerScript
{
public:
AreaTrigger_at_brewfest() : AreaTriggerScript("at_brewfest")
{
// Initialize for cooldown
_triggerTimes[AT_BREWFEST_DUROTAR] = _triggerTimes[AT_BREWFEST_DUN_MOROGH] = 0;
}

bool OnTrigger(Player* player, AreaTriggerEntry const* trigger)
{
uint32 triggerId = trigger->id;
// Second trigger happened too early after first, skip for now
if (sWorld->GetGameTime() - _triggerTimes[triggerId] < AREATRIGGER_TALK_COOLDOWN)
return false;

switch (triggerId)
{
case AT_BREWFEST_DUROTAR:
if (Creature* tapper = player->FindNearestCreature(NPC_TAPPER_SWINDLEKEG, 20.0f))
tapper->AI()->Talk(SAY_WELCOME, player->GetGUID());
break;
case AT_BREWFEST_DUN_MOROGH:
if (Creature* ipfelkofer = player->FindNearestCreature(NPC_IPFELKOFER_IRONKEG, 20.0f))
ipfelkofer->AI()->Talk(SAY_WELCOME, player->GetGUID());
break;
default:
break;
}

_triggerTimes[triggerId] = sWorld->GetGameTime();
return false;
}

private:
std::map _triggerTimes;
};
```

```sql
-- Areatrigger scriptname
DELETE FROM `areatrigger_scripts` WHERE `entry` IN (4829,4820);
INSERT INTO `areatrigger_scripts` (`entry`,`ScriptName`) VALUES
(4829,'at_brewfest'), -- Durotar
(4820,'at_brewfest'); -- Dun Morogh
```