[request] zeds drop pickups when killed mutator

  • Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

mooarchanox

FNG / Fresh Meat
Aug 19, 2010
188
11
0
i'm thinking about how players can refill their ammo in very long waves (600-800zeds per wave) and i get this idea, so i would like to know that is it doable ...

the idea of this thing is that when players kill zeds, they have a chance to drop some pickups (ammo, guns etc.) and server can config what pickups can be dropped and the drop chances. with this it might give more gameplay aspects like instead of getting everything from trader, get somethings from the zeds ..

i think that this can be done though, something like when a zed is killed runs something to calculate the drop chance if meet then spawn a pickup .. well i don't know, not that expert in coding yet ...

anyone ?
 
Last edited:
  • Like
Reactions: Benjamin

FluX

Grizzled Veteran
Oct 26, 2010
5,395
234
63
www.fluxiserver.co.uk
This has been done but im not sure if it was released to public. I know someone has done this anyway and im tempted of showing him this thread for you and see if he'll allow to give you the mutator.

I also had this problem myself but I made an ammo mutator to counter-act this. Basically the rules are:
if it's wave 6 or higher & 9+ players
then give an ammo box every 10 minutes. This wont make the game too easy and still makes people watch what they shoot at and how much. Basically my custom server is all made for teamwork so my rules are for this too.
 

mooarchanox

FNG / Fresh Meat
Aug 19, 2010
188
11
0
i have been tinkering with the code and now i can spawn a certain pickup after killing zed, but i really have no clue on how to make it random (% chance to drop after killed) and different item each time.

anyone :( ?
 
Last edited:

Benjamin

Grizzled Veteran
May 17, 2009
3,650
635
113
France
i have been tinkering with the code and now i can spawn a certain pickup after killing zed, but i really have no clue on how to make it random (% chance to drop after killed) and different item each time.

anyone :( ?

Use the rand() function for chance:

Code:
if (rand(100) < 20)
	... /// 20% chance of this happening
}
 

mooarchanox

FNG / Fresh Meat
Aug 19, 2010
188
11
0
somehow, the current coding is very mess up (i use the code from clot's day mutator). i modified something to make in spawn ammo pickup instead. the problem is that the spawn is not reliable at all.

so now i'm looking for other way .. to make it spawn right under the killed zeds or may be similar to player dropping a weapon when killed (already try to add function throw on death to each zeds but it is not working since i know just that)

or making a random chance to give player the ammo directly when killing zeds

anyone .. ?
 

FluX

Grizzled Veteran
Oct 26, 2010
5,395
234
63
www.fluxiserver.co.uk
somehow, the current coding is very mess up (i use the code from clot's day mutator). i modified something to make in spawn ammo pickup instead. the problem is that the spawn is not reliable at all.

so now i'm looking for other way .. to make it spawn right under the killed zeds or may be similar to player dropping a weapon when killed (already try to add function throw on death to each zeds but it is not working since i know just that)

or making a random chance to give player the ammo directly when killing zeds

anyone .. ?
The only way to get a real answer is to be honest to experiment it for yourself. Try see the pros and the cons of each and maybe share what you discovered? Only way I could possibly answer that personally.
 

Excalibolg

FNG / Fresh Meat
May 3, 2009
142
27
0
KF-BioticsLab
I'll just drop this here, no warrantys or anything.

CustomKFMonster.uc
Code:
class CustomKFMonster extends KFMonster;

var class<Pickup> Tier1[10];
var class<Pickup> Tier2[13];

function Died(Controller Killer, class<DamageType> damageType, vector HitLocation)
{
    local Pickup Item;
    local float MassModifier;

    super.Died(Killer, damageType, HitLocation);

    /* Mass:
        Clot: 100
        Crawler: 100
        Siren: 100
        Stalker: 100
        Gorefast: 350 
        Husk: 400
        Bloat: 400
        Scrake: 500
        FP: 600
        */
        
    if ( Mass == 100)
        MassModifier = 0.5;
    else if (Mass <= 400 )
        MassModifier = 1;
    else if (Mass <= 500)
        MassModifier = 1.5;
    else if (Mass >= 600)
        MassModifier = 2;
    
    // Armor
    if (Rand(100) <= 3 * MassModifier)
    {
        Item = Spawn(class'KFMod.Vest',,, HitLocation);
        Item.GotoState('Pickup');
    }
    // Tier 3
    else if ( Rand(100) <= 30 * MassModifier )
    {
        Item = Spawn(Tier2[Rand(13)],,, HitLocation);
        Item.GotoState('Pickup');
    }
    // Tier 1
    else if ( Rand(100) <= 40 * MassModifier )
    {
        Item = Spawn(Tier1[Rand(10)],,, HitLocation);
        Item.GotoState('Pickup');
    }
    // Ammo
    else if (Rand(100) <= 60 * MassModifier)
    {
        Item = Spawn(class'KFMod.KFAmmoPickup',,, HitLocation);
        Item.GotoState('Pickup');
    }
}

defaultproperties
{
    Tier1(0)=Class'KFMod.ShotgunPickup'                //Support
    Tier1(1)=Class'KFMod.SinglePickup'                //Sharpshooter
    Tier1(2)=Class'KFMod.DualiesPickup'                //Sharpshooter
    Tier1(3)=Class'KFMod.DeaglePickup'                //Sharpshooter
    Tier1(4)=Class'KFMod.DualDeaglePickup'            //Sharpshooter
    Tier1(5)=Class'KFMod.WinchesterPickup'            //Sharpshooter
    Tier1(6)=Class'KFMod.BullpupPickup'                //Commando
    Tier1(7)=Class'KFMod.MachetePickup'                //Berserker
    Tier1(8)=Class'KFMod.AxePickup'                    //Berserker
    Tier1(9)=Class'KFMod.BoomStickPickup'                //Support
    
    Tier2(0)=Class'KFMod.MP7MPickup'                    //Medic
    Tier2(1)=Class'KFMod.LAWPickup'                    //Support
    Tier2(2)=Class'KFMod.AA12Pickup'                    //Support
    Tier2(3)=Class'KFMod.CrossbowPickup'                //Sharpshooter
    Tier2(4)=Class'KFMod.M14EBRPickup'                //Sharpshooter
    Tier2(5)=Class'KFMod.AK47Pickup'                    //Commando
    Tier2(6)=Class'KFMod.SCARMK17Pickup'                //Commando
    Tier2(7)=Class'KFMod.ChainsawPickup'                //Berserker
    Tier2(8)=Class'KFMod.KatanaPickup'                //Berserker
    Tier2(9)=Class'KFMod.FlameThrowerPickup'            //Firebug
    Tier2(10)=Class'KFMod.PipeBombPickup'                //Demolition
    Tier2(11)=Class'KFMod.M79Pickup'                    //Demolition
    Tier2(12)=Class'KFMod.M32Pickup'                    //Demolition
}

LootingGame.uc
Code:
Class LootingGame extends Mutator;

const NS_NUM_NEW = 2;
var String NSOld[NS_NUM_NEW];
var String NSNew[NS_NUM_NEW];

function PostBeginPlay()
{
    /* This code is taken from NoTraderMut and was original in PreBeginPlay.
           Because of the Destroy(); the event chain was broken and PostBeginPlay was never called.
           I spent about 45 minutes debugging why my specimen weren't getting replaced.
           
           Screw you Tripwire :> */
           
    local ShopVolume S;

    foreach AllActors(Class'ShopVolume',S)
        S.bAlwaysClosed = true;
        
    //Destroy();
    
    SetTimer(5.0, False);
    Super.PostBeginPlay();
}

// Ripped from WTF Mut, cheers for teaching me something new~
function Timer()
{
    local KFGameType KF;
    local byte squad,squadMem,replaceCounter,i,ii;
    local class<KFMonster> MC;
        
    KF = KFGameType(Level.Game);
    if ( KF!=None )
    {    
        //normal squads
        for( squad=0; squad<KF.InitSquads.Length; squad++)
        {
            for( squadMem=0; squadMem < KF.InitSquads[squad].MSquad.Length; squadMem++ )
            {
                for (replaceCounter=0; replaceCounter < NS_NUM_NEW; replaceCounter++)
                {
                    if ( String(KF.InitSquads[squad].MSquad[squadMem]) == NSOld[replaceCounter] )
                    {
                         MC = Class<KFMonster>(DynamicLoadObject(NSNew[replaceCounter],Class'Class'));
                        KF.InitSquads[squad].MSquad[squadMem]=MC;
                    }
                }
            }
        }
    
        //special squads
        for (i=0;i<KF.SpecialSquads.Length;i++)
        {
            for (ii=0; ii<KF.SpecialSquads[i].ZedClass.Length;ii++)
            {
                for (replaceCounter=0; replaceCounter < NS_NUM_NEW; replaceCounter++)
                {
                    if (KF.SpecialSquads[i].ZedClass[ii] == NSOld[replaceCounter] )
                    {
                        KF.SpecialSquads[i].ZedClass[ii]=NSNew[replaceCounter];
                    }
                }
            }
        }
    }
}

function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
    // Remove random ammo and item respawners.
    if ( KFRandomSpawn(Other) != None)
        return false;
        
    // Does not work. Log overflows with errors.
    // Remove ammo respawners
    //if ( KFAmmoPickup(other) != None && KFAmmoPickup(other).RespawnTime > 0)
    //    return false;
    
    return true;
}

defaultproperties
{
    NSOld(0)="KFChar.ZombieClot"
    NSOld(1)="KFChar.ZombieGorefast" 
    NSNew(0)="LootingGame.LootZombieClot"
    NSNew(1)="LootingGame.LootZombieGorefast"
    bAlwaysRelevant=True
    RemoteRole=ROLE_SimulatedProxy
    bAddToServerPackages=True
    GroupName="KF-Loot"
    FriendlyName="KFLooting"
    Description="Scavenge your gear!"
}

LootZombieClot.uc
Code:
class LootZombieClot extends ZombieClot;

function Died(Controller Killer, class<DamageType> damageType, vector HitLocation)
{
    local Pickup Item;
    local int Chance;

    super.Died(Killer, damageType, HitLocation);

    Chance = Rand(100);
    
    
    if (Chance <= 1)
    {
        Item = Spawn(class'KFMod.Vest',,, HitLocation);
        Item.RespawnTime = 0; // Don't respawn this item!
        Item.GotoState('Pickup');
    }
    else if ( Chance <= 41 )
    {
        Item = Spawn(class'KFAmmoPickup',,, HitLocation);
        Item.RespawnTime = 0; // Don't respawn this item!
        Item.GotoState('Pickup');
    }
}

LootZombieGorefast.uc
Code:
class LootZombieGorefast extends ZombieGorefast;

var class<Pickup> PickupClasses[7];

function Died(Controller Killer, class<DamageType> damageType, vector HitLocation)
{
    local Pickup Item;
    local int Chance;

    super.Died(Killer, damageType, HitLocation);

    Chance = Rand(100);
    
    if (Chance <= 5)
    {
        Item = Spawn(class'KFMod.Vest',,, HitLocation);
        Item.RespawnTime = 0; // Don't respawn this item!
        Item.GotoState('Pickup');
    }
    else if (Chance <= 25)
    {
        Item = Spawn(PickupClasses[Rand(7)],,, HitLocation);
        Item.RespawnTime = 0; // Don't respawn this item!
        Item.GotoState('Pickup');
    }
}

defaultproperties
{
     PickupClasses(0)=Class'KFMod.SinglePickup'
     PickupClasses(1)=Class'KFMod.ShotgunPickup'
     PickupClasses(2)=Class'KFMod.BullpupPickup'
     PickupClasses(3)=Class'KFMod.DeaglePickup'
     PickupClasses(4)=Class'KFMod.WinchesterPickup'
     PickupClasses(5)=Class'KFMod.AxePickup'
     PickupClasses(6)=Class'KFMod.MachetePickup'
}

And as a special surprise:

HarryEnfieldClot.uc
Code:
class HarryEnfieldClot extends ZombieClot;

function vector eVect( float x , float y , float z )
{
    local vector v ;
    v.x = x ;
    v.y = y ;
    v.z = z ;
    return v ;
}

function Died(Controller Killer, class<DamageType> damageType, vector HitLocation)
{
    local CashPickup Item;
    local int Chance, i;
    local float TossX;
    local Vector X,Y,Z;
    local Vector TossVel;

    super.Died(Killer, damageType, HitLocation);

    Chance = Rand(100);
    
    for ( i = 0; i < 18; i ++ )
    {
        TossX = i * 20;
        if (Chance >= 0)
        {
            Item = Spawn(class'CashPickup',,, Location + 0.8 * CollisionRadius * X - 0.5 * CollisionRadius * Y);

            if(Item != none)
            {
                GetAxes(Rotation,X,Y,Z);

                TossVel = Vector(GetViewRotation());
                TossVel = TossVel * ((Velocity Dot TossVel) + 500) + eVect(0, TossX, 200);
            
                Item.CashAmount = 10;
                Item.bDroppedCash = true;
                Item.RespawnTime = 0;   // Dropped cash doesnt respawn. For obvious reasons.
                Item.Velocity = TossVel;
                Item.DroppedBy = Controller;
                Item.InitDroppedPickupFor(None);
            }
        }
    }
    
    /*if (Chance <= 1)
    {
        Item = Spawn(class'KFMod.Vest',,, HitLocation);
        Item.GotoState('Pickup');
    }
    else if ( Chance >= 41 )
    {
        Item = Spawn(class'KFAmmoPickup',,, HitLocation);
        Item.GotoState('Pickup');
    }*/
}

I wanted to expand this to a full mutator a while back and mix it with WeaponPerks but in the end I couldn't be arsed to. Feel free to take the code and do w/e you want with it
 

mooarchanox

FNG / Fresh Meat
Aug 19, 2010
188
11
0
thanks, will be looking around with it.

edit: tested the above zeds and it works after some correction, thanks again. the gametype looks interesting will try later ...
 
Last edited: