viewing paste Unknown #646 | C

Posted on the
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
// 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);
    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) {
            if ($@MapFlagStatus) {
                if (.@Flag & 1) setmapflag .@Map$[.@x], mf_pvp;
                if (.@Flag & 2) setmapflag .@Map$[.@x], mf_pvp_noparty;
                if (.@Flag & 4) setmapflag .@Map$[.@x], mf_pvp_noguild;
                if (.@Flag & 8) setmapflag .@Map$[.@x], mf_gvg;
                if (.@Flag & 16) setmapflag .@Map$[.@x], mf_gvg_noparty;
                if (.@Flag & 32) setmapflag .@Map$[.@x], mf_noskill;
                if (.@Flag & 64) setmapflag .@Map$[.@x], mf_nightmaredrop;
            } else {
                if (.@Flag & 1) removemapflag .@Map$[.@x], mf_pvp;
                if (.@Flag & 2) removemapflag .@Map$[.@x], mf_pvp_noparty;
                if (.@Flag & 4) removemapflag .@Map$[.@x], mf_pvp_noguild;
                if (.@Flag & 8) removemapflag .@Map$[.@x], mf_gvg;
                if (.@Flag & 16) removemapflag .@Map$[.@x], mf_gvg_noparty;
                if (.@Flag & 32) removemapflag .@Map$[.@x], mf_noskill;
                if (.@Flag & 64) removemapflag .@Map$[.@x], mf_nightmaredrop;
            }
        }
        set .@Page, .@Page + 100; // Move to the Next Page
    } while(.@Rows);
    return;
}
 
// Map Flag Manager
-   script  MFM -1,{
    ceroLeft:
        set .@Num$, getarg(0);
        while (getstrlen(.@Num$) < getarg(1)) {
            set .@Num$, "0" + .@Num$;
        }
        return .@Num$;
    OnInit:
        set .PvpMap$, "pvp_y_1-2";
        set .PvpExitMap$, "prontera";
        set .PvpExitX,156;
        set .PvpExitY,192;
        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 ranges exactly like the sample (2300,2359,0000,0330)
        setarray .Changes[0],2300,2359,0000,0330,1547,1855;
        set .Count, getarraysize(.Changes);
    
        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";
 
    OnWhisperGlobal:
    OnTimer60000: // Check every 1 minute (support restarts)
        set .@Done,0;
        for (set .@x,0; .@x < .Count && !.@Done; set .@x, .@x + 2) {
            set .@CurrentHour, atoi(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) {
                if (!$@MapFlagStatus) {
                    debugmes "[" + .@CurrentHour + "] Enabling Nightmare Flags [" + .@Hour1 + " to " + .@Hour2 + "]";
                    night;
                    callfunc "applyMapFlags",1; // Activating Map Flags
                    set .@Done,1;
                    
                    setbattleflag "base_exp_rate", 2 * .baseexp;
                    setbattleflag "job_exp_rate", 2 * .jobexp;
                    atcommand "@reloadmobdb";
                    
                    mapwarp .PvpMap$,.PvpExitMap$,.PvpExitX,.PvpExitY; //warps the players in the pvp map
                    night;
                    for (set .@x,0; .@x < getarraysize(.@msgs$); set .@x, .@x + 1) {
                        announce .@msgs$[.@x],bc_all;
                        sleep 2000;
                    }
                }
            }
        }
        // If there are not valid ranges but the nightmare mode is enabled...
        if (!.@Done && $@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;
            
            setbattleflag "base_exp_rate", .baseexp;
            setbattleflag "job_exp_rate", .jobexp;
            atcommand "@reloadmobdb";
        }
        initnpctimer;
        
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;
}
Viewed 807 times, submitted by Myzter.