Aller au contenu

Photo

Get Value of a Custom Item Property?


  • Veuillez vous connecter pour répondre
11 réponses à ce sujet

#1
Zeke

Zeke
  • Members
  • 46 messages

After tinkering with CEP I saw a new Item property - Use Limitation: Gender.

 

ehEiy3n.jpg

 

It doesn't have or at least I can't find any functionalities implemented, so I started implementing my own. I saw in itempropdef.2da that the ID of the property is 150 and that it is getting its values from gender.2da

 

nahK7eA.jpg

 

The problem is that I can't get what gender is selected (I think it's called subtype?) for it to limit.

 

GetItemPropertyCostTableValue() in the following function always returns 0:

// This scipt is attached on OnPlayerEquipItem

object oItem = GetPCItemLastEquipped();
object oPC   = GetPCItemLastEquippedBy();
itemproperty ipLoop = GetFirstItemProperty(oItem);

while (GetIsItemPropertyValid(ipLoop))
{	
	if  (GetItemPropertyType(ipLoop) == 150 ) // Check to see if the item has UseLimitationGender
		{
			int nCost = GetItemPropertyCostTableValue(ipLoop);
			SendMessageToPC(oPC, IntToString(nCost));
		}

	ipLoop = GetNextItemProperty(oItem);
}

I guess GetItemPropertyCostTableValue() is not the function I have to use?

 

 

Yes, I know all of this can be achieved with a simple variable on the equipment but I want to use the property (it has a text in the game interface).



#2
meaglyn

meaglyn
  • Members
  • 802 messages

You want the subtype. i.e. : GetItemPropertySubType(ipLoop).



#3
Zeke

Zeke
  • Members
  • 46 messages

Ah, sounds so logical. Couldn't find this function in the Lexicon... Thank you, once again!



#4
Zeke

Zeke
  • Members
  • 46 messages

Oh, and now - a bonus question time!

 

Is there OnEquip for henchmen? Because currently, if I make Female-Only Armor, I can equip it on a male henchman.



#5
Proleric

Proleric
  • Members
  • 2 343 messages

No, OnPlayerEquipItem is only for players. You have to prevent the henchman from acquiring the item in OnAcquireItem. This is my custom code for single player:

 

Spoiler

 

Sorry that oPC is a confusing variable name, it ought to be oHenchman or whatever, but I don't have time to edit it this morning!


  • Fester Pot et meaglyn aiment ceci

#6
meaglyn

meaglyn
  • Members
  • 802 messages

@proleric, does that actually work? I've been under the impression that OnAcquireItem and friends also only fire for PCs. 



#7
Proleric

Proleric
  • Members
  • 2 343 messages
Yes, it works. Live code from my Dark Energy module. OnPlayerX events only work for player (the clue is in the name) but OnAcquireItem works for NPCs.

#8
meaglyn

meaglyn
  • Members
  • 802 messages

Interesting!

 

Someone should update some of the lexicon pages then.  Grimlar's Tag based scripting tutorial, for example, clearly says no (at least in the CHM version).  Having read that I had not bothered looking at it closely...  Does it fire when stores acquire items or just creature objects? Chests?

 

I like the ghosting visuals hack. I'm going to crib that one for my cursed item stuff which has that issue :)



#9
meaglyn

meaglyn
  • Members
  • 802 messages

Well cool.  Seems to fire for all creatures. How about activate? I did not think you could make NPCs activate item special powers.   I guess I need to use a bigger grain of salt when looking at the lexicon :)



#10
Proleric

Proleric
  • Members
  • 2 343 messages
I don't know of a way to force a creature to activate an item (unless there is some backdoor using spell functions). If that's correct, then OnActivateItem is player-only.

You could, of course, by-pass the event, by modding the creature AI to execute a similar script if it has the item in inventory and ought to activate it. I do something like that with thieves' tools, for example.

#11
Zeke

Zeke
  • Members
  • 46 messages

Aah, this worked! Nice!

 

What is the purpose of the last line (the conversation one)?

 

And what is that ghosting visuals hack that meaglyn talks about?



#12
Proleric

Proleric
  • Members
  • 2 343 messages
The conversation simply displays custom token 12. Sorry, should have explained that. If you prefer floaty text or a message instead, no problem. I prefer conversation because it's more obvious and has to be cleared by the player once read.

Dummy out the OpenInentiory lines to see the ghosting they prevent.