1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
//===== Hercules Documentation ===============================
//= WoE Time Explanation
//===== By: ==================================================
//= erKURITA
//===== Current Version: =====================================
//= 20120717
//===== 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. The types are:
1 - Seconds (of a minute)
2 - Minutes (of an hour)
3 - Hour (of a day), ranging from 0 to 23
4 - Weekday, ranging from 0 (Sunday) to 6 (Saturday)
5 - Day of the month
6 - Number of the month
7 - Year
8 - Day of the year
This way, we can check for a desired minute, hour, day, month, etc.
-------------------------------------------------------------------------------
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(4)==2) && (gettime(3)>=21 && gettime(3)<23)) goto L_Start;
if((gettime(4)==4) && (gettime(3)>=21 && gettime(3)<23)) goto L_Start;
if((gettime(4)==6) && (gettime(3)>=16 && gettime(3)<18)) goto L_Start;
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(4)==2) && (gettime(3)>=21 && gettime(3)<23))
The first gettime() is checking for a type 4, the day of the week, and it's
comparing it to the one desired, which is 2 (Tuesday). The function will
return either 1 (true) or 0 (false).
The second gettime is checking type 3, 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, look at the parentheses. Parentheses are very important when making comparisons
and conditions. Check the order of these. I'll place dummy characters for this example:
if ((X && (Y && Z)) goto L_Start;
It's saying, if Y and Z are true, the condition is met. Now let's use another set
of dummy characters. We're checking if (Y && Z) = G:
if (X && G) goto L_Start;
It's saying that if X and G are true, the condition is met, thus proceeding to L_Start.
Now, the last part of the script, regarding the end of WoE time:
if((gettime(4)==2) && (gettime(3)==23)) goto L_End;
if((gettime(4)==4) && (gettime(3)==23)) goto L_End;
if((gettime(4)==6) && (gettime(3)==18)) goto L_End;
end;
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 can only be written once: put OnClock above and the checks below.
if ((gettime(4)==1) && (gettime(3)>=16 && gettime(3)<22)) goto L_Start;
if ((gettime(4)==1) && (gettime(3)==22) goto L_End;
end; // Don't forget this!
|