1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GameEventSender.h"
#include "GameObject.h"
#include "GameObjectAI.h"
#include "Map.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "Util.h"
#include "ZoneScript.h"
void GameEvents::Trigger(uint32 gameEventId, WorldObject* source, WorldObject* target)
{
ASSERT(source || target, "At least one of [source] or [target] must be provided");
WorldObject* refForMapAndZoneScript = Coalesce<WorldObject>(source, target);
ZoneScript* zoneScript = refForMapAndZoneScript->GetZoneScript();
if (!zoneScript && refForMapAndZoneScript->IsPlayer())
zoneScript = refForMapAndZoneScript->FindZoneScript();
if (zoneScript)
zoneScript->ProcessEvent(target, gameEventId, source);
sScriptMgr->OnEventTrigger(target, source, gameEventId);
if (GameObject* goTarget = Object::ToGameObject(target))
if (GameObjectAI* goAI = goTarget->AI())
goAI->EventInform(gameEventId);
if (Player* sourcePlayer = Object::ToPlayer(source))
TriggerForPlayer(gameEventId, sourcePlayer);
Map* map = refForMapAndZoneScript->GetMap();
TriggerForMap(gameEventId, map, source, target);
}
void GameEvents::TriggerForPlayer(uint32 gameEventId, Player* source)
{
Map* map = source->GetMap();
if (map->Instanceable())
{
source->FailCriteria(CriteriaFailEvent::SendEvent, gameEventId);
source->StartCriteria(CriteriaStartEvent::SendEvent, gameEventId);
}
source->UpdateCriteria(CriteriaType::PlayerTriggerGameEvent, gameEventId, 0, 0, source);
if (map->IsScenario())
source->UpdateCriteria(CriteriaType::AnyoneTriggerGameEventScenario, gameEventId, 0, 0, source);
}
void GameEvents::TriggerForMap(uint32 gameEventId, Map* map, WorldObject* source, WorldObject* target)
{
map->ScriptsStart(sEventScripts, gameEventId, source, target);
}
|