Page 1 of 1

_weapons.gsc and watchPickup()

Posted: October 2nd, 2011, 8:59 pm
by bSun Lynx
i'm trying to make it so axis get no ammo when they pick up something or not even pick it if it's just ammo. looking back at _weapons.gsc i've found something called watchPickup() but there's nothing regarding the ammo itself.

Code: Select all

watchPickup()
{
        self endon("death");
        
        weapname = self getItemWeaponName();
        
        while(1)
        {
                self waittill( "trigger", player, droppedItem );
                
                if ( isdefined( droppedItem ) )
                        break;
                // otherwise, player merely acquired ammo and didn't pick this up
        }
        
        /#
        if ( getdvar("scr_dropdebug") == "1" )
                println( "picked up weapon: " + weapname + ", " + isdefined( self.ownersattacker ) );
        #/
 
        assert( isdefined( player.tookWeaponFrom ) );
        
        // make sure the owner information on the dropped item is preserved
        droppedWeaponName = droppedItem getItemWeaponName();
        if ( isdefined( player.tookWeaponFrom[ droppedWeaponName ] ) )
        {
                droppedItem.owner = player.tookWeaponFrom[ droppedWeaponName ];
                droppedItem.ownersattacker = player;
                player.tookWeaponFrom[ droppedWeaponName ] = undefined;
        }
        droppedItem thread watchPickup();
        
        // take owner information from self and put it onto player
        if ( isdefined( self.ownersattacker ) && self.ownersattacker == player )
        {
                player.tookWeaponFrom[ weapname ] = self.owner;
        }
        else
        {
                player.tookWeaponFrom[ weapname ] = undefined;
        }
}
i've tried to add a check at the top of it but it went dysfunctional and i could pick up everything (both ammo and weapons) still..

Code: Select all

if(self.pers["team"] == "axis")
        return;

Re: _weapons.gsc and watchPickup()

Posted: October 3rd, 2011, 2:01 am
by Drofder2004
I believe this is purely for achievement tracking, specifically "Cruelty" - using the weapon dropped from your victim, to kill that victim again.

Code: Select all

if ( isdefined( player.tookWeaponFrom[ data.sWeapon ] ) )
        {
                if ( player.tookWeaponFrom[ data.sWeapon ] == data.victim && data.sMeansOfDeath != "MOD_MELEE" )
                        player processChallenge( "ch_cruelty" );
        }

Re: _weapons.gsc and watchPickup()

Posted: October 4th, 2011, 2:24 am
by bSun Lynx
i'm still kinda lost at this one

Re: _weapons.gsc and watchPickup()

Posted: October 4th, 2011, 5:42 am
by Drofder2004
bSun Lynx wrote:i'm still kinda lost at this one
What are you lost about?

The function you posted is not used to give a player a weapon/ammo (at least not directly).
the weapon pickup stuff is HARD coded and cannot be modified. IF you want to stop a player picking up weapons, the only way is to stop the weapon from dropping.

item = self dropItem( weapon );

that is the line of code found in _Weapons.gsc.

-----

If you want the other team to be able to pickup, then you will need to do a little coding yourself.

Firstly, stop the item dropping.
Spawn a trigger in its place.
Use the trigger to detect the team of the player.
Finally decide what ammo and how much to give [clipammo, stockammo]

All of that info can be obtained in "dropWeaponForDeath".