summaryrefslogtreecommitdiff
path: root/npc/commands/grantpower.txt
blob: 1f867f6e44a5a12683adce69540e5dfdcc0d9cd1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// 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;
}