-
-
Notifications
You must be signed in to change notification settings - Fork 179
Expand file tree
/
Copy pathEvents.hpp
More file actions
167 lines (137 loc) · 6.65 KB
/
Events.hpp
File metadata and controls
167 lines (137 loc) · 6.65 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/.
*
* The original code is copyright (c) 2024, open.mp team and contributors.
*/
#pragma once
#include "../ComponentManager.hpp"
#include "sdk.hpp"
template <EventPriorityType PRIORITY>
struct NPCEvents : public NPCEventHandler, public Singleton<NPCEvents<PRIORITY>>
{
void onNPCFinishMove(INPC& npc) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCFinishMove", EventReturnHandler::None, &npc);
}
void onNPCCreate(INPC& npc) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCCreate", EventReturnHandler::None, &npc);
}
void onNPCDestroy(INPC& npc) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCDestroy", EventReturnHandler::None, &npc);
}
void onNPCWeaponStateChange(INPC& npc, PlayerWeaponState newState, PlayerWeaponState oldState) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCWeaponStateChange", EventReturnHandler::None, &npc, int(newState), int(oldState));
}
bool onNPCTakeDamage(INPC& npc, IPlayer& damager, float damage, uint8_t weapon, BodyPart bodyPart) override
{
return ComponentManager::Get()->CallEvent<PRIORITY>("onNPCTakeDamage", EventReturnHandler::StopAtFalse, &npc, &damager, damage, int(weapon), int(bodyPart));
}
bool onNPCGiveDamage(INPC& npc, IPlayer& damaged, float damage, uint8_t weapon, BodyPart bodyPart) override
{
return ComponentManager::Get()->CallEvent<PRIORITY>("onNPCGiveDamage", EventReturnHandler::StopAtFalse, &npc, &damaged, damage, int(weapon), int(bodyPart));
}
void onNPCDeath(INPC& npc, IPlayer* killer, int reason) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCDeath", EventReturnHandler::None, &npc, killer, reason);
}
void onNPCSpawn(INPC& npc) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCSpawn", EventReturnHandler::None, &npc);
}
void onNPCRespawn(INPC& npc) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCRespawn", EventReturnHandler::None, &npc);
}
void onNPCUpdate(INPC& npc) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCUpdate", EventReturnHandler::None, &npc);
}
void onNPCStreamIn(INPC& npc, IPlayer& forPlayer) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCStreamIn", EventReturnHandler::None, &npc, &forPlayer);
}
void onNPCStreamOut(INPC& npc, IPlayer& forPlayer) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCStreamOut", EventReturnHandler::None, &npc, &forPlayer);
}
void onNPCPlaybackStart(INPC& npc, int recordId) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCPlaybackStart", EventReturnHandler::None, &npc, recordId);
}
void onNPCPlaybackEnd(INPC& npc, int recordId) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCPlaybackEnd", EventReturnHandler::None, &npc, recordId);
}
void onNPCVehicleEntryComplete(INPC& npc, IVehicle& vehicle, int seatId) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCVehicleEntryComplete", EventReturnHandler::None, &npc, &vehicle, seatId);
}
void onNPCVehicleExitComplete(INPC& npc, IVehicle& vehicle) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCVehicleExitComplete", EventReturnHandler::None, &npc, &vehicle);
}
bool onNPCVehicleTakeDamage(INPC& npc, IPlayer& issuer, IVehicle& vehicle, float damage, uint8_t weapon, const Vector3& hitPos) override
{
return ComponentManager::Get()->CallEvent<PRIORITY>("onNPCVehicleTakeDamage", EventReturnHandler::StopAtFalse, &npc, &issuer, &vehicle,
damage, int(weapon), hitPos.x, hitPos.y, hitPos.z);
}
void onNPCChangeHeightPos(INPC& npc, float newZ, float oldZ) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCChangeHeightPos", EventReturnHandler::None, &npc, newZ, oldZ);
}
bool onNPCShotMissed(INPC& npc, const PlayerBulletData& bulletData) override
{
return ComponentManager::Get()->CallEvent<PRIORITY>("onNPCShotMissed", EventReturnHandler::StopAtFalse, &npc,
int(bulletData.weapon), bulletData.offset.x, bulletData.offset.y, bulletData.offset.z);
}
bool onNPCShotPlayer(INPC& npc, IPlayer& target, const PlayerBulletData& bulletData) override
{
return ComponentManager::Get()->CallEvent<PRIORITY>("onNPCShotPlayer", EventReturnHandler::StopAtFalse, &npc, &target,
int(bulletData.weapon), bulletData.offset.x, bulletData.offset.y, bulletData.offset.z);
}
bool onNPCShotNPC(INPC& npc, INPC& target, const PlayerBulletData& bulletData) override
{
return ComponentManager::Get()->CallEvent<PRIORITY>("onNPCShotNPC", EventReturnHandler::StopAtFalse, &npc, &target,
int(bulletData.weapon), bulletData.offset.x, bulletData.offset.y, bulletData.offset.z);
}
bool onNPCShotVehicle(INPC& npc, IVehicle& target, const PlayerBulletData& bulletData) override
{
return ComponentManager::Get()->CallEvent<PRIORITY>("onNPCShotVehicle", EventReturnHandler::StopAtFalse, &npc, &target,
int(bulletData.weapon), bulletData.offset.x, bulletData.offset.y, bulletData.offset.z);
}
bool onNPCShotObject(INPC& npc, IObject& target, const PlayerBulletData& bulletData) override
{
return ComponentManager::Get()->CallEvent<PRIORITY>("onNPCShotObject", EventReturnHandler::StopAtFalse, &npc, &target,
int(bulletData.weapon), bulletData.offset.x, bulletData.offset.y, bulletData.offset.z);
}
bool onNPCShotPlayerObject(INPC& npc, IPlayerObject& target, const PlayerBulletData& bulletData) override
{
return ComponentManager::Get()->CallEvent<PRIORITY>("onNPCShotPlayerObject", EventReturnHandler::StopAtFalse, &npc, &target,
int(bulletData.weapon), bulletData.offset.x, bulletData.offset.y, bulletData.offset.z);
}
void onNPCFinishNodePoint(INPC& npc, int nodeId, uint16_t pointId) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCFinishNodePoint", EventReturnHandler::None, &npc, nodeId, int(pointId));
}
void onNPCFinishNode(INPC& npc, int nodeId) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCFinishNode", EventReturnHandler::None, &npc, nodeId);
}
bool onNPCChangeNode(INPC& npc, int newNodeId, int oldNodeId) override
{
return ComponentManager::Get()->CallEvent<PRIORITY>("onNPCChangeNode", EventReturnHandler::StopAtFalse, &npc, newNodeId, oldNodeId);
}
void onNPCFinishMovePath(INPC& npc, int pathId) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCFinishMovePath", EventReturnHandler::None, &npc, pathId);
}
void onNPCFinishMovePathPoint(INPC& npc, int pathId, int pointId) override
{
ComponentManager::Get()->CallEvent<PRIORITY>("onNPCFinishMovePathPoint", EventReturnHandler::None, &npc, pathId, pointId);
}
};