Author Topic: Bullets not working on gun  (Read 701 times)

Does anyone know why this is happening?

nevermind I fixed it by just copying the gun code into mine since i must've changed it. although how can I change the speed of the bullet?

muzzleVelocity in the ProjectileData, velInheritFactor below it means how affected by the player's momentum the projectile is, like, the projectile will go towards the side if a player is strafing while firing, rather than go towards where they were looking when they fired the gun, for velInheritFactor, 1 is usually a good amount of player momentum to inherit if you want that, setting it to 0 will nullify that

lifetime, if it wasn't obvious enough, is how long the projectile exists (in milliseconds, or units?) before it stops existing
« Last Edit: June 21, 2016, 12:37:09 AM by Masterlegodude »

also do anyone know a good tutorial for adding ammo to weapons?

also do anyone know a good tutorial for adding ammo to weapons?
i would just look through the script files of some mod like tier tactical and see how it works there
doesnt feel like it would be too hard
[pseudocode]
Code: [Select]
on gun fire
if ammo = 0
reload
else
fire gun
ammo--
you would have to add a reload animation too though
and bottomprint/something else for showing ammo

ok i looked through the gunplus code and i modified that but now it's not working since when the ammo gets to 1 the sound doesn't play.
Code: [Select]
function barrettImage::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
{
%obj.playThread(2, standJump);
  }

  if(%obj.barrettammo $= "")
    %obj.barrettammo = 5;

bottomPrint(%obj.client, "<just:right><font:impact:25>\c3Ammo\c6: " @ %obj.barrettammo @ " / 5", 2);
if(%obj.barrettammo == 0)
{
%obj.unmountImage(%slot);
%obj.mountImage(barrettReloadImage, %slot);
%obj.barrettammo = 5;
}
Parent::onFire(%this,%obj,%slot);
%obj.barrettammo--;
}

function BarrettReloadImage::onComplete(%this,%obj,%slot)
{
%obj.schedule(1200, unmountImage, %slot);
%obj.schedule(1200, mountImage, BarrettImage, %slot, 1);
}

function BarrettImage::onMount(%this,%obj,%slot, %reloaded)
{
Parent::onMount(%this,%obj,%slot);
  %obj.setMaxForwardSpeed(2);
  %obj.setMaxSideSpeed(1);
  %obj.setMaxBackwardSpeed(1);
%obj.hideNode("RHand");
%obj.hideNode("RHook");
%obj.hideNode("LHand");
%obj.hideNode("LHook");
  if(%reloaded)
  {
    %obj.barrettammo = 5;
    return;
  }
}

function BarrettImage::onUnMount(%this,%obj,%slot)
{
Parent::onMount(%this,%obj,%slot);
%obj.unHideNode("ALL");
  %obj.setMaxForwardSpeed(7);
  %obj.setMaxSideSpeed(6);
  %obj.setMaxBackwardSpeed(4);
if(isObject(%obj.client))
{
%obj.client.applyBodyParts();
%obj.client.applyBodyColors();
}
else
applyDefaultCharacterPrefs(%obj);
}

move the bottomPrint to after you decrement ammo so it shows the values correctly
otherwise (i think?) it will lag behind by 1 bullet

it still does it, sound doesn't play and the projectile is actually fired

it still does it, sound doesn't play and the projectile is actually fired
not exactly sure what you mean by this
but it doesnt look like you put the function name (mountImage/unMountImage) in quotes in the schedules?

that doesn't make a difference at all