Jump to content

How to run script once per session, without GameMode?


FiftyTifty

Recommended Posts

Yea thanks! I just didn't see that working. I tried it myself and it works, except for the StopQuest command. The UDF gets called after some other startup scripts print their messages to the console. I need to check out that command more.

 

How can I open the console and see my new PrintC commands working in my new quest at that point, when I haven't even loaded a save yet? It must be operating on the data from the ESP at that point.

Link to comment
Share on other sites

Yea thanks! I just didn't see that working. I tried it myself and it works, except for the StopQuest command. The UDF gets called after some other startup scripts print their messages to the console. I need to check out that command more.

 

How can I open the console and see my new PrintC commands working in my new quest at that point, when I haven't even loaded a save yet? It must be operating on the data from the ESP at that point.

Why are you using PrintC and not Print? Give it a go. Also, you open the console at the main menu as you normally do in-game.

Edited by FiftyTifty
Link to comment
Share on other sites

 

Your approach runs your script every frame at all times in GameMode.

 

 

My point was to show you how to run every frame without "Begin GameMode"

 

Of course it is not as easy,steady,reliable ... otherwise everybody would use the effect script

Link to comment
Share on other sites

 

Yea thanks! I just didn't see that working. I tried it myself and it works, except for the StopQuest command. The UDF gets called after some other startup scripts print their messages to the console. I need to check out that command more.

 

How can I open the console and see my new PrintC commands working in my new quest at that point, when I haven't even loaded a save yet? It must be operating on the data from the ESP at that point.

Why are you using PrintC and not Print? Give it a go. Also, you open the console at the main menu as you normally do in-game.

 

 

IDK. PrintC does exactly what I want it to, and I know how to use it.

 

Obviously, opening the console at the startup screen and then after I loaded a save is how I tested it.

 

The solution you came up with is good for what? A situation where you want a scripted function to run only once when the mod is activated. Setting the reach of a base weapon will work for that session only. The next time the game is loaded. the weapon goes back to being unchanged. But, if you have commands that only need to be done once, it will work.

 

You could accomplish the same thing with a quest script that has a gamemode. The checks for getgameloaded & GetgameRestarted are redundant, since the first time the script will run is at gameload, It just does the change to the weapon and then does a stopquest on itself. No point in having it also do things in MenuMode 4. This would be the most efficient way to do it.

scn AAAFyTyWeapReachQuestScript
begin GameMode    ;The quest script will only run ONCE
    SetWeaponReach 0.4 WeapSwitchBlade
    StopQuest AAAFyTyWeapReachQuest
end
Edited by GamerRick
Link to comment
Share on other sites

Just for others that may stumble on this thread in the future.....

 

I think FiftyTifty found a good way to solve the title of the post, even though the code posted does not, since it stops itself from ever running again on future game sessions.

 

To make this work such that it would run once on every gameload, this could work (pending actual testing):

 

Here is the script attached to the quest, which only runs at the main menu. At no other point is it being processed in any way and the separate UDF code to do it:

scn AAAFyTyWeapReachQuestScript

int bGameLoaded

begin MenuMode 4 ;The quest script will only run at the main menu
    if bGameLoaded == 0    ; DON'T want this block running more than once at each startup.  
        set bGameLoaded to 1     
        SetGameMainLoopCallback AAAFyTyWeapReachQuestScriptUDFGameMode 1 1 1 ; 1 1 1 == Register the callback, run every frame, run only in GameMode
    endif
end

scn AAAFyTyWeapReachQuestScriptUDFGameMode
Begin Function {}

set AAAFyTyWeapReachQuest.bGameLoaded to 0

SetWeaponReach 0.4 WeapSwitchBlade
SetGameMainLoopCallback AAAFyTyWeapReachQuestScriptUDFGameMode 0 ;Code that only needs to run once, has been run. So we stop the callback from being run again
End

FYI: a quest script runs as often as you tell it to in the quest's Script Processing Delay option. The default is every 5 seconds, NOT every frame. However, for a startup type script, this can be a PIA, since a player would need to wait for up to 5 seconds after loading the game for the script to be run. This is most obvious when doing something noticeable, like a script in my FNV mod that sets all ammo weights to 0 in HardCore mode. At gameload, I get a message that I am over-encumbered, and am until that script runs. So, I changed the delay to 2 seconds to make it less intrusive, though I still get the over-encumbered message at gameload, a few seconds later I can run again.

 

Keep in mid that the game still has to do some extra processing for quest scripts to do the calls at the specified interval. So, it's not totally "free" of inefficiencies. However, now that processors are doing at least 100,000 MIPS, a few few dozen is pretty much irrelevant.

 

Given that, I would prefer the method of a GameMode block with a GETGAMELOAD/GETGAMERESTARTED check, leaving the quest delay at the default 5 seconds. In situations where you are doing something that does get saved in the save-game, you can do what others do and just stop the quest after it runs once, which is how i have seen many other mods do it (like those that add items to FormLists). And (pretty much always), I am doing this in a quest script that serves other purposes that require a GameMode block.

Edited by GamerRick
Link to comment
Share on other sites

I swear I had all sorts of f*#@ery going on, when I relied upon the quest script delay setting. Never got it to run properly for my Pipboy Remover Redux mod.

 

As for modern processors being able to process a bunch, yep, they are capable of it. Except we're using shitty scripting performance in shitty game engine. With an insane number of scripts doing this exact thing; running every frame to check stuff.

 

Much better to do it right.

Link to comment
Share on other sites

OK, but you still can't do the StopQuest command in the Menu 4 block. Open the console and do a GetQuestRunning AAAFyTyWeapReachQuest command.to see it.

 

You can't make really dumb mistakes and expect me to argue with you about something i've been doing for decades as a job.

Link to comment
Share on other sites

OK, but you still can't do the StopQuest command in the Menu 4 block. Open the console and do a GetQuestRunning AAAFyTyWeapReachQuest command.to see it.

 

You can't make really dumb mistakes and expect me to argue with you about something i've been doing for decades as a job.

 

But lets not forget that I have been making dumb mistakes for decades ... which maybe I have a menu block on aisle fore ?

And Maybe I should Stop Questing for consoling the mistakes of the past || Get Quest Running for checking on our weapons of outreach mod ?

 

Either way ... if you can't put the time in for navmeshing your reality . You probably won't have one with friends :\

Link to comment
Share on other sites

OK, but you still can't do the StopQuest command in the Menu 4 block. Open the console and do a GetQuestRunning AAAFyTyWeapReachQuest command.to see it.

 

You can't make really dumb mistakes and expect me to argue with you about something i've been doing for decades as a job.

...We're not having an argument though. It's a discussion. If this is something that actually eats at you, you need to sort yourself out.

Link to comment
Share on other sites

 

OK, but you still can't do the StopQuest command in the Menu 4 block. Open the console and do a GetQuestRunning AAAFyTyWeapReachQuest command.to see it.

 

You can't make really dumb mistakes and expect me to argue with you about something i've been doing for decades as a job.

...We're not having an argument though. It's a discussion. If this is something that actually eats at you, you need to sort yourself out.

 

+1

Link to comment
Share on other sites

  • Recently Browsing   0 members

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