OnEquip Block doen not run

Post » Sat May 15, 2010 7:40 pm

I have a scripted piece of armor that uses an OnEquip block, but the block does not fire when a follower gets the armor via the ShowInventory menu. If I take the equiped armor away using that menu, the OnUnequip block runs, but giving her the armor (and her subsequent equipping of it) does not fire the on equip block. Any suggestion outside of using FOSE commands?

EDIT: I know the script works because if the player equips/unequips the armor, the script fires. I placed a showmessage command in each (OnEquip/OnUnequip) block and a printc just to be sure.
User avatar
jadie kell
 
Posts: 3497
Joined: Sat Jul 29, 2006 3:54 pm

Post » Sun May 16, 2010 1:27 am

Well a small gamemode block should work.
set me to getcontainerIf once == 0 if me.getequipped SomeItem  ;do stuff   set once to 1endifendif

User avatar
Sophie Miller
 
Posts: 3300
Joined: Sun Jun 18, 2006 12:35 am

Post » Sat May 15, 2010 9:26 pm

Thanks for the suggestion.
User avatar
Isabell Hoffmann
 
Posts: 3463
Joined: Wed Apr 18, 2007 11:34 pm

Post » Sun May 16, 2010 1:53 am

Something to be aware of with that approach is that if an actor has multiple instances of the armour in their inventory, one of which is equipped, they will both run their scripts as though they're equipped.

http://geck.gamesas.com/index.php/OnEquip blocks won't run if an object is equipped via http://geck.gamesas.com/index.php/EquipItem, perhaps this is basically the same as that? You could try using an effect script with a http://geck.gamesas.com/index.php/ScriptEffectStart block in an object effect instead of an object script with an http://geck.gamesas.com/index.php/OnEquip block and see if that works.

Cipscis
User avatar
Laura-Lee Gerwing
 
Posts: 3363
Joined: Fri Jan 12, 2007 12:46 am

Post » Sun May 16, 2010 7:57 am

I tried the script effect approach too, but this is a permanent effect and I had trouble getting the scriptEffectUpdate to continue. The wiki indicated that this approach would not work and refered to using two scripts, one of which needed to use an OnEquip Block - which brought me back to the same problem. The script I came up with is posted in http://www.gamesas.com/bgsforums/index.php?showtopic=1076794 and is used to restore health to the wearer upon being damaged while in combat. I know its not perfect, but it does work, the duplicate armor not withstanding. Using FOSE commands could have made it more robust, but that was not an option.

I suppose one could check for the number of the objects in the actor's inventory and divide the restoration amount by that number to account for multiple versions of the script running.
User avatar
Kayla Keizer
 
Posts: 3357
Joined: Tue Dec 12, 2006 4:31 pm

Post » Sun May 16, 2010 12:35 am

Since this is a follower and you can know what they have in their Inventory, why not take advantage of how NPCs always wear the best item they have and avoid the EquipItem all together?
Like maybe a RemoveItem worn_armor, AddItem your_armor_with_onequip_block.. They'll equip it by themselves and the OnEquip block would run fine. I've handed out armor with OnEquip blocks and they DO fire when the NPC auto-wears it for lack of something better to wear, although I usually do that by console->additem xx, script additem xx, or in the geck npc inventory, not the shared inventory dialog.
User avatar
Kristian Perez
 
Posts: 3365
Joined: Thu Aug 23, 2007 3:03 am

Post » Sun May 16, 2010 6:21 am

Since this is a follower and you can know what they have in their Inventory, why not take advantage of how NPCs always wear the best item they have and avoid the EquipItem all together?
Like maybe a RemoveItem worn_armor, AddItem your_armor_with_onequip_block.. They'll equip it by themselves and the OnEquip block would run fine. I've handed out armor with OnEquip blocks and they DO fire when the NPC auto-wears it for lack of something better to wear, although I usually do that by console->additem xx, script additem xx, or in the geck npc inventory, not the shared inventory dialog.

I am actaully trying to get this to work for all actors. The main wearer are the outcasts, and individually, I can script it for a specific group. Its just I wanted it to work under all circumstance including followers. Thanks BD.
User avatar
MatthewJontully
 
Posts: 3517
Joined: Thu Mar 08, 2007 9:33 am

Post » Sat May 15, 2010 5:26 pm

Hmmm ok. Yeah that does kind of change things a bit. Think maybe you can "fool" the NPCs into thinking your armor is better than anything they might have? Like maybe inflating a useless stat on it so they choose yours over what they have? Just a thought...

There's also the idea that if your OnEquip needs to run, it can be placed into an invisible wearable that maps to an unused body or head slot, like earrings, mouth, or whatever. Should be able to tie the 2 together so that when one gets worn the other is added automatically. The theory, and from what I've seen, is that if there's no item already worn in that NPCs slot (and not disallowed by another worn item), an item that fits there will just get equipped on add no matter what.
User avatar
^~LIL B0NE5~^
 
Posts: 3449
Joined: Wed Oct 31, 2007 12:38 pm


Return to Fallout 3