how to specify ammo amounts

  • 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/
  • Weve updated the Tripwire Privacy Notice under our Policies to be clearer about our use of customer information to come in line with the EU General Data Protection Regulation (GDPR) rules that come into force today (25th May 2018). The following are highlights of our changes:


    We've incorporated the relevant concepts from the GDPR including joining the EU and Swiss Privacy Shield framework. We've added explanations for why and how Tripwire processes customer data and the types of data that we process, as well as information about your data protection rights.



    For more information about our privacy practices, please review the new Privacy Policy found here: https://tripwireinteractive.com/#/privacy-notice

ro_sauce

FNG / Fresh Meat
Sep 26, 2007
3,135
329
0
bwhgaming.com
i guess i should have phrased the question better:
i am making a custom gun.
in unrealscript, how do i specify the amount of bullets in the gun (mag size) and how many mags can be carried for that gun?
 

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,468
2,503
0
Canada
in the default properties of the weapon put this in:

MagCapacity=20


You don't have to put 20 you can put whatever u like


And in the ammo class put this in the default properties:

MaxAmmo=36
InitialAmount=18
AmmoPickupAmount=6


Again, you don't have to put those numbers in you can put whatever u like!
 

ro_sauce

FNG / Fresh Meat
Sep 26, 2007
3,135
329
0
bwhgaming.com
this is hard, i've never done any coding in my life before, so i'm kind of just winging it, does anyone have any really good beginner's coding tutorials that i can download?
 

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,468
2,503
0
Canada
Take a look at this:

Code:
class NoKarmaMut extends Mutator;
simulated function PostBeginPlay()
{
 local KActor K;
 ForEach DynamicActors(Class'KActor',K)
 {
  K.Destroy();
  if( K==None )
   Continue;
  K.SetPhysics(PHYS_None);
  K.SetCollision(False);
  K.bHidden = True;
  K.bScriptInitialized = true;
  K.Disable('Tick');
  K.RemoteRole = ROLE_None;
 }
}
 
Defaultproperties
{
 GroupName = "KF-NoKarma"
 FriendlyName = "No Karma Decorations"
 Description = "Remove all those buggy karma decorations from the maps."
 RemoteRole=ROLE_SimulatedProxy
 bAlwaysRelevant=True
}
A very basic "class" or mutator in this case, that deletes all KActors.(Objects that can be pushed and/or shot around the room.)


Code:
class AdvArena extends Mutator;
var() config array<string> WeaponClassNames;
var() config bool   bRandomPickOne;
var() config bool   bRandomPerSpawn;
var   array<class<weapon> > WeaponClasses;
simulated function PostBeginPlay()
{
 local ShopVolume S;
 foreach AllActors(Class'ShopVolume',S)
  S.bAlwaysClosed = true;
 Destroy();
}
function PreBeginPlay ()
{
 local int i;
 local class<weapon> W;
 super.PreBeginPlay();
 if (bRandomPickOne)
  DefaultWeaponName = WeaponClassNames[Rand(WeaponClassNames.length)];
 for (i=0;i<WeaponClassNames.length;i++)
 {
  W = class<weapon>(DynamicLoadObject(WeaponClassNames[i],class'Class'));
  if (W != None)
   WeaponClasses[WeaponClasses.length] = W;
 }
}
function ModifyPlayer(Pawn Other)
{
 local int i;
 local byte LP;
 local class<weapon> W;
 Super.ModifyPlayer(Other);
 if (bRandomPerSpawn)
 {
  W = WeaponClasses[Rand(WeaponClasses.length)];
  SpawnWeapon(W, Other);
  SpawnAmmo(W.default.FireModeClass[0].default.AmmoClass, Other);
  if (W.default.FireModeClass[1].default.AmmoClass != None && W.default.FireModeClass[0].default.AmmoClass != W.default.FireModeClass[1].default.AmmoClass)
   SpawnAmmo(W.default.FireModeClass[1].default.AmmoClass, Other);
  Other.Controller.ClientSwitchToBestWeapon();
  KFHumanPawn(Other).RequiredEquipment[0] = string(W);
  return;
 }
 if (bRandomPickOne)
  return;
 for (i=0;i<WeaponClasses.length;i++)
 {
  SpawnWeapon(WeaponClasses[i], Other);
  if (WeaponClasses[i].default.Priority > LP)
  {
   LP = WeaponClasses[i].default.Priority;
   KFHumanPawn(Other).RequiredEquipment[0] = string(WeaponClasses[i]);
  }
  if (KFHumanPawn(Other) != None)
  {
   SpawnAmmo(WeaponClasses[i].default.FireModeClass[0].default.AmmoClass, Other);
   if (WeaponClasses[i].default.FireModeClass[0].default.AmmoClass != WeaponClasses[i].default.FireModeClass[1].default.AmmoClass)
    SpawnAmmo(WeaponClasses[i].default.FireModeClass[1].default.AmmoClass, Other);
  }
 }
 Other.Controller.ClientSwitchToBestWeapon();
}
function class<Weapon> MyDefaultWeapon()
{
 if (!bRandomPickOne || bRandomPerSpawn)
  return None;
 return super.MyDefaultWeapon();
}
function string GetInventoryClassOverride(string InventoryClassName)
{
 return Super(Mutator).GetInventoryClassOverride(InventoryClassName);
}
function ItemPickedUp(Pickup Other);
function ItemChange(Pickup Other);
static function SpawnWeapon(class<weapon> newClass, Pawn P)
{
 local Weapon newWeapon;
    if( (newClass!=None) && P != None && (P.FindInventoryType(newClass)==None) )
    {
        newWeapon = P.Spawn(newClass,,,P.Location);
        if( newWeapon != None )
            newWeapon.GiveTo(P);
    }
}
static function SpawnAmmo(class<Ammunition> newClass, Pawn P, optional float Multiplier)
{
 local Ammunition Ammo;
 if (P==None || newClass == None)
  return;
 Ammo = Ammunition(P.FindInventoryType(newClass));
 if(Ammo == None)
    {
  Ammo = P.Spawn(newClass);
  P.AddInventory(Ammo);
    }
 if(Ammo == None)
  return;
    if (Multiplier > 0)
  Ammo.AddAmmo(Ammo.InitialAmount*Multiplier);
    else
  Ammo.AddAmmo(Ammo.InitialAmount);
 Ammo.GotoState('');
}
function bool CheckReplacement( Actor Other, out byte bSuperRelevant )
{
 local int i;
 bSuperRelevant = 0;
 if (Weapon(Other) != None)
 {
  for (i=0;i<WeaponClasses.length;i++)
   if (WeaponClasses[i] == Other.class)
    return true;
  return false;
 }
 else if (KFHumanPawn(Other) != None)
 {
  KFHumanPawn(Other).RequiredEquipment[0] = "";
  KFHumanPawn(Other).RequiredEquipment[1] = "";
  return true;
 }
 else if (WeaponPickup(Other) != None && Other.Owner == None)
 {
  return false;
 }
 
 return Super.CheckReplacement( Other, bSuperRelevant );
}
defaultproperties
{
     ConfigMenuClassName="ArenaMut.ArenaMenu"
     FriendlyName="Advanced Weapon Arena"
     GroupName="KF-AdvArena"
     Description="A highly advanced weapon arena"
}

A very advanced advanced mutator (class) that is configurable and has a menu you can open and edit. This mutator basically makes it so you can only add specific guns to the arena instead of the default ones and pickups. The class for the config menu is a seperate class and is refered to in this class several times. Due to its length I cannot post it on here.
Don't bother trying to decipher or understand it because its for the advanced coders, such as my self :D
 
Last edited:

ro_sauce

FNG / Fresh Meat
Sep 26, 2007
3,135
329
0
bwhgaming.com
hmmm, ok, so is there a list somewhere of what variable do what and how to actually do the coding?

i'm basically starting fresh, i dont even know why the parenthesis are there by themselves
 
Last edited:

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,468
2,503
0
Canada
you mean the barrakets after the word then the ;
Example: K.Destroy();

Local K KActor replaces the name of the class KActor with k so it easy to write the code and saves time and space. Its much easier to type instead of KActor everytime it is called.

K=KActor
Destroy(); = Calls the function to destroy the class KActor if it exists in the current map.
We can do this with other objects too!

This destroys all "KFWeaponPickup" (The pickup of a weapon you see when you toss it or see one on the ground.)


Code:
simulated function PostBeginPlay()
{
local KFWeaponPickup K;
ForEach DynamicActors(Class'KFWeaponPickup',K)
{
K.Destroy();
if( K==None )
Continue;
K.SetCollision(False);
K.bHidden = True;
K.RemoteRole = ROLE_None;
}
}
 
Last edited: