Worst-case scenario: the UEd Goblin wipes the map and burns down your house.

Legacy:Ammo (UT)

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
UT :: Actor (UT) >> Inventory (UT) >> Pickup (UT) >> Ammo (Package: Engine)

Parent class of ammunition types for Weapon (UT)s. Child class TournamentAmmo corresponds with TournamentWeapon (UT) weapons.

One does not actually posess a quantity of Ammo inventory items. Rather, an Ammo item is a placeholder which indicates how much of the corresponding ammunition type the player may expend.

Properties

int AmmoAmount (travel, replicated to owning client) 
In inventory, the amount of ammunition of this type the player may expend. For a pickup, amount of ammunition to be added to an inventory copy of the ammotype's AmmoAmount.
int MaxAmmo (travel) 
Maximum amount AmmoAmount may reach in a player's inventory.
class<Ammo> ParentAmmo 
Parent class of Ammotype. Some ammotypes are smaller, child classes of other types, only different in, say, the size of AmmoAmount. Providing a link to a parent class prevents the child ammo from being added to a player's inventory separately from its parent.
byte UsedInWeaponSlot[10] 
For display purposes AFAIK. Position in the HUD Ammo and AmmoAmount should be displayed in.
Ammo PAmmo 
 ???Original implementation of ParentAmmo???

Methods

Inherited from Inventory (UT)

float BotDesireability (Pawn (UT) Bot) 

Known subclasses

Discussion


Csimbi: How can I change the starting ammo, the maximum ammo, and the pickup ammo settings dynamically (default properties are static)?

The following code adjust starting ammo and maximum ammo correctly, but how can I adjust the amount of ammo that is added when player picks up some ammo?

function GiveWeapon(pawn P, string ThisClass)
{
	local class<weapon> WeaponClass< SEMI >
	local weapon NewWeapon;
 
	if (ThisClass=="none") return;
 
	WeaponClass = class<weapon>(DynamicLoadObject(ThisClass, class'Class') );
	if (WeaponClass==none||P.FindInventoryType(WeaponClass)!=none) return;
 
	WeaponClass.default.ItemArticle=MyArticle;
	NewWeapon=Spawn(WeaponClass);
	WeaponClass.default.ItemArticle=NormalArticle;
	NewWeapon.RespawnTime=0.0;
	NewWeapon.GiveTo(P);
	NewWeapon.bHeldItem=true;
	NewWeapon.GiveAmmo(P);
	NewWeapon.SetSwitchPriority(P);
	NewWeapon.WeaponSet(P);
	NewWeapon.AmbientGlow = 0;
 
	if (P.IsA('PlayerPawn')) NewWeapon.SetHand(PlayerPawn(P).Handedness);
	else NewWeapon.GotoState('Idle');
	P.Weapon.GotoState('DownWeapon');
	P.PendingWeapon=none;
	if(ThisClass==MyWeapon && NewWeapon!=none)
	{
		NewWeapon.AmmoType.AmmoAmount=class'OptionsPage'.default.InitialAmmo;
		NewWeapon.AmmoType.MaxAmmo=class'OptionsPage'.default.MaxAmmo;
	}
}

An example would be nice... Thank You.

Wormbo: You can use one of the various HandlePickupQuery() functions (Inventory (UT), Mutator (UT), etc.) to handle any type of pickup, but could you please put your questions where people can actually find them? The Help Desk would be a good place, or a coding forum (e.g. BUF Coding).

Ticklemonster: Open the weapon's uc file, browse down to default properties, and look at this line:

     PickupAmmoCount=8

Change the count to say 99.

Then, look for the weapon's ammo, let's say it's AmmoName=Class'botpack.BulletBox', to go open that uc file, and change it to look like this:

class BulletBox99 extends TournamentAmmo;
 
defaultproperties
{
     AmmoAmount=10
     MaxAmmo=99
     UsedInWeaponSlot(9)=1
     PickupMessage="You got a box of rifle rounds."
     ItemName="Box of Rifle Rounds"
     PickupViewMesh=LodMesh'Botpack.BulletBoxM'
     MaxDesireability=0.240000
     Icon=Texture'UnrealI.Icons.I_RIFLEAmmo'
     Physics=PHYS_Falling
     Skin=Texture'Botpack.Skins.BulletBoxT'
     Mesh=LodMesh'Botpack.BulletBoxM'
     CollisionRadius=15.000000
     CollisionHeight=10.000000
     bCollideActors=True
}

Of course you want to put them in their own class of their own named directory. Say it's a sniper rifle, save the assualtrifle.uc as assualtrifle99.uc and save the bulletbox as bulletbox99.uc. If they are in \AssaultRifle99\Classes, then you will have an AssaultRifle99.u that you can use. You'd want to make a mutator, I guess to make it want to work.

Does that help?

Unknown: (hey Ma, look! I posted on Wiki.beyondunreal!!! Now if I could get someone to tell me how to make a flakslug act like a regular sniper bullet, then make that the primary fire on the flak cannon, I'd be all set... hint hint Mr. Wormbo)