Tryin to update this but don't currently have a way to test it, was hoping some of the gurus here would give it an eye over and tell me if they see a problem. I feel it should be tight, but it will be a while yet fore I can test it. The premise is that a module with subrace ips applied to the PC skin can use this to apply ips from a helm to the pc skin. The function definitions and notes should be helpfull in explaining what does what.
[nwscript]
#include "x2_inc_itemprop"
#include "x2_inc_switches"
const int DEBUG = 0;
//Constants
///////////////////////////////////////////////////////////////////////////////
//the following const is a Bioware Default Pot Helm ResRef
//it is used to determine if the PC has enough space in their inventory
//to hold the helm that will be moved from their head to their inventory
const string HCHECK = "nw_arhe001";
//the following const is a Bioware Default "skin" ResRef
//it is used to insure the PC has enough room in their inventory to hold
//the skin that will be spawned in their inventory, it is a badger skin
const string SCHECK = "x2_ac_bdgr001";
//the following string is used to warn a PC there is not enough room in
//their inventory to reapply the skin stored in the database
//this process prevents the PC from winding up with 'skins' in their invo
const string SKIN_DENY = "You do not have room to have the proper skin applied. Speak with after clearing some inventory space.";
//the following string is used to warn a PC there is not enough room in their
//inventory to hold the helm they have equipped it also prevents them from
//activating the system and having the helm fall to the ground
const string HELM_DENY = "You do not have enough room in your inventory to hold the helm you have equipped. Please clear some room in your inventory and try again.";
//ProtoTypes
///////////////////////////////////////////////////////////////////////////////
//void HelmClientEnter(object oPC)
//This function should be the last thing called by the oncliententer script
//of a module. This function checks a db int if the int is set to 1 it will
//reequip a stored buffed skin to the PC. This skin was stored after the player
//activated the helm widget, and the ips were added to it.
void HelmClientEnter(object oPC);
//void HelmRetrieveSkin(object oPC);
//This function will replace a players skin that was stored after the widget
//activation, but before the ips were applied from the helmet. IE: a player with
//subrace ips on their skin activates the widget, a copy of their skin as is is
//stored, this fuction reapplyes that stored skin. This function would be used
//in the modules OnPlayerEquip handle, so that when they equip a helm the unbuffed
//skin will be reapplied.
void HelmRetrieveSkin(object oPC);
//void HelmPropAdd(itemproperty iHelm, object oSkin)
//This function adds matching ips costtable values
//then applys the itemproperty as a property to the pc skin
//iHelm...the itemproperty we are using as a refrence
//oSkin...the object the ip will be applied to
void HelmPropAdd(itemproperty iHelm, object oSkin);
//void HelmPropSubtract(itemproperty iHelm, object oSkin)
//this function subtracts opposing ip type, matching subtype, costtable
//values, and assigns either an ip with a bonus/decrease.
//iHelm...the ip we are comparing to the skin
//oSkin...the pcskin used to compare the iHelm property too.
void HelmPropSubtract(itemproperty iHelm, object oSkin);
//int HelmPropChk(int nType)
//Simply check the integer type of the itemproperty if it is one of the following
//ability bonus
//immuninty damage type
//damage vulnerability
//decreased ability
//decreased skill
//save increase
//save vs specific increase
//save decrease
//save vs specific decrease
//skill bonus
//It return a 1 if the type is one of those 0 if it isn't
int HelmPropChk(int nType);
//void HelmPropApply(object oHelm)
//This function does the heavy lifting in the system, storing skins, ints,
//and setting up the ip transferral.
void HelmPropApply(object oHelm);
//int HelmGetSkinHasOpposing(object oSkin, itemproperty iHelm)
//This is a comparison of the object oSkin with the itemproperty
//iHelm. Returns a 1 if the skin has an opposing type, but mathing subtyp
//of itempropety. IE: abilitybonus, str / abilitydecrease, str
int HelmGetSkinHasOpposing(object oSkin, itemproperty iHelm);
//int HelmGetAreOpposing(int nType, int nSType)
//Returns a 1 if the two integers would be considered opposing ip types
//IE: AbilityBonus vs AbilityDecrease
int HelmGetAreOpposing(int nType, int nSType);
//int HelmGetHelmSpace(object oPC);
//this function will return TRUE or FALSE
//TRUE...indicates there is space for the helm in the PC inventory
//FALSE...indicates there is NOT space in the PC inventory
int HelmGetHelmSpace(object oPC);
//int HelmGetSkinSpace(object oPC);
//this function returns TRUE or FALSE
//TRUE...indicates there is space in the PC inventory to hold the skin
//FALSE..indicates there is NOT space to hold the skin
int HelmGetSkinSpace(object oPC);
//void HelmDMBuffFixSkin(object oPC, object oDM = OBJECT_SELF);
//this function can be used as part of an item activation widget for DMs
//target a PC who has been instructed to seek a DMs help with this system
//after assuring that the PC has cleard room for the skin to be in their
//inventory, the room is needed just for the moment that the skin will
//be in the PCs inventory, it will be equipped to the skin slot by this
//system. This is only to reapply a buffed skin, IE: the PC activated
//the sys widget to apply ips from a helm to their subrace skin
void HelmDMFixBuffSkin(object oPC, object oDM = OBJECT_SELF);
//void HelmDMFixSubraceSkin(object oPC, object oDM = OBJECT_SELF);
//this function can be used in an item activation script to allow
//DM to target a PC and reapply their pre_buff subrace skin, it the PC
//has one stored.
void HelmDMFixSubraceSkin(object oPC, object oDM = OBJECT_SELF);
//Function Definitions
//////////////////////////////////////////////////////////////////////////////
//void HelmDMFixSubraceSkin(object oPC, object oDM = OBJECT_SELF)
/////////////////////////////////////////////////////////////////
void HelmDMFixSubraceSkin(object oPC, object oDM = OBJECT_SELF)
{
int nSknSpc = HelmGetSkinSpace(oPC);
object oSkin;
if(nSknSpc == FALSE)
{//there is NOT room in the PC inventory for the skin item
SendMessageToPC(oDM, "This character, "+GetName(oPC)+", does not have room in their inventory that is required.");
SendMessageToPC(oPC, SKIN_DENY);
return;
}
oSkin = RetrieveCampaignObject(GetName(oPC)+GetPCPublicCDKey(oPC)+"CLNHELM", "PC_SKIN",
GetLocation(oPC), oPC, oPC);//retrieve the skin stored before the ips were applied
DestroyObject(GetItemInSlot(17, oPC));//destroy the skin object already equipped
AssignCommand(oPC, ClearAllActions(TRUE));
AssignCommand(oPC, ActionEquipItem( oSkin,17));
SendMessageToPC(oPC, "You'r subrace skin should be applied.");
SendMessageToPC(oDM, "The PCs' subrace skin should be applied.");
}
//void HelmDMFixBuffSkin(object oPC, object oDM = OBJECT_SELF)
/////////////////////////////////
void HelmDMFixBuffSkin(object oPC, object oDM = OBJECT_SELF)
{
int nSkin = GetCampaignInt(GetName(oPC)+GetPCPublicCDKey(oPC)+"POSTHELM", "HELMSET", oPC);
int nSknSpc = HelmGetSkinSpace(oPC);
if(nSkin == 0)
{//db marks this PC as NOT having a skin stored so stop here
SendMessageToPC(oDM, "This character, "+GetName(oPC)+", does not have a skin in storage.");
return;
}
if(nSknSpc == FALSE)
{//there is NOT room in the PC inventory for the skin item
SendMessageToPC(oDM, "This character, "+GetName(oPC)+", does not have room in their inventory that is required.");
SendMessageToPC(oPC, SKIN_DENY);
return;
}
DestroyObject(GetItemInSlot(17, oPC));//destroy the currently equipped skin
AssignCommand(oPC, ClearAllActions(TRUE));
AssignCommand(oPC, ActionEquipItem( RetrieveCampaignObject(GetName(oPC)+GetPCPublicCDKey(oPC)+"POSTHELM",
"PC_BUFFSKIN", GetLocation(oPC), oPC, oPC),17));//retrieve and equip buffed skin
SendMessageToPC(oPC, "You'r buffed skin should be applied.");
SendMessageToPC(oDM, "The PCs' buffed skin should be applied.");
}
//int HelmGetSkinSpace(object oPC)
//////////////////////////////////////////////////////////////////////////////
int HelmGetSkinSpace(object oPC)
{
string sCheck = "SKIN_SPC_CHK";
object oChkr = CreateItemOnObject(SCHECK, oPC, 1, sCheck);
object o1 = GetFirstItemInInventory(oPC);
int nReturn = FALSE;
string sTag;
while(GetIsObjectValid(o1))
{
sTag = GetTag(o1);
if(sTag == sCheck)
{
DestroyObject(o1);
return TRUE;
}
o1 = GetNextItemInInventory(oPC);
}
DestroyObject(oChkr);
return nReturn;
}
//int HelmGetHelmSpace(object oPC)
//////////////////////////////////////////////////////////////////////////////
int HelmGetHelmSpace(object oPC)
{
string sCheck = "HELM_SPC_CHK";
object oChkr = CreateItemOnObject(HCHECK, oPC, 1, sCheck);
object o1 = GetFirstItemInInventory(oPC);
int nReturn = FALSE;
string sTag;
while(GetIsObjectValid(o1))
{
sTag = GetTag(o1);
if(sTag == sCheck)
{
DestroyObject(o1);
return TRUE;
}
o1 = GetNextItemInInventory(oPC);
}
DestroyObject(oChkr);
return nReturn;
}
//void HelmClientEnter(object oPC)
//////////////////////////////////////////////////////////////////////////////
void HelmClientEnter(object oPC)
{
int nCheck = GetCampaignInt(GetName(oPC)+GetPCPublicCDKey(oPC)+"POSTHELM", "HELMSET", oPC);
location lP = GetLocation(oPC);
object oSkin = GetItemInSlot(17, oPC);
object oHelmSkin, oSChk;
int nChk = HelmGetSkinSpace(oPC);
if(nCheck == 0)return;//no db set so dont need to add skin to PC
if(nChk == FALSE)
{//there is NOT enough room in the PC inventory for the skin object
SendMessageToPC(oPC, SKIN_DENY);//send message
DelayCommand(5.0, SendMessageToPC(oPC, SKIN_DENY));//send it again
return;
}
oHelmSkin = RetrieveCampaignObject(GetName(oPC)+GetPCPublicCDKey(oPC)+"POSTHELM",
"PC_BUFFSKIN", lP, oPC, oPC);//call up the buffed skin stored for this PC
DestroyObject(oSkin);//destroy the default/subrace skin
AssignCommand(oPC, ActionEquipItem(oHelmSkin, 17));//equip the new "buffed" skin
}
//int HelmGetAreOpposing(int nType, int nSType)
//////////////////////////////////////////////////////////////////////////////
int HelmGetAreOpposing(int nType, int nSType)
{
int nReturn = 0;
switch(nType)
{
case 0://ability bonus
if(nSType == 27) nReturn = 1;
break;
case 20://immuninty damage type
if(nSType == 24) nReturn = 1;
break;
case 24://damage vulnerability
if(nSType == 20) nReturn = 1;
break;
case 27://decreased ability
if(nSType == 0) nReturn = 1;
break;
case 29://decreased skill
if(nSType == 52) nReturn = 1;
break;
case 40://save increase
if(nSType == 49) nReturn = 1;
break;
case 41://save vs specific increase
if(nSType == 50) nReturn = 1;
break;
case 49://save decrease
if(nSType == 40) nReturn = 1;
break;
case 50://save vs specific decrease
if(nSType == 41) nReturn = 1;
break;
case 52://skill bonus
if(nSType == 29) nReturn = 1;
break;
}
return nReturn;
}
//int HelmGetSkinHasOpposing(object oSkin, itemproperty iHelm)
////////////////////////////////////////////////////////////////////////////////
int HelmGetSkinHasOpposing(object oSkin, itemproperty iHelm)
{
int nType = GetItemPropertyType(iHelm);
int nSub = GetItemPropertySubType(iHelm);
itemproperty iTemp;
int nReturn = 0;
switch(nType)
{
case 0://ability bonus
iTemp = ItemPropertyDecreaseAbility(nSub, 1);
if(IPGetItemHasProperty(oSkin, iTemp, 2)) nReturn = 1;
break;
case 20://immuninty damage type
iTemp = ItemPropertyDamageVulnerability(nSub, 1);
if(IPGetItemHasProperty(oSkin, iTemp, 2)) nReturn = 1;
break;
case 24://damage vulnerability
iTemp = ItemPropertyDamageImmunity(nSub, 1);
if(IPGetItemHasProperty(oSkin, iTemp, 2)) nReturn = 1;
break;
case 27://decreased ability
iTemp = ItemPropertyAbilityBonus(nSub, 1);
if(IPGetItemHasProperty(oSkin, iTemp, 2)) nReturn = 1;
break;
case 29://decreased skill
iTemp = ItemPropertySkillBonus(nSub, 1);
if(IPGetItemHasProperty(oSkin, iTemp, 2)) nReturn = 1;
break;
case 40://save increase
iTemp = ItemPropertyReducedSavingThrow(nSub, 1);
if(IPGetItemHasProperty(oSkin, iTemp, 2)) nReturn = 1;
break;
case 41://save vs specific increase
iTemp = ItemPropertyReducedSavingThrowVsX(nSub, 1);
if(IPGetItemHasProperty(oSkin, iTemp, 2)) nReturn = 1;
break;
case 49://save decrease
iTemp = ItemPropertyBonusSavingThrow(nSub, 1);
if(IPGetItemHasProperty(oSkin, iTemp, 2)) nReturn = 1;
break;
case 50://save vs specific decrease
iTemp = ItemPropertyBonusSavingThrowVsX(nSub, 1);
if(IPGetItemHasProperty(oSkin, iTemp, 2)) nReturn = 1;
break;
case 52://skill bonus
iTemp = ItemPropertyDecreaseSkill(nSub, 1);
if(IPGetItemHasProperty(oSkin, iTemp, 2)) nReturn = 1;
break;
}
return nReturn;
}
//void HelmRetrieveSkin(object oPC)
//////////////////////////////////////////////////////////////////////////////
void HelmRetrieveSkin(object oPC)
{
location lP = GetLocation(oPC);
object oInven = GetFirstItemInInventory(oPC);
object oPrevious;
object oWid = GetItemPossessedBy(oPC, "cln_helmoff");
object oHelm = GetItemInSlot(0, oPC);
int nHelmChk = GetLocalInt(oHelm, "HELMSET");
int nOther = GetLocalInt(oWid, "SPELLSET");
int nSkin = GetCampaignInt(GetName(oPC)+GetPCPublicCDKey(oPC)+"CLNHELM", "HELMSET", oPC);
int nCheck;
object oHolder;
while(GetIsObjectValid(oInven))
{//loop through invo lookin for helm with integer set on it
nCheck = GetLocalInt(oInven, "HELMSET");
if(nCheck == 1)
{//found helm
oHolder = oInven;
}
oInven = GetNextItemInInventory(oPC);
}
if(nSkin == 1)
{//db shows that ips have been added from a helm to the skin
if(HelmGetSkinSpace(oPC) == FALSE)
{//there is NOT enough room to hold the skin item
SendMessageToPC(oPC, SKIN_DENY);
DelayCommand(5.0, SendMessageToPC(oPC, SKIN_DENY));
return;
}
else
{//there IS enough room in the inventory for the skin
oPrevious = RetrieveCampaignObject(GetName(oPC)+GetPCPublicCDKey(oPC)+"CLNHELM",
"PC_SKIN", lP, oPC, oPC);
DestroyObject(GetItemInSlot(17, oPC), 0.0);
AssignCommand(oPC, ActionEquipItem(oPrevious, 17));
DestroyCampaignDatabase(GetName(oPC)+GetPCPublicCDKey(oPC)+"CLNHELM");
DestroyCampaignDatabase(GetName(oPC)+GetPCPublicCDKey(oPC)+"POSTHELM");
}
}
if(nOther == 1)
{//if spells have been added to the widget
DestroyObject(oWid, 0.1);
RetrieveCampaignObject(GetName(oPC)+GetPCPublicCDKey(oPC)+"CLNHELM",
"PC_WIDGET", lP, oPC, oPC);
}
if(GetIsObjectValid(oHelm))
{//they may have put back on the helm they wore when the previously activated the sys
if(nHelmChk == 1)
{//they did put back on the helm used in the previous activation
SetLocalInt(oHelm, "HELMSET", 0);
SetPlotFlag(oHelm, FALSE);
SetStolenFlag(oHelm, FALSE);
SetItemCursedFlag(oHelm, FALSE);
}
}
SetPlotFlag(oHolder, FALSE);
SetStolenFlag(oHolder, FALSE);
SetItemCursedFlag(oHolder, FALSE);
}
//void HelmPropAdd(itemproperty iHelm, object oSkin)
//////////////////////////////////////////////////////////////////////////////
void HelmPropAdd(itemproperty iHelm, object oSkin)
{
int nType = GetItemPropertyType(iHelm);
int nSub = GetItemPropertySubType(iHelm);
itemproperty iSkin = GetFirstItemProperty(oSkin);
int nSType, nSSub, nAdd;
itemproperty iTemp;
while(GetIsItemPropertyValid(iSkin))
{
nSType = GetItemPropertyType(iSkin);
nSSub = GetItemPropertySubType(iSkin);
if(nType == nSType && nSub == nSSub)
{
nAdd = GetItemPropertyCostTableValue(iHelm)+GetItemPropertyCostTableValue(
iSkin);
}
iSkin = GetNextItemProperty(oSkin);
}
switch(nType)
{
case 0://ability bonus
iTemp = ItemPropertyAbilityBonus(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
break;
case 20://immuninty damage type
iTemp = ItemPropertyDamageImmunity(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
break;
case 24://damage vulnerability
iTemp = ItemPropertyDamageVulnerability(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
break;
case 27://decreased ability
iTemp = ItemPropertyDecreaseAbility(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
break;
case 29://decreased skill
iTemp = ItemPropertyDecreaseSkill(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
break;
case 40://save increase
iTemp = ItemPropertyBonusSavingThrow(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
break;
case 41://save vs specific increase
iTemp = ItemPropertyBonusSavingThrowVsX(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
break;
case 49://save decrease
iTemp = ItemPropertyReducedSavingThrow(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
break;
case 50://save vs specific decrease
iTemp = ItemPropertyReducedSavingThrowVsX(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
break;
case 52://skill bonus
iTemp = ItemPropertySkillBonus(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
break;
}
return;
}
//void HelmPropSubtract(itemproperty iHelm, object oSkin)
////////////////////////////////////////////////////////////////////////////////
void HelmPropSubtract(itemproperty iHelm, object oSkin)
{
int nType = GetItemPropertyType(iHelm);
int nSub = GetItemPropertySubType(iHelm);
int nCost = GetItemPropertyCostTableValue(iHelm);
itemproperty iSkin = GetFirstItemProperty(oSkin);
int nSType, nSSub, nSCost, nAdd;
itemproperty iTemp;
while(GetIsItemPropertyValid(iSkin))
{
nSType = GetItemPropertyType(iSkin);
nSSub = GetItemPropertySubType(iSkin);
nSCost = GetItemPropertyCostTableValue(iSkin);
if(HelmGetAreOpposing(nType, nSType) && nSub == nSSub)
{
if(nCost > nSCost)
{
nAdd = nCost-nSCost;
}
else if(nCost < nSCost)
{
nAdd = nSCost-nCost;
}
else
{
nAdd = 0;
}
}
iSkin = GetNextItemProperty(oSkin);
}
switch(nType)
{
case 0://ability bonus
if(nAdd == 0) return;
if(nCost > nSCost)
{
iTemp = ItemPropertyAbilityBonus(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
else
{
iTemp = ItemPropertyDecreaseAbility(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
break;
case 20://immuninty damage type
if(nAdd == 0) return;
if(nCost > nSCost)
{
iTemp = ItemPropertyDamageImmunity(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
else
{
iTemp = ItemPropertyDamageVulnerability(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
break;
case 24://damage vulnerability
if(nAdd == 0) return;
if(nCost > nSCost)
{
iTemp = ItemPropertyDamageVulnerability(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
else
{
iTemp = ItemPropertyDamageImmunity(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
break;
case 27://decreased ability
if(nAdd == 0) return;
if(nCost > nSCost)
{
iTemp = ItemPropertyDecreaseAbility(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
else
{
iTemp = ItemPropertyAbilityBonus(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
break;
case 29://decreased skill
if(nAdd == 0) return;
if(nCost > nSCost)
{
iTemp = ItemPropertyDecreaseSkill(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
else
{
iTemp = ItemPropertySkillBonus(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
break;
case 40://save increase
if(nAdd == 0) return;
if(nCost > nSCost)
{
iTemp = ItemPropertyBonusSavingThrow(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
else
{
iTemp = ItemPropertyReducedSavingThrow(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
break;
case 41://save vs specific increase
if(nAdd == 0) return;
if(nCost > nSCost)
{
iTemp = ItemPropertyBonusSavingThrowVsX(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
else
{
iTemp = ItemPropertyReducedSavingThrowVsX(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
break;
case 49://save decrease
if(nAdd == 0) return;
if(nCost > nSCost)
{
iTemp = ItemPropertyReducedSavingThrow(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
else
{
iTemp = ItemPropertyBonusSavingThrow(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
break;
case 50://save vs specific decrease
if(nAdd == 0) return;
if(nCost > nSCost)
{
iTemp = ItemPropertyReducedSavingThrowVsX(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
else
{
iTemp = ItemPropertyBonusSavingThrowVsX(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
break;
case 52://skill bonus
if(nAdd == 0) return;
if(nCost > nSCost)
{
iTemp = ItemPropertySkillBonus(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
else
{
iTemp = ItemPropertyDecreaseSkill(nSub, nAdd);
IPSafeAddItemProperty(oSkin, iTemp);
return;
}
break;
}
}
//int HelmPropChk(int nType)
//////////////////////////////////////////////////////////////////////////////
int HelmPropChk(int nType)
{
int nReturn = 0;
switch(nType)
{
case 0://ability bonus
case 20://immuninty damage type
case 24://damage vulnerability
case 27://decreased ability
case 29://decreased skill
case 40://save increase
case 41://save vs specific increase
case 49://save decrease
case 50://save vs specific decrease
case 52://skill bonus
nReturn = 1;
break;
}
return nReturn;
}
//void HelmPropApply(object oHelm)
///////////////////////////////////////////////////////////////////////////////
void HelmPropApply(object oHelm)
{
itemproperty iHelm = GetFirstItemProperty(oHelm);
object oPC = GetItemPossessor(oHelm);
object oSkin = GetItemInSlot(17, oPC);
object oWid = GetItemPossessedBy(oPC, "cln_helmoff");
itemproperty iSkin = GetFirstItemProperty(oSkin);
int nType = GetItemPropertyType(iHelm);
int nSub = GetItemPropertySubType(iHelm);
int nCost = GetItemPropertyCostTableValue(iHelm);
itemproperty iTemp;
int nSType, nSSub, nSCost, nChk, nAdd;
object oSpell;
int nHelmRoom = HelmGetHelmSpace(oPC);
if(nHelmRoom == FALSE)
{//if there is NOT enough room to hold the helm in the inventory stop here
SendMessageToPC(oPC, HELM_DENY);
DelayCommand(5.0, SendMessageToPC(oPC, HELM_DENY));
return;
}
StoreCampaignObject(GetName(oPC)+GetPCPublicCDKey(oPC)+"CLNHELM", "PC_SKIN",
oSkin, oPC);//store the original skin, without the ips added from the helm
StoreCampaignObject(GetName(oPC)+GetPCPublicCDKey(oPC)+"CLNHELM", "PC_WIDGET",
oWid, oPC);//store hte original widget, without the spells added from the helm
while(GetIsItemPropertyValid(iHelm))
{
if(!HelmPropChk(nType))
{//if the ip is NOT one we need to add/subtract to others possibly
IPSafeAddItemProperty(oSkin, iHelm);
if(nType == 15)
{
IPSafeAddItemProperty(oWid, iHelm);
SetLocalInt(oWid, "SPELLSET", 1);
}
iHelm = GetNextItemProperty(oHelm);
}
else
{//if the ip IS one we may need to add/subtract to/from an existing ip on the skin
if(IPGetItemHasProperty(oSkin, iHelm, 2))
{//if the skin already has this specific ip add em IE: both abilitybonus strength
HelmPropAdd(iHelm, oSkin);
iHelm = GetNextItemProperty(oHelm);
}
if(HelmGetSkinHasOpposing(oSkin, iHelm))
{//if the skin has an opposing ip IE: helm ip strength bonus/skin strength reduction
HelmPropSubtract(iHelm, oSkin);
iHelm = GetNextItemProperty(oHelm);
}
else
{//skin has neither matching or opposing ip
IPSafeAddItemProperty(oSkin, iHelm);
iHelm = GetNextItemProperty(oHelm);
}
}
}
SetLocalInt(oHelm, "HELMSET", 1);//mark helm
//the following flags make the helm untradeable/undroppable
SetPlotFlag(oHelm, TRUE);
SetStolenFlag(oHelm, TRUE);
SetItemCursedFlag(oHelm, TRUE);
//the following set the current "buffed" skin out to a db for reapplication
//upon client log in
SetLocalInt(oSkin, "HELMSET", 1);//mark the skin
SetCampaignInt(GetName(oPC)+GetPCPublicCDKey(oPC)+"CLNHELM", "HELMSET", 1, oPC);
StoreCampaignObject(GetName(oPC)+GetPCPublicCDKey(oPC)+"POSTHELM", "PC_BUFFSKIN",
GetItemInSlot(17, oPC), oPC);
SetCampaignInt(GetName(oPC)+GetPCPublicCDKey(oPC)+"POSTHELM", "HELMSET", 1, oPC);
//ExportSingleCharacter(oPC);
}
void main(){}[/nwscript]