Skip to content

Commit e8c718d

Browse files
Parik27pongo1231
authored andcommitted
Clothes Randomizer: Allow editing general/mask/parachute odds
* Can now edit the odds for general randomization and individual component odds for masks and parachutes.
1 parent 1f5217a commit e8c718d

File tree

3 files changed

+100
-8
lines changed

3 files changed

+100
-8
lines changed

config.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,14 @@ OddsOfPlayerModels = 20
197197
LightShiftFrequency = 1.0
198198

199199
# 0-100, with 0 being lights are never random to 100 being lights are always random.
200-
RandomizeOdds = 85.0
200+
RandomizeOdds = 85.0
201+
202+
#######################################################
203+
[ClothesRandomizer]
204+
205+
# Odds of a certain ped getting random clothes
206+
RandomizeOdds = 80
207+
208+
# Odds of a certain ped having random mask/parachutes
209+
MaskOdds = 20
210+
ParachuteOdds = 20

src/common/configDefault.hh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,14 @@ OddsOfPlayerModels = 20
198198
LightShiftFrequency = 1.0
199199
200200
# 0-100, with 0 being lights are never random to 100 being lights are always random.
201-
RandomizeOdds = 85.0)";
201+
RandomizeOdds = 85.0
202+
203+
#######################################################
204+
[ClothesRandomizer]
205+
206+
# Odds of a certain ped getting random clothes
207+
RandomizeOdds = 80
208+
209+
# Odds of a certain ped having random mask/parachutes
210+
MaskOdds = 20
211+
ParachuteOdds = 20)";

src/peds/clothes.cc

Lines changed: 78 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,36 @@
33
#include <Utils.hh>
44
#include <CTheScripts.hh>
55

6+
#include <array>
7+
68
#include <common/config.hh>
79
#include <common/logger.hh>
810
#include <common/minhook.hh>
911
#include <common/events.hh>
1012

13+
#ifdef ENABLE_DEBUG_MENU
14+
#include <debug/base.hh>
15+
#endif
16+
1117
using namespace NativeLiterals;
1218

19+
enum eComponentType : int32_t
20+
{
21+
CPT_FACE,
22+
CPT_MASK,
23+
CPT_HAIR,
24+
CPT_TORSO,
25+
CPT_LEG,
26+
CPT_PARACHUTE,
27+
CPT_SHOES,
28+
CPT_ACCESSORY,
29+
CPT_UNDERSHIRT,
30+
CPT_KEVLAR,
31+
CPT_BADGE,
32+
CPT_TORSO2,
33+
CPT_NUM_COMPONENTS
34+
};
35+
1336
class ClothesRandomizer
1437
{
1538
using Queue = ClothesRandomizer_Queue;
@@ -26,6 +49,20 @@ class ClothesRandomizer
2649
= "GET_NUMBER_OF_PED_PROP_TEXTURE_VARIATIONS"_joaat;
2750

2851

52+
RB_C_CONFIG_START
53+
{
54+
int RandomizeOdds = 80;
55+
56+
int MaskOdds = 20;
57+
int ParachuteOdds = 20;
58+
59+
int ForcedRandomComponent = -1;
60+
}
61+
RB_C_CONFIG_END
62+
63+
inline static std::array<int, CPT_NUM_COMPONENTS> m_ComponentOdds
64+
= {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
65+
2966
/*******************************************************/
3067
template <uint32_t NativeHash, typename... Args>
3168
static uint32_t
@@ -61,12 +98,31 @@ class ClothesRandomizer
6198
static bool
6299
RandomizePedClothes (uint32_t ped)
63100
{
64-
for (int i = 0; i < 12; i++)
65-
RandomizeComponent(ped, i);
66-
101+
if (!RandomBool (Config ().RandomizeOdds))
102+
return true;
103+
104+
m_ComponentOdds[CPT_FACE] = Config ().MaskOdds;
105+
m_ComponentOdds[CPT_MASK] = Config ().MaskOdds;
106+
m_ComponentOdds[CPT_PARACHUTE] = Config ().ParachuteOdds;
107+
m_ComponentOdds[CPT_KEVLAR] = Config ().ParachuteOdds;
108+
m_ComponentOdds[CPT_ACCESSORY] = Config ().ParachuteOdds;
109+
m_ComponentOdds[CPT_TORSO2] = 0;
110+
111+
if (Config ().ForcedRandomComponent != -1)
112+
{
113+
RandomizeComponent (ped, Config ().ForcedRandomComponent);
114+
return true;
115+
}
116+
117+
for (int i = 0; i < CPT_NUM_COMPONENTS; i++)
118+
{
119+
if (m_ComponentOdds[i] == -1 || RandomBool (m_ComponentOdds[i]))
120+
RandomizeComponent (ped, i);
121+
}
122+
67123
return true;
68124
}
69-
125+
70126
/*******************************************************/
71127
static void
72128
ProcessUpgradesQueue (uint64_t *, uint64_t *, scrProgram *,
@@ -98,13 +154,29 @@ class ClothesRandomizer
98154

99155
public:
100156
ClothesRandomizer ()
101-
{
102-
RB_C_DO_CONFIG_NO_OPTIONS ("ClothesRandomizer");
157+
{
158+
RB_C_DO_CONFIG ("ClothesRandomizer", RandomizeOdds, MaskOdds,
159+
ParachuteOdds, ForcedRandomComponent);
160+
161+
m_ComponentOdds[CPT_FACE] = Config ().MaskOdds;
162+
m_ComponentOdds[CPT_MASK] = Config ().MaskOdds;
163+
m_ComponentOdds[CPT_PARACHUTE] = Config ().ParachuteOdds;
164+
m_ComponentOdds[CPT_KEVLAR] = Config ().ParachuteOdds;
165+
m_ComponentOdds[CPT_ACCESSORY] = Config ().ParachuteOdds;
166+
m_ComponentOdds[CPT_TORSO2] = 0;
103167

104168
Rainbomizer::Events ().OnRunThread += ProcessUpgradesQueue;
105169
Rainbomizer::Events ().OnFade +=
106170
[] { Queue::Add (int ("PLAYER_PED_ID"_n())); };
107171

172+
#ifdef ENABLE_DEBUG_MENU
173+
DebugInterfaceManager::AddAction ("Randomize Player Clothes",
174+
[] (bool) {
175+
Queue::Add (
176+
int ("PLAYER_PED_ID"_n()));
177+
});
178+
#endif
179+
108180
"SET_PED_COMPONENT_VARIATION"_n.Hook ([] (scrThread::Info *info) {});
109181
"SET_PED_PROP_INDEX"_n.Hook ([] (scrThread::Info *info) {});
110182

0 commit comments

Comments
 (0)