forked from DarkflameUniverse/DarkflameServer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCppScripts.h
More file actions
394 lines (340 loc) · 12.7 KB
/
CppScripts.h
File metadata and controls
394 lines (340 loc) · 12.7 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
#pragma once
#include <cstdint>
#include <string>
#include <vector>
class User;
class Entity;
class NiPoint3;
enum class eMissionState : int32_t;
enum class ePetTamingNotifyType : uint32_t;
enum class eQuickBuildState : uint32_t;
namespace CppScripts {
/**
* Base class for all scripts. Includes virtual methods to be overridden to handle LUA equivelent events.
*
* All methods pass 'self' as the first parameter, this is the associated parent entity for the event.
* There will only ever be one instance of each script.
*
* Do not use class members as entity specific variables unless you're sure there will only event be one instance of this script.
* Do use class members as script wide variables, variables all entities which this script will access.
*
* Use self->GetVar<type_t>(u"variable_name") and self->SetVar<type_t>(u"variable_name", value) to manage variables.
*
* Designed to yield as close to a 1:1 mapping as possible with LUA.
* There will be events which are not implemented or inheritetly LUA features not easily translated to C++.
* Most of the time these can be worked around or ignored.
*/
class Script {
public:
/**
* Invoked one frame after the script is loaded.
*
* Equivalent to 'function onStartup(self)'
*/
virtual void OnStartup(Entity* self) {};
/**
* Invoked upon an entity entering the phantom collider on self.
*
* Equivalent to 'function onCollisionPhantom(self, msg)'
*/
virtual void OnCollisionPhantom(Entity* self, Entity* target) {};
/**
* Invoked upon an entity leaving the phantom collider on self.
*
* Equivalent to 'function onOffCollisionPhantom(self, msg)'
*/
virtual void OnOffCollisionPhantom(Entity* self, Entity* target) {};
/**
* Invoked when a player accepted a mission.
*
* Equivalent to 'function onMissionDialogueOK(self, msg)'
*/
virtual void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) {};
/**
* Invoked when the client or the server invoked an event server-side.
*
* Equivalent to 'function onFireEventServerSide(self, msg)'
*/
virtual void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {};
/**
* Invoked upon sending a object notification.
*
* Equivalent to 'function onNotifyObject(self, msg)'
*/
virtual void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) {};
/**
* Invoked upon a player exiting the modular build minigame.
*
* Equivalent to 'function onModularBuildExit(self, msg)'
*/
virtual void OnModularBuildExit(Entity* self, Entity* player, bool bCompleted, std::vector<LOT> modules) {};
/**
* Invoked when a player has loaded into the zone.
*
* Equivalent to 'function onPlayerLoaded(self, msg)'
*/
virtual void OnPlayerLoaded(Entity* self, Entity* player) {};
/**
* Invoked when a player has died.
*
* Equivalent to 'function onPlayerDied(self, msg)'
*/
virtual void OnPlayerDied(Entity* self, Entity* player) {};
/**
* Invoked when a player has resurrected.
*
* Equivalent to 'function onPlayerResurrected(self, msg)'
*/
virtual void OnPlayerResurrected(Entity* self, Entity* player) {};
/**
* Invoked when a player has left the zone.
*
* Equivalent to 'function onPlayerExit(self, msg)'
*/
virtual void OnPlayerExit(Entity* self, Entity* player) {};
/**
* Invoked when a player has interacted with the proximity collider on self.
*
* Equivalent to 'function onProximityUpdate(self, msg)'
*
* @param name The name of the proximity collider recviving an interaction.
* @param status "ENTER" if a player has entered the proximity collider; "LEAVE" if a player has left the proximity collider
*/
virtual void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {};
/**
* Invoked when a timer on self has expired.
*
* Equivalent to 'function onTimerDone(self, msg)'
*/
virtual void OnTimerDone(Entity* self, std::string timerName) {};
/**
* Invoked when a player interactions with self.
*
* Equivalent to 'function onUse(self, msg)'
*/
virtual void OnUse(Entity* self, Entity* user) {};
/**
* Invoked when self has died.
*
* Equivalent to 'function onDie(self, msg)'
*/
virtual void OnDie(Entity* self, Entity* killer) {};
/**
* Invoked when self has received a hit.
*
* Equivalent to 'function onHit(self, msg)'
*/
virtual void OnHit(Entity* self, Entity* attacker) {};
/**
* Invoked when self has received an emote from a player.
*
* Equivalent to 'function onEmoteReceived(self, msg)'
*/
virtual void OnEmoteReceived(Entity* self, int32_t emote, Entity* target) {};
/**
* Invoked when a player has started building this quickbuild.
*
* Equivalent to 'function onQuickBuildStart(self, msg)'
*/
virtual void OnQuickBuildStart(Entity* self, Entity* target) {};
/**
* Invoked when this quickbuild has changed state.
*
* Equivalent to 'function onQuickBuildNotifyState(self, msg)'
*/
virtual void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) {};
/**
* Invoked when this quickbuild has been completed.
*
* Equivalent to 'function OnQuickBuildComplete(self, msg)'
*/
virtual void OnQuickBuildComplete(Entity* self, Entity* target) {};
/**
* Invoked when self has received either a hit or heal.
*
* Equivalent to 'function onHitOrHealResult(self, msg)'
*/
virtual void OnHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) {};
/**
* Invoked when self has received either a hit or heal. Only used for scripts subscribed to an entity.
*
* Equivalent to 'function notifyHitOrHealResult(self, msg)'
*/
virtual void NotifyHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) {};
virtual void NotifyPlayerResurrectionFinished(Entity& self, GameMessages::PlayerResurrectionFinished& msg) {};
/**
* Invoked when a player has responsed to a mission.
*
* Equivalent to 'function onRespondToMission(self, msg)'
*/
virtual void OnRespondToMission(Entity* self, int missionID, Entity* player, int reward) {};
/**
* Invoked once per frame.
*
* No LUA eqivalent.
*/
virtual void OnUpdate(Entity* self) {};
/**
* Invoked when this property has been rented.
*
* Equivalent to 'function onZonePropertyRented(self, msg)'
*/
virtual void OnZonePropertyRented(Entity* self, Entity* renter) {};
/**
* Invoked when a player has begun to edit this property.
*
* Equivalent to 'function onZonePropertyEditBegin(self, msg)'
*/
virtual void OnZonePropertyEditBegin(Entity* self) {};
/**
* Invoked when a player has concluded editing this property.
*
* Equivalent to 'function onZonePropertyEditEnd(self, msg)'
*/
virtual void OnZonePropertyEditEnd(Entity* self) {};
/**
* Invoked when a player has equipped a model while editing this property.
*
* Equivalent to 'function onZonePropertyModelEquipped(self, msg)'
*/
virtual void OnZonePropertyModelEquipped(Entity* self) {};
/**
* Invoked when a player has placed a model while editing this property.
*
* Equivalent to 'function onZonePropertyModelPlaced(self, msg)'
*/
virtual void OnZonePropertyModelPlaced(Entity* self, Entity* player) {};
/**
* Invoked when a player has picked up a model while editing this property.
*
* Equivalent to 'function onZonePropertyModelPickedUp(self, msg)'
*/
virtual void OnZonePropertyModelPickedUp(Entity* self, Entity* player) {};
/**
* Invoked when a player removed a model while editing this property.
*
* Equivalent to 'function onZonePropertyModelRemoved(self, msg)'
*/
virtual void OnZonePropertyModelRemoved(Entity* self, Entity* player) {};
/**
* Invoked when a player removed a model while holding it when editing this property.
*
* Equivalent to 'function onZonePropertyModelRemoved(self, msg)'
*/
virtual void OnZonePropertyModelRemovedWhileEquipped(Entity* self, Entity* player) {};
/**
* Invoked when a player rotated a model while editing this property.
*
* Equivalent to 'function onZonePropertyModelRotated(self, msg)'
*/
virtual void OnZonePropertyModelRotated(Entity* self, Entity* player) {};
/**
* Invoked when the pet taming minigame encounted an event.
*
* Equivalent to 'function onNotifyPetTamingMinigame(self, msg)'
*/
virtual void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) {};
/**
* Invoked when a player responded to a message box.
*
* Equivalent to 'function onMessageBoxResponse(self, msg)'
*/
virtual void OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {};
/**
* Invoked when a player responded to a choice box.
*
* Equivalent to 'function onChoiceBoxResponse(self, msg)'
*/
virtual void OnChoiceBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& buttonIdentifier, const std::u16string& identifier) {};
/**
* Invoked when self arrived at a moving platform waypoint.
*
* Equivalent to 'function onWaypointReached(self, msg)'
*/
virtual void OnWaypointReached(Entity* self, uint32_t waypointIndex) {};
/**
* Invoked when a player fired a skill event on self.
*
* Equivalent to 'function onSkillEventFired(self, msg)'
*/
virtual void OnSkillEventFired(Entity* self, Entity* caster, const std::string& message) {};
/**
* Invoked when self casted a skill.
*
* Equivalent to 'function onSkillCast(self, msg)'
*/
virtual void OnSkillCast(Entity* self, uint32_t skillID) {};
/**
* Invoked when a player on a rail reaches a waypoint
* Equivalent to: 'onPlayerRailArrivedNotification(self, msg)'
* @param self the parent of the script
* @param sender the entity that sent the event
* @param pathName the name of the path the entity was on
* @param waypoint the waypoint number of the path the entity was on
*/
virtual void OnPlayerRailArrived(Entity* self, Entity* sender, const std::u16string& pathName, int32_t waypoint) {};
/**
* Used by legacy minigames to indicate something has changed about the activity
* @param self the entity the script belongs to
* @param senderID the sender of the message
* @param value1 some value to represent the change
* @param value2 some other value to represent the change
* @param stringValue some string value to represent the change
*/
virtual void OnActivityStateChangeRequest(Entity* self, const LWOOBJID senderID, const int32_t value1,
const int32_t value2, const std::u16string& stringValue) {
};
virtual void OnCinematicUpdate(Entity* self, Entity* sender, eCinematicEvent event, const std::u16string& pathName,
float_t pathTime, float_t totalTime, int32_t waypoint) {
};
/**
* Used by items to tell their owner that they were equipped.
*
* @param itemOwner The owner of the item
* @param itemObjId The items Object ID
*/
virtual void OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) {};
/**
* Used by items to tell their owner that they were unequipped.
*
* @param itemOwner The owner of the item
* @param itemObjId The items Object ID
*/
virtual void OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) {};
/**
* Handles exiting a scripted activity
*
* @param sender
* @param player the player to remove
* @param canceled if it was done via the cancel button
*/
virtual void OnRequestActivityExit(Entity* sender, LWOOBJID player, bool canceled) {};
virtual void OnZoneLoadedInfo(Entity* self, const GameMessages::ZoneLoadedInfo& info) {};
/**
* @brief Handles notifying when activity data is done
*
* @param self
* @param notify The parameters of the notification
*/
virtual void OnActivityNotify(Entity* self, GameMessages::ActivityNotify& notify) {};
/**
* @brief handles shooting gallery fire
*
* @param self
* @param fire The firing data
*/
virtual void OnShootingGalleryFire(Entity& self, GameMessages::ShootingGalleryFire& fire) {};
/**
* @brief Handles when a child is loaded
*
* @param self
* @param fire The child info
*/
virtual void OnChildLoaded(Entity& self, GameMessages::ChildLoaded& childLoaded) {};
};
Script* const GetScript(Entity* parent, const std::string& scriptName);
// Get the invalid script. Would be a static variable of the namespace, but that would be
// more cluttery to use. Also this allows us to control where this invalid script is defined and initialized
// since we dont want anyone externally modifying it.
Script* const GetInvalidScript();
};