I have been asked by a fellow forum user to create a mutator for their custom server which regenerates ammo over time instant of purely having infinite ammo, to stifle the exploitation of various weapons that have high damage.
Using a very early GliderAmmo mutator as a base to butcher (Sorry about that the original is below).
I changed the line highlighted to
Which worked very nicely, and as I anticipated ammo started to regenerate at 1% of the players MaxAmmo per second, as instructed by the timer. Weapons with a max ammo less than 100 did not regenerate ammo as they seemed to be treated as 0, I'm not 100% sure but I could get around that with a float... I think.
I was then asked to make different categories of ammo regeneration based on the class of weapon used. Ammo regeneration ranging from 1% of MaxAmmo per 2 seconds for specifically assualt rifles to 1 bullet per 12 seconds for things like the law and M99.
I had the idea to make an ini and group weapons into categories (Although I am just making stabs in the dark, I'll be honest).
To try and segregate different timers into for different functions I thought maybe I could try and make different regeneration amounts in different functions. Which you can see here:
(Please mind the name, they said to call it that, so I did, by no measure do I care for the name)
However I hit the wall of being unable to call an instance function into a static function and have no idea how to call timers into each of the different functions (Let alone get the mutator to read from the .ini file to realise which weapon fits into which category.
If someone could point me into the right direction I would appreciate it. It's an awful big task though.
Also the ini
Yes that does indeed look like the layout from marco's serverperks, the list was sent to me for all the weapon classes and it seemed like common sense to just find and replace.
Using a very early GliderAmmo mutator as a base to butcher (Sorry about that the original is below).
Code:
class GliderAmmo extends Mutator;
event PreBeginPlay()
{
SetTimer(1.0,true);
}
function Timer()
{
local Controller C;
for (C = Level.ControllerList; C != None; C = C.NextController)
{
ModifyPawn(C.Pawn);
}
}
static simulated function ModifyPawn(Pawn pawn)
{
GiveAmmo(pawn);
}
static function GiveAmmo(Pawn pawn)
{
local KFHumanPawn human;
Local Inventory Inv;
human = KFHumanPawn(pawn);
if (human != None)
{
for (Inv = human.Inventory; Inv != None; Inv = Inv.Inventory)
{
if (Inv != None)
{
if ( KFAmmunition(Inv) != None && (FragAmmo(Inv) == None) && (PipeBombAmmo(Inv) == None) && (KFAmmunition(Inv).AmmoAmount < KFAmmunition(Inv).MaxAmmo) )
{
[COLOR=Red] KFAmmunition(Inv).AmmoAmount = KFAmmunition(Inv).MaxAmmo;[/COLOR]
}
}
}
}
}
defaultproperties
{
GroupName="KF-GliderAmmo"
FriendlyName="GliderAmmo"
Description="Unlimited ammunition"
}
Code:
KFAmmunition(Inv).AmmoAmount = KFAmmunition(Inv).AmmoAmount + (KFAmmunition(Inv).MaxAmmo*0.01);
I was then asked to make different categories of ammo regeneration based on the class of weapon used. Ammo regeneration ranging from 1% of MaxAmmo per 2 seconds for specifically assualt rifles to 1 bullet per 12 seconds for things like the law and M99.
I had the idea to make an ini and group weapons into categories (Although I am just making stabs in the dark, I'll be honest).
To try and segregate different timers into for different functions I thought maybe I could try and make different regeneration amounts in different functions. Which you can see here:
Code:
class SnebbersAmmoRegen extends Mutator;
event PreBeginPlay()
{
SetTimer(1 ,true);
}
function Timer()
{
local Controller C;
for (C = Level.ControllerList; C != None; C = C.NextController)
{
ModifyPawn(C.Pawn);
}
}
static simulated function ModifyPawn(Pawn pawn)
{
AmmoRegen0(pawn);
AmmoRegen1(pawn);
AmmoRegen2(pawn);
AmmoRegen3(pawn);
AmmoRegen4(pawn);
AmmoRegen5(pawn);
AmmoRegen6(pawn);
}
static function AmmoRegen0(Pawn pawn)
{
local KFHumanPawn human;
Local Inventory Inv;
human = KFHumanPawn(pawn);
if (human != None)
{
for (Inv = human.Inventory; Inv != None; Inv = Inv.Inventory)
{
if (Inv != None)
{
if ( KFAmmunition(Inv) != None && (KFAmmunition(Inv).AmmoAmount < KFAmmunition(Inv).MaxAmmo) )
{
KFAmmunition(Inv).AmmoAmount = KFAmmunition(Inv).MaxAmmo;
}
}
}
}
}
static function AmmoRegen1(Pawn pawn)
{
local KFHumanPawn human;
Local Inventory Inv;
human = KFHumanPawn(pawn);
if (human != None)
{
for (Inv = human.Inventory; Inv != None; Inv = Inv.Inventory)
{
if (Inv != None)
{
if ( KFAmmunition(Inv) != None && (KFAmmunition(Inv).AmmoAmount < KFAmmunition(Inv).MaxAmmo) )
{
KFAmmunition(Inv).AmmoAmount = KFAmmunition(Inv).AmmoAmount + (KFAmmunition(Inv).MaxAmmo*0.01);
}
}
}
}
}
static function AmmoRegen2(Pawn pawn)
{
local KFHumanPawn human;
Local Inventory Inv;
human = KFHumanPawn(pawn);
if (human != None)
{
for (Inv = human.Inventory; Inv != None; Inv = Inv.Inventory)
{
if (Inv != None)
{
if ( KFAmmunition(Inv) != None && (KFAmmunition(Inv).AmmoAmount < KFAmmunition(Inv).MaxAmmo) )
{
KFAmmunition(Inv).AmmoAmount = KFAmmunition(Inv).AmmoAmount + 1;
}
}
}
}
}
static function AmmoRegen3(Pawn pawn)
{
local KFHumanPawn human;
Local Inventory Inv;
human = KFHumanPawn(pawn);
if (human != None)
{
for (Inv = human.Inventory; Inv != None; Inv = Inv.Inventory)
{
if (Inv != None)
{
if ( KFAmmunition(Inv) != None && (KFAmmunition(Inv).AmmoAmount < KFAmmunition(Inv).MaxAmmo) )
{
KFAmmunition(Inv).AmmoAmount = KFAmmunition(Inv).AmmoAmount + KFWeapon(Inv).MagCapacity;
}
}
}
}
}
static function AmmoRegen4(Pawn pawn)
{
local KFHumanPawn human;
Local Inventory Inv;
human = KFHumanPawn(pawn);
if (human != None)
{
for (Inv = human.Inventory; Inv != None; Inv = Inv.Inventory)
{
if (Inv != None)
{
if ( KFAmmunition(Inv) != None && (KFAmmunition(Inv).AmmoAmount < KFAmmunition(Inv).MaxAmmo) )
{
KFAmmunition(Inv).AmmoAmount = KFAmmunition(Inv).AmmoAmount + 1;
}
}
}
}
}
static function AmmoRegen5(Pawn pawn)
{
local KFHumanPawn human;
Local Inventory Inv;
human = KFHumanPawn(pawn);
if (human != None)
{
for (Inv = human.Inventory; Inv != None; Inv = Inv.Inventory)
{
if (Inv != None)
{
if ( KFAmmunition(Inv) != None && (KFAmmunition(Inv).AmmoAmount < KFAmmunition(Inv).MaxAmmo) )
{
KFAmmunition(Inv).AmmoAmount = KFAmmunition(Inv).AmmoAmount + 2;
}
}
}
}
}
static function AmmoRegen6(Pawn pawn)
{
local KFHumanPawn human;
Local Inventory Inv;
human = KFHumanPawn(pawn);
if (human != None)
{
for (Inv = human.Inventory; Inv != None; Inv = Inv.Inventory)
{
if (Inv != None)
{
if ( KFAmmunition(Inv) != None && (KFAmmunition(Inv).AmmoAmount < KFAmmunition(Inv).MaxAmmo) )
{
KFAmmunition(Inv).AmmoAmount = KFAmmunition(Inv).AmmoAmount + 1;
}
}
}
}
}
defaultproperties
{
GroupName="KF-SnebbersAmmoRegen"
FriendlyName="SnebbersAmmoRegen"
Description="Ammo regeneration over time"
}
However I hit the wall of being unable to call an instance function into a static function and have no idea how to call timers into each of the different functions (Let alone get the mutator to read from the .ini file to realise which weapon fits into which category.
If someone could point me into the right direction I would appreciate it. It's an awful big task though.
Also the ini
Code:
; Groups are as follows:
; Group 0 is exclusively for the 9mm, and it is infinite ammo regardless.
; Group 1 is for weapons that regenerate 1% of the players MaxAmmo every 2 seconds.
; Group 2 is for power weapons, like the crossbow that regenerate 1 ammo(bullet, bolt, whatever) every 8 seconds.
; Group 3 is for Dual wield weapons and regenerate a clip every 15 seconds.
; Group 4 is for most shotguns and regenerate 1 shell every 3 seconds.
; Group 5 is for the husk gun, the ammo regen is 2 fuel every second.
; Group 6 is for the Law, HRL-1, RPG-1 and M99 and regenerates 1 bullet every 12 seconds.
AmmoRegen=1:ScrnBalanceSrv.ScrnChainsaw
AmmoRegen=2:ScrnBalanceSrv.ScrnCrossbuzzsaw
AmmoRegen=0:ScrnBalanceSrv.ScrnSingle
AmmoRegen=1:ScrnBalanceSrv.ScrnMagnum44
AmmoRegen=1:ScrnBalanceSrv.ScrnMK23
AmmoRegen=1:ScrnBalanceSrv.ScrnDeagle
AmmoRegen=3:ScrnBalanceSrv.ScrnDualies
AmmoRegen=3:ScrnBalanceSrv.ScrnDual44Magnum
AmmoRegen=3:ScrnBalanceSrv.ScrnDualMK23
AmmoRegen=3:ScrnBalanceSrv.ScrnDualDeagle
AmmoRegen=3:ScrnBalanceSrv.ScrnDual44MagnumLaser
AmmoRegen=3:ScrnBalanceSrv.ScrnDualMK23Laser
AmmoRegen=1:KFMod.GoldenDeagle
AmmoRegen=3:KFMod.GoldenDualDeagle
AmmoRegen=1:KFMod.FlareRevolver
AmmoRegen=3:KFMod.DualFlareRevolver
AmmoRegen=1:Cz75Laser.Cz75Laser
AmmoRegen=1:FNComboWPMut.P57LLI
AmmoRegen=4:ScrnBalanceSrv.ScrnShotgun
AmmoRegen=4:ScrnBalanceSrv.ScrnBoomStick
AmmoRegen=4:ScrnBalanceSrv.ScrnNailGun
AmmoRegen=4:ScrnBalanceSrv.ScrnKSG
AmmoRegen=4:ScrnBalanceSrv.ScrnBenelli
AmmoRegen=4:ScrnBalanceSrv.ScrnAA12
AmmoRegen=4:KFMod.GoldenAA12
AmmoRegen=4:KFMod.SPShotgun
AmmoRegen=4:KFMod.Trenchgun
AmmoRegen=4:KFMod.GoldenBenelli
AmmoRegen=4:ScrnWeapons.Saiga12c
AmmoRegen=2:Rem870ECMut.Rem870EC
AmmoRegen=4:Moss12Mut.Moss12
AmmoRegen=4:ProtectaMut.Protecta
AmmoRegen=1:ScrnBalanceSrv.ScrnWinchester
AmmoRegen=2:KFMod.Crossbow
AmmoRegen=3:ScrnBalanceSrv.ScrnSPSniper
AmmoRegen=1:ScrnBalanceSrv.ScrnM14EBR
AmmoRegen=6:ScrnBalanceSrv.ScrnM99
AmmoRegen=1:ScrnWeapons.VSSDT
AmmoRegen=1:ScrnWeapons.SVDc
AmmoRegen=1:JS_L85A2.L85A2
AmmoRegen=1:Weapon_M44Beta.M44
AmmoRegen=1:L96AWPLLImut.L96AWPLLI
AmmoRegen=1:BDHuntingRifleFinal.Hunting_Rifle
AmmoRegen=1:SV98.SV98
AmmoRegen=1:ScrnBalanceSrv.ScrnBullpup
AmmoRegen=1:ScrnBalanceSrv.ScrnAK47
AmmoRegen=1:KFMod.MKb42
AmmoRegen=1:ScrnBalanceSrv.ScrnM4
AmmoRegen=1:KFMod.Thompson
AmmoRegen=1:ScrnBalanceSrv.ScrnSPThompson
AmmoRegen=1:ScrnBalanceSrv.ScrnThompsonDrum
AmmoRegen=1:ScrnBalanceSrv.ScrnSCARMK17
AmmoRegen=1:ScrnBalanceSrv.ScrnFNFAL_ACOG_
AmmoRegen=1:KFMod.GoldenAK47
#AmmoRegen=4:KFMod.KrissM
AmmoRegen=4:ScrnBalanceSrv.ScrnM4203
AmmoRegen=1:ScrnWeapons.Thompson
AmmoRegen=1:ScrnWeapons.AKC74
AmmoRegen=1:ScrnWeapons.VALDT
AmmoRegen=1:ScrnWeapons.HK417
AmmoRegen=0:KFPortalTurret.PTurret
AmmoRegen=1:FNComboWPMut.P90DT
AmmoRegen=1:KFPPSHMut.PPSH
AmmoRegen=1:FX-G36C.G36C
AmmoRegen=1:AUG_A1ARMut.AUG_A1AR
AmmoRegen=1:M249Mut.M249
AmmoRegen=1:XMV850.XMV850
AmmoRegen=7:ScrnBalanceSrv.ScrnPipeBomb
AmmoRegen=2:KFMod.M79
AmmoRegen=2:KFMod.GoldenM79
AmmoRegen=8:KFMod.SPGrenade
AmmoRegen=2:ScrnBalanceSrv.ScrnM4203
AmmoRegen=2:ScrnBalanceSrv.ScrnM32
AmmoRegen=6:ScrnBalanceSrv.ScrnHRL
AmmoRegen=6:ScrnBalanceSrv.ScrnLAW
AmmoRegen=6:KFMod.SealSqueal
AmmoRegen=2:KFMod.SeekerSix
AmmoRegen=2:ScrnWeapons.HopMineL
AmmoRegen=6:ScrnWeapons.RPG
#AmmoRegen=6:ScrnWeapons.M202A2
AmmoRegen=1:ScrnBalanceSrv.ScrnMAC10
AmmoRegen=1:ScrnBalanceSrv.ScrnThompsonInc
AmmoRegen=1:ScrnBalanceSrv.ScrnFlareRevolver
AmmoRegen=3:ScrnBalanceSrv.ScrnDualFlareRevolver
AmmoRegen=1:ScrnBalanceSrv.ScrnFlameThrower
AmmoRegen=4:ScrnBalanceSrv.ScrnTrenchgun
AmmoRegen=2:ScrnBalanceSrv.ScrnM79Inc
AmmoRegen=1:KFMod.Thompson
AmmoRegen=1:KFMod.GoldenFT
#AmmoRegen=6:ScrnWeapons.M202A1
AmmoRegen=6:Coctel02.Molotov
AmmoRegen=1:TommygunInc.ThompsonInc
AmmoRegen=1:ScrnBalanceSrv.ScrnMP7M
AmmoRegen=1:ScrnBalanceSrv.ScrnMP5M
AmmoRegen=1:ScrnBalanceSrv.ScrnKrissM
AmmoRegen=1:ScrnBalanceSrv.ScrnM7A3M
AmmoRegen=1:ScrnBalanceSrv.ScrnM79M
AmmoRegen=1:ScrnBalanceSrv.ScrnM4203M
AmmoRegen=1:KFMod.BlowerThrower
AmmoRegen=4:WhiskyMediShot.WMediShot
AmmoRegen=1:KFMod.ZEDMKII
Yes that does indeed look like the layout from marco's serverperks, the list was sent to me for all the weapon classes and it seemed like common sense to just find and replace.
Last edited: