=====================
//= Toasty's WoE Controller (formerly WoE Info Banner)
//===== By:
===================================================================================
=========
//= ToastOfDoom (aka: iHeart)
//===== Current Version:
===============================================================================
//= 1.22
//===== Description:
===================================================================================
//= A WoE Controller function which controls castle based WoE by utilising npc
events.
//= Includes a NPC that provides information on the next WoE session
//=
//= This script is kinda @reloadscript/@loadnpc safe, provided that someone clicks
the NPCs afterwards
//= to start the OnInit function. That said..it is recommended that you don't use
@reloadscript/@loadnpc
//= but reset your server.
//===== Changelog:
===================================================================================
==
//= 1.22
//= - Fixed an issue regarding the controller getting confused when using
@reloadscript/loadnpc while
//= WoE was still active. (thanks to annie for pointing out)
//= 1.21
//= - Fixed a misspelt variable name (thanks to rahuldev345 for pointing out)
//= 1.20
//= - Project renamed to 'Toasty's WoE Controller'. The script originally was only
used to display WoE
//= times then I 1st wrote it 3yrs ago and I feel it's purpose is more to control
WoE these days. So
//= name change to better reflect purpose.
//= - Added support for novice WoE. Region teleport goes to the Novice Warper NPC
(default in prontera)
//= Change position in .region_maps, .region_x, .region_y if needed.
//= - Region warp now only displays regions that have castles used at least once.
(eg. If you don't
//= configure any castles for Payon region, payon will not show up)
//= - Optimised WoE Active/Inactive map notifier. Old method used too many loops
for something that
//= can happen alot.
//= - Adjusted menus to be abit more friendly. 'next's will always display before
'menu's
//= - Fixed bug with WoE autostarting when only configured for 2 sessions in one
day
//= - Added some nifty code that prevents catastrophic failure of the script if you
try to run a trunk
//= version on a stable server (ie. if you do, it will show an error message, but
script will still
//= run perfectly fine - check out WoEToggler function for those that want to
peek at it =P)
//= 1.11
//= - Fixed timer glitch when players only configured sessions for one day of the
week
//= - Adjusted timer to show remaining time more accurately
//= - Modified .num_woes calculation due to bug regarding 0's being counted as
unset values in arrays
//= 1.10
//= - Expanded script to allow castle based configuration
//= - Moved away from portal based woe control. Now using donpcevents to
OnAgitEnd/2 events. Provided
//= castles are linked to the main agit commands in this manner, they will be
controllable using this
//= script.
//= - Added an onLoadMap WoE available notifier. Can be disabled by setting
.notify_woe to 0 in the
//= CONFIG section.
//= - Did some funky color coding.
//= - Added Coordinate based warping per region (see .region_x & .region_y in the
CONSTANTS section)
//= 1.02
//= - Added delwaitingroom to banner npc to prevent memory leaks from bug #2325
//= - To reduce spamming of waitingroom packets to players banner NPC only now
updates when the banner
//= text changes. Thus min time between updates is now 1sec regardless of
setting.
//= - Added setting for rate which banner time is updated (.banner_refresh_rate) in
the CONFIG section.
//= - Added agitstart2/end2 to provide WoE2 support (Hope it works ^_^;)
//= 1.01
//= - Hardcoded in refresh value for banner npc instead of getting it from config
from WoEInfoBase. Had
//= issues starting the script after @reloadscript/@loadnpc
//=================================================================================
=====================
- script WoEInfoBase -1,{
OnStartMenu:
if(.init == 0)
donpcevent strnpcinfo(3)+"::OnInit";
OnStartMenu2:
mes "La sesin" + ((.state)?"^00DD00 ACTIVA":"^DD0000 PRXIMA") +
"^000000 de WoE es: ";
mes " ";
mes "Da: ^0000DD" + .daysOfWeek$[.woe_day[.woe_index]];
mes "^000000Inicio: ^00DD00" + .woe_0_str$[.woe_index];
mes "^000000Fin: ^DD0000" + .woe_1_str$[.woe_index];
mes "^000000Castillo:";
switch(@menu) {
case 1: //warp
next;
menu "Horn",warpswand;
warpswand:
warp "aru_gld",68,158;
end;
warpcyr:
warp "pay_gld",317,294;
end;
cast001:
warp "prt_gld",240,130;
end;
cast002:
warp "pay_gld",204,264;
end;
cast005:
warp "sch_gld",288,244;
end;
cast006:
warp "gef_fild13",158,46;
end;
cast007:
next;
warp "prt_gld",129,239;
end;
cast009:
warp "gef_fild13",311,89;
end;
cast011:
warp "pay_gld",298,117;
end;
cast012:
warp "alde_gld",95,245;
end;
cast013:
warp "prt_gld",152,133;
end;
cast014:
warp "gef_fild13",191,275;
end;
end;
case 2: //view
set .@woe_state_array$, ".woe_state_" +
.woe_state[.woe_index];
for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
set .@k, 0;
set .@castles$, ".castles_" + .regions$[.@i] + "$";
set .@castle_check, getd(.@woe_state_array$ + "["
+ .@i + "]");
while(.@castle_check && .@k < .num_castles[.@i]) {
if(.@castle_check & (1 << .@k)) {
set .@map$, getd(.@castles$+"["+.@k+"]");
if (GetCastleData(.@map$,1)) {
dispbottom "El castillo [" +
GetCastleName(.@map$) + "] de la ciudad [" + .region_names$[.@i] + "] est dominado
por el Clan [" + GetGuildName(GetCastleData(.@map$,1)) + "].";
} else {
dispbottom "El castillo [" +
GetCastleName(.@map$) + "] de la ciudad [" + .region_names$[.@i] + "] est
actualmente ocupado.";
}
set .@castle_check, .@castle_check - (1
<< .@k);
}
set .@k, .@k + 1;
}
}
break;
case 3: //woe times
for(set .@i, 0; .@i < .num_woes; set .@i, .@i + 1) {
case 4:
next;
mes "[^FF0000Top 5 Rompe Empes^000000]";
for(set .@i,0;.@i<getarraysize($topempe);set .@i,.@i+1)
mes "Top "+(.@i+1)+": ^0000FF" +$topempe$[.@i]
+"^000000 con: ^FF0000" +$topempe[.@i] +"^000000 Empes Rotos.";
close;
break;
case 5:
mes "Has roto un total de: " +EmpeRotos1+" empes.";
close;
break;
mes "^FF0000Are you sure you want to skip the next WoE
session^000000";
next;
if(select("Yes:No") == 2) break;
if(.state) { //you really can't do this with woe
active
next;
mes "Sorry, in the time you took making your
decision, WoE started";
mes "Please either manually end it first or wait";
break;
}
set .woe_index, (.woe_index + 1) % .num_woes;
donpcevent strnpcinfo(3)+"::OnUpdateCountTick";
sleep2 .timer_refresh_rate;
break;
default: close;
}
goto OnStartMenu2;
OnInit:
//---------------------------------------------------------------------
--------------------//
//CONFIG START
//
//---------------------------------------------------------------------
--------------------//
//Horario de Invierno
//setarray .woe_day[0], 0, 1, 1,
2, 2, 3, 3, 4, 5,
5, 6;
//setarray .woe_0[0], 54000, 46800, 75600,
46800, 68400, 46800, 72000, 68400, 46800,
68400, 57600;
//setarray .woe_1[0], 61200, 54000, 82800,
54000, 75600, 54000, 79200, 75600, 54000,
75600, 64800;
//setarray .woe_state[0], 0, 5,
1, 4, 1, 2, 3, 1,
2, 5, 3;
setarray .woe_day[0], 1, 3, 4, 7,
setarray .woe_0[0], 50400, 50400, 50400,
32400;
setarray .woe_1[0], 57600, 57600, 57600,
39600;
setarray .woe_state[0], 0, 3, 0, 3;
//---------------------------------------------------------------------
--------------------//
//CONFIG END
//
//---------------------------------------------------------------------
--------------------//
//---------------------------------------------------------------------
--------------------//
//CONSTANTS START - Don't touch this unless you know what you are doing
//
//---------------------------------------------------------------------
--------------------//
//region prefixs
setarray
.regions$[0],"prtg","payg","gefg","aldeg","arug","schg","novi";
//region info
setarray .region_names$[0],"Prontera", "Payon", "Geffen", "Aldebaran",
"Arunafeltz", "Schwarzwald", "Novice Castles";
setarray .region_maps$[0],"prt_gld", "pay_gld", "gef_fild13",
"alde_gld", "aru_gld", "sch_gld", "prontera";
//coords to warp player to region (0 is random)
setarray .region_x[0],0, 0, 0, 0, 0, 0, 148;
setarray .region_y[0],0, 0, 0, 0, 0, 0, 163;
//---------------------------------------------------------------------
--------------------//
//CONSTANTS END
//
//---------------------------------------------------------------------
--------------------//
donpcevent strnpcinfo(3)+"::OnFindCurIndex";
donpcevent strnpcinfo(3)+"::OnUpdateCountTick";
if(.active_woe) {
if(.notify_woe) {
//set mapflag for all castle maps
for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
set .@region_array$, ".castles_" + .regions$[.@i] +
"$";
for(set .@k, 0; .@k < .num_castles[.@i]; set .@k, .@k
+ 1) {
setmapflag getd(.@region_array$ + "[" + .@k +
"]"), mf_loadevent;
setd(".loadmap_region_" + getd(.@region_array$
+ "[" + .@k + "]"), .@i + 1);
setd(".loadmap_castleIndex_" +
getd(.@region_array$ + "[" + .@k + "]"), .@k);
}
}
}
//activates WoE if needed
donpcevent strnpcinfo(3)+"::OnDoWoE";
}
//flag that init occured
set .init, 1;
OnWoETimer:
//timer stuff
while (1) {
set .remainTime, .count_tick - gettimetick(2);
set .bannerTimer, .remainTime - (.remainTime %
.banner_refresh_rate) + .banner_refresh_rate;
set .min, .bannerTimer / 60;
set .sec, .bannerTimer - .min * 60;
set .hr, .min / 60;
set .min, .min - .hr * 60;
set .roomMsg$, .waitMsg$[.state] + .hr + ":" + ((.min <
10 )?"0":"") + .min + ":" + ((.sec < 10 )?"0":"") + .sec;
sleep .timer_refresh_rate;
if(.remainTime <= 0) {
if(.active_woe) {
donpcevent strnpcinfo(3)+"::OnDoWoE";
}
set .roomMsg$, .startMsg$[.state];
donpcevent strnpcinfo(3)+"::OnUpdateCountTick";
sleep .change_state_sleep;
}
}
end; //obligatory end =D
OnUpdateCountTick:
set .count_tick, getd(".woe_" + .state + "[" + .woe_index + "]");
set .count_tick, gettimetick(2) + .count_tick - gettimetick(1) +
(.woe_day[.woe_index] - gettime(4) + 7) % 7 * .ticks_in_day;
OnFindCurIndex:
set .woe_index, 0;
set .state, 0;
if(.woe_day[.@i] == .@cur_day) {
if(.woe_0[.@i] >= .@cur_tick) {
set .woe_index, .@i;
set .state, 0;
break;
}
if(.woe_1[.@i] >= .@cur_tick) {
set .woe_index, .@i;
set .state, 1;
break;
}
}
if(.woe_day[.@i] > .@cur_day) {
set .woe_index, .@i;
set .state, 0;
break;
}
}
end;
//---------------------------------------------------------------------------
---
// WoE Controller Stuff Here
//---------------------------------------------------------------------------
---
OnDoWoE:
if((.state == 0 && .init) || (.state == 1 && !agitcheck())) {
//starting
callfunc "WoEToggler", 1;
} else {
announce "The [" + GetCastleName(.@map$) + "]
castle of the [" + .region_names$[.@i] + "] region is currently
unoccupied.",bc_all;
}
set .@castle_check, .@castle_check - (1 << .@k);
}
set .@k, .@k + 1;
}
}
end;
}
prontera,164,168,2 script WoE Info 837,{
if(getwaitingroomstate(3, strnpcinfo(3)) == -1)
donpcevent strnpcinfo(3)+"::OnInit";
doevent "WoEInfoBase::OnStartMenu";
end;
OnInit:
while (1) {
//only updates if msg is different
set .banner$, getwaitingroomstate(4, strnpcinfo(3));
if(getvariableofnpc(.roomMsg$, "WoEInfoBase") != .banner$) {
delwaitingroom;
waitingroom getvariableofnpc(.roomMsg$, "WoEInfoBase"), 0;
}
sleep 500;
}
end;
//Reset de rankings
OnDay0101:
OnDay0201:
OnDay0301:
OnDay0401:
OnDay0501:
OnDay0601:
OnDay0701:
OnDay0801:
OnDay0901:
OnDay1001:
OnDay1101:
OnDay1201:
query_sql "DELETE FROM `global_reg_value` WHERE `str` = 'EmpeRotos1'";
cleararray $topempe[0],0,5;
cleararray $topempe$[0],"",5;
end;
}
//zomg! it duplicates!!
//prontera,164,168,2 duplicate(WoE Info) WoE Info#1 837
morocc.gat,166,97,5 duplicate(WoE Info) WoE Info#2 837
geffen.gat,128,63,5 duplicate(WoE Info) WoE Info#3 837
aldebaran.gat,134,118,5 duplicate(WoE Info) WoE Info#4 837
payon.gat,187,104,5 duplicate(WoE Info) WoE Info#5 837
veins.gat,173,78,5 duplicate(WoE Info) WoE Info#6 837
moscovia.gat,212,217,5 duplicate(WoE Info) WoE Info#8 837
nameless_i.gat,185,173,5 duplicate(WoE Info) WoE Info#9 837
rachel.gat,134,144,5 duplicate(WoE Info) WoE Info#10 837
louyang.gat,228,103,5 duplicate(WoE Info) WoE Info#11 837
alberta.gat,121,69,5 duplicate(WoE Info) WoE Info#12 837
izlude.gat,122,81,5 duplicate(WoE Info) WoE Info#13 837
gonryun.gat,152,116,5 duplicate(WoE Info) WoE Info#14 837
ayothaya.gat,221,181,5 duplicate(WoE Info) WoE Info#15 837
mora.gat,122,113,5 duplicate(WoE Info) WoE Info#16 837
brasilis.gat,185,203,5 duplicate(WoE Info) WoE Info#17 837
dicastes01.gat,187,184,5 duplicate(WoE Info) WoE Info#18 837
xmas.gat,155,126,5 duplicate(WoE Info) WoE Info#19 837
lighthalzen.gat,154,106,4 duplicate(WoE Info) WoE Info#20 837
prt_fild08,148,371,4 duplicate(WoE Info) WoE Info#21 837
//---------------------------------------------------------------------------------
------------------------------------
//These two functions handle WoE's activation/deactivation. Since stable does not
have AgitStart2/AgitEnd2,
//using the trunk version will result in catastrophic failure of the script. Double
declaration of the following
//functions fixes this (you will get warning messages though)
set @nameintop,.@i;
if(getarraysize($topempe) < 5)
set @getinrank,-1;
else
set @getinrank,.@i;
if(@nameintop == getarraysize($topempe$)){
if(@getinrank == -1){
set $topempe[getarraysize($topempe)],.@empesrotos;
set $topempe$[getarraysize($topempe$)],.@nombre$;
}
if(@getinrank >= 0 && @getinrank < 5){
//Si NO perteneces al Top 5 y tu tiempo califica para entrar te
coloca en la ultima posicion
set $topempe[getarraysize($topempe)-1],.@empesrotos;
set $topempe$[getarraysize($topempe$)-1],.@nombre$;
}
}
else {
if(.@empesrotos > $topempe[@nameintop]){
set $topempe[@nameintop],.@empesrotos;
set $topempe$[@nameintop],.@nombre$;
}
}