summaryrefslogblamecommitdiff
path: root/npc/011-3/flood.txt
blob: 8f9e6265d4036b1006de85475b45d5abfdc1b82b (plain) (tree)
1
2
3
4
5
6
7
8
9




                              
                                                                                 
                                                                                     
                                                          
                                                     
 






                                                            
                                     
                                                                      





                                                           
        
 
           
           
           
           
           
           
           
           
           
           
           
           

                                          
            
                                                      
                                                                   

               
                                                              

                                                                                      
                                         
                                         
                                            






                               
                               


                                                              
                                                                               
                                                                               
            


                                                           

                       

                                            
 
          
                 



                          
                                                                  
          
 
                                   
                                    
                                                               
                                                
                                                
 
                                                  

                                                               





                                                                 


                                    
 
                                                        
                                                                                                                    
                                                                                 
                                                                                 

                                              
                                                  
                                                                      


         
                                                         



                                 
                                               
                                      
                     
                                           
                     
                                             
                     
                                             
                     
                                             
                      
                                             
                      


                                             
                      
                                         


        
 
// TMW2 scripts.
// Authors:
//    Jesusalva
// Description:
//    Controls Eternal Swamps.
//    Contains functions to flood the map (hide the bridges - mask 1024 + mask 2)
//    Flood happens at random and causes BluePar to be spawn. Runs every 6/4 minutes.
//    At the 6th minute of an hour (6, 16, 26, 36, 46, 56)
//    At the 2nd minute of an hour (2, 14 ... 44, 54)

011-3,0,0,0	script	#EternalSwampCore	NPC_HIDDEN,{
    end;

OnSwampMob:
    end;

OnInit:
    addmapmask "011-3", MASK_SPECIAL;
    bindatcmd "es_flood", "#EternalSwampCore::OnSkipFlood", 99, 99, 1;

    // We need to keep 011-4 in sync with 011-3, dealt here
    addmapmask "011-4", MASK_SPECIAL;
    setcells "011-4", 157, 31, 159, 34, 1, "ESwpRBridge1";
    setcells "011-4", 157, 44, 159, 52, 1, "ESwpRBridge2";
    setcells "011-4", 151, 76, 153, 83, 1, "ESwpRBridge3";
    end;

OnMinute02:
OnMinute06:
OnMinute12:
OnMinute16:
OnMinute22:
OnMinute26:
OnMinute32:
OnMinute36:
OnMinute42:
OnMinute46:
OnMinute52:
OnMinute56:
    // Check if auto-restart was scheduled
    SchedRestart();
OnSkipFlood:
    if ($@GM_OVERRIDE) debugmes "[Flood] Cycle begin";
    .@fd=!(getmapmask("011-3")&MASK_SPECIAL); // .@fd - is flooded?

    if (.@fd) {
        if ($@GM_OVERRIDE) debugmes "[Flood] UF - Unflooding";
        // If it is flooded, unflood it to prevent players getting struck for too long
        killmonster("011-3", "#EternalSwampCore::OnSwampMob");
        addmapmask "011-3", MASK_SPECIAL;
        addmapmask "011-4", MASK_SPECIAL;
        //debugmes "[Flood] UF - Del Cells";
        delcells "ESwpBridge1";
        delcells "ESwpBridge2";
        delcells "ESwpBridge3";
        delcells "ESwpBridge4";
        delcells "ESwpBridge5";
        delcells "ESwpBridge6";
        delcells "ESwpBridge7";
        delcells "ESwpBridge8";
        setcells "011-4", 157, 31, 159, 34, 1, "ESwpRBridge1";
        setcells "011-4", 157, 44, 159, 52, 1, "ESwpRBridge2";
        setcells "011-4", 151, 76, 153, 83, 1, "ESwpRBridge3";
        mapannounce "011-3", "Eternal Swamps: The flood ceases!",bc_all|bc_npc;
        mapannounce "011-4", "Eternal Swamps: The flood ceases!",bc_all|bc_npc;
    } else {
        // 45% chances to flood, 80% during night
        // When raining: floods 60% at day and 95% at night
        .@odds=45;
        if (is_night())
            .@odds+=35;
        if (getmapmask("011-3") & MASK_RAIN)
            .@odds+=15;

        /*
        // Bugfix
        if ($@GM_OVERRIDE)
            .@odds=100;
        else
            .@odds=0;
        debugmes "[Flood] Analysis with %d odds to flood", .@odds;
        */

        // Maybe we should flood it
        if (rand2(0,100) < .@odds) {
            if ($@GM_OVERRIDE) debugmes "[Flood] F - Flooding";
            removemapmask "011-3", MASK_SPECIAL;
            removemapmask "011-4", MASK_SPECIAL;

            //debugmes "[Flood] F - Adding Cells";
            setcells "011-3", 37, 22, 39, 24, 1, "ESwpBridge1";
            setcells "011-3", 37, 34, 39, 41, 1, "ESwpBridge2";
            setcells "011-3", 31, 107, 33, 113, 1, "ESwpBridge3";
            setcells "011-3", 40, 136, 42, 142, 1, "ESwpBridge4";
            setcells "011-3", 38, 170, 40, 176, 1, "ESwpBridge5";
            setcells "011-3", 41, 197, 43, 203, 1, "ESwpBridge6";
            setcells "011-3", 36, 227, 38, 233, 1, "ESwpBridge7";
            setcells "011-3", 31,  67, 33,  72, 1, "ESwpBridge8";
            delcells "ESwpRBridge1";
            delcells "ESwpRBridge2";
            delcells "ESwpRBridge3";

            //debugmes "[Flood] F - Spawn and Announce";
            areamonster "011-3", 20, 20, 60, 260, "Bluepar", Bluepar, rand2(11,29), "#EternalSwampCore::OnSwampMob";
            mapannounce "011-3", "Eternal Swamps: A flood starts!",bc_all|bc_npc;
            mapannounce "011-4", "Eternal Swamps: A flood starts!",bc_all|bc_npc;

            // TODO: Handle players in bridges
            //debugmes "[Flood] F - Map Timer OK";
            maptimer("011-3", 100, "#EternalSwampCore::OnBridgeDown");
        }

    }
    if ($@GM_OVERRIDE) debugmes "[Flood] Cycle finished";
    end;

// Fix players struck by setcells
OnBridgeDown:
    //debugmes "[Flood] [OnBD] Bridge is Down";
    if (isin("011-3", 37, 22, 39, 24))
        slide 38, 21;
    else if (isin("011-3", 37, 34, 39, 41))
        slide 38, 33;
    else if (isin("011-3", 31, 107, 33, 113))
        slide 32, 65;
    else if (isin("011-3", 40, 136, 42, 142))
        slide 41, 95;
    else if (isin("011-3", 38, 170, 40, 176))
        slide 39, 128;
    else if (isin("011-3", 41, 197, 43, 203))
        slide 42, 155;
    else if (isin("011-3", 36, 227, 38, 233))
        slide 37, 185;
    else if (isin("011-3", 31, 67, 32, 72))
        slide 37, 185;
    //debugmes "[Flood] [OnBD] Finished";

    end;
}