2
#include "../../Misc/SWTypes.h"
4
DEFINE_HOOK(6CEF84, SuperWeaponTypeClass_GetCursorOverObject, 7)
6
GET(SuperWeaponTypeClass*, pThis, ECX);
8
SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pThis);
10
if(pThis->Action == SW_YES_CURSOR) {
11
GET_STACK(CellStruct *, pMapCoords, 0x0C);
13
int Action = SW_YES_CURSOR;
15
if(!pData->SW_FireToShroud.Get()) {
16
CellClass* pCell = MapClass::Instance->GetCellAt(pMapCoords);
19
if(MapClass::Instance->IsLocationShrouded(pCell->GetCoords(&Crd))) {
20
Action = SW_NO_CURSOR;
24
if(pThis->Type >= FIRST_SW_TYPE && !NewSWType::GetNthItem(pThis->Type)->CanFireAt(pMapCoords)) {
25
Action = SW_NO_CURSOR;
30
if(Action == SW_YES_CURSOR) {
31
SWTypeExt::CurrentSWType = pThis;
32
Actions::Set(&pData->SW_Cursor, pData->SW_FireToShroud);
34
SWTypeExt::CurrentSWType = NULL;
35
Actions::Set(&pData->SW_NoCursor, pData->SW_FireToShroud);
43
DEFINE_HOOK(653B3A, RadarClass_GetMouseAction_CustomSWAction, 5)
45
int idxSWType = Unsorted::CurrentSWType;
47
GET_STACK(byte, EventFlags, 0x58);
49
MouseEvent::Value E(EventFlags);
50
if(E & (MouseEvent::RightDown | MouseEvent::RightUp)) {
54
SuperWeaponTypeClass *pThis = SuperWeaponTypeClass::Array->GetItem(idxSWType);
55
SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pThis);
57
if(pThis->Action == SW_YES_CURSOR) {
58
GET_STACK(CellStruct, pMapCoords, STACK_OFFS(0x54, 0x3C));
60
int Action = SW_YES_CURSOR;
62
if(!pData->SW_FireToShroud.Get()) {
63
CellClass* pCell = MapClass::Instance->GetCellAt(&pMapCoords);
66
if(MapClass::Instance->IsLocationShrouded(pCell->GetCoords(&Crd))) {
67
Action = SW_NO_CURSOR;
71
if(pThis->Type >= FIRST_SW_TYPE && !NewSWType::GetNthItem(pThis->Type)->CanFireAt(&pMapCoords)) {
72
Action = SW_NO_CURSOR;
77
if(Action == SW_YES_CURSOR) {
78
SWTypeExt::CurrentSWType = pThis;
79
Actions::Set(&pData->SW_Cursor, pData->SW_FireToShroud);
81
SWTypeExt::CurrentSWType = NULL;
82
Actions::Set(&pData->SW_NoCursor, pData->SW_FireToShroud);
92
XPORT_FUNC(SidebarClass_ProcessCameoClick)
94
DWORD idx = R->get_ESI();
95
SuperWeaponTypeClass *pThis = SuperWeaponTypeClass::Array->GetItem(idx);
96
// int TypeIdx = pThis->get_Type();
98
SWTypeExt::CurrentSWType = pThis;
99
SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pThis);
101
// Actions::Set(&pData->SW_Cursor);
107
// decouple SpyPlane from SPYP
108
DEFINE_HOOK(6CD67A, SuperClass_Launch_SpyPlane_FindType, 0)
110
GET(SuperClass *, Super, EBX);
111
SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(Super->Type);
113
R->EAX<int>(pData->SpyPlane_TypeIndex);
117
// decouple SpyPlane from allied paradrop counts
118
DEFINE_HOOK(6CD6A6, SuperClass_Launch_SpyPlane_Fire, 6)
120
GET(SuperClass *, Super, EBX);
121
GET(CellClass *,TargetCell, EDI);
122
SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(Super->Type);
124
Super->Owner->SendSpyPlanes(
125
pData->SpyPlane_TypeIndex, pData->SpyPlane_Count, pData->SpyPlane_Mission, TargetCell, NULL);
130
// decouple nuke siren from DigSound
131
DEFINE_HOOK(6CDDE3, SuperClass_Launch_Nuke_Siren, 6)
133
GET(SuperClass *, Super, EBX);
134
SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(Super->Type);
136
R->ECX(pData->Nuke_Siren);
141
DEFINE_HOOK(6CEE96, SuperWeaponTypeClass_GetTypeIndex, 5)
143
GET(const char *, TypeStr, EDI);
144
int customType = NewSWType::FindIndex(TypeStr);
145
if(customType > -1) {
153
// translates SW click to type
154
DEFINE_HOOK(4AC20C, DisplayClass_LMBUp, 7)
156
int Action = R->Stack32(0x9C);
157
if(Action < SW_NO_CURSOR) {
158
SuperWeaponTypeClass * pSW = SuperWeaponTypeClass::FindFirstOfAction(Action);
160
return pSW ? 0x4AC21C : 0x4AC294;
162
else if(Action == SW_NO_CURSOR) {
167
R->EAX(SWTypeExt::CurrentSWType);
172
// decoupling sw anims from types
174
DEFINE_HOOK(446418, BuildingClass_Place1, 6)
176
GET(BuildingClass *, pBuild, EBP);
177
GET(HouseClass *, pHouse, EAX);
178
int swTIdx = pBuild->Type->SuperWeapon;
180
swTIdx = pBuild->Type->SuperWeapon2;
186
R->EAX(pHouse->Supers.GetItem(swTIdx));
191
DEFINE_HOOK(44656D, BuildingClass_Place2, 6)
197
DEFINE_HOOK(45100A, BuildingClass_ProcessAnims1, 6)
199
GET(BuildingClass *, pBuild, ESI);
200
GET(HouseClass *, pHouse, EAX);
201
int swTIdx = pBuild->Type->SuperWeapon;
203
swTIdx = pBuild->Type->SuperWeapon2;
209
R->EDI(pBuild->Type);
210
R->EAX(pHouse->Supers.GetItem(swTIdx));
215
DEFINE_HOOK(451132, BuildingClass_ProcessAnims2, 6)
222
DEFINE_HOOK(446937, BuildingClass_AnnounceSW, 6)
224
GET(BuildingClass *, pBuild, EBP);
225
int swTIdx = pBuild->Type->SuperWeapon;
227
swTIdx = pBuild->Type->SuperWeapon2;
233
SuperWeaponTypeClass *pSW = SuperWeaponTypeClass::Array->GetItem(swTIdx);
234
SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pSW);
236
if(pData->EVA_Detected != -1) {
237
VoxClass::PlayIndex(pData->EVA_Detected);
245
DEFINE_HOOK(6CBDD7, SuperClass_AnnounceReady, 6)
247
GET(SuperWeaponTypeClass *, pThis, EAX);
248
SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pThis);
250
if(pData->EVA_Ready != -1) {
251
VoxClass::PlayIndex(pData->EVA_Ready);
258
DEFINE_HOOK(6CC0EA, SuperClass_AnnounceQuantity, 9)
260
GET(SuperClass *, pThis, ESI);
261
SuperWeaponTypeClass *pSW = pThis->Type;
262
SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pSW);
264
if(pData->EVA_Ready != -1) {
265
VoxClass::PlayIndex(pData->EVA_Ready);
271
DEFINE_HOOK(50B319, HouseClass_UpdateSWs, 6)
273
// GET(SuperClass *, Super, ECX);
274
GET(HouseClass *, H, EBP);
275
GET(int, Index, EDI);
276
SuperClass *Super = H->Supers.GetItem(Index);
277
SuperWeaponTypeClass *pSW = Super->Type;
278
SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pSW);
279
if(pData->SW_AutoFire) {
280
// Fire! requires networking event woodoo or fake mouse clicks, bah
285
// EVA_Activated is complex, will do later
287
// AI SW targeting submarines
288
DEFINE_HOOK(50CFAA, HouseClass_PickOffensiveSWTarget, 0)
296
DEFINE_HOOK(6CC390, SuperClass_Launch, 6)
298
GET(SuperClass *, pSuper, ECX);
299
GET_STACK(CellStruct*, pCoords, 0x4);
300
GET_STACK(byte, IsPlayer, 0x8);
301
bool handled = SWTypeExt::SuperClass_Launch(pSuper, pCoords, IsPlayer);
303
return handled ? 0x6CDE40 : 0;
306
DEFINE_HOOK(6CC360, SuperClass_IsReadyToFire, 5)
308
GET(SuperClass *, pThis, ECX);
309
SuperWeaponTypeClass *pSW = pThis->Type;
310
SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pSW);
312
if(pData->Money_Amount) {
313
if(pThis->Owner->Available_Money() < pData->Money_Amount) {
320
DEFINE_HOOK(44691B, BuildingClass_4DC_SWAvailable, 6)
322
GET(BuildingClass *, Structure, EBP);
323
GET(BuildingTypeClass *, AuxBuilding, EAX);
324
return Structure->Owner->CountOwnedNow(AuxBuilding) > 0
330
DEFINE_HOOK(45765A, BuildingClass_SWAvailable, 6)
332
GET(BuildingClass *, Structure, ESI);
333
GET(BuildingTypeClass *, AuxBuilding, EAX);
334
return Structure->Owner->CountOwnedNow(AuxBuilding) > 0
340
DEFINE_HOOK(4576BA, BuildingClass_SW2Available, 6)
342
GET(BuildingClass *, Structure, ESI);
343
GET(BuildingTypeClass *, AuxBuilding, EAX);
344
return Structure->Owner->CountOwnedNow(AuxBuilding) > 0