Skip to content

Commit

Permalink
Fix "Shuffle entities positions" effect
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedSnark committed Apr 9, 2024
1 parent b5e37bf commit abc030b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion GSChaos/CFeatureShuffleEntitiesPositions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void CFeatureShuffleEntitiesPositions::ActivateFeature()
std::mt19937 randMT(randDev());

std::vector<Vector> entPositions;
std::vector<int> entNumbers;

edict_t* e;
for (int i = 1; i < sv->num_edicts; i++)
Expand All @@ -30,14 +31,15 @@ void CFeatureShuffleEntitiesPositions::ActivateFeature()
continue;

entPositions.push_back(e->v.origin);
entNumbers.push_back(i);
}
}

std::shuffle(entPositions.begin(), entPositions.end(), randMT);

for (size_t i = 0; i < entPositions.size(); i++)
{
e = ORIG_EDICT_NUM(i + 1);
e = ORIG_EDICT_NUM(entNumbers[i]);
if (e)
{
if (e->v.flags & FL_CLIENT)
Expand Down
12 changes: 12 additions & 0 deletions GSChaos/GSChaos.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@
<ClCompile Include="CFeatureSwapHealth.cpp">
<Filter>Effects</Filter>
</ClCompile>
<ClCompile Include="CFeatureShuffleEntitiesPositions.cpp">
<Filter>Effects</Filter>
</ClCompile>
<ClCompile Include="CFeatureTeleportToRandomNPC.cpp">
<Filter>Effects</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="includes.h" />
Expand Down Expand Up @@ -723,6 +729,12 @@
<ClInclude Include="CFeatureSwapHealth.h">
<Filter>Effects</Filter>
</ClInclude>
<ClInclude Include="CFeatureTeleportToRandomNPC.h">
<Filter>Effects</Filter>
</ClInclude>
<ClInclude Include="CFeatureShuffleEntitiesPositions.h">
<Filter>Effects</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Hooking">
Expand Down

0 comments on commit abc030b

Please sign in to comment.