diff options
Diffstat (limited to 'npc/functions/util.txt')
-rw-r--r-- | npc/functions/util.txt | 95 |
1 files changed, 81 insertions, 14 deletions
diff --git a/npc/functions/util.txt b/npc/functions/util.txt index 2cb28573..8e263eb0 100644 --- a/npc/functions/util.txt +++ b/npc/functions/util.txt @@ -8,17 +8,19 @@ // season_direction({day, month}) // returns the direction that represents our current season (approximation) -// DOWN: Winter, 21/12 -// DOWNLEFT: Spring, 20/03 -// LEFT: Summer, 21/06 -// UPLEFT: Autumn, 22/09 +// Note: You may also use WINTER/SPRING/SUMMER/AUTUMN constants for scripts +// where the direction is not important, but the season is. (Readability) +// DOWN: Winter, 21/12 WINTER +// DOWNLEFT: Spring, 20/03 SPRING +// LEFT: Summer, 21/06 SUMMER +// UPLEFT: Autumn, 22/09 AUTUMN function script season_direction { - .@current_month = getarg(0, gettime(GETTIME_MONTH)); + .@current_month = getarg(1, gettime(GETTIME_MONTH)); if (.@current_month % 3 == 0) { - .@current_day = getarg(1, gettime(GETTIME_DAYOFMONTH)); + .@current_day = getarg(0, gettime(GETTIME_DAYOFMONTH)); switch (.@current_month) { @@ -36,7 +38,7 @@ function script season_direction { } // This is part of Jesusalva script toolkit to make his life easier when writing -// quests. Many of these are actually redudant functions. +// quests. Many of these are actually redundant functions. // Four different flavours of setq() to quickly preserve old values function script setq1 { @@ -63,14 +65,79 @@ function script setqtime { return; } -// Function to quickly disregard part of getmapxy(). -// If you use this function too much, you'll lose efficiency, and it'll be better -// to use getmapxy() normally to save to temporary variables. -// Can take one optional argument (unittype argument). +// Shortcut for getmapname() function script getmap { - if (getmapxy(.@mapName$, .@xpos, .@ypos, getarg(0,0)) != 0) - return false; - return .@mapName$; + return getmapname(); } +// Returns the player race in plain text +// GETRACE_RACE - returns player race (default) +// GETRACE_SKIN - returns player skin +// GETRACE_FULL - returns player skin + race +// Can take an optional 2nd param with the class +// get_race( {Flag, {Class}} ) +function script get_race { + .@m=getarg(0, GETRACE_RACE); + .@g=getarg(1, Class); + // We also allow this to run without player attached for... science. + if (playerattached()) + { + setarray .@allraces$, l("Human"), l("Ukar"), l("Kralog"), + l("Raijin"), l("Kralog"), l("Raijin"), l("Tritan"), + l("Human"), l("Human"), l("Tritan"), l("Ukar"); + setarray .@allskins$, l("Kaizei"), l("Cave"), l("Fire"), + l("Light"), l("Frost"), l("Dark"), l("Sea"), l("Argaes"), + l("Tonori"), l("Lake"), l("Mountain"); + } + else + { + setarray .@allraces$, "Human", "Ukar", "Kralog", "Raijin", + "Kralog", "Raijin", "Tritan", "Human", "Human", "Tritan", "Ukar"; + setarray .@allskins$, "Kaizei", "Cave", "Fire", "Light", + "Frost", "Dark", "Sea", "Argaes", "Tonori", "Lake", "Mountain"; + } + + if (.@m == GETRACE_RACE) + return .@allraces$[.@g]; + else if (.@m == GETRACE_SKIN) + return .@allskins$[.@g]; + else + return .@allskins$[.@g] + " " + .@allraces$[.@g]; +} + +// gettimeparam(GETTIME_X) +// Returns the number of seconds/minutes/hours/days/months/years since 01/01/1970 +// This is for truly daily quests, which doesn't imposes a timed wait in hours +function script gettimeparam { + .@p=getarg(0, GETTIME_MINUTE); + + // Seconds (same as gettimetick(2) - use that instead) + .@t=gettimetick(2); + if (.@p == GETTIME_SECOND) + return .@t; + + // Minutes (default) + .@t=.@t/60; + if (.@p == GETTIME_MINUTE) + return .@t; + + // Hours + .@t=.@t/60; + if (.@p == GETTIME_HOUR) + return .@t; + + // Days + .@t=.@t/24; + if (.@p == GETTIME_DAYOFMONTH) + return .@t; + + // Months (estimative) + .@t=.@t/30; + if (.@p == GETTIME_MONTH) + return .@t; + + // Years (estimative, unused, fallback) + .@t=.@t/12; + return .@t; +} |