Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Gameplay.CustomPlayerLoadout


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
//
// class: CustomPlayerLoadout
//
// 
//
class CustomPlayerLoadout extends Loadout
	native
	transient;

var config class<CombatRole>	combatRoleClass;
var config string				userSkinPath;
var config string				loadoutName;

struct native SkinPreferenceMapping
{
	var config Mesh		mesh;
	var config string	skin;
};

var config Array<SkinPreferenceMapping>	skinPreferences;

// isValid
// returns false if the given loadout is invalid for a character
//
// this version always returns true if the armorClass is valid 
// because the armor is held in the loadout and thus should be ok
//
function bool isValid(Character c, Armor a)
{
	if(combatRoleClass.default.armorClass != None)
		return true;
	else
		return super.isValid(c, a);
}

// equip
// gives the equipment in the loadout to the player
function bool equip(Character c)
{
	local bool equipped;
	local Mesh mesh;
	local Jetpack jetpack;
	local Mesh armsMesh;

	if(combatRoleClass != None)
	{
		c.combatRole = combatRoleClass;
		if(combatRoleClass.default.armorClass != None)
		{
			c.armorClass = combatRoleClass.default.armorClass;

			combatRoleClass.default.armorClass.static.equip(c);

			// set mesh from TeamInfo
			mesh = c.team().getMeshForRole(c.combatRole, c.bIsFemale);
			if(mesh != None)
				c.LinkMesh(mesh);
			else
				log("MultiplayerGameInfo: No mesh defined for combat role "$c.combatRole$", team "$c.team()$", bIsFemale "$c.bIsFemale);

			// set jetpack mesh for TeamInfo
			jetpack = c.team().getJetpackForRole(c, c.combatRole, c.bIsFemale);
			if (jetpack != None)
				c.setJetpack(jetpack);

			armsMesh = c.team().getArmsMeshForRole(c.combatRole);
			if (armsMesh != None)
				c.setArmsMesh(armsMesh);
		}
	}

	equipped = super.equip(c);
	if (equipped)
	{
		c.tribesReplicationInfo.userSkinName = userSkinPath;
	}

	return equipped;
}

// skin helper functions

static function SetSkinPreference(out Array<SkinPreferenceMapping> skinPreferences, Mesh mesh, String skinPath)
{
	local int i;

	for(i = 0; i < skinPreferences.Length; ++i)
	{
		if(mesh == skinPreferences[i].mesh)
		{
			skinPreferences[i].skin = skinPath;
			return;
		}
	}

	skinPreferences.Length = skinPreferences.Length + 1;
	skinPreferences[skinPreferences.Length - 1].mesh = mesh;
	skinPreferences[skinPreferences.Length - 1].skin = skinPath;
}

static function String GetSkinPreference(Array<SkinPreferenceMapping> skinPreferences, Mesh mesh)
{
	local int i;

	for(i = 0; i < skinPreferences.Length; ++i)
	{
		if(mesh == skinPreferences[i].mesh)
			return skinPreferences[i].skin;
	}

	return "";
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ne 5.9.2004 15:53:14.000 - Creation time: st 23.5.2018 00:10:43.011 - Created with UnCodeX