Scripting QuestionHelp (Getting the armor a target is wearin

Post » Thu May 03, 2012 4:48 pm

Hey everyone. I'm taking a stab at learning Oblivion's scripting language and am working on a mod in which I have to get a reference for an NPC's equipped armor, then use it to compare to the formIDs in a list of custom armors to see which one the NPC is wearing. So far all I've gotten accomplished is becoming frustrated. Here's a brief example of what I'm trying to use to do this:

ref whoref armorid;get a reference for NPC armor in upper body, lower body,;hand, foot slotset armorid to who.GetEquippedObject 20if armorid.GetIsID "FormIDGoesHere"   ;do somethingendif

From what I understand the GetIsID function should return a 1 if the reference belongs to the base object that the FormID represents. When the script runs in game however, it simply stops at the if statement (I'm assuming I'm using the GetIsID function incorrectly, but it looks valid based on the documentation on the construction set wiki). Can anyone please offer an alternative method or perhaps let me know what I'm doing wrong here? Thanks!
User avatar
carla
 
Posts: 3345
Joined: Wed Aug 23, 2006 8:36 am

Post » Fri May 04, 2012 3:36 am

Wrong forum, you want the TESCS forum here: http://www.gamesas.com/forum/24-construction-set-oblivion/


--Tomlong75210
User avatar
Jason Rice
 
Posts: 3445
Joined: Thu Aug 16, 2007 3:42 pm

Post » Thu May 03, 2012 3:09 pm

Ah ok, thanks!
User avatar
Sylvia Luciani
 
Posts: 3380
Joined: Sun Feb 11, 2007 2:31 am

Post » Thu May 03, 2012 10:57 pm

It may simply be those quotes. The function will be checking to see if the armor is the string, not the object it names. (Strings have ID's too, so the compiler's happy to let you do that).
User avatar
Juan Suarez
 
Posts: 3395
Joined: Sun Nov 25, 2007 4:09 am

Post » Fri May 04, 2012 4:35 am

I believe I tried all three of the following variations on that. I tried using the actual EditorID name, the FormID, and the FormID in quotes. If I remember correctly it wouldn't save the script because it told me the FormID without quotes and the EditorID name were unrecognized.

EDIT: I see your point though. My thought was that it would recognize what I meant to be a FormID as an integer.

EDIT2: Still trying to figure this out. I double checked and taking the quotes off yields nothing. GetIsID doesn't seem to work at all the way it is described in the construction set wiki. I also haven't had any luck with GetIsReference. If anyone has any suggestions I'd REALLY appreciate it at this point, as being able to acquire the kind of armor the target is wearing is critical to the mod =/.
User avatar
Alan Whiston
 
Posts: 3358
Joined: Sun May 06, 2007 4:07 pm

Post » Thu May 03, 2012 10:57 pm

I'm no mod maker/scripter, but perhaps you should try thinking of a mod that does this and take a look inside it. What about any of those armor degrading mods...The ones that break characters' armor after a certain number of hits.


--Tomlong75210
User avatar
Sabrina Schwarz
 
Posts: 3538
Joined: Fri Jul 14, 2006 10:02 am

Post » Thu May 03, 2012 4:44 pm

set armorid to who.GetEquippedObject 20if armorid == EditorIDGoesHere   ;do somethingendif
GetEquippedObject returns a base item. GetIsID and GetIsReference actually cannot work there, since you can't get a reference to an item in an inventory.
You can, but you'll have much to learn first, little grasshopper...
User avatar
Facebook me
 
Posts: 3442
Joined: Wed Nov 08, 2006 8:05 am

Post » Thu May 03, 2012 11:00 pm

Posted this over at your Nexus topic to the same question, but can't hurt to repeat it here:

As long as the item the NPC is wearing and you're checking for is from this same mod, you can use EditorID fine. EditorIDs from other plugins you just read up or something won't work. That's where FormID comes into play. However, as FormID is depending on the plugin's place in load order (1st two digits is hex for place in load order), this way using hardcoded FormIDs from other plugins will also hardcode the script to the one single load order and none else will work. In this case I think those fancy OBSE functions along the line of GetFormFromMod or what it's called come in handy. Though I haven't got around to use them myself, yet.

And I discourage usage of "GetEquippedObject 20" (20 for upper, lower, hand and foot slot combined) to this matter, as it will only return correct results as long as the item worn covers all 4 slots at once, no more and no less. Items not covering those 4 slots but some less, like only cuirass or robes, or even more slots than these will return a value I couldn't yet decipher the meaning of. It is not the EditorID/FormID of the item worn and it is not "0" (empty slot). "GetEquippedObject 20" doesn't help in identifying different "types" of armor at the same time, only those actually occupying all 4 slots at once.

Whereas "GetEquipmentSlotMask 4" (4 for upperbody) will return the EditorID/FormID of every item worn which "at least" occupies the upperbody slot. Works reliably with cuirasses, robes, fullbody armors and any arbitrary combination of slots as long as upperbody is occupied by it. This even covers slot-combinations impossible for "GetEquippedObject", as it covers all there can be. So that's my personal preference at any time.
User avatar
Nice one
 
Posts: 3473
Joined: Thu Jun 21, 2007 5:30 am


Return to IV - Oblivion