| Home Page | Recent Changes

Mod Ideas/RegeneratingAmmo

Mod ideas for UT 2003 – Regenerating Ammunition

Description

This small mod removes all ammunition (weapons and all other objects are still in play) from the level. Ammunition for weapons held slowly regenerate back up to their full amount.

Interested Scripters

If you are interested in developing this mod for UT2003 then add your name to the list. Once you start development you should indicate that below (and hopefully include a link to a journal page). Before you start development you should also check this section to see if anyone else has started.

Discussion

Ben2500: I have tried this before and havent been able to suceed. This is what i tried

              
function Timer()
{
    local Controller C;

    for (C = Level.ControllerList; C != None; C = C.NextController)
    {
        if (C.Ammunition != None && C.Ammunition.Ammo < C.Pawn.AmmoMax )
        {
            C.Ammunition.Ammo = Min( C.Ammunition.Ammo+RegenPerSecond, C.Ammunition.AmmoMax );
        }
    }
}

Instead of

function Timer()
{
    local Controller C;

    for (C = Level.ControllerList; C != None; C = C.NextController)
    {
        if (C.Pawn != None && C.Pawn.Health < C.Pawn.HealthMax )
        {
            C.Pawn.Health = Min( C.Pawn.Health+RegenPerSecond, C.Pawn.HealthMax );
        }
    }
}

MortalMonkey: Not exactly an expert on UT2k3, but shouldn't that be C.Pawn.Ammunition?

Uncommon: Perhaps you can tell us exactly what happens when you try to use that code? You could also look at the Excessive mod, since that has regenerating ammo.

RegularX: You can also grab the xpak code, which has regen ammo, off the UTutes?.

GRAF1K: Already been done: Shield Gun's shield ammo. :D Or am I missing something?

Ben2500: Thats not the exact code but It was something like this. Definently not very good at Scripting. :D

Sir_Brizz: I did a better function of this in EvenGround. I will post the exact code later, because it is 100% efficient, fast and tested.

Ben2500: Anybody wanna rub my salt lick?

Sir_Brizz: Here is how I did it.

function Timer()
{ 
     local Inventory inv;
     local int count;
     local Controller C;
     
     if( (SomeOption) && TimerCount >= (put a recharge rate here)*2 )
     {
         for ( C=Level.ControllerList; C!=None; C=C.NextController )
         {
           if (C.pawn==None)
            continue;
           gp=xPawn(C.Pawn);

           for( inv=gp.Inventory;inv!=none;inv=inv.Inventory )
           {
              if( inv.IsA('Weapon') && (!inv.IsA('TransLauncher')) && (!inv.IsA('ShieldGun')) )
              {
                  if( Weapon(inv).Ammo[0].AmmoAmount < Weapon(inv).Ammo[0].InitialAmount )
                  {
                      //Log( "Timer #"$TimerCount$" Inv: "$inv$" Ammo: "$Weapon(inv).Ammo[0].AmmoAmount );
                      TimerCount=0;
                      Weapon(inv).Ammo[0].AmmoAmount = Min( Weapon(inv).Ammo[0].AmmoAmount + 1,Weapon(inv).Ammo[0].InitialAmount );
                  }
              }
           }
         }
     }
     if( TimerCount == ((put a recharge rate here)*2)+1 )
         TimerCount = 0;
     TimerCount++;
}             

It works for any weapon and it's moddable by changing the recharge rate. In my opinion it's perfect for a mutator that recharges your am on all of your guns.

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In