OBSE weapon stat changes will not take effect

Post » Sat Feb 19, 2011 5:07 am

I discovered that OBSE weapon stat changes like:

SetAttackDamage
SetWeaponSpeed

do not take effect in the game right after the stats have been changed with a weapon that is out
unless the actor first unequips the weapon and then re-equips the weapon.

Same for the player or if they go into the menu the also seems to "bake" the changes.
I can force an unequip then equip on actors (it is not pretty but it works)
but I am not sure if i want to force the player to do that.

Any suggestions?
User avatar
Mizz.Jayy
 
Posts: 3483
Joined: Sat Mar 03, 2007 5:56 pm

Post » Fri Feb 18, 2011 8:41 pm

per the wiki discussion page for SetWeaponDamage I only need to sheath and unsheath the weapons, but this still looks yuky...
User avatar
Auguste Bartholdi
 
Posts: 3521
Joined: Tue Jun 13, 2006 11:20 am

Post » Sat Feb 19, 2011 12:11 pm

Any suggestions?

Just a wild, untested idea, but if you create an http://obse.silverlock.org/obse_command_doc.html#Inventory_Reference to the equipped weapon and call SetAttackDamage (or any similar function) directly on that reference, maybe it will work immediately.

E.g. something like:

ref actorref weaponBaseObjectref weaponRefshort newDamagearray_var intventoryWeaponsarray_var weaponStack...SetAttackDamage newDamage weaponBaseObject  					; Changes the stat for all weapons of type weaponBaseObject, except the equipped one?let intventoryWeapons := actor.GetInvRefsForItem weaponBaseObject		; Creates an array of all stacks of that weapon in the actor's inventoryForEach weaponStack <- intventoryWeapons					; Iterates over the array, and assigns each stack to weaponStack in turn	let weaponRef := *weaponStack						; Sets weaponRef to the inventory reference for one weapon stack	weaponRef.SetAttackDamage newDamage					; Sets damage for each stack in the inventory including the equipped oneLoop

User avatar
Dragonz Dancer
 
Posts: 3441
Joined: Sat Jun 24, 2006 11:01 am

Post » Sat Feb 19, 2011 9:25 am

So TheNiceOne ....you are so !THE MAN!
No one can deny that.

(JUST LET ANYONE EVEN TRY TO!) :toughninja:

:D

But why the extra long code to just use the CreateTempRef idea?
After you pointed out to me the idea to use CreateTempRef I did this:

let TmpRef := CreateTempRef TmpWeaponTmpRef.setWeaponSpeed NewSpeedFloatlet TmpRef := 0 



IT SEEMS TO BE WORKING GREAT!
No more forced playgroup sheath the weapon sillyness.

The way you had done it with the extra array use and loops?

I already have 2 interacting arrays running to first go thru a list of previously adapted weapons and then break from that loop to another that did more work then came back to the first loop...and so on. :banghead:

So putting in another set of loop arrays was intimidating me enough to just stay with the silly playgroup sheath method.
But after reading about CreateTempRef I thought why not try "the easy way".

I am asking because I am worried I may be in ignorance of a good reason to go the "long way" as you suggested. Or maybe I am just missing the point of what you were trying to communicate with the extra array and loop?


Can you explain why you think this temp ref thing works? Why would it not work using the Obj reference?


Just a wild, untested idea, but if you create an http://obse.silverlock.org/obse_command_doc.html#Inventory_Reference to the equipped weapon and call SetAttackDamage (or any similar function) directly on that reference, maybe it will work immediately.

E.g. something like:

ref actorref weaponBaseObjectref weaponRefshort newDamagearray_var intventoryWeaponsarray_var weaponStack...SetAttackDamage newDamage weaponBaseObject  					; Changes the stat for all weapons of type weaponBaseObject, except the equipped one?let intventoryWeapons := actor.GetInvRefsForItem weaponBaseObject		; Creates an array of all stacks of that weapon in the actor's inventoryForEach weaponStack <- intventoryWeapons					; Iterates over the array, and assigns each stack to weaponStack in turn	let weaponRef := *weaponStack						; Sets weaponRef to the inventory reference for one weapon stack	weaponRef.SetAttackDamage newDamage					; Sets damage for each stack in the inventory including the equipped oneLoop


User avatar
GEo LIme
 
Posts: 3304
Joined: Wed Oct 03, 2007 7:18 pm

Post » Sat Feb 19, 2011 4:31 am

Glad that I helped you to find a solution. I have never done anything similar to what you're doing here, but from your explanation of the problem, I had an idea of what might happen in the Oblivion code:

I thought that when the weapon was sheated, its stats was stored in some temporary reference since updating the base Object didn't help. My thinking was that by looping through the inventory stacks of that base Object, one of the stacks would be a reference to the actual single equipped weapon, and changing the stats for that object would change the data stored in the temporary reference. If you for instance want to change the current health of the equipped weapon (and no other weapon of the same type), something like this would be the way to go.

By using CreateTempRef instead, you don't get a reference to the actual equipped weapon, but rather to a temporary weapon of the same type. So logically, doing that would have exactly the same effect as using
setWeaponSpeed NewSpeedFloat TmpWeapon - which didn't work in the first case. So the fact that using CreateTempRef works is a little mystery to me, but it is a mystery why just setting it for the base object, too.
User avatar
how solid
 
Posts: 3434
Joined: Mon Apr 23, 2007 5:27 am

Post » Sat Feb 19, 2011 5:20 am

That all leaves me a bit confused as to whether those two functions affect the base or the instance. After making the change, are all instances of the same weapon affected? The fact that you can't enchant extra "base" - i.e. non-magical - damage or speed makes me think it would do so, as there wouldn't be an instance attribute to hold the change.
User avatar
Nicole M
 
Posts: 3501
Joined: Thu Jun 15, 2006 6:31 am

Post » Sat Feb 19, 2011 11:19 am

That all leaves me a bit confused as to whether those two functions affect the base or the instance. After making the change, are all instances of the same weapon affected? The fact that you can't enchant extra "base" - i.e. non-magical - damage or speed makes me think it would do so, as there wouldn't be an instance attribute to hold the change.

The functions affect the base object.
I can't say for certain without digging into the game executable why the first method requires an unequip/re-equip and the second tempref method doesn't.
Most likely the stats of the currently equipped weapon are cached. We do some internal housekeeping when working with temporary references which may cause that cached info to be refreshed.
This is all just semi-informed speculation until I look at the actual code.
User avatar
Charlotte Buckley
 
Posts: 3532
Joined: Fri Oct 27, 2006 11:29 am


Return to IV - Oblivion

cron