Startup Weapons change?

  • 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/

ro_sauce

FNG / Fresh Meat
Sep 26, 2007
3,134
329
0
bwhgaming.com
hey guys, i know jack schitt about coding, so maybe someone can help me.

how would i make it so that when someone spawns in a certain playerspawn, they will have certain weapons (or none)

ex:
playerstart1 = spawn with knife only, no pistol, no welder, no healing thing
triggeredplayerstart2 = spawn with dualies, knife, healer
triggeredplayerstart3 = spawn with dualies, knife, shotgun, healer welder

(are welder/healer actual pickups? i've notice in the game that it says i already have them, duuh, so can i make it so ppl actually have to find them by placing the weaponspawn of welder/healer?)
 

slavek

Grizzled Veteran
May 4, 2006
3,074
943
113
UnrealEd: Viewport #1
Not sure about the playerspawn thing, But if you make it so players don't spawn with medic syringe or welder(Can be set in map or through mutator), then players should be able to pick them up. I was thinking of this for story maps. Instead of having hordes of zombies (Fel style), you could have less zombies but players would have limited medical assistance.
 
  • Like
Reactions: Olivier

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,459
2,502
0
Canada
I'll see if I can try to make something like this, do you want it so you can config what weapons are given at that spawn?
 

ro_sauce

FNG / Fresh Meat
Sep 26, 2007
3,134
329
0
bwhgaming.com
yeah because i dont want them to start with nothing the next time the spawn (further down the map) but i dont want them spawning with the lvl 6 stuff (perks wont work in my new map because i'm using tons of new code)
mostly i want them to start with just a knife, but on respawn i want them to have a fighting chance.
 

ro_sauce

FNG / Fresh Meat
Sep 26, 2007
3,134
329
0
bwhgaming.com
Not sure about the playerspawn thing, But if you make it so players don't spawn with medic syringe or welder(Can be set in map or through mutator), then players should be able to pick them up. I was thinking of this for story maps. Instead of having hordes of zombies (Fel style), you could have less zombies but players would have limited medical assistance.

how do i set in the map what they spawn with?
i guess i could just have weapon pickups at the next spawn areas, so how do i set what they spawn with without a mutator?
 

slavek

Grizzled Veteran
May 4, 2006
3,074
943
113
UnrealEd: Viewport #1
You can use a KFSPLevelInfo(Think that's the name) to set the players required equipment. Having weapons change on each spawn will require some coding though.
 
  • Like
Reactions: Olivier

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,459
2,502
0
Canada
var() config array<string> WeaponClassNames;
var array<class<weapon> > WeaponClasses;

function PreBeginPlay ()
{
local int i;
local class<weapon> W;
super.PreBeginPlay();
for (i=0;i<WeaponClassNames.length;i++)
{
W = class<weapon>(DynamicLoadObject(WeaponClassNames,class'Class'));
if (W != None)
WeaponClasses[WeaponClasses.length] = W;
}
}
function ModifyPlayer(Pawn Other)
{
local int i;
local byte LP;
local class<weapon> W;
Super.ModifyPlayer(Other);
for (i=0;i<WeaponClasses.length;i++)
{
SpawnWeapon(WeaponClasses, Other);
if (WeaponClasses.default.Priority > LP)
{
LP = WeaponClasses.default.Priority;
KFHumanPawn(Other).RequiredEquipment[0] = string(WeaponClasses);
}
if (KFHumanPawn(Other) != None)
{
SpawnAmmo(WeaponClasses.default.FireModeClass[0].default.AmmoClass, Other);
if (WeaponClasses.default.FireModeClass[0].default.AmmoClass != WeaponClasses.default.FireModeClass[1].default.AmmoClass)
SpawnAmmo(WeaponClasses.default.FireModeClass[1].default.AmmoClass, Other);
}
}
}
function string GetInventoryClassOverride(string InventoryClassName)
{
return Super(Mutator).GetInventoryClassOverride(InventoryClassName);
}
function ItemPickedUp(Pickup Other);
function ItemChange(Pickup Other);
static function SpawnWeapon(class<weapon> newClass, Pawn P)
{
local Weapon newWeapon;
if( (newClass!=None) && P != None && (P.FindInventoryType(newClass)==None) )
{
newWeapon = P.Spawn(newClass,,,P.Location);
if( newWeapon != None )
newWeapon.GiveTo(P);
}
}
static function SpawnAmmo(class<Ammunition> newClass, Pawn P, optional float Multiplier)
{
local Ammunition Ammo;
if (P==None || newClass == None)
return;
Ammo = Ammunition(P.FindInventoryType(newClass));
if(Ammo == None)
{
Ammo = P.Spawn(newClass);
P.AddInventory(Ammo);
}
if(Ammo == None)
return;
if (Multiplier > 0)
Ammo.AddAmmo(Ammo.InitialAmount*Multiplier);
else
Ammo.AddAmmo(Ammo.InitialAmount);
Ammo.GotoState('');
}
function bool CheckReplacement( Actor Other, out byte bSuperRelevant )
{
local int i;
bSuperRelevant = 0;
if (Weapon(Other) != None)
{
for (i=0;i<WeaponClasses.length;i++)
if (WeaponClasses == Other.class)
return true;
return false;
}
else if (KFHumanPawn(Other) != None)
{
KFHumanPawn(Other).RequiredEquipment[0] = "";
KFHumanPawn(Other).RequiredEquipment[1] = "";
return true;
}
else if (WeaponPickup(Other) != None && Other.Owner == None)
{
return false;
}

return Super.CheckReplacement( Other, bSuperRelevant );
}