summaryrefslogblamecommitdiff
path: root/npc/006-8/kage.txt
blob: 894c6e4f4465604cb151658b21e98df67df0e92b (plain) (tree)
1
2
3
4
5
6
7



               
                                                                      
                                     
                            









                                                        

























                                                        
                                            







                                                        
                                            




















                                                                                                                                                                                                                  



                                                                                                                                                          
                                         













                                             















                                                                                                                 






                                                                             



                                                                              
                                                                             




                                                                                 





                                                                               




                                        
                                   




























                                                                                  
                            






































































                                                                                                                        



                               




                              

                                   
                                                             

                           
                                                                                                                          


                           
                                                                                                                         
     
                                                                  





















                                                                                  



              





                                    








                                                                                                                         
              

                          
                            
                                                                                              


                                                                           
                            

                                                                          
                            

                                                                     
                  
     

                                            



                           
                 






        
// TMW2 Script
// Author:
//    Jesusalva

// Mapflags (FIXME: Disable splash... Or weapons and magic in general)
006-8	mapflag	zone	MMO No Revive
006-8	mapflag	battleground

006-8,44,68,0	script	#OutOf0068	NPC_HIDDEN,0,0,{
    end;

OnTouch:
    if (!$@CAPTURE_FLAG)
        warp "006-6", 47, 34;
    end;
}

006-8,38,58,0	script	#Abort0068A	NPC_HIDDEN,0,1,{
    end;

OnTouch:
    if (!$@CAPTURE_FLAG) {
        slide 40, 64;
        bg_leave();
    }
    end;
}

006-8,51,58,0	script	#Abort0068B	NPC_HIDDEN,0,1,{
    end;

OnTouch:
    if (!$@CAPTURE_FLAG) {
        slide 49, 64;
        bg_leave();
    }
    end;
}

006-8,40,62,0	script	#Signin0068A	NPC_HIDDEN,1,0,{
    end;

OnTouch:
    if ($@CAPTURE_INSC && CAPTURE_FLAG >= 0)
        bgjoin($@CAPTURE_T1, "006-8", 37, 58);
    end;
}

006-8,48,62,0	script	#Signin0068B	NPC_HIDDEN,1,0,{
    end;

OnTouch:
    if ($@CAPTURE_INSC && CAPTURE_FLAG >= 0)
        bgjoin($@CAPTURE_T2, "006-8", 52, 58);
    end;
}

006-8,45,65,0	script	Kage	NPC_CRUSADER,{
    function getmobid;
    if ($@CAPTURE_FLAG) {
        npctalk l("A game is currently going on, please wait for it to finish.");
        end;
    }
    mesn;
    mesq l("This a simple game; Choose one of the shrines - west or east. The one at west is %s, the one at east is %s.", b(l("Magenta")), b(l("Yellow")));
    next;
    mesn;
    mesq l("You can enter when clock ticks :15, and the game begin when the clock ticks :25 if anyone is around. This is to match with Call of Dusty event.");
    next;
    mesn;
    mesq l("Once it begins (you can fight against an AI), kill the most of enemy sparks you can, while preventing your own sparks of being killed. Wins whoever has more sparks after %s minutes.", l(b("five")));
    next;
    mesn;
    mesq l("Keep in mind this is a PvP area - So try to avoid being butchered, because revival spells are disabled here! Hahaha!");
    next;
    mesn;
    mesq l("Oh, and if I perchance catch you using %s or %s... You'll be banned from my game, understood?", b(l("splash weapons")), b(l("splash magic")));
    mesc l("-- In such event, Candor Underground B4F will be permanently unreachable for this char."), 1;
    if (is_master() && !$@CAPTURE_FLAG) {
        next;
        select
            l("Ok"),
            l("Toggle Inscription"),
            l("Start");
        mes "";
        if (@menu == 2)
            $@CAPTURE_INSC = !$@CAPTURE_INSC;
        if (@menu == 3) {
            initnpctimer;
            closeclientdialog;
            goto OnMinute25;
        }
    }
    close;

OnForfeit1:
    .@s=true;
OnForfeit2:
    bg_leave();
    mapannounce "006-8", sprintf("%s (%s side) is down!", strcharinfo(0), (.@s ? b("Magenta") : b("Yellow"))), 0;
    end;

OnSpark1:
    .sp1 += 1; end;
OnSpark2:
    .sp2 += 1; end;
    end;
OnSkip:
    end;
OnFinish:
    if (getcharid(4) == .win) {
        Zeny+=670;
        Mobpt+=500;
        dispbottom l("You earned %s Monster Points for winning.", fnum(500));
        CAPTURE_FLAG += 1;
        switch (CAPTURE_FLAG % 11) {
        case 1: getitem MercBoxA, 1; break;
        case 2: getitem any(Aquada, Piberries, Cheese, Bread), 1; break;
        case 3: getitem any(Coffee, ChamomileTea, MysteriousBottle), 1; break;
        case 4: getitem any(Aquada, Piberries, Cheese, Bread), 1; break;
        case 5: getitem any(ReturnPotion, TreasureMap, DungeonMap), 1; break;
        case 6: getitem any(Aquada, Piberries, Cheese, Bread), 1; break;
        case 7: getitem any(SmokeGrenade, DodgePotion), 1; break;
        case 8: getitem any(Aquada, Piberries, Cheese, Bread), 1; break;
        case 9: getitem any(ScrollSCave, InsuranceContract, Insurance), 1; break;
        case 10: getitem any(Aquada, Piberries, Cheese, Bread), 1; break;
        default: getitem any(IcedBottle, PurificationPotion, ScrollSMaggot), 1;
        }
    }
    bg_leave();
    warp "006-8", 44, 66;
    end;

OnInit:
    .distance=4;
    .sp1 = 0; // Sparks killed by Team 1
    .sp2 = 0; // Sparks killed by Team 2
    .win = -2; // Last match winner
    $@CAPTURE_FLAG = false;
    $@CAPTURE_INSC = false;
    $@CAPTURE_T1 = bgnew("006-8", 34, 28, "Kage::OnForfeit1", "Kage::OnForfeit1");
    $@CAPTURE_T2 = bgnew("006-8", 55, 28, "Kage::OnForfeit2", "Kage::OnForfeit2");
    end;

function getmobid {
    .@lv = getarg(0);
    if (.@lv <= 5)
        return HouseMaggot;
    else if (.@lv <= 11)
        return AngryScorpion;
    else if (.@lv <= 15)
        return CaveMaggot;
    else if (.@lv <= 20)
        return AngryBat;
    else if (.@lv <= 26)
        return Bandit;
    else if (.@lv <= 30)
        return Bluepar;
    else if (.@lv <= 35)
        return RobinBandit;
    else if (.@lv <= 40)
        return Snake;
    else if (.@lv <= 46)
        return Wolvern;
    else if (.@lv <= 52)
        return HoodedNinja;
    else if (.@lv <= 60)
        return FallenGuard1;
    else if (.@lv <= 65)
        return Scar;
    else if (.@lv <= 75)
        return Forain;
    else if (.@lv <= 80)
        return Terranite;
    else if (.@lv <= 85)
        return GoboBear;
    else if (.@lv <= 90)
        return TerraniteProtector;
    else if (.@lv <= 100)
        return Reaper;
    else if (.@lv <= 107)
        return Snail;
    else if (.@lv <= 115)
        return Mandragora;
    else if (.@lv <= 120)
        return PinkieMaximus;
    else if (.@lv <= 125)
        return Junglefowl;
    else if (.@lv <= 130)
        return Tengu;
    else if (.@lv <= 135)
        return SuperiorShroom;
    else if (.@lv <= 140)
        return Nutcracker;
    else if (.@lv <= 150)
        return Golem;
    else if (.@lv <= 160)
        return EarthElement;
    else if (.@lv <= 175)
        return EpiphanyWisp;
    // If all else fails, pick the strongest aggro mob
    return EpiphanyWisp;
}

OnMinute15:
    $@CAPTURE_INSC = true;
    mapannounce "006-8", "Kage : Inscriptions are open! The event will begin in ##B10 minutes!##b", 0;
    end;

OnMinute24:
    mapannounce "006-8", "Kage : Inscriptions are about to close! The event will begin in ##B1 minute!##b", 0;
    end;

OnMinute25:
    $@CAPTURE_INSC = false;
    $@CAPTURE_FLAG = true;
    /* Prepare the teams */
    setbgteam $@CAPTURE_T1, 1;
    setbgteam $@CAPTURE_T2, 2;
    /* Validate difficulty */
    .@t1p = bg_get_data($@CAPTURE_T1, 0);
    .@t2p = bg_get_data($@CAPTURE_T2, 0);
    .@t1lv = 0; .@t2lv = 0;
    /* Optional Reinforcements when unbalanced */
    freeloop(true);
    .@c=getunits(BL_PC, .@pcs, MAX_CYCLE_PC, "006-8", 30, 20, 60, 60);
    for (.@i = 0; .@i < .@c; .@i++) {
        .@id = .@pcs[.@i];
        .@n$ = strcharinfo(0, "", .@id);
        .@bg = getcharid(4, .@n$);
        if (.@bg < 1) { consolewarn("Invalid bg for %s (%d): %d",.@m$, .@id, .@bg); continue; } // TODO: Get rid of them
        if (.@bg == $@CAPTURE_T1)
            .@t1lv += readparam(BaseLevel, .@id);
        else if (.@bg == $@CAPTURE_T2)
            .@t2lv += readparam(BaseLevel, .@id);
        else
            consolebug("BG %d is not valid (%d, %d)", .@bg, $@CAPTURE_T1, $@CAPTURE_T2);
    }
    // Calc. averages
    if (.@t1p)
        .@t1a = .@t1lv / .@t1p;
    if (.@t2p)
        .@t2a = .@t2lv / .@t2p;
    // If average is zero...?!
    if (.@t1a && !.@t2a)
        .@t2a = .@t1a;
    if (.@t2a && !.@t1a)
        .@t1a = .@t2a;
    /* Spawn guards as needed... */
    // Normalize player count
    // TODO: Maybe use the other side average, mobs are weak?
    while (.@t1p < .@t2p) {
        .@t1p += 1;
        bg_monster($@CAPTURE_T1, "006-8", 32, rand2(24, 32), "Magenta Ally", getmobid(max(.@t1a, .@t2a)), "Kage::OnSkip");
    }
    while (.@t2p < .@t1p) {
        .@t2p += 1;
        bg_monster($@CAPTURE_T2, "006-8", 53, rand2(24, 32), "Yellow Ally", getmobid(max(.@t1a, .@t2a)), "Kage::OnSkip");
    }
    // TODO: Maybe buff their HP. Also, they didn't attack sparks?
    // Apply a buff on the teams, based on level difference
    .@c=getunits(BL_PC, .@pcs, MAX_CYCLE_PC, "006-8", 30, 20, 60, 60);
    .@t1b = .@t2a - .@t1a; // Team 1 Boost
    .@t2b = .@t1a - .@t2a; // Team 2 Boost
    for (.@i = 0; .@i < .@c; .@i++) {
        .@id = .@pcs[.@i];
        .@n$ = strcharinfo(0, "", .@id);
        .@bg = getcharid(4, .@n$);
        if (.@bg == $@CAPTURE_T1 && .@t1b > 0) {
            sc_start SC_INCMHP, 300000, .@t1b * 1000, 10000, SCFLAG_NOAVOID, .@id;
            sc_start SC_INCATKRATE, 300000, .@t1b, 10000, SCFLAG_NOAVOID, .@id;
            sc_start SC_INCHITRATE, 300000, .@t1b, 10000, SCFLAG_NOAVOID, .@id;
            sc_start SC_INCFLEERATE, 300000, .@t1b, 10000, SCFLAG_NOAVOID, .@id;
        } else if (.@bg == $@CAPTURE_T2 && .@t2b > 0) {
            sc_start SC_INCMHP, 300000, .@t2b * 1000, 10000, SCFLAG_NOAVOID, .@id;
            sc_start SC_INCATKRATE, 300000, .@t2b, 10000, SCFLAG_NOAVOID, .@id;
            sc_start SC_INCHITRATE, 300000, .@t2b, 10000, SCFLAG_NOAVOID, .@id;
            sc_start SC_INCFLEERATE, 300000, .@t2b, 10000, SCFLAG_NOAVOID, .@id;
        }
    }
    freeloop(false);
    // FALLTHROUGH
OnTimer60000:
OnTimer120000:
OnTimer180000:
OnTimer240000:
OnMinute26:
OnMinute27:
OnMinute28:
OnMinute29:
    /* New wave of sparks */
    .@am = 7 + getmapusers("006-8");
    freeloop(true);
    for (.@i=0; .@i < .@am; .@i++) {
        bg_monster($@CAPTURE_T1, "006-8", rand2(31, 44), rand2(21, 35), "Magenta Spark", MagentaSpark, "Kage::OnSpark1");
        bg_monster($@CAPTURE_T2, "006-8", rand2(45, 58), rand2(21, 35), "Yellow Spark", YellowSpark, "Kage::OnSpark2");

    }
    freeloop(false);
    end;

OnTimer300000:
OnMinute30:
    /* Finish the duel! */
    killmonsterall("006-8");
    mapannounce "006-8", sprintf("Kage : Final Score: Magenta %d - %d Yellow", .sp2, .sp1), 0;
    if (.sp2 > .sp1) {
        // More spark 2 killed than spark 1
        mapannounce "006-8", "Kage : ##BMagenta Team##b is the victor!", 0;
        .win = $@CAPTURE_T1;
    } else if (.sp1 > .sp2) {
        mapannounce "006-8", "Kage : ##BYellow Team##b is the victor!", 0;
        .win = $@CAPTURE_T2;
    } else {
        mapannounce "006-8", "Kage : ##BDraw##b! No one has won!", 0;
        .win = -2;
    }
    // Assign rewards
    maptimer("006-8", 10, "Kage::OnFinish");
    /* Cleanup */
    $@CAPTURE_FLAG = false;
    .sp1 = 0;
    .sp2 = 0;
    stopnpctimer;
    end;

}