Messing with time...

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: Messing with time...
Shaper
Member # 3442
Profile Homepage #0
No, not a Doctor Who scenario (why do I even try to be funny anymore?), but an annoying problem.

Basically, for my scenario to be realistic, I decided to mess about with day and night in order to get a fairly balanced distribution of light and dark. The idea is that at night-time the bad guy comes out, and does his naughty stuff (technical term number 56), and then disappears during the day. However, this is gonna be stretching the imagination of the player if night-time is only the default 1/8th of the day.

In order to combat this, I added some code to the scenario scripts Start_state to figure out whether it was day or night, and to set a flag accordingly...

ticks = (get_current_tick() % 5000);
if((ticks > 3750) || (ticks < 500)) {
time = night;
print_num(ticks); //Here for debugging only
set_flag(250,0,1);
} else {
time = day;
set_ticks_forward(1);
set_flag(250,0,0);
print_num(ticks); //Here for debugging only
}
Here, "ticks" is a variable, by the way.

This is all well and good, and the code works and all, and I now have the exact details of when the night-time is (my night-time also takes into account dawn and dusk, so the figures are a little different to what they should be). But daylight hours still far outweigh the night hours. Eek. In fact, day time is 3250 ticks long, and night-time only 1750. Now I could just say that the scenario takes place in summer. But that's lazy. If I divide the daylight hours by 2, I get 1625 ticks, which is close enough to my 1750 at night-time. But how to halve the number of ticks during the day? Well, in the code above, I set_ticks_forward by 1 for every daylight tick. Sorted. Now, in towns, day and night are fairly similar in length.

The problem then, is that in the outdoors, BoA doesn't seem to want to let me set the ticks forward by 1, or any number. In fact time just passes in increments of 10 as it should do. Any ideas how I can stop it, and maybe increase the number of ticks passed in a single turn outdoors? I've tried adding a set_ticks_forward(1) in the start_state of the outdoor script during daylight hours, but no cigar.

Any ideas would be nice :)

Thanks, Nikki xx

--------------------
And when you want to Live
How do you start?
Where do you go?
Who do you need to know?

Posts: 2864 | Registered: Monday, September 8 2003 07:00
Guardian
Member # 6670
Profile Homepage #1
I had a similar idea a while back for a scenario I'd probably never get around to doing. It would take place in a city, and thieves would come out at night. Basically, there'd be two copies of every town section, one for night and one for day. Ticks would never advance until you entered an inn. When you went to sleep, you could tell the innkeeper whether you wanted to get woken up at night or during the day.

Don't know if this helps. Modifying the way time advances is much more slick than my idea.

--------------------
IF I EVER BECOME AN EVIL OVERLORD:
I will not use hostages as bait in a trap. Unless you're going to use them for negotiation or as human shields, there's no point in taking them.
Posts: 1509 | Registered: Tuesday, January 10 2006 08:00
The Establishment
Member # 6
Profile #2
quote:
The problem then, is that in the outdoors, BoA doesn't seem to want to let me set the ticks forward by 1, or any number. In fact time just passes in increments of 10 as it should do. Any ideas how I can stop it, and maybe increase the number of ticks passed in a single turn outdoors? I've tried adding a set_ticks_forward(1) in the start_state of the outdoor script during daylight hours, but no cigar.
Can you move time ahead and back in increments of 10? If so, you can always do the time shift every third turn or something like that.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Shaper
Member # 3442
Profile Homepage #3
No. I can't get it to go forward any amount of ticks, other than the default ten...

--------------------
And when you want to Live
How do you start?
Where do you go?
Who do you need to know?

Posts: 2864 | Registered: Monday, September 8 2003 07:00
Lifecrafter
Member # 6193
Profile Homepage #4
The code will work if placed in the start_state of the scenario script. Use a (is_outdoors()) check to decide whether you should set the ticks forward 1 for town, or an extra 10 for outdoors.

Edit: Apparently while outdoors all ticks are rounded up to 10, so if you set forward only one tick the difference never shows. Set it forward 10 ticks (which shouldn't be a problem, after all to balance time you'll have to double the time passed) and then it will work.

[ Monday, September 18, 2006 10:57: Message edited by: Lazarus. ]

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
The Establishment
Member # 6
Profile #5
quote:
No. I can't get it to go forward any amount of ticks, other than the default ten...
So then 200 ticks forward is not possible if I understand? You could always loop it to do more I suppose.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Lifecrafter
Member # 6193
Profile Homepage #6
Yikes, now I'm confused. *i, during outdoor mode you can pass any interval of ticks that is divisible by 10, or maybe I just didn't understand what you said.

Nikki: Why do you want to set it forward just 1 tick anyways? Setting it forward 1 tick during the afternoon won't balance things if it's just 11 ticks instead of the usual 10 at night, the difference would be hardly noticeable. You should pass 20 ticks each turn as opposed to the usual 10 at night, to keep pace with the double time in town mode. This can be easily done with a set_ticks_foward(10)

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
...b10010b...
Member # 869
Profile Homepage #7
Emerald Mountain uses scripting to keep the scenario in daytime all the time. You might want to look at how it does it and modify it for your needs.

--------------------
The Empire Always Loses: This Time For Sure!
Posts: 9973 | Registered: Saturday, March 30 2002 08:00
Shaper
Member # 3442
Profile Homepage #8
Eep.

I figured it out. It was a combination of bad coding and my stupidity that caused the problem.

Basically, I'd set calls to only set ticks forward in certain towns. The theory behind this was because in two towns the party isn't allowed to progress from day into night. I'd set up various 'IF' loops to check the current town, but nothing to check if the party were outdoors. Hence, if the party were in towns 3-6, say, time would be speeded up, but if they weren't, it wouldn't. This, of course, ignored the party when they were outdoors.

I eventually got it sorted with this code:

(Again, "ticks", "time" and "night" are variables.)

ticks = (get_current_tick() % 5000);
if((ticks > 3750) || (ticks < 500)) {
time = night;
print_num(ticks);
set_flag(250,0,1);
} else {
if(is_town() == 1) {
if(current_town == 1) || if(current_town == 0) {
set_flag(250,0,0);
set_ticks_forward(-1);
print_num(ticks);
}
} else {
if(is_town() == 0) {
set_ticks_forward(10);
set_flag(250,0,0);
print_num(ticks);
} else {
set_ticks_forward(1);
set_flag(250,0,0);
print_num(ticks);
}
I'm only posting in case anybody else wants to use it for any reason.

Oh - and BoA also likes to round up ticks when the party enters the outdoors, which could cause other problems too, if you aren't watching what you do...

Edit: The various print_num calls are for debugging only. just to clear things up.

[ Tuesday, September 19, 2006 05:36: Message edited by: Guy Fawkes xx ]

--------------------
And when you want to Live
How do you start?
Where do you go?
Who do you need to know?

Posts: 2864 | Registered: Monday, September 8 2003 07:00
Infiltrator
Member # 3040
Profile #9
Related question: Do the time intervals for when creature/terrain scripts get called rely on the same ticks as the day/night cycles? That is, will doing this kind of tomfoolery mess up how often scripts get called?

--------------------
5.0.1.0.0.0.0.1.0...
Posts: 508 | Registered: Thursday, May 29 2003 07:00
Shaper
Member # 3442
Profile Homepage #10
If you're using scripts which use tick differences, (and I can't think of any examples... is abilnpc one?) then I imagine so, yes. Luckily, I'm not planning on using any script other than basicnpc, so this isn't a problem for me, and so really I'm not sure what the effect would be.

You should be able to work around it though< I'd have thought.

--------------------
And when you want to Live
How do you start?
Where do you go?
Who do you need to know?

Posts: 2864 | Registered: Monday, September 8 2003 07:00