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+
1117using 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+
1336class 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
99155public:
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