Jump to content

Simple script advice (I hope)


adman85

Recommended Posts

So, I'm new to this, but I think this will solve the problem I've been having with a perk I created.

 

Instead of just adding the perk to the player (which causes the player to be unable to rest or wait due to an annoying flaw)

 

I want to attach a script to the player (and possibly all npcs and non robotic creatures) which adds the perk when the player falls below 70% of his max health, then removes the perk when the player is above 70%.. I assume it would go something like this..

 

scn addremoveperk

 

BEGIN GetHealthPercentage < 0.70

player.addperk (perkrefnumber)

 

OR

 

GetHealthPercentage => 0.70

player.removeperk (perkrefnumber)

 

END

 

 

But i really don't know as I've never really written a script from scratch before, (i have successfully transplanted some simple scripts from fallout before)

Link to comment
Share on other sites

A couple of quick pointers that I think will make things easier on you.

 

Create a quest and have it set to Start Game Enabled.

 

Create your script, making sure it is a Quest script (not Object which is the default)

 

scn addremoveperk

 

Begin GameMode

 

 

;the rest of your script

 

END

 

Go back to your quest and add the script and your done. Remember is the script doesn't save there is something wrong with your syntax.

Link to comment
Share on other sites

Well I couldn't get the script to save so i must have written it badly..

 

The above functions are all I want it to do.

 

I also tried manually adding and removing the perk through the console, but it doesn't reckognise the id i put in.. :wallbash:

 

Frustration!

 

Edit; ok so I got the console to work, but still not the script.. I guess manual console commands will have to do for now.

Edited by adman85
Link to comment
Share on other sites

you can try this

idk if it will work but hopefully it will work like a charm

 

scn addremoveperk

Begin GameMode

If player.GetHealthPercentage < 0.70 && player.HasPerk (perkrefnumber) == 0
player.AddPerk (perkrefnumber)
ElseIf player.GetHealthPercentage => 0.70  && player.HasPerk (perkrefnumber) == 1
player.RemovePerk (perkrefnumber)
EndIf

End

Edited by troyquay
Link to comment
Share on other sites

sorry

it doesn't work

i made a small mistake

i didn't try it on GECK because i was overconfident that it will work

 

here is the correct one

 

scn addremoveperk

Begin GameMode

If player.GetHealthPercentage < 0.70 && player.HasPerk AnimalFriend == 0
       player.AddPerk AnimalFriend
ElseIf player.GetHealthPercentage >= 0.70 && player.HasPerk AnimalFriend == 1
       player.RemovePerk AnimalFriend
EndIf

End

 

you can change the AnimalFriend to any other perk name. for example, ActionBoy, Chemist, etc

the problem with the previous script is the ---> =>

the correct one should be ---> >=

 

I think you don't have to install another program like NVSE to use it.

Edited by troyquay
Link to comment
Share on other sites

Hey thanks again.

 

The script works pretty much perfectly, except the perk seems to cut in and out every few seconds even when the conditions should be met.

 

Though this may be due to the problem you just mentioned above, I will fix that line and see if it works better.

 

EDIT; fixed the line in FNVEdit, but I still get the perk turning off and back on weirdly every few seconds after the script conditions are met

 

Also the ElseIf line needs a space between the two words (Else If)

 

Would EndIf need a space too then?

Edited by adman85
Link to comment
Share on other sites

what do you mean by "cut in and out" ?

I tested it just now and it worked just fine

how do you use the script? using a Quest? or something elese

 

EDIT:

no. the ElseIF line should be one word, not separated.

I tested it and it worked well.

Edited by troyquay
Link to comment
Share on other sites

Yes I have it on a quest which is start game enabled.

 

If it works fine for you then it must be something to do with the perk.

 

The perk itself has health percentage conditions as well, would this mess with the process?

 

EDIT; weird when I tried to save it had a "syntax error" until I separated the two words..

Edited by adman85
Link to comment
Share on other sites

  • Recently Browsing   0 members

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