summaryrefslogblamecommitdiff
path: root/server/scripts/woe_time_explanation.txt
blob: d030355f88339f118c2edc825ea34ada4f04eac1 (plain) (tree)
































































































                                                                                                                  
//===== Hercules Documentation ===============================
//= WoE Time Explanation
//===== By: ==================================================
//= erKURITA
//===== Current Version: =====================================
//= 20151115
//===== Description: =========================================
//= Details on the behavior of the default WoE controller.
//============================================================

There are 2 main commands that determine WoE times:
OnClock<time>: and gettime(<type>).

OnClock<time> triggers when <time> is reached.
The format is HHMM, where H = hour, M = minute.
OnClock2350: would run at 23:50, server time.

gettime(<type>) is a function that checks for certain information regarding
time. For more information about it, see script_commands.txt.

-------------------------------------------------------------------------------

Now the structure:

	OnClock2100:	// Start time for Tues(2), Thurs(4)
	OnClock2300:	// End time for Tues(2), Thurs(4)
	OnClock1600:	// Start time for Sat(6)
	OnClock1800:	// End time for Sat(6)

These 4 labels will run one after the other, reaching the next check:

	if ((gettime(GETTIME_WEEKDAY) == TUESDAY  && gettime(GETTIME_HOUR) >= 21 && gettime(GETTIME_HOUR) < 23) ||
	    (gettime(GETTIME_WEEKDAY) == THURSDAY && gettime(GETTIME_HOUR) >= 21 && gettime(GETTIME_HOUR) < 23) ||
	    (gettime(GETTIME_WEEKDAY) == SATURDAY && gettime(GETTIME_HOUR) >= 16 && gettime(GETTIME_HOUR) < 18)) {
		agitstart();
	}

This part will check for the times. Since both Start and End times run
through the same chain of commands, these are important checks to ensure
it's the right time. Let's take the following example:

	if (gettime(GETTIME_WEEKDAY) == TUESDAY && gettime(GETTIME_HOUR) >= 21 && gettime(GETTIME_HOUR) < 23)

The first gettime() is checking for type GETTIME_WEEKDAY, the day of the week,
and it's comparing it to the one desired, which is TUESDAY. The function will
return either 1 (true) or 0 (false).

The second gettime is checking type GETTIME_HOUR, the hour, and it's comparing
it to 21. If the first part is greater than or equal to (>=) the second part,
the comparison will return 1.

The third and last gettime is checking again for the hour, but the time has to be less
than the specified time (in this case, 23).

Now, the last part of the script, regarding the end of WoE time:

	if ((gettime(GETTIME_WEEKDAY) == TUESDAY  && gettime(GETTIME_HOUR) == 23) ||
	    (gettime(GETTIME_WEEKDAY) == THURSDAY && gettime(GETTIME_HOUR) == 23) ||
	    (gettime(GETTIME_WEEKDAY) == SATURDAY && gettime(GETTIME_HOUR) == 18)) {
		agitend();
	}

This is the same as before, but it's checking for the day in the first gettime() and
the hour on the second. If both conditions are true, WoE will end. We're checking 
here for the end time, not the start.

Another important thing is "OnAgitInit:". This special label will be run as soon as the
castle data is loaded from the char data. It will check for the above start and end times
to see if it's in WoE time, hence why the hours have to be checked.

-------------------------------------------------------------------------------

An example of how to set the WoE so it starts on Monday, at 4 pm and ends up at 10 pm:

	OnClock1600: // 16:00 = 4 pm
	OnClock2200: // 22:00 = 10 pm

	OnAgitInit: // This label should appear once and only once in the script

	// starting time checks
	if (gettime(GETTIME_WEEKDAY) == MONDAY && gettime(GETTIME_HOUR) >= 16 && gettime(GETTIME_HOUR) < 22) {
		if (!agitcheck()) {
			agitstart;
			callsub S_DisplayOwners;
		}
		end;
	}

	// end time checks
	if (gettime(GETTIME_WEEKDAY) == MONDAY && gettime(GETTIME_HOUR) == 22) {
		if (agitcheck()) {
			agitend;
			callsub S_DisplayOwners;
		}
		end;
	}
	end; // Don't forget this!