Author Topic: Pistol brass on wrong side  (Read 1205 times)

0 Members and 1 Guest are viewing this topic.

Phrozo

  • Mr. Phrozo
  • Jr. Member
  • **
  • Posts: 56
  • Karma: +11/-0
  • :3
    • View Profile
    • Mod Page
Re: Pistol brass on wrong side
« Reply #15 on: February 05, 2016, 12:37:43 AM »
I can't help with the model/bone stuff but here is something easy you can do with the code.

I'm not sure why this was done in the original code, but the ejected brass debris is having it's linear ( and also angular ) velocity forced to eject based on the player view axis after it is launched. This isn't necessary and prevents a negative y value for the vector being used which is needed to eject right.

From Weapon.cpp:
Code: [Select]
/*
================
idWeapon::Event_EjectBrass

Toss a shell model out from the breach if the bone is present
================
*/
void idWeapon::Event_EjectBrass( void ) {
if ( !g_showBrass.GetBool() || !owner->CanShowWeaponViewmodel() ) {
return;
}

if ( ejectJointView == INVALID_JOINT || !brassDict.GetNumKeyVals() ) {
return;
}

if ( gameLocal.isClient ) {
return;
}

idMat3 axis;
idVec3 origin, linear_velocity, angular_velocity;
idEntity *ent;

if ( !GetGlobalJointTransform( true, ejectJointView, origin, axis ) ) {
return;
}

gameLocal.SpawnEntityDef( brassDict, &ent, false );
if ( !ent || !ent->IsType( idDebris::Type ) ) {
gameLocal.Error( "'%s' is not an idDebris", weaponDef ? weaponDef->dict.GetString( "def_ejectBrass" ) : "def_ejectBrass" );
}
idDebris *debris = static_cast<idDebris *>(ent);
debris->Create( owner, origin, axis );
debris->Launch();

linear_velocity = 40 * ( playerViewAxis[0] + playerViewAxis[1] + playerViewAxis[2] );
angular_velocity.Set( 10 * gameLocal.random.CRandomFloat(), 10 * gameLocal.random.CRandomFloat(), 10 * gameLocal.random.CRandomFloat() );

debris->GetPhysics()->SetLinearVelocity( linear_velocity );
debris->GetPhysics()->SetAngularVelocity( angular_velocity );
}

Comment out this:

Code: [Select]
//linear_velocity = 40 * ( playerViewAxis[0] + playerViewAxis[1] + playerViewAxis[2] );
//angular_velocity.Set( 10 * gameLocal.random.CRandomFloat(), 10 * gameLocal.random.CRandomFloat(), 10 * gameLocal.random.CRandomFloat() );

//debris->GetPhysics()->SetLinearVelocity( linear_velocity );
//debris->GetPhysics()->SetAngularVelocity( angular_velocity );

After modifying the code, you can get the shotgun shell to eject right with one last change:

Change the y value to something negative for this vector being used in 'debris_shotgunbrass'
Code: [Select]
"velocity" "-25 -100 50"
I also tested this so it should work.
« Last Edit: February 05, 2016, 01:09:51 AM by Phrozo »

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 791
  • Karma: +30/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Pistol brass on wrong side
« Reply #16 on: February 05, 2016, 06:49:12 AM »
Thanks.  I was starting to think down that path.