Hello,
I'm a total newcomer to scripting and programming, but was wondering if you gentlepersons might help me advance time in the OC by 8 hours each time I rest? I changed all the modules to have 1 hour = 60 min, so I kind of need it both for the immersion and for any time-dependent debuffs to go away.
Currently I have to turn debugmode on and off and insert the code for advancing time, but it's pretty troublesome - even if I only rest at "safe" areas.
Thanks for any assistance in advance!
Help with advancing time by 8 hours when resting in the OC?
Débuté par
Zelekendel
, janv. 12 2014 03:20
#1
Posté 12 janvier 2014 - 03:20
#2
Posté 12 janvier 2014 - 08:14
Do you actually want to play it like in real time? I don't know how, I guess you would have to go look at the rest event.of the module. You could try and use the MotB system, without the wandering monster if you don't want them, but it could be trouble... but it could be a place to look, since there the time advances when you rest.
#3
Posté 12 janvier 2014 - 09:56
IMPORTANT: back up 'k_mod_player_rest.NSS/.NCS' in your OC Campaign folder before trying any of this!
I'm going to jump over a bunch of assumptions here, but this is ( i believe ) the fundamental code:
That should go in the script 'k_mod_player_rest' -- which as Andy points out can be accessed through any of the OC's modules' event: "On Player Rest Script". That is, all the modules in the OC ought use this same event/script.
But so will many other modules/campaigns!!! tbh i don't expect you'd notice conflicts tho. In fact it might well be rather refreshing, esp. if you put in a Fadeout+Fadein ... l8r
In 'k_mod_player_rest' you're looking for a codeblock that starts with: case REST_EVENTTYPE_REST_FINISHED:
it might start with switch() or an if/else .... (I just looked: the original script uses if/else, but another one I have here uses a switch) no biggie
Put the code above just inside the Rest_Event_Finished, compile and stay alert because the script is going to save itself and compile itself to somewhere on your hardrive that'll drive ya nuts to try and find. Once you do, however, chuck them (k_mod_player_rest.nss + k_mod_player_rest.ncs) in your player/Override folder
and make sure it's the only pair in there,
NOTE: There's also 'k_mod_player_rest' in the MotB and SoZ Campaign folders. If you manage to stick directly to the OC version, the compile should happen in that Campaign folder and you'll never experience any conflicts... reminder: back ups are Good.
I'm going to jump over a bunch of assumptions here, but this is ( i believe ) the fundamental code:
int iHour = GetTimeHour(); int iMin = GetTimeMinute(); int iSec = GetTimeSecond(); int iMilli = GetTimeMillisecond(); iHour += 8; SetTime(iHour, iMin, iSec, iMilli);
That should go in the script 'k_mod_player_rest' -- which as Andy points out can be accessed through any of the OC's modules' event: "On Player Rest Script". That is, all the modules in the OC ought use this same event/script.
But so will many other modules/campaigns!!! tbh i don't expect you'd notice conflicts tho. In fact it might well be rather refreshing, esp. if you put in a Fadeout+Fadein ... l8r
In 'k_mod_player_rest' you're looking for a codeblock that starts with: case REST_EVENTTYPE_REST_FINISHED:
it might start with switch() or an if/else .... (I just looked: the original script uses if/else, but another one I have here uses a switch) no biggie
Put the code above just inside the Rest_Event_Finished, compile and stay alert because the script is going to save itself and compile itself to somewhere on your hardrive that'll drive ya nuts to try and find. Once you do, however, chuck them (k_mod_player_rest.nss + k_mod_player_rest.ncs) in your player/Override folder
and make sure it's the only pair in there,
NOTE: There's also 'k_mod_player_rest' in the MotB and SoZ Campaign folders. If you manage to stick directly to the OC version, the compile should happen in that Campaign folder and you'll never experience any conflicts... reminder: back ups are Good.
Modifié par kevL, 12 janvier 2014 - 10:05 .
#4
Posté 12 janvier 2014 - 05:29
From experience, though, 8 hours is a pretty awkward delay for resting. You go from noon to night, midnight to mid-morning. If you're resting in the midst of a quest or some sort of plot action, it can throw the flow of time all out of whack. If you're just staying at an inn or something, checking out at 2:00am seem pretty odd, too.
You might want to consider a shorter, say 2-4 hour 'nap', or maybe just advancing the clock to the next morning.
You might want to consider a shorter, say 2-4 hour 'nap', or maybe just advancing the clock to the next morning.
#5
Posté 12 janvier 2014 - 09:53
As far as the OC is concerned, kneeling down constantly for eight hours doesn't sound very restful. 
In my current module, I have the entire party encircle a campfire, sit down, and fade to black before advancing the time (either 4 hours just to heal and restore, or 8 hours to also memorise spells). When the scene fades back from black the party all stand up and play one of several animations at random (yawn, brush off, shrug, etc).
Incorporating something like that into the OC would be difficult though.
In my current module, I have the entire party encircle a campfire, sit down, and fade to black before advancing the time (either 4 hours just to heal and restore, or 8 hours to also memorise spells). When the scene fades back from black the party all stand up and play one of several animations at random (yawn, brush off, shrug, etc).
Incorporating something like that into the OC would be difficult though.
#6
Posté 13 janvier 2014 - 01:56
1 sec / level
...tradition (nwn)
...tradition (nwn)
#7
Posté 14 janvier 2014 - 03:40
Good thoughts, though beyond me to implement. Thank you for the assistance with the scripting though, I'll have a crack at it.
I'm using the real time advancement both because of 1 hour / level spells as well as the constantly cycling day / night just plain annoying me.
Lugaid, it's not a problem, I can just rest again if I'd leave at an awkward time otherwise. Besides, why would I rest in the midst of a quest or plot action? Clearly that is no time for resting. You only rest when you are able, after everything is resolved, of course. To do otherwise would be exploiting the system.
Ed. though I realized what you mean now, you mean having a shorter rest period of like 4 hours would allow me to advance time less and be more versatile about it, and rest two times to rest the full 8 hours.
I tried it, but it didn't work for me. Opened in the toolset script editor, after I put the nss in the override folder, made these changes to the end:
else if (GetLastRestEventType()==REST_EVENTTYPE_REST_FINISHED) { // No longer used but left in for the community // WMFinishPlayerRest(oPC); // removes sleep effect, etc int iHour = GetTimeHour(); int iMin = GetTimeMinute(); int iSec = GetTimeSecond(); int iMilli = GetTimeMillisecond();
iHour += 8;
SetTime(iHour, iMin, iSec, iMilli); } }}
Saved and compiled, it put the Ncs in the same override subfolder for me. No dice, unfortunately.
I'm using the real time advancement both because of 1 hour / level spells as well as the constantly cycling day / night just plain annoying me.
Lugaid, it's not a problem, I can just rest again if I'd leave at an awkward time otherwise. Besides, why would I rest in the midst of a quest or plot action? Clearly that is no time for resting. You only rest when you are able, after everything is resolved, of course. To do otherwise would be exploiting the system.
Ed. though I realized what you mean now, you mean having a shorter rest period of like 4 hours would allow me to advance time less and be more versatile about it, and rest two times to rest the full 8 hours.
I tried it, but it didn't work for me. Opened in the toolset script editor, after I put the nss in the override folder, made these changes to the end:
else if (GetLastRestEventType()==REST_EVENTTYPE_REST_FINISHED) { // No longer used but left in for the community // WMFinishPlayerRest(oPC); // removes sleep effect, etc int iHour = GetTimeHour(); int iMin = GetTimeMinute(); int iSec = GetTimeSecond(); int iMilli = GetTimeMillisecond();
iHour += 8;
SetTime(iHour, iMin, iSec, iMilli); } }}
Saved and compiled, it put the Ncs in the same override subfolder for me. No dice, unfortunately.
Modifié par Zelekendel, 14 janvier 2014 - 08:03 .
#8
Posté 15 janvier 2014 - 12:03
well well look what i found:
sry, Didn't notice that...
In the OC's default 'k_mod_player_rest' script, there appears to be a short-circuit that stops the script from proceeding. The simple way to get the script to complete normally is by simply placing two slashes in front of:
But then you might have wandering monsters or something whaky show up during REST_EVENTTYPE_REST_STARTED.
So, since it's not supposed to run anyway, here's a pruned script:
btw, I tried the code snippet from my first post and it works (although i'm using different scripts, the time went from afternoon to BOOM middle of night when resting finished -- it really needs a couple of fades and that's the main reason to keep the REST_STARTED block above: a fade-out should be put there, and a fade-in would go in REST_FINISHED)
other than that it sounds like you're doing it right,
[edit] btw i concur w/ DJ & Lugaid. 4 hours: how much rest can really be had on campaign??
void main()
{
object oPC = GetLastPCRested();
return; // short circuiting for nowsry, Didn't notice that...
In the OC's default 'k_mod_player_rest' script, there appears to be a short-circuit that stops the script from proceeding. The simple way to get the script to complete normally is by simply placing two slashes in front of:
// return; // short-circuiting the short circuit...
But then you might have wandering monsters or something whaky show up during REST_EVENTTYPE_REST_STARTED.
So, since it's not supposed to run anyway, here's a pruned script:
// 'k_mod_player_rest'
void main()
{
if (GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
{
}
else if (GetLastRestEventType() == REST_EVENTTYPE_REST_CANCELLED)
{
}
else if (GetLastRestEventType() == REST_EVENTTYPE_REST_FINISHED)
{
int iHour = GetTimeHour();
int iMin = GetTimeMinute();
int iSec = GetTimeSecond();
int iMilli = GetTimeMillisecond();
iHour += 8;
SetTime(iHour, iMin, iSec, iMilli);
}
}btw, I tried the code snippet from my first post and it works (although i'm using different scripts, the time went from afternoon to BOOM middle of night when resting finished -- it really needs a couple of fades and that's the main reason to keep the REST_STARTED block above: a fade-out should be put there, and a fade-in would go in REST_FINISHED)
other than that it sounds like you're doing it right,
[edit] btw i concur w/ DJ & Lugaid. 4 hours: how much rest can really be had on campaign??
Modifié par kevL, 15 janvier 2014 - 12:07 .
#9
Posté 15 janvier 2014 - 06:59
The NWN2 OC Makeover causes resting in the OC to consume 8 hours. You can look at the campaign scripts to see how that was done. Specifically the k_bb_mod_player_rest command. As suggested above there is a modification to the REST_EVENTTYPE_REST_FINISHED event to advance the time 8 hours using this function:
void advanceTime(int nHours = 0, int nMinutes = 0)
{
SetTime( GetTimeHour() + nHours, GetTimeMinute() + nMinutes, GetTimeSecond(), GetTimeMillisecond() );
}
Regards
void advanceTime(int nHours = 0, int nMinutes = 0)
{
SetTime( GetTimeHour() + nHours, GetTimeMinute() + nMinutes, GetTimeSecond(), GetTimeMillisecond() );
}
Regards
#10
Posté 21 janvier 2014 - 05:27
Cheers fellows, it works now. Still don't know how to do the fadeout, though, google does show a NWN-related cutscene with fadeouts, but I wasn't able to figure out how it would properly work based on that.
I've also got my 6-character party with the custom difficulty (+50% enemy HP and damage), so I should be good for now.
I've also got my 6-character party with the custom difficulty (+50% enemy HP and damage), so I should be good for now.
#11
Posté 21 janvier 2014 - 10:08
// 'k_mod_player_rest'
// take.2
void main()
{
object oPC = GetLastPCRested();
if (GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
{
FadeToBlack(oPC, FADE_SPEED_MEDIUM, 30.0);
}
else if (GetLastRestEventType() == REST_EVENTTYPE_REST_CANCELLED)
{
FadeFromBlack(oPC);
}
else if (GetLastRestEventType() == REST_EVENTTYPE_REST_FINISHED)
{
int iHour = GetTimeHour();
int iMin = GetTimeMinute();
int iSec = GetTimeSecond();
int iMilli = GetTimeMillisecond();
iHour += 8;
SetTime(iHour, iMin, iSec, iMilli);
FadeFromBlack(oPC);
}
}
#12
Posté 21 janvier 2014 - 09:34
Thanks, Kev, noticed that you're the author of the PIA, so maybe you'd have insight about the difficulty increase needed for a 6 member party, if it's too OT we can do it via PMs or the comment section of your mod at the Vault.
I had a pretty tough but enjoyable time with the original four with the aforementioned +50% damage and HP active, although of course the early game is easier, but still, it might be that I need some tweaks like increased saves, or moderate stat boosts. Something like the equal of Pathfinder's Advanced template (Increase natural armor by +2; +4 to all ability scores), considering that the "base game" is a bit too easy as it is.
I had a pretty tough but enjoyable time with the original four with the aforementioned +50% damage and HP active, although of course the early game is easier, but still, it might be that I need some tweaks like increased saves, or moderate stat boosts. Something like the equal of Pathfinder's Advanced template (Increase natural armor by +2; +4 to all ability scores), considering that the "base game" is a bit too easy as it is.
#13
Posté 21 janvier 2014 - 09:53
uhm, I'll shy away from even offering values for Pia
The default Difficulty.2da is pretty tough. A lot depends on how much you micromanage and/or Pause to mull things over each round. have another look at it
But i should point out it's not a straight percentage increase. Iirc it's a percentage increase based on a 20 HD/CR opponent. And several other values aren't even percents at all... but straight pips, again scaled vs 20CR opponents.
ie, a 10 HD/CR creature gets half what you specify. browse the descriptions of values in my Doc too, i Tried to give a sense of what's going on there
It's a feely-intuitive thing, and it's best to stay on the shy side. Just keep easy monsters easy, because when you run into the tuff ones they'll be tuff.
The default Difficulty.2da is pretty tough. A lot depends on how much you micromanage and/or Pause to mull things over each round. have another look at it
But i should point out it's not a straight percentage increase. Iirc it's a percentage increase based on a 20 HD/CR opponent. And several other values aren't even percents at all... but straight pips, again scaled vs 20CR opponents.
ie, a 10 HD/CR creature gets half what you specify. browse the descriptions of values in my Doc too, i Tried to give a sense of what's going on there
It's a feely-intuitive thing, and it's best to stay on the shy side. Just keep easy monsters easy, because when you run into the tuff ones they'll be tuff.





Retour en haut






