Skip to content

Commit

Permalink
Player Randomizer: Implement michael4/jewelry_setup no-suit
Browse files Browse the repository at this point in the history
  • Loading branch information
Parik27 committed May 30, 2021
1 parent 1b64757 commit 3a8d548
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build-count.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
390
392
28 changes: 28 additions & 0 deletions src/mission/missions_YscUtils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,34 @@ public:
pPatternResult = ptr;
}

/* Reinitialises the UtilsOps to the branch destination at offset of stored
* ptr */
void
FollowBranchDestination (int64_t offset)
{
switch (*Get<YscOpCode> (offset))
{
// Absolute offset
case YscOpCode::CALL:
pPatternResult = &GetProgram ()->GetCodeByte<uint8_t> (
(*Get<uint32_t> (offset) >> 8));
break;

// Relative offset
case YscOpCode::J:
case YscOpCode::JZ:
case YscOpCode::IEQ_JZ:
case YscOpCode::INE_JZ:
case YscOpCode::IGT_JZ:
case YscOpCode::IGE_JZ:
case YscOpCode::ILT_JZ:
case YscOpCode::ILE_JZ:
pPatternResult += *Get<uint16_t> (offset + 1) + (offset + 3);

default: bOperationFailed = true; break;
}
}

/* Returns the evaluated pattern/initialised value of the stored ptr */
template <typename T>
T *
Expand Down
36 changes: 36 additions & 0 deletions src/peds/peds_PlayerFixes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "CModelInfo.hh"
#include "ParserUtils.hh"
#include "mission/missions_YscUtils.hh"
#include "peds_Compatibility.hh"

#include <CPed.hh>
Expand Down Expand Up @@ -133,6 +134,37 @@ class PedRandomizer_PlayerFixes
return true;
}

/*******************************************************/
static bool
RemoveJewelrySetupClothesRequirement (YscUtilsOps &ops)
{
if (!ops.IsAnyOf ("mission_triggerer_a"_joaat))
return false;

uint8_t return_0x1[] = {0x6f, 0x2e, 0x00, 0x01};

ops.Init ("2d 00 03 00 ? 2c ? 00 74 71 5d ? ? ? 39 02 38 02 6e");
ops.WriteBytes (/*Offset=*/5, return_0x1);

return true;
}

/*******************************************************/
static bool
RemoveMichael4ClothesRequirement (YscUtilsOps &ops)
{
if (!ops.IsAnyOf ("michael4"_joaat))
return false;

uint8_t return_0x1[] = {0x6f, 0x2e, 0x03, 0x01};

ops.Init ("26 0c 10 5d ? ? ? 06 56 ? ? 28 c9 14 71 0d");
ops.FollowBranchDestination (/*Offset=*/3);
ops.WriteBytes (/*Offset=*/5, return_0x1);

return true;
}

/*******************************************************/
template <auto &CPlayerPedSaveStructure__PreSave>
static void
Expand Down Expand Up @@ -191,6 +223,10 @@ public:

YscCodeEdits::Add ("Remove Lester1 Clothes Requirement",
RemoveLester1ClothesRequirement);
YscCodeEdits::Add ("Remove JewelrySetup Clothes Requirement",
RemoveJewelrySetupClothesRequirement);
YscCodeEdits::Add ("Remove Michael4 Clothes Requirement",
RemoveMichael4ClothesRequirement);
}

/*******************************************************/
Expand Down

0 comments on commit 3a8d548

Please sign in to comment.