Jump to content

How to script a forcefield


ozziefire

Recommended Posts

I'm trying to make a forcefield that varies in strength depednding on how much health it has, using the health like a battery level as well, but when I mod DT it changes the overall DT so I actually managed to get a negative DT after taking the armor off. I'm also not sure the head is being protected is there seperate DT for locations? I'm having trouble finding info about this in GECK help, I thought there was a page on it somewhere but haven't been able to find it again Edited by ozziefire
Link to comment
Share on other sites

this should reset the DT to the DT as it was when equipped when you unequip the armor:

*note you can condense this a bit i just set it up the way i did for readability.

 

int initialDTvar
int currentDTvar
int DTdifferenceVAR

begin onequip player
set initialDTvar to player.getAV DamageThreshold
End

begin onunequip player
set currentDTvar to player.getAV DamageThreshold
set DTdifferenceVAR to ( initialDTvar - currentDTvar )
player modAV DamageThreshold DTdifferenceVAR
End

 

BTW

this may not work if anything else modifies the DT while you have it equipped though because as youve realized DT changes, change DT overall as a whole.. so on unequip this will still set it all back to whaterer it was when you equipped it.

 

the best thing to do would be tracking the overall changes to DT that your armor does in a separate variable and then always applying the negative of that number to the player upon unequipping the armor.

 

for example

if when you equipped the armor your dt was 12, and while you had the armor equipped modified your dt by an initial +20 then over time a -5 and -7 and -3 your overall change would be 5 leaving the character with a DT of 17 so to negate the effect caused by the armor apply the negative of the variable that tracked those changes: -5.

 

if you track these changes in a variable, because it only applies to the changes made by your armor, other items that affect DT should be unaffected

Edited by angelwraith
Link to comment
Share on other sites

Another approach to consider may be to have several variants of the item, each with a constant DT. As the health of the item changes, silently drop one item and add another. For example, you could have Shield33, Shield66 and Shield100 items representing the damaged, lightly damaged and undamaged versions. Each would have the same user-visible name. When the health goes below 67, remove the Shield100 item and add a Shield66 item.
Link to comment
Share on other sites

Since you are using NVSE to get the health of the armor (right?)

 

You might as well use SetArmorDT to set it's DT value and avoid modav on the player.

 

SetArmorDT works on the base object, so hopefully the armor is unique.

 

Edit - these are in the header files of the NVSE code:

 

DEFINE_GET_INV(GetArmorDT, GetArmorDamageThreshold, returns the damage threshold of the armor.);
DEFINE_SET_INV_FLOAT(SetArmorDT, SetArmorDamageThreshold, sets the damage threshold of the armor);

Link to comment
Share on other sites

Since you are using NVSE to get the health of the armor (right?)

 

You might as well use SetArmorDT to set it's DT value and avoid modav on the player.

 

SetArmorDT works on the base object, so hopefully the armor is unique.

 

Edit - these are in the header files of the NVSE code:

 

DEFINE_GET_INV(GetArmorDT, GetArmorDamageThreshold, returns the damage threshold of the armor.);
DEFINE_SET_INV_FLOAT(SetArmorDT, SetArmorDamageThreshold, sets the damage threshold of the armor);

Thanks Mate, I hadn't realised NVSE actuall gave me extra script commands will have to check it out further :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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