Automatic shotgun Reloading problems

Grab your favourite IDE and tinker with the innards of game engines

Automatic shotgun Reloading problems

Postby Jangalomph on Fri Jul 16, 2010 12:05 am

Greetings people that probably won't reply..

I have finally gotten my AA-12 shotgun to be automatic like a machine gun.. now since it has a drum magazine.. we want it to reload just like an SMG would.. the current shotgun code overrides so its only one shell at a time.. meaning it uses our reload animation 20 times to fill a whole magazine.. How do we get it to where it simply just does the reload animation then bam.. we have our 20 shells?

Code: Select all
bool CWeaponAA12::StartReload( void )
{
   CBaseCombatCharacter *pOwner  = GetOwner();
   
   if ( pOwner == NULL )
      return false;

   if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
      return false;

   if (m_iClip1 >= GetMaxClip1())
      return false;

   // If AA12 totally emptied then a pump animation is needed
   
   //NOTENOTE: This is kinda lame because the player doesn't get strong feedback on when the reload has finished,
   //         without the pump.  Technically, it's incorrect, but it's good for feedback...

   if (m_iClip1 <= 0)
   {
      m_bNeedPump = true;
   }

   int j = min(1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));

   if (j <= 0)
      return false;

   SendWeaponAnim( ACT_SHOTGUN_RELOAD_START );

   // Make AA12 shell visible
   SetBodygroup(1,0);

   pOwner->m_flNextAttack = gpGlobals->curtime;
   m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();

   m_bInReload = true;
   return true;
}

//-----------------------------------------------------------------------------
// Purpose: Override so only reload one shell at a time
// Input  :
// Output :
//-----------------------------------------------------------------------------
bool CWeaponAA12::Reload( void )
{
   // Check that StartReload was called first
   if (!m_bInReload)
   {
      Warning("ERROR: AA12 Reload called incorrectly!\n");
   }

   CBaseCombatCharacter *pOwner  = GetOwner();
   
   if ( pOwner == NULL )
      return false;

   if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
      return false;

   if (m_iClip1 >= GetMaxClip1())
      return false;

   int j = min(1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));

   if (j <= 0)
      return false;

   FillClip();
   // Play reload on different channel as otherwise steals channel away from fire sound
   WeaponSound(RELOAD);
   SendWeaponAnim( ACT_VM_RELOAD );

   pOwner->m_flNextAttack = gpGlobals->curtime;
   m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();

   return true;
}

//-----------------------------------------------------------------------------
// Purpose: Play finish reload anim and fill clip
// Input  :
// Output :
//-----------------------------------------------------------------------------
void CWeaponAA12::FinishReload( void )
{
   // Make AA12 shell invisible
   SetBodygroup(1,1);

   CBaseCombatCharacter *pOwner  = GetOwner();
   
   if ( pOwner == NULL )
      return;

   m_bInReload = false;

   // Finish reload animation
   SendWeaponAnim( ACT_SHOTGUN_RELOAD_FINISH );

   pOwner->m_flNextAttack = gpGlobals->curtime;
   m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
}



Showing off what we've got.. and in one part.. notice how it tries to reload, but only puts in 1 shell.. :cry:
http://www.nomoreroominhell.com
I don’t know whether I was right or wrong, I guess I’ll never know… But I made it. And I guess I should be thankful for that. - Strelok
Has anyone really been far even as decided to use even go want to do look more like?
User avatar
Jangalomph
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Wed Jun 25, 2008 3:19 pm
Location: Sumter, SC

Re: Automatic shotgun Reloading problems

Postby jgoodroad on Fri Jul 16, 2010 4:57 am

curiosity bump?

I just didn't want to be the "guy who reads this and dosn't post" after reading your first line... since I have no redemable traits... I can't do anything to help... but bump.

and I am curios* on what the fix for this is...
===[]"

Image
current projects: nmo_boardwalk, nmo_asylum
User avatar
jgoodroad
Senior Member
Senior Member
 
Joined: Thu Apr 09, 2009 4:44 am
Location: on a boat... unless it's a farm.

Re: Automatic shotgun Reloading problems

Postby ErikKiller on Fri Jul 16, 2010 10:00 am

Could it be from the lack of ammo?
Image
Image
First rodeo? Use the Source SDK Documentation for reference!
User avatar
ErikKiller
May Contain Skills
May Contain Skills
 
Joined: Sun Sep 09, 2007 4:05 pm
Location: Estonia

Re: Automatic shotgun Reloading problems

Postby JLea on Fri Jul 16, 2010 11:19 am

delete startreload

replace reload with SMG reload

m_bReloadsSingly = false;
User avatar
JLea
May Contain Skills
May Contain Skills
 
Joined: Mon Jan 02, 2006 1:19 pm
Location: Melbourne, Australia

Re: Automatic shotgun Reloading problems

Postby ErikKiller on Fri Jul 16, 2010 2:46 pm

Somebody had a dose of Australium...
Image
Image
First rodeo? Use the Source SDK Documentation for reference!
User avatar
ErikKiller
May Contain Skills
May Contain Skills
 
Joined: Sun Sep 09, 2007 4:05 pm
Location: Estonia

Re: Automatic shotgun Reloading problems

Postby Jangalomph on Fri Jul 16, 2010 4:58 pm

So i replace startreload codes with the smg's and leave the :reload function as is?

Never mind.. i think i got it.

EDIT:2 Sorry jlea.. that doesn't work. When i replace the reload function it doesn't even put a bullet in. :|
http://www.nomoreroominhell.com
I don’t know whether I was right or wrong, I guess I’ll never know… But I made it. And I guess I should be thankful for that. - Strelok
Has anyone really been far even as decided to use even go want to do look more like?
User avatar
Jangalomph
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Wed Jun 25, 2008 3:19 pm
Location: Sumter, SC

Re: Automatic shotgun Reloading problems

Postby Jangalomph on Sat Jul 17, 2010 12:12 am

http://pastebin.com/daTk7AWd that is the link to the AA-12 on the weapon_shotgun.cpp version.

Now.. for the Smg1 code converted to a shotgun..

I get these errors in the console. I pasted all the ACTS_SHOTGUN_BULLCRAP over the SMG's actions.

And i get this super wonderful error in console..


Missing RecvProp for DT_WeaponAA12 - DT_BaseAnimating/baseclass
Host_EndGame: CL_ParseClassInfo_EndClasses: CreateDecoders failed.

Dropped [SχG]Andy Bernard from server (Disconnect by user.)

Here is the code to my AA12.

http://pastebin.com/YXjSZhgc

So all of my errors in the C++ editor have been fixed =D.. just gotta work out console now.

Here is my weapon_aa12.txt file.

http://pastebin.com/yXpbJvRF
http://www.nomoreroominhell.com
I don’t know whether I was right or wrong, I guess I’ll never know… But I made it. And I guess I should be thankful for that. - Strelok
Has anyone really been far even as decided to use even go want to do look more like?
User avatar
Jangalomph
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Wed Jun 25, 2008 3:19 pm
Location: Sumter, SC

Re: Automatic shotgun Reloading problems

Postby Jordash on Sun Jul 18, 2010 1:42 pm

Get a SMG clone weapon working correctly, then grab the primary fire code from base machinegun or base weapon, paste that in, then get the firebullets command from the shotgun and replace the SMG one you've stolen.

In theory it will work like a charm
User avatar
Jordash
Been Here A While
Been Here A While
 
Joined: Mon Sep 21, 2009 10:36 am
Location: Perth, Australia

Re: Automatic shotgun Reloading problems

Postby Noodles on Sun Jul 18, 2010 2:08 pm

Jordash wrote:Get a SMG clone weapon working correctly, then grab the primary fire code from base machinegun or base weapon, paste that in, then get the firebullets command from the shotgun and replace the SMG one you've stolen.

In theory it will work like a charm


I'm not a coder, but from what I know that's what I'd suggest - you use SMG code and change the bullet type to 'buckshot', I think it's called. Might even be able to do it in the script, up the number of bullets fired at one time, and of course you can change dmg, time between firing, etc.

Also, sexy animations you have there :smt023
'English as tuppence, changing yet changeless as canal water, nestling in green nowhere, armoured and effete, bold flag-bearer, lotus-fed Miss Havershambling, opsimath and eremite, feudal, still reactionary Rawlinson End.'
User avatar
Noodles
Pheropod
Pheropod
 
Joined: Mon May 09, 2005 3:52 pm
Location: Sweden

Re: Automatic shotgun Reloading problems

Postby Jordash on Mon Jul 19, 2010 5:55 am

its nothing to do with calling it "buckshot" thats only the damage amount.

This is from the shotgun code. The 7 at the start is how many bullets are fired, for the SMG and all other weapons that value is 1

Code: Select all
FireBulletsInfo_t info( 7, vecSrc, vecAiming, GetBulletSpread(), MAX_TRACE_LENGTH, m_iPrimaryAmmoType );
User avatar
Jordash
Been Here A While
Been Here A While
 
Joined: Mon Sep 21, 2009 10:36 am
Location: Perth, Australia

Return to Programming

Who is online

Users browsing this forum: No registered users

cron