Difference between revisions of "Scripting Tutorial: Modify Weapon On Equip"
Jump to navigation
Jump to search
Scripting Tutorial: Modify Weapon On Equip (edit)
Revision as of 06:23, 24 April 2010
, 06:23, 24 April 2010no edit summary
imported>Demolishun (New page: == Modify Weapon On Equip == This article covers modifying a weapon when equipped. After searching many websites including this one I decided to write an article on what I learned about ...) |
imported>Demolishun |
||
|
The next step I took was trying to get onEquip to "Cast" an enchantment that did exactly what I wanted. However, like before I ran into it just won't work from onEquip syndrome. The next thing I tried was adding an object to the players inventory (a ring) that had the spell. This created a whole bunch of issues and still didn't work. I even tried calling EquipItem2 but that crashed Oblivion. What to do...
Finally I figured it out. Don't try to do much of anything inside onEquip! Don't daisy chain calls, spells, etc. Set a flag and let another script service the flag/event. What would be able to do that? A quest script can. So, here is some basic code to show you what I mean
== Part 1: OnEquip Method ==
OnEquip method for object script sets event flag in quest.
<pre>
begin OnEquip Player
Set WOLEvents.EvEquipWOL to 1 ; Set event flag
end
</pre>
== Part 2: Event Flag ==
Event flag detected in quest.
<pre>
if (EvEquipWOL) ; Detecting event flag
PrintC "Cloning weapon"
set Weapon to Player.GetEquippedObject 16 ; Get the equipped weapon base type.
Call WOLCloneWeapon Weapon ; OBSE 18 Function call. Reduces code in scripts.
set EvEquipWOL to 0 ; Event flag reset
endif
</pre>
| |||