-
Notifications
You must be signed in to change notification settings - Fork 2
/
game_Events_G1.d
213 lines (157 loc) · 5.13 KB
/
game_Events_G1.d
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
/*
*
*/
//[Internal variables]
var int _TradeOnAccept_Event;
var int _TradeOnAccept_Event_Break;
var int _TradeOnExit_Event;
var int _TradeOnExit_Event_Break;
var int _TradeHandleEvent_Event;
var int _TradeHandleEvent_Event_Break;
var int _ItemContainerActivate_Event;
var int _ItemContainerHandleEvent_Event;
var int _StealContainerHandleEvent_Event;
var int _NpcContainerHandleEvent_Event;
var int _NpcInventoryHandleEvent_Event;
func void TradeOnAcceptEvent_AddListener (var func f) {
Event_AddOnce (_TradeOnAccept_Event, f);
};
func void TradeOnAcceptEvent_RemoveListener (var func f) {
Event_Remove (_TradeOnAccept_Event, f);
};
func void TradeOnExitEvent_AddListener (var func f) {
Event_AddOnce (_TradeOnExit_Event, f);
};
func void TradeOnExitEvent_RemoveListener (var func f) {
Event_Remove (_TradeOnExit_Event, f);
};
func void TradeHandleEvent_AddListener (var func f) {
Event_AddOnce (_TradeHandleEvent_Event, f);
};
func void TradeHandleEvent_RemoveListener (var func f) {
Event_Remove (_TradeHandleEvent_Event, f);
};
func void ItemContainerActivate_AddListener (var func f) {
Event_AddOnce (_ItemContainerActivate_Event, f);
};
func void ItemContainerActivate_RemoveListener (var func f) {
Event_Remove (_ItemContainerActivate_Event, f);
};
func void ItemContainerHandleEvent_AddListener (var func f) {
Event_AddOnce (_ItemContainerHandleEvent_Event, f);
};
func void ItemContainerHandleEvent_RemoveListener (var func f) {
Event_Remove (_ItemContainerHandleEvent_Event, f);
};
func void StealContainerHandleEvent_AddListener (var func f) {
Event_AddOnce (_StealContainerHandleEvent_Event, f);
};
func void StealContainerHandleEvent_RemoveListener (var func f) {
Event_Remove (_StealContainerHandleEvent_Event, f);
};
func void NpcContainerHandleEvent_AddListener (var func f) {
Event_AddOnce (_NpcContainerHandleEvent_Event, f);
};
func void NpcContainerHandleEvent_RemoveListener (var func f) {
Event_Remove (_NpcContainerHandleEvent_Event, f);
};
func void NpcInventoryHandleEvent_AddListener (var func f) {
Event_AddOnce (_NpcInventoryHandleEvent_Event, f);
};
func void NpcInventoryHandleEvent_RemoveListener (var func f) {
Event_Remove (_NpcInventoryHandleEvent_Event, f);
};
//---
func void _hook_oCViewDialogTrade_OnAccept () {
_TradeOnAccept_Event_Break = FALSE;
Event_Execute (_TradeOnAccept_Event, 0);
};
func void _hook_oCViewDialogTrade_OnExit () {
_TradeOnExit_Event_Break = FALSE;
Event_Execute (_TradeOnExit_Event, 0);
};
func void _hook_oCViewDialogTrade_HandleEvent () {
//--> Safety check
if (!MEM_InformationMan.DlgTrade) { return; };
var oCViewDialogTrade dialogTrade;
dialogTrade = _^ (MEM_InformationMan.DlgTrade);
if (!dialogTrade.IsActivated) { return; };
//<--
_TradeHandleEvent_Event_Break = FALSE;
Event_Execute (_TradeHandleEvent_Event, 0);
};
//---
func void _hook_oCItemContainer_Activate () {
Event_Execute (_ItemContainerActivate_Event, 0);
};
func void _hook_oCItemContainer_HandleEvent () {
Event_Execute (_ItemContainerHandleEvent_Event, 0);
};
func void _hook_oCStealContainer_HandleEvent () {
Event_Execute (_StealContainerHandleEvent_Event, 0);
};
func void _hook_oCNpcContainer_HandleEvent () {
Event_Execute (_NpcContainerHandleEvent_Event, 0);
};
func void _hook_oCNpcInventory_HandleEvent () {
Event_Execute (_NpcInventoryHandleEvent_Event, 0);
};
//---
func void G1_TradeEvents_Init () {
if (!_TradeOnAccept_Event) {
_TradeOnAccept_Event = Event_Create ();
};
if (!_TradeOnExit_Event) {
_TradeOnExit_Event = Event_Create ();
};
if (!_TradeHandleEvent_Event) {
_TradeHandleEvent_Event = Event_Create ();
};
const int once = 0;
if (!once) {
//[Trade events]
HookEngine (oCViewDialogTrade__OnAccept, 6, "_hook_oCViewDialogTrade_OnAccept");
HookEngine (oCViewDialogTrade__OnExit, 5, "_hook_oCViewDialogTrade_OnExit");
HookEngine (oCViewDialogTrade__HandleEvent, 7, "_hook_oCViewDialogTrade_HandleEvent");
once = 1;
};
};
func void G1_ItemContainerActivateEvent_Init () {
if (!_ItemContainerActivate_Event) {
_ItemContainerActivate_Event = Event_Create ();
};
const int once = 0;
if (!once) {
HookEngine (oCItemContainer__Activate, 7, "_hook_oCItemContainer_Activate");
once = 1;
};
};
func void G1_InventoryEvents_Init () {
G1_ItemContainerActivateEvent_Init ();
if (!_ItemContainerHandleEvent_Event) {
_ItemContainerHandleEvent_Event = Event_Create ();
};
if (!_StealContainerHandleEvent_Event) {
_StealContainerHandleEvent_Event = Event_Create ();
};
if (!_NpcContainerHandleEvent_Event) {
_NpcContainerHandleEvent_Event = Event_Create ();
};
if (!_NpcInventoryHandleEvent_Event) {
_NpcInventoryHandleEvent_Event = Event_Create ();
};
const int once = 0;
if (!once) {
//G2A HookLen 6
HookEngine (oCItemContainer__HandleEvent, 7, "_hook_oCItemContainer_HandleEvent");
HookEngine (oCStealContainer__HandleEvent, 6, "_hook_oCStealContainer_HandleEvent");
//G2A HookLen 7
HookEngine (oCNpcContainer__HandleEvent, 8, "_hook_oCNpcContainer_HandleEvent");
HookEngine (oCNpcInventory__HandleEvent, 6, "_hook_oCNpcInventory_HandleEvent");
once = 1;
};
};
func void G1_GameEvents_Init () {
G1_TradeEvents_Init ();
G1_InventoryEvents_Init ();
};