Author Topic: Item Property Comparison Function  (Read 458 times)

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Item Property Comparison Function
« on: October 12, 2014, 01:33:24 pm »


               

Hello scripting masters, I was wondering if someone would be up for the task of helping me script an Item Property Removal System....

 


I've tried the suggestion Lightfoot8 gave below, e.g. return io==iProp;  (Didn't work)


 


Here is what I have so far, I believe this is going to require some work, becuase it's removing ALL Properties presently of the same type & subtype for Saving Throws...  Obviously I'm going to have to run checks on CostTableValues to ensure both values are the same, but I don't know how to code this efficiently, because the system is already intense enough...


 


 


int iMatch(object oScan, itemproperty io)

{

 // First read the PC Item's Property & get any Statistics on it...

 int ioType = GetItemPropertyType(io);

 int ioSub = GetItemPropertySubType(io);

 int ioDur = GetItemPropertyDurationType(io);

 int ioTable =  GetItemPropertyCostTable(io);

 int ioVal = GetItemPropertyCostTableValue(io);


 


 itemproperty ip = GetFirstItemProperty(oScan);

 while(GetIsItemPropertyValid(ip))

 {

  if(GetItemPropertyType(ip) == ioType && ioDur != DURATION_TYPE_TEMPORARY)

  {

   if(GetItemPropertySubType(ip) == ioSub)

   {

    return TRUE;

   }

  }


  ip = GetNextItemProperty(oScan);

 }


 return FALSE;

}



               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Item Property Comparison Function
« Reply #1 on: October 12, 2014, 08:42:35 pm »


               

Here's the guts of IPGetItemHasProperty() from x2_inc_itemprop.nss. If it doesn't do what you need, it will at least get you started.

 



if ((GetItemPropertyType(ip) == GetItemPropertyType(ipCompareTo)))
{
     if (GetItemPropertySubType(ip) == GetItemPropertySubType(ipCompareTo) || bIgnoreSubType)
     {
        if (GetItemPropertyDurationType(ip) == nDurationCompare || nDurationCompare == -1)
        {
              return TRUE; // if duration is not ignored and durationtypes are equal, true
        }
    }
}


               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Item Property Comparison Function
« Reply #2 on: October 13, 2014, 12:04:33 am »


               

what is wrong with.   


 


int PropertyIsMatching(itemproperty iProp, itemproperty io)


{


  return iProp == io; 


}



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Item Property Comparison Function
« Reply #3 on: October 13, 2014, 12:59:07 am »


               


what is wrong with.   


 


int PropertyIsMatching(itemproperty iProp, itemproperty io)


{


  return iProp == io; 


}




i believe itemproperties behave as effects, effect eHaste != EffectHaste()


               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Item Property Comparison Function
« Reply #4 on: October 13, 2014, 02:44:04 am »


               

now I remember that argument between us before.   If I remember most of that difference came from the Effect creator and how they where linked.    Iprops should not have a problem with iprop creator.   Of course I am not testing any of this(currently ) .  I was just wondering   if he tried a simple comparison before scripting one. 



               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Item Property Comparison Function
« Reply #5 on: October 13, 2014, 03:04:40 am »


               

OK, update, I've got the main script running, and it's not kicking out Too Many Instruction errors, (Yay!)....


 


I just gotta get the above function in the OP coded & I need some help here, because I don't know which functions need to check for what...