-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboutique.patch
387 lines (381 loc) · 14.2 KB
/
boutique.patch
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
--- src/game/Level0.cpp.orig 2009-09-04 15:27:17.000000000 +0200
+++ src/game/Level0.cpp 2009-09-04 21:58:27.000000000 +0200
@@ -29,6 +29,7 @@
#include "revision.h"
#include "revision_nr.h"
#include "Util.h"
+#include "ObjectMgr.h"
bool ChatHandler::HandleHelpCommand(const char* args)
{
@@ -261,3 +262,310 @@
PSendSysMessage(LANG_MOTD_CURRENT, sWorld.GetMotd());
return true;
}
+
+//! Boutique par NiCkOoS
+bool ChatHandler::HandleBoutiqueAchatLevelCommand(const char* args)
+{
+ Player* character = m_session->GetPlayer();
+ uint32 boutiquecredits;
+ int32 remaining;
+ uint32 gain;
+ uint32 prix;
+ std::string name;
+ if(character){
+ QueryResult* result = loginDatabase.PQuery("SELECT `credits` FROM `account` WHERE `id` = '%u'",character->GetSession()->GetAccountId());
+ if(!result)
+ return true;
+
+ Field* fields = result->Fetch();
+ if(!fields)
+ return true;
+
+ boutiquecredits = fields[0].GetUInt32();
+ if(boutiquecredits <= 0){
+ PSendSysMessage("Vous n'avez pas de Credits, veuillez recharger votre compte.");
+ return true;
+ }
+
+ name = character->GetName();
+ int32 oldlevel = character->getLevel();
+ QueryResult* result2 = WorldDatabase.PQuery("SELECT `gain`,`prix` FROM `boutique_level` WHERE `level_max` > '%u' AND level_min <= '%u'",oldlevel,oldlevel);
+
+ if(!result2)
+ return true;
+
+ Field* fields2 = result2->Fetch();
+ gain = fields2[0].GetUInt32();
+ prix = fields2[1].GetUInt32();
+ remaining = boutiquecredits - prix;
+ if(remaining < 0){
+ PSendSysMessage("Vous n'avez pas assez de credits, cet objet coute %u credits.",prix);
+ return true;
+ }
+
+ int32 newlevel = oldlevel + gain;
+ character->GiveLevel(newlevel);
+ character->InitTalentForLevel();
+ character->SetUInt32Value(PLAYER_XP,0);
+ loginDatabase.PQuery("UPDATE `account` SET `credits` = '%u' WHERE `id` = '%u'",remaining,character->GetSession()->GetAccountId());
+ PSendSysMessage("Achat effectue, vous avez recu %u Levels. Il vous reste %u credits.",gain,remaining);
+ character->SaveToDB();
+ }
+ return true;
+}
+
+bool ChatHandler::HandleBoutiqueAchatItemCommand(const char* args)
+{
+ char* boutiqueid = strtok ((char*)args, " ");
+ if(!boutiqueid)
+ return true;
+
+ int32 boutiqueid2 = (int32)atoi(boutiqueid);
+ Player* character = m_session->GetPlayer();
+ uint32 boutiquecredits;
+ int32 remaining;
+ uint32 prix;
+ uint32 count;
+ uint32 itemid;
+ std::string name;
+ if(character){
+ QueryResult* result = loginDatabase.PQuery("SELECT `credits` FROM `account` WHERE `id` = '%u'",character->GetSession()->GetAccountId());
+ if(!result)
+ return true;
+
+ Field* fields = result->Fetch();
+ if(!fields)
+ return true;
+
+ boutiquecredits = fields[0].GetUInt32();
+ if(boutiquecredits <= 0){
+ PSendSysMessage("Vous n'avez pas de Credits, veuillez recharger votre compte.");
+ return true;
+ }
+
+ name = character->GetName();
+ QueryResult* result2 = WorldDatabase.PQuery("SELECT `itemid`,`count`,`prix` FROM `boutique_item` WHERE `itemid` LIKE '%u'",boutiqueid2);
+ if(!result2){
+ PSendSysMessage("Vous n'avez pas chosi un objet valide : %u .",boutiqueid2);
+ return true;
+ }
+
+ Field* fields2 = result2->Fetch();
+ itemid = fields2[0].GetUInt32();
+ count = fields2[1].GetUInt32();
+ prix = fields2[2].GetUInt32();
+ remaining = boutiquecredits - prix;
+ if(remaining < 0){
+ PSendSysMessage("Vous n'avez pas assez de credits, cet objet coute %u credits.",prix);
+ return true;
+ }
+
+ ItemPosCountVec dest;
+ ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype >(itemid);
+ if(!pProto){
+ PSendSysMessage("L'item %u est introuvable dans les donnees.", boutiqueid2);
+ return true;
+ }
+
+ uint8 msg = character->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemid, count, false);
+ if(msg == EQUIP_ERR_OK){
+ Item* item = character->StoreNewItem(dest, itemid, count, true);
+ character->SendNewItem(item,count,true,false);
+ }else{
+ PSendSysMessage("Impossible d'ajouter l'article %s x %u", pProto->Name1, count);
+ PSendSysMessage("Vos sacs semblent remplis ou l'objet est unique.",boutiqueid2,remaining);
+ return true;
+ }
+
+ loginDatabase.PQuery("UPDATE `account` SET `credits` = '%u' WHERE `id` = '%u'",remaining,character->GetSession()->GetAccountId());
+ character->SaveToDB();
+ if(count > 1){
+ PSendSysMessage("Achat effectue, vous avez recu l'item %u x %u. Il vous reste %u Credits.",count,boutiqueid2,remaining);
+ }else{
+ PSendSysMessage("Achat effectue, vous avez recu l'item %u. Il vous reste %u Credits.",boutiqueid2,remaining);
+ }
+ }
+ return true;
+}
+
+bool ChatHandler::HandleBoutiqueAchatMoneyCommand(const char* args)
+{
+ Player* character = m_session->GetPlayer();
+ uint32 boutiquecredits;
+ uint32 gain;
+ int32 remaining;
+ uint32 prix;
+ std::string name;
+ if(character){
+ QueryResult* result = loginDatabase.PQuery("SELECT `credits` FROM `account` WHERE `id` = '%u'",character->GetSession()->GetAccountId());
+ if(!result)
+ return true;
+
+ Field* fields = result->Fetch();
+ if(!fields)
+ return true;
+
+ boutiquecredits = fields[0].GetUInt32();
+ if(boutiquecredits <= 0){
+ PSendSysMessage("Vous n'avez pas de credits, veuillez recharger votre compte.");
+ return true;
+ }
+ name = character->GetName();
+ int32 oldlevel = character->getLevel();
+ QueryResult* result2 = WorldDatabase.PQuery("SELECT `gain`,`prix` FROM `boutique_money` WHERE `level_max` >= '%u' AND level_min <= '%u'",oldlevel,oldlevel);
+ if(!result2)
+ return true;
+
+ Field* fields2 = result2->Fetch();
+ gain = fields2[0].GetUInt32();
+ prix = fields2[1].GetUInt32();
+ remaining = boutiquecredits - prix;
+ if(remaining < 0){
+ PSendSysMessage("Vous n'avez pas assez de credits, cet objet coute %u credits.",prix);
+ return true;
+ }
+
+ character->ModifyMoney( gain );
+ loginDatabase.PQuery("UPDATE `account` SET `credits` = '%u' WHERE `id` = '%u'",remaining,character->GetSession()->GetAccountId());
+ gain = gain / 10000;
+ PSendSysMessage("Achat effectue, vous avez recu %u Pieces d'Or. Il vous reste %u credits.",gain,remaining);
+ character->SaveToDB();
+ }
+ return true;
+}
+
+bool ChatHandler::HandleBoutiquePrixLevelCommand(const char* args)
+{
+ Player* character = m_session->GetPlayer();
+ uint32 boutiquecredits;
+ int32 remaining;
+ uint32 gain;
+ uint32 prix;
+ std::string name;
+ if(character){
+ QueryResult* result = loginDatabase.PQuery("SELECT `credits` FROM `account` WHERE `id` = '%u'",character->GetSession()->GetAccountId());
+ if(!result)
+ return true;
+
+ Field* fields = result->Fetch();
+ if(!fields)
+ return true;
+
+ boutiquecredits = fields[0].GetUInt32();
+ name = character->GetName();
+ int32 oldlevel = character->getLevel();
+ QueryResult* result2 = WorldDatabase.PQuery("SELECT `gain`,`prix` FROM `boutique_level` WHERE `level_max` > '%u' AND level_min <= '%u'",oldlevel,oldlevel);
+ if(!result2)
+ return true;
+
+ Field* fields2 = result2->Fetch();
+ gain = fields2[0].GetUInt32();
+ prix = fields2[1].GetUInt32();
+ remaining = boutiquecredits - prix;
+ PSendSysMessage("Pour recevoir %u Levels, il vous faudra %u credits.",gain,prix);
+ PSendSysMessage("Vous avez %u credits et il vous restera %u credits.",boutiquecredits,remaining);
+ }
+ return true;
+}
+
+bool ChatHandler::HandleBoutiquePrixMoneyCommand(const char* args)
+{
+ Player* character = m_session->GetPlayer();
+ uint32 boutiquecredits;
+ int32 remaining;
+ uint32 gain;
+ uint32 prix;
+ std::string name;
+ if(character){
+ QueryResult* result = loginDatabase.PQuery("SELECT `credits` FROM `account` WHERE `id` = '%u'",character->GetSession()->GetAccountId());
+ if(!result)
+ return true;
+
+ Field* fields = result->Fetch();
+ if(!fields)
+ return true;
+
+ boutiquecredits = fields[0].GetUInt32();
+ name = character->GetName();
+ int32 oldlevel = character->getLevel();
+ QueryResult* result2 = WorldDatabase.PQuery("SELECT `gain`,`prix` FROM `boutique_money` WHERE `level_max` >= '%u' AND level_min <= '%u'",oldlevel,oldlevel);
+ if(!result2)
+ return true;
+
+ Field* fields2 = result2->Fetch();
+ gain = fields2[0].GetUInt32();
+ prix = fields2[1].GetUInt32();
+ remaining = boutiquecredits - prix;
+ PSendSysMessage("Pour recevoir %u pieces d'or, il vous faudra %u credits.",gain,prix);
+ PSendSysMessage("Vous avez %u credits et il vous restera %u credits.",boutiquecredits,remaining);
+ }
+ return true;
+}
+
+bool ChatHandler::HandleBoutiquePrixItemCommand(const char* args)
+{
+ char* boutiqueid = strtok ((char*)args, " ");
+ if(!boutiqueid)
+ return true;
+
+ int32 boutiqueid2 = (int32)atoi(boutiqueid);
+ Player* character = m_session->GetPlayer();
+ uint32 boutiquecredits;
+ int32 remaining;
+ uint32 prix;
+ std::string name;
+ if(character)
+ {
+ QueryResult* result = loginDatabase.PQuery("SELECT `credits` FROM `account` WHERE `id` = '%u'",character->GetSession()->GetAccountId());
+ if(!result)
+ return true;
+
+ Field* fields = result->Fetch();
+ if(!fields)
+ return true;
+
+ boutiquecredits = fields[0].GetUInt32();
+ name = character->GetName();
+ QueryResult* result2 = WorldDatabase.PQuery("SELECT `prix` FROM `boutique_item` WHERE `entry` = '%u'",boutiqueid2);
+ if(!result2)
+ {
+ PSendSysMessage("Vous n'avez pas choisi un article valide : %u.",boutiqueid2);
+ return true;
+ }
+
+ Field* fields2 = result2->Fetch();
+ prix = fields2[0].GetUInt32();
+ remaining = boutiquecredits - prix;
+ PSendSysMessage("Pour recevoir cet article, il vous faudra %u credits.",prix);
+ PSendSysMessage("Vous avez %u credits et il vous restera %u credits.",boutiquecredits,remaining);
+ }
+ return true;
+}
+
+bool ChatHandler::HandleBoutiqueCreditsCommand(const char* args)
+{
+ Player* character = m_session->GetPlayer();
+ uint32 boutiquecredits;
+ if(character)
+ {
+ QueryResult* result = loginDatabase.PQuery("SELECT `credits` FROM `account` WHERE `id` = '%u'",character->GetSession()->GetAccountId());
+ if(!result)
+ return true;
+
+ Field* fields = result->Fetch();
+ if(!fields)
+ return true;
+
+ boutiquecredits = fields[0].GetUInt32();
+ if(boutiquecredits > 0){
+ PSendSysMessage("Vous possedez %u credits ! Allez vite les depenser !",boutiquecredits);
+ }else if(boutiquecredits == 0){
+ PSendSysMessage("Vous n'avez aucun credit ! Allez vite en acheter !");
+ }else{
+ loginDatabase.PQuery("UPDATE `account` SET `credits` = 0 WHERE `id` = '%u'",character->GetSession()->GetAccountId());
+ PSendSysMessage("Vous n'avez aucun credit ! Allez vite en acheter !");
+ }
+ }
+ return true;
+}
+//! Boutique par NiCkOoS
--- src/game/Chat.h.orig 2009-09-04 15:27:06.000000000 +0200
+++ src/game/Chat.h 2009-09-04 16:16:05.000000000 +0200
@@ -487,6 +487,16 @@
bool HandleRepairitemsCommand(const char* args);
bool HandleWaterwalkCommand(const char* args);
+ //! Boutique par NiCkOoS
+ bool HandleBoutiqueAchatItemCommand(const char* args);
+ bool HandleBoutiqueAchatMoneyCommand(const char* args);
+ bool HandleBoutiqueAchatLevelCommand(const char* args);
+ bool HandleBoutiquePrixItemCommand(const char* args);
+ bool HandleBoutiquePrixMoneyCommand(const char* args);
+ bool HandleBoutiquePrixLevelCommand(const char* args);
+ bool HandleBoutiqueCreditsCommand(const char* args);
+ //! Boutique par NiCkOoS
+
//! Development Commands
bool HandleSet32Bit(const char* args);
bool HandleSaveAllCommand(const char* args);
--- src/game/Chat.cpp.orig 2009-09-04 15:27:29.000000000 +0200
+++ src/game/Chat.cpp 2009-09-04 16:15:44.000000000 +0200
@@ -559,6 +559,32 @@
{ NULL, 0, false, NULL, "", NULL }
};
+ //! Boutique par NiCkOoS
+ static ChatCommand BoutiqueAchatCommandTable[] =
+ {
+ { "item", SEC_PLAYER, false, &ChatHandler::HandleBoutiqueAchatItemCommand, "", NULL },
+ { "money", SEC_PLAYER, false, &ChatHandler::HandleBoutiqueAchatMoneyCommand, "", NULL },
+ { "level", SEC_PLAYER, false, &ChatHandler::HandleBoutiqueAchatLevelCommand, "", NULL },
+ { NULL, 0, false, NULL, "", NULL }
+ };
+
+ static ChatCommand BoutiquePrixCommandTable[] =
+ {
+ { "item", SEC_PLAYER, false, &ChatHandler::HandleBoutiquePrixItemCommand, "", NULL },
+ { "money", SEC_PLAYER, false, &ChatHandler::HandleBoutiquePrixMoneyCommand, "", NULL },
+ { "level", SEC_PLAYER, false, &ChatHandler::HandleBoutiquePrixLevelCommand, "", NULL },
+ { NULL, 0, false, NULL, "", NULL }
+ };
+
+ static ChatCommand BoutiqueCommandTable[] =
+ {
+ { "achat", SEC_PLAYER, true, NULL, "", BoutiqueAchatCommandTable },
+ { "prix", SEC_PLAYER, false, NULL, "", BoutiquePrixCommandTable },
+ { "credit", SEC_PLAYER, false, &ChatHandler::HandleBoutiqueCreditsCommand, "", NULL },
+ { NULL, 0, false, NULL, "", NULL }
+ };
+ //! Boutique par NiCkOoS
+
static ChatCommand commandTable[] =
{
{ "account", SEC_PLAYER, true, NULL, "", accountCommandTable },
@@ -644,6 +670,10 @@
{ "repairitems", SEC_GAMEMASTER, true, &ChatHandler::HandleRepairitemsCommand, "", NULL },
{ "waterwalk", SEC_GAMEMASTER, false, &ChatHandler::HandleWaterwalkCommand, "", NULL },
+ //! Boutique par NiCkOoS
+ { "boutique", SEC_PLAYER, true, NULL, "", BoutiqueCommandTable },
+ //! Boutique par NiCkOoS
+
{ NULL, 0, false, NULL, "", NULL }
};