Tremulous Forum

General => Feedback => Topic started by: SLAVE|Mietz on April 08, 2006, 12:12:54 PM

Title: reload: glitch or feature?
Post by: SLAVE|Mietz on April 08, 2006, 12:12:54 PM
I noticed that if you hit reload while your weapon has full ammo, the full cardridge will be discarded completely.

I don't know, is this a bug or a feature? (to bring in more reality)

Maybe it would be possible to deactivate the reloading function when the ammo-cardridge is full.
Title: reload: glitch or feature?
Post by: Snarboo on April 08, 2006, 05:54:52 PM
I've wondered about this myself. Considering how Trem handles magazines (eg any left over rounds in a magazine are simply discarded), I think it might be intentional.
Title: reload: glitch or feature?
Post by: Howitzer on April 09, 2006, 01:20:18 AM
It's intentional i think.
I've seen in in Battlefield 1942 aswell and i think it's fairly logical since we're dealing with cartridges here, not individual bullets.

And disabling reloading when you have half a clip left isn't a good idea.
I like to have a full cartridge to shoot when going into combat.
Title: reload: glitch or feature?
Post by: R1CH on April 09, 2006, 06:23:37 AM
This is "fixed" on AKKA as I didn't really see the point, an accidental keypress shouldn't throw away an entire clip of ammo. Whether it is a bug or feature though I cannot say.
Title: reload: glitch or feature?
Post by: Timbo on April 09, 2006, 11:57:28 AM
Feature.
Title: reload: glitch or feature?
Post by: Catalyc on April 09, 2006, 01:07:43 PM
Newbie trap!  :roll:
Title: reload: glitch or feature?
Post by: SLAVE|Mietz on April 09, 2006, 02:56:44 PM
Quote from: HowitzerIt's intentional i think.
I've seen in in Battlefield 1942 aswell and i think it's fairly logical since we're dealing with cartridges here, not individual bullets.

And disabling reloading when you have half a clip left isn't a good idea.
I like to have a full cartridge to shoot when going into combat.

Now I didn't say that the half cartridge should be blocked, only the full cartridge.
Title: reload: glitch or feature?
Post by: Howitzer on April 09, 2006, 03:19:59 PM
Sorry, i read half-full :P
Title: reload: glitch or feature?
Post by: next_ghost on May 08, 2006, 03:18:44 PM
Well, here's a patch for game/bg_pmove.c that blocks full-ammo reloads. Works against both 1.1.0 and CVS.

--- /usr/src/tremulous-1.1.0-src/src/game/bg_pmove.c 2006-01-12 18:05:09.000000000 +0100
+++ bg_pmove.c 2006-05-08 14:50:08.000000000 +0200
@@ -2674,7 +2674,7 @@
static void PM_Weapon( void )
{
  int           addTime = 200; //default addTime - should never be used
-  int           ammo, clips, maxClips;
+  int           ammo, maxammo, clips, maxClips;
  qboolean      attack1 = qfalse;
  qboolean      attack2 = qfalse;
  qboolean      attack3 = qfalse;
@@ -2810,14 +2810,22 @@
  {
    pm->ps->pm_flags &= ~PMF_WEAPON_RELOAD;

-    pm->ps->weaponstate = WEAPON_RELOADING;
+    BG_FindAmmoForWeapon( pm->ps->weapon, &maxammo, NULL );
+    if( BG_FindUsesEnergyForWeapon( pm->ps->weapon ) &&
+        BG_InventoryContainsUpgrade( UP_BATTPACK, pm->ps->stats ) )
+      maxammo = (int)( (float)maxammo * BATTPACK_MODIFIER );

-    //drop the weapon
-    PM_StartTorsoAnim( TORSO_DROP );
+    // don't reload full clips
+    if(ammo < maxammo) {
+      pm->ps->weaponstate = WEAPON_RELOADING;

-    addTime = BG_FindReloadTimeForWeapon( pm->ps->weapon );
+      //drop the weapon
+      PM_StartTorsoAnim( TORSO_DROP );

-    pm->ps->weaponTime += addTime;
+      addTime = BG_FindReloadTimeForWeapon( pm->ps->weapon );
+
+      pm->ps->weaponTime += addTime;
+    }
    return;
  }
Title: reload: glitch or feature?
Post by: Paradox on May 08, 2006, 07:40:14 PM
Every FPS i have ever played uses this feature. :-?
Title: reload: glitch or feature?
Post by: next_ghost on June 07, 2006, 11:08:50 AM
A little question for the devs. Do you think that this is a good idea:
bg_pmove.c lines 2780-2786:
static void PM_Weapon( void ) {
...
 // check for out of ammo
 if( !ammo && !clips && !BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) )
 {
   PM_AddEvent( EV_NOAMMO );
   pm->ps->weaponTime += 200;
   return;
 }

... lines 2712-2738

 // check for weapon change
 // can't change if weapon is firing, but can change
 // again if lowering or raising
 if( pm->ps->weaponTime <= 0 || pm->ps->weaponstate != WEAPON_FIRING )
 {
   //TA: must press use to switch weapons
   if( pm->cmd.buttons & BUTTON_USE_HOLDABLE )
   {
     if( !( pm->ps->pm_flags & PMF_USE_ITEM_HELD ) )
     {
       if( pm->cmd.weapon <= 32 )
       {
         //if trying to select a weapon, select it
         if( pm->ps->weapon != pm->cmd.weapon )
           PM_BeginWeaponChange( pm->cmd.weapon );
       }
       else if( pm->cmd.weapon > 32 )
       {
         //if trying to toggle an upgrade, toggle it
         if( BG_InventoryContainsUpgrade( pm->cmd.weapon - 32, pm->ps->stats ) ) //sanity check
         {
           if( BG_UpgradeIsActive( pm->cmd.weapon - 32, pm->ps->stats ) )
             BG_DeactivateUpgrade( pm->cmd.weapon - 32, pm->ps->stats );
           else
             BG_ActivateUpgrade( pm->cmd.weapon - 32, pm->ps->stats );
         }
       }
       pm->ps->pm_flags |= PMF_USE_ITEM_HELD;
     }
   }
...
}


This little piece of code (lines 2780 thru 2786) does nothing for weapons except grenade (the only weapon with EV_NOAMMO handler). It simply repeatedly blocks weapon actions for 200ms. That also means it blocks item toggle button because items can be toggled in PM_Weapon() only if pm->ps->weaponTime <= 0 and WEAPON_FIRING flag is not set (lines 2712 thru 2738). It also seems the WEAPON_FIRING flag is never cleared because PM_Weapon() exits before it checks for attacks.

Edit: https://bugzilla.icculus.org/show_bug.cgi?id=2737