Custom character: How to Add

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

braindead

FNG / Fresh Meat
Aug 22, 2009
918
346
0
Merry Ol' England
Marco

I have created a mut using your code and so far all seems ok but here is a daft question, how do I change only one character?

i.e. I don't want all of the players to be stig, only if they choose the character Corporal_Lewis
 

KF-Argentina

FNG / Fresh Meat
Oct 18, 2010
226
57
0
Argentina
Braindead, it's the same as my prior question!

The answer is to copmare the next:
// Other is a Pawn
Other.PlayerReplicationInfo.CharacterName~="Corporal_Lewis

Now that you doubt it's solved, can you tell me if all the clients see the changes of the skins? becouse in my mut (the same as marco without new texture or addpackages things) only the hoster see the skin changes and the clients don't...
 

Faneca

FNG / Fresh Meat
Sep 16, 2010
1,150
778
0
Portugal
Good idea making this "tutorial" of sorts.
Would be nice if someone ported the old characters from the KF Mod.
 

MetalMedved

FNG / Fresh Meat
Feb 22, 2011
144
38
0
Russia
braindead
I'll plan select choosen chars by Harsware ID like in serverperks logic. But firstly it needs alive mutator. Does marco's script work correctly and all chars change to your custom one?

Faneca
You can extract old skins from KillingFloor 2.5 and InfedtedSolders Mutators. If it strongly need I can do it in this thread
 
Last edited:

braindead

FNG / Fresh Meat
Aug 22, 2009
918
346
0
Merry Ol' England
braindead
I'll plan select choosen chars by Harsware ID like in serverperks logic. But firstly it needs alive mutator. Does marco's script work correctly and all chars change to your custom one?

Hey Metal

Sorry for late reply but I can now confirm, Marco's code works perfectly online.
Ran a dedicated server with the mut running and joined on my and gf's pc's and all playable characters changed to the stig. When you send a message, the portrait was even the stig so all works fine!

Going to work on a matching hand skin now.

Braindead, it's the same as my prior question!

The answer is to copmare the next:
// Other is a Pawn
Other.PlayerReplicationInfo.CharacterName~="Corporal_Lewis

Now that you doubt it's solved, can you tell me if all the clients see the changes of the skins? becouse in my mut (the same as marco without new texture or addpackages things) only the hoster see the skin changes and the clients don't...


Sorry KF-Argentina, I never seen this code posted before! thank you, I wil try this later and let you know if only the one character changes.
 

MetalMedved

FNG / Fresh Meat
Feb 22, 2011
144
38
0
Russia
Ok I try to use Marco's code again. If it needs just change skin it works. But I totally can't change mesh!
Then I use in GirlMut
Code:
AddToPackageMap("Trader");
It raises on server start
Code:
Can't load file 'Girl': Can't find file for container 'Girl'
Can't load file 'Trader': Can't find file for container 'Girl'

AddToPackageMap: Invalid package Trader
If I try import mesh in GirlMod via
Code:
#exec OBJ LOAD FILE=Trader.ukx
It raises on player entering
Code:
Can't load file 'Girl': Can't find file for container 'Girl'
Can't load file 'Trader': Can't find file for container 'Girl'
Can't load 'Mesh Trader.TraderP': Can't find file for container 'Girl'

Failed to load player mesh Trader.TraderP
But if I use in GurlMod
Code:
MeshName="KF_Soldier_Trip.ShopKeeper_Trip"
It changes mesh but player moves in initial state on map

It also logs "Can't play AnimSequence..."

So how can i load and apply custom mesh?
 

braindead

FNG / Fresh Meat
Aug 22, 2009
918
346
0
Merry Ol' England
Here is my setup if it helps you at all for the stig character

<root>\KFStigMod\Classes\KFStig.uc

Code:
class KFStig extends PlayerRecordClass;

#exec OBJ LOAD FILE=..\animations\BD_Character_A.ukx
#exec OBJ LOAD FILE=..\textures\BD_Stig_T.utx 

defaultproperties 
{ 
        MeshName="BD_Character_A.stig" 
        BodySkinName="BD_Stig_T.stig.bodyfinal"
        FaceSkinName="BD_Stig_T.stig.headfinal" 
        Portrait=Material'BD_Stig_T.stig.stigport' 
        Ragdoll="British_Soldier1"
        Sex="Male"
        Skeleton="KFSoldiers.Soldier"
        Menu="SP"
        Species=class'KFmod.SoldierSpecies'
        TextName="XPlayers.Default"
        VoiceClassName="KFMod.KFVoicePackTwo"
    
}

<root>\KFStigMut\Classes\KFStigMut.uc

Code:
class KFStigMut extends Mutator;

var array<xPlayer> NewPlayers;

function PreBeginPlay()
{
    // Add all needed packages.
    AddToPackageMap("KFStigMod");
    AddToPackageMap("BD_Stig_T");
    AddToPackageMap("BD_Character_A");
    Class'KFGameType'.Default.AvailableChars[Class'KFGameType'.Default.AvailableChars.Length] = "KFStig";

}
function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
    if( xPlayer(Other)!=None )
    {
        NewPlayers[NewPlayers.Length] = xPlayer(Other);
        SetTimer(0.1,false);
    }
    return true;
}
function Timer()
{
    while( NewPlayers.Length>0 )
    {
        if( NewPlayers[0]!=None && NewPlayers[0].Player!=None )
            NewPlayers[0].SetPawnClass("","KFStig");
        NewPlayers.Remove(0,1);
    }
}

defaultproperties
{
    GroupName="KF_StigMut"
    FriendlyName="Stig Mutator"
    Description="Change Character Skin Forcedly"
     bAddToServerPackages=True
     bAlwaysRelevant=True
}

<root>\System\KillingFloor.ini

Code:
ServerPackages=KFStigMod
ServerPackages=BD_Stig_T
ServerPackages=KFStigMut
 

MetalMedved

FNG / Fresh Meat
Feb 22, 2011
144
38
0
Russia
I just import animation set in ukx and it works!

One more question: how can i get id from server perks? it needs for applying skin for selected chars only
 

braindead

FNG / Fresh Meat
Aug 22, 2009
918
346
0
Merry Ol' England
I just import animation set in ukx and it works!

One more question: how can i get id from server perks? it needs for applying skin for selected chars only

I'll have a look but this isn't my best area, Marco is definitely the best person to help with this.

When you say selected characters, does KF-Argentina's code not help? or do you mean depending on which perk is selected? because that would really be a moot option until the mod is whitelisted as perks will not be available.
 

MetalMedved

FNG / Fresh Meat
Feb 22, 2011
144
38
0
Russia
Argentina speaks about change by skin. As if I select Sg Powers then my skin will change. But I want to change skin independently of selected skin but by ID
 

KF-Argentina

FNG / Fresh Meat
Oct 18, 2010
226
57
0
Argentina
M... try if the hash is the same as the ID you want you can get doing:

// PC is a KFPlayerController, the method returns an string
PC.GetPlayerIDHash()
 

MetalMedved

FNG / Fresh Meat
Feb 22, 2011
144
38
0
Russia
I suppose KFPlayerController is intern class doesn't connect with ServerPerks so they use different ID type. KFPlayerController uses SteamID or smth. It's good idea for white mutator. But I need exactly ServerPerksID. As Marco develop ServerParks he best knows one. So I wait for him. Now I try to look into source code myself)

UPD
Argentina you right! ServPerksID equals PlayerIDHash
Code:
final function StatsObject GetStatsForPlayer( PlayerController PC )
{
	local StatsObject S;
	local string SId;
	local int i;

	if( bNoSavingProgress || Level.Game.bGameEnded )
		return None;
	SId = PC.GetPlayerIDHash();
	for( i=0; i<ActiveStats.Length; ++i )
		if( string(ActiveStats[i].Name)~=SId )
		{
			S = ActiveStats[i];
			break;
		}
	if( S==None )
	{
		S = new(None,SId) Class'StatsObject';
		ActiveStats[ActiveStats.Length] = S;
	}
	S.PlayerName = PC.PlayerReplicationInfo.PlayerName;
	S.PlayerIP = PC.GetPlayerNetworkAddress();
	return S;
}

I try to implement selecting by ID in GirlMut:
Code:
//Add
function bool IsSkinPlayer(Pawn Other, array<Pawn> SkinPlayers)
{
	local int i;
	for(i=0;i<SkinPlayers.Length;i++)
		if (Other == SkinPlayers[i])
			return true;
	return false;
}

//change
function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
	local array<Pawn> SkinPlayers;
	local Controller C;
	
	for (C = Level.ControllerList; C != None; C = C.NextController)
		if (C.Pawn != None && KFHumanPawn(C.Pawn) != None
			&& PlayerController(C).GetPlayerIDHash() == "76561200942501240")
				SkinPlayers[SkinPlayers.Length] = C.Pawn;
				
	if( xPlayer(Other)!=None && IsSkinPlayer(Pawn(Other), SkinPlayers))
    {
        NewPlayers[NewPlayers.Length] = xPlayer(Other);
        SetTimer(0.1,false);
    }
    return true;
}
It doesn't work
 
Last edited:

KF-Argentina

FNG / Fresh Meat
Oct 18, 2010
226
57
0
Argentina
Sorry but is too late herer in argentina (almost 6am) but a "on the fly reading" i can say:

1.
if (Other == SkinPlayers)
return true;


I think you must return false, since the player already is in the array and there isn't necesary to add it again...

2.
function bool IsSkinPlayer(Pawn Other, array<Pawn> SkinPlayers)
{
local int i;
for(i=0;i<SkinPlayers.Length;i++)
if (Other == SkinPlayers)
return true;
return false;
}


A better reading, that is all unnecesary from my point of view, becouse you call settimer right before of adding a new player to the NewPlayers array, then in ssettimer you will assing the playerecodclass and then remove the player from the array, all from one shoot or time... so isn't necesary to implement a double array and an extra function like(IsSkinPlayer) to check the player. In theory you will only have or the actual player to give the skins... or nothing, so the length fo the NewspLayer array will be in the range of 0 to 1

Hope that helps,

I invite you to see the new mutator, you type !girl and a trader skin will be assigned :D: Online Girl Mutator
 

Marco

Active member
May 23, 2009
645
232
43
Finland
<root>\System\KillingFloor.ini

Code:
ServerPackages=KFStigMod
ServerPackages=BD_Stig_T
ServerPackages=KFStigMut
That is not neccesary because "AddToPackageMap" function does exactly that.
I try to implement selecting by ID in GirlMut:
Code:
...
It doesn't work
That code makes no sense whatsoever, try this:
Code:
var config array<string> PlayerIDs;

...

function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
    if( xPlayer(Other)!=None )
    {
        NewPlayers[NewPlayers.Length] = xPlayer(Other);
        SetTimer(0.1,false);
    }
    return true;
}
function Timer()
{
    while( NewPlayers.Length>0 )
    {
        if( NewPlayers[0]!=None && NewPlayers[0].Player!=None && ShouldSkin(NewPlayers[0].GetPlayerIDHash()) )
            NewPlayers[0].SetPawnClass("","Girl");
        NewPlayers.Remove(0,1);
    }
}
final function bool ShouldSkin( string ID )
{
    local int i;

    for( i=(PlayerIDs.Length-1); i>=0; --i )
        if( PlayerIDs[i]==ID )
            return true;
    return false;
}

defaultproperties
{
    PlayerIDs(0)="76561200942501240"
...
}
You can simply add more PlayerIDs in KillingFloor.ini once you created config entry for it.
 

MetalMedved

FNG / Fresh Meat
Feb 22, 2011
144
38
0
Russia
Cool stuff! All works.
But I can't add PalyerIDs via KillingFloor.ini
I write in KillingFloor.ini
Code:
[GirlMut.GirlMut]
PlayerIDs=76561200942501240 ;debug
And it doesn't work

I also have a situation with 1st person view skin. I haven't find the property through i can set this skin and mesh in PlayerRecordClass.
 
Last edited:

braindead

FNG / Fresh Meat
Aug 22, 2009
918
346
0
Merry Ol' England
Cool stuff! All works.
But I can't add PalyerIDs via KillingFloor.ini
I write in KillingFloor.ini
Code:
[GirlMut.GirlMut]
PlayerIDs=76561200942501240 ;debug
And it doesn't work

I also have a situation with 1st person view skin. I haven't find the property through i can set this skin and mesh in PlayerRecordClass.

When you load the mutator, do you get an advanced option in the mut config screen to add the names? or the mut may have it's own ini to add the list in there

have a dummy line at the end of the list PlayerIds=

(This happens with the customshopmutator)

With the 1st person skin, create a new species type i.e. GirlSpecies extends CivilianSpecies or any other type and then put the sleeve texture in there.

example:

Code:
class GirlSpecies extends CivilianSpecies;

defaultproperties
{
     DetachedArmClass=Class'yourpackage.yourseveredarm'
     DetachedLegClass=Class'yourpackage.yourseveredleg'
     SleeveTexture=Texture'yourpackage.yourtexture'
}
This uc file can be put in the mod or mut folder and then link to this in your girl playerrecordclass file
 
Last edited:

MetalMedved

FNG / Fresh Meat
Feb 22, 2011
144
38
0
Russia
Thanks! I make 1st person skin.
ID through ini file still doesn't work. Marco says that it should write exactly in killingfloor.ini
 

Kowku

FNG / Fresh Meat
Feb 5, 2011
5
0
0
Hi guys.
I need to add two new skins on the server...
I tried to do this in two mutator, but I have nothing to not work


Code:
class FOSTERADD extends Mutator;

var array<xPlayer> NewPlayers;
var config array<string> PlayerIDs;

function PreBeginPlay()
{
    AddToPackageMap("FosterWhiteMod");
    AddToPackageMap("KFCharacters");
    AddToPackageMap("KF_Soldier_Trip");
    class'KFGameType'.default.AvailableChars[Class'KFGameType'.Default.AvailableChars.Length] = "Fostermod";
}
function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
    if( xPlayer(Other)!=None )
    {
        NewPlayers[NewPlayers.Length] = xPlayer(Other);
        SetTimer(0.1,false);
    }
    return true;
}
function Timer()
{
    while( NewPlayers.Length>0 )
    {
        if( NewPlayers[0]!=None && NewPlayers[0].Player!=None ){
                if(NewPlayers[0].PlayerReplicationInfo.CharacterName~="Corporal_Lewis")
                {
                NewPlayers[0].SetPawnClass("","Fostermod");
                }
        }
        NewPlayers.Remove(0,1);
    }
}

defaultproperties
{
     PlayerIDs(0)="76561200057131316"
     bAddToServerPackages=True
     GroupName="FOSTERADD"
     FriendlyName="FOSTERADD"
     Description="FOSTERADD"
     bAlwaysRelevant=True
}
Code:
class KFARGGirlA extends Mutator;

var array<xPlayer> NewPlayers;
var config array<string> PlayerIDs;

function PreBeginPlay()
{
    
    AddToPackageMap("KFARGGirlAAMod");
    AddToPackageMap("KFCharacters");
    AddToPackageMap("KF_Soldier_Trip_T");
    AddToPackageMap("TraderPlayer");
    class'KFGameType'.default.AvailableChars[Class'KFGameType'.Default.AvailableChars.Length] = "KFARGGirlAA";
    
}
function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
    if( xPlayer(Other)!=None )
    {
        NewPlayers[NewPlayers.Length] = xPlayer(Other);
        SetTimer(0.1,false);
    }
    return true;
}
function Timer()
{
    while( NewPlayers.Length>0 )
    {
        if( NewPlayers[0]!=None && NewPlayers[0].Player!=None ){
                if(NewPlayers[0].PlayerReplicationInfo.CharacterName~="Corporal_Lewis")
                {
                NewPlayers[0].SetPawnClass("","KFARGGirlAA");
                }
        }
        if( NewPlayers[1]!=None && NewPlayers[1].Player!=None ){
                if(NewPlayers[1].PlayerReplicationInfo.CharacterName~="Corporal_Lewis")
                {
                NewPlayers[1].SetPawnClass("","KFARGGirlAA");
                }
        }
        if( NewPlayers[2]!=None && NewPlayers[2].Player!=None ){
                if(NewPlayers[2].PlayerReplicationInfo.CharacterName~="Corporal_Lewis")
                {
                NewPlayers[2].SetPawnClass("","KFARGGirlAA");
                }
        }
        NewPlayers.Remove(0,1);
    }
}

defaultproperties
{
     PlayerIDs(0)="76561199309454430"
     PlayerIDs(1)="76561200053416110"
     PlayerIDs(2)="76561201528834970"
     bAddToServerPackages=True
     GroupName="KFARGGirlA"
     FriendlyName="KFARGGirlA"
     Description="Coporal Lewis to Trader :D"
     bAlwaysRelevant=True
}
As they were to combine into one mutator?
PS:I'm sorry for my bad English.
 
Last edited: