Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Content.Server/Cloning/CloningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,15 @@ public string GetSpawnEntity(EntityUid oldBody, CloningPodComponent component, S
switch (ev.ForcedType)
{
case ForcedMetempsychosisType.None:
if (!ev.NeverTrulyClone
&& chance > 1
&& _random.Prob(chance - 1))
if (!ev.NeverTrulyClone)
{
changeProfile = false;
return oldSpecies.Prototype;
var cloneChance = 1.0f - Math.Clamp(chance, 0, 1);

if (_random.Prob(Math.Clamp(cloneChance, 0, 1)))
{
changeProfile = false;
return oldSpecies.Prototype;
}
}
Comment on lines 376 to 388
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

wc -l Content.Server/Cloning/CloningSystem.cs

Repository: WWhiteDreamProject/wwdpublic

Length of output: 115


🏁 Script executed:

sed -n '350,420p' Content.Server/Cloning/CloningSystem.cs

Repository: WWhiteDreamProject/wwdpublic

Length of output: 2627


🏁 Script executed:

sed -n '1,50p' Content.Server/Cloning/CloningSystem.cs

Repository: WWhiteDreamProject/wwdpublic

Length of output: 1768


🏁 Script executed:

# Check git history for this method to understand if this is recent change
git log --oneline -20 -- Content.Server/Cloning/CloningSystem.cs

Repository: WWhiteDreamProject/wwdpublic

Length of output: 114


🏁 Script executed:

# Search for any tests related to this cloning logic
find . -name "*.cs" -type f | xargs grep -l "GetSpawnEntity\|MetempsychoticHumanoidPool" | head -20

Repository: WWhiteDreamProject/wwdpublic

Length of output: 924


🏁 Script executed:

# Check if there are any related configuration values or comments about the probability
rg "HumanoidBaseChance|MetempsychoticHumanoidPool" -A 3 -B 3

Repository: WWhiteDreamProject/wwdpublic

Length of output: 3734


Уточните распределение вероятностей в логике раннего возврата.

При ForcedMetempsychosisType.None вероятность гуманоида сокращается с chance до chance * chance из-за двух последовательных проверок на одну переменную:

  • Первая: _random.Prob(1.0f - clampedChance) для выхода с клоном (строка ~378)
  • Вторая: _random.Prob(chance) для выбора гуманоида (строка ~383)

При текущей конфигурации (HumanoidBaseChance = 0.8) вероятность гуманоида составляет 0.8 × 0.8 = 0.64 вместо ожидаемых 0.8. Подтвердите, что такое сокращение вероятности намеренно, или используйте отдельный параметр для выбора гуманоида.

🤖 Prompt for AI Agents
In `@Content.Server/Cloning/CloningSystem.cs` around lines 376 - 388, The
early-return logic under ForcedMetempsychosisType.None double-samples the same
probability (via the two _random.Prob calls around the cloneChance and the later
_random.Prob(chance)), causing the effective humanoid probability to be
chance*chance; fix by performing a single draw or by using a separate
humanoid-selection parameter: compute cloneChance = 1.0f -
Math.Clamp(chance,0,1) and do one _random.Prob(cloneChance) to decide cloning,
otherwise use a single separate humanoidRollChance (e.g.,
HumanoidSelectionChance or a local humanoidChance = Math.Clamp(chance,0,1)) to
choose humanoid without reusing the same random call, updating the branches that
reference ev.NeverTrulyClone, changeProfile and returns (refer to
ForcedMetempsychosisType.None, ev.NeverTrulyClone, cloneChance, chance, and the
two _random.Prob calls) so the final humanoid probability equals the intended
parameter.


chance = Math.Clamp(chance, 0, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
components:
- type: CloningPod
doMetempsychosis: true
HumanoidBaseChance: 0.8
biomassCostMultiplier: 0.5
- type: Machine
board: MetempsychoticMachineCircuitboard
Expand Down
24 changes: 19 additions & 5 deletions Resources/Prototypes/Nyanotrasen/metempsychoticHumanoids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,22 @@
Harpy: 1
Moth: 1
Tajaran: 1 # Einstein Engines
Diona: 0.5
Reptilian: 0.5
SlimePerson: 0.5
Vulpkanin: 0.5
Plasmaman: 0.25
#wwdp edit start
Diona: 1 # 0.5 -> 1
Reptilian: 1 # 0.5 -> 1
SlimePerson: 1 # 0.5 -> 1
Vulpkanin: 1 # 0.5 -> 1
Plasmaman: 1 # 0.25 -> 1
Shadow: 1
Vox: 1
Xelthia: 1
Dwarf: 1
Arachne: 1
Kobold: 1
Skeleton: 1
Shadowkin: 1
Abductor: 1
Thaven: 1
Gingerbread: 1
Chitinid: 1
#wwdp edit end
Loading