summaryrefslogblamecommitdiff
path: root/npc/001-11/Demure.txt
blob: b663e18765bb467098bbca98993516775b76ccc5 (plain) (tree)
1
2
3
4
5
6
7
8
9
10






                                                            


                
                                

                                                    
                                                                   









                                                                          

             





                                     
                                                                                      
                        

               
                                                    


                                                




                                                                                        

                                                                                                                                                       
                         
                                                                             













                                                                                                 
                                                                        
                                 
                                                                                
                            
                                                                                    

                                                   

                                                     

                                             
                                                          
                                                    


                                                                     
                                                                              

                                              

                                                                                                       


                                            


                                                                                               
                                                                                                              



                                                                        

                                                                                

                                                                    
                                                                                     
                                               
                                                                                                    
                                    
                                                                                                              
 

                                                                                                        
                                                                                                            


                                                                                  

                                                                         

                                               
                                            










                                                                                      

                         
                                                               

                                                                    
                                                                                         



                                                                                                         
                                     

                                                                









                                                                      

                                 

                             





                                                                                        
                                                                                                                                                                                                                                                





                                                                                                                                                                 
                                            
                                                        
                                                                                                                   


                                                                                            
                                                                
         



                             
                                                                
                                                  





                           
                                                                                                                                                                                                                      


                                                                                                              
                                                                                                                                                                            
                 
                                                                                                                                                           
                                                                                                                        


                                                                                                              
                                                                                                                                 


                                                                                                                                    
                                                                                                                                                
                 




                                                                                                                               




                             

                             
                   
                            








                               



                                                       




                                            
                  
 
            
            

                                                                                                                                                                                                                                                 
        

 
// TMW2 scripts.
// Author:
//    Jesusalva
// Description:
//    Valentine Event Master

001-11,40,25,0	script	Demure#Valentine	NPC_FEMALE,{
    goto L_Main;

    // Functions
    function	ScoreValentine {

        mes "##B"+l("Top 10 - Valentine Day")+"##b";
        mesc l("Leaderboard is refresh daily at 11:59 and 23:59!");
	    mes("1." +$@valentine_name$[0]+" ("+$@valentine_value[0]+")");
	    mes("2." +$@valentine_name$[1]+" ("+$@valentine_value[1]+")");
	    mes("3." +$@valentine_name$[2]+" ("+$@valentine_value[2]+")");
	    mes("4." +$@valentine_name$[3]+" ("+$@valentine_value[3]+")");
	    mes("5." +$@valentine_name$[4]+" ("+$@valentine_value[4]+")");
	    mes("6." +$@valentine_name$[5]+" ("+$@valentine_value[5]+")");
	    mes("7." +$@valentine_name$[6]+" ("+$@valentine_value[6]+")");
	    mes("8." +$@valentine_name$[7]+" ("+$@valentine_value[7]+")");
	    mes("9." +$@valentine_name$[8]+" ("+$@valentine_value[8]+")");
	    mes("10."+$@valentine_name$[9]+" ("+$@valentine_value[9]+")");
        next;
    }
    // $@VALENTINE_GIFTSTACKS
    // (account id, gifts to receive)
    // $@VALENTINE_LOVELETTER
    // (account id, list of names)
    function	SendGift {
        mesn;
        mesq l("How many chocolate do you want to send? You can trade: @@", @maximus);
        input @Val_Ammo;
        mes "";

        if (@Val_Ammo > @maximus || @Val_Ammo < 1) {
            mesc l("You don't have that many!");
            return;
        }

        do {
            mesn;
            mesq l("To whom you want to send @@ boxes? Cannot be yourself!", @Val_Ammo);
            mesc l("Leave blank to abort.");
            if (!#VALENTINE_SENT)
                mesc l("(If you don't have anyone special to send these, send to @@. Perhaps they'll calm down with those T.T)", b("Monster King")), 3;
            input .@ref$;
            //debugmes "Sending chocolate to: "+.@ref$; // [DO NOT UNCOMMENT]
            mes "";
            if (.@ref$ != "") {
                .@ref=gf_accid(strip(.@ref$));
                if (.@ref > 0) {
                    if (.@ref == getcharid(3)) {
                        mesn;
                        mesq l("I said it cannot be yourself... </3");
                        next;
                    } else {
                        // Now we do the magic, first of, delete the chocolate and the text input
                        delitem BoxOfChocolates, @Val_Ammo;
                        .@ref$="";

                        // Send the Chocolate
                        .@m = htget($@VALENTINE_GIFTSTACKS, str(.@ref));
                        if (!.@m)
                            htput $@VALENTINE_GIFTSTACKS, str(.@ref), @Val_Ammo;
                        else
                            htput $@VALENTINE_GIFTSTACKS, str(.@ref), .@m+@Val_Ammo;

                        // Get 1 Point per sent box
                        #VALENTINE_POINTS+=@Val_Ammo;
                        #VALENTINE_SENT+=@Val_Ammo;

                        // Handle Love Letter
                        // TODO: Allow multiple attachment
                        if (countitem(LoveLetter)) {
                            mesn;
                            mesq l("Should I attach a love letter?");
                            next;
                            .@totalneed=@Val_Ammo/10+(@Val_Ammo % 10 ? 1 : 0);
                            select
                                l("Yes, one"),
                                //rif(countitem(LoveLetter) >= .@totalneed, l("Yes, %d", .@totalneed)),
                                l("I'll input how many I want to attach."),
                                l("No");
                            mes "";
                            .@reply=@menu-1;
                            // Custom input
                            if (@menu == 2) {
                                mes l("How many %s should I attach?", getitemlink(LoveLetter));
                                mesc l("Recommended: ##B%d##b | Max: %d", .@totalneed, countitem(LoveLetter));
                                input .@totalneed;
                                if (.@totalneed > countitem(LoveLetter))
                                    .@totalneed=countitem(LoveLetter);
                            }
                            if (@menu != 3) {
                                delitem LoveLetter, (.@reply ? .@totalneed : 1);

                                // Register your name on love letter
                                .@s$ = htget($@VALENTINE_LOVELETTER, str(.@ref), "");
                                if (.@s$ == "")
                                    htput $@VALENTINE_LOVELETTER, str(.@ref), strip(strcharinfo(0));
                                else
                                    htput $@VALENTINE_LOVELETTER, str(.@ref), .@s$+", "+strip(strcharinfo(0));

                                // Get the bonus
                                // Old rule: 1 point for 2 boxes, capped at 25 and minimum 1 extra point
                                // Sending over 50 boxes at once won't give bonus, give another Love Letter.
                                //#VALENTINE_POINTS+=min(25, max(1, @Val_Ammo/2));

                                // New rule: Double points up to 10 points
                                .@min=(.@reply ? .@totalneed*10 : 10);
                                #VALENTINE_POINTS+=min(.@min, @Val_Ammo);

                            } // Love Letter OK
                        mesc l("Ok, done!");
                        } // Not yourself
                    } // Valid Person
                } else {
                    mesn;
                    mesq l("Oops, there is nobody known as @@ on this game.", .@ref$);
                    mesq l("Could you try again? There could be a typo!");
                    next;
                } // Invalid Input
            } // Non void input
        } while (.@ref$ != "");
        return;
    }
    function	GetGift {
        .@m = htget($@VALENTINE_GIFTSTACKS, str(getcharid(3)));
        if (.@m > 0) {
            mesq l("Hey, look, you have @@ boxes to collect!", .@m);
            .@n$ = htget($@VALENTINE_LOVELETTER, str(getcharid(3)), l("Secret Admirer"));
            mesq l("They were given with @@ by @@.", any(l("love"), l("passion"), l("affection")), .@n$);

            inventoryplace BoxOfChocolates, .@m;
            getitem BoxOfChocolates, .@m;
            #VALENTINE_RECEIVED+=.@m;
            htput $@VALENTINE_GIFTSTACKS, str(getcharid(3)), 0;
            htput $@VALENTINE_LOVELETTER, str(getcharid(3)), "";

        } else {
            mesq l("Sorry, you don't have any chocolate to pick up.");
        }

        return;
    }

// Script begin
L_Main:
    // Safety Check
    if ($EVENT$ != "Valentine") {
        if (is_staff())
            ScoreValentine();
        warp "Save", 0, 0; end;
    }

    // Demure Main
    mesn;
    mesq l("That annoying guy on the side of the tree is annoying. I want to ban him.");
    tutmes l("Spamming, Scamming and Harassment are major offenses in Moubootaur Legends. Harassing other players (except by giving chocolate on this event) may get you permanently banned. You have been warned!"), l("Reminder about rules");
    next;
    mesn;
    mesq l("Anyway, it is Valentine Day, a good day to trade @@ with your admired one!", getitemlink(BoxOfChocolates));
    next;
    do {
        mesc l("You currently have @@ points, @@ boxes of chocolate and @@ love letters.", #VALENTINE_POINTS, countitem(BoxOfChocolates), countitem(LoveLetter));
        @maximus=countitem(BoxOfChocolates);
        if (#VALENTINE_RECEIVED-#VALENTINE_OPENED > 0) {
            mesc l("@@ boxes of chocolate were given to you as a gift.", #VALENTINE_RECEIVED-#VALENTINE_OPENED), 1;
            // Demure can just send Soren's Chocolate to somebody else.
            // Everyone else cannot send their gift chocolates. Please don't lose the boxes.
            if (!is_gm())
                @maximus-=#VALENTINE_RECEIVED-#VALENTINE_OPENED;
        }
        mes "";
        select
            l("Information"),
            l("Scoreboards"),
            rif(!is_gm() && @maximus >= 0, l("Send Chocolate")),
            rif(!is_gm(), l("Receive Chocolate")),
            l("Okay, bye");
        mes "";

        switch (@menu) {
            case 1:
            mesn;
            mes lg("Valentine Day event consist in gathering @@ and sending them to your loved one.","Valentine Day event consist in gathering @@ and sending them to your loved one.", getitemlink(BoxOfChocolates));
            next;
            mesn;
            mes l("Don't worry if they don't correspond to you. Each box sent will grant you 1 event point.");
            mes l("The prizes are only for the top 10. Loratay on Land Of Fire Village can make, for limited time, a @@ for you if you want.", getitemlink(ValentineDress));
            next;
            mes l("You can optionally send a @@ along the chocolate box, so the person knows it was you who sent the chocolate.", getitemlink(LoveLetter));
            mes l("Sending the letter will give you double event points, but no more than 10 extra points per letter.");
            next;
            mes l("When receiving the chocolate, you must eat it before event ends to get a point for that!");
            mes l("These boxes cannot be sold, but they'll be deleted a while after the event ends.");
            mes l("You also cannot send any boxes before eating any you've received, but Demure is an exception for this rule.");
            next;
            mes l("As with all TMW2 Major Events, the top 1 receive a special pet, and the other ranked ones get diverse rewards.");
            mes l("There might be reward for anyone who doesn't gets a rank, but I never count on that. So, let's start?");
            mesc l("Note: You must have a char on the first slot to leaderboard work. Points are shared accross all chars on your account."), 1;
            next;
            if (gettime(GETTIME_YEAR) == 2020) {
                mesc l("During Valentine 2020, you can get event equipment with the Soul Stone.");
                mesc l("On the friday, the 14th, an additional hunting field will be open. Talk to Soul Stone to go there :>");
                next;
            }
            break;
            case 2:
            ScoreValentine();
            break;
            case 3:
            SendGift(); next;
            break;
            case 4:
            GetGift(); next;
            break;
        }
    } while (@menu != 5);
    closedialog;
    goodbye;
    close;

OnInit:
    .@npcId = getnpcid(.name$);
    setunitdata(.@npcId, UDT_HEADTOP, Cap);
    setunitdata(.@npcId, UDT_HEADMIDDLE, RedStockings);
    setunitdata(.@npcId, UDT_HEADBOTTOM, BunnyEars);
    setunitdata(.@npcId, UDT_WEAPON, GMRobe);
    setunitdata(.@npcId, UDT_HAIRSTYLE, 14);
    setunitdata(.@npcId, UDT_HAIRCOLOR, 18);

    .sex = G_FEMALE;
    .distance = 5;
    // fallthrough

OnClock2359:
OnClock1159:
    if (season() == WINTER)
        .@nb = query_sql("SELECT c.name, i.value FROM `acc_reg_num_db` AS i, `char` AS c WHERE i.key='#VALENTINE_POINTS' AND i.account_id=c.account_id AND c.char_num='0' ORDER BY i.value DESC LIMIT 10", $@valentine_name$, $@valentine_value);
    end;
}