Generic GetShield?

Post » Sat Jul 30, 2011 8:48 pm

I know you must get this all the time but I was wondering if someone can help me with a particular function I was trying to find. I am trying to improve my scripting ability by trying to imitate spells from warhammer fantasy battle into Oblivion. I think I almost perfected a spell that will summon a custom bound item. I made the spell, weapon (wFlamingswordofrhuin type: BladeOneHand), and enchantment that I wanted. The spell calls a script that adds a the weapon to the casters inventory. The weapon has a script attached to it and I am trying to get it to do the following things: first when the weapon is added, it will equip the sword; second when the sword is equipped, it will give the user a strength bonus of 30, and if the user has a blade of less than 86 it will set the user's blade to 85; third if the user attempts to cast a spell, it will unequip the flaming sword; fourth if the flaming sword is unequipped, the user will lose the bonus of 30 strength, the user's blade skill will be reset, and the sword will be removed from the inventory; finally what I am struggling with is I want the user to be unable to use a shield while this sword is equipped and if the user attempts to equip a shield, the sword is unequipped. This is what I have so far for the script on the weapon:

scriptname FlamingSwordofRhuin

ref user
short startingblade

begin OnAdd
_ set user to GetContainer
_ if user.IsShieldOut == 1
_ _ ???
_ endif
_ user.EquipItem wFlamingswordofrhuin
end

begin OnEquip
_ ModActorValue Strength 30
_ set startingblade to user.GetActorValue Blade
_ if user.GetBaseActorValue Blade < 86
_ _ user.SetActorValue Blade 85
_ endif
end

begin GameMode
_ if user.IsCasting == 1
_ _ user.UnequipItem wFlamingswordofrhuin
_ endif
_ if user.IsShieldOut == 1
_ _user.UnequipItem wFlamingswordofrhuin
_ endif
end

begin OnUnequip
_ ModActorValue Strength -30
_ user.SetActorValue Blade startingblade
_ user.RemoveItem wFlamingswordofrhuin, 1
_ return
end

*the underscores represent spaces for readability as multiple spaces don't seem to appear on the forum. And sorry I haven't added any comments yet but it is simple enough I think.

So a few questions here. Is there a function I can use at the question marks to get the shield reference of the user? So then I potentially add a new ref variable called "shield" and insert the following at the question marks:

set shield to user."GetShield"
user.UnequipItem shield

Also I have read that using the blocktype GameMode is evil and will slow down frame rate on slow computers. I don't have a slow computer but I want to learn how to script as efficiently as possible and was wondering if there is a work around that I don't know about.

Sorry if this is too much information, if I am not using the right coding words, or if this is really obvious. I hope I am able to convey want I am trying to convey so if anything is unclear I will try to put it better. I am open to any general criticism of the script as well. Thank you for your time.

edit: noticed a typo
User avatar
Louise
 
Posts: 3407
Joined: Wed Nov 01, 2006 1:06 pm

Return to IV - Oblivion