-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.cpp
167 lines (130 loc) · 3.81 KB
/
Plugin.cpp
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 file added in headers queue
// File: "Sources.h"
#include "resource.h"
namespace GOTHIC_ENGINE {
// TO DO
// Your code ...
void Game_Entry() {
}
void Game_Init() {
}
void Game_Exit() {
}
void Game_PreLoop() {
}
void Game_Loop() {
}
void Game_PostLoop() {
}
void Game_MenuLoop() {
}
// Information about current saving or loading world
TSaveLoadGameInfo& SaveLoadGameInfo = UnionCore::SaveLoadGameInfo;
void Game_SaveBegin() {
}
void Game_SaveEnd() {
}
void LoadBegin() {
}
void LoadEnd() {
}
void Game_LoadBegin_NewGame() {
LoadBegin();
}
void Game_LoadEnd_NewGame() {
LoadEnd();
}
void Game_LoadBegin_SaveGame() {
LoadBegin();
}
void Game_LoadEnd_SaveGame() {
LoadEnd();
}
void Game_LoadBegin_ChangeLevel() {
LoadBegin();
}
void Game_LoadEnd_ChangeLevel() {
LoadEnd();
}
void Game_LoadBegin_Trigger() {
}
void Game_LoadEnd_Trigger() {
}
void Game_Pause() {
}
void Game_Unpause() {
}
void Game_DefineExternals() {
}
void Game_ApplyOptions() {
}
HOOK Hook_oCNpc_SetTradeNpc PATCH(&oCNpc::SetTradeNpc, &oCNpc::SetTradeNpc_Union);
void oCNpc::SetTradeNpc_Union(oCNpc* targetNpc) {
if (this == player) {
THISCALL(Hook_oCNpc_SetTradeNpc)(targetNpc);
return;
}
if (targetNpc == nullptr) {
THISCALL(Hook_oCNpc_SetTradeNpc)(targetNpc);
return;
}
auto equippedRangedWeapon = this->GetEquippedRangedWeapon();
auto equippedMeleeWeapon = this->GetEquippedMeleeWeapon();
if (equippedMeleeWeapon) {
this->UnequipItem(equippedMeleeWeapon);
}
if (equippedRangedWeapon) {
this->UnequipItem(equippedRangedWeapon);
}
THISCALL(Hook_oCNpc_SetTradeNpc)(targetNpc);
}
/*
Functions call order on Game initialization:
- Game_Entry * Gothic entry point
- Game_DefineExternals * Define external script functions
- Game_Init * After DAT files init
Functions call order on Change level:
- Game_LoadBegin_Trigger * Entry in trigger
- Game_LoadEnd_Trigger *
- Game_Loop * Frame call window
- Game_LoadBegin_ChangeLevel * Load begin
- Game_SaveBegin * Save previous level information
- Game_SaveEnd *
- Game_LoadEnd_ChangeLevel *
Functions call order on Save game:
- Game_Pause * Open menu
- Game_Unpause * Click on save
- Game_Loop * Frame call window
- Game_SaveBegin * Save begin
- Game_SaveEnd *
Functions call order on Load game:
- Game_Pause * Open menu
- Game_Unpause * Click on load
- Game_LoadBegin_SaveGame * Load begin
- Game_LoadEnd_SaveGame *
*/
#define AppDefault True
CApplication* lpApplication = !CHECK_THIS_ENGINE ? Null : CApplication::CreateRefApplication(
Enabled( AppDefault ) Game_Entry,
Enabled( AppDefault ) Game_Init,
Enabled( AppDefault ) Game_Exit,
Enabled( AppDefault ) Game_PreLoop,
Enabled( AppDefault ) Game_Loop,
Enabled( AppDefault ) Game_PostLoop,
Enabled( AppDefault ) Game_MenuLoop,
Enabled( AppDefault ) Game_SaveBegin,
Enabled( AppDefault ) Game_SaveEnd,
Enabled( AppDefault ) Game_LoadBegin_NewGame,
Enabled( AppDefault ) Game_LoadEnd_NewGame,
Enabled( AppDefault ) Game_LoadBegin_SaveGame,
Enabled( AppDefault ) Game_LoadEnd_SaveGame,
Enabled( AppDefault ) Game_LoadBegin_ChangeLevel,
Enabled( AppDefault ) Game_LoadEnd_ChangeLevel,
Enabled( AppDefault ) Game_LoadBegin_Trigger,
Enabled( AppDefault ) Game_LoadEnd_Trigger,
Enabled( AppDefault ) Game_Pause,
Enabled( AppDefault ) Game_Unpause,
Enabled( AppDefault ) Game_DefineExternals,
Enabled( AppDefault ) Game_ApplyOptions
);
}