summaryrefslogblamecommitdiff
path: root/npc/functions/aurora.txt
blob: 47df65945ce7746125a307fc298640982af3c3a1 (plain) (tree)
1
2
3
4
5
6
7
8
9








                                                                           
                                                                              


                                                                            







                                                                             



                                                          
                         
                                       
                           
                                                                  












                                                                      
 


                                                   



                                                    


                                      




                                           
                       





                                                                      
                       
                                 
                                                                  

              
                         
                                   
                                                                                                     
              
           
                          
                                    
                                                                             

              


                                                                      

              
                             
                       
                                 
                                                                  

              
                             

                               
                                                                                                     

              
                             
                          
                                    
                                                                             

              


                                                                      

              
                             
                       
                                 
                                                                  

              
                             

                               
                                                                                                     

              
                             
                          
                                    
                                                                             

              
                                   


           
 



 













                                                                            




                                






                                                    
                                                        
                                   


                                                              
                            




                    
 





                                         







                                                                                  
                                   

                                   




                                         
 





                                         
                                                                                        







                                        









                                         













                                         







                                         















































                                                                                                                                                                                                                                                     

                                         
                                                           





                                          
 
 
                                                                   
                                         
                               


                                                                                                                                                                                                                                              
                                        


















                                                                                                                                                                                                                      

                                               
          



                                               
          



           
 








                                                    
// TMW2 scripts.
// Authors:
//    Jesusalva
// Description:
//    AURORA EVENT FRAMEWORK
//    Previously known as FY:Event System
//
//    Controls weekly events so Saulc, seeds and I can take vacations.
//    See also: seasons.txt, command/event.txt, event.txt, 003-1/events.txt
//    soulmenhir.txt, scoreboards.txt and, of course, the event maps (if any).
//    Aurora Event Framework functions are called by event.txt
//    specs override and is overriden by those defined in commands/event.txt

// Variables:
//      $MOST_HEROIC$
//          Updated every 2 weeks, the top 1 from previous event
//          Only the hero may begin sieges against Fortress Town.
//          Every NPC will recognize them, and Lightbringer will also
//          pay special attention to them.
//      $FYEVENT_CYCLE
//          Current cycle. I thought in using gettimeparam(WEEK) but gave up.
//      Q_AuroraEvent
//          Quest Variable: DayCtrl, Score, ClaimedControl
//
// Event Specific Variables:
//      $REGNUM_BLESSMAP$
//          Map under Regnum's Blessing
//      $REGNUM_BLESSMAP_H$
//          Human-readable form of the map under Regnum's Blessing
//
//      $FYREWARD_PT
//          Array with minimum points for rewards (primary key)
//      $FYREWARD_ID
//          Array with claimable reward IDs
//      $FYREWARD_AM
//          Array with the amount of the reward ID you'll receive
//      $FYLOGIN_PTS
//          How many event score boost you'll receive for daily login
//
//      $WORLDEXPO_ENEMY$
//          Name of the enemy responsible for ruining the World's Expo


// AEF: BEGIN
function	script	FYNewEvent	{
    debugmes "\033[1mFY event is set to happen...";
    // Aurora Events only begin after Liberation Day
    if ($GAME_STORYLINE < 1)
        return;
    // Update the loop
    $FYEVENT_CYCLE+=1;
    // Overrides standard event system
    $EVENT$="";
    // Delayed cleanup (Just in case)
    DelItemFromEveryPlayer(EventTreasure1);
    DelItemFromEveryPlayer(EventTreasure2);
    DelItemFromEveryPlayer(EventTreasure3);
    DelItemFromEveryPlayer(EventFish);
    // Select the event
    switch ($FYEVENT_CYCLE % 12) {
    case 1:
        $EVENT$="Kamelot";
        kamibroadcast("Kamelot Season is now open!", "Aurora Events");
        break;
    case 2:
        $EVENT$="Expo";
        callfunc("FYEConf_Expo");
        kamibroadcast("World Expo is now open!", "Aurora Events");
        break;
    case 3:
        $EVENT$="Regnum";
        callfunc("FYEConf_Regnum");
        kamibroadcast("Regnum's Blessing: "+$REGNUM_BLESSMAP_H$+" is now blessed!", "Aurora Events");
        break;
    case 4:
        $EVENT$="Fishing";
        callfunc("FYEConf_Fishing");
        kamibroadcast("Catch the Golden Fish is now open!", "Aurora Events");
        break;
    case 5:
        // FIXME: PLACEHOLDER
        $EVENT$="Kamelot";
        kamibroadcast("Kamelot Season is now open!", "Aurora Events");
        break;
    case 6:
        // FIXME: PLACEHOLDER
        $EVENT$="Expo";
        callfunc("FYEConf_Expo");
        kamibroadcast("World Expo is now open!", "Aurora Events");
        break;
    case 7:
        // FIXME: PLACEHOLDER
        $EVENT$="Regnum";
        callfunc("FYE_Regnum");
        kamibroadcast("Regnum's Blessing: "+$REGNUM_BLESSMAP_H$+" is now blessed!", "Aurora Events");
        break;
    case 8:
        // FIXME: PLACEHOLDER
        $EVENT$="Fishing";
        callfunc("FYEConf_Fishing");
        kamibroadcast("Catch the Golden Fish is now open!", "Aurora Events");
        break;
    case 9:
        // FIXME: PLACEHOLDER
        $EVENT$="Kamelot";
        kamibroadcast("Kamelot Season is now open!", "Aurora Events");
        break;
    case 10:
        // FIXME: PLACEHOLDER
        $EVENT$="Expo";
        callfunc("FYEConf_Expo");
        kamibroadcast("World Expo is now open!", "Aurora Events");
        break;
    case 11:
        // FIXME: PLACEHOLDER
        $EVENT$="Regnum";
        callfunc("FYE_Regnum");
        kamibroadcast("Regnum's Blessing: "+$REGNUM_BLESSMAP_H$+" is now blessed!", "Aurora Events");
        break;
    case 12:
        // FIXME: PLACEHOLDER
        $EVENT$="Fishing";
        callfunc("FYEConf_Fishing");
        kamibroadcast("Catch the Golden Fish is now open!", "Aurora Events");
        break;
    }
    donpcevent "Aurora::OnRestore";
    return;
}






// Modify Kamelot
function	script	FYE_Kamelot	{
    .@g=getcharid(2);
    if ($@FYE_KAMELOT[.@g] != gettimeparam(GETTIME_DAYOFMONTH)) {
        mesc l("Kamelot Season is open!");

        // Instance still exists
        if (instanceowner($@KAMELOT_ID[.@g]) == .@g) {
            mesc l("However, your guild just challenged Kamelot Dungeons.");
            mesc l("Please wait a while.");
            return false;
        }
        mesc l("Should we?");
        next;
        askyesno();
        closeclientdialog();

        // Not going? Spoilsport
        if (@menu == ASK_NO)
            return false;

        // Someone began while you waited
        if (instanceowner($@KAMELOT_ID[.@g]) == .@g)
            return true;

        // Begin
        //callfunc("KamelotCleanup", .@g); // Not needed
        $KAMELOT_COOLDOWN[.@g] = 0;
        $@FYE_KAMELOT[.@g] = gettimeparam(GETTIME_DAYOFMONTH);
        mesc l("Have fun!");
        next;
        closeclientdialog();
        return true;
    }
    return false;
}






// Configure Regnum Blessing
function	script	FYEConf_Regnum	{
    setarray .@ma$, "004-1", "007-1", "004-2", "010-2", "014-3", "014-5", "015-5",
                    "018-3", "019-1", "025-2", "025-2-1", "soren";
    setarray .@mb$, "Tulimshar Outskirts", "Tulimshar Mines",
                    "Tulimshar (West) Canyon", "Halinarzo (East) Canyon",
                    "Central Woodlands", "North Woodlands",
                    "Abandoned Mines (Woodlands)", "Somber Caves (LoF)",
                    "Snow Field", "Fortress Island - South",
                    "Fortress Island South Cave", "Soren Island";
    .@m=rand2(getarraysize(.@ma$));
    $REGNUM_BLESSMAP$=.@ma$[.@m];
    $REGNUM_BLESSMAP_H$=.@mb$[.@m];
    // Apply the blessing
    setmapflag(.@ma$[.@m], mf_bexp, 200);
    return;
}






// Configure World Expo
function	script	FYEConf_Expo	{
    $WORLDEXPO_ENEMY$=any("Xakabael the Dark", "Isbamuth", "Saulc", "SUSAN", "Terogan");
    setarray $FYREWARD_PT, 100, 200;
    setarray $FYREWARD_ID, Bread, Bread;
    setarray  $FYREWARD_AM, 1, 2;
    $FYLOGIN_PTS=rand2(18,22);
    return;
}


// Modify Treasure Chests
function	script	FYE_Expo	{
    // TODO: Merit-based random formula
    getitem EventTreasure1, rand2(6);
    getitem EventTreasure2, rand2(4);
    getitem EventTreasure3, rand2(2);
    return;
}






// Configure Fishing
function	script	FYEConf_Fishing	{
    setarray $FYREWARD_PT, 100, 200;
    setarray $FYREWARD_ID, Bread, Bread;
    setarray  $FYREWARD_AM, 1, 2;
    $FYLOGIN_PTS=rand2(6,8);
    return;
}


// Modify Fishing
function	script	FYE_Fishing	{
    // TODO: Merit-based random formula
    getitem EventFish, 1;
    return;
}






// "Submit" button from 003-1/events.txt
// Don't forget to enable it in npc/utils.txt as well!!
function	script	FYE_Submit	{
    .@day=getq(Q_AuroraEvent);
    .@pts=getq2(Q_AuroraEvent);

    // Handle daily login score rewards
    if (.@day != gettimeparam(GETTIME_DAYOFMONTH)) {
        setq1 Q_AuroraEvent, gettimeparam(GETTIME_DAYOFMONTH);
        setq2 Q_AuroraEvent, .@pts+$FYLOGIN_PTS;
        .@pts=getq2(Q_AuroraEvent);
        if ($FYLOGIN_PTS)
            dispbottom l("Daily Event Bonus: %d Points!", $FYLOGIN_PTS);
    }

    // Give you points
    if ($EVENT$ == "Expo") {
        // .:: WORLD EXPO EVENT ::.
        .@pts+=countitem(EventTreasure1)*1;
        .@pts+=countitem(EventTreasure2)*3;
        .@pts+=countitem(EventTreasure3)*5;

        setq2 Q_AuroraEvent, .@pts;
        delitem EventTreasure1, countitem(EventTreasure1);
        delitem EventTreasure2, countitem(EventTreasure2);
        delitem EventTreasure3, countitem(EventTreasure3);
    } else if ($EVENT$ == "Fishing") {
        // .:: CATCH THE GOLD FISH EVENT ::.
        .@pts+=countitem(EventFish)*1;

        setq2 Q_AuroraEvent, .@pts;
        delitem EventFish, countitem(EventFish);
    } else {
        // Wut? This is not an Aurora Event
        Exception($EVENT$+" is NOT a valid Aurora Event; Misdefinition.\n\nPlease ensure that it is defined in utils, aurora, news, and command/event.\n\nFYE_Submit - FYEventUsesRanking - FYE_* - FYEConf_* - FYStopEvent", RB_DEFAULT|RB_ISFATAL);
    }
    return;
}






// Stops any Aurora Event
function	script	FYStopEvent	{
    setarray .@av$, "Kamelot", "Regnum", "Expo", "Fishing";
    if (array_find(.@av$, $EVENT$) >= 0) {
        sClear();
        $EVENT$="";
    }
    return;
}


// Handle the ending of Aurora Events (see also functions/util.txt)
function	script	FYRewardEvent	{
    if (FYEventUsesRanking()) {
        debugmes("Rewards are due");
        // This code absolutely can't fail:
	    .@nb = query_sql("SELECT c.name, i.count2, c.char_id FROM `quest` AS i, `char` AS c WHERE i.quest_id="+Q_AuroraEvent+" AND i.char_id=c.char_id ORDER BY i.count2 DESC LIMIT 10", $@aurora_name$, $@aurora_value, $@aurora_charid);
        $MOST_HEROIC$=$@aurora_name$[0];
        for (.@i=0;.@i < getarraysize($@aurora_charid);.@i++) {
            switch (.@i+1) {
                case 1:
                    .@prize=120; break;
                case 2:
                    .@prize=100; break;
                case 3:
                    .@prize=80; break;
                case 4:
                case 5:
                    .@prize=60; break;
                case 6:
                case 7:
                    .@prize=40; break;
                default:
                    .@prize=20;
            }
            rodex_sendmail($@aurora_charid[.@i], "Aurora Events", $EVENT$+" Reward!", "Final Ranking: #"+(.@i+1)+". Congratulations on making "+$@aurora_value[.@i]+" points on the event!", 0, StrangeCoin, .@prize);
        }
        // Destroy the quest
        DelQuestFromEveryPlayer(Q_AuroraEvent);
        /*
        DelItemFromEveryPlayer(EventTreasure1);
        DelItemFromEveryPlayer(EventTreasure2);
        DelItemFromEveryPlayer(EventTreasure3);
        DelItemFromEveryPlayer(EventFish);
        */
    }
    return;
}


// Normalize Aurora Event after a server restart
function	script	FYE_Normalize	{
    if ($EVENT$ == "Regnum") {
        // Reapply the Regnum's blessing
        setmapflag($REGNUM_BLESSMAP$, mf_bexp, 200);
    }
    return;
}