Jump to content

How to Apply An Effect Once?


Teabone3

Recommended Posts

Hi everyone, I'm updating a mod and I'm trying to figure out how to make it so that when a certain character's health is below 30%, his health is restored. I've managed to make this happen with no problems, however I would like for this ability to only occur once and never a second time.

 

How would I go about that?

Link to comment
Share on other sites

Not sure exactly how you are applying the effect, but depending on how you are making it all happen you could always put a typical "if doonce ==" thing like below.

If NPC.GetHealthPercentage <= 0.30 & DoOnce == 0
     NPC.CastImmediateOnSelf HealSpell
     Set DoOnce to 1
Endif

You can also put a "condition" on the "effect item" depending on how you have it implemented.

Link to comment
Share on other sites

I was doing it not through script. Perhaps that's how I should go about it.

What I have is an item in the enemy's Actor Effect List -- "HealSpell"

 

Then in HealSpell Actor Effects:

Type: Ability

 

Effect Item (HealSpell):

Effect: Restore Health

Range: Self

Duration: 0

Magnitude: 10000

Condition: GetHealthPercentage <= 0.30 -- Run on Target

 

Perhaps I should just use a script seems easier?

Link to comment
Share on other sites

Interesting way to go about it. I thought that Actor Effect List was only used for special attacks tied to animations. Good to know it works otherwise since you never know when the GECK will make you do a workaround. :smile: You can still do it that way, but I think you would still have to do some scripting with a Quest Script to set a variable to be used as a AND Condition to use with the GetHealthPercentage <= 0.30 and even then you would have to find a way to set the variable. In the end I think it would be easier to just attach a script to the actor to apply the effect once if that is all you are trying to do. I think below would work adjusted for your naming.

scn HealNPConce

short DoOnce

Begin Gamemode
If NPCrefname.GetHealthPercentage <= 0.30 && DoOnce == 0
     NPCrefname.CastImmediateOnSelf HealSpell
     Set DoOnce to 1
Endif
END
Link to comment
Share on other sites

That sounds like a better idea and then I could possibly add more additional effects in with it. Visual effects like shaders and such.

 

When testing that script I get an error when trying to save it.

I went to Scripts and right clicked "New" and the pasted what you have here. Then hit save and got a Syntax error at line 6. I believe its related to the "&" symbol and that I should have two instead of one. I could be wrong. but when I make it "&&" I then get an error related to "NPCrefname". That's a placeholder right?

I'm hoping to use this type of script for many different types of NPC's (that have different ID names). I'm not very good at scripting :/

Edited by Teabone3
Link to comment
Share on other sites

Okay I'm going to rest with ref Actionref since it at least lets me save when i use that. but I'm unable to locate it in the drop down list for scripts within an NPC's properties...

 

Or do I have to do something with quests to get this to work. Its really a lot more easier in CK :/

Edited by Teabone3
Link to comment
Share on other sites

Basically trying to recreate the Legendary healing in Fallout 4

 

EDIT: Meant to add this note to previous post.

Edited by Teabone3
Link to comment
Share on other sites

Trust me I'm no genius when it comes to scripting either. I use a lot of trial and error sometimes. :) You are right I missed that second & in the script. You are probably not seeing the script because it needs to be a Object script and not a Quest or Effect script to show up in the drop down. The script above was/is designed to be attached to 1 NPC reference in the world at a time. Every Editor ID would need it's own script with it's own Reference Editor ID used in the place of "NPCrefname". "NPCrefname" you would change to whatever Reference Editor ID you gave it in the world space. If you wanted to have the script work for 1 Editor ID, but for multiple references in the world of that ID it would be a bit more complicated.

Link to comment
Share on other sites

Ah yes I was using Effect rather than Object. I now see it there.

I guess its not too much of a problem making a new script per NPC. Going to give this a test and see the results.

 

EDIT: Oh I don't have these NPC's in the worldspace, but rather part of random encounter spawns. Explains why it didnt work. I guess it wouldn't be too much trouble to manually place them in the worldspace to make things easier -- since they are "legendary" i guess it would make more sense to have them unique anyways.


Thank you so much for your help! Everything is working nicely. Even have a message display that the Legendary Creature has Mutated :D

Going to be adding this to my Fallout 4 Ranking System Mod

Edited by Teabone3
Link to comment
Share on other sites

  • Recently Browsing   0 members

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