summaryrefslogblamecommitdiff
path: root/npc/025-1/ctrl.c
blob: cc97a55bf48f3f96f369ea186a5c300ea761e8e3 (plain) (tree)
1
2
3
4
5
6
7
8







                                                                          



                             

                                     
                                                                        
                                                         




                                                                                

                                                                         
                                                         

                                                              










                                         









                                     
                    






                                              
                                           
     


           






                                                                                     
                                                                                   



                                                
 















                                                 











                                         
 
                                                            
                                                       














                                                                                                  
                                         
          
 
       
                               


          




                     


        

 
                                             



                                                                

                         

        
 

                                               


 
 
// TMW2 Script
// Notes: The Monster King will retake the town every
// OnTue0000
// (Tuesday, midnight)
// Only the world hero may begin a siege.
// Only one siege per day is allowed
// Writes to MK Temp Var. This variable will unlock the castle gates
// Then the inner gates, and finally, will be a co-requisite to the floors
// Variables:
//      $FORTRESS_STATE = int
//          0 - Locked
//          1 - Unlocked
//      $@FORTRESS_STATUE = bitmask
//          1,2,4,8... broken statues
// TODO: Use bg() - maybe with dummysd? What will increase allies count?
//       mapwarp() everyone outside when FTCleanup(false)
// TODO: Gate control during siege (not $FORTRESS_STATE). Gate monster.
// TODO: Spawn the monster general for each statue. Count their deaths.
// TODO: Spawn Monster Governor (and add it) once statue is broken. ::OnConquest
// TODO: Record nº of victories. Strengthen the governor.
// TODO: Provide a way to resume failed attempts. Move Phoenix inside.
// TODO: Testing.
//       Use setwall() instead of builtin collision? (Deprecates out NPC)
// TODO: NPCs from inside: Bank. Barber. Aeros Shop. Etc.
// TODO: Spawn inside and outside when siege begins.
// TODO: Heartbeat - (Re)Spawn monsters inside every X seconds

// MAPFLAGS
025-1	mapflag	zone	MMO
025-1	mapflag	nosave	025-2 100 27

/////////////////////////////////////////
// FUNCTIONS

// FTCleanup(status)
function	script	FTCleanup	{
    $FORTRESS_STATE=getarg(0);
    // TODO: Magic Statues (FTStatue)
    $@FORTRESS_STATUE=0;
    //enablenpc "Magic Statue#F_1";
    //enablenpc "Magic Statue#F_2";
    //enablenpc "Magic Statue#F_4";
    //enablenpc "Magic Statue#F_8";
    //enablenpc "Magic Statue#F_16";
    // TODO: Gate
    // TODO: ::OnConquest
    // TODO: Kill stray monsters
    //killmonsterall
    // Main gate
    if ($FORTRESS_STATE) {
        disablenpc "Fortress Gate";
        donpcevent "#025-1_99_112::OnDisable";
    } else {
        enablenpc "Fortress Gate";
        donpcevent "#025-1_99_112::OnEnable";
        mapwarp("025-1", "025-2", 100, 27);
    }
    return;
}

// FTStatue(id)
function	script	FTStatue	{
    .@id=getarg(0);
    mesn l("Magic Statue");
    mes l("There is a reading: The Mana Source. The Moubootaur. The Monster King.");
    mes l("The war. The blood. The inspiration. The mana. The world. The defiance.");
    mes l("The guard. The heir. The originals. The races. The later. The seal.");
    mes l("The fragments. The war. The Terranite. AEGIS MAGNA PROTECTIVE SCUTUM.");
    next;
    mesc l("It seems to be a defensive spell.");
    if ($FORTRESS_STATE)
        return;

    // Break the statues?
    mesc l("Break the Statue?"), 1;
    next;
    if (askyesno() == ASK_YES) {
        if ($@FORTRESS_STATUE & .@id)
            return;
        sc_start SC_STUN, 10000, 1;
        //getmapxy();
        //areamonster();
        //mapannounce();
        //maybe spawn monster governor
        $@FORTRESS_STATUE=$@FORTRESS_STATUE|.@id;
    }

    return;
}










/////////////////////////////////////////
// NPC SCRIPTS

// Main gate - Also where the World Hero can begin the siege
025-1,100,112,0	script	Fortress Gate	NPC_NO_SPRITE,{
    // Main Story block - WHAT
    if ($GAME_STORYLINE < 3)
        die();
    // Still open
    if ($FORTRESS_STATE)
        end;
    // Only World Hero may interact
    if (strcharinfo(0) !=  $MOST_HEROIC$) {
        dispbottom l("I will not assault the Fortress Island. I'll wait for %s.",  $MOST_HEROIC$);
        end;
    }

    // Hey, you can assault the town!
    mesc ".:: "+l("THE FORTRESS ISLAND TOWN") + " ::.", 1;
    mes l("Behind this gate, lies the Fortress Island Town.");
    //monster(FortressGate, ::OnOpenGate)
    close;

OnInit:
    FTCleanup($FORTRESS_STATE);
    end;

OnTue0000:
    FTCleanup(false);
    end;

OnConquest:
    FTCleanup(true);
    end;
}



// This exit must work even if gate is closed
025-1,99,111,0	script	#FortressTownOut	NPC_HIDDEN,1,0,{
    end;

OnTouch:
    if (!$FORTRESS_STATE)
        slide 100, 114;
    end;
}

// TODO: 100,20 - The Impregnable Fortress Gate
// And don't forget the curse timer