Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Parik27 committed Nov 6, 2023
2 parents 9ff5a9d + 6396908 commit 24aa1a5
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 23 deletions.
2 changes: 1 addition & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ EnableEasterEgg = true
# Cutscene Randomizer
# Randomizes the models used in motion-captured cutscenes, as well as the location in which they take place.

# Voice Line Randomizer
# Sound Randomizer
# Randomizes dialogue spoken by characters in missions. (Requires original AudioEvents.txt)
# Can also randomize generic ped lines and some other types of sound effects.

Expand Down
2 changes: 1 addition & 1 deletion include/config_default.hh
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ EnableEasterEgg = true
# Cutscene Randomizer
# Randomizes the models used in motion-captured cutscenes, as well as the location in which they take place.
# Voice Line Randomizer
# Sound Randomizer
# Randomizes dialogue spoken by characters in missions. (Requires original AudioEvents.txt)
# Can also randomize generic ped lines and some other types of sound effects.
Expand Down
55 changes: 53 additions & 2 deletions include/functions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,59 @@ struct CPlayerInfo
char field_0x00[0x18c];
};

struct CObject : public CEntity
{
struct CObjectInfo
{
float m_fMass;
float m_fTurnMass;
float m_fAirResistance;
float m_fElasticity;
float m_fBuoyancyConstant;
float m_fUprootLimit;
float m_fColDamageMultiplier;
char m_bColDamageEffect;
char m_bSpecialColResponseCase;
bool m_nCameraAvoidObject;
bool b_CausesExplosion;
int m_bFxType;
RwV3d m_vFxOffset;
int m_pFxSystem;
float m_fSmashMultiplier;
RwV3d m_vBreakVelocity;
float m_fBreakVelocityRand;
int m_dwGunBreakMode;
int m_dwSparksOnImpact;
};

struct CObject : public CPhysical
{
int m_pControlCodeList;
char m_nObjectType;
char m_nBonusValue;
char m_nCostValue;
int m_nObjectFlags;
char m_nCurrentColDamageEffect;
char m_nStoredColDamageEffect;
char field_146;
char m_nGarageDoorGarageIndex;
char m_nLastWeaponDamage;
char m_nColBrightness;
short m_wCarPartModelIndex;
int m_nColorId;
int m_nRemovalTime;

float m_fHealth;
float m_fDoorAngle;
float m_fScale;
CObjectInfo* m_pObjectInfo;
int m_pFire;
short m_wScriptTriggerIndex;
short m_wRemapTxd;
int m_pRemapTexture;
int m_pDummyObject;
int m_dwTimeToRemoveParticles;
float m_fParticlesIntensity;

static CObject *Create (int modelId);
};

#pragma pack(push, 1)
Expand Down
6 changes: 4 additions & 2 deletions include/objects.hh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public:
322, 323, 324, 325, 326, 329, 330, 386};

static inline std::vector<int> objectsToIgnore
= {44, 87, 88, 89, 159, 161, 239, 240, 241,
242, 305, 306, 314, 333, 334, 336, 347};
= {44, 87, 88, 89, 159, 161, 222, 227, 239, 240, 241,
242, 305, 306, 307, 314, 333, 334, 336, 347};

static inline bool modifyObject = false;
};
7 changes: 7 additions & 0 deletions src/functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,13 @@ CShopping::LoadShoppingType (const char *name)
Call<0x49B8D0> (name);
}

/*******************************************************/
CObject*
CObject::Create (int modelId)
{
return CallAndReturn<CObject *, 0x5A1F60> (modelId);
}

/*******************************************************/
int
CIplStore::FindIplSlot (char *name)
Expand Down
32 changes: 31 additions & 1 deletion src/objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void __fastcall RandomizeObjectIndices (CRunningScript *script, void *edx,
{
objectsToUse = ObjectsRandomizer::GetInstance ()
->destructibleObjects;
ObjectsRandomizer::modifyObject = true;
}
else
{
Expand All @@ -59,14 +60,43 @@ void __fastcall RandomizeObjectIndices (CRunningScript *script, void *edx,
}
}

// Directly modifies the data of the created object to change its properties.
// Values still need to be worked out.
/*******************************************************/
CObject *
ChangeObjectData (int modelId)
{
CObject *obj = CObject::Create (modelId);
if (ObjectsRandomizer::modifyObject)
{
// obj->m_pObjectInfo->m_fMass = 50.0f;
//obj->m_pObjectInfo->m_fTurnMass = 150.0f;
// obj->m_pObjectInfo->m_fAirResistance = 0.99f;
//obj->m_pObjectInfo->m_fElasticity = 0.0f;
// obj->m_pObjectInfo->m_fUprootLimit = 350.0f;
//obj->m_pObjectInfo->m_fColDamageMultiplier = 5.0f;

obj->m_pObjectInfo->m_bColDamageEffect = 200;
obj->m_pObjectInfo->m_fSmashMultiplier = 1.0f;
obj->m_pObjectInfo->m_vBreakVelocity = {0.0f, 0.0f, 0.1f};
obj->m_pObjectInfo->m_fBreakVelocityRand = 0.07f;
obj->m_pObjectInfo->m_dwGunBreakMode = 2;
obj->m_pObjectInfo->m_dwSparksOnImpact = 0;
obj->m_fHealth = 1.0f;
ObjectsRandomizer::modifyObject = false;
}
return obj;
}

/*******************************************************/
void
ObjectsRandomizer::Initialise ()
{
if (!ConfigManager::ReadConfig ("ObjectRandomizer"))
return;

RegisterHooks ({{HOOK_CALL, 0x469773, (void *) RandomizeObjectIndices}});
RegisterHooks ({{HOOK_CALL, 0x469773, (void *) RandomizeObjectIndices}/*,
{HOOK_CALL, 0x46979B, (void *) ChangeObjectData}*/});
Logger::GetLogger ()->LogMessage ("Intialised ObjectsRandomizer");
}

Expand Down
42 changes: 26 additions & 16 deletions src/util/dyom/TTS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -516,27 +516,37 @@ DyomRandomizerTTS::ProcessTTS ()
void
DyomRandomizerTTS::ReadSwearFilterFile ()
{
auto filterFile = GetRainbomizerDataFile("Swear_Words.txt");
char line[512] = {};

while (fgets (line, 256, filterFile))
FILE *filterFile = OpenRainbomizerFile ("Swear_Words.txt", "r", "data/");
if (filterFile)
{
line[strcspn (line, "\n")] = 0;
if (strlen (line) <= 2)
continue;
char line[512] = {};

try
{
std::regex reg{line, std::regex_constants::icase};
swearFilter.push_back (reg);
}
catch (std::regex_error &e)
while (fgets (line, 256, filterFile))
{
Logger::GetLogger ()->LogMessage ("Error parsing regex: "
+ std::string (line) + " "
+ e.what ());
line[strcspn (line, "\n")] = 0;
if (strlen (line) <= 2)
continue;

try
{
std::regex reg{line, std::regex_constants::icase};
swearFilter.push_back (reg);
}
catch (std::regex_error &e)
{
Logger::GetLogger ()->LogMessage (
"Error parsing regex: " + std::string (line)
+ " " + e.what ());
}
}
}
else if (!filterFile)
{
// Log a message if file wasn't found
Logger::GetLogger ()->LogMessage (
"Failed to read file: rainbomizer/data/Swear_Words.txt");
}
/*auto filterFile = GetRainbomizerDataFile("Swear_Words.txt");*/
}

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

0 comments on commit 24aa1a5

Please sign in to comment.