// Configure 'flagmaps' table using this custom flags // 1: PvP // 2: PvP No Party // 4: PvP No Guild // 8: GvG // 16: GvG No Party // 32: No Skill // 64: Nightmare Drops (only rAthena) // Function to Set / Unset the World Map Flags function script applyMapFlags { set $@MapFlagStatus,getarg(0); set .@Cnt,0; do { set .@Rows, query_sql("select map, flag from flagmaps limit " + .@Page + ",100", .@Map$, .@Flags); set .@Flag, .@Flags[0]; for (set .@x,0; .@x < .@Rows; set .@x, .@x + 1) { set .@SelectedMap$, .@Map$[.@x]; if ($@MapFlagStatus) { if (.@Flag & 1) setmapflag .@SelectedMap$, mf_pvp; if (.@Flag & 2) setmapflag .@SelectedMap$, mf_pvp_noparty; if (.@Flag & 4) setmapflag .@SelectedMap$, mf_pvp_noguild; if (.@Flag & 8) setmapflag .@SelectedMap$, mf_gvg; if (.@Flag & 16) setmapflag .@SelectedMap$, mf_gvg_noparty; if (.@Flag & 32) setmapflag .@SelectedMap$, mf_noskill; if (.@Flag & 64) setmapflag .@SelectedMap$, mf_nightmaredrop; } else { if (.@Flag & 1) removemapflag .@SelectedMap$, mf_pvp; if (.@Flag & 2) removemapflag .@SelectedMap$, mf_pvp_noparty; if (.@Flag & 4) removemapflag .@SelectedMap$, mf_pvp_noguild; if (.@Flag & 8) removemapflag .@SelectedMap$, mf_gvg; if (.@Flag & 16) removemapflag .@SelectedMap$, mf_gvg_noparty; if (.@Flag & 32) removemapflag .@SelectedMap$, mf_noskill; if (.@Flag & 64) removemapflag .@SelectedMap$, mf_nightmaredrop; } } set .@Page, .@Page + 100; // Move to the Next Page } while(.@Rows); return; } // Broadcast - script MFBC -1,{ OnInit: setarray .msgs$[0], "The night is slowly taking over Rune midgard.", "Weaklings and cowards stay in towns, while fierce warriors grab their weapons and prepare for bloody fights....", "Players whose level is lower than lv40 can't kill/be killed by other players during NMM"; end; Ontimer1000: for (set .@m,0; .@m < getarraysize(.msgs$); set .@m, .@m + 1) { announce .msgs$[.@m],bc_all; sleep 5000; } stopnpctimer; } // Map Flag Manager - script MFM -1,{ ceroLeft: set .@Num$, getarg(0); while (getstrlen(.@Num$) < getarg(1)) { set .@Num$, "0" + .@Num$; } return .@Num$; setRates: setbattleflag "base_exp_rate", getarg(0); setbattleflag "job_exp_rate", getarg(1); atcommand "@reloadmobdb"; return; OnInit: set .baseexp, getbattleflag("base_exp_rate"); set .jobexp, getbattleflag("job_exp_rate"); // Sample Configuration: These pairs of numbers are hours with minutes // (23:00 to 00:00 - 00:00 to 03:30 - 15:47 to 15:48) // Don't mix hours of two days (ie: "2300","0330") because doesn't work, in this cases add 2 consecutive ranges: "2300","2359","0000","0100" setarray .Changes$[0],"0300","0315","0600","0615","0900","0915","1200","1215","1500","1515","1800","1815","2100","2115","0000","0015","2202","2235"; set .Count, getarraysize(.Changes$); sleep 2000; OnWhisperGlobal: OnTimer60000: // Check every 1 minute (support restarts) set .@PKEnable,0; for (set .@x,0; .@x < .Count; set .@x, .@x + 2) { set .@CurrentHour$, callsub(ceroLeft,gettime(3),2) + callsub(ceroLeft,gettime(2),2); set .@Hour1$, .Changes$[.@x]; set .@Hour2$, .Changes$[.@x + 1]; // If this is a valid range... if (.@CurrentHour$ >= .@Hour1$ && .@CurrentHour$ <= .@Hour2$) { set .@PKEnable,1; if (!$@MapFlagStatus) { night; initnpctimer "MFBC"; // Broadcast in a separated thread debugmes "[" + .@CurrentHour$ + "] Enabling Nightmare Flags [" + .@Hour1$ + " to " + .@Hour2$ + "]"; callfunc "applyMapFlags",1; // Activating Map Flags mapwarp "pvp_y_1-2","prontera",155,180; //warps the players in the pvp map callsub setRates, (2 * .baseexp), (2 * .jobexp); } } } // If there are not valid ranges but the nightmare mode is enabled... if (!.@PKEnable && $@MapFlagStatus) { debugmes "[" + .@CurrentHour$ + "] Disabling Nightmare Flags [" + .@Hour1$ + " to " + .@Hour2$ + "]"; callfunc "applyMapFlags",0; // Disabling Map Flags day; announce "Nightmares: A new day is starting, you had sweet dreams ? Nightmare Mode deactivated! .",bc_all; callsub setRates, .baseexp, .jobexp; } initnpctimer; end; OnPCDieEvent: if (!$@MapFlagStatus) end; callfunc "PenaltyBaseExp", (killerrid > 1999999?2:1); } function script PenaltyBaseExp { if (BaseExp) { set BaseExp, BaseExp - (BaseExp / 100 * getarg(0)); announce "~ Nightmare Penalty: -" + getarg(0) + "% Base Exp", bc_self, 0xEAC8E7; } return; }