_weapons.gsc and watchPickup()

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Post Reply
bSun Lynx
CJ Wannabe
CJ Wannabe
Posts: 10
Joined: October 1st, 2011, 10:10 pm

_weapons.gsc and watchPickup()

Post by bSun Lynx » October 2nd, 2011, 8:59 pm

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;

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: _weapons.gsc and watchPickup()

Post by Drofder2004 » October 3rd, 2011, 2:01 am

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" );
        }
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

bSun Lynx
CJ Wannabe
CJ Wannabe
Posts: 10
Joined: October 1st, 2011, 10:10 pm

Re: _weapons.gsc and watchPickup()

Post by bSun Lynx » October 4th, 2011, 2:24 am

i'm still kinda lost at this one

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: _weapons.gsc and watchPickup()

Post by Drofder2004 » October 4th, 2011, 5:42 am

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".
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests