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:35, 24 April 2010
, 06:35, 24 April 2010no edit summary
imported>Demolishun |
imported>Demolishun |
||
|
endif
</pre>
== Part 3: OBSE 18 Function call ==
This is our OBSE 18 "Function" call to do the dirty work. The handy part of this function is that I use the exact same function in a spell designed to do the same thing. Only change the important code once. Code reuse. I know, sick and wrong.
<pre>
begin Function { Weapon }
set test to IsClonedForm Weapon
if ( test )
PrintC "Already cloned: %i", Weapon
else
set TWeapon to CloneForm Weapon
SetEnchantment WOLWeaponStrike TWeapon
set ClonedWeapon to TWeapon
Player.RemoveItemNS Weapon 1
Player.AddItemNS ClonedWeapon 1
Player.EquipItemNS ClonedWeapon
PrintC "New clone: %i, Old: %i" ClonedWeapon Weapon
set Weapon to ClonedWeapon
endif
SetFunctionValue Weapon
sv_Destruct ctext
end
</pre>
Sweet isn't it?! OBSE 18 is certainly making this a lot easier with the new features.
== Conclusion ==
I sure hope this article saves someone some headache. OBSE is a great tool to do some neat things with Oblivion, but sometimes understanding exactly how to do something helps tremendously. I know it took me quite a while to understand some of the intricacies. The one that really threw me was this:
<pre>
TWeapon.SetEnchantment WOLWeaponStrike
</pre>
==== OR ====
<pre>
SetEnchantment WOLWeaponStrike TWeapon
</pre>
The first one "sort of" works in the onEquip function. It doesn't do what it is supposed to, but it sort of works. But the first one would not work at all in the code I laid out above. The second one is the proper way to do it for an objectID and works well. For what I was doing the second one is what I should have working with. Unfortunately it took a few hours to understand one was a 'refID' and the other was a 'objectID'. Anyway, that is how we learn...
| |||