Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor change VOB location fix #370

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/Ninja/G1CP/Content/Fixes/Gamesave/fix051_StonehengeCryptChest.d
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
/*
* #51 Chest in stonehenge crypt behind wall
*/

/*
* Make the positions available to the functions below
*/
const float G1CP_051_StonehengeCryptChest_OriginalPos[3] = {-35498.5625, 2331.01416, -13830.9131};
const float G1CP_051_StonehengeCryptChest_CorrectedPos[3] = {-35311.8100, 2281.0100, -14096.8200};

/*
* Apply the fix
*/
func int G1CP_051_StonehengeCryptChest() {
var int vobPtr; vobPtr = G1CP_FindVobByPosF(-35498.5625, 2331.01416, -13830.9131, Hlp_Is_oCMobContainer);
if (vobPtr) {
G1CP_MoveVobToPosF(vobPtr, -35311.8100, 2281.0100, -14096.8200);
return TRUE;
};
return FALSE;
return G1CP_ChangeVobLocation(G1CP_051_StonehengeCryptChest_OriginalPos, G1CP_051_StonehengeCryptChest_CorrectedPos,
Hlp_Is_oCMobContainer);
};

/*
* This function reverts the changes
*/
func int G1CP_051_StonehengeCryptChestRevert() {
// Only revert if it was applied by the G1CP
if (!G1CP_IsFixApplied(51)) {
return FALSE;
};

// Search the VOB again
var int vobPtr; vobPtr = G1CP_FindVobByPosF(-35311.8100, 2281.0100, -14096.8200, Hlp_Is_oCMobContainer);
if (vobPtr) {
G1CP_MoveVobToPosF(vobPtr, -35498.5625, 2331.01416, -13830.9131);
return TRUE;
};
return FALSE;
return G1CP_ChangeVobLocation(G1CP_051_StonehengeCryptChest_CorrectedPos, G1CP_051_StonehengeCryptChest_OriginalPos,
Hlp_Is_oCMobContainer);
};
32 changes: 16 additions & 16 deletions src/Ninja/G1CP/Content/Fixes/Gamesave/fix057_CastleWallTexture.d
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/*
* #57 Misplaced texture near Gravo
*/
func int G1CP_057_CastleWallTexture() {
var int vobPtr; vobPtr = G1CP_FindVobByPosF(-5893.91455, -664.270386, 78.9339142, G1CP_057_CastleWallTextureCheck);
if (vobPtr) {
G1CP_MoveVobToPosF(vobPtr, -5902.01807, -664.270386, 82.8507462);
return TRUE;
};
return FALSE;
};

/*
* Make the positions available to the functions below
*/
const float G1CP_057_CastleWallTexture_OriginalPos[3] = {-5893.91455, -664.270386, 78.9339142};
const float G1CP_057_CastleWallTexture_CorrectedPos[3] = {-5902.01807, -664.270386, 82.8507462};

/*
* Callback function to check the found VOBs: Check if the VOB's visual is a decal
Expand All @@ -19,20 +17,22 @@ func int G1CP_057_CastleWallTextureCheck(var int vobPtr) {
return (MEM_GetClassDef(vob.visual) == zCDecal_classDef);
};

/*
* Apply the fix
*/
func int G1CP_057_CastleWallTexture() {
return G1CP_ChangeVobLocation(G1CP_057_CastleWallTexture_OriginalPos, G1CP_057_CastleWallTexture_CorrectedPos,
G1CP_057_CastleWallTextureCheck);
};

/*
* This function reverts the changes
*/
func int G1CP_057_CastleWallTextureRevert() {
// Only revert if it was applied by the G1CP
if (!G1CP_IsFixApplied(57)) {
return FALSE;
};

// Find the VOB again
var int vobPtr; vobPtr = G1CP_FindVobByPosF(-5902.01807, -664.270386, 82.8507462, G1CP_057_CastleWallTextureCheck);
if (vobPtr) {
G1CP_MoveVobToPosF(vobPtr, -5893.91455, -664.270386, 78.9339142);
return TRUE;
};
return FALSE;
return G1CP_ChangeVobLocation(G1CP_057_CastleWallTexture_CorrectedPos, G1CP_057_CastleWallTexture_OriginalPos,
G1CP_057_CastleWallTextureCheck);
};
14 changes: 14 additions & 0 deletions src/Ninja/G1CP/Content/Misc/world.d
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,17 @@ func int G1CP_GetWorldTime() {

return hour * 100 + min;
};

/*
* Find VOB in the world by its exact position and move it to another position. Returns true on success.
*/
func int G1CP_ChangeVobLocation(var float originalPos, var float correctedPos, var int callback) {
var int vobPtr; vobPtr = G1CP_FindVobByPosPtr(_@(originalPos), callback);

if (!vobPtr) {
return FALSE;
};

G1CP_MoveVobToPosPtr(vobPtr, _@(correctedPos));
return TRUE;
};
Loading