Shaidon7 Posted February 5, 2011 Share Posted February 5, 2011 I'm having trouble with a small script to run a shader effect on robe when equiped.I manage to make it work ok on the player, but if I add it to a NPC and then make them equip it, the shader don't work. I don't know if is the OnEquip block or the reference that is just not working. Here my current script: ref iUser Begin OnEquip set iUser to GetContainer If iUser.IsActor == 1 iUser.pms effectAtronachFlame endif End Begin OnUnequip iUser.sms effectAtronachFlame End Using on a GameMode block works, but of course, the shader will keep starting on each frame making a mess! :laugh: Link to comment Share on other sites More sharing options...
Hickory Posted February 5, 2011 Share Posted February 5, 2011 OnEquip assumes a reference, so try: Begin OnEquip If IsActor pms effectAtronachFlame endif End Begin OnUnequip sms effectAtronachFlame End Link to comment Share on other sites More sharing options...
Shaidon7 Posted February 6, 2011 Author Share Posted February 6, 2011 (edited) Your script didn't triggered the shader. I had to take away the condition and add the reference "player." before the command to make it work. So I guess that a reference it's necessary. I was trying to make it as an enchantment script, but didn't worked.There was a enchantment to ass shader effect on Shivering Isles, called "SE32CirionsHelmetEnch1". First time I fought that was working, but the enchantment had also Fortify Skills that made the normal glow when equip it. I guess scripts to add effects don't work on enchantments... EDITOK, I guess I just found about the issue, when I was testing another item that works like the sword Dawnfang/Duskfang from Shivering Isles.It's seems that items equiped with a command (EquipItem) don't run the script. At least the block "OnEquip" I haven't tested yet with another.I just added the item that was working on my inventory and used the command, and nothing happened. I guess that NPCs automatic use the command to equip stuff from their inventory... =/ Edited February 6, 2011 by Shaidon7 Link to comment Share on other sites More sharing options...
The_Vyper Posted February 6, 2011 Share Posted February 6, 2011 I've successfully gotten OnEquip to work with NPCs and the Player before. In your original script, the IsActor check is unnecessary since only actors can equip anything. Try Begin OnEquip pms effectAtronachFlame End Begin OnUnEquip sms effectAtronachFlame end Alternately, you could replace the pms/sms effectAtronachFlame lines with AddSpell/RemoveSpell AbAtronachFlameEffect, since that spell will play the desired effect shader. Link to comment Share on other sites More sharing options...
Shaidon7 Posted February 6, 2011 Author Share Posted February 6, 2011 (edited) The_Viper, but was same script of Hickory. That is how my script started, until I figure out that a reference to the command PlayMagicShaderVisuals (pms) was necessary. It is a object script, not magic effect. I know that the condition IsActor was unnecessary. I was playing with conditions to see if I could make it work on NPCs and also to possible avoid the glitch that happens when trying to equip something broken and the OnEquip block run the script without the UnOnEquip block to stop it. Just to make sure, I tried again with your script, and using AddSpell AbAtronachFlameEffect, and PlayMagicEffectVisuals FIDG (that gives a fire damage effect), and none worked. The OnEquip work to trigger the effect on player if you normally equip it, but on NPC does matter how I added the item and let him equip it, or forcing it, don't work. I manage to work with another script that I was working, by adding Flags to a OnAdd block, I might try again on this script. :wink: == EDIT (solved!) == Nothing like a good night of sleep!OK, the solution was right there, but I didn't saw at first because I have trouble with making Flags. Since the effect works on the block GameMode, I just need to add a "DoOnce" style of flag, to make it... well... rund just ONCE! XD So here is a working object script: scn InsertTheNameOfTheScriptHere ref iUser short iDoOnce Begin OnAdd set iUser to GetContainer set iDoOnce to 1 End Begin GameMode If DoOnce == 1 && iMyself.GetEquipped EditorIDofYourEquip iUser.PMS effectAtronachFlame set iDoOnce to 0 endif End Begin OnUnEquip iuser.SMS effectAtronachFlame set iDoOnce to 1 End So, as soon you add the item, the script start running and the Flag "iDoOnce" is set to "on", as the reference that got the item (its necessary) is also set.The GameMode block run contantly, so you need conditions to turn on the effect. The Flag and if the Item was equipped (without this, not matter what equipment you were using, the effect will happen). And of course, the Flag is now set to "off" (iDoOnce == 0).If it's unequipped, the Flag must be set to on again, or else, if you try to equip it again, won't work, since the Flag got set to off for good. I advise of always use an unique name for a Flag, not just "DoOnce", or might mess up with another script that also use the same name for it. This same script works if saved as Magic Effect. The advange is that you can add a name for the effect and save the Object Script slot for another script. :thumbsup: p.s.: something weird happened here, my old script to activate the effect must got stuck somehow on my save, because when I added the effect to a block like GameMode and ScriptEffectUpdate without conditions, the effect started as soon I loaded the save, don't matter if I was using the scripted object on didn't even had set the it to anything. WEIRD! So I deleted the infamous script, good ridance! :laugh: Edited February 6, 2011 by Shaidon7 Link to comment Share on other sites More sharing options...
Recommended Posts