Jump to content

Making all weapons have the ability to ADS


Recommended Posts

Starting even from the simple E-11 to the distruptor, i've found that not being able to aim kind of ruins immersion a little. I'm currently working on a project (No, I'm not allowed to reveal it yet) that would make use of an ADS script for normal weapons. 

 

This is what I have so far, this is line 1912 in cg_weapons.c

// play a sound
    if (altFire)
    {
        // play a sound
        for ( c = 0 ; c < 4 ; c++ ) {
            if ( !weap->altFlashSound[c] ) {
                break;
            }
        }
        if ( c > 0 ) {
            c = rand() % c;
            if ( weap->altFlashSound[c] )
            {
                trap_S_StartSound( NULL, ent->number, CHAN_WEAPON, weap->altFlashSound[c] );
            }
        }
    }

Also prepositions from bg_pmove.c, line 6222;if ( pm->ps->weaponstate == WEAPON_CHARGING )
    {
        // weapon has a charge, so let us do an attack
#ifdef _DEBUG
        Com_Printf("Firing. Charge time=%d\n", pm->cmd.serverTime - pm->ps->weaponChargeTime);
#endif


        // dumb, but since we shoot a charged weapon on button-up, we need to repress this button for now
        pm->cmd.buttons |= BUTTON_ATTACK;
        pm->ps->eFlags |= EF_FIRING;
    }
    else if ( pm->ps->weaponstate == WEAPON_CHARGING_ALT )
    {
        // weapon has a charge, so let us do an alt-attack
#ifdef _DEBUG
        Com_Printf("Firing. Charge time=%d\n", pm->cmd.serverTime - pm->ps->weaponChargeTime);
#endif


        
// dumb, but since we shoot a charged weapon on button-up, we need to repress this button for now
        pm->cmd.buttons |= BUTTON_ALT_ATTACK;
        pm->ps->eFlags |= (EF_FIRING|EF_ALT_FIRING);
    }


This one is basically from charged weapon section. Sniper rifle belongs to this section.


Lastly, line 7659;


if ( pm->cmd.buttons & BUTTON_ALT_ATTACK )  {
//if ( pm->ps->weapon == WP_BRYAR_PISTOL && pm->gametype != GT_SIEGE )
if (0)
{ //kind of a hack for now
PM_AddEvent( EV_FIRE_WEAPON );
addTime = weaponData[pm->ps->weapon].fireTime;
}
else if (pm->ps->weapon == WP_DISRUPTOR && pm->ps->zoomMode != 1)
{
PM_AddEvent( EV_FIRE_WEAPON );
addTime = weaponData[pm->ps->weapon].fireTime;
}
else if (pm->ps->weapon == WP_BLASTER && pm->ps->zoomMode != 1)
{
PM_AddEvent( EV_FIRE_WEAPON );
addTime = weaponData[pm->ps->weapon].fireTime;
}
 
Any ideas/Feedback? I already have 2d models to attach to the ADS in place of the sniper scope.
Edited by Circa
code tags are lovely this time of year
Link to comment
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...