viewing paste Unknown #657 | 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 121 122 123 124 125 126
// 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;
}
Viewed 1119 times, submitted by Myzter.