-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3ca1ed
commit b56310e
Showing
2 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
class DXRWeaponMods extends DXRActorsBase transient; | ||
|
||
struct RandomModStruct { var class<#var(prefix)WeaponMod> type; var float chance; }; | ||
var RandomModStruct randommods[8]; | ||
|
||
var config float min_rate_adjust, max_rate_adjust; | ||
|
||
function class<#var(prefix)WeaponMod> PickRandomMod() | ||
{ | ||
local class<#var(prefix)WeaponMod> newmod; | ||
local float r; | ||
local int i; | ||
|
||
newmod=None; | ||
|
||
r = initchance(); | ||
for (i=0;i<ArrayCount(randommods);i++){ | ||
if(chance(randommods[i].chance,r)) newmod = randommods[i].type; | ||
} | ||
|
||
if (newmod==None){ | ||
//Shouldn't happen, but... | ||
err("Failed to pick a random weapon mod"); | ||
newmod=randommods[0].type; | ||
} | ||
|
||
return newmod; | ||
} | ||
|
||
function AddRandomMod(class<#var(prefix)WeaponMod> mod, float c) | ||
{ | ||
local int i; | ||
for(i=0;i < ArrayCount(randommods);i++){ | ||
if (randommods[i].type==None){ | ||
randommods[i].type=mod; | ||
randommods[i].chance=rngrangeseeded(c,min_rate_adjust,max_rate_adjust,mod.name); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
function CheckConfig() | ||
{ | ||
local float total; | ||
local int i; | ||
|
||
Super.CheckConfig(); | ||
|
||
//This is the vanilla count of each mod through the game | ||
AddRandomMod(class'#var(prefix)WeaponModAccuracy',14); | ||
AddRandomMod(class'#var(prefix)WeaponModClip',10); | ||
AddRandomMod(class'#var(prefix)WeaponModRange',7); | ||
AddRandomMod(class'#var(prefix)WeaponModRecoil',10); | ||
AddRandomMod(class'#var(prefix)WeaponModReload',8); | ||
AddRandomMod(class'#var(prefix)WeaponModScope',3); | ||
AddRandomMod(class'#var(prefix)WeaponModSilencer',5); | ||
AddRandomMod(class'#var(prefix)WeaponModLaser',6); | ||
|
||
//Scale to 100% | ||
total=0; | ||
for(i=0;i<ArrayCount(randommods);i++) | ||
{ | ||
total += randommods[i].chance; | ||
} | ||
for(i=0;i<ArrayCount(randommods);i++) | ||
{ | ||
randommods[i].chance *= 100.0/total; | ||
} | ||
} | ||
|
||
function FirstEntry() | ||
{ | ||
local #var(prefix)WeaponMod mod; | ||
local #var(prefix)WeaponMod mods[16]; | ||
local Containers container; | ||
local class<#var(prefix)WeaponMod> newMod; | ||
local int i; | ||
|
||
Super.FirstEntry(); | ||
|
||
SetSeed("RandoWeaponMods"); | ||
|
||
i=0; | ||
foreach AllActors(class'#var(prefix)WeaponMod',mod) | ||
{ | ||
if (mod.Owner==None){ | ||
mods[i++]=mod; | ||
} | ||
} | ||
|
||
for (i=0;mods[i]!=None;i++){ | ||
mod = #var(prefix)WeaponMod(SpawnReplacement(mods[i],PickRandomMod(),True)); | ||
if (mod!=None){ | ||
mods[i].Destroy(); | ||
} else { | ||
err("Failed to replace weapon mod "$mods[i].Name); | ||
} | ||
} | ||
|
||
//Technically any decoration can contain objects, but I think DX only puts them in containers | ||
foreach AllActors(class'Containers',container) | ||
{ | ||
//I don't know if anything has anything in contents2 or contents3, but can't hurt... | ||
if(ClassIsChildOf(container.contents,class'#var(prefix)WeaponMod')){ | ||
container.contents = PickRandomMod(); | ||
} | ||
if(ClassIsChildOf(container.content2,class'#var(prefix)WeaponMod')){ | ||
container.content2 = PickRandomMod(); | ||
} | ||
if(ClassIsChildOf(container.content3,class'#var(prefix)WeaponMod')){ | ||
container.content3 = PickRandomMod(); | ||
} | ||
} | ||
} | ||
|
||
defaultproperties | ||
{ | ||
min_rate_adjust=0.3 | ||
max_rate_adjust=1.75 | ||
} |