Announcement

Collapse
No announcement yet.

Weapons given to killer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Yes, I know, that worked. I'm just wondering how to turn off weapon throwing now.

    Leave a comment:


  • replied
    My code above will give the killer all the victims weapons, including the one they are holding......

    Leave a comment:


  • replied
    I'm tring to prevent them from dropping their current weapon when they die. Is there a setting for that?

    Leave a comment:


  • replied
    I turned off weapon tossing like this in my mutator class, works fine for me.

    Code:
    function PreBeginPlay()
    {
       Super.PreBeginPlay();
    
       Level.Game.bAllowWeaponThrowing = FALSE;
    }
    That stops people from tossing their weapons but they still drop their current weapon when they die.

    Leave a comment:


  • replied
    Is there an easy way to turn off the weapon tossing in the code? I've been looking through source code, but I can't seem to find this setting anywhere.

    Leave a comment:


  • replied
    Originally posted by bigbogus
    Thanks. That worked perfectly. Why does this need to be called from the PreventDeath() method rather than the Killed() method to work? I'll still relatively new to unrealscript, so I'm trying to learn as much as I can.
    PreventDeath() is called before the victim is killed (so he still holds his weapon), Killed() is called when he's killed (so his weapon has already been tossed).

    Leave a comment:


  • replied
    You going to release this puupy or what?

    Leave a comment:


  • replied
    Thanks. That worked perfectly. Why does this need to be called from the PreventDeath() method rather than the Killed() method to work? I'll still relatively new to unrealscript, so I'm trying to learn as much as I can.

    Leave a comment:


  • replied
    Sorry, my first post was flawed:
    Code:
    function bool PreventDeath(Pawn Killed, Controller Killer, class<DamageType> damageType, vector HitLocation){
    	local bool PD;
    	PD=Super.PreventDeath(Killed,Killer,damageType,HitLocation);
    	if (!PD) processKill(Killer.Pawn,Killed);
    	return PD;
    }
    
    function processKill(Pawn Killer, Pawn Victim)
    {
        local Inventory Inv, newWeapon;
    
        // Boost killers properties on kill
        Killer.Health = 199;
        Killer.AddShieldStrength(250);
    
        // Give victims weapons to killer
        for(Inv = Victim.Inventory; Inv != None; Inv = Inv.Inventory)
        {
            if(Weapon(Inv)!= None)
            {
                newWeapon = Spawn(Inv.Class);
                if (newWeapon != None) {
                      Log("----- Relinquishing weapon "$ Weapon(Inv) $" to: "$ Killer.PlayerReplicationInfo.PlayerName $ "...");
                      newWeapon.GiveTo(Killer);
                      if ( Weapon(newWeapon)!=None ) Weapon(newWeapon).MaxOutAmmo();
                      //Weapon(Inv).Destroy();
    
                }
            }
        }
    }
    Tested an working.

    Leave a comment:


  • replied
    I'm still not able to get the victim's current weapon. Could this be happening because the weapon is thrown upon death? How do I disable this?

    Leave a comment:


  • replied
    Victim.Weapon? Contains the current weapon of the pawn. Perhaps it still exists there.

    Leave a comment:


  • replied
    Thanks for the tip. It is mostly working now, however, it doesn't work for the gun they are holding at the time of death. I believe this is because the weapons gets thrown/dropped when they die. Is there anyway to disable this to make this work for that gun too?

    Leave a comment:


  • replied
    Code:
    function processKill(Pawn Killer, Pawn Victim)
    {
        local Inventory Inv, newWeapon;
    
        // Boost killers properties on kill
        Killer.Health = 199;
        Killer.AddShieldStrength(250);
    
        // Give victims weapons to killer
        for(Inv = Victim.Inventory; Inv != None; Inv = Inv.Inventory)
        {
            if(Weapon(Inv)!= None)
            {
                newWeapon = Spawn(Inv.Class);
                if (newWeapon != None) {
                      Log("----- Relinquishing weapon "$ Weapon(Inv) $" to: "$ Killer.PlayerReplicationInfo.PlayerName $ "...");
                      newWeapon.GiveTo(Killer);
                      newWeapon.MaxOutAmmo();
    
                }
            }
        }
    
        // Max out ammo on killers weapons
        //for(Inv = Killer.Inventory; Inv != None; Inv = Inv.Inventory)
        //{
        //        if (Inv!=None)
        //              if(Weapon(Inv)!= None) Weapon(Inv).MaxOutAmmo();
        //}
    }
    Inventory items once owned by a pawn can only be destroyed,, so you need to spawn a new inventory of the same.


    You could modify this for better gameplay, say like check to see if the killer has the weapon first then take the ammo amount and add it to the killers weapon, instead of maxing out ammo, unless that's what you want.

    Leave a comment:


  • replied
    I am extending the xDeathMatch in this class. Here is the full code I'm using for the kill process:

    Code:
    // Some killing action going on...
    function Killed(Controller Killer, Controller Killed, Pawn KilledPawn, class<DamageType> damageType)
    {
        processKill(Killer.Pawn, Killed.Pawn);
        super.Killed(Killer, Killed, KilledPawn, damageType);
    }
    
    
    // Process a kill 
    function processKill(Pawn Killer, Pawn Victim)
    {
        local Inventory Inv;
    
        // Boost killers properties on kill
        Killer.Health = 199;
        Killer.AddShieldStrength(250);
    
        // Give victims weapons to killer
        for(Inv = Victim.Inventory; Inv != None; Inv = Inv.Inventory)
        {
            if(Weapon(Inv)!= None)
            {
                Log("----- Relinquishing weapon to: " $ Killer.PlayerReplicationInfo.PlayerName $ "...");
                if(Inv != None) Inv.GiveTo(Killer);
            }
        }
    
        // Max out ammo on killers weapons
        for(Inv = Killer.Inventory; Inv != None; Inv = Inv.Inventory)
        {
            if(Weapon(Inv)!= None) Weapon(Inv).MaxOutAmmo();
        }
    }
    Shouldn't the victims inventory still be intact at this stage?

    Leave a comment:


  • replied
    I'm not sure where inventory is destroyed in the chain of someone dying, but you may be trying to look through the victim's inventory too late.

    Leave a comment:

Working...
X