woe_time_explanation.txt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //===== rAthena Documentation ================================
  2. //= WoE Time Explanation
  3. //===== By: ==================================================
  4. //= erKURITA
  5. //===== Last Updated: ========================================
  6. //= 20161206
  7. //===== Description: =========================================
  8. //= Details on the behavior of the default WoE controller.
  9. //============================================================
  10. There are 2 main commands that determine WoE times:
  11. OnClock<time>: and gettime(<type>).
  12. OnClock<time> triggers when <time> is reached.
  13. The format is HHMM, where H = hour, M = minute.
  14. OnClock2350: would run at 23:50, server time.
  15. gettime(<type>) is a function that checks for certain
  16. information regarding time. The types are:
  17. DT_SECOND - Seconds (of the current minute)
  18. DT_MINUTE - Minutes (of the current hour)
  19. DT_HOUR - Hour (of the current day)
  20. DT_DAYOFWEEK - Week day (constants for MONDAY to SUNDAY are available)
  21. DT_DAYOFMONTH - Day of the current month
  22. DT_MONTH - Month (constants for JANUARY to DECEMBER are available)
  23. DT_YEAR - Year
  24. DT_DAYOFYEAR - Day of the year
  25. This way, we can check for a desired minute, hour, day, month, etc.
  26. -------------------------------------------------------------------------------
  27. Now the structure:
  28. OnClock2100: // Start time for Tuesday and Thursday
  29. OnClock2300: // End time for Tuesday and Thursday
  30. OnClock1600: // Start time for Saturday
  31. OnClock1800: // End time for Saturday
  32. These 4 labels will run one after the other, reaching the next check:
  33. if((gettime(DT_DAYOFWEEK)==TUESDAY) && (gettime(DT_HOUR)>=21 && gettime(DT_HOUR)<23)) goto L_Start;
  34. if((gettime(DT_DAYOFWEEK)==THURSDAY) && (gettime(DT_HOUR)>=21 && gettime(DT_HOUR)<23)) goto L_Start;
  35. if((gettime(DT_DAYOFWEEK)==SATURDAY) && (gettime(DT_HOUR)>=16 && gettime(DT_HOUR)<18)) goto L_Start;
  36. This part will check for the times. Since both Start and End times run
  37. through the same chain of commands, these are important checks to ensure
  38. it's the right time. Let's take the following example:
  39. if((gettime(DT_DAYOFWEEK)==TUESDAY) && (gettime(DT_HOUR)>=21 && gettime(DT_HOUR)<23))
  40. The first gettime() is checking for a type DT_DAYOFWEEK, the day of the week, and it's
  41. comparing it to the one desired, which is TUESDAY. The function will
  42. return either true or false.
  43. The second gettime is checking type DT_HOUR, the hour, and it's comparing
  44. it to 21. If the first part is greater than or equal to (>=) the second part,
  45. the comparison will return 1.
  46. The third and last gettime is checking again for the hour, but the time has to be less
  47. than the specified time (in this case, 23).
  48. Now, look at the parentheses. Parentheses are very important when making comparisons
  49. and conditions. Check the order of these. I'll place dummy characters for this example:
  50. if ((X && (Y && Z)) goto L_Start;
  51. It's saying, if Y and Z are true, the condition is met. Now let's use another set
  52. of dummy characters. We're checking if (Y && Z) = G:
  53. if (X && G) goto L_Start;
  54. It's saying that if X and G are true, the condition is met, thus proceeding to L_Start.
  55. Now, the last part of the script, regarding the end of WoE time:
  56. if((gettime(DT_DAYOFWEEK)==TUESDAY) && (gettime(DT_HOUR)==23)) goto L_End;
  57. if((gettime(DT_DAYOFWEEK)==THURSDAY) && (gettime(DT_HOUR)==23)) goto L_End;
  58. if((gettime(DT_DAYOFWEEK)==SATURDAY) && (gettime(DT_HOUR)==18)) goto L_End;
  59. end;
  60. This is the same as before, but it's checking for the day in the first gettime() and
  61. the hour on the second. If both conditions are true, WoE will end. We're checking
  62. here for the end time, not the start.
  63. Another important thing is "OnAgitInit:". This special label will be run as soon as the
  64. castle data is loaded from the char data. It will check for the above start and end times
  65. to see if it's in WoE time, hence why the hours have to be checked.
  66. -------------------------------------------------------------------------------
  67. An example of how to set the WoE so it starts on Monday, at 4 pm and ends up at 10 pm:
  68. OnClock1600: // 16:00 = 4 pm
  69. OnClock2200: // 22:00 = 10 pm
  70. OnAgitInit: // This can only be written once: put OnClock above and the checks below.
  71. if ((gettime(DT_DAYOFWEEK)==MONDAY) && (gettime(DT_HOUR)>=16 && gettime(DT_HOUR)<22)) goto L_Start;
  72. if ((gettime(DT_DAYOFWEEK)==MONDAY) && (gettime(DT_HOUR)==22) goto L_End;
  73. end; // Don't forget this!