Author Topic: Gamemode_Zombie's Ammo system and modifying how much ammo a weapon starts with  (Read 1142 times)

Is there a way to set max ammo(Gamemode Zombie's ammo system is limited ammo but no reloading) for specific weapons if you use the ammo system Gamemode_Zombie has?



For example, I want to make the first gun have 60-ish or so ammo and the second gun have 20-ish or so ammo. How would I do that?

lol, I was looking through the code
//I was an extra in a movie today, it was really strange, and I probably heard someone say standby about 300 times.
still haven't found what adds ammo, it isn't in the ammo crate file..

oh, I think I found the code that does it
line 494 of Zombie_Overwrite.cs
Code: [Select]
function armor::onCollision(%this, %obj, %col, %fade, %pos, %norm)
{
if(%col.getdatablock().getname() $= "RAmmoCrateItem" && %col.iszombie != 1)
{
if(isObject(%obj.getmountedimage(0)) && IsInMinigame(%obj) && %obj.getmountedimage(0).melee != 1  && MinigameIncludesItem(%col) && %col.isshutting != 1)
{
if(%obj.zombieammo[%obj.getmountedimage(0).projectile] == -1)
{
%obj.zombieammo[%obj.getmountedimage(0).projectile] = 1;
%obj.mountimage(%obj.getmountedimage(0).RWep,0);
if(%col.isopen == 0)
{
HealthlockerAnim(%col,1);
}
cancel(%col.closedoor);
%col.closedoor = schedule(600,0,HealthlockerAnim,%col,0);
}
if($zombie::ammo::Ammo[%obj.getmountedimage(0).projectile] > 0)
{
if(%obj.zombieammo[%obj.getmountedimage(0).projectile] < $zombie::ammo::Ammo[%obj.getmountedimage(0).projectile])
{

%obj.zombieammo[%obj.getmountedimage(0).projectile]++;
if($zombie::ammo::Ammo[%obj.getmountedimage(0).projectile] >= 30 && %obj.getmountedimage(0).projectile.getname !$= "MiniGunProjectile")
{
%obj.zombieammo[%obj.getmountedimage(0).projectile]+=4;
}
if(%obj.getmountedimage(0).projectile.getname $= "MiniGunProjectile")
{
%obj.zombieammo[%obj.getmountedimage(0).projectile]++;
}
%obj.playaudio(1,ammocratesound);
bottomprintremainingammo(%obj,%obj.getmountedimage(0));
if(%col.isopen == 0)
{
HealthlockerAnim(%col,1);
}
cancel(%col.closedoor);
%col.closedoor = schedule(600,0,HealthlockerAnim,%col,0);
}
if(%obj.zombieammo[%obj.getmountedimage(0).projectile] > $zombie::ammo::Ammo[%obj.getmountedimage(0).projectile])
{
%obj.zombieammo[%obj.getmountedimage(0).projectile] = $zombie::ammo::Ammo[%obj.getmountedimage(0).projectile];
%obj.playaudio(1,ammocratesound);
bottomprintremainingammo(%obj,%obj.getmountedimage(0));
if(%col.isopen == 0)
{
HealthlockerAnim(%col,1);
}
cancel(%col.closedoor);
%col.closedoor = schedule(600,0,HealthlockerAnim,%col,0);
}
}
else
{
if(%obj.zombieammo[%obj.getmountedimage(0).projectile] < 20)
{
%obj.zombieammo[%obj.getmountedimage(0).projectile]++;
%obj.playaudio(1,ammocratesound);
bottomprintremainingammo(%obj,%obj.getmountedimage(0));
if(%col.isopen == 0)
{
HealthlockerAnim(%col,1);
}
cancel(%col.closedoor);
%col.closedoor = schedule(600,0,HealthlockerAnim,%col,0);
}
}
}
return;
}
if(%col.getdatablock().getname() $= "RHealthLockerItem" && %col.iszombie != 1)
{
if(IsInMinigame(%obj) && MinigameIncludesItem(%col) && %obj.getdamagelevel() > 0 && %obj.getstate() !$= "Dead" && %col.isshutting != 1)
{
%obj.addhealth(5);
%obj.mountimage(RHealImage,2);
%obj.playaudio(2,PrintFireSound);
if(%col.isopen == 0)
{
HealthlockerAnim(%col,1);
}
cancel(%col.closedoor);
%col.closedoor = schedule(600,0,HealthlockerAnim,%col,0);
}
return;
}
if(%obj.getclassname() $= "AiPlayer")
{
parent::onCollision(%this, %obj, %col, %fade, %pos, %norm);
return;
}
if(IsInMinigame(%obj))
{
for(%i=0;%i<5;%i++)
{
%toolDB = %obj.tool[%i].image;
if(%toolDB $= %col.getdatablock().image)
{
return;
break;
}
}
if(%col.getclassname()$= "Item" && isobject(%col.spawnbrick))
{
%col.RemAmmo = 0;
}
if(%col.getclassname() $= "Item" && %col.RemAmmo != 0)
{
%projectile = %col.getdatablock().image.projectile;
%obj.zombieammo[%col.getdatablock().image.projectile] = %col.RemAmmo;
}
}
parent::onCollision(%this, %obj, %col, %fade, %pos, %norm);
}
looks like you just need to set $zombie::ammo::Ammo[%obj.getmountedimage(0).projectile]; for it to have an ammo value

it should then call this function
Code: [Select]
function WeaponImage::onFire(%this, %obj, %slot)
{
if(IsInMinigame(%obj) && %obj.client.minigame.EnableAmmoMod == 1)
{
if(%this.melee == 1){
parent::onFire(%this, %obj, %slot);
return ;
}
if(%obj.zombieammo[%this.projectile] == -1)
{
BottomPrint(%obj.client,"<just:center><color:FFFF00>Ammo <color:FFFFFF>: <just:left><color:FF0000> NONE",3);
//%obj.playthread(2,activate2);
return;

}
if(%obj.zombieammo[%this.projectile] >= 1)
{
%obj.zombieammo[%this.projectile]--;
bottomprintremainingammo(%obj,%this);
parent::onFire(%this, %obj, %slot);
if(%obj.zombieammo[%this.projectile] == 1 && %this.projectile $= "akimboGunProjectile")
{
%obj.zombieammo[%this.projectile]--;
bottomprintremainingammo(%obj,%this);
}
}
if(%obj.zombieammo[%this.projectile] <= 0)
{
%obj.zombieammo[%this.projectile] = -1;
if(isobject(%obj.getmountedimage(0).getname() @ "NoFire"))
{
%obj.mountimage(%obj.getmountedimage(0).getname() @ "NoFire",0);
}
BottomPrint(%obj.client,"<just:center><color:FFFF00>Ammo <color:FFFFFF>: <just:left><color:FF0000> NONE",3);
%obj.playaudio(1,ammocratesound);
%obj.playthread(2,activate2);
return;
}
}
else
{
parent::onFire(%this, %obj, %slot);
}
}
and not fire when it's out of ammo
if it's melee, it should ignore that and swing anyway

... found another bit of relevant code in Zombie_spawn.cs
Code: [Select]
$zombie::ammo::Listcount = 0;
$zombie::ammo::Gun[$zombie::ammo::Listcount++] = GunProjectile;
$zombie::ammo::AmmoGunProjectile = 60;
$zombie::ammo::Gun[$zombie::ammo::Listcount++] = AkimboGunProjectile;
$zombie::ammo::AmmoAkimboGunProjectile = 100;
$zombie::ammo::Gun[$zombie::ammo::Listcount++] = RocketLauncherProjectile;
$zombie::ammo::AmmoRocketLauncherProjectile = 20;
$zombie::ammo::Gun[$zombie::ammo::Listcount++] = SniperRifleProjectile;
$zombie::ammo::AmmoSniperRifleProjectile = 40;
$zombie::ammo::Gun[$zombie::ammo::Listcount++] = MiniGunProjectile;
$zombie::ammo::AmmoMiniGunProjectile = 200;
$zombie::ammo::Gun[$zombie::ammo::Listcount++] = ShotgunProjectile;
$zombie::ammo::AmmoShotgunProjectile = 40;

So the ammo system is based off of projectiles? What if I want to use the Bow or Ladios's Laser Pack?

it's based off of guns that use the projectile, I think
so if you made a bow shoot rockets instead of arrows, it should share the same ammo pool as a rocket launcher
if you want to use a bow with arrows, you'd probably just do $zombie::ammo::Gun[$zombie::ammo::Listcount++] = bow.projectile; $zombie::ammo:Ammo[bow.projectile] = 10;
or something similar to get 10 max arrows for a bow