summaryrefslogblamecommitdiff
path: root/world/map/npc/functions/clear_vars.txt
blob: 905528ae74cc6008964f7bd3441b284444327fb0 (plain) (tree)
1
2
3
4
5
6

                       
                                
 

                       












































                       

                                   















































                                                                                         










                                     

                                 


                                                             

                                 

                                                        

                                                           

                                                                                
 




                                                                                                           




                                                                                                          






                                                                                                  
                                                                     

                                                   

                                           

                                                

                           







                                              



                                                



                         

        
                              
                        
 
                  

                                          
           

           
                                  

                        
 
 


                                                                                      
                                   
 
                                    




                                                
                  

         
                                                        

                                                                                            
                      
                   

                  



                                                                                                  
                      
                   

                  



                                                                                                      
                      
                   

                   



                                                                                                       
                     
                    

                 



                                                                                                     
                     
                  

                           



                                                                                                        

                



           

                             

        



                                                                                
                       















                                                                 
                     







































                                                                                          
// Clears old variables

function|script|ClearVariables|,
{
    set EasterQuest, 0;

    // Halloween 2006
    set HWQUEST1, 0;
    set HWQUEST2, 0;
    set HWQUEST3, 0;
    set HWQUEST4, 0;
    set HWQUEST5, 0;
    set HWQUEST6, 0;
    set HWQUEST7, 0;
    set HWQUEST8, 0;
    set HWQUEST9, 0;
    set HWQUEST10, 0;
    set HWQUEST11, 0;
    set HWQUEST12, 0;
    set HWQUEST13, 0;
    set HWQUEST14, 0;
    set HWQUEST15, 0;
    set HWQUEST16, 0;
    set HWQUEST17, 0;
    set HWQUEST18, 0;
    set HWQUEST18, 0;
    set HWQUEST19, 0;
    set HWQUEST20, 0;

    // Christmas 2006
    set XMASQUEST1, 0;
    set XMASQUEST2, 0;
    set XMASQUEST3, 0;
    set XMASQUEST4, 0;
    set XMASQUEST5, 0;
    set XMASQUEST6, 0;
    set XMASQUEST7, 0;
    set XMASQUEST8, 0;
    set XMASQUEST9, 0;
    set XMASQUEST10, 0;
    set XMASQUEST11, 0;
    set XMASQUEST12, 0;
    set XMASQUEST13, 0;
    set XMASQUEST14, 0;
    set XMASQUEST15, 0;
    set XMASQUEST16, 0;
    set XMASQUEST17, 0;
    set XMASQUEST18, 0;
    set XMASQUEST19, 0;
    set XMASQUEST20, 0;

    set QUEST_Halloween07_state, 0;

    set QUEST_xmas07_state, 0;
    set QUEST_xmas07_milk, 0;
    set QUEST_xmas07_cookies, 0;
    set QUEST_xmas07_presents, 0;

    set QUEST_Easter08_state, 0;

    set Halloween08, 0;

    set QUEST_xmas08_state, 0;

    set QUEST_Easter09, 0;

    set Candyman, 0; // Halloween 2009

    set QUEST_Christmas09_state, 0;

     set QUEST_Easter09_slots, 0;

    // easter 2010
    // This must not be cleared: since some people would like to go to the easter island!
    // set Easter_2010_QuestState, 0;
    set Easter_2010_EggState1, 0;
    set Easter_2010_EggState2, 0;
    set Easter_2010_EggState3, 0;
    set Easter_2010_EggState4, 0;
    set Easter_2010_EggState5, 0;

    // halloween 2010
    set hween10, 0;
    set hween10_collect_canpump, 0;
    set hween10_credits, 0;
    set hween10_collect, 0;
    set hween10_collect_mmallow, 0;
    set hween10_collect_jelskul, 0;
    set hween10_bonecount, 0;
    set hween10_collect_tondel, 0;
    set hween10_paid, 0;

    // Xmas 2010:
    set Count_Yellow, 0;
    set Count_White, 0;
    set Maze, 0;
    set Yellow, 0;
    set White, 0;
    set Xmas2010, 0;
    set Golbenez_Inn_Cost, 0;

    set QUEST_Easter11, 0;

    // contains bad karma information
    // set hw2011, 0;

    set xmas11, 0;

    set QUEST_Easter12, 0;

    set xmas2012, 0;

    set QUEST_clothdyer_angus, 0;

    // Tulimshar and Mine Variables which aren't used anymore
    set Scorp, 0;
    set Bugleg, 0;
    // variable isn't used
    set QUEST_clothdyer_state, 0;
    // variable was moved to a temporary player variable
    set KatzeBeenOutside, 0;
    // variable was moved to Nibble 1 of the variable Katze
    set LastHiss, 0;
    // quest was turned into a Daily Quest, so the variable isn't needed anymore
    set CaveSnakeLamp, 0;

    // move Scythe quest into bitmasked variable QUEST_Hurnscald
    if (QUEST_Scythe_state)
        set QUEST_Hurnscald, (QUEST_Hurnscald & ~(NIBBLE_1_MASK)) | (QUEST_Scythe_state << NIBBLE_1_SHIFT);
    set QUEST_Scythe_state, 0;

    // move Demon Mask quest into bitmasked variable QUEST_Hurnscald
    if (QUEST_demon_mines)
        set QUEST_Hurnscald, (QUEST_Hurnscald & ~(NIBBLE_2_MASK)) | (QUEST_demon_mines << NIBBLE_2_SHIFT);
    set QUEST_demon_mines, 0;

    // move Inspector quest into bitmasked variable QUEST_Hurnscald
    set @inspector, ((QUEST_Hurnscald & NIBBLE_3_MASK) >> NIBBLE_3_SHIFT);
    if (Inspector > @inspector)
        set QUEST_Hurnscald, (QUEST_Hurnscald & ~(NIBBLE_3_MASK)) | (Inspector << NIBBLE_3_SHIFT);
    set Inspector, 0;
    set @inspector, 0;

    //These lines are needed to migrate stuff from variables to flags
    if (Open_Underground_Palace_Barrier)
        set FLAGS, FLAGS | FLAG_OPENED_UNDERGROUND;
    set Open_Underground_Palace_Barrier, 0;

    if (Naem_Quest_Done)
        set FLAGS, FLAGS | FLAG_GOT_NAEM_GLOVES;
    set Naem_Quest_Done, 0;

    if (ChristmasQuest)
        set FLAGS, FLAGS | FLAG_SNOWMAN;
    set ChristmasQuest, 0;

    if (ChristmasQuest2)
        set FLAGS, FLAGS | FLAG_SANTAS_HELPER;
    set ChristmasQuest2, 0;

    if (ChestQuest)
        set FLAGS, FLAGS | FLAG_HURNSMINE_CHEST;
    set ChestQuest, 0;

    if (#BankAccount < 0)
        goto FixBank;

    return;

FixBank:
    if (Zeny >= -#BankAccount)
        goto L_Fix_Full;

    // Partial fix
    set #BankAccount, #BankAccount + Zeny;
    set Zeny, 0;
    return;

L_Fix_Full:
    set Zeny, Zeny + #BankAccount;
    set #BankAccount, 0;
    return;
}

// The variable TMW_Quest was used to save the progress in several subquests linearly.
// The subquests are moved to different nibbles of other variables
// to make it possible to do some of the quests in parallel.
function|script|ClearVarTMW_Quest|,
{
    if (TMW_Quest == 0) goto L_Done;
    if (TMW_Quest <= 6)  goto L_Bernard_Mikhail;
    if (TMW_Quest <= 8)  goto L_Sarah;
    if (TMW_Quest <= 10)  goto L_Vincent;
    if (TMW_Quest <= 12)  goto L_Sandra;
    if (TMW_Quest <= 40)  goto L_Desert;
    goto L_Bandit;

L_Bandit:
// move Bandit subquest into Nibble 0 of QUEST_Hurnscald
    set @bandit, TMW_Quest - 40;
    set QUEST_Hurnscald, (QUEST_Hurnscald & ~(NIBBLE_0_MASK) | (@bandit << NIBBLE_0_SHIFT));
    set TMW_Quest, 40;
    set @bandit, 0;
    goto L_Desert;

L_Desert:
// move guard and miner subquest into Byte 2 (Nibble 4 and 5) of QUEST_SouthTulimshar
    set @miners, TMW_Quest - 12;
    set QUEST_SouthTulimshar, (QUEST_SouthTulimshar & ~(BYTE_2_MASK) | (@miners << BYTE_2_SHIFT));
    set TMW_Quest, 12;
    set @miners, 0;
    goto L_Sandra;

L_Sandra:
// move Sandra subquest into Nibble 3 of QUEST_SouthTulimshar
    set @sandra, TMW_Quest - 10;
    set QUEST_SouthTulimshar, (QUEST_SouthTulimshar & ~(NIBBLE_3_MASK) | (@sandra << NIBBLE_3_SHIFT));
    set TMW_Quest, 10;
    set @sandra, 0;
    goto L_Vincent;

L_Vincent:
// move Vincent subquest into Nibble 2 of QUEST_SouthTulimshar
    set @vincent, TMW_Quest - 8;
    set QUEST_SouthTulimshar, (QUEST_SouthTulimshar & ~(NIBBLE_2_MASK) | (@vincent << NIBBLE_2_SHIFT));
    set TMW_Quest, 8;
    set @vincent, 0;
    goto L_Sarah;

L_Sarah:
// move Sarah subquest into Nibble 1 of QUEST_SouthTulimshar
    set @sarah, TMW_Quest - 6;
    set QUEST_SouthTulimshar, (QUEST_SouthTulimshar & ~(NIBBLE_1_MASK) | (@sarah << NIBBLE_1_SHIFT));
    set TMW_Quest, 6;
    set @sarah, 0;
    goto L_Bernard_Mikhail;

L_Bernard_Mikhail:
// move Bernard and Mikhail subquest into Nibble 0 of QUEST_SouthTulimshar
    set QUEST_SouthTulimshar, (QUEST_SouthTulimshar & ~(NIBBLE_0_MASK) | (TMW_Quest << NIBBLE_0_SHIFT));
    set TMW_Quest, 0;
    goto L_Done;

L_Done:
    return;
}

-|script|#ClearGlobalVars|-1,
{
    end;

OnInit:

// Clear some entries of the arrays which save the Fluffy Hunting highscore list
    set $@loop, 5;
    goto L_FluffyClear;

L_FluffyClear:
    if ($@loop == 12)
        goto L_IlliaClear;

    set $Record_Fluffy_Name$[$@loop], "";
    set $Record_Fluffy_Date$[$@loop], "";
    set $Record_Fluffy_Kills[$@loop], 0;

    set $@loop, $@loop + 1;
    goto L_FluffyClear;


// Clear the array which saves the teams who beat the Illia quest
L_IlliaClear:
    set $@loop, 0;
    goto L_IlliaLoop;

L_IlliaLoop:
    if ($Illia_Win_Records$[$@loop] == "")
        goto L_EventClear;

    set $Illia_Win_Records$[$@loop], "";

    set $@loop, $@loop + 1;
    goto L_IlliaLoop;

L_EventClear:
    set $@loop, 0;

// Clear global variable used in the Halloween event 2009
    set $CandyOpsComplete, 0;

// Clear global variables used in the Easter event 2010
    set $Easter_2010_Npc_State1, 0;
    set $Easter_2010_Npc_State2, 0;
    set $Easter_2010_Egg_Loc_State1, 0;
    set $Easter_2010_Egg_Loc_State2, 0;
    set $Easter_2010_Egg_Loc_State3, 0;
    set $Easter_2010_Egg_Loc_State4, 0;
    set $Easter_2010_Egg_Loc_State5, 0;

// Clear global variables used in the Halloween event 2010
    set $hween10, 0;
    set $hween10_tondel, 0;
    set $hween10_mmallow, 0;
    set $hween10_jelskul, 0;
    set $hween10_canpump, 0;

// Clear global variable used in Christmas event 2010
    set $Golbenez_Inn_Cost, 0;

// Variable was used in Voltain's script, was renamed and turned into a temporary variable
    set $state, 0;

    end;
}