Check for a specific property
#1
Posté 09 septembre 2012 - 02:19
TY in advance
#2
Posté 09 septembre 2012 - 03:03
Try :
if (
GetItemPropertyType(iProp) == ITEM_PROPERTY_LIGHT
&&GetItemPropertyCostTableValue(iProp)== IP_CONST_LIGHTBRIGHTNESS_BRIGHT
&& GetItemPropertyParam1Value(iProp)== IP_CONST_LIGHTCOLOR_WHITE
)
#3
Posté 09 septembre 2012 - 03:42
#4
Posté 09 septembre 2012 - 03:44
Although this does work:
//ffbj
void main()
{
object oPC=GetEnteringObject();
if (!GetIsPC(oPC)) return;
object oItem = GetItemInSlot( INVENTORY_SLOT_LEFTHAND, oPC);
if (
GetItemHasItemProperty(oItem, IP_CONST_LIGHTBRIGHTNESS_BRIGHT)
&& GetItemHasItemProperty(oItem, IP_CONST_LIGHTCOLOR_WHITE)
)
FloatingTextStringOnCreature("Light", oPC,TRUE);
}
Modifié par ffbj, 09 septembre 2012 - 07:46 .
#5
Posté 09 septembre 2012 - 07:41
ffbj wrote...
Removed since it did not work to try and get the visual effect.
Bummer, I was hoping it would.
#6
Posté 09 septembre 2012 - 07:50
(There is a constant int ITEM_PROPERTY_VISUALEFFECT, though I don't think you want or need that in this case. Not sure how that would work. For instance in determing if an item had any visual effect on it, so in that case going from the general to the specific. And a use in a specific case would be to remove a visual effect without affecting the property on the item. There must be something on that in the darkness spells for a better understanding of the various realtionships.
Modifié par ffbj, 09 septembre 2012 - 08:23 .
#7
Posté 09 septembre 2012 - 08:30
#8
Posté 09 septembre 2012 - 10:38
#9
Posté 10 septembre 2012 - 12:44
//ffbj
void main()
{
object oPC=GetEnteringObject();
if (!GetIsPC(oPC)) return;
object oItem = GetItemInSlot( INVENTORY_SLOT_LEFTRING, oPC);
itemproperty iProperty = ItemPropertyLight(IP_CONST_LIGHTBRIGHTNESS_BRIGHT,IP_CONST_LIGHTCOLOR_WHITE);
if
(IPGetItemHasProperty(oItem, iProperty, -1, TRUE))
{
SendMessageToPC(oPC, "Bight White Light");
}
}
Function Description:
IPGetItemHasProperty(object, itemproperty, int, int)
Checks if an item has a matching itemproperty.int IPGetItemHasProperty(
object oItem,
itemproperty ipCompareTo,
int nDurationType,
int bIgnoreSubType = FALSE
);
Parameters
oItem
Item to check for property.
ipCompareTo
ItemProperty to compare to
nDurationType
See description and remarks.
bIgnoreSubType
TRUE to ignore subtype. Otherwise FALSE. (Default: FALSE)
Description
Wrapper for GetItemHasItemProperty that returns true if oItem has an itemproperty that matches ipCompareTo by Type AND DurationType AND SubType
nDurationType = Valid DURATION_TYPE_* or -1 to ignore
bIgnoreSubType - If set to TRUE an item property will be considered identical even if the SubType is different.
Remarks
Only DURATION_TYPE_TEMPORARY, DURATION_TYPE_PERMANENT, and -1 are valid for nDurationType.
This differs from GetItemHasItemProperty in several ways. First of all because it also takes duration type and subtype into account. And also because it uses an itemproperty value for parameter, instead of the ITEM_PROPERTY_* integer constant.
Returns TRUE if oItem has the same type of itemproperty that ipCompareTo is. If nDurationType is different from -1, it also needs to be that same duration type. If bIgnoreSubType is FALSE, it also needs to be of the same subtype.
Returns FALSE if the above isn't mean. It also prints "Not Found" to the log.
Requirements
#include "x2_inc_itemprop"
Modifié par ffbj, 10 septembre 2012 - 12:58 .
#10
Posté 10 septembre 2012 - 01:14
ffbj wrote...
#include "x2_inc_itemprop"
//ffbj
void main()
{
object oPC=GetEnteringObject();
if (!GetIsPC(oPC)) return;
object oItem = GetItemInSlot( INVENTORY_SLOT_LEFTRING, oPC);
itemproperty iProperty = ItemPropertyLight(IP_CONST_LIGHTBRIGHTNESS_BRIGHT,IP_CONST_LIGHTCOLOR_WHITE);
if
(IPGetItemHasProperty(oItem, iProperty, -1, TRUE))
{
SendMessageToPC(oPC, "Bight White Light");
}
}
No good, That function only check PropertyType && ItemPropertySubType.
Light has no sub type. It only has a Pram1 for the color and a CostTablevalue for the brightness.
So that function will return TRUE for any light on the item.
I tested the first code fragment i posted and it works.
#11
Posté 10 septembre 2012 - 01:28
Modifié par ffbj, 10 septembre 2012 - 01:42 .
#12
Posté 10 septembre 2012 - 01:48
{
itemproperty iProp = GetFirstItemProperty (oItem);
while( GetIsItemPropertyValid(iProp))
{
if (
GetItemPropertyType(iProp) == ITEM_PROPERTY_LIGHT
&&GetItemPropertyCostTableValue(iProp)== IP_CONST_LIGHTBRIGHTNESS_BRIGHT
&& GetItemPropertyParam1Value(iProp)== IP_CONST_LIGHTCOLOR_WHITE
) return TRUE;
iProp = GetNextItemProperty (oItem);
}
return FALSE;
}
#13
Posté 10 septembre 2012 - 03:52
Thanks for the instruction.
#14
Posté 10 septembre 2012 - 06:43
ffbj wrote...
Yeah, that's what I figured a while loop. It seems that is the only way since the function that will create an item with those parameters cannot be used to retrieve the said object. That seems odd that the function only works one way.
Thanks for the instruction.
It may have to do with the fact that the prop on the item has a duration Type. The prop created in the script, having never been applyed to an item, having a null entry for the druation and duration type. I have never looked at the comparsion operator of Item Propterys to see what it compairs.
EDIT: If I get a wild hair tomorow, I might just do that. (the wet messy hair on the cat avatar not included)
Modifié par Lightfoot8, 10 septembre 2012 - 06:45 .
#15
Posté 10 septembre 2012 - 10:32
It seems to mirror the thinking with get first effect etc..Earlier... the ip visual effect question, which can only be put on weapons could present a way to get bight white light if it's on a weapon.
.
So that function compares the item property type, and the duration and the subtype, but you can just tell it to ignore the last two properties, if you want. Just conjecturing that that function was implemented originally as a way to curtail certain exploits. The continual light one for instance.





Retour en haut






