Jump to content

how to make continous scripts


TheBlob2

Recommended Posts

It's a bit vague, but in general this works fine:

 

Create a quest with delay time 10

Attach a gamemode script

In the script you scan the cell for reference type 200 (using GetFirstRef / GetNextRef)

Execute the code for the references found

 

at least until the code you execute is not very heavy. At that point I would add an extra stage to the script, to handle the code in a different way.

Maybe you want to provide more infos?

Edited by Fallout2AM
Link to comment
Share on other sites

remember that script I made? (reminder: http://forums.nexusmods.com/index.php?/topic/2506359-scripts-are-hard-man/) I'm trying to get this script on all npcs in the same cell as the player, but instead of a set agility debuff, it changes based on which fromlist the currently equipped weapon belongs to and does a different amount of agility damage. so basically this is how the script will work:

 

>checks all actors in the same cell as the player every 10 seconds, but this script does not check the player, and it doesn't check the same npc more than once unless they change weapons. and during combat it checks every second

>does agility damage according to the formlist that the currently equipped weapon belongs to

>unequips their current weapon

>requips the weapon

>restores the damage done to their agility stat

 

this will cause the npc to draw and reload their weapons slower depending on the weapon, and the reason why it unequips and requips is because the agility stat modifier on weapon draw speed doesn't affect npcs unless they unequip and requip their weapon, and I realized that the script that I had made earlier (the one linked above) only works on the player, apparently scripts on weapons only work when the player is using them.

 

I know I don't know how to do this, it may be too advanced for me, but I'm willing to learn. but some people may know a way of getting the same result more efficiently than I do

Edited by TheBlob2
Link to comment
Share on other sites

You can't just apply object script to NPC around. Script will run on them only once (one frame) in 10 seconds. It won't "catch" the moment they enter combat.

What you're trying to do here can be done but that would require making heavy and difficult scripts (store all NPC into arrays, then mark them to make sure script runs only once, catch the moment they enter combat by checking "IsInCombat" for each of them,change agility and stuff, unmark them . That's not worth it in my opinion.That would require script less which will slow game down. And that will probably require making NX vars for each of them to store their agility and "status".

Link to comment
Share on other sites

You could scan the cell and cast spells on npcs, the spell contains all the script that handles your code.

 

I wouldn't have any problem in writing some scrap of code to do that, but I would personally feel to discourage this all if you are not used to script, for several reasons, here a simple example: someone's using this mod, it has already affected and changed some npc stat, they remove the mod from the Load Order >>> What will happen if they saved in the meantime and they reload it? a clean save shouldn't help in this, it probably won't give em back their original stats, only a script could, and the mod was unactivated... What I mean is I think it's not easy to handle unexpected behaviours like this and maybe wouldn't be bad starting with something easier. However it's just my personal opinion, feel to do whatever you think it's better, I'll give help if I can

 

PS I know the other script stlil requires to be finished, but I was thinking that maybe you could shorten the second part with something like this:

if user.getav agility > 3
   user.damageav agility 3
elseif user.getav agility == 3
   user.damageav agility 2
else
   user.damageav agility 1
endif
Edited by Fallout2AM
Link to comment
Share on other sites

You could scan the cell and cast spells on npcs, the spell contains all the script that handles your code.

or maybe a script that casts a script effect spell on the player every 10 seconds that has a very wide area of effect

Edited by TheBlob2
Link to comment
Share on other sites

You mean like a null explosion with a script that affect the other people? sure, the difference is the explosion would be a circle, a cell could have a different shape. So the explosion can or can't affect the whole cell, and it would affect in a different way when you are outside. "all npcs in the same cell as the player" = scan with depth 0, that's the only sure way.

Edited by Fallout2AM
Link to comment
Share on other sites

 

>restores the damage done to their agility stat

 

 

I wouldn't have any problem in writing some scrap of code to do that, but I would personally feel to discourage this all if you are not used to script, for several reasons, here a simple example: someone's using this mod, it has already affected and changed some npc stat, they remove the mod from the Load Order >>> What will happen if they saved in the meantime and they reload it? a clean save shouldn't help in this, it probably won't give em back their original stats, only a script could, and the mod was unactivated... What I mean is I think it's not easy to handle unexpected behaviours like this and maybe wouldn't be bad starting with something easier.

 

as for uninstalling the mod, if you do uninstall it, all the npcs who have been affected will still draw their weapons slower until they unquip and requip, because the agility modifier doesnt take affect until the actor unquips and requips. so after they uninstall the mod, as soon as the npc unquips their weapon and requips it, it should return to normal because in the original concept it will restore the agility after the weapon has been equipped, so an uninstall plugin would need to be made, the plugin will be the same as the orignal plugin but without the agility damaging affect. as for the player, its as simple as going into your inventory and unequiping

Link to comment
Share on other sites

An uninstall plugin could work, or like I've seen in some Skyrim's mods a simple flag on the MCM which starts an uninstall procedure, to flag just before removing the mod from the load order. But that wasn't really my point, my point was I think it's not a simple script to start with. But if you feel confortable in doing that, it seems a nice idea

Link to comment
Share on other sites

The idea is good but implementation is not at all. Scanning cell, giving NPC spells (to every one of them! and each spell wil continiously check for "IsInCombat") and changing ACTOR VALUE (with a risk of permanent save damage because if mod is uninstalled - all spells on NPC will be dispelled immediately and if NPC is still equipping weapon he will lose his original agility value forever. Or what if player just type "coc Goodsprings" when combat started and spell on NPC stops working (they do that) just to make weapon equipping slower?

 

Oh no. I'll sure add this mod to incompatible list for my mod.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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