Need help with my armorPerk mod.

Post » Sun May 02, 2010 4:26 pm

http://www.newvegasnexus.com/downloads/file.php?id=37383
I have divided the perks into: Science armor (all labcoats and such), Cloth, Light armor, Medium armor, Heavy armor and Power Armor.

Now I want to update the mod to allow other peoples armor mods to be compatible with my perks.
What ive done so far is simply add all the armors in the game to different formlists, then use the GetEquipped function to set the various conditions.
All done in Perk or Ablity menues, almost no scripting necesary.

I did have to script one abilty that affected Followers, so i copied the Ferocious Loyalty perk and used that script to make my own version.


Now im left with something of a conundrum.

If I want to add someone elses armor mod to my perks ill need to either make a compatibility patch of every armor mod in existence and add their armors to my formlists...
This proved problematic as most other mods tends to be ESPs, as is my mod and im not sure how I could make a comp. patch without making changes to files i dont even own.

So i thought of a better solution.

Divide my perks based on DT, and so it doesnt matter what mod the armor comes from its DT rating will determine what Perk applies to it.
However, while the game has a GetArmorRatingUpperBody function, there is nothing that checks for DT.

But NVSE (v1 b5) seems to.
Or rather it has the functions GetEquippedObject and GetArmorDT.

So putting those two together in a script should yield the result I need, but I cant get it to work.

Also the function IsPowerArmor or IsPA should work for the powerarmor perk, but once again I have to admit I dont know enough.

This is my first mod, I made it last weekend, and im just learning as I go.
If any of these functions showed up in the Perk or Ability condition menues id be set, but nothing from NVSE seems to show up there, does NVSE only work for scripts ?


Any help would be appreciated.


-Exo
User avatar
Jennifer Rose
 
Posts: 3432
Joined: Wed Jan 17, 2007 2:54 pm

Post » Sun May 02, 2010 10:15 pm

Here is the script im trying to make work.
So far all it does is add the benefits (the INVIS perks) but never remove them, no matter how much DT the player is wearing.
Even removing all the perks (including the INVIS) and the player still gets the benefits, I dont get it.

Here is the code ive been using.

scn exoClothArmorSCRIPT

ref exoVariableBegin GameModeset exoVariable to Player.GetEquippedObject 2 ; 2 = upperbodyif Player.HasPerk exoClothArmor == 0 ; added this to try to make the script properly remove the perk if the player dont have it.	Player.Removeperk exoClothArmorINVIS1	elseif ( exoVariable.GetArmorDT <= 8 ) ; No idea if this is how its supposed to be done.					Player.AddPerk exoClothArmorINVIS1	endif	elseif ( exoVariable.GetArmorDT >=8 )			Player.RemovePerk exoClothArmorINVIS1	endifendifend



-Exo
User avatar
Yvonne Gruening
 
Posts: 3503
Joined: Mon Apr 23, 2007 7:31 pm

Post » Sun May 02, 2010 4:22 pm

Here is the script im trying to make work.
So far all it does is add the benefits (the INVIS perks) but never remove them, no matter how much DT the player is wearing.
Even removing all the perks (including the INVIS) and the player still gets the benefits, I dont get it.

Here is the code ive been using.

scn exoClothArmorSCRIPT

ref exoVariableBegin GameModeset exoVariable to Player.GetEquippedObject 2 ; 2 = upperbodyif Player.HasPerk exoClothArmor == 0 ; added this to try to make the script properly remove the perk if the player dont have it.	Player.Removeperk exoClothArmorINVIS1	elseif ( exoVariable.GetArmorDT <= 8 ) ; No idea if this is how its supposed to be done.					Player.AddPerk exoClothArmorINVIS1	endif	elseif ( exoVariable.GetArmorDT >=8 )			Player.RemovePerk exoClothArmorINVIS1	endifendifend

-Exo



Okay, I don't understand your conditionals here.

If the player does NOT have the perk exoClothArmor, then you remove the perk ecoClothArmorINVIS1

Otherwise you always add the perk exoClothArmorINVIS1?

your two conditionals getArmorDT <= 8 and then <= 8 combine to form the following mathematical statement: If DT < OR < OR = 8. That will always be true.

secondly you're not removing the same perk you're adding, and you're saying if they don't have the perk exoClothArmor then you remove ExoClothArmorINVIS1. What is exoClothArmor and how is it added? is it meant to be so that you must have it to have the invis1 perk?

I don't quite understand the code here, can you tell me what you're trying to do?
User avatar
Amy Cooper
 
Posts: 3400
Joined: Thu Feb 01, 2007 2:38 am

Post » Sun May 02, 2010 7:01 pm

Okay, I don't understand your conditionals here.

If the player does NOT have the perk exoClothArmor, then you remove the perk ecoClothArmorINVIS1

Otherwise you always add the perk exoClothArmorINVIS1?

your two conditionals getArmorDT <= 8 and then <= 8 combine to form the following mathematical statement: If DT < OR < OR = 8. That will always be true.

secondly you're not removing the same perk you're adding, and you're saying if they don't have the perk exoClothArmor then you remove ExoClothArmorINVIS1. What is exoClothArmor and how is it added? is it meant to be so that you must have it to have the invis1 perk?

I don't quite understand the code here, can you tell me what you're trying to do?


Christ let me try this again, sorry.
Apparently I posted a code I was working with...

Heres is what I started with:

ref exoVariableBegin GameModeset exoVariable to Player.GetEquippedObject 2if ( exoVariable.GetArmorDT <=8 )	Player.AddPerk exoClothArmorINVIS1endifif ( exoVariable.GetArmorDT >=8 )	Player.RemovePerk exoClothArmorINVIS1endifend



Thats what ive been trying to do, im sorry about the other code.
It was something i was testing to see how the script would react.

So exoClothPerk is a perk that points to this script.
While the INVIS perk is an invisible perk added to the player under those conditions, that perk has all the actual benefits.
Thou exoClothPerk is the one the player chooses. (at lvl 8)


-Exo
User avatar
Liv Staff
 
Posts: 3473
Joined: Wed Oct 25, 2006 10:51 pm

Post » Mon May 03, 2010 1:33 am

Ah that's so much clearer.

However it still has the same logic issue. DT <=> 8 will ALWAYS be true.

DT >= 8 is true if DT is 8 or up
DT <= 8 is true if DT is 8 or lower.

That causes two issues.

First, it's bad programming etiquette to have two conditionals in the same case select that could be true at once. In this case if DT == 8 then both elses are true at the same time. In this instance case select's behavior is indeterminate, but it's common practice for either all true conditionals or the first true conditional to be executed depending on the scripting language's implementation.

Second, I'm assuming you're not writing all this out rather than player.removeperk exoClothArmor for fun, you want this case select to change behavior based on the variable, in which case it isn't behaving as intended.

So this is what your code is ACTUALLY doing, in psuedocode

If DT >= 8 remove the perk
If DT <= 8 remove the perk



What is that perk? and when do you WANT it to be applied/removed?
User avatar
Charlotte Lloyd-Jones
 
Posts: 3345
Joined: Fri Jun 30, 2006 4:53 pm

Post » Sun May 02, 2010 10:56 pm

Ah that's so much clearer.

However it still has the same logic issue. DT <=> 8 will ALWAYS be true.

DT >= 8 is true if DT is 8 or up
DT <= 8 is true if DT is 8 or lower.

That causes two issues.

First, it's bad programming etiquette to have two conditionals in the same case select that could be true at once. In this case if DT == 8 then both elses are true at the same time. In this instance case select's behavior is indeterminate, but it's common practice for either all true conditionals or the first true conditional to be executed depending on the scripting language's implementation.

Second, I'm assuming you're not writing all this out rather than player.removeperk exoClothArmor for fun, you want this case select to change behavior based on the variable, in which case it isn't behaving as intended.

So this is what your code is ACTUALLY doing, in psuedocode

If DT >= 8 remove the perk
If DT <= 8 remove the perk



What is that perk? and when do you WANT it to be applied/removed?



Ur absolutely right about the = sign that was dumb.

So obviously the bottom IF statement should only contain a > sign.
So in other words:

exoVariable.GetArmorDT > 8 


So the idea is that when the player puts on an armor with 8 DT or less, he gets the perk.
As soon as he puts on an armor with MORE then 8 DT, the perk is removed.

The Perk that the player chooses at lvl 8 is exoClothArmor all that perk does is point to this Script.
Then I use the perk exoClothArmorINVIS to give all the actuall benefits, but ONLY while the player is wearing cloth armor (designated here as all armor with 8 or less DT)

Do u see what im trying to do ?

-Exo
User avatar
sally R
 
Posts: 3503
Joined: Mon Sep 25, 2006 10:34 pm

Post » Sun May 02, 2010 11:11 pm

In that case the amended (to remove the second = sign and as put in your SECOND post, with addperk and removeperk not double removeperk) should function exactly as you intend.

However, I think a more elegant solution to your problem would be to use a formlist of armor you consider "metallic" or "nonmetallic" depending. That would be a little more logical in any event though it would be more complex.

That's just what I'm doing for a mod for depleted uranium ammo, since I want DPU to behave, as in real life, as a pyrophoric: igniting spontainiously when it hits something hard enough.

As it stands however your amended code seems as if it ought to function as intended.

Just make sure it's executing.
User avatar
Jose ordaz
 
Posts: 3552
Joined: Mon Aug 27, 2007 10:14 pm

Post » Sun May 02, 2010 1:14 pm

In that case the amended (to remove the second = sign and as put in your SECOND post, with addperk and removeperk not double removeperk) should function exactly as you intend.

However, I think a more elegant solution to your problem would be to use a formlist of armor you consider "metallic" or "nonmetallic" depending. That would be a little more logical in any event though it would be more complex.

That's just what I'm doing for a mod for depleted uranium ammo, since I want DPU to behave, as in real life, as a pyrophoric: igniting spontainiously when it hits something hard enough.

As it stands however your amended code seems as if it ought to function as intended.

Just make sure it's executing.


Yes I use formlists in the previous versions.
But adding the armors of other modders to the formlists is something I dont know how to do, so my idea is that as long as the player uses armors from the game it would go by formlists, but as soon as he uses an armor from another mod it would simply be divided by DT.

Here is the non-simplefied code that im using now, thanks to ur help.

scn exoClothArmorSCRIPTref exoVariableBegin GameModeset exoVariable to Player.GetEquippedObject 2 if (( exoVariable.GetArmorDT <= 8 ) || ( Player.GetEquipped exoPerkClothArmor == 1 )) && (( Player.GetEquipped exoPerkLightArmor == 0 ) && ( Player.GetEquipped exoPerkMediumArmor == 0 ) && ( Player.GetEquipped exoPerkHeavyArmor == 0 ) && ( Player.GetEquipped exoPerkPowerArmor == 0 ) && ( Player.GetEquipped exoPerkScienceArmor2 == 0 )) 				Player.AddPerk exoClothArmorINVIS1endifif ( exoVariable.GetArmorDT > 8 ) || ( Player.GetEquipped exoPerkClothArmor == 0 ) || ( Player.GetEquipped exoPerkLightArmor == 1 ) || ( Player.GetEquipped exoPerkMediumArmor == 1 ) || ( Player.GetEquipped exoPerkHeavyArmor == 0 ) || ( Player.GetEquipped exoPerkPowerArmor == 1 ) || ( Player.GetEquipped exoPerkScienceArmor2 == 1 )		Player.RemovePerk exoClothArmorINVIS1endifend


Basically what im trying to say here is this:

If the player is wearing an armor with DT of 8 or less, OR if he is wearing an armor from the cloth formlist, AND this armor is NOT on any of the other formlists.
Add the perk.

But if the player is wearing an armor with more DT then 8, OR one that is NOT in the clothform list, OR is in one of the other formlists.
Remove the perk.


And it doesnt work. :-P

Unlike before when the ability was impossible to be get rid of, it now doesnt work at all, its as if nothing happens.

An extra pair of eyes would be helpful here.


-Exo
User avatar
Lou
 
Posts: 3518
Joined: Wed Aug 23, 2006 6:56 pm

Post » Sun May 02, 2010 9:42 pm

Tried the simpler version now:

scn exoClothArmorSCRIPTref exoVariableBegin GameModeset exoVariable to Player.GetEquippedObject 2 if exoVariable.GetArmorDT <= 8			Player.AddPerk exoClothArmorINVIS1endifif exoVariable.GetArmorDT > 8		Player.RemovePerk exoClothArmorINVIS1endifend


Now I get the opposite result.

The perks work, but they work no matter what armor I wear, no matter the DT.

Its as if the NVSE functions dont work, or dont work as I thought they would.

Do we know GetEquippedObject and GetArmorDT works?


-Exo
User avatar
rheanna bruining
 
Posts: 3415
Joined: Fri Dec 22, 2006 11:00 am

Post » Sun May 02, 2010 6:57 pm

Now im making some headway.

It seems Perks arent the best thing to use in this situation, maybe I should switch to abilites.

In any case, looking at the NON simplefied code I found the error with the Medium armor and switched it from == 1 to == 0.

I tested it out again, and started getting totally random results.

Then I figured it out.


The variable is stored too long, putting on a new armor doesnt reset the variable and the perk keeps working, or not working based on whatever armor I wore last.
Taking the new armor and taking it off, then imidiatly putting it back on makes it work as intended.

But it is still a bug id like to get rid off.
So how can I reset the variable...


-Exo
User avatar
Cameron Wood
 
Posts: 3384
Joined: Wed Oct 31, 2007 3:01 pm

Post » Sun May 02, 2010 4:58 pm

Last note before I go to bed.

Still having the same bug, though I ahve to say I can live with it. The Script will not initialize imidiatly and so will pretend the Player is wearing whatever he wore last.

Switching weapons, any piece of armor, even taking the armor on and off again causes the script to kick in and it works fine.

In the long run thats not a big deal.


Lastly I need to figure out how to use IsPowerArmor in a script, as I cannot differentiate between Heavy armors and power armors based on DT alone since many of them will overlap.

Will this work ?


ref exoVariableBegin GameModeset exoVariable to Player.GetEquippedObject 2If exoVariable IsPowerArmor == 1      Player.Addperk exoPowerArmorendifIf exoVariable IsPowerArmor != 1     Player.Removeperk exoPowerArmorendifend



:snoring: Too tired to think, thanks for all ur help so far, just getting a second pair of eyes makes all the difference.


-Exo
User avatar
Jordan Moreno
 
Posts: 3462
Joined: Thu May 10, 2007 4:47 pm

Post » Sun May 02, 2010 7:22 pm

That script should work far as I can tell, though the GECK documentation lead me to a question there.

You may have to play with it because the documentation says that it returns if the bipedal form is considered powered armor. Not sure if in this case that's synonymous because biped form is what part of the body is covered...
User avatar
Susan
 
Posts: 3536
Joined: Sun Jun 25, 2006 2:46 am

Post » Sun May 02, 2010 9:27 pm

That script should work far as I can tell, though the GECK documentation lead me to a question there.

You may have to play with it because the documentation says that it returns if the bipedal form is considered powered armor. Not sure if in this case that's synonymous because biped form is what part of the body is covered...


Yeah thats the part I dont get myself.

Im assuming Bipedal form is the UpperBody and its just an awkward way of saying so...


Still not happy with the last script, is there another option to Begin GameMode that might work better?
What would Begin OnAdd do in a perk script ?

-Exo
User avatar
Liii BLATES
 
Posts: 3423
Joined: Tue Aug 22, 2006 10:41 am


Return to Fallout: New Vegas