HoS_PRC8/_mod/_module/nss/lib_h_pccustom.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

271 lines
9.7 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////////
// lib_h_pccustom - Customize your PC include Libray
//------------------------------------------------------------------------------
// By Deva B. Winblood. September, 30th 2008
////////////////////////////////////////////////////////////////////////////////
#include "x3_inc_string"
//////////////////////////////
// PROTOTYPES
//////////////////////////////
// FILE: lib_h_pccustom FILE: GetTeamSkinColors()
// This will return a string as stored on the PC_CUSTOMIZE waypoint
// as sSkin_teamid_race#_gender (MF). This will have valid color numbers
// stored as color/color/color/color
string GetTeamSkinColors(string sTeamID,int nRace,int nGender);
// FILE: lib_h_pccustom FILE: GetTeamHairColors()
// This will return a string as stored on the PC_CUSTOMIZE waypoint
// as sHair_teamid_race#_genger (MF). This will have valid hair colors
// stored as color/color/color/color
string GetTeamHairColors(string sTeamID,int nRace,int nGender);
// FILE: lib_h_pccustom FILE: GetTeamHeadNumbers()
// This will return a string as stored on the PC_CUSTOMIZE waypoint as
// sHead_teamid_race#_gender (MF). This will have valid head numbers stored
// as head/head/head/head
string GetTeamHeadNumbers(string sTeamID,int nRace,int nGender);
// FILE: lib_h_pccustom FILE: StoreCurrentPCAppearance()
// This will store the current PC appearance as the default.
void StoreCurrentPCAppearance(object oPC);
// FILE: lib_h_pccustom FILE: RestorePCAppearance()
// This will restore the PC to any stored appearance stored for this PC.
void RestorePCAppearance(object oPC);
// FILE: lib_h_pccustom FILE: GetIsSkinColorValid()
// This will return TRUE if the PC is using a skin color that is valid for
// the current team, race, and gender.
int GetIsSkinColorValid(object oPC);
// FILE: lib_h_pccustom FILE: GetIsHairColorValid()
// This will return TRUE if the PC is using a hair color that is valid for
// the current team, race, and gender.
int GetIsHairColorValid(object oPC);
// FILE: lib_h_pccustom FILE: GetIsHeadValid()
// This will return TRUE if the PC is using a head that is valid for the current
// team, race, and gender.
int GetIsHeadValid(object oPC);
// FILE: lib_h_pccustom FILE: SetNextSkinColor()
// This will set the next skin color for the PC and will start over at the
// beginning if need be.
void SetNextSkinColor(object oPC);
// FILE: lib_h_pccustom FILE: SetNextHairColor()
// This will set the next hair color for the PC and will start over at the
// beginning if need be.
void SetNextHairColor(object oPC);
// FILE: lib_h_pccustom FILE: SetNextHead()
// This will set the next head for the PC and will start over at the beginning
// if need be.
void SetNextHead(object oPC);
//////////////////////////////
// FUNCTIONS
//////////////////////////////
string GetTeamSkinColors(string sTeamID,int nRace,int nGender)
{ // PURPOSE: Return Skin Color string
object oWP=GetWaypointByTag("PC_CUSTOMIZATION");
string sGender="M";
if (nGender==GENDER_FEMALE) sGender="F";
return GetLocalString(oWP,"sSkin_"+sTeamID+"_"+IntToString(nRace)+"_"+sGender);
} // GetTeamSkinColors()
string GetTeamHairColors(string sTeamID,int nRace,int nGender)
{ // PURPOSE: Return Hair Color string
object oWP=GetWaypointByTag("PC_CUSTOMIZATION");
string sGender="M";
if (nGender==GENDER_FEMALE) sGender="F";
return GetLocalString(oWP,"sHair_"+sTeamID+"_"+IntToString(nRace)+"_"+sGender);
} // GetTeamHairColors()
string GetTeamHeadNumbers(string sTeamID,int nRace,int nGender)
{ // PURPOSE: Return Head Number string
object oWP=GetWaypointByTag("PC_CUSTOMIZATION");
string sGender="M";
if (nGender==GENDER_FEMALE) sGender="F";
return GetLocalString(oWP,"sHead_"+sTeamID+"_"+IntToString(nRace)+"_"+sGender);
} // GetTeamHeadNumbers()
void StoreCurrentPCAppearance(object oPC)
{ // PURPOSE: Store current head and skin colors
int nHead=GetCreatureBodyPart(CREATURE_PART_HEAD,oPC);
int nSkin=GetColor(oPC,COLOR_CHANNEL_SKIN);
int nHair=GetColor(oPC,COLOR_CHANNEL_HAIR);
SetLocalInt(oPC,"nDefaultSkinColor",nSkin);
SetLocalInt(oPC,"nDefaultHairColor",nHair);
SetLocalInt(oPC,"nDefaultHead",nHead);
} // StoreCurrentPCAppearance()
void RestorePCAppearance(object oPC)
{ // PURPOSE: Restore stored default appearance
int nHead=GetLocalInt(oPC,"nDefaultHead");
int nSkin=GetLocalInt(oPC,"nDefaultSkinColor");
int nHair=GetLocalInt(oPC,"nDefaultHairColor");
SetColor(oPC,COLOR_CHANNEL_SKIN,nSkin);
SetColor(oPC,COLOR_CHANNEL_HAIR,nHair);
SetCreatureBodyPart(CREATURE_PART_HEAD,nHead,oPC);
} // RestorePCAppearance()
int GetIsSkinColorValid(object oPC)
{ // PURPOSE: Return TRUE if valid skin color
string sTeamID=GetLocalString(oPC,"sTeamID");
int nColor=GetColor(oPC,COLOR_CHANNEL_SKIN);
int nRace=GetRacialType(oPC);
int nGender=GetGender(oPC);
string sS=GetTeamSkinColors(sTeamID,nRace,nGender);
string sParse=StringParse(sS,"/");
while(GetStringLength(sS)>0)
{ // see if color matches
if (StringToInt(sParse)==nColor) return TRUE;
sS=StringRemoveParsed(sS,sParse,"/");
sParse=StringParse(sS,"/");
} // see if color matches
return FALSE;
} // GetIsSkinColorValid()
int GetIsHairColorValid(object oPC)
{ // PURPOSE: Return TRUE if valid hair color
string sTeamID=GetLocalString(oPC,"sTeamID");
int nColor=GetColor(oPC,COLOR_CHANNEL_HAIR);
int nRace=GetRacialType(oPC);
int nGender=GetGender(oPC);
string sS=GetTeamHairColors(sTeamID,nRace,nGender);
string sParse=StringParse(sS,"/");
while(GetStringLength(sS)>0)
{ // see if color matches
if (StringToInt(sParse)==nColor) return TRUE;
sS=StringRemoveParsed(sS,sParse,"/");
sParse=StringParse(sS,"/");
} // see if color matches
return FALSE;
} // GetIsHairColorValid()
int GetIsHeadValid(object oPC)
{ // PURPOSE: Return TRUE if valid head
string sTeamID=GetLocalString(oPC,"sTeamID");
int nHead=GetCreatureBodyPart(CREATURE_PART_HEAD,oPC);
int nRace=GetRacialType(oPC);
int nGender=GetGender(oPC);
string sS=GetTeamHeadNumbers(sTeamID,nRace,nGender);
string sParse=StringParse(sS,"/");
while(GetStringLength(sS)>0)
{ // see if head matches
if (StringToInt(sParse)==nHead) return TRUE;
sS=StringRemoveParsed(sS,sParse,"/");
sParse=StringParse(sS,"/");
} // see if head matches
return FALSE;
} // GetIsHeadValid()
void SetNextSkinColor(object oPC)
{ // PURPOSE: Get Next Skin Color
string sTeamID=GetLocalString(oPC,"sTeamID");
int nRace=GetRacialType(oPC);
int nGender=GetGender(oPC);
string sColorString=GetLocalString(oPC,"sSkinColorString");
string sParse;
if (GetStringLength(sColorString)>0)
{ // it exists
sParse=StringParse(sColorString,"/");
sColorString=StringRemoveParsed(sColorString,sParse,"/");
if (GetStringLength(sColorString)>0) SetLocalString(oPC,"sSkinColorString",sColorString);
else { DeleteLocalString(oPC,"sSkinColorString"); }
SetColor(oPC,COLOR_CHANNEL_SKIN,StringToInt(sParse));
} // it exists
else
{ // it does not
sColorString=GetTeamSkinColors(sTeamID,nRace,nGender);
sParse=StringParse(sColorString,"/");
sColorString=StringRemoveParsed(sColorString,sParse,"/");
if (GetStringLength(sColorString)>0) SetLocalString(oPC,"sSkinColorString",sColorString);
else { DeleteLocalString(oPC,"sSkinColorString"); }
SetColor(oPC,COLOR_CHANNEL_SKIN,StringToInt(sParse));
} // it does not
} // SetNextSkinColor()
void SetNextHairColor(object oPC)
{ // PURPOSE: Get Next Hair Color
string sTeamID=GetLocalString(oPC,"sTeamID");
int nRace=GetRacialType(oPC);
int nGender=GetGender(oPC);
string sColorString=GetLocalString(oPC,"sHairColorString");
string sParse;
if (GetStringLength(sColorString)>0)
{ // it exists
sParse=StringParse(sColorString,"/");
sColorString=StringRemoveParsed(sColorString,sParse,"/");
if (GetStringLength(sColorString)>0) SetLocalString(oPC,"sHairColorString",sColorString);
else { DeleteLocalString(oPC,"sHairColorString"); }
SetColor(oPC,COLOR_CHANNEL_HAIR,StringToInt(sParse));
} // it exists
else
{ // it does not
sColorString=GetTeamHairColors(sTeamID,nRace,nGender);
sParse=StringParse(sColorString,"/");
sColorString=StringRemoveParsed(sColorString,sParse,"/");
if (GetStringLength(sColorString)>0) SetLocalString(oPC,"sHairColorString",sColorString);
else { DeleteLocalString(oPC,"sHairColorString"); }
SetColor(oPC,COLOR_CHANNEL_HAIR,StringToInt(sParse));
} // it does not
} // SetNextHairColor()
void SetNextHead(object oPC)
{ // PURPOSE: Get Next Head
string sTeamID=GetLocalString(oPC,"sTeamID");
int nRace=GetRacialType(oPC);
int nGender=GetGender(oPC);
string sHead=GetLocalString(oPC,"sHeadString");
string sParse;
if (GetStringLength(sHead)>0)
{ // it exists
sParse=StringParse(sHead,"/");
sHead=StringRemoveParsed(sHead,sParse,"/");
if (GetStringLength(sHead)>0) SetLocalString(oPC,"sHeadString",sHead);
else { DeleteLocalString(oPC,"sHeadString"); }
SetCreatureBodyPart(CREATURE_PART_HEAD,StringToInt(sParse),oPC);
} // it exists
else
{ // it does not
sHead=GetTeamHeadNumbers(sTeamID,nRace,nGender);
sParse=StringParse(sHead,"/");
sHead=StringRemoveParsed(sHead,sParse,"/");
if (GetStringLength(sHead)>0) SetLocalString(oPC,"sHeadString",sHead);
else { DeleteLocalString(oPC,"sHeadString"); }
SetCreatureBodyPart(CREATURE_PART_HEAD,StringToInt(sParse),oPC);
} // it does not
} // SetNextHead()
//void main(){}