summaryrefslogblamecommitdiff
path: root/npc/021-4/main.txt
blob: baa2e43d78c3d7d73a82cb3827a87c70e5e7533f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                                                                               














                                                                        





                                                                                  
 
        

                                    
                                                        
                                     
                     






                                               
               

 


                                                                                            
































                                                                                                                                  



                                                                                          

          


           








                          
          









                                         









                                                                          

                
                                      





                                 
        
 
 
// TMW2 scripts.
// Authors:
//    The Mana World Team
//    Jesusalva
// Description:
//    Cindy Cave core logic. You must flip 5 switches to free Cindy, and kill every
//    Yeti to leave the Yeti's King Throne Room. Each passing minute, a new Yeti will
//    spawn. Amount relies on how long this has been dragging on.
//    Flipping switches creates yetis on the other switches.
//    You must try flip all 5 switches at once. Once all switches are flipped, there'll
//    be various waves of Yetis. More time passing = more penalty Yetis, with a safety
//    check to abort script after a hour. If this happen, everyone inside the cave
//    will be banned for cheating. This should not be possible without @monsterignore anyway :<

// Switches
function	script	CindySwitch_Check_214	{
    .@st1=getvariableofnpc(.lifetime, "#CindySwitch_06")-gettimetick(2);
    .@st2=getvariableofnpc(.lifetime, "#CindySwitch_07")-gettimetick(2);
    .@st3=getvariableofnpc(.lifetime, "#CindySwitch_08")-gettimetick(2);
    .@st4=getvariableofnpc(.lifetime, "#CindySwitch_09")-gettimetick(2);
    .@st5=getvariableofnpc(.lifetime, "#CindySwitch_10")-gettimetick(2);
    .@i=0;
    if (.@st1 > 0) .@i++;
    if (.@st2 > 0) .@i++;
    if (.@st3 > 0) .@i++;
    if (.@st4 > 0) .@i++;
    if (.@st5 > 0) .@i++;
    return .@i;
}

021-4,101,33,0	duplicate(#CindySwitch_01)	#CindySwitch_06	NPC_SWITCH_OFFLINE
021-4,90,79,0	duplicate(#CindySwitch_01)	#CindySwitch_07	NPC_SWITCH_OFFLINE
021-4,49,65,0	duplicate(#CindySwitch_01)	#CindySwitch_08	NPC_SWITCH_OFFLINE
021-4,47,21,0	duplicate(#CindySwitch_01)	#CindySwitch_09	NPC_SWITCH_OFFLINE
021-4,80,49,0	duplicate(#CindySwitch_01)	#CindySwitch_10	NPC_SWITCH_OFFLINE

// Cindy
//    Global Variable: $@CINDY_STATE

021-4,66,49,0	script	Cindy#Outside	NPC_CINDY_CAGE,{
    if (getq(NivalisQuest_Cindy) < 4)
        goto L_Cheat;
    if ($@CINDY_STATE > 150000) goto L_Reset;
    if ($@CINDY_STATE % 2 == 0) goto L_Start;
    // Victory check missing
    if (CindySwitch_Check_214() == 5) {
        // Gate open must advance
        setnpcdisplay .name$, NPC_CINDY_UNCAGE;
    }
    hello; end;


L_Cheat:
    warp "Save", 0, 0; atcommand "@jail "+strcharinfo(0); dispbottom l("Cheater detected.");
    end;

L_Reset:
    $@CINDY_STATE=0;
    npctalk l("*beeep*");
    end;

L_Start:
    mesn;
    mesq l("Have you came here to rescue me?");
    mes ""; mes "";
    mesc l(".:: WARNING ::."), 1;
    mesc l("Once you decide to rescue Cindy, nobody else will be able to enter or leave this room."), 1;
    mesc l("The blame of failure will be over you, but so will be the glory of success. There's no death penalty for others."), 1;
    mes "";
    select
        l("Not yet, I'm waiting for friends"),
        l("Yes. Let me try to open this."),
        l("No, I'll let you there to the Yeti's mercy.");

    if (@menu == 2 && $@CINDY_STATE % 2 == 0) {
        $@CINDY_STATE+=1;
        $@CINDY_HERO=strcharinfo(0);
        goto L_Begin;
    }
    close;

L_Begin:
    initnpctimer;
    enablenpc "#CindySwitch_06";
    enablenpc "#CindySwitch_07";
    enablenpc "#CindySwitch_08";
    enablenpc "#CindySwitch_09";
    enablenpc "#CindySwitch_10";

    .@pl = getmapusers("021-4");
    areamonster "021-4", 20, 20, 100, 80, "Yeti", Yeti, .@pl, "Cindy#Outside::OnPetDeath";
    monster "021-4", 66, 49, "Yeti", Yeti, 1, "Cindy#Outside::OnPetDeath";
    close;

OnPetDeath:
    end;

OnReward:
    if (ispcdead()) {
        recovery();
        warp "Save", 0, 0;
        end;
    }
    getexp 10000, 0;
    end;

L_CleanUp:
    .lifetime=0;
    $@CINDY_HERO="";
    disablenpc "#CindySwitch_06";
    disablenpc "#CindySwitch_07";
    disablenpc "#CindySwitch_08";
    disablenpc "#CindySwitch_09";
    disablenpc "#CindySwitch_10";
    setnpcdisplay .name$, NPC_CINDY_CAGE;
    end;

OnTimer1000:
    .@y=mobcount("021-4", "Cindy#Outside::OnPetDeath");
    .@v=CindySwitch_Check_214();
    if (.@y == 0 && .@v >= 5) {
        mapannounce "021-4", "You won.",0;
        areatimer "021-4", 20, 20, 100, 80, 10, "Cindy#Outside::OnReward";
        goto L_CleanUp;
    }
    end;

OnInit:
    .distance=5;
    .lifetime=0; // Controls Yeti Wave
    $@CINDY_HERO="";
    disablenpc "#CindySwitch_06";
    disablenpc "#CindySwitch_07";
    disablenpc "#CindySwitch_08";
    disablenpc "#CindySwitch_09";
    disablenpc "#CindySwitch_10";
    end;
}