Jump to content
ℹ️ Intermittent Download History issues ×

Activate remote NPC for one frame


lgpmichael

Recommended Posts

Hi guys, I have a scripting issue that I can't find a workaround for, so I am hoping someone has an idea

 

I need to activate an NPC that is in another cell, just for one frame.

 

Why:

 

OK, I am adding a spell Ability as follows

 

A damage health Ability that damages HP, and has an accompanying script. The script removes the ability from the target.

 

In effect this causes damage to the actor it is applied to, which is proper damage instead of the fake damage done by modav

 

If applied to an actor in the same cell as the player, it works just fine

 

If applied to an actor in a different cell, it wont work, as the ability and its script will not run until the npc is in the same cell as the player.

 

This means when I use another script to look at the NPC's health for other reasons, before the player goes near the NPC, the damage hasn't happened.

 

What I need to do is to activate the NPC for just one frame, so they can run through their regular routine and apply the ability effects.

 

So, does anyone have a useful trick, hack, or other workaround, to make an NPC activate themselves for one frame? If not, I'll have to move the NPC to somewhere in the same cell that the player can't see, and then do it before moving them back, and I'd rather not do that, its ugly {;-)

 

Thanks

Link to comment
Share on other sites

When you set a variable in a script, the script will run for 1 frame even if the object the script is attached to is not loaded. It's written here on the CS wiki. I've done it, so I know it works.

 

If you know the reference ID of the NPC, then you should be able to set the variable the same way you set the variable in a quest. I don't know this for sure, but that's how it's done when you rent beds at an inn. Check the "BedYes" topic result scripts in the "BedRental" quest to see for yourself.

 

So, it's possible to run an NPC's script even when they are not in the same cell as the player. However, I don't think you can do the same with a spell effect script on a spell.

 

Is there any reason why you have to apply the damage through the spell? Why not use ModAV2? It doesn't reduce an actor's base stats, which is what I think you're worried about. Then you can just attach a script to the NPC that checks for whether the NPC has an ability, and uses ModAV2 to damage its health if it does.

Link to comment
Share on other sites

When you set a variable in a script, the script will run for 1 frame even if the object the script is attached to is not loaded. It's written here on the CS wiki. I've done it, so I know it works.

 

If you know the reference ID of the NPC, then you should be able to set the variable the same way you set the variable in a quest. I don't know this for sure, but that's how it's done when you rent beds at an inn. Check the "BedYes" topic result scripts in the "BedRental" quest to see for yourself.

 

So, it's possible to run an NPC's script even when they are not in the same cell as the player. However, I don't think you can do the same with a spell effect script on a spell.

 

Is there any reason why you have to apply the damage through the spell? Why not use ModAV2? It doesn't reduce an actor's base stats, which is what I think you're worried about. Then you can just attach a script to the NPC that checks for whether the NPC has an ability, and uses ModAV2 to damage its health if it does.

 

The main and only reason - not using OBSE, and I've done a lot of work to make the mod work without it. From what I've seen, is that while OBSE is great, a lot of people won't run OBSE mods, and so I'm trying to avoid it. I've got 16 or so hours of gameplay without it, and I really don't want to add the dependency in for the very last dungeon of the whole mod. {:-)

 

The script idea didn't work unfortunately, however I ended up with a hacky workaround, storing an offset in a script, so add that to the getAV health to get the HP, then when adding in the damage ability also add in an ability which sets the offset back to zero, so when the abilities do eventually run, they do their job and remove the offset. Job done, all works. Its a bit hacky but I guess thats the name of the game sometimes {;-)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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