Jump to content

Script commands and weapon health percentages.


CouncilOfDave

Recommended Posts

Hey, working on a few scripting problems with a mod I'm playing with.

 

Basic gist is that I am making some aid items that are weapon mods, so when you activate them the base effect and script switches the weapons in your inventory and equipped weapons.

 

So, say I have a 1911, and a 1911 suppressor. I click on the suppressor in the aid section, it checks what weapon I'm holding, removes it, adds the suppressed weapon, and equips it. I have this part working, and vice versa.

 

However I'm having problems finding the correct function to float a weapon health percentage.

 

Basically, I need it to check the health percentage of the weapon I start with, and apply that to the weapon it substitutes. That way I don't have a weapon at 59% health, only to have it jump to 100% when I put the suppressor on it, and back to 100% when I take the suppressor off.

 

player.GetWeaponHealthPerc, and other variations of it don't compile.

 

I have the latest NVSE, and I've checked every function reference I can. I've been scouring the internet all night, and cannot find an answer.

 

The mod works great, it's just this one function I'm having issues with.

 

Anyone done this? I can't find any examples.

Link to comment
Share on other sites

From what you have described so far, you don't need to use NVSE functions. I've used the vanilla GetWeaponHelthPerc lots of times, in this way. Once you have the health value, you can add an the new item with the same health using the AddItemHealthPercent

http://geck.bethsoft.com/index.php/AddItemHealthPercent

http://geck.bethsoft.com/index.php/GetWeaponHealthPerc

 

 

float fWeaponHealth

set fWeaponHealth to Player.GetWeaponHealthPerc

set fWeaponHealth to fWeaponHealth / 100 ;need to do this for the additem command

Player.AddItemHealthPercent ModdedWeapon 1 fWeaponHealth

 

 

Link to comment
Share on other sites

Okay, it's working beautifully now.

 

Here's what I ended up with: The only thing done differently is the line in bold, and it makes sense now why it wasn't working.

 

I greatly appreciate the help.

 

 

 

scn 1911ExMagAddScript

 

float WeaponHealth

 

begin ScriptEffectStart

 

if player.getequipped 1911Pistol == 1

 

set WeaponHealth to Player.GetWeaponHealthPerc

set WeaponHealth to WeaponHealth / 100

player.removeitem 1911Pistol 1

player.addItemHealthPercent 1911PistolExMag 1 WeaponHealth

player.equipitem 1911PistolExMag

player.additem 1911Mag 1

 

elseif player.getequipped 1911PistolSD == 1

 

set WeaponHealth to Player.GetWeaponHealthPerc

set WeaponHealth to WeaponHealth / 100

player.removeitem 1911PistolSD 1

player.addItemHealthPercent 1911PistolEMSD 1 WeaponHealth

player.equipitem 1911PistolEMSD

player.additem 1911Mag 1

 

else

 

player.additem 1911ExMag 1

 

endif

 

end

Link to comment
Share on other sites

  • Recently Browsing   0 members

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