Jump to content

Using ShowMessage with variables from NVSE functions


jabubu

Recommended Posts

The idea was to have a message window that displays the statistics of your equipped weapon with the ShowMessage function and format specifiers. I had no problem displaying variables that were set by vanilla functions (such as GetActorValue), but when I try doing the same thing with NVSE functions (such as GetWeaponCritChance ) to get the weapon data, the variables return values of zero.

 

The Message Window is triggered by an object script which deletes the token object it belongs to. The trigger for the token spawning is a hotkey when in the inventory, but I've tried different triggers in case it was related to something there, but the results were always the same.

 

scn 0WMToken3

ref weapon

short wDAM ;damage
float wCC ;critical change
short wCD ; critical damage
short wAP
short wROF

short xint

Begin OnAdd player


set weapon to player.GetEquippedObject 5

set wDAM to weapon.GetDamage
set wCD to weapon.GetCritDam 
set wCC to weapon.GetCritPerc
set wAP to weapon.GetAP
set wROF to weapon.GetFireRate
set xint to player.getav Intelligence
	
showmessage 0WMWeaponMenuX wDAM wCD wCC wAP wROF xInt

RemoveMe

End

 

The player.getav intelligence is there just to show it works for other functions (as can be seen in the screenshot )

 

 

 

Am I doing something wrong? Is there a way around the problem?

 

Appreciate any help.

Edited by jabubu
Link to comment
Share on other sites

Try

set weapon to player.GetEquippedObject 5

set weapon to gbo weapon

 

Getitemvalues always work on the 'base' form of an object (ie: you can't change your 9mm pistols stats without changing every 9mm pistol in the game using NVSE

 

According to the FOSE documentation GetEquippedObject already returns the base object of the item. Calling gbo on a base object stops the script, and this is what happened when I added the gbo line; the message window never appears.

 

 

I don't think taking values from base objects should be an issue, since this mod would merely display whatever stats a weapon has without any editing.

Edited by jabubu
Link to comment
Share on other sites

'weapon' is not a reference, yet you are calling the functions as if it were. You need to use the base format for calling the functions on 'weapon'.

 

set wAP to GetWeaponActionPoints weapon

Link to comment
Share on other sites

'weapon' is not a reference, yet you are calling the functions as if it were. You need to use the base format for calling the functions on 'weapon'.

 

set wAP to GetWeaponActionPoints weapon

 

Ahhh, so thats what thats about...

NVSE documentation explains very little.

Link to comment
Share on other sites

So I got the mod mostly working as intended. A window pops up showing the statistics of your equipped weapon after hitting the hotkey.

 

Here's it working properly

http://i.imgur.com/p3Rstl.jpg

 

However, on a few weapons I'm consistently getting astronomical numbers for critical damage.

http://i.imgur.com/0cOXal.jpg

 

I see no pattern in this occuring. It's always the same weapons displaying the same values, but it's true of vanilla, DLC and modded on content. Most weapons don't display this weird behavior but some nonetheless do.

 

Here's the pertinent code (I took out the other variables).

 

scn 0WMTokenSimple

ref weapon

float wCD ; critical damage

Begin OnAdd player


set weapon to player.GetEquippedObject 5

if weapon

	set wCD to GetCritDam weapon
			
	showmessage MyMessage wCD 

endif

RemoveMe

end

 

e:MyMessage would consist of just "Critical Damage %.0f" (in screenshots it's actually %12.0f, used for aligning, but I tested both and got the same results).

 

 

I tried writing a code to display an alternative message if a huge crit dam was detected in case I don't find a solution, with the crit dam value replaced with "XX", but then on some weapons other values go haywire.

 

http://i.imgur.com/eJd21l.jpg

 

Any ideas?

Edited by jabubu
Link to comment
Share on other sites

In your original script, you had that as a short. The function returns a float http://fose.silverlock.org/fose_command_doc.html#GetWeaponCritDamage

Not sure if that's the issue - if it were me, I would match up my variable types with the return types of the functions. Also, if you switch a variable in your script from one type to another, you should do a clean save with the mod unticked, or it will create a dirty save issue.

Link to comment
Share on other sites

In your original script, you had that as a short. The function returns a float http://fose.silverlock.org/fose_command_doc.html#GetWeaponCritDamage

Not sure if that's the issue - if it were me, I would match up my variable types with the return types of the functions. Also, if you switch a variable in your script from one type to another, you should do a clean save with the mod unticked, or it will create a dirty save issue.

 

Yeah I noticed I was using the wrong return type and changed it since. Since this was a fresh script (I made a simpler version that only displayed crit dam) with wCD set to float from the beginning, I don't think dirty saves are the issue. Just for certain I did untick the mod, launched NV, exited and launched again with the mod ticked. Same result.

 

You think this is some quirk of NVSE?

 

It's a real bummer. I was really excited when I first got it working.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...