Skip to content

Commit

Permalink
Fix #193 initialize focus modes correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
szapp committed Oct 16, 2018
1 parent 5a73598 commit 39e3d26
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
25 changes: 21 additions & 4 deletions _work/data/Scripts/Content/GFA/_intern/init.d
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,27 @@ func void GFA_InitAlways() {
// The focus instances are, however, critical for enabling/disabling free aiming: Reinitialize them by hand.
// Additionally, they need to be reset on loading. Otherwise the default values are lost
MEM_Info("Initializing focus modes.");
const int call = 0;
if (CALL_Begin(call)) {
CALL__cdecl(oCNpcFocus__InitFocusModes);
call = CALL_End();

if (!MEM_ReadInt(oCNpcFocus__focus)) {
// Create and initialize focus modes
const int call = 0;
if (CALL_Begin(call)) {
CALL__cdecl(oCNpcFocus__InitFocusModes);
call = CALL_End();
};
} else {
// Reinitialize already created focus modes
repeat(i, oCNpcFocus__num); var int i;
var int focusModePtr; focusModePtr = MEM_ReadIntArray(oCNpcFocus__focuslist, i);
var int focusModeNamePtr; focusModeNamePtr = oCNpcFocus__focusnames + i * sizeof_zString;

const int call2 = 0;
if (CALL_Begin(call2)) {
CALL_PtrParam(_@(focusModeNamePtr));
CALL__thiscall(_@(focusModePtr), oCNpcFocus__Init);
call2 = CALL_End();
};
end;
};

// Backup focus instance values
Expand Down
6 changes: 6 additions & 0 deletions _work/data/Scripts/Content/GFA/_intern/offsets_G1.d
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const int oCNpc__EV_Strafe_magicCombat = 0;
const int oCNpc__Interrupt_stopAnisLayerA = 6891985; //0x6929D1
const int oCNpc__RefreshNpc_createAmmoIfNone = 6940460; //0x69E72C
const int oCNpcFocus__InitFocusModes = 6507760; //0x634CF0
const int oCNpcFocus__Init = 6508608; //0x635040
const int oCNpcFocus__focusnames = 9283000; //0x8DA5B8
const int oCNpcFocus__focuslist = 9283120; //0x8DA630
const int oCNpcFocus__focus = 9283144; //0x8DA648
const int oCItem___CreateNewInstance = 6764320; //0x673720
const int oCItem__InitByScript = 6755936; //0x671660
const int oCItem__InsertEffect = 0; // Does not exist in Gothic 1
Expand Down Expand Up @@ -256,6 +260,8 @@ const int sizeof_zTTraceRayReport = 40; //0x0028
const int sizeof_zCCollisionReport = 52; //0x0034
const int sizeof_zMAT4 = 64; //0x0040

const int oCNpcFocus__num = 6; // Number of different focus modes

// Trafo matrix as zMAT4 is divided column wise
const int zMAT4_rightVec = 0; // Right vector
const int zMAT4_upVec = 1; // Up vector
Expand Down
6 changes: 6 additions & 0 deletions _work/data/Scripts/Content/GFA/_intern/offsets_G2.d
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const int oCNpc__EV_Strafe_magicCombat = 6833595; //0x6845BB
const int oCNpc__Interrupt_stopAnisLayerA = 7560322; //0x735C82
const int oCNpc__RefreshNpc_createAmmoIfNone = 7611174; //0x742326
const int oCNpcFocus__InitFocusModes = 7072384; //0x6BEA80
const int oCNpcFocus__Init = 7073344; //0x6BEE40
const int oCNpcFocus__focusnames = 11208320; //0xAB0680
const int oCNpcFocus__focuslist = 11208440; //0xAB06F8
const int oCNpcFocus__focus = 11208504; //0xAB0738
const int oCItem___CreateNewInstance = 7423040; //0x714440
const int oCItem__InitByScript = 7412688; //0x711BD0
const int oCItem__InsertEffect = 7416896; //0x712C40
Expand Down Expand Up @@ -256,6 +260,8 @@ const int sizeof_zTTraceRayReport = 40; //0x0028
const int sizeof_zCCollisionReport = 52; //0x0034
const int sizeof_zMAT4 = 64; //0x0040

const int oCNpcFocus__num = 6; // Number of different focus modes

// Trafo matrix as zMAT4 is divided column wise
const int zMAT4_rightVec = 0; // Right vector
const int zMAT4_upVec = 1; // Up vector
Expand Down

0 comments on commit 39e3d26

Please sign in to comment.