Problem Background
Kenshi's MOD system produces identical random results (like NPC positions, item drops, etc.) each time a new game is started without changing the MOD list. This is because the game uses a fixed random number seed, causing players to encounter the exact same random events every time they start a new game.
Solution
This tool replaces the game's runtime random number seed through DLL injection to achieve randomization differentiation for each new game.
Technical Implementation
Referencing RE_Kenshi FixRNG's implementation strategy, seed replacement is achieved by hooking MSVCR100 runtime library and game internal functions:
| Hook Target | Description |
|---|---|
srand | MSVCR100 seed replacement (timestamp or custom value) |
rand | TLS switching between true random / deterministic mode |
randomInt | Building::selectParts +0x113, integer random |
random (float) | Building::selectParts +0x26D, float random |
getFoliageRotation | RVA 0x6CB8A0, foliage rotation random |
Seed Replacement Principle
// Use timestamp instead of fixed seed
void srand_hook(unsigned int seed) {
if (use_custom_seed) {
original_srand(custom_seed_value);
} else {
// Use current timestamp as seed
original_srand((unsigned int)time(NULL));
}
}All 5 hooks are implemented based on fixed offset addresses obtained through reverse engineering.
Usage
Basic Usage
- Place
KenshiRNGFix.dlland launcher in Kenshi game directory - Run launcher, choose whether to use custom seed
- Start game, each new game will produce different random results
Custom Seed
If you need to reproduce specific random results:
[RNG]
use_custom_seed=true
custom_seed=12345Using the same seed can reproduce consistent random results, useful for testing and sharing.
Verification
- Log shows
"Full RNG fix active (RE-style)"indicating all hooks are active - Compare NPC positions and item drops after multiple new games to verify randomization
- Enable
use_custom_seedto reproduce consistent random results with same seed
Limitations
The hooks in this tool depend on specific game version memory offsets:
- Only supports Kenshi version 1.0.64
- May need to re-adapt offset addresses after game updates
- Cannot guarantee compatibility with other DLL injection tools
Relationship with RE_Kenshi
This tool's hook strategy references RE_Kenshi FixRNG's implementation but is provided as a standalone tool without depending on the RE_Kenshi framework.
Related Links
Last updated: 2026-03-17