Game Development Community

how would i make a specific weaon have infinate ammo?

by Ace · in General Discussion · 03/22/2002 (7:06 pm) · 3 replies

im hoping theres an esy way to do this (i just aint found it yet)most "good" games have a start weapon that dont use up ammo and id like to put with the following code if i could:

//ace
%weapon = new Item()
{
// Let this point to the type of weapon
// (Rifle and Crossbow being the defalt)
dataBlock = Crossbow;
};

%ammo = new Item()
{
dataBlock = CrossbowAmmo;
};

MissionCleanup.add(%weapon);
MissionCleanup.add(%ammo);
%player.pickup(%weapon, 1);
%player.pickup(%ammo, 1);
//endace

#1
03/22/2002 (7:36 pm)
hey ok i think i found it (correct me if im rong)

in crosbow.cs the last function
function CrossbowImage::onFire(%this, %obj, %slot)
{
%projectile = %this.projectile;

// Decrement inventory ammo. The image's ammo state is update
// automatically by the ammo inventory hooks.
%obj.decInventory(%this.ammo,0);


i just changed
%obj.decInventory(%this.ammo,1);

to a value of 0

[edit] im not going to use the cbow for it ,its just everyone has one [/edit]
#2
03/23/2002 (3:02 am)
just remove the decinventory command totally...doing it set to 0 is redundant and eating up CPU cycles.

-Tim aka Spock
#3
03/23/2002 (3:05 am)
cool thanks for the tip