Unlimited Ammo - Mutator Help

  • Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Tendency

FNG / Fresh Meat
Dec 12, 2009
168
31
0
www.rainingblood.org
I am using this mutator but it generates the following two errors making the log file massive.

Code:
Warning: MutAmmo KF-Bedlam.MutAmmo (Function MutAmmo.MutAmmo.GiveAmmo:001C) Accessed None 'Human'
Warning: MutAmmo KF-Bedlam.MutAmmo (Function MutAmmo.MutAmmo.GiveAmmo:001C) Accessed None 'Human'
Warning: MutAmmo KF-Bedlam.MutAmmo (Function MutAmmo.MutAmmo.GiveAmmo:001C) Accessed None 'Human'
Warning: MutAmmo KF-Bedlam.MutAmmo (Function MutAmmo.MutAmmo.GiveAmmo:001C) Accessed None 'Human'
Warning: MutAmmo KF-Bedlam.MutAmmo (Function MutAmmo.MutAmmo.GiveAmmo:001C) Accessed None 'Human'
Warning: MutAmmo KF-Bedlam.MutAmmo (Function MutAmmo.MutAmmo.GiveAmmo:003E) Accessed None 'Inv'
Warning: MutAmmo KF-Bedlam.MutAmmo (Function MutAmmo.MutAmmo.GiveAmmo:0051) Accessed None 'Inv'
Warning: MutAmmo KF-Bedlam.MutAmmo (Function MutAmmo.MutAmmo.GiveAmmo:003E) Accessed None 'Inv'

I would like to fix it. But i am not a coder. I have no problems decompiling or compiling, just dont understand the structure of classes. Sometimes i can get lucky and make the correct changes, but not this time. Here is the code.

Code:
//=============================================================================
// MutAmmo - Unlimited 9mm ammo - By EvilDooinz aka Bruce303lee
//=============================================================================
class MutAmmo 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 Other)
{
local int AddAmmo;
AddAmmo = 10 + Rand(51);
GiveAmmo(Other, AddAmmo);
}
static function GiveAmmo(Pawn pawn,float Percentage)
{
local KFHumanPawn human;
Local Inventory Inv;
human = KFHumanPawn(pawn);
for (Inv = human.Inventory; Inv != None; Inv = Inv.Inventory)
{
if (KFAmmunition(Inv).AmmoAmount < KFAmmunition(Inv).MaxAmmo)
KFAmmunition(Inv).AmmoAmount = KFAmmunition(Inv).MaxAmmo;
}
}
defaultproperties
{
GroupName="KF-Ammo"
FriendlyName="Ammo Regen"
Description="All weapons have unlimited ammunition"
}
 
Last edited:

Benjamin

Grizzled Veteran
May 17, 2009
3,650
635
113
France
You need to check that 'human' and 'inv' are not none before you access them, otherwise you will get these warnings.
 

Tendency

FNG / Fresh Meat
Dec 12, 2009
168
31
0
www.rainingblood.org
How can you "exclude" an item from being regenerated, e.g. Frags + Pipebombs.

I want to provide unlimited ammo for all weapons except for frags and pipebombs. Would this be a case to use the "ignores" function or "else if".
 
Last edited:

Marco

Active member
May 23, 2009
645
232
43
Finland
Simply like this:
Code:
static function GiveAmmo(Pawn pawn,float Percentage)
{
    Local Inventory Inv;

    if( pawn==None )
        return;
    for (Inv = pawn.Inventory; Inv != None; Inv = Inv.Inventory)
    {
        if ( KFAmmunition(Inv)!=None && [COLOR=Red]FragAmmo(inv)==None[/COLOR] && [COLOR=Red]PipeBombAmmo(inv)==None[/COLOR]
         && KFAmmunition(Inv).AmmoAmount<KFAmmunition(Inv).MaxAmmo )
            KFAmmunition(Inv).AmmoAmount = KFAmmunition(Inv).MaxAmmo;
    }
}
 
  • Like
Reactions: Demon_333

Rioku

FNG / Fresh Meat
Apr 18, 2011
6
2
0
I have a question, is it possible to make it to where all weapons, including custom weapons, have unlimited ammo?
 

Rioku

FNG / Fresh Meat
Apr 18, 2011
6
2
0
Thank you! :) How do I implement it though? I have a version that only replenishes the 9mm and a select few other weapons.
 

Rioku

FNG / Fresh Meat
Apr 18, 2011
6
2
0
Thank you!! :) I just have one question, how would you implement this? I have a version that someone made already but it only works for a few weapons such as the MP7, 9mm, and I believe that's it.
 

Excalibolg

FNG / Fresh Meat
May 3, 2009
142
27
0
KF-BioticsLab
This is the code I use on my server. Refills the ammo of every weapon but grenades and pipebombs.

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) )
                {
                   KFAmmunition(Inv).AmmoAmount = KFAmmunition(Inv).MaxAmmo;
                }
            }
        }
    }
}

defaultproperties
{
     GroupName="KF-GliderAmmo"
     FriendlyName="GliderAmmo"
     Description="Unlimited  ammunition"
}
 

Rayman1103

FNG / Fresh Meat
Apr 24, 2011
23
0
0
United States of America
Can someone please release an unlimited ammo Mutator? I've tried to create a Mutator myself but I can't get it to compile. Also if it's possible make only the clips be unlimited, meaning I'd still like to reload.