192 lines
5.3 KiB
Plaintext
192 lines
5.3 KiB
Plaintext
////////////////////////////////////////////////////////////////////////////////
|
|
// equip_h - This header contains functions for stripping equipment and equipping
|
|
// the player with team specific equipment.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
struct stEquipment {
|
|
string sArmor;
|
|
string sHelm;
|
|
};
|
|
|
|
|
|
////////////////////////////////////
|
|
// PROTOTYPES
|
|
////////////////////////////////////
|
|
|
|
// FILE: equip_h FUNCTION: GetInitialEquipment()
|
|
// This function will return two resrefs for equipment
|
|
// This is for starting equipment only.
|
|
struct stEquipment GetInitialEquipment(object oPC);
|
|
|
|
|
|
// FILE: equip_h FUNCTION: GetTeamEquipment()
|
|
// This is used for when a PC is respawning to outfit
|
|
// them with the appropriate clothing.
|
|
struct stEquipment GetTeamEquipment(object oPC);
|
|
|
|
// FILE: equip_h FUNCTION: SwapOutEquipment()
|
|
// This function takes the resrefs in stEquipment structure
|
|
// and makes sure the PC has them and they are worn. If a
|
|
// resref is blank it will not swap that equipment
|
|
void SwapOutEquipment(object oPC,struct stEquipment stEquip);
|
|
|
|
|
|
// FILE: equip_h FUNCTION: PurgeExistingEquipment()
|
|
// This function will remove existing equipment to keep the player from
|
|
// using an exploit to get a lot of free equipment.
|
|
void PurgeExistingEquipment(object oPC);
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////
|
|
// FUNCTIONS
|
|
////////////////////////////////////
|
|
|
|
struct stEquipment GetInitialEquipment(object oPC)
|
|
{ // PURPOSE: Return starting equipment
|
|
struct stEquipment stRet;
|
|
string sTeamID=GetLocalString(oPC,"sTeamID");
|
|
int nClass=GetClassByPosition(1,oPC);
|
|
int nGender=GetGender(oPC);
|
|
if (nClass==CLASS_TYPE_BARBARIAN)
|
|
{
|
|
stRet.sArmor=sTeamID+"astl";
|
|
}
|
|
else if (nClass==CLASS_TYPE_BARD)
|
|
{
|
|
stRet.sArmor=sTeamID+"alth";
|
|
}
|
|
else if (nClass==CLASS_TYPE_CLERIC)
|
|
{
|
|
stRet.sArmor=sTeamID+"alth";
|
|
stRet.sHelm=sTeamID+"ahl";
|
|
}
|
|
else if (nClass==CLASS_TYPE_DRUID)
|
|
{
|
|
stRet.sArmor=sTeamID+"alth";
|
|
}
|
|
else if (nClass==CLASS_TYPE_FIGHTER)
|
|
{
|
|
stRet.sArmor=sTeamID+"asc";
|
|
stRet.sHelm=sTeamID+"ahl";
|
|
}
|
|
else if (nClass==CLASS_TYPE_MONK)
|
|
{
|
|
if (nGender==GENDER_MALE)
|
|
{
|
|
stRet.sArmor=sTeamID+"acm";
|
|
}
|
|
else
|
|
{
|
|
stRet.sArmor=sTeamID+"acf";
|
|
}
|
|
}
|
|
else if (nClass==CLASS_TYPE_PALADIN)
|
|
{
|
|
stRet.sArmor=sTeamID+"astl";
|
|
stRet.sHelm=sTeamID+"ahl";
|
|
}
|
|
else if (nClass==CLASS_TYPE_RANGER)
|
|
{
|
|
stRet.sArmor=sTeamID+"alth";
|
|
}
|
|
/* else if (nClass==CLASS_TYPE_ROGUE)
|
|
{
|
|
stRet.sArmor=sTeamID+"alth";
|
|
} */
|
|
else if (nClass==CLASS_TYPE_SORCERER||nClass==CLASS_TYPE_WIZARD)
|
|
{
|
|
stRet.sArmor=sTeamID+"ara";
|
|
}
|
|
else //if (nClass==CLASS_TYPE_ROGUE)
|
|
{
|
|
stRet.sArmor=sTeamID+"alth";
|
|
}
|
|
return stRet;
|
|
} // GetInitialEquipment()
|
|
|
|
struct stEquipment GetTeamEquipment(object oPC)
|
|
{ // PURPOSE: return respawn related equipment
|
|
struct stEquipment stRet;
|
|
string sTeamID=GetLocalString(oPC,"sTeamID");
|
|
int nClass=GetClassByPosition(1,oPC);
|
|
int nGender=GetGender(oPC);
|
|
object oItem;
|
|
if (nClass==CLASS_TYPE_DRUID||nClass==CLASS_TYPE_CLERIC)
|
|
{ // divine
|
|
stRet.sArmor=sTeamID+"ard";
|
|
} // divine
|
|
else if (nClass==CLASS_TYPE_SORCERER||nClass==CLASS_TYPE_WIZARD)
|
|
{ // arcane
|
|
stRet.sArmor=sTeamID+"ara";
|
|
} // arcane
|
|
else
|
|
{ // normal
|
|
if (nGender==GENDER_MALE)
|
|
{
|
|
stRet.sArmor=sTeamID+"acm";
|
|
}
|
|
else
|
|
{
|
|
stRet.sArmor=sTeamID+"acf";
|
|
}
|
|
} // normal
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_HEAD,oPC);
|
|
if (oItem!=OBJECT_INVALID&&GetPlotFlag(oItem)) stRet.sHelm="";
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_CHEST,oPC);
|
|
if (oItem!=OBJECT_INVALID&&GetPlotFlag(oItem)) stRet.sArmor="";
|
|
return stRet;
|
|
} // GetTeamEquipment()
|
|
|
|
|
|
void fnEquipIt(object oItem,int nSlot)
|
|
{ // PURPOSE: Delay support function to make sure PC equips the item
|
|
object oSlot=GetItemInSlot(nSlot,OBJECT_SELF);
|
|
if (oSlot!=oItem)
|
|
{ // equip
|
|
ActionEquipItem(oItem,nSlot);
|
|
DelayCommand(4.0,fnEquipIt(oItem,nSlot));
|
|
} // equip
|
|
} // fnEquipIt()
|
|
|
|
void SwapOutEquipment(object oPC,struct stEquipment stEq)
|
|
{ // PURPOSE: To replace equipment with team specific equipment
|
|
object oExist;
|
|
object oNew;
|
|
if (GetStringLength(stEq.sArmor)>0)
|
|
{ // armor
|
|
oExist=GetItemInSlot(INVENTORY_SLOT_CHEST,oPC);
|
|
if (oExist!=OBJECT_INVALID) DestroyObject(oExist);
|
|
oNew=CreateItemOnObject(stEq.sArmor,oPC);
|
|
AssignCommand(oPC,fnEquipIt(oNew,INVENTORY_SLOT_CHEST));
|
|
} // armor
|
|
if (GetStringLength(stEq.sHelm)>0)
|
|
{ // helmet
|
|
oExist=GetItemInSlot(INVENTORY_SLOT_HEAD,oPC);
|
|
if (oExist!=OBJECT_INVALID) DestroyObject(oExist);
|
|
oNew=CreateItemOnObject(stEq.sHelm,oPC);
|
|
AssignCommand(oPC,fnEquipIt(oNew,INVENTORY_SLOT_HEAD));
|
|
} // helmet
|
|
} // SwapOutEquipment()
|
|
|
|
|
|
void PurgeExistingEquipment(object oPC)
|
|
{ // PURPOSE: Purge extra equipment
|
|
object oItem=GetItemInSlot(INVENTORY_SLOT_HEAD,oPC);
|
|
int nBT;
|
|
if (GetIsObjectValid(oItem)) DestroyObject(oItem);
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_CHEST,oPC);
|
|
if (GetIsObjectValid(oItem)) DestroyObject(oItem);
|
|
oItem=GetFirstItemInInventory(oPC);
|
|
while(GetIsObjectValid(oItem))
|
|
{ // purge
|
|
nBT=GetBaseItemType(oItem);
|
|
if (nBT==BASE_ITEM_ARMOR||nBT==BASE_ITEM_HELMET) DelayCommand(0.1,DestroyObject(oItem));
|
|
oItem=GetNextItemInInventory(oPC);
|
|
} // purge
|
|
} // PurgeExistingEquipment()
|
|
|
|
//void main(){}
|