forked from thetrueoneshots/CWSDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cwsdk.h
282 lines (229 loc) · 9.9 KB
/
cwsdk.h
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
#ifndef CWMODS_H
#define CWMODS_H
//#define MODLOADER 1
#define EXPORT extern "C" __declspec(dllexport) __declspec(noinline)
//Default C++ Headers
#include <cstdint>
#include <dinput.h>
#include <d3d11.h>
#include <string>
#include <map>
#include <vector>
//IDA Software Types
#include "IDA/types.h"
//Cube Header File
#include "cube/cube.h"
//Common Header Files
#include "common/BytesIO.h"
#include "common/ColorRGB.h"
#include "common/math.h"
#include "common/Matrix4.h"
#include "common/RGBA.h"
#include "common/types.h"
#include "common/Vector2.h"
#include "common/Vector3.h"
//Cube World Header Files, associated with lots of things from Blocks to the Worl Map
#include "cube/AdaptionWidget.h"
#include "cube/AI.h"
#include "cube/BaseWidget.h"
#include "cube/Block.h"
#include "cube/BlockProperties.h"
#include "cube/CharacterPreviewWidget.h"
#include "cube/CharacterStyleWidget.h"
#include "cube/CharacterWidget.h"
#include "cube/ChatWidget.h"
#include "cube/Client.h"
#include "cube/Connection.h"
#include "cube/Controls.h"
#include "cube/ControlsWidget.h"
#include "cube/Creature.h"
#include "cube/Database.h"
#include "cube/Field.h"
#include "cube/FormulaDetailsWidget.h"
#include "cube/EnchantWidget.h"
#include "cube/Equipment.h"
#include "cube/Game.h"
#include "cube/GUI.h"
#include "cube/HelpWidget.h"
#include "cube/Host.h"
#include "cube/Interaction.h"
#include "cube/InventoryWidget.h"
#include "cube/Item.h"
#include "cube/ItemStack.h"
#include "cube/MapOverlayWidget.h"
#include "cube/MultiplayerWidget.h"
#include "cube/Music.h"
#include "cube/Options.h"
#include "cube/OptionsWidget.h"
#include "cube/PreviewWidget.h"
#include "cube/Projectile.h"
#include "cube/QuestionWidget.h"
#include "cube/ResolutionInfo.h"
#include "cube/SaveData.h"
#include "cube/ServerUpdates.h"
#include "cube/SpawnPoint.h"
#include "cube/SpawnPointFactory.h"
#include "cube/Speech.h"
#include "cube/SpeechText.h"
#include "cube/SpeechTextNode.h"
#include "cube/SpeechWidget.h"
#include "cube/Sprite.h"
#include "cube/SpriteManager.h"
#include "cube/SpriteWidget.h"
#include "cube/StartMenuWidget.h"
#include "cube/SystemWidget.h"
#include "cube/TextFX.h"
#include "cube/VoxelWidget.h"
#include "cube/World.h"
#include "cube/WorldMap.h"
#include "cube/XAudio2Engine.h"
#include "cube/Zone.h"
#include "cube/constants.h"
//Graphical Related Headers
#include "gfx/Chunk.h"
#include "gfx/ChunkBuffer.h"
#include "gfx/D3D11Graphics.h"
#include "gfx/D3D11Renderer.h"
#include "gfx/D3D11IndexBuffer.h"
#include "gfx/D3D11VertexBuffer.h"
#include "gfx/Graphics.h"
#include "gfx/IndexBuffer.h"
#include "gfx/Renderer.h"
#include "gfx/VertexBuffer.h"
//Note: Will attempt on making a MSVC port of the CWSDK and Mods
//Using CMAKE sucks TwT
#include "msvc/_Thrd_t.h"
//Plasma Engine Headers
#include "plasma/Attribute.h"
#include "plasma/ContinuousAttribute.h"
#include "plasma/D3D11Engine.h"
#include "plasma/DiscreteAttribute.h"
#include "plasma/Display.h"
#include "plasma/Engine.h"
#include "plasma/FontEngine.h"
#include "plasma/Keyable.h"
#include "plasma/NamedObject.h"
#include "plasma/Matrix.h"
#include "plasma/Map.h"
#include "plasma/Node.h"
#include "plasma/Object.h"
#include "plasma/ObjectManager.h"
#include "plasma/ScalableFont.h"
#include "plasma/Transformation.h"
#include "plasma/Vector.h"
#include "plasma/Widget.h"
#include "plasma/Shape.h"
#include "plasma/TextShape.h"
//Mod Helper Headers
#include "modhelper/Daytime/Daytime.h"
#include "modhelper/Utils/Utils.h"
#include "modhelper/ModMetadata/ModMetadata.h"
#include "modhelper/SpriteLoader/SpriteLoader.h"
#include "modhelper/Items/ModItem.h"
#include "modhelper/Items/ItemData.h"
#include "modhelper/Items/ItemManager.h"
#include "modhelper/Items/ItemRequest.h"
#include "modhelper/CraftingManager/CraftingManager.h"
#include "modhelper/KeybindManager/KeybindManager.h"
#include "modhelper/Widget/ModBaseWidget.h"
//Steam Headers
#include "steam/steam_api_common.h"
void* CWBase();
void* CWOffset(size_t offset);
EXPORT void ModPreInitialize();
EXPORT int ModMajorVersion();
EXPORT int ModMinorVersion();
void WriteByte(void* location, char val);
#ifndef MODLOADER
void WriteFarJMP(void* source, void* destination);
__declspec(noinline) void* operator new(size_t size);
__declspec(noinline) void* operator new[](size_t size);
__declspec(noinline) void operator delete(void* ptr) noexcept;
__declspec(noinline) void operator delete[](void* ptr) noexcept;
#endif
class GenericMod {
public:
enum Priority : u8 {
VeryHighPriority = 0,
HighPriority = 1,
NormalPriority = 2,
LowPriority = 3,
VeryLowPriority = 4
};
modhelper::ModMetadata mod_metadata;
modhelper::SpriteLoader sprite_loader;
modhelper::ItemManager item_manager;
modhelper::CraftingManager crafting_manager;
modhelper::KeybindManager keybind_manager;
// Used for registering to mod callbacks. The callbacks are defined in the CWSDK.
virtual void Initialize() {}
Priority OnChatPriority = NormalPriority;
virtual int OnChat(std::wstring* message) { return 0; }
Priority OnCheckInventoryFullPriority = NormalPriority;
virtual int OnCheckInventoryFull(cube::Creature* player, cube::Item* item) { return 0; }
Priority OnP2PRequestPriority = NormalPriority;
virtual int OnP2PRequest(uint64_t steamID) { return 0; }
Priority OnGameTickPriority = NormalPriority;
virtual void OnGameTick(cube::Game* game) {}
Priority OnZoneGeneratedPriority = NormalPriority;
virtual void OnZoneGenerated(cube::Zone* zone) {}
Priority OnZoneDestroyPriority = NormalPriority;
virtual void OnZoneDestroy(cube::Zone* zone) {}
Priority OnWindowProcPriority = NormalPriority;
virtual int OnWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return 0; }
Priority OnGetKeyboardStatePriority = NormalPriority;
virtual void OnGetKeyboardState(BYTE* diKeys) {}
Priority OnGetMouseStatePriority = NormalPriority;
virtual void OnGetMouseState(DIMOUSESTATE* diMouse) {}
Priority OnPresentPriority = NormalPriority;
virtual void OnPresent(IDXGISwapChain* SwapChain, UINT SyncInterval, UINT Flags) {}
Priority OnCreatureArmorCalculatedPriority = NormalPriority;
virtual void OnCreatureArmorCalculated(cube::Creature* creature, float* armor) {}
Priority OnCreatureCriticalCalculatedPriority = NormalPriority;
virtual void OnCreatureCriticalCalculated(cube::Creature* creature, float* critical) {}
Priority OnCreatureAttackPowerCalculatedPriority = NormalPriority;
virtual void OnCreatureAttackPowerCalculated(cube::Creature* creature, float* power) {}
Priority OnCreatureSpellPowerCalculatedPriority = NormalPriority;
virtual void OnCreatureSpellPowerCalculated(cube::Creature* creature, float* power) {}
Priority OnCreatureHasteCalculatedPriority = NormalPriority;
virtual void OnCreatureHasteCalculated(cube::Creature* creature, float* haste) {}
Priority OnCreatureHPCalculatedPriority = NormalPriority;
virtual void OnCreatureHPCalculated(cube::Creature* creature, float* hp) {}
Priority OnCreatureResistanceCalculatedPriority = NormalPriority;
virtual void OnCreatureResistanceCalculated(cube::Creature* creature, float* resistance) {}
Priority OnCreatureRegenerationCalculatedPriority = NormalPriority;
virtual void OnCreatureRegenerationCalculated(cube::Creature* creature, float* regeneration) {}
Priority OnCreatureManaGenerationCalculatedPriority = NormalPriority;
virtual void OnCreatureManaGenerationCalculated(cube::Creature* creature, float* manaGeneration) {}
Priority OnChunkRemeshPriority = NormalPriority;
virtual void OnChunkRemesh(cube::Zone* zone) {}
Priority OnChunkRemeshedPriority = NormalPriority;
virtual void OnChunkRemeshed(cube::Zone* zone) {}
enum DeathType : __int32 {
COMBAT = 0,
DROWN,
FALL
};
Priority OnPlayerDeathPriority = NormalPriority;
virtual void OnPlayerDeath(cube::Game* game, cube::Creature* player, DeathType type) {}
Priority OnCreatureDeathPriority = NormalPriority;
virtual void OnCreatureDeath(cube::Game* game, cube::Creature* creature, cube::Creature* attacker) {}
Priority OnGameUpdatePriority = NormalPriority;
virtual void OnGameUpdate(cube::Game* game) {}
Priority OnGetItemBuyingPricePriority = NormalPriority;
virtual void OnGetItemBuyingPrice(cube::Item* item, int* price) {}
Priority OnGetItemSellingPricePriority = NormalPriority;
virtual void OnGetItemSellingPrice(cube::Item* item, int* price) {}
Priority OnCreatureCanEquipItemPriority = NormalPriority;
virtual void OnCreatureCanEquipItem(cube::Creature* creature, cube::Item* item, bool* equipable) {}
Priority OnItemGetGoldBagValuePriority = NormalPriority;
virtual void OnItemGetGoldBagValue(cube::Item* item, int* gold) {}
Priority OnClassCanWearItemPriority = NormalPriority;
virtual void OnClassCanWearItem(cube::Item* item, int classType, bool* wearable) {}
//Priority OnGetItemRarityModifierPriority = NormalPriority;
//virtual void OnGetItemRarityModifier(cube::Item* item, cube::Creature* creature, int spirits, float* modifier) {}
Priority OnCraftInventoryUpdatePriority = NormalPriority;
virtual void OnCraftInventoryUpdate(cube::Game* game, cube::Creature* creature, std::vector<std::vector<cube::ItemStack>>* itemVector) {}
#include "VtablePadding.h"
};
#endif // CWMODS_H