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











                                                             
                     
                              







                                                                                                 

                             
                                    











                                                                                




                                                                




                                                                
                                                                    

                      
                       










                                                                                                           












                                                               







                                                             

















                                                                                                                                                                                                                                                                                                                                                              
            





















































































                                                                                                                                                 

 
// 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$, " ");
    if (is_admin()) {
        if (!$LEGENDARYINIT) {
            inventoryplace Lightbringer, 3; // Script Handled: LB and AS
            getitembound DemureAxe, 1, 1;
            getitembound Tyranny, 1, 1;
            getitembound Runestaff, 1, 1;
            $LEGENDARYINIT=true;
            Exception("Legendary weapons not previously initialized.", RB_ISFATAL|RB_DISPBOTTOM);
        }
    }

    // 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));
        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$;
    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!");
    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;
}