Author Topic: I am tryin to update my subrace compatible noshowhelms thing.......  (Read 489 times)

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0


               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]
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
I am tryin to update my subrace compatible noshowhelms thing.......
« Reply #1 on: September 23, 2010, 06:51:59 am »


               Oh, I am updating it so that if there is not enough room in the PC inventory to hold the helm on activation, or skin oncliententer the system will not run so that the helm/skin does not drop to the ground. Thanks for yalls attention.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
I am tryin to update my subrace compatible noshowhelms thing.......
« Reply #2 on: September 23, 2010, 07:01:45 am »


               Just posting it here helped me see where I missed adding "a DM" to one of my constant strings.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
I am tryin to update my subrace compatible noshowhelms thing.......
« Reply #3 on: September 23, 2010, 12:35:20 pm »


               I doubt your system can ever be compatible with various skin systems. In order to be compatible with mine for examply, I would have to be able to somehow recognize its itemproperty from helm, and there is no way yet, only for linux nwnx...':unsure:'
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
I am tryin to update my subrace compatible noshowhelms thing.......
« Reply #4 on: September 23, 2010, 06:58:05 pm »


               Well my subrace compatible noshowhelms system is ment to work with those that place properties on the PC skin. The idea being that a PC already has the ips on the skin in their skin slot that would be there because of their subrace, my system loops thro the ips on the helm, when the widget is activated, and compares the helm ips with the subrace ips on the skin. Before any adding/subtracting is done, the system stores the current "subrace" skin out to a db, then comaprisons are done. If the ips are matching type/subtype we add the costtable values, if matching type, but opposing subtype, we subtract the costtable values. If spells are on the helm, they are copied to the widget so as to remain useable, with the original widget also being stored to a db.

So this system to make it compatible with hopefully various subrace systems actually just crunches the numbers and adds/subtracts ips after all the subrace stuff is done.

Also when the pc activates the widget, the helm they have equipped is unequipped and thereby placed in their inventory. Any helm they may equip after that should cause the "buffed" skin to be destroyed and the stored "normal" subrace skin to be recalled and reequipped, also if there were spells added to the widget, then that spelled up widget is destroyed, and the original one recalled from the db. I was hopeing that would make it compatible with the various sytems.

The databases are destroyed when a helm is equipped, thereby cleaing the helm ips from the skin, so as to reduce db clutter.

I don't quite follow what you mean by your subrace system would have to recognize the helms ips.
Could you expand on that?
               
               

               


                     Modifié par Baragg, 23 septembre 2010 - 06:01 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
I am tryin to update my subrace compatible noshowhelms thing.......
« Reply #5 on: September 23, 2010, 07:19:18 pm »


               Well my system for example re-add sneak attack bonus feat every time you level up (to have it stacked for various custom classes).

So in OnLevelUp (and custom Down and other events...), Im currently removing all itemproperties from skin and then I will re-add them depending on the current levels/classes. But even if I would not removed them all, I would have to remove first or any bonus feat: sneak attack 1-20 (quite bunch of code just for this). If I would do that, and if the player had lets say bonus feat: sneak attack 1d6 on the helm and he would previously used your no-show helm script, after level up process it would be broken anyway.

Anyway just got idea it to work with my system as well... I would just have to remove all itemproperties when any helm was equipped and then call my levelup script. (modified version of course)

But this can't be done from your side, you just can't make it compatible with the way its done on my side now. And if any similar subrace/custom class system (and PRC does) works the same way, you would have to make special version for each such system, if available.
               
               

               


                     Modifié par ShaDoOoW, 23 septembre 2010 - 06:22 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
I am tryin to update my subrace compatible noshowhelms thing.......
« Reply #6 on: September 24, 2010, 01:25:13 pm »


               Interesting, mayhap to work with your system you could do your level up thing then have a bit of code that after all your stuff is done, check the db int and if set to one, loop thro the pc invo, and find the helm marked with the int, then run the helmpropadd func.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
I am tryin to update my subrace compatible noshowhelms thing.......
« Reply #7 on: September 28, 2010, 07:56:34 pm »


               I took your input ShadoOow and added a function to the library script that would be called at the end of a level up script that would reapply the helm ips to the pc skin. I appreciate your feedback on this, I don't play much anymore and the worlds I do play on do not have subraces so leveling up did not occur to me as something that I would need to consider.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
I am tryin to update my subrace compatible noshowhelms thing.......
« Reply #8 on: September 28, 2010, 08:09:12 pm »


               Yea such function will do it, builder just must add it into his scripts. Maybe I will add your script then '<img'>
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
I am tryin to update my subrace compatible noshowhelms thing.......
« Reply #9 on: September 28, 2010, 09:52:56 pm »


               Still fiddling with it and want to get it tested as best I can before I upload the update. Thanks for your input ShadoOow.