summaryrefslogblamecommitdiff
path: root/npc/commands/grantpower.txt
blob: cd88cff2b8f93e5b52325cf9429a10f9496ac580 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                                             
                                    











                                                                                




                                                                




                                                                
                                                                    

                      
                       







                                                                                                           
                                                                                           


                         












                                                               







                                                             







                                                                                                                                                                                                                                                                                                                                                              
                                                                             






                                                                                                                                                                                  
                                                                             


           
            





















































































                                                                                                                                                 

 
// TMW2 Script
//
// @grantpower <username>
// Grants a legendary weapon to <username>. Cannot be undone.
// Only way to bypass restrictions on legendary weapons.

-	script	@grantpower	32767,{
    end;

OnCall:
    .@request$ = "";
	.@request$ += implode(.@atcmd_parameters$, " ");

    // Player is not attached
    .@id = getcharid(3, .@request$);
    if (!.@id) {
        Exception("Player not found.", RB_ISFATAL|RB_DISPBOTTOM);
    }
    mes ".:: " + l("Grant Power") + " ::.";
    mesc l("You're about to transfer a legendary weapon to @@.", .@request$), 1;
    mesc l("This action CANNOT BE UNDONE."), 1;
    mes l("Are you sure?");
    if (askyesno() == ASK_NO)
        close;
    mes "";
    mes ".:: " + l("Grant Power") + " ::.";
    mes l("Please select the weapon to transfer.");
    mes "";
    mesc l("* Options will be removed after transfer is done.");
    mesc l("* Cards will be deleted after transfer is done.");
    mesc l("* Refine will be lost after transfer is done.");
    mes "";
    menuint
        l("None"), 0,
        rif(countitem(DemureAxe), l("Demure's Axe")), DemureAxe,
        rif(countitem(Tyranny), l("Tyranny")), Tyranny,
        rif(countitem(Runestaff), l("Runestaff")), Runestaff,
        rif(countitem(AegisShield), l("Aegis Shield")), AegisShield,
        l("Abort"), 0;
    mes "";
    .@ori=getcharid(3);
    .@ite=@menuret;
    if (!.@ite)
        close;

    // Transfer the weapon
    if (attachrid(.@id)) {
        getitembound .@ite, 1, 1; // Account bound or char bound? (1 or 4)
        dispbottom l("You received the @@ from @@.", getitemlink(.@ite), strcharinfo(0, "someone", .@ori));
        consoleinfo("%s is the new owner for the %s.", strcharinfo(0), getitemname(.@ite));
        detachrid();
        attachrid(.@ori);
        delitem .@ite, 1;
        switch (.@ite) {
            case DemureAxe:
                $DEMUR_HOLDER$ = .@request$; break;
            case Tyranny:
                $TYRAN_HOLDER$ = .@request$; break;
            case Runestaff:
                $RUNES_HOLDER$ = .@request$; break;
            case AegisShield:
                $AEGIS_HOLDER$ = .@request$; break;
            default:
                Exception("Invalid legendary item "+str(.@ite),
                          RB_DEFAULT|RB_IRCBROADCAST); break;
        }
    } else {
        Exception("Player not found.", RB_ISFATAL|RB_SPEECH);
    }

    close;

OnInit:
    bindatcmd "grantpower", "@grantpower::OnCall", 0, 100, 1;
    end;

// Legendary Controls: Interact over legendary holders and determine their status
function legendaryAPIWarning {
    .@aid=getarg(0);
	.@nb = query_sql("SELECT email FROM `login` WHERE `account_id` == "+.@aid+" LIMIT 1", .@email$);
    .@msg$=sprintf("[\"%s\", \"Good evening!\nYou have been inactive for a week on Moubootaur Legends.\n\nYou are currently possessing a Legendary Weapon.\nIf you do not login within seven days, your legendary weapon will be returned so the player community can obtain it again.\n\nYour TMW2 Team\", \"Legendary item expiration notice\"]", .@email$);
    debugmes .@msg$;
    consoleinfo("%d notified for Legendary weapon inactivity. (L:2)", .@aid);
    api_send(API_SENDMAIL, .@msg$);
    return;
}

function legendaryRodexWarning {
    .@cid=getarg(0);
    rodex_sendmail(.@cid, "Legendary Weapon", "Inactivity Warning", "You have not logged in the past 2 days. Shall you fail to login for 15 days, the weapon will be destroyed!");
    consoleinfo("%d notified for Legendary weapon inactivity. (L:1)", .@cid);
    return;
}

OnClock0238:
    .@date=gettimetick(2);
    .@warn=.@date-(86400*2);
    .@kick=.@date-(86400*7);
    .@kban=.@date-(86400*15);
    //////////////////////////////////////////
    if ($LIGHT_HOLDER$ != "") {
    	.@nb = query_sql("SELECT last_login, char_id, account_id FROM `char` WHERE `name` == "+$LIGHT_HOLDER$+" LIMIT 1", .@login, .@cid, .@aid);
        if (.@login < .@kban) {
            // Destroy the item by force
            DelItemFromEveryPlayer(Lightbringer);
            $LIGHT_HOLDER$="";
            kamibroadcast("The Lightbringer has given up on its previous owner and is now available for someone worthier.");
        } else if (.@login < .@kick) {
            // Send warning via API
            legendaryAPIWarning(.@aid);
        } else if (.@login < .@warn) {
            // Send warning ingame
            legendaryRodexWarning(.@cid);
        }
    }
    //////////////////////////////////////////
    if ($DEMUR_HOLDER$ != "") {
    	.@nb = query_sql("SELECT last_login, char_id, account_id FROM `char` WHERE `name` == "+$DEMUR_HOLDER$+" LIMIT 1", .@login, .@cid, .@aid);
        if (.@login < .@kban) {
            // Destroy the item by force
            DelItemFromEveryPlayer(DemureAxe);
            $DEMUR_HOLDER$="";
            kamibroadcast("The Demure Axe has given up on its previous owner and is now available for someone worthier.");
        } else if (.@login < .@kick) {
            // Send warning via API
            legendaryAPIWarning(.@aid);
        } else if (.@login < .@warn) {
            // Send warning ingame
            legendaryRodexWarning(.@cid);
        }
    }
    //////////////////////////////////////////
    if ($TYRAN_HOLDER$ != "") {
    	.@nb = query_sql("SELECT last_login, char_id, account_id FROM `char` WHERE `name` == "+$TYRAN_HOLDER$+" LIMIT 1", .@login, .@cid, .@aid);
        if (.@login < .@kban) {
            // Destroy the item by force
            DelItemFromEveryPlayer(Tyranny);
            $TYRAN_HOLDER$="";
            kamibroadcast("The Tyranny has given up on its previous owner and is now available for someone worthier.");
        } else if (.@login < .@kick) {
            // Send warning via API
            legendaryAPIWarning(.@aid);
        } else if (.@login < .@warn) {
            // Send warning ingame
            legendaryRodexWarning(.@cid);
        }
    }
    //////////////////////////////////////////
    if ($RUNES_HOLDER$ != "") {
    	.@nb = query_sql("SELECT last_login, char_id, account_id FROM `char` WHERE `name` == "+$RUNES_HOLDER$+" LIMIT 1", .@login, .@cid, .@aid);
        if (.@login < .@kban) {
            // Destroy the item by force
            DelItemFromEveryPlayer(Runestaff);
            $RUNES_HOLDER$="";
            kamibroadcast("The Runestaff has given up on its previous owner and is now available for someone worthier.");
        } else if (.@login < .@kick) {
            // Send warning via API
            legendaryAPIWarning(.@aid);
        } else if (.@login < .@warn) {
            // Send warning ingame
            legendaryRodexWarning(.@cid);
        }
    }
    //////////////////////////////////////////
    if ($AEGIS_HOLDER$ != "") {
    	.@nb = query_sql("SELECT last_login, char_id, account_id FROM `char` WHERE `name` == "+$AEGIS_HOLDER$+" LIMIT 1", .@login, .@cid, .@aid);
        if (.@login < .@kban) {
            // Destroy the item by force
            DelItemFromEveryPlayer(AegisShield);
            $AEGIS_HOLDER$="";
            kamibroadcast("The Aegis Shield has given up on its previous owner and is now available for someone worthier.");
        } else if (.@login < .@kick) {
            // Send warning via API
            legendaryAPIWarning(.@aid);
        } else if (.@login < .@warn) {
            // Send warning ingame
            legendaryRodexWarning(.@cid);
        }
    }
    //////////////////////////////////////////
    end;
}