@@ -29,6 +29,25 @@ OTHER DEALINGS IN THE SOFTWARE.
29
29
Compile as x64 code
30
30
*/
31
31
32
+ /*
33
+ Get cell regions:
34
+ 1) Call TESCell__sub_1403B4A10
35
+ 2) [eax + 0x8] - first region
36
+ 3) [eax + 0x10] - pointer to RegionUnk struct
37
+
38
+ struct RegionUnk {
39
+ TESRegion *region;
40
+ RegionUnk *nextRegionUnk;
41
+ };
42
+ */
43
+
44
+ /*
45
+ Check if cell is within region border:
46
+ 1) Get cell regions
47
+ 2) If there's border region the cell is within border region,
48
+ otherwise it is outside.
49
+ */
50
+
32
51
/*
33
52
Is current cell interior or exterior check:
34
53
1) Get ObjectReference pointer (rax)
@@ -165,6 +184,13 @@ internal _TESObjectReference_MoveToCell TESObjectReference_MoveToCell;
165
184
internal _TESObjectReference_GetCurrentLocation TESObjectReference_GetCurrentLocation;
166
185
// ------ #TESObjectReference ------
167
186
187
+ // ------ TESCell ------
188
+ typedef TESCellUnk * (__fastcall *_TESCell_GetUnk)
189
+ (TESCell *cell, bool flag);
190
+
191
+ internal _TESCell_GetUnk TESCell_GetUnk;
192
+ // ------ #TESCell ------
193
+
168
194
// ------ TESWorldSpace ------
169
195
typedef TESCell * (__fastcall *_TESWorldSpace_FindExteriorCellByCoordinates)
170
196
(TESWorldSpace *tesWorldSpace, unsigned int cellX, unsigned int cellY);
@@ -233,6 +259,8 @@ extern "C" {
233
259
uint64 TESObjectReferenceMoveToCellAddress;
234
260
uint64 TESObjectReferenceGetCurrentLocationAddress;
235
261
262
+ uint64 TESCellGetUnkAddress;
263
+
236
264
uint64 TESWorldSpaceFindExteriorCellByCoordinatesAddress;
237
265
238
266
uint64 TESFindInteriorCellByNameAddress;
@@ -277,6 +305,8 @@ internal void DefineAddresses()
277
305
TESObjectReferenceMoveToCellAddress = 0x00E9A330 ;
278
306
TESObjectReferenceGetCurrentLocationAddress = 0x0040EE70 ;
279
307
308
+ TESCellGetUnkAddress = 0x003B4A30 ;
309
+
280
310
TESWorldSpaceFindExteriorCellByCoordinatesAddress = 0x004923E0 ;
281
311
282
312
TESFindInteriorCellByNameAddress = 0x00152EB0 ;
@@ -317,6 +347,8 @@ internal void DefineAddresses()
317
347
TESObjectReferenceMoveToCellAddress = 0x00E989E0 ;
318
348
TESObjectReferenceGetCurrentLocationAddress = 0x0040EE50 ;
319
349
350
+ TESCellGetUnkAddress = 0x003B4A10 ;
351
+
320
352
TESWorldSpaceFindExteriorCellByCoordinatesAddress = 0x004923C0 ;
321
353
322
354
TESFindInteriorCellByNameAddress = 0x00152EB0 ;
@@ -365,6 +397,8 @@ internal void ShiftAddresses()
365
397
TESObjectReference_MoveToCell = (_TESObjectReference_MoveToCell)(TESObjectReferenceMoveToCellAddress + baseAddress);
366
398
TESObjectReference_GetCurrentLocation = (_TESObjectReference_GetCurrentLocation)(TESObjectReferenceGetCurrentLocationAddress + baseAddress);
367
399
400
+ TESCell_GetUnk = (_TESCell_GetUnk)(TESCellGetUnkAddress + baseAddress);
401
+
368
402
TESWorldSpace_FindExteriorCellByCoordinates = (_TESWorldSpace_FindExteriorCellByCoordinates)(TESWorldSpaceFindExteriorCellByCoordinatesAddress + baseAddress);
369
403
370
404
TESFindInteriorCellByName = (_TESFindInteriorCellByName)(TESFindInteriorCellByNameAddress + baseAddress);
@@ -422,7 +456,7 @@ internal TESWorldSpace * GetPlayerCurrentWorldSpace()
422
456
TESWorldSpace *worldspace = 0 ;
423
457
424
458
TESPlayer *player = TES_GetPlayer ();
425
- TESCell *playerCell = player->objectReference .parentCell ;
459
+ TESCell *playerCell = player->tesActor . objectReference .parentCell ;
426
460
427
461
if ( playerCell ) {
428
462
worldspace = playerCell->worldSpace ;
@@ -463,6 +497,30 @@ internal TESWorldSpace * GetPlayerCurrentWorldSpace()
463
497
464
498
return worldspace;
465
499
}
500
+
501
+ internal bool IsCellWithinBorderRegion (TESCell *cell)
502
+ {
503
+ bool result = false ;
504
+
505
+ TESCellUnk *cellUnk = TESCell_GetUnk (cell, 1 );
506
+
507
+ if ( cellUnk ) {
508
+ RegionUnk *regionUnk = (RegionUnk *)(&cellUnk->region );
509
+ if ( regionUnk ) {
510
+ while ( regionUnk ) {
511
+ TESRegion *region = regionUnk->region ;
512
+ if ( !region ) break ;
513
+
514
+ result = ((region->tesForm .flags ) >> 6 ) && 1 ;
515
+ if ( result ) break ;
516
+
517
+ regionUnk = regionUnk->nextRegionUnk ;
518
+ }
519
+ }
520
+ }
521
+
522
+ return result;
523
+ }
466
524
// ------ #Functions ------
467
525
468
526
#endif
0 commit comments