]> jfr.im git - irc/gameservirc.git/blame_incremental - gameserv/gameserv.cpp
removed server.txt
[irc/gameservirc.git] / gameserv / gameserv.cpp
... / ...
CommitLineData
1#include "aClient.h"
2#include "config.h"
3#include "extern.h"
4#include "flags.h"
5#include "list.h"
6#include "sockhelp.h"
7
8#include <cctype>
9#include <fstream>
10
11using std::ifstream;
12using std::ofstream;
13
14#if defined(HAVE_CRYPT_H)
15
16#include <crypt.h>
17
18#elif defined(HAVE_UNISTD_H)
19
20#include <unistd.h>
21
22#endif
23
24List<aClient> players;
25
26Monster *monsters[LEVELS][MONSTERS]; // Monsters per level. Total = MONSTERS * LEVELS
27
28Monster *masters[LEVELS]; // A master for each level
29
30// Database functions
31int save_gs_dbase();
32int load_gs_dbase();
33
34// String functions
35#ifndef HAVE_STRTOK
36char *strtok(char *str, const char *delim);
37#endif
38
39int stricmp(const char *s1, const char *s2);
40int strnicmp(const char *s1, const char *s2, size_t len);
41// String Functions
42
43
44/********** Password functions **********/
45
46bool passcmp(char *encrypted, char *plaintext); // Compares an encrypted pass with a plain text one
47
48bool check_password(char *name, char *plaintext); // Finds a password for the given name, and checks it with passcmp against the plaintext password given.
49
50/********** Password functions **********/
51
52
53/********** GameServ Booleans **********/
54
55bool is_playing(char *u); // True if the given nickname in the clients list is playing.
56bool is_playing(aClient *user);
57
58bool is_fighting(char *u); // True if the given nick in the clients list is fighting anything.
59bool is_fighting(aClient *user);
60
61bool player_fight(char *u); // True if the player is fighting another player.
62bool player_fight(aClient *user);
63
64bool master_fight(char *u); // True if the player is fighting their master.
65bool master_fight(aClient *user);
66
67/********** GameServ Booleans **********/
68
69void display_help(char *u, char *file = NULL);
70void display_monster(char *u);
71void display_players(char *u);
72void display_players(aClient *user);
73long int chartoint(char ch);
74int isstringnum(char *num);
75long int pow (int x, int y);
76long int stringtoint(char *number);
77
78char *spaces(int len, char *seperator);
79void refresh(Player *p);
80void refreshall();
81void reset(Player *p);
82void init_masters();
83void init_monsters();
84bool load_monsters();
85void delete_monsters();
86void delete_masters();
87
88void do_admin(char *u);
89void do_attack(char *u);
90void do_bank(char *u);
91void do_fight(char *u);
92void do_heal(char *u);
93void do_help(char *u);
94void do_identify(char *u);
95void do_inventory(char *u);
96void do_refresh(char *u);
97void do_register(char *u);
98void do_list(char *u);
99void do_master(char *u);
100void do_play(char *u);
101void do_quitg(char *u);
102void do_reset(char *u);
103void do_run(char *u);
104void do_stats(char *u);
105void do_store(char *u);
106void do_tavern(char *u);
107void do_use(char *u);
108void see_master(char *u);
109
110void showstats(const char *u, const char *nick);
111void showinventory(aClient *from, aClient *to);
112void showBankBalance(const char *u);
113void end_turn(aClient *user);
114
115#define WNA 16
116char *weapons[WNA] = { "Fists", "Stick", "Dagger", "Quarterstaff", "Short Sword",
117 "Long Sword", "Silver Spear", "Battle Axe", "The Ragnarok",
118 "Chain Saw", "Poison Sword", "Flame Sword", "Earth Hammer",
119 "Light Saber", "Masamune", "Mystical Sword"};
120
121char *armors[WNA] = { "Nothing", "Clothes", "Leather Vest", "Chain Mail", "Plate Armor",
122 "Full Body Armor", "Magic Mail", "Graphite Suit", "Steel Suit",
123 "Force Field", "Armor of Light", "Mythril Vest", "DemiGod Armor",
124 "Hades' Cloak", "Dragon Scales", "Adamantium"};
125
126int prices[WNA - 1] = {200, 1000, 3000, 10000, 30000, 100000, 150000, 200000, 400000,
127 1000000, 4000000, 10000000, 40000000, 100000000, 400000000};
128int webonus[WNA] = {0, 10, 15, 25, 35, 45, 65, 85, 125, 185, 255, 355, 505, 805, 1205, 1805};
129int arbonus[WNA] = {0, 1, 3, 10, 15, 25, 35, 50, 75, 100, 150, 225, 300, 400, 600, 1000};
130
131int hpbonus[11] = {10, 15, 20, 30, 50, 75, 125, 185, 250, 350, 550};
132int strbonus[11] = {5, 7, 10, 12, 20, 35, 50, 75, 110, 150, 200};
133int defbonus[11] = {2, 3, 5, 10, 15, 22, 35, 60, 80, 120, 150};
134
135void gameserv(char *source, char *buf)
136{
137 char *cmd;
138 cmd = strtok(buf, " ");
139
140 #ifndef P10
141 source++; // Get rid of that : at the beginning of a :Nick privmsg Gameserv :text
142 #endif
143
144 if (cmd[0] == ':')
145 cmd++; // Get rid of that : at the beginning of the :text (command)
146
147 #ifdef DEBUGMODE
148 log("Source: %s Command: %s", source, cmd);
149 #endif
150
151 long int mn = midnight() - 12 * 3600; // 12 noon ;)
152
153 if (mn > timestamp)
154 {
155 refreshall();
156 timestamp = mn;
157 save_timestamp();
158 }
159
160 if (strnicmp(cmd, "\1PING", 6) == 0)
161 {
162 char *ts;
163 ts = strtok(NULL, "\1");
164 notice(s_GameServ, source, "\1PING %s\1", ts);
165 } else if (stricmp(cmd, "\1VERSION\1") == 0) {
166 notice(s_GameServ, source, "\1VERSION %s %s +devel\1", PACKAGE, VERSION);
167 } else if (stricmp(cmd, "SEARCH") == 0) {
168 cmd = strtok(NULL, " ");
169
170 if (!cmd)
171 notice(s_GameServ, source, "SYNTAX: /msg %S SEARCH FOREST");
172 else
173 do_forest(source);
174
175 } else if (stricmp(cmd, "FIGHT") == 0) {
176 do_fight(source);
177 } else if (stricmp(cmd, "ATTACK") == 0) {
178 do_attack(source);
179 } else if (stricmp(cmd, "RUN") == 0) {
180 do_run(source);
181 } else if (stricmp(cmd, "USE") == 0) {
182 do_use(source);
183 } else if (stricmp(cmd, "HEAL") == 0) {
184 do_heal(source);
185 } else if (stricmp(cmd, "INVENTORY") == 0) {
186 do_inventory(source);
187 } else if (stricmp(cmd, "MASTER") == 0) {
188 do_master(source);
189 } else if (stricmp(cmd, "STORE") == 0) {
190 do_store(source);
191 } else if (stricmp(cmd, "BANK") == 0) {
192 do_bank(source);
193 } else if (stricmp(cmd, "ADMIN") == 0) {
194 do_admin(source);
195 } else if (stricmp(cmd, "REFRESH") == 0) {
196 do_refresh(source);
197 } else if (stricmp(cmd, "RESET") == 0) {
198 do_reset(source);
199 } else if (stricmp(cmd, "TAVERN") == 0) {
200 do_tavern(source);
201 } else if (stricmp(cmd, "LIST") == 0) {
202 do_list(source);
203 #ifdef DEBUGMODE
204 } else if (stricmp(cmd, "PRINT") == 0) {
205 cout << "Printing the clients list:" << endl;
206 clients.print();
207 cout << "\nPrinting the players list:" << endl;
208 players.print();
209 #endif
210 } else if (stricmp(cmd, "REGISTER") == 0) {
211 do_register(source);
212 } else if (stricmp(cmd, "IDENTIFY") == 0) {
213 do_identify(source);
214 } else if (stricmp(cmd, "HELP") == 0) {
215 do_help(source);
216 } else if (stricmp(cmd, "STATS") == 0) {
217 do_stats(source);
218 } else if (stricmp(cmd, "SHUTDOWN") == 0) {
219 aClient *user;
220
221 if (!(user = find(source)))
222 {
223 notice(s_GameServ, source, "Error: aClient not found. Contact a %S admin");
224 log("Error: aClient not found: %s", source);
225 }
226 else if (!isAdmin(user))
227 {
228 notice(s_GameServ, source, "You must be a %S admin to use this command!");
229 }
230 else
231 {
232 save_gs_dbase();
233 #ifdef P10
234 raw("SQ %s 0 :leaving", servername);
235 #else
236 raw("SQUIT %s :leaving", servername);
237 #endif
238 }
239 } else if (stricmp(cmd, "SAVE") == 0) {
240 aClient *user;
241
242 if (!(user = find(source)))
243 {
244 notice(s_GameServ, source, "Error: aClient not found. Contact a %S admin");
245 log("Error: aClient not found: %s", source);
246 }
247 else if (!isAdmin(user))
248 {
249 notice(s_GameServ, source, "You must be a %S admin to use this command!");
250 }
251 else
252 {
253 save_gs_dbase();
254 }
255 } else if (stricmp(cmd, "LOAD") == 0) {
256 aClient *user;
257
258 if (!(user = find(source)))
259 {
260 notice(s_GameServ, source, "Error: aClient not found. Contact a %S admin");
261 log("Error: aClient not found: %s", source);
262 }
263 else if (!isAdmin(user))
264 {
265 notice(s_GameServ, source, "You must be a %S admin to use this command!");
266 }
267 else
268 {
269 char *cmd2 = strtok(NULL, " ");
270 if (!cmd2)
271 {
272 notice(s_GameServ, source, "Loading player data from %s", playerdata);
273 load_gs_dbase();
274 }
275 else if (stricmp(cmd2, "MONSTERS") == 0)
276 {
277 notice(s_GameServ, source, "Loading monster data from %s", monsterdata);
278 load_monsters();
279 }
280 else
281 display_help(source, cmd);
282 }
283 } else if (stricmp(cmd, "RAW") == 0) {
284 aClient *user;
285
286 if (!(user = find(source)))
287 {
288 notice(s_GameServ, source, "Error: aClient not found. Contact a %S admin");
289 log("Error: aClient not found: %s", source);
290 }
291 else if (!isAdmin(user))
292 {
293 notice(s_GameServ, source, "You must be a %S admin to use this command!");
294 }
295 else
296 {
297 char *rest = strtok(NULL, "");
298 raw("%s", rest);
299 }
300 } else {
301 notice(s_GameServ, source, "Unknown command \002%s\002. Type /msg %S \002HELP\002 to get a list of commands.", cmd);
302 }
303
304 source--; // Bring the ':' back so we don't leak memory
305 cmd--; // Same thing :)
306}
307
308int stricmp(const char *s1, const char *s2)
309{
310 register int c;
311
312 while ((c = tolower(*s1)) == tolower(*s2)) {
313 if (c == 0)
314 return 0;
315 s1++;
316 s2++;
317 }
318 if (c < tolower(*s2))
319 return -1;
320 return 1;
321}
322
323void showstats(const char *u, const char *nick)
324{
325 aClient *ni, *sender = find(u);
326 char *buf;
327 buf = new char[50];
328 char *space;
329
330
331 if (!(ni = findplayer(nick)))
332 {
333 notice(s_GameServ, u, "%s not found", nick);
334 }
335 else if (ni->stats)
336 {
337 notice(s_GameServ, sender->getNick(), "Stats for %s:", ni->stats->name);
338
339 sprintf(buf, "Experience: %ld", ni->stats->exp);
340 space = spaces(strlen(buf), " ");
341 notice(s_GameServ, sender->getNick(), "%s%sLevel: %d", buf, space,
342 ni->stats->level);
343 delete [] space;
344
345 sprintf(buf, "Gold: %ld", ni->stats->gold);
346 space = spaces(strlen(buf), " ");
347 notice(s_GameServ, sender->getNick(), "%s%sGold in Bank: %ld", buf, space, ni->stats->bank);
348 delete [] space;
349
350 notice(s_GameServ, sender->getNick(), "Hit Points: %d of %d", ni->stats->hp,
351 ni->stats->maxhp);
352
353 sprintf(buf, "Strength: %d", ni->stats->strength + webonus[ni->stats->weapon]);
354 space = spaces(strlen(buf), " ");
355 notice(s_GameServ, sender->getNick(), "%s%sDefense: %d",
356 buf, space, ni->stats->defense + arbonus[ni->stats->armor]);
357 delete [] space;
358
359 sprintf(buf, "Armor: %s", armors[ni->stats->armor]);
360 space = spaces(strlen(buf), " ");
361 notice(s_GameServ, sender->getNick(), "%s%sWeapon: %s", buf, space,
362 weapons[ni->stats->weapon]);
363 delete [] space;
364
365 sprintf(buf, "Forest Fights: %d", ni->stats->forest_fights);
366 space = spaces(strlen(buf), " ");
367 notice(s_GameServ, sender->getNick(), "%s%sPlayer Fights: %d", buf, space, ni->stats->player_fights);
368 delete [] space;
369 }
370 else
371 {
372 notice(s_GameServ, u, "%s is not playing!", ni->stats->name);
373 }
374 delete [] buf;
375}
376
377char *spaces(int len, char *seperator)
378{
379 char *final;
380 final = new char[30];
381 int y;
382 strcpy(final, seperator);
383 for (y = 0; y < 30 - len; y++)
384 strcat(final, seperator);
385 return final;
386}
387
388void raw(const char *fmt, ...)
389{
390 va_list args;
391 char *input;
392 const char *t = fmt;
393 input = new char[1024];
394 va_start(args, fmt);
395 memset(input, 0, sizeof(input)); // Initialize to NULL
396 for (; *t; t++)
397 {
398 if (*t == '%')
399 {
400 switch(*++t) {
401 case 'd': sprintf(input, "%s%d", input, va_arg(args, int)); break;
402 case 's': sprintf(input, "%s%s", input, va_arg(args, char *)); break;
403 case 'S': sprintf(input, "%s%s", input, s_GameServ); break;
404 case 'l':
405 if (*++t == 'd')
406 sprintf(input, "%s%ld", input, va_arg(args, long int)); break;
407 }
408 }
409 else
410 {
411 sprintf(input, "%s%c", input, *t);
412 }
413
414 }
415 #ifdef DEBUGMODE
416 log("Input: %s", input);
417 #endif
418
419 sprintf(input, "%s%s", input, "\r\n");
420 sock_puts(sock, input);
421 delete [] input;
422 va_end(args);
423}
424/* Send a NOTICE from the given source to the given nick. */
425
426void notice(const char *source, const char *dest, const char *fmt, ...)
427{
428 if (fmt[0] == '\0')
429 return;
430
431 va_list args;
432 char *input;
433 const char *t = fmt;
434 input = new char[1024];
435 va_start(args, fmt);
436 if (dest[0] == ':')
437 {
438 dest++;
439
440 #if !defined(P10)
441 sprintf(input, ":%s NOTICE %s :", source, dest);
442 #else
443 sprintf(input, "%s O %s :", gsnum, dest);
444 #endif
445
446 dest--;
447 }
448 else
449 {
450 #if !defined(P10)
451 sprintf(input, ":%s NOTICE %s :", source, dest);
452 #else
453 sprintf(input, "%s O %s :", gsnum, dest);
454 #endif
455 }
456
457 for (; *t; t++)
458 {
459 if (*t == '%')
460 {
461 switch(*++t) {
462 case 'd': sprintf(input, "%s%d", input, va_arg(args, int)); break;
463 case 's': sprintf(input, "%s%s", input, va_arg(args, char *)); break;
464 case 'S': sprintf(input, "%s%s", input, s_GameServ); break;
465 case 'l':
466 if (*++t == 'd')
467 sprintf(input, "%s%ld", input, va_arg(args, long int)); break;
468 }
469 }
470 else
471 {
472 sprintf(input, "%s%c", input, *t);
473 }
474
475 }
476 #ifdef DEBUGMODE
477 log("Input: %s", input);
478 #endif
479 sprintf(input, "%s%s", input, "\r\n");
480 sock_puts(sock, input);
481 delete [] input;
482va_end(args);
483}
484
485
486int strnicmp(const char *s1, const char *s2, size_t len)
487{
488 register int c;
489
490 if (!len)
491 return 0;
492 while ((c = tolower(*s1)) == tolower(*s2) && len > 0) {
493 if (c == 0 || --len == 0)
494 return 0;
495 s1++;
496 s2++;
497 }
498 if (c < tolower(*s2))
499 return -1;
500 return 1;
501}
502
503#ifndef HAVE_STRTOK
504char *strtok(char *str, const char *delim)
505{
506 static char *current = NULL;
507 char *ret;
508
509 if (str)
510 current = str;
511 if (!current)
512 return NULL;
513 current += strspn(current, delim);
514 ret = *current ? current : NULL;
515 current += strcspn(current, delim);
516 if (!*current)
517 current = NULL;
518 else
519 *current++ = 0;
520 return ret;
521}
522#endif
523
524void do_list(char *u)
525{
526 ListNode<aClient> *temp;
527 temp = players.First();
528 if (!players.isEmpty())
529 {
530 notice(s_GameServ, u, "People Playing:");
531 while(temp)
532 {
533 notice(s_GameServ, u, "IRC: %s Game: %s", temp->getData()->getNick(), temp->getData()->stats->name);
534 temp = temp->Next();
535 }
536 notice(s_GameServ, u, "End of List");
537 }
538 else
539 notice(s_GameServ, u, "No one is playing");
540}
541
542void do_register(char *u)
543{
544 char *password, *name;
545 aClient *user, *p;
546 name = strtok(NULL, " ");
547 password = strtok(NULL, " ");
548
549 static char saltChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
550 static char salt[3];
551
552 salt[0] = saltChars[rand() % strlen(saltChars)];
553 salt[1] = saltChars[rand() % strlen(saltChars)];
554 salt[2] = '\0';
555
556 if (!name)
557 {
558 notice(s_GameServ, u, "SYNTAX: /msg %S REGISTER NAME PASSWORD");
559 }
560 else if (!password)
561 {
562 notice(s_GameServ, u, "SYNTAX: /msg %S REGISTER NAME PASSWORD");
563 }
564 else if ((user = find(u)))
565 {
566 p = findplayer(u);
567 if (!user->stats && !p)
568 {
569 user->stats = new Player(user);
570 user->stats->user = user; // Set the backwards pointer
571 strcpy(user->stats->password, crypt(password, salt));
572 strcpy(user->stats->name, name);
573 players.insertAtBack(user);
574 notice(s_GameServ, u, "Player %s registered with password %s.", user->stats->name, password);
575 notice(s_GameServ, u, "Write this password down. If you lose it, there is no way to retrieve it!");
576 log("Nickname %s registered player %s.", u, user->stats->name);
577 }
578 else
579 {
580 notice(s_GameServ, u, "Already registered. Contact a %S admin for help.");
581 }
582 }
583}
584
585void do_identify(char *u)
586{
587 char *password, *name;
588 aClient *user, *p;
589 name = strtok(NULL, " ");
590 password = strtok(NULL, " ");
591 user = find(u);
592 if (!password || !name)
593 {
594 notice(s_GameServ, u, "SYNTAX: /msg %S IDENTIFY NAME PASSWORD");
595 }
596 else if (!user)
597 {
598 notice(s_GameServ, u, "Fatal error. Cannot find aClient. Buf: %s", strtok(NULL, ""));
599 log("Error: aClient not found: %s", u);
600 }
601 else if (!(p = findplayer(name)) || !p->stats)
602 notice(s_GameServ, u, "Player %s not found", name);
603 else if (!check_password(name, password) && !isAdmin(user))
604 {
605 notice(s_GameServ, u, "Password incorrect");
606 }
607 else
608 {
609 if (p->stats->user && !isAdmin(user))
610 {
611 notice(s_GameServ, u, "That player has already identified.");
612 return;
613 }
614 if (!user->stats)
615 {
616 ListNode<aClient> *temp;
617 temp = players.Find(p);
618 if (!temp)
619 {
620 notice(s_GameServ, u, "Fatal error. Contact %S Admin. Buf: %s",
621 strtok(NULL, ""));
622 return;
623 }
624 user->stats = new Player(p->stats->name);
625 #ifdef DEBUGMODE
626 log("Setting data for identified");
627 #endif
628 user->stats->setData(p->stats);
629
630 #ifdef DEBUGMODE
631 log("Player Identified");
632 #endif
633
634 temp->setPtr(user);
635
636 notice(s_GameServ, u, "Password Accepted. Identified.");
637
638 }
639 else
640 {
641 notice(s_GameServ, u, "Already identified. Contact a %S admin for help.");
642 }
643 }
644}
645
646void do_stats(char *u)
647{
648 char *nick;
649 aClient *user;
650
651 nick = strtok(NULL, " ");
652
653 if (!nick)
654 {
655 if (!(user = find(u)))
656 {
657 notice(s_GameServ, u, "Fatal Error in do_stats(). Contact a %S admin for help!");
658 log("Error: aClient not found: %s", u);
659 return;
660 }
661 else if (!is_playing(user))
662 {
663 notice(s_GameServ, u, "You're not playing, so you have no stats!");
664 return;
665 }
666 else
667 showstats(u, user->stats->name);
668 }
669 else
670 showstats(u, nick);
671}
672void init_masters()
673{
674 #ifdef DEBUGMODE
675 log("Calling delete_masters()");
676 #endif
677
678 delete_masters();
679
680 #ifdef DEBUGMODE
681 log("Initializing masters");
682 #endif
683
684 for (int x = 0; x < LEVELS; x++)
685 masters[x] = new Monster;
686
687 strcpy(masters[0]->name, "Old Bones");
688 strcpy(masters[0]->weapon, "Dull Sword Cane");
689 masters[0]->strength = 15;
690 masters[0]->gold = 0;
691 masters[0]->exp = 0;
692 masters[0]->maxhp = 30;
693 masters[0]->hp = 30;
694 strcpy(masters[0]->death, "You have done well my student, but the road is long. Use your new strength with humility and honor as you progress in levels!");
695
696 strcpy(masters[1]->name, "Master Chang");
697 strcpy(masters[1]->weapon, "Nanchaku");
698 masters[1]->strength = 30;
699 masters[1]->gold = 0;
700 masters[1]->exp = 0;
701 masters[1]->maxhp = 40;
702 masters[1]->hp = 40;
703 strcpy(masters[1]->death, "You try to make out what Master Chang is saying, but the only thing you catch is something about a grasshopper.");
704
705 strcpy(masters[2]->name, "Chuck Norris");
706 strcpy(masters[2]->weapon, "Ranger Kick");
707 masters[2]->strength = 85;
708 masters[2]->gold = 0;
709 masters[2]->exp = 0;
710 masters[2]->maxhp = 70;
711 masters[2]->hp = 70;
712 strcpy(masters[2]->death, "Be strong, and keep your goals in site. Drink milk, and don't do drugs. One day you may be fighting next to me as a Texas Ranger YEEHAW!");
713
714
715 strcpy(masters[3]->name, "Mr. Miagi");
716 strcpy(masters[3]->weapon, "Petrified Bonsai");
717 masters[3]->strength = 120;
718 masters[3]->gold = 0;
719 masters[3]->exp = 0;
720 masters[3]->maxhp = 120;
721 masters[3]->hp = 120;
722 strcpy(masters[3]->death, "Skill comes from repeating the correct but seemingly mundane actions. Wax ON, wax OFF!");
723
724 strcpy(masters[4]->name, "Jackie Chan");
725 strcpy(masters[4]->weapon, "Kung Fu Kick");
726 masters[4]->strength = 135;
727 masters[4]->gold = 0;
728 masters[4]->exp = 0;
729 masters[4]->maxhp = 200;
730 masters[4]->hp = 200;
731 strcpy(masters[4]->death, "I like to let people talk who like to talk... it's easier to find out how full of it they really are!");
732
733 strcpy(masters[5]->name, "Jet Li");
734 strcpy(masters[5]->weapon, "Motorcycle");
735 masters[5]->strength = 160;
736 masters[5]->gold = 0;
737 masters[5]->exp = 0;
738 masters[5]->maxhp = 400;
739 masters[5]->hp = 400;
740 strcpy(masters[5]->death, "Failure is a fuel for excuses. It's the doing the do, that makes the making.");
741
742
743 strcpy(masters[6]->name, "Muhammad Ali");
744 strcpy(masters[6]->weapon, "Quick Jab");
745 masters[6]->strength = 185;
746 masters[6]->gold = 0;
747 masters[6]->exp = 0;
748 masters[6]->maxhp = 600;
749 masters[6]->hp = 600;
750 strcpy(masters[6]->death, "It's just a job. Grass grows, birds fly, waves pound the sand. I beat people up.");
751
752 strcpy(masters[7]->name, "Li Mu Bai");
753 strcpy(masters[7]->weapon, "Green Destiny");
754 masters[7]->strength = 210;
755 masters[7]->gold = 0;
756 masters[7]->exp = 0;
757 masters[7]->maxhp = 800;
758 masters[7]->hp = 800;
759 strcpy(masters[7]->death, "No growth without resistance. No action without reaction. No desire without restraint.");
760
761
762 strcpy(masters[8]->name, "Jimmy Wang Yu");
763 strcpy(masters[8]->weapon, "Flying Guillotine");
764 masters[8]->strength = 275;
765 masters[8]->gold = 0;
766 masters[8]->exp = 0;
767 masters[8]->maxhp = 1200;
768 masters[8]->hp = 1200;
769 strcpy(masters[8]->death, "You have beaten the one armed boxer. Proceed with caution!");
770
771 strcpy(masters[9]->name, "Wong Fei Hung");
772 strcpy(masters[9]->weapon, "Drunken Boxing");
773 masters[9]->strength = 360;
774 masters[9]->gold = 0;
775 masters[9]->exp = 0;
776 masters[9]->maxhp = 1800;
777 masters[9]->hp = 1800;
778 strcpy(masters[9]->death, "Hiccup! Monkey drinks master's wine!");
779
780 strcpy(masters[10]->name, "Bruce Lee");
781 strcpy(masters[10]->weapon, "Fists of fury");
782 masters[10]->strength = 575;
783 masters[10]->gold = 0;
784 masters[10]->exp = 0;
785 masters[10]->maxhp = 2500;
786 masters[10]->hp = 2500;
787 strcpy(masters[10]->death, "You must learn to concentrate. It is like a finger pointing away to the moon... DONT concentrate on the finger, or you will miss all the heavenly glory.");
788}
789
790void init_monsters()
791{
792 #ifdef DEBUGMODE
793 log("Calling delete_monsters");
794 #endif
795
796 delete_monsters();
797
798 for (int x = 0; x < LEVELS; x++)
799 for (int y = 0; y < MONSTERS; y++)
800 monsters[x][y] = new Monster();
801
802 // Hard coded for now - Kain
803/*
804
805 strcpy(monsters[0][0]->name, "Slime");
806 strcpy(monsters[0][0]->weapon, "Acid Goo");
807 monsters[0][0]->strength = 6;
808 monsters[0][0]->gold = 50;
809 monsters[0][0]->exp = 3;
810 monsters[0][0]->maxhp = 9;
811 strcpy(monsters[0][0]->death, "The slime oozes into nothing... you clean the acid goo off of your weapon");
812
813 strcpy(monsters[0][1]->name, "Ghost");
814 strcpy(monsters[0][1]->weapon, "Cold Breath");
815 monsters[0][1]->strength = 8;
816 monsters[0][1]->gold = 100;
817 monsters[0][1]->exp = 10;
818 monsters[0][1]->maxhp = 10;
819 strcpy(monsters[0][1]->death, "You feel a chill as the spirit leaves the realm.");
820
821 strcpy(monsters[0][2]->name, "Ugly Rodent");
822 strcpy(monsters[0][2]->weapon, "Sharp Teeth");
823 monsters[0][2]->strength = 9;
824 monsters[0][2]->gold = 75;
825 monsters[0][2]->exp = 8;
826 monsters[0][2]->maxhp = 13;
827 strcpy(monsters[0][2]->death, "You stomp on the Ugly Rodent's remains for a finishing blow.");
828
829 strcpy(monsters[0][3]->name, "Whart Hog");
830 strcpy(monsters[0][3]->weapon, "Tusks");
831 monsters[0][3]->strength = 10;
832 monsters[0][3]->gold = 80;
833 monsters[0][3]->exp = 6;
834 monsters[0][3]->maxhp = 10;
835 strcpy(monsters[0][3]->death, "You cook and eat the hog for good measure!");
836
837 strcpy(monsters[0][4]->name, "Pesky Kid");
838 strcpy(monsters[0][4]->weapon, "Slingshot");
839 monsters[0][4]->strength = 8;
840 monsters[0][4]->gold = 30;
841 monsters[0][4]->exp = 4;
842 monsters[0][4]->maxhp = 6;
843 strcpy(monsters[0][4]->death, "You take his slingshot and snap the band, sending the kid crying home to mom!");
844
845 strcpy(monsters[0][5]->name, "Playground Bully");
846 strcpy(monsters[0][5]->weapon, "Painful Noogie");
847 monsters[0][5]->strength = 11;
848 monsters[0][5]->gold = 44;
849 monsters[0][5]->exp = 6;
850 monsters[0][5]->maxhp = 10;
851 strcpy(monsters[0][5]->death, "You give him an indian burn, and punt him across the schoolyard!");
852
853 strcpy(monsters[0][6]->name, "Small Imp");
854 strcpy(monsters[0][6]->weapon, "Dagger");
855 monsters[0][6]->strength = 6;
856 monsters[0][6]->gold = 64;
857 monsters[0][6]->exp = 10;
858 monsters[0][6]->maxhp = 10;
859 strcpy(monsters[0][6]->death, "You can't help but laugh as he stumbles and falls onto his own dagger!");
860
861 strcpy(monsters[0][7]->name, "Little Monkey");
862 strcpy(monsters[0][7]->weapon, "Monkey Wrench");
863 monsters[0][7]->strength = 6;
864 monsters[0][7]->gold = 53;
865 monsters[0][7]->exp = 9;
866 monsters[0][7]->maxhp = 9;
867 strcpy(monsters[0][7]->death, "You want to cook it, but you just can't think of eating something that looks so human!");
868
869 strcpy(monsters[0][8]->name, "Grub Worm");
870 strcpy(monsters[0][8]->weapon, "Minor Nudge");
871 monsters[0][8]->strength = 2;
872 monsters[0][8]->gold = 10;
873 monsters[0][8]->exp = 3;
874 monsters[0][8]->maxhp = 3;
875 strcpy(monsters[0][8]->death, "You decide to save the poor little fella for your next fishing trip.");
876
877 strcpy(monsters[0][9]->name, "Drakee");
878 strcpy(monsters[0][9]->weapon, "Tail Slap");
879 monsters[0][9]->strength = 5;
880 monsters[0][9]->gold = 22;
881 monsters[0][9]->exp = 7;
882 monsters[0][9]->maxhp = 5;
883 strcpy(monsters[0][9]->death, "You pull the little Drakee by its tale and slam it down on a dry stump!");
884
885 strcpy(monsters[0][10]->name, "Fat Slob");
886 strcpy(monsters[0][10]->weapon, "Smelly Breath");
887 monsters[0][10]->strength = 6;
888 monsters[0][10]->gold = 40;
889 monsters[0][10]->exp = 10;
890 monsters[0][10]->maxhp = 7;
891 strcpy(monsters[0][10]->death, "You kick his stomach for fun, and are thrown back by the spring of it all!");
892
893 strcpy(monsters[0][11]->name, "Lost Warrior");
894 strcpy(monsters[0][11]->weapon, "Long Sword");
895 monsters[0][11]->strength = 10;
896 monsters[0][11]->gold = 250;
897 monsters[0][11]->exp = 19;
898 monsters[0][11]->maxhp = 15;
899 strcpy(monsters[0][11]->death, "You give him a proper burial in respect for the dead warrior.");
900
901 strcpy(monsters[1][0]->name, "Lost Warrior's Cousin Larry");
902 strcpy(monsters[1][0]->weapon, "Wood Axe");
903 monsters[1][0]->strength = 19;
904 monsters[1][0]->gold = 134;
905 monsters[1][0]->exp = 24;
906 monsters[1][0]->maxhp = 30;
907 strcpy(monsters[1][0]->death, "He was pretty pissed you killed his cousin, but he seems to have suffered the same fate!");
908
909 strcpy(monsters[1][1]->name, "Sandman");
910 strcpy(monsters[1][1]->weapon, "Sleeping Dust");
911 monsters[1][1]->strength = 25;
912 monsters[1][1]->gold = 80;
913 monsters[1][1]->exp = 6;
914 monsters[1][1]->maxhp = 27;
915 strcpy(monsters[1][1]->death, "You put the sandman to his final sleep.");
916
917 strcpy(monsters[1][2]->name, "Dirty Prostitute");
918 strcpy(monsters[1][2]->weapon, "Stiletto Heel");
919 monsters[1][2]->strength = 21;
920 monsters[1][2]->gold = 160;
921 monsters[1][2]->exp = 12;
922 monsters[1][2]->maxhp = 25;
923 strcpy(monsters[1][2]->death, "Your pimp hand is strong!");
924
925 strcpy(monsters[1][3]->name, "Goblin Gardener");
926 strcpy(monsters[1][3]->weapon, "Garden Spade");
927 monsters[1][3]->strength = 18;
928 monsters[1][3]->gold = 130;
929 monsters[1][3]->exp = 8;
930 monsters[1][3]->maxhp = 20;
931 strcpy(monsters[1][3]->death, "You trample on his garden after slaying him... that felt good!");
932
933 strcpy(monsters[1][4]->name, "Evil Elf");
934 strcpy(monsters[1][4]->weapon, "Dark Bow");
935 monsters[1][4]->strength = 23;
936 monsters[1][4]->gold = 136;
937 monsters[1][4]->exp = 13;
938 monsters[1][4]->maxhp = 24;
939 strcpy(monsters[1][4]->death, "Elves are usually nice you thought... hmm.");
940
941 strcpy(monsters[1][5]->name, "Viking Warrior");
942 strcpy(monsters[1][5]->weapon, "Broad Sword");
943 monsters[1][5]->strength = 21;
944 monsters[1][5]->gold = 330;
945 monsters[1][5]->exp = 20;
946 monsters[1][5]->maxhp = 18;
947 strcpy(monsters[1][5]->death, "You heard vikings were big, but not THAT big you thought.");
948
949 strcpy(monsters[1][6]->name, "Wicked Witch");
950 strcpy(monsters[1][6]->weapon, "Cackling Laugh");
951 monsters[1][6]->strength = 20;
952 monsters[1][6]->gold = 130;
953 monsters[1][6]->exp = 20;
954 monsters[1][6]->maxhp = 26;
955 strcpy(monsters[1][6]->death, "Just for kicks, you splash some water on her and watch her melt.");
956
957 strcpy(monsters[1][7]->name, "Vampire Bat");
958 strcpy(monsters[1][7]->weapon, "Blood Sucking Fangs");
959 monsters[1][7]->strength = 18;
960 monsters[1][7]->gold = 125;
961 monsters[1][7]->exp = 21;
962 monsters[1][7]->maxhp = 29;
963 strcpy(monsters[1][7]->death, "You fry up the bat and eat it... needs garlic.");
964
965 strcpy(monsters[1][8]->name, "Thorn Bush");
966 strcpy(monsters[1][8]->weapon, "101 Thorns");
967 monsters[1][8]->strength = 16;
968 monsters[1][8]->gold = 94;
969 monsters[1][8]->exp = 15;
970 monsters[1][8]->maxhp = 25;
971 strcpy(monsters[1][8]->death, "You set the bush ablaze and roast some marshmallows.");
972
973 strcpy(monsters[1][9]->name, "Barbarian");
974 strcpy(monsters[1][9]->weapon, "Heavy Sword");
975 monsters[1][9]->strength = 29;
976 monsters[1][9]->gold = 250;
977 monsters[1][9]->exp = 25;
978 monsters[1][9]->maxhp = 30;
979 strcpy(monsters[1][9]->death, "You listen to him moan as he falls over dead.");
980
981 strcpy(monsters[1][10]->name, "Crypt Rat");
982 strcpy(monsters[1][10]->weapon, "Stinging Bite");
983 monsters[1][10]->strength = 25;
984 monsters[1][10]->gold = 119;
985 monsters[1][10]->exp = 20;
986 monsters[1][10]->maxhp = 26;
987 strcpy(monsters[1][10]->death, "You squash the little rodent for fear that it might not be dead.");
988
989 strcpy(monsters[1][11]->name, "Small Orc");
990 strcpy(monsters[1][11]->weapon, "blade");
991 monsters[1][11]->strength = 28;
992 monsters[1][11]->gold = 300;
993 monsters[1][11]->exp = 30;
994 monsters[1][11]->maxhp = 36;
995 strcpy(monsters[1][11]->death, "It's an ugly one, and it would've grown up to be a terror...");
996
997 strcpy(monsters[2][0]->name, "Teferi");
998 strcpy(monsters[2][0]->weapon, "Puzzle Box");
999 monsters[2][0]->strength = 29;
1000 monsters[2][0]->gold = 380;
1001 monsters[2][0]->exp = 18;
1002 monsters[2][0]->maxhp = 29;
1003 strcpy(monsters[2][0]->death, "It was a puzzling experience.");
1004
1005 strcpy(monsters[2][1]->name, "Spineless Thug");
1006 strcpy(monsters[2][1]->weapon, "Spiked Bat");
1007 monsters[2][1]->strength = 37;
1008 monsters[2][1]->gold = 384;
1009 monsters[2][1]->exp = 27;
1010 monsters[2][1]->maxhp = 32;
1011 strcpy(monsters[2][1]->death, "See you at the crossroads!");
1012
1013 strcpy(monsters[2][2]->name, "Pyromaniac");
1014 strcpy(monsters[2][2]->weapon, "Flame Thrower");
1015 monsters[2][2]->strength = 29;
1016 monsters[2][2]->gold = 563;
1017 monsters[2][2]->exp = 22;
1018 monsters[2][2]->maxhp = 45;
1019 strcpy(monsters[2][2]->death, "He chants FIRE FIRE as he falls to the ground... a burning heap of flesh.");
1020
1021 strcpy(monsters[2][3]->name, "Evil Enchantress");
1022 strcpy(monsters[2][3]->weapon, "Deadly Spell");
1023 monsters[2][3]->strength = 50;
1024 monsters[2][3]->gold = 830;
1025 monsters[2][3]->exp = 35;
1026 monsters[2][3]->maxhp = 35;
1027 strcpy(monsters[2][3]->death, "She looked just about as good as she fought.");
1028
1029 strcpy(monsters[2][4]->name, "Killer Leprechaun");
1030 strcpy(monsters[2][4]->weapon, "Gold Rush");
1031 monsters[2][4]->strength = 35;
1032 monsters[2][4]->gold = 1300;
1033 monsters[2][4]->exp = 30;
1034 monsters[2][4]->maxhp = 37;
1035 strcpy(monsters[2][4]->death, "You steal his pot of gold... that's a lot of money!");
1036
1037 strcpy(monsters[2][5]->name, "Avalanche Rider");
1038 strcpy(monsters[2][5]->weapon, "Huge Snowball");
1039 monsters[2][5]->strength = 32;
1040 monsters[2][5]->gold = 700;
1041 monsters[2][5]->exp = 32;
1042 monsters[2][5]->maxhp = 38;
1043 strcpy(monsters[2][5]->death, "You take his snowboard and snap it in two!");
1044
1045 strcpy(monsters[2][6]->name, "Blundering Idiot");
1046 strcpy(monsters[2][6]->weapon, "Stupidity");
1047 monsters[2][6]->strength = 14;
1048 monsters[2][6]->gold = 700;
1049 monsters[2][6]->exp = 20;
1050 monsters[2][6]->maxhp = 29;
1051 strcpy(monsters[2][6]->death, "Now there's one person you don't feel sorry for killing!");
1052
1053 strcpy(monsters[2][7]->name, "Militant Anarchist");
1054 strcpy(monsters[2][7]->weapon, "Molotov Cocktail");
1055 monsters[2][7]->strength = 33;
1056 monsters[2][7]->gold = 245;
1057 monsters[2][7]->exp = 45;
1058 monsters[2][7]->maxhp = 32;
1059 strcpy(monsters[2][7]->death, "Order has been restored for now...");
1060
1061 strcpy(monsters[2][8]->name, "Scathe Zombies");
1062 strcpy(monsters[2][8]->weapon, "Death Grip");
1063 monsters[2][8]->strength = 38;
1064 monsters[2][8]->gold = 763;
1065 monsters[2][8]->exp = 15;
1066 monsters[2][8]->maxhp = 45;
1067 strcpy(monsters[2][8]->death, "That was perhaps the scariest experience of your life.");
1068
1069 strcpy(monsters[2][9]->name, "Spitting Llama");
1070 strcpy(monsters[2][9]->weapon, "Spit Spray");
1071 monsters[2][9]->strength = 48;
1072 monsters[2][9]->gold = 638;
1073 monsters[2][9]->exp = 28;
1074 monsters[2][9]->maxhp = 34;
1075 strcpy(monsters[2][9]->death, "You wipe the spit off your face and fling it back at the Llama.");
1076
1077 strcpy(monsters[2][10]->name, "Juggalo");
1078 strcpy(monsters[2][10]->weapon, "Clown Axe");
1079 monsters[2][10]->strength = 60;
1080 monsters[2][10]->gold = 650;
1081 monsters[2][10]->exp = 30;
1082 monsters[2][10]->maxhp = 29;
1083 strcpy(monsters[2][10]->death, "What is a Juggalo? I don't know!");
1084
1085 strcpy(monsters[2][11]->name, "The Boogie Man");
1086 strcpy(monsters[2][11]->weapon, "Striking Fear");
1087 monsters[2][11]->strength = 46;
1088 monsters[2][11]->gold = 600;
1089 monsters[2][11]->exp = 35;
1090 monsters[2][11]->maxhp = 27;
1091 strcpy(monsters[2][11]->death, "He's scared you for the very last time!");
1092
1093 strcpy(monsters[3][0]->name, "Living Fire");
1094 strcpy(monsters[3][0]->weapon, "Scorching Wind");
1095 monsters[3][0]->strength = 55;
1096 monsters[3][0]->gold = 1100;
1097 monsters[3][0]->exp = 36;
1098 monsters[3][0]->maxhp = 55;
1099 strcpy(monsters[3][0]->death, "You extinguish the Living Flame once and for all!");
1100
1101 strcpy(monsters[3][1]->name, "Raging Orc");
1102 strcpy(monsters[3][1]->weapon, "Orcish Artillary");
1103 monsters[3][1]->strength = 89;
1104 monsters[3][1]->gold = 900;
1105 monsters[3][1]->exp = 25;
1106 monsters[3][1]->maxhp = 50;
1107 strcpy(monsters[3][1]->death, "This orc was a bit tougher than you remembered!");
1108
1109 strcpy(monsters[3][2]->name, "Huge Tarantula");
1110 strcpy(monsters[3][2]->weapon, "Tangling Web");
1111 monsters[3][2]->strength = 59;
1112 monsters[3][2]->gold = 1000;
1113 monsters[3][2]->exp = 35;
1114 monsters[3][2]->maxhp = 60;
1115 strcpy(monsters[3][2]->death, "You're glad you overcame your arachniphobia so soon!");
1116
1117 strcpy(monsters[3][3]->name, "Rabid Wolf");
1118 strcpy(monsters[3][3]->weapon, "Cujo Bite");
1119 monsters[3][3]->strength = 40;
1120 monsters[3][3]->gold = 1200;
1121 monsters[3][3]->exp = 47;
1122 monsters[3][3]->maxhp = 76;
1123 strcpy(monsters[3][3]->death, "The mutt falls over dead as white foam drips from its deadly canines...");
1124
1125 strcpy(monsters[3][4]->name, "Goblin Fighter");
1126 strcpy(monsters[3][4]->weapon, "Morning Star");
1127 monsters[3][4]->strength = 38;
1128 monsters[3][4]->gold = 700;
1129 monsters[3][4]->exp = 30;
1130 monsters[3][4]->maxhp = 75;
1131 strcpy(monsters[3][4]->death, "He almost caught you with his chain mace, but you sliced off his head.");
1132
1133 strcpy(monsters[3][5]->name, "Grizzly Bear");
1134 strcpy(monsters[3][5]->weapon, "Razor Claws");
1135 monsters[3][5]->strength = 68;
1136 monsters[3][5]->gold = 1747;
1137 monsters[3][5]->exp = 81;
1138 monsters[3][5]->maxhp = 51;
1139 strcpy(monsters[3][5]->death, "It almost got you this time... better be careful");
1140
1141 strcpy(monsters[3][6]->name, "Skeleton Man");
1142 strcpy(monsters[3][6]->weapon, "Leg Bone");
1143 monsters[3][6]->strength = 70;
1144 monsters[3][6]->gold = 597;
1145 monsters[3][6]->exp = 57;
1146 monsters[3][6]->maxhp = 60;
1147 strcpy(monsters[3][6]->death, "As a finisher, you wind up with the broad side of your weapon and hit his skull off for a home run!");
1148
1149 strcpy(monsters[3][7]->name, "Young Werewolf");
1150 strcpy(monsters[3][7]->weapon, "Howling Bites");
1151 monsters[3][7]->strength = 75;
1152 monsters[3][7]->gold = 1742;
1153 monsters[3][7]->exp = 65;
1154 monsters[3][7]->maxhp = 42;
1155 strcpy(monsters[3][7]->death, "You scatter the wolf's body parts in hopes he will stay dead!");
1156
1157 strcpy(monsters[3][8]->name, "Dark Infantry");
1158 strcpy(monsters[3][8]->weapon, "Flesh Reaper");
1159 monsters[3][8]->strength = 69;
1160 monsters[3][8]->gold = 870;
1161 monsters[3][8]->exp = 43;
1162 monsters[3][8]->maxhp = 65;
1163 strcpy(monsters[3][8]->death, "Light has prevailed this time... but it's only so long before you meet again.");
1164
1165 strcpy(monsters[3][9]->name, "Erie Spirit");
1166 strcpy(monsters[3][9]->weapon, "Deadly Grin");
1167 monsters[3][9]->strength = 63;
1168 monsters[3][9]->gold = 1300;
1169 monsters[3][9]->exp = 32;
1170 monsters[3][9]->maxhp = 50;
1171 strcpy(monsters[3][9]->death, "His cousin the ghost was a little bit easier.");
1172
1173 strcpy(monsters[3][10]->name, "Gollum");
1174 strcpy(monsters[3][10]->weapon, "Precious Treasure");
1175 monsters[3][10]->strength = 66;
1176 monsters[3][10]->gold = 1492;
1177 monsters[3][10]->exp = 73;
1178 monsters[3][10]->maxhp = 54;
1179 strcpy(monsters[3][10]->death, "Gollum screams out \"MY PRECIOUS\" as his small body falls limp from your blow.");
1180
1181 strcpy(monsters[3][11]->name, "Rock Fighter");
1182 strcpy(monsters[3][11]->weapon, "Small Boulders");
1183 monsters[3][11]->strength = 87;
1184 monsters[3][11]->gold = 1742;
1185 monsters[3][11]->exp = 99;
1186 monsters[3][11]->maxhp = 65;
1187 strcpy(monsters[3][11]->death, "You dodge his last rock, and counter with a low blow, cutting off his legs.");
1188
1189
1190 strcpy(monsters[4][0]->name, "Giant Sphinx");
1191 strcpy(monsters[4][0]->weapon, "Ancient Curse");
1192 monsters[4][0]->strength = 120;
1193 monsters[4][0]->gold = 1000;
1194 monsters[4][0]->exp = 100;
1195 monsters[4][0]->maxhp = 80;
1196 strcpy(monsters[4][0]->death, "You look in awe at the great wonder, collapsed at your feet!");
1197
1198 strcpy(monsters[4][1]->name, "Giant Ogre");
1199 strcpy(monsters[4][1]->weapon, "Big Log");
1200 monsters[4][1]->strength = 130;
1201 monsters[4][1]->gold = 857;
1202 monsters[4][1]->exp = 175;
1203 monsters[4][1]->maxhp = 100;
1204 strcpy(monsters[4][1]->death, "Your wits outmatched the ogre's brawn... big dumb thing.");
1205
1206 strcpy(monsters[4][2]->name, "Massive Cockroach");
1207 strcpy(monsters[4][2]->weapon, "Piercing Hiss");
1208 monsters[4][2]->strength = 125;
1209 monsters[4][2]->gold = 700;
1210 monsters[4][2]->exp = 150;
1211 monsters[4][2]->maxhp = 112;
1212 strcpy(monsters[4][2]->death, "Where's the exterminator when you need one?");
1213
1214 strcpy(monsters[4][3]->name, "Big Venomous Snake");
1215 strcpy(monsters[4][3]->weapon, "Poison Fangs");
1216 monsters[4][3]->strength = 140;
1217 monsters[4][3]->gold = 900;
1218 monsters[4][3]->exp = 175;
1219 monsters[4][3]->maxhp = 126;
1220 strcpy(monsters[4][3]->death, "After killing this beast you check for puncture marks... you find none, luckily.");
1221
1222 strcpy(monsters[4][4]->name, "Lizard Man");
1223 strcpy(monsters[4][4]->weapon, "Deadly Jaws");
1224 monsters[4][4]->strength = 145;
1225 monsters[4][4]->gold = 1250;
1226 monsters[4][4]->exp = 175;
1227 monsters[4][4]->maxhp = 150;
1228 strcpy(monsters[4][4]->death, "His scales made for tough armor, and his jaws for a tougher opponent!");
1229
1230 strcpy(monsters[4][5]->name, "Face Dancer");
1231 strcpy(monsters[4][5]->weapon, "Illusion Scyth");
1232 monsters[4][5]->strength = 138;
1233 monsters[4][5]->gold = 1603;
1234 monsters[4][5]->exp = 198;
1235 monsters[4][5]->maxhp = 173;
1236 strcpy(monsters[4][5]->death, "His carcus takes the shape of many things before it dies. His true form is so repulsive, you know why he changed faces so much!");
1237
1238 strcpy(monsters[4][6]->name, "Darklord Longbow Archer");
1239 strcpy(monsters[4][6]->weapon, "Deadly Bow and Arrows");
1240 monsters[4][6]->strength = 145;
1241 monsters[4][6]->gold = 1569;
1242 monsters[4][6]->exp = 243;
1243 monsters[4][6]->maxhp = 170;
1244 strcpy(monsters[4][6]->death, "Your face turns white with horror after you realize you just met the devil's protector!");
1245
1246 strcpy(monsters[4][7]->name, "Hell's Paladin");
1247 strcpy(monsters[4][7]->weapon, "Sword of Hellfire");
1248 monsters[4][7]->strength = 200;
1249 monsters[4][7]->gold = 2191;
1250 monsters[4][7]->exp = 254;
1251 monsters[4][7]->maxhp = 175;
1252 strcpy(monsters[4][7]->death, "This is starting to get tough you think. Do you really want to go to level 6?");
1253
1254 strcpy(monsters[4][8]->name, "The Unknown Soldier");
1255 strcpy(monsters[4][8]->weapon, "Soul Torture");
1256 monsters[4][8]->strength = 175;
1257 monsters[4][8]->gold = 1890;
1258 monsters[4][8]->exp = 200;
1259 monsters[4][8]->maxhp = 180;
1260 strcpy(monsters[4][8]->death, "Who was that? Where was he from? And what was that weapon??");
1261
1262 strcpy(monsters[4][9]->name, "Undead Cult Leader");
1263 strcpy(monsters[4][9]->weapon, "Lance of Deceit");
1264 monsters[4][9]->strength = 180;
1265 monsters[4][9]->gold = 1792;
1266 monsters[4][9]->exp = 195;
1267 monsters[4][9]->maxhp = 190;
1268 strcpy(monsters[4][9]->death, "His words fall on deaf ears... this is one cult you will NOT be part of!");
1269
1270 strcpy(monsters[4][10]->name, "Water Serpent");
1271 strcpy(monsters[4][10]->weapon, "Forked Tongue");
1272 monsters[4][10]->strength = 150;
1273 monsters[4][10]->gold = 1500;
1274 monsters[4][10]->exp = 176;
1275 monsters[4][10]->maxhp = 220;
1276 strcpy(monsters[4][10]->death, "The serpent squeals as you cut off its head!");
1277
1278 strcpy(monsters[4][11]->name, "Silverback Gorilla");
1279 strcpy(monsters[4][11]->weapon, "Deadly Banana Peel");
1280 monsters[4][11]->strength = 160;
1281 monsters[4][11]->gold = 1300;
1282 monsters[4][11]->exp = 150;
1283 monsters[4][11]->maxhp = 178;
1284 strcpy(monsters[4][11]->death, "Was that gorilla or guerilla?");
1285
1286 strcpy( monsters[5][0]->name, "");
1287 strcpy( monsters[5][0]->weapon, "");
1288 monsters[5][0]->strength = 200;
1289 monsters[5][0]->gold = 2500;
1290 monsters[5][0]->exp = 200;
1291 monsters[5][0]->maxhp = 200;
1292 strcpy( monsters[5][0]->death, "");
1293
1294 strcpy( monsters[5][1]->name, "");
1295 strcpy( monsters[5][1]->weapon, "");
1296 monsters[5][1]->strength = 230;
1297 monsters[5][1]->gold = 3215;
1298 monsters[5][1]->exp = 230;
1299 monsters[5][1]->maxhp = 210;
1300 strcpy( monsters[5][1]->death, "");
1301
1302 strcpy( monsters[5][2]->name, "");
1303 strcpy( monsters[5][2]->weapon, "");
1304 monsters[5][2]->strength = 215;
1305 monsters[5][2]->gold = 2750;
1306 monsters[5][2]->exp = 245;
1307 monsters[5][2]->maxhp = 214;
1308 strcpy( monsters[5][2]->death, "");
1309
1310 strcpy( monsters[5][3]->name, "Cheap Bastard");
1311 strcpy( monsters[5][3]->weapon, "Sack of Pennies");
1312 monsters[5][3]->strength = 245;
1313 monsters[5][3]->gold = 1000;
1314 monsters[5][3]->exp = 195;
1315 monsters[5][3]->maxhp = 200;
1316 strcpy( monsters[5][3]->death, "You hear him scream, \"MY COINS!!\" as you run off with his sack.");
1317
1318 strcpy( monsters[5][4]->name, "");
1319 strcpy( monsters[5][4]->weapon, "");
1320 monsters[5][4]->strength = 300;
1321 monsters[5][4]->gold = 4500;
1322 monsters[5][4]->exp = 375;
1323 monsters[5][4]->maxhp = 221;
1324 strcpy( monsters[5][4]->death, "");
1325
1326 strcpy( monsters[5][5]->name, "");
1327 strcpy( monsters[5][5]->weapon, "");
1328 monsters[5][5]->strength = 1;
1329 monsters[5][5]->gold = 1;
1330 monsters[5][5]->exp = 1;
1331 monsters[5][5]->maxhp = 1;
1332 strcpy( monsters[5][5]->death, "");
1333
1334 strcpy( monsters[5][6]->name, "");
1335 strcpy( monsters[5][6]->weapon, "");
1336 monsters[5][6]->strength = 1;
1337 monsters[5][6]->gold = 1;
1338 monsters[5][6]->exp = 1;
1339 monsters[5][6]->maxhp = 1;
1340 strcpy( monsters[5][6]->death, "");
1341
1342 strcpy( monsters[5][7]->name, "");
1343 strcpy( monsters[5][7]->weapon, "");
1344 monsters[5][7]->strength = 1;
1345 monsters[5][7]->gold = 1;
1346 monsters[5][7]->exp = 1;
1347 monsters[5][7]->maxhp = 1;
1348 strcpy( monsters[5][7]->death, "");
1349
1350 strcpy( monsters[5][8]->name, "");
1351 strcpy( monsters[5][8]->weapon, "");
1352 monsters[5][8]->strength = 1;
1353 monsters[5][8]->gold = 1;
1354 monsters[5][8]->exp = 1;
1355 monsters[5][8]->maxhp = 1;
1356 strcpy( monsters[5][8]->death, "");
1357
1358 strcpy( monsters[5][9]->name, "");
1359 strcpy( monsters[5][9]->weapon, "");
1360 monsters[5][9]->strength = 1;
1361 monsters[5][9]->gold = 1;
1362 monsters[5][9]->exp = 1;
1363 monsters[5][9]->maxhp = 1;
1364 strcpy( monsters[5][9]->death, "");
1365
1366 strcpy( monsters[5][10]->name, "");
1367 strcpy( monsters[5][10]->weapon, "");
1368 monsters[5][10]->strength = 1;
1369 monsters[5][10]->gold = 1;
1370 monsters[5][10]->exp = 1;
1371 monsters[5][10]->maxhp = 1;
1372 strcpy( monsters[5][10]->death, "");
1373
1374 strcpy( monsters[5][11]->name, "");
1375 strcpy( monsters[5][11]->weapon, "");
1376 monsters[5][11]->strength = 1;
1377 monsters[5][11]->gold = 1;
1378 monsters[5][11]->exp = 1;
1379 monsters[5][11]->maxhp = 1;
1380 strcpy( monsters[5][11]->death, "");
1381
1382 strcpy( monsters[6][0]->name, "");
1383 strcpy( monsters[6][0]->weapon, "");
1384 monsters[6][0]->strength = 1;
1385 monsters[6][0]->gold = 1;
1386 monsters[6][0]->exp = 1;
1387 monsters[6][0]->maxhp = 1;
1388 strcpy( monsters[6][0]->death, "");
1389
1390 strcpy( monsters[6][1]->name, "");
1391 strcpy( monsters[6][1]->weapon, "");
1392 monsters[6][1]->strength = 1;
1393 monsters[6][1]->gold = 1;
1394 monsters[6][1]->exp = 1;
1395 monsters[6][1]->maxhp = 1;
1396 strcpy( monsters[6][1]->death, "");
1397
1398 strcpy( monsters[6][2]->name, "");
1399 strcpy( monsters[6][2]->weapon, "");
1400 monsters[6][2]->strength = 1;
1401 monsters[6][2]->gold = 1;
1402 monsters[6][2]->exp = 1;
1403 monsters[6][2]->maxhp = 1;
1404 strcpy( monsters[6][2]->death, "");
1405
1406 strcpy( monsters[6][3]->name, "");
1407 strcpy( monsters[6][3]->weapon, "");
1408 monsters[6][3]->strength = 1;
1409 monsters[6][3]->gold = 1;
1410 monsters[6][3]->exp = 1;
1411 monsters[6][3]->maxhp = 1;
1412 strcpy( monsters[6][3]->death, "");
1413
1414 strcpy( monsters[6][4]->name, "");
1415 strcpy( monsters[6][4]->weapon, "");
1416 monsters[6][4]->strength = 1;
1417 monsters[6][4]->gold = 1;
1418 monsters[6][4]->exp = 1;
1419 monsters[6][4]->maxhp = 1;
1420 strcpy( monsters[6][4]->death, "");
1421
1422 strcpy( monsters[6][5]->name, "");
1423 strcpy( monsters[6][5]->weapon, "");
1424 monsters[6][5]->strength = 1;
1425 monsters[6][5]->gold = 1;
1426 monsters[6][5]->exp = 1;
1427 monsters[6][5]->maxhp = 1;
1428 strcpy( monsters[6][5]->death, "");
1429
1430 strcpy( monsters[6][6]->name, "");
1431 strcpy( monsters[6][6]->weapon, "");
1432 monsters[6][6]->strength = 1;
1433 monsters[6][6]->gold = 1;
1434 monsters[6][6]->exp = 1;
1435 monsters[6][6]->maxhp = 1;
1436 strcpy( monsters[6][6]->death, "");
1437
1438 strcpy( monsters[6][7]->name, "");
1439 strcpy( monsters[6][7]->weapon, "");
1440 monsters[6][7]->strength = 1;
1441 monsters[6][7]->gold = 1;
1442 monsters[6][7]->exp = 1;
1443 monsters[6][7]->maxhp = 1;
1444 strcpy( monsters[6][7]->death, "");
1445
1446 strcpy( monsters[6][8]->name, "");
1447 strcpy( monsters[6][8]->weapon, "");
1448 monsters[6][8]->strength = 1;
1449 monsters[6][8]->gold = 1;
1450 monsters[6][8]->exp = 1;
1451 monsters[6][8]->maxhp = 1;
1452 strcpy( monsters[6][8]->death, "");
1453
1454 strcpy( monsters[6][9]->name, "");
1455 strcpy( monsters[6][9]->weapon, "");
1456 monsters[6][9]->strength = 1;
1457 monsters[6][9]->gold = 1;
1458 monsters[6][9]->exp = 1;
1459 monsters[6][9]->maxhp = 1;
1460 strcpy( monsters[6][9]->death, "");
1461
1462 strcpy( monsters[6][10]->name, "");
1463 strcpy( monsters[6][10]->weapon, "");
1464 monsters[6][10]->strength = 1;
1465 monsters[6][10]->gold = 1;
1466 monsters[6][10]->exp = 1;
1467 monsters[6][10]->maxhp = 1;
1468 strcpy( monsters[6][10]->death, "");
1469
1470 strcpy( monsters[6][11]->name, "");
1471 strcpy( monsters[6][11]->weapon, "");
1472 monsters[6][11]->strength = 1;
1473 monsters[6][11]->gold = 1;
1474 monsters[6][11]->exp = 1;
1475 monsters[6][11]->maxhp = 1;
1476 strcpy( monsters[6][11]->death, "");
1477
1478 strcpy( monsters[7][0]->name, "");
1479 strcpy( monsters[7][0]->weapon, "");
1480 monsters[7][0]->strength = 1;
1481 monsters[7][0]->gold = 1;
1482 monsters[7][0]->exp = 1;
1483 monsters[7][0]->maxhp = 1;
1484 strcpy( monsters[7][0]->death, "");
1485
1486 strcpy( monsters[7][1]->name, "");
1487 strcpy( monsters[7][1]->weapon, "");
1488 monsters[7][1]->strength = 1;
1489 monsters[7][1]->gold = 1;
1490 monsters[7][1]->exp = 1;
1491 monsters[7][1]->maxhp = 1;
1492 strcpy( monsters[7][1]->death, "");
1493
1494 strcpy( monsters[7][2]->name, "");
1495 strcpy( monsters[7][2]->weapon, "");
1496 monsters[7][2]->strength = 1;
1497 monsters[7][2]->gold = 1;
1498 monsters[7][2]->exp = 1;
1499 monsters[7][2]->maxhp = 1;
1500 strcpy( monsters[7][2]->death, "");
1501
1502 strcpy( monsters[7][3]->name, "");
1503 strcpy( monsters[7][3]->weapon, "");
1504 monsters[7][3]->strength = 1;
1505 monsters[7][3]->gold = 1;
1506 monsters[7][3]->exp = 1;
1507 monsters[7][3]->maxhp = 1;
1508 strcpy( monsters[7][3]->death, "");
1509
1510 strcpy( monsters[7][4]->name, "");
1511 strcpy( monsters[7][4]->weapon, "");
1512 monsters[7][4]->strength = 1;
1513 monsters[7][4]->gold = 1;
1514 monsters[7][4]->exp = 1;
1515 monsters[7][4]->maxhp = 1;
1516 strcpy( monsters[7][4]->death, "");
1517
1518 strcpy( monsters[7][5]->name, "");
1519 strcpy( monsters[7][5]->weapon, "");
1520 monsters[7][5]->strength = 1;
1521 monsters[7][5]->gold = 1;
1522 monsters[7][5]->exp = 1;
1523 monsters[7][5]->maxhp = 1;
1524 strcpy( monsters[7][5]->death, "");
1525
1526 strcpy( monsters[7][6]->name, "");
1527 strcpy( monsters[7][6]->weapon, "");
1528 monsters[7][6]->strength = 1;
1529 monsters[7][6]->gold = 1;
1530 monsters[7][6]->exp = 1;
1531 monsters[7][6]->maxhp = 1;
1532 strcpy( monsters[7][6]->death, "");
1533
1534 strcpy( monsters[7][7]->name, "");
1535 strcpy( monsters[7][7]->weapon, "");
1536 monsters[7][7]->strength = 1;
1537 monsters[7][7]->gold = 1;
1538 monsters[7][7]->exp = 1;
1539 monsters[7][7]->maxhp = 1;
1540 strcpy( monsters[7][7]->death, "");
1541
1542 strcpy( monsters[7][8]->name, "");
1543 strcpy( monsters[7][8]->weapon, "");
1544 monsters[7][8]->strength = 1;
1545 monsters[7][8]->gold = 1;
1546 monsters[7][8]->exp = 1;
1547 monsters[7][8]->maxhp = 1;
1548 strcpy( monsters[7][8]->death, "");
1549
1550 strcpy( monsters[7][9]->name, "");
1551 strcpy( monsters[7][9]->weapon, "");
1552 monsters[7][9]->strength = 1;
1553 monsters[7][9]->gold = 1;
1554 monsters[7][9]->exp = 1;
1555 monsters[7][9]->maxhp = 1;
1556 strcpy( monsters[7][9]->death, "");
1557
1558 strcpy( monsters[7][10]->name, "");
1559 strcpy( monsters[7][10]->weapon, "");
1560 monsters[7][10]->strength = 1;
1561 monsters[7][10]->gold = 1;
1562 monsters[7][10]->exp = 1;
1563 monsters[7][10]->maxhp = 1;
1564 strcpy( monsters[7][10]->death, "");
1565
1566 strcpy( monsters[7][11]->name, "");
1567 strcpy( monsters[7][11]->weapon, "");
1568 monsters[7][11]->strength = 1;
1569 monsters[7][11]->gold = 1;
1570 monsters[7][11]->exp = 1;
1571 monsters[7][11]->maxhp = 1;
1572 strcpy( monsters[7][11]->death, "");
1573
1574 strcpy( monsters[8][0]->name, "");
1575 strcpy( monsters[8][0]->weapon, "");
1576 monsters[8][0]->strength = 1;
1577 monsters[8][0]->gold = 1;
1578 monsters[8][0]->exp = 1;
1579 monsters[8][0]->maxhp = 1;
1580 strcpy( monsters[8][0]->death, "");
1581
1582 strcpy( monsters[8][1]->name, "");
1583 strcpy( monsters[8][1]->weapon, "");
1584 monsters[8][1]->strength = 1;
1585 monsters[8][1]->gold = 1;
1586 monsters[8][1]->exp = 1;
1587 monsters[8][1]->maxhp = 1;
1588 strcpy( monsters[8][1]->death, "");
1589
1590 strcpy( monsters[8][2]->name, "");
1591 strcpy( monsters[8][2]->weapon, "");
1592 monsters[8][2]->strength = 1;
1593 monsters[8][2]->gold = 1;
1594 monsters[8][2]->exp = 1;
1595 monsters[8][2]->maxhp = 1;
1596 strcpy( monsters[8][2]->death, "");
1597
1598 strcpy( monsters[8][3]->name, "");
1599 strcpy( monsters[8][3]->weapon, "");
1600 monsters[8][3]->strength = 1;
1601 monsters[8][3]->gold = 1;
1602 monsters[8][3]->exp = 1;
1603 monsters[8][3]->maxhp = 1;
1604 strcpy( monsters[8][3]->death, "");
1605
1606 strcpy( monsters[8][4]->name, "");
1607 strcpy( monsters[8][4]->weapon, "");
1608 monsters[8][4]->strength = 1;
1609 monsters[8][4]->gold = 1;
1610 monsters[8][4]->exp = 1;
1611 monsters[8][4]->maxhp = 1;
1612 strcpy( monsters[8][4]->death, "");
1613
1614 strcpy( monsters[8][5]->name, "");
1615 strcpy( monsters[8][5]->weapon, "");
1616 monsters[8][5]->strength = 1;
1617 monsters[8][5]->gold = 1;
1618 monsters[8][5]->exp = 1;
1619 monsters[8][5]->maxhp = 1;
1620 strcpy( monsters[8][5]->death, "");
1621
1622 strcpy( monsters[8][6]->name, "");
1623 strcpy( monsters[8][6]->weapon, "");
1624 monsters[8][6]->strength = 1;
1625 monsters[8][6]->gold = 1;
1626 monsters[8][6]->exp = 1;
1627 monsters[8][6]->maxhp = 1;
1628 strcpy( monsters[8][6]->death, "");
1629
1630 strcpy( monsters[8][7]->name, "");
1631 strcpy( monsters[8][7]->weapon, "");
1632 monsters[8][7]->strength = 1;
1633 monsters[8][7]->gold = 1;
1634 monsters[8][7]->exp = 1;
1635 monsters[8][7]->maxhp = 1;
1636 strcpy( monsters[8][7]->death, "");
1637
1638 strcpy( monsters[8][8]->name, "");
1639 strcpy( monsters[8][8]->weapon, "");
1640 monsters[8][8]->strength = 1;
1641 monsters[8][8]->gold = 1;
1642 monsters[8][8]->exp = 1;
1643 monsters[8][8]->maxhp = 1;
1644 strcpy( monsters[8][8]->death, "");
1645
1646 strcpy( monsters[8][9]->name, "");
1647 strcpy( monsters[8][9]->weapon, "");
1648 monsters[8][9]->strength = 1;
1649 monsters[8][9]->gold = 1;
1650 monsters[8][9]->exp = 1;
1651 monsters[8][9]->maxhp = 1;
1652 strcpy( monsters[8][9]->death, "");
1653
1654 strcpy( monsters[8][10]->name, "");
1655 strcpy( monsters[8][10]->weapon, "");
1656 monsters[8][10]->strength = 1;
1657 monsters[8][10]->gold = 1;
1658 monsters[8][10]->exp = 1;
1659 monsters[8][10]->maxhp = 1;
1660 strcpy( monsters[8][10]->death, "");
1661
1662 strcpy( monsters[8][11]->name, "");
1663 strcpy( monsters[8][11]->weapon, "");
1664 monsters[8][11]->strength = 1;
1665 monsters[8][11]->gold = 1;
1666 monsters[8][11]->exp = 1;
1667 monsters[8][11]->maxhp = 1;
1668 strcpy( monsters[8][11]->death, "");
1669
1670 strcpy( monsters[9][0]->name, "");
1671 strcpy( monsters[9][0]->weapon, "");
1672 monsters[9][0]->strength = 1;
1673 monsters[9][0]->gold = 1;
1674 monsters[9][0]->exp = 1;
1675 monsters[9][0]->maxhp = 1;
1676 strcpy( monsters[9][0]->death, "");
1677
1678 strcpy( monsters[9][1]->name, "");
1679 strcpy( monsters[9][1]->weapon, "");
1680 monsters[9][1]->strength = 1;
1681 monsters[9][1]->gold = 1;
1682 monsters[9][1]->exp = 1;
1683 monsters[9][1]->maxhp = 1;
1684 strcpy( monsters[9][1]->death, "");
1685
1686 strcpy( monsters[9][2]->name, "");
1687 strcpy( monsters[9][2]->weapon, "");
1688 monsters[9][2]->strength = 1;
1689 monsters[9][2]->gold = 1;
1690 monsters[9][2]->exp = 1;
1691 monsters[9][2]->maxhp = 1;
1692 strcpy( monsters[9][2]->death, "");
1693
1694 strcpy( monsters[9][3]->name, "");
1695 strcpy( monsters[9][3]->weapon, "");
1696 monsters[9][3]->strength = 1;
1697 monsters[9][3]->gold = 1;
1698 monsters[9][3]->exp = 1;
1699 monsters[9][3]->maxhp = 1;
1700 strcpy( monsters[9][3]->death, "");
1701
1702 strcpy( monsters[9][4]->name, "");
1703 strcpy( monsters[9][4]->weapon, "");
1704 monsters[9][4]->strength = 1;
1705 monsters[9][4]->gold = 1;
1706 monsters[9][4]->exp = 1;
1707 monsters[9][4]->maxhp = 1;
1708 strcpy( monsters[9][4]->death, "");
1709
1710 strcpy( monsters[9][5]->name, "");
1711 strcpy( monsters[9][5]->weapon, "");
1712 monsters[9][5]->strength = 1;
1713 monsters[9][5]->gold = 1;
1714 monsters[9][5]->exp = 1;
1715 monsters[9][5]->maxhp = 1;
1716 strcpy( monsters[9][5]->death, "");
1717
1718 strcpy( monsters[9][6]->name, "");
1719 strcpy( monsters[9][6]->weapon, "");
1720 monsters[9][6]->strength = 1;
1721 monsters[9][6]->gold = 1;
1722 monsters[9][6]->exp = 1;
1723 monsters[9][6]->maxhp = 1;
1724 strcpy( monsters[9][6]->death, "");
1725
1726 strcpy( monsters[9][7]->name, "");
1727 strcpy( monsters[9][7]->weapon, "");
1728 monsters[9][7]->strength = 1;
1729 monsters[9][7]->gold = 1;
1730 monsters[9][7]->exp = 1;
1731 monsters[9][7]->maxhp = 1;
1732 strcpy( monsters[9][7]->death, "");
1733
1734 strcpy( monsters[9][8]->name, "");
1735 strcpy( monsters[9][8]->weapon, "");
1736 monsters[9][8]->strength = 1;
1737 monsters[9][8]->gold = 1;
1738 monsters[9][8]->exp = 1;
1739 monsters[9][8]->maxhp = 1;
1740 strcpy( monsters[9][8]->death, "");
1741
1742 strcpy( monsters[9][9]->name, "");
1743 strcpy( monsters[9][9]->weapon, "");
1744 monsters[9][9]->strength = 1;
1745 monsters[9][9]->gold = 1;
1746 monsters[9][9]->exp = 1;
1747 monsters[9][9]->maxhp = 1;
1748 strcpy( monsters[9][9]->death, "");
1749
1750 strcpy( monsters[9][10]->name, "");
1751 strcpy( monsters[9][10]->weapon, "");
1752 monsters[9][10]->strength = 1;
1753 monsters[9][10]->gold = 1;
1754 monsters[9][10]->exp = 1;
1755 monsters[9][10]->maxhp = 1;
1756 strcpy( monsters[9][10]->death, "");
1757
1758 strcpy( monsters[9][11]->name, "");
1759 strcpy( monsters[9][11]->weapon, "");
1760 monsters[9][11]->strength = 1;
1761 monsters[9][11]->gold = 1;
1762 monsters[9][11]->exp = 1;
1763 monsters[9][11]->maxhp = 1;
1764 strcpy( monsters[9][11]->death, "");
1765
1766 strcpy( monsters[10][0]->name, "");
1767 strcpy( monsters[10][0]->weapon, "");
1768 monsters[10][0]->strength = 1;
1769 monsters[10][0]->gold = 1;
1770 monsters[10][0]->exp = 1;
1771 monsters[10][0]->maxhp = 1;
1772 strcpy( monsters[10][0]->death, "");
1773
1774 strcpy( monsters[10][1]->name, "");
1775 strcpy( monsters[10][1]->weapon, "");
1776 monsters[10][1]->strength = 1;
1777 monsters[10][1]->gold = 1;
1778 monsters[10][1]->exp = 1;
1779 monsters[10][1]->maxhp = 1;
1780 strcpy( monsters[10][1]->death, "");
1781
1782 strcpy( monsters[10][2]->name, "");
1783 strcpy( monsters[10][2]->weapon, "");
1784 monsters[10][2]->strength = 1;
1785 monsters[10][2]->gold = 1;
1786 monsters[10][2]->exp = 1;
1787 monsters[10][2]->maxhp = 1;
1788 strcpy( monsters[10][2]->death, "");
1789
1790 strcpy( monsters[10][3]->name, "");
1791 strcpy( monsters[10][3]->weapon, "");
1792 monsters[10][3]->strength = 1;
1793 monsters[10][3]->gold = 1;
1794 monsters[10][3]->exp = 1;
1795 monsters[10][3]->maxhp = 1;
1796 strcpy( monsters[10][3]->death, "");
1797
1798 strcpy( monsters[10][4]->name, "");
1799 strcpy( monsters[10][4]->weapon, "");
1800 monsters[10][4]->strength = 1;
1801 monsters[10][4]->gold = 1;
1802 monsters[10][4]->exp = 1;
1803 monsters[10][4]->maxhp = 1;
1804 strcpy( monsters[10][4]->death, "");
1805
1806 strcpy( monsters[10][5]->name, "");
1807 strcpy( monsters[10][5]->weapon, "");
1808 monsters[10][5]->strength = 1;
1809 monsters[10][5]->gold = 1;
1810 monsters[10][5]->exp = 1;
1811 monsters[10][5]->maxhp = 1;
1812 strcpy( monsters[10][5]->death, "");
1813
1814 strcpy( monsters[10][6]->name, "");
1815 strcpy( monsters[10][6]->weapon, "");
1816 monsters[10][6]->strength = 1;
1817 monsters[10][6]->gold = 1;
1818 monsters[10][6]->exp = 1;
1819 monsters[10][6]->maxhp = 1;
1820 strcpy( monsters[10][6]->death, "");
1821
1822 strcpy( monsters[10][7]->name, "");
1823 strcpy( monsters[10][7]->weapon, "");
1824 monsters[10][7]->strength = 1;
1825 monsters[10][7]->gold = 1;
1826 monsters[10][7]->exp = 1;
1827 monsters[10][7]->maxhp = 1;
1828 strcpy( monsters[10][7]->death, "");
1829
1830 strcpy( monsters[10][8]->name, "");
1831 strcpy( monsters[10][8]->weapon, "");
1832 monsters[10][8]->strength = 1;
1833 monsters[10][8]->gold = 1;
1834 monsters[10][8]->exp = 1;
1835 monsters[10][8]->maxhp = 1;
1836 strcpy( monsters[10][8]->death, "");
1837
1838 strcpy( monsters[10][9]->name, "");
1839 strcpy( monsters[10][9]->weapon, "");
1840 monsters[10][9]->strength = 1;
1841 monsters[10][9]->gold = 1;
1842 monsters[10][9]->exp = 1;
1843 monsters[10][9]->maxhp = 1;
1844 strcpy( monsters[10][9]->death, "");
1845
1846 strcpy( monsters[10][10]->name, "");
1847 strcpy( monsters[10][10]->weapon, "");
1848 monsters[10][10]->strength = 1;
1849 monsters[10][10]->gold = 1;
1850 monsters[10][10]->exp = 1;
1851 monsters[10][10]->maxhp = 1;
1852 strcpy( monsters[10][10]->death, "");
1853
1854 strcpy( monsters[10][11]->name, "");
1855 strcpy( monsters[10][11]->weapon, "");
1856 monsters[10][11]->strength = 1;
1857 monsters[10][11]->gold = 1;
1858 monsters[10][11]->exp = 1;
1859 monsters[10][11]->maxhp = 1;
1860 strcpy( monsters[10][11]->death, "");
1861
1862 strcpy( monsters[11][0]->name, "");
1863 strcpy( monsters[11][0]->weapon, "");
1864 monsters[11][0]->strength = 1;
1865 monsters[11][0]->gold = 1;
1866 monsters[11][0]->exp = 1;
1867 monsters[11][0]->maxhp = 1;
1868 strcpy( monsters[11][0]->death, "");
1869
1870 strcpy( monsters[11][1]->name, "");
1871 strcpy( monsters[11][1]->weapon, "");
1872 monsters[11][1]->strength = 1;
1873 monsters[11][1]->gold = 1;
1874 monsters[11][1]->exp = 1;
1875 monsters[11][1]->maxhp = 1;
1876 strcpy( monsters[11][1]->death, "");
1877
1878 strcpy( monsters[11][2]->name, "");
1879 strcpy( monsters[11][2]->weapon, "");
1880 monsters[11][2]->strength = 1;
1881 monsters[11][2]->gold = 1;
1882 monsters[11][2]->exp = 1;
1883 monsters[11][2]->maxhp = 1;
1884 strcpy( monsters[11][2]->death, "");
1885
1886 strcpy( monsters[11][3]->name, "");
1887 strcpy( monsters[11][3]->weapon, "");
1888 monsters[11][3]->strength = 1;
1889 monsters[11][3]->gold = 1;
1890 monsters[11][3]->exp = 1;
1891 monsters[11][3]->maxhp = 1;
1892 strcpy( monsters[11][3]->death, "");
1893
1894 strcpy( monsters[11][4]->name, "");
1895 strcpy( monsters[11][4]->weapon, "");
1896 monsters[11][4]->strength = 1;
1897 monsters[11][4]->gold = 1;
1898 monsters[11][4]->exp = 1;
1899 monsters[11][4]->maxhp = 1;
1900 strcpy( monsters[11][4]->death, "");
1901
1902 strcpy( monsters[11][5]->name, "");
1903 strcpy( monsters[11][5]->weapon, "");
1904 monsters[11][5]->strength = 1;
1905 monsters[11][5]->gold = 1;
1906 monsters[11][5]->exp = 1;
1907 monsters[11][5]->maxhp = 1;
1908 strcpy( monsters[11][5]->death, "");
1909
1910 strcpy( monsters[11][6]->name, "");
1911 strcpy( monsters[11][6]->weapon, "");
1912 monsters[11][6]->strength = 1;
1913 monsters[11][6]->gold = 1;
1914 monsters[11][6]->exp = 1;
1915 monsters[11][6]->maxhp = 1;
1916 strcpy( monsters[11][6]->death, "");
1917
1918 strcpy( monsters[11][7]->name, "");
1919 strcpy( monsters[11][7]->weapon, "");
1920 monsters[11][7]->strength = 1;
1921 monsters[11][7]->gold = 1;
1922 monsters[11][7]->exp = 1;
1923 monsters[11][7]->maxhp = 1;
1924 strcpy( monsters[11][7]->death, "");
1925
1926 strcpy( monsters[11][8]->name, "");
1927 strcpy( monsters[11][8]->weapon, "");
1928 monsters[11][8]->strength = 1;
1929 monsters[11][8]->gold = 1;
1930 monsters[11][8]->exp = 1;
1931 monsters[11][8]->maxhp = 1;
1932 strcpy( monsters[11][8]->death, "");
1933
1934 strcpy( monsters[11][9]->name, "");
1935 strcpy( monsters[11][9]->weapon, "");
1936 monsters[11][9]->strength = 1;
1937 monsters[11][9]->gold = 1;
1938 monsters[11][9]->exp = 1;
1939 monsters[11][9]->maxhp = 1;
1940 strcpy( monsters[11][9]->death, "");
1941
1942 strcpy( monsters[11][10]->name, "");
1943 strcpy( monsters[11][10]->weapon, "");
1944 monsters[11][10]->strength = 1;
1945 monsters[11][10]->gold = 1;
1946 monsters[11][10]->exp = 1;
1947 monsters[11][10]->maxhp = 1;
1948 strcpy( monsters[11][10]->death, "");
1949
1950 strcpy( monsters[11][11]->name, "");
1951 strcpy( monsters[11][11]->weapon, "");
1952 monsters[11][11]->strength = 1;
1953 monsters[11][11]->gold = 1;
1954 monsters[11][11]->exp = 1;
1955 monsters[11][11]->maxhp = 1;
1956 strcpy( monsters[11][11]->death, "");
1957
1958*/
1959}
1960
1961void delete_monsters()
1962{
1963 for (int x = 0; x < LEVELS; x++)
1964 for (int y = 0; y < MONSTERS; y++)
1965 if (monsters[x][y])
1966 delete monsters[x][y];
1967}
1968
1969void delete_masters()
1970{
1971 for (int x = 0; x < LEVELS; x++)
1972 if (masters[x])
1973 delete masters[x];
1974}
1975
1976void display_monster(char *u)
1977{
1978 if (is_playing(u))
1979 {
1980 aClient *user = find(u);
1981 Player *ni = user->stats;
1982
1983 notice(s_GameServ, u, "Your Hitpoints: \ 2%d\ 2", ni->hp);
1984 notice(s_GameServ, u, "%s's Hitpoints: \ 2%d\ 2", ni->fight->name, ni->fight->hp);
1985 notice(s_GameServ, u, "Here are your commands:");
1986 notice(s_GameServ, u, "/msg %S attack");
1987 notice(s_GameServ, u, "/msg %S run");
1988 notice(s_GameServ, u, "What will you do?");
1989 }
1990}
1991
1992void display_players(char *u)
1993{
1994 if (is_playing(u))
1995 {
1996 aClient *ni = find(u);
1997
1998 aClient *battle = ni->stats->battle;
1999
2000 notice(s_GameServ, u, "Your Hitpoints: \ 2%d\ 2", ni->stats->hp);
2001 notice(s_GameServ, u, "%s's Hitpoints: \ 2%d\ 2", battle->getNick(),
2002 battle->stats->hp);
2003
2004 notice(s_GameServ, u, "Here are your commands:");
2005 notice(s_GameServ, u, "/msg %S attack");
2006 notice(s_GameServ, u, "/msg %S run");
2007 notice(s_GameServ, u, "What will you do?");
2008 }
2009}
2010void display_players(aClient *user)
2011{
2012 char *u = user->getNick();
2013 if (is_playing(user) && player_fight(user))
2014 {
2015 aClient *battle = user->stats->battle;
2016 notice(s_GameServ, u, "Your Hitpoints: \ 2%d\ 2", user->stats->hp);
2017 notice(s_GameServ, u, "%s's Hitpoints: \ 2%d\ 2", battle->getNick(), battle->stats->hp);
2018 notice(s_GameServ, u, "Here are your commands:");
2019 notice(s_GameServ, u, "/msg %S attack");
2020 notice(s_GameServ, u, "/msg %S run");
2021 notice(s_GameServ, u, "What will you do?");
2022 }
2023}
2024
2025
2026bool is_playing(char *u)
2027{
2028 aClient *user;
2029 if (!(user = find(u)))
2030 {
2031 return false;
2032 }
2033 else
2034 {
2035 return user->stats != NULL;
2036 }
2037}
2038
2039bool is_playing(aClient *user)
2040{
2041 return user->stats != NULL && (stricmp(user->getNick(), "!NULL!") != 0);
2042}
2043
2044bool is_fighting(char *u)
2045{
2046 aClient *user;
2047
2048 if (!(user = find(u)))
2049 {
2050 return false;
2051 }
2052 else if (user->stats)
2053 {
2054 return user->stats->fight != NULL || user->stats->battle != NULL
2055 || user->stats->master != NULL;
2056 }
2057 else
2058 return false;
2059}
2060bool is_fighting(aClient *user)
2061{
2062 if (!is_playing(user))
2063 return false;
2064 else
2065 return (user->stats->fight != NULL || user->stats->battle != NULL || user->stats->master != NULL);
2066}
2067
2068bool player_fight(char *u)
2069{
2070 aClient *user;
2071
2072 if (!(user = find(u)))
2073 return false;
2074 else if (user->stats)
2075 return user->stats->battle != NULL;
2076 else
2077 return false;
2078}
2079bool player_fight(aClient *user)
2080{
2081 if (!is_fighting(user))
2082 return false;
2083 else
2084 return user->stats->battle != NULL;
2085}
2086
2087bool master_fight(char *u)
2088{
2089 aClient *user;
2090
2091 if (!(user = find(u)))
2092 return false;
2093 else if (user->stats)
2094 return user->stats->master != NULL;
2095 else
2096 return false;
2097}
2098bool master_fight(aClient *user)
2099{
2100 if (!is_playing(user))
2101 return false;
2102 else
2103 return user->stats->master != NULL;
2104}
2105
2106void do_fight(char *u)
2107{
2108 aClient *ni, *battle;
2109
2110 char *nick = strtok(NULL, " ");
2111
2112 if (!nick)
2113 {
2114 notice(s_GameServ, u, "SYNTAX: /msg %S FIGHT PLAYER");
2115 }
2116 else if (!(ni = find(u)))
2117 {
2118 notice(s_GameServ, u, "Fatal error. Contact a(n) %S admin. buf: %s", strtok(NULL, ""));
2119 return;
2120 }
2121 else if (!(battle = find(nick)))
2122 {
2123 notice(s_GameServ, u, "You can't attack %s while they aren't playing!", nick);
2124 return;
2125 }
2126 else if (!is_playing(ni))
2127 {
2128 notice(s_GameServ, u, "You are not playing!");
2129 return;
2130 }
2131/*
2132 * Offline fighting not implemented yet.
2133 * else if (!(fight = finduser(nick)))
2134 * {
2135 * ni->stats->battle = battle;
2136 * battle->battle = ni;
2137 * ni->yourturn = 1;
2138 * battle->yourturn = 0;
2139 * notice(s_GameServ, u, "You decide to fight %s while they're not online!",
2140 * battle->getNick());
2141 * display_players(u);
2142 * }
2143 */
2144 else if (!isAlive(ni->stats))
2145 {
2146 notice(s_GameServ, u, "You are dead. Wait until tomorrow to fight others!");
2147 return;
2148 }
2149 else if (player_fight(battle))
2150 {
2151 notice(s_GameServ, u, "%s is fighting %s already!", battle->stats->name, battle->stats->battle->stats->name);
2152 return;
2153 }
2154 else if (is_fighting(battle))
2155 {
2156 notice(s_GameServ, u, "%s is fighting %s already!", battle->stats->name, battle->stats->fight->name);
2157 return;
2158 }
2159 else if (is_playing(ni) && is_playing(battle) && stricmp(ni->stats->name, battle->stats->name) != 0)
2160 {
2161 // Set your battle pointer to the other player
2162 ni->stats->battle = battle;
2163
2164 // Set the other player's battle pointer to you
2165 battle->stats->battle = ni;
2166
2167 // The initiator gets the first move (perhaps this should be 50/50)
2168 setYourTurn(ni->stats);
2169 clearYourTurn(battle->stats);
2170
2171 // Initiate Battle sequence!
2172 notice(s_GameServ, u, "You challenge %s to an online duel!", battle->getNick());
2173 notice(s_GameServ, battle->getNick(), "%s has challenged you to an online duel!", u);
2174 notice(s_GameServ, battle->getNick(), "%s gets to go first because he initiated!", u);
2175 notice(s_GameServ, battle->getNick(), "Please wait while %s decides what to do.", u);
2176 display_players(u);
2177 }
2178}
2179void do_use(char *u)
2180{
2181 aClient *user;
2182 Pouch *p;
2183
2184 char *item = strtok(NULL, " ");
2185
2186 if (!item)
2187 {
2188 notice(s_GameServ, u, "SYNTAX: USE ITEM");
2189 notice(s_GameServ, u, "Type /msg %S HELP USE for more information.");
2190 return;
2191 }
2192 else if (!(user = find(u)))
2193 {
2194 notice(s_GameServ, u, "Fatal Error in do_use. Contact a(n) %S Admin");
2195 return;
2196 }
2197 else if (!is_playing(user))
2198 {
2199 notice(s_GameServ, u, "You must be playing to use items!");
2200 return;
2201 }
2202
2203 p = &user->stats->inventory;
2204
2205 if (stricmp(item, "HEALTH") == 0)
2206 {
2207 if (p->Healing() <= 0)
2208 {
2209 notice(s_GameServ, u, "You are out of Health Potions!");
2210 return;
2211 }
2212 int oldhealth = user->stats->hp;
2213 notice(s_GameServ, u, "You hastiliy gulp down the flask of cool life-giving waters.");
2214 notice(s_GameServ, u, "Rejuvination spreads throughout your body.");
2215 user->stats->hp += (10 * user->stats->level) + (rand() % 10) * user->stats->level;
2216 notice(s_GameServ, u, "You gain %d HP!", user->stats->hp - oldhealth);
2217 p->decHealing();
2218 }
2219 else if (stricmp(item, "STRENGTH") == 0)
2220 {
2221 if (p->Strength() <= 0)
2222 {
2223 notice(s_GameServ, u, "You are out of Strength Potions!");
2224 return;
2225 }
2226 int oldstrength = user->stats->strength;
2227 notice(s_GameServ, u, "As you grip the flask containing pure power, you feel adrenaline coarse through your veins!");
2228 notice(s_GameServ, u, "In one swallow you drink the potion and feel your muscle fibers bulging andgrowing!");
2229 user->stats->strength += 1 + rand() % 2; // 1 - 2 Strength Added
2230 notice(s_GameServ, u, "You gain %d Strength points!", user->stats->strength - oldstrength);
2231 p->decStrength();
2232 }
2233 else if (stricmp(item, "DEFENSE") == 0)
2234 {
2235 if (p->Defense() <= 0)
2236 {
2237 notice(s_GameServ, u, "You are out of Defense Potions!");
2238 return;
2239 }
2240 int olddefense = user->stats->defense;
2241 notice(s_GameServ, u, "You drink the foul tasting viscous liquid while pinching your nose in disgust.");
2242 notice(s_GameServ, u, "It tasted bad, but you feel like you are unbeatable!");
2243 user->stats->defense += 1 + rand() % 2; // 1 - 2 Defense Added
2244 notice(s_GameServ, u, "You gain %d Defense points!", user->stats->defense - olddefense);
2245 p->decDefense();
2246 }
2247 else if (stricmp(item, "HP") == 0)
2248 {
2249 if (p->HP() <= 0)
2250 {
2251 notice(s_GameServ, u, "You are out of HP Potions!");
2252 return;
2253 }
2254 int oldHP = user->stats->maxhp;
2255 notice(s_GameServ, u, "You feel your life growing longer as you drink the green glowing liquid.");
2256 user->stats->maxhp += 1 + rand() % 5; // 1 - 5 Maxhp
2257 notice(s_GameServ, u, "You gain %d Maximum hit points!", user->stats->maxhp - oldHP);
2258 p->decHP();
2259 }
2260 else
2261 {
2262 notice(s_GameServ, u, "SYNTAX: /msg %S USE {HEALTH | STRENGTH | DEFENSE}");
2263 return;
2264 }
2265
2266 end_turn(user); // If they're fighting, end their turn
2267}
2268void do_run(char *u)
2269{
2270 aClient *user;
2271 Player *p, *p2 = NULL;
2272
2273 if (!(user = find(u)))
2274 {
2275 notice(s_GameServ, u, "Couldn't find you. Error. Contact a %S admin");
2276 return;
2277 }
2278
2279 p = user->stats;
2280
2281 if (p->battle)
2282 p2 = p->battle->stats;
2283
2284 if (!is_fighting(user))
2285 notice(s_GameServ, u, "You run in place... try fighting next time.");
2286 else if (!player_fight(user) && !master_fight(user))
2287 {
2288 notice(s_GameServ, u, "You run away from \ 2%s\ 2 like a little baby!", p->fight->name);
2289 delete p->fight;
2290 p->fight = NULL;
2291 }
2292 else if (player_fight(user) && isYourTurn(p))
2293 {
2294 notice(s_GameServ, u, "You run away from \ 2%s\ 2 like a little baby!", p2->name);
2295 notice(s_GameServ, p->battle->getNick(), "\ 2%s\ 2 ran away from you like a little baby!", p->name);
2296 p2->battle = NULL;
2297 }
2298 else if (player_fight(user) && !isYourTurn(p))
2299 {
2300 notice(s_GameServ, u, "It is not your turn. Please wait until \ 2%s\ 2 decides what to do.", p2->name);
2301 }
2302 else if (master_fight(user))
2303 {
2304 notice(s_GameServ, u, "You cannot run from \ 2%s\ 2! FIGHT!", p->master->name);
2305 }
2306 p->battle = NULL;
2307}
2308
2309void end_turn(aClient *user)
2310{
2311 char *nick, *u = user->getNick();
2312 Monster *fight;
2313 aClient *battle;
2314 int mhit;
2315
2316 nick = new char[strlen(user->getNick()) + 1];
2317
2318 if (!user || !is_playing(user) || !is_fighting(user))
2319 goto endturn;
2320
2321 if (!player_fight(user) && !master_fight(user))
2322 fight = user->stats->fight;
2323 else
2324 fight = user->stats->master;
2325 battle = user->stats->battle;
2326
2327 if (!player_fight(user))
2328 {
2329 // Opponent's Hit
2330 mhit = (fight->strength / 2) +
2331 (rand() % (fight->strength / 2) - (user->stats->defense +
2332 arbonus[user->stats->armor]));
2333 }
2334 else
2335 {
2336 // Opponent's Hit
2337 mhit = (((battle->stats->strength + webonus[battle->stats->weapon]) / 2) +
2338 (rand() % ((battle->stats->strength + webonus[battle->stats->weapon])) / 2) -
2339 (user->stats->defense + arbonus[user->stats->armor]));
2340 }
2341 if (!player_fight(user))
2342 {
2343
2344 if (mhit > 0)
2345 {
2346 notice(s_GameServ, u, "\1f%s\1f attacks with their \1f%s\1f for \ 2%d\ 2 damage!",
2347 fight->name, fight->weapon, mhit);
2348 }
2349 else if (mhit <= 0)
2350 notice(s_GameServ, u, "%s completely misses you!", fight->name);
2351
2352 if (mhit >= user->stats->hp)
2353 {
2354 if (!master_fight(user))
2355 {
2356 notice(s_GameServ, u, "You have been \ 2\1fkilled\1f\ 2 by %s!", fight->name);
2357 notice(s_GameServ, u, "You lose all gold on hand and lose 10 percent "\
2358 "of your experience!");
2359 user->stats->gold = 0;
2360 user->stats->exp -= (long int)(user->stats->exp * .10);
2361 user->stats->fight = NULL;
2362 clearAlive(user->stats);
2363 goto endturn;
2364 }
2365 else
2366 {
2367 notice(s_GameServ, u, "%s has bested you! You will have to wait "\
2368 "until tomorrow to try again", user->stats->master->name);
2369 user->stats->fight = NULL;
2370 user->stats->master = NULL;
2371 goto endturn;
2372 }
2373 }
2374 else
2375 {
2376 if (mhit > 0)
2377 user->stats->hp -= mhit;
2378 display_monster(u);
2379 goto endturn;
2380 }
2381 }
2382 else
2383 {
2384 clearYourTurn(user->stats);
2385 setYourTurn(battle->stats);
2386 display_players(battle);
2387 }
2388endturn:
2389 delete nick;
2390}
2391
2392void do_attack(char *u)
2393{
2394 int hit, mhit;
2395 aClient *ni, *battle; // The player and perhaps the player they're fighting
2396 Monster *fight; // The monster they may be fighting
2397
2398 if (!(ni = find(u)))
2399 {
2400 notice(s_GameServ, u, "Fatal error in do_attack. Contact a(n) %S admin for help.");
2401 return;
2402 }
2403 else if (!is_playing(ni))
2404 {
2405 notice(s_GameServ, u, "You're not playing!");
2406 return;
2407 }
2408 else if (!is_fighting(ni))
2409 {
2410 notice(s_GameServ, u, "You're not in battle!");
2411 return;
2412 }
2413 else
2414 {
2415 if (!ni->stats->master) // This is not a master fight
2416 fight = ni->stats->fight; // Monster Could be NULL
2417 else // This IS a master fight
2418 fight = ni->stats->master; // Master Could be NULL
2419
2420 battle = ni->stats->battle; // Player Could be NULL
2421
2422 // One has to be !NULL based on the previous else if
2423 // We wouldn't be here if they were all NULL
2424 }
2425
2426 if (!player_fight(ni))
2427 {
2428 // Player's Hit
2429 hit = ((ni->stats->strength + webonus[ni->stats->weapon]) / 2) +
2430 (rand() % ((ni->stats->strength + webonus[ni->stats->weapon]) / 2));
2431
2432 // Opponent's Hit
2433 mhit = (fight->strength / 2) +
2434 (rand() % (fight->strength / 2) - (ni->stats->defense +
2435 arbonus[ni->stats->armor]));
2436 }
2437 else
2438 {
2439 // Opponent's Hit
2440 mhit = (((battle->stats->strength + webonus[battle->stats->weapon]) / 2) +
2441 (rand() % ((battle->stats->strength + webonus[battle->stats->weapon])) / 2) -
2442 (ni->stats->defense + arbonus[ni->stats->armor]));
2443
2444 // Player's Hit
2445 hit = (((ni->stats->strength + webonus[ni->stats->weapon]) / 2) +
2446 (rand() % ((ni->stats->strength + webonus[ni->stats->weapon])) / 2) -
2447 (battle->stats->defense + arbonus[battle->stats->armor]));
2448 }
2449
2450 if (!player_fight(ni))
2451 {
2452 if (hit > 0)
2453 notice(s_GameServ, u, "You attack \1f%s\1f for \ 2%d\ 2 points!", fight->name, hit);
2454 else
2455 notice(s_GameServ, u, "You miss \1f%s\1f completely!", fight->name);
2456
2457 if (hit >= fight->hp)
2458 {
2459 if (master_fight(ni))
2460 notice(s_GameServ, u, "You have bested %s!", fight->name);
2461 else
2462 notice(s_GameServ, u, "You have killed \ 2%s\ 2!", fight->name);
2463
2464 notice(s_GameServ, u, "%s", fight->death);
2465 notice(s_GameServ, u, "You recieve \ 2%d\ 2 experience and \ 2%d\ 2 gold!",
2466 fight->exp, fight->gold);
2467
2468 // If your new experience (or gold) will be greater than 2 billion,
2469 // then set your exp to 2bil. (2 billion max)... otherwise add them.
2470 // This could be a problem with overflowing out of the sign bit.
2471 // Unsigned long int maybe? Leave it for now.
2472 ni->stats->exp = ( (ni->stats->exp + fight->exp) > 2000000000 ? 2000000000 :
2473 ni->stats->exp + fight->exp);
2474
2475 ni->stats->gold = (ni->stats->gold + fight->gold > 2000000000 ? 2000000000 :
2476 ni->stats->gold + fight->gold);
2477
2478
2479 if (master_fight(ni))
2480 {
2481 notice(s_GameServ, u, "You are now level %d!", ni->stats->level + 1);
2482 notice(s_GameServ, u, "You gain %d Strength, and %d Defense points!",
2483 strbonus[ni->stats->level - 1], defbonus[ni->stats->level - 1]);
2484
2485 // Increase your level
2486 ni->stats->level++;
2487
2488 // Increase your maximum hit points
2489 ni->stats->maxhp += hpbonus[ni->stats->level - 1];
2490
2491 // Heal the player by setting hp to their max
2492 ni->stats->hp = ni->stats->maxhp;
2493
2494 // Add to your strength
2495 ni->stats->strength += strbonus[ni->stats->level - 1];
2496
2497 // Add to your defensive power
2498 ni->stats->defense += defbonus[ni->stats->level - 1];
2499
2500 // Clear the pointer for your master
2501 ni->stats->master = NULL;
2502 }
2503
2504 // They're dead so remove the pointer
2505 delete ni->stats->fight;
2506 ni->stats->fight = NULL;
2507 ni->stats->master = NULL;
2508
2509 return;
2510 }
2511 else
2512 {
2513 if (hit > 0)
2514 fight->hp -= hit;
2515 if (mhit > 0)
2516 {
2517 notice(s_GameServ, u, "\1f%s\1f attacks with their \1f%s\1f for \ 2%d\ 2 damage!",
2518 fight->name, fight->weapon, mhit);
2519 }
2520 else if (mhit <= 0)
2521 notice(s_GameServ, u, "%s completely misses you!", fight->name);
2522
2523 if (mhit >= ni->stats->hp)
2524 {
2525 if (!master_fight(ni))
2526 {
2527 notice(s_GameServ, u, "You have been \ 2\1fkilled\1f\ 2 by %s!", fight->name);
2528 notice(s_GameServ, u, "You lose all gold on hand and lose 10 percent "\
2529 "of your experience!");
2530 ni->stats->gold = 0;
2531 ni->stats->exp -= (long int)(ni->stats->exp * .10);
2532 ni->stats->fight = NULL;
2533 clearAlive(ni->stats);
2534 return;
2535 }
2536 else
2537 {
2538 notice(s_GameServ, u, "%s has bested you! You will have to wait "\
2539 "until tomorrow to try again", ni->stats->master->name);
2540 ni->stats->fight = NULL;
2541 ni->stats->master = NULL;
2542 return;
2543 }
2544 }
2545 else
2546 {
2547 if (mhit > 0)
2548 ni->stats->hp -= mhit;
2549 display_monster(u);
2550 return;
2551 }
2552 }
2553 }
2554 else if (player_fight(ni))
2555 {
2556/* Offline fighting not available yet
2557 if (!(online = finduser(ni->stats->battle->nick)) || !nick_identified(online))
2558 {
2559 if (hit > 0)
2560 notice(s_GameServ, u, "You attack \1f%s\1f for \ 2%d\ 2 points!", battle->nick, hit);
2561 else
2562 notice(s_GameServ, u, "You miss \1f%s\1f completely!", battle->nick);
2563 if (hit >= battle->stats->hp)
2564 {
2565 notice(s_GameServ, u, "You have killed \ 2%s\ 2!", battle->nick);
2566* notice(s_GameServ, u, "You recieve \ 2%d\ 2 experience and \ 2%ld\ 2 gold!",
2567 (long int)(battle->stats->exp * .10), battle->stats->gold);
2568 if (2000000000 - ni->stats->exp > (long int)(battle->stats->exp * .10))
2569 {
2570 ni->stats->exp += (long int)(battle->stats->exp * .10);
2571 battle->stats->exp -= (long int)(battle->stats->exp * .10);
2572 }
2573* else
2574 {
2575 battle->stats->exp -= (long int)(battle->stats->exp * .10);
2576 ni->stats->exp = 2000000000;
2577 }
2578
2579 if (2000000000 - ni->stats->gold > battle->stats->gold)
2580 {
2581* ni->stats->gold += battle->stats->gold;
2582 battle->stats->gold = 0;
2583 }
2584 else
2585 {
2586 battle->stats->gold = 2000000000 - ni->stats->gold;
2587 ni->stats->gold = 2000000000;
2588 }
2589* ni->stats->battle->stats->alive = 0;
2590 ni->stats->battle->battle = NULL;
2591 ni->stats->battle = NULL;
2592 return;
2593 }
2594 else
2595 {
2596 if (hit > 0)
2597* battle->stats->hp -= hit;
2598 if (mhit > 0)
2599 {
2600 notice(s_GameServ, u, "\1f%s\1f hits you with their \1f%s\1f for \ 2%d\ 2 damage!",
2601 battle->nick, weapons[battle->stats->weapon], mhit);
2602 }
2603 else if (mhit <= 0)
2604 notice(s_GameServ, u, "%s completely misses you!", battle->nick);
2605*
2606 if (mhit >= ni->stats->hp)
2607 {
2608 notice(s_GameServ, u, "You have been \ 2\1fkilled\1f\ 2 by %s!", battle->nick);
2609 if (2000000000 - battle->stats->gold > ni->stats->gold)
2610 {
2611 notice(s_GameServ, u, "%s took all your gold!", battle->nick);
2612 battle->stats->gold += ni->stats->gold;
2613* ni->stats->gold = 0;
2614 }
2615 else
2616 {
2617 notice(s_GameServ, u, "You're lucky, %s couldn't carry all your gold.",
2618 battle->nick);
2619 ni->stats->gold -= (2000000000 - battle->stats->gold);
2620 notice(s_GameServ, u, "You were left dead with %d gold.",
2621* (long int)ni->stats->gold);
2622 battle->stats->gold = 2000000000;
2623 }
2624 ni->stats->battle->battle = NULL;
2625 ni->stats->battle = NULL;
2626 ni->stats->alive = 0;
2627 return;
2628 }
2629* else
2630 {
2631 if (mhit > 0)
2632 ni->stats->hp -= mhit;
2633 display_players(u);
2634 return;
2635 }
2636 }
2637 }
2638* end offline fighting */
2639
2640 if (is_playing(battle->getNick()))
2641 {
2642 if (!isYourTurn(ni->stats))
2643 {
2644 notice(s_GameServ, u, "Please wait until %s decides what to do!",
2645 battle->getNick());
2646 return;
2647 }
2648 if (hit > 0)
2649 {
2650 notice(s_GameServ, u, "You attack \1f%s\1f for \ 2%d\ 2 points!", battle->getNick(), hit);
2651
2652 notice(s_GameServ, battle->getNick(), "%s has hit you with their %s for "\
2653 "\ 2%d\ 2 damage!", u, weapons[ni->stats->weapon],
2654 hit);
2655 clearYourTurn(ni->stats);
2656 setYourTurn(battle->stats);
2657 display_players(battle->getNick());
2658 }
2659 else
2660 {
2661 notice(s_GameServ, u, "You miss \1f%s\1f completely!", battle->getNick());
2662 notice(s_GameServ, battle->getNick(), "%s misses you completely!", u);
2663 clearYourTurn(ni->stats);
2664 setYourTurn(battle->stats);
2665 display_players(battle->getNick());
2666 }
2667 if (hit >= battle->stats->hp)
2668 {
2669 notice(s_GameServ, u, "You have killed \ 2%s\ 2!", battle->getNick());
2670 notice(s_GameServ, u, "You recieve \ 2%d\ 2 experience and \ 2%ld\ 2 gold!",
2671 (long int)(battle->stats->exp * .10), battle->stats->gold);
2672 notice(s_GameServ, battle->getNick(), "You have been killed by \ 2%s\ 2!", u);
2673 battle->stats->hp = 0;
2674 clearAlive(battle->stats);
2675
2676 if (2000000000 - ni->stats->exp > (long int)(battle->stats->exp * .10))
2677 {
2678 ni->stats->exp += (long int)(battle->stats->exp * .10);
2679 battle->stats->exp -= (long int)(battle->stats->exp * .10);
2680 }
2681 else
2682 {
2683 battle->stats->exp -= (long int)(battle->stats->exp * .10);
2684 ni->stats->exp = 2000000000;
2685 }
2686
2687 if (2000000000 - ni->stats->gold > battle->stats->gold)
2688 {
2689 notice(s_GameServ, battle->getNick(), "You lose ten percent of experience and "\
2690 "all gold on hand!");
2691 ni->stats->gold += battle->stats->gold;
2692 battle->stats->gold = 0;
2693 }
2694 else
2695 {
2696 battle->stats->gold = 2000000000 - ni->stats->gold;
2697 notice(s_GameServ, battle->getNick(), "You lose ten percent of your experience!");
2698
2699 notice(s_GameServ, battle->getNick(), "However, %s could not carry all of your "\
2700 "gold.", u);
2701
2702 notice(s_GameServ, battle->getNick(), "Luckily, you still have \ 2%ld\ 2 gold "\
2703 "left. All is not lost!", battle->stats->gold);
2704
2705 ni->stats->gold = 2000000000;
2706 }
2707 battle->stats->battle = NULL;
2708 ni->stats->battle = NULL;
2709 return;
2710 }
2711 else
2712 {
2713 if (hit > 0)
2714 battle->stats->hp -= hit;
2715 clearYourTurn(ni->stats);
2716 setYourTurn(battle->stats);
2717 notice(s_GameServ, u, "Please wait while %s decides what to do!",
2718 battle->getNick());
2719
2720 return;
2721 }
2722 }
2723 }
2724}
2725void do_heal(char *u)
2726{
2727 aClient *ni;
2728 char *amount = strtok(NULL, " ");
2729 int price, num;
2730
2731 if (!amount)
2732 {
2733 notice(s_GameServ, u, "SYNTAX: /msg %S HEAL {ALL | #}");
2734 }
2735 else if (!(ni = find(u)))
2736 {
2737 notice(s_GameServ, u, "Fatal error. Contact a(n) %S admin. buf: %s", strtok(NULL, ""));
2738 return;
2739 }
2740 else if (!is_playing(ni))
2741 {
2742 notice(s_GameServ, u, "You aren't playing!");
2743 return;
2744 }
2745 else if (!isAlive(ni->stats))
2746 {
2747 notice(s_GameServ, u, "You are dead. Wait until tomorrow for healing.");
2748 return;
2749 }
2750 else if (is_fighting(ni))
2751 {
2752 notice(s_GameServ, u, "You can't heal in battle!");
2753 }
2754 else if (ni->stats->hp >= ni->stats->maxhp)
2755 {
2756 notice(s_GameServ, u, "You don't need healing!");
2757 }
2758 else if (stricmp(amount, "ALL") == 0)
2759 {
2760 price = ni->stats->level * 3;
2761 if (ni->stats->gold < (ni->stats->maxhp - ni->stats->hp) * price)
2762 {
2763 notice(s_GameServ, u, "Healing \ 2%d\ 2 points for \ 2%d\ 2 gold per point.",
2764 (long int)ni->stats->gold/price, price);
2765 ni->stats->hp += ni->stats->gold / price;
2766 ni->stats->gold %= price;
2767 }
2768 else
2769 {
2770 notice(s_GameServ, u, "Healing all possible points at \ 2%d\ 2 gold "\
2771 "per point.", price);
2772 notice(s_GameServ, u, "\ 2%d\ 2 points healed for \ 2%ld\ 2 gold. HP at MAX!",
2773 (ni->stats->maxhp - ni->stats->hp),
2774 (price * (ni->stats->maxhp - ni->stats->hp)) );
2775 ni->stats->gold -= price * (ni->stats->maxhp - ni->stats->hp);
2776 ni->stats->hp = ni->stats->maxhp;
2777 }
2778 }
2779 else if (isstringnum(amount))
2780 {
2781 num = stringtoint(amount);
2782 price = ni->stats->level * 3;
2783 if (ni->stats->gold < price * num)
2784 {
2785 notice(s_GameServ, u, "You only have enough gold to heal \ 2%d\ 2 points!",
2786 (long int)ni->stats->gold/price);
2787 }
2788 else if (num <= ni->stats->maxhp - ni->stats->hp)
2789 {
2790 notice(s_GameServ, u, "Healing \ 2%d\ 2 points at \ 2%d\ 2 gold per point.",
2791 num, price);
2792 ni->stats->hp += num;
2793 ni->stats->gold -= num * price;
2794 }
2795 else if (num > ni->stats->maxhp - ni->stats->hp)
2796 {
2797 notice(s_GameServ, u, "Healing all possible points at \ 2%d\ 2 gold "\
2798 "per point.", price);
2799 notice(s_GameServ, u, "\ 2%d\ 2 points healed. HP at MAX!",
2800 (ni->stats->maxhp - ni->stats->hp));
2801 ni->stats->gold -= price * (ni->stats->maxhp - ni->stats->hp);
2802 ni->stats->hp = ni->stats->maxhp;
2803 }
2804 }
2805 else if (amount[0] == '-')
2806 notice(s_GameServ, u, "You trying to cheat?");
2807 else
2808 notice(s_GameServ, u, "SYNTAX: /msg %S HEAL {ALL | #}");
2809}
2810
2811int isstringnum(char *num)
2812{
2813 unsigned int x;
2814 for (x = 0; x < strlen(num); x++)
2815 {
2816 if ((int)num[x] < 48 || (int)num[x] > 57)
2817 return 0;
2818 }
2819return 1;
2820}
2821
2822long int stringtoint(char *number)
2823{
2824 long int x, len = strlen(number), sum = 0;
2825 if (len == 1)
2826 return chartoint(number[0]);
2827 sum += chartoint(number[len - 1]);
2828 for (x = len - 2; x >= 0; x--)
2829 sum += chartoint(number[x]) * pow(10, abs(x - len + 1));
2830 return sum;
2831}
2832
2833long int pow(int x, int y)
2834{
2835 long int value = 0;
2836 int count = 0;
2837 value += x;
2838
2839 if (x != 0 && y != 0)
2840 {
2841 for (count = 1; count <= y - 1; count++)
2842 value *= x;
2843 }
2844 else
2845 return 1;
2846return value;
2847}
2848
2849long int chartoint(char ch)
2850{
2851 if (int(ch) >= 48 && int(ch) <= 57)
2852 return int(ch) - 48;
2853 else
2854 return 0;
2855}
2856
2857int save_gs_dbase()
2858{
2859 ListNode<aClient> *ptr = players.First();
2860 Player *it;
2861 ofstream outfile;
2862
2863 outfile.open(playerdata);
2864
2865 if (!outfile)
2866 {
2867 log("Error opening %s", playerdata);
2868 return 0;
2869 }
2870
2871 while(ptr)
2872 {
2873 it = ptr->getData()->stats;
2874 outfile << it->name << ' ' << it->level << ' ' << it->exp << ' ' << it->gold << ' ' << it->bank << ' '
2875 << it->hp << ' ' << it->maxhp << ' ' << it->strength << ' ' << it->defense << ' '
2876 << it->armor << ' ' << it->weapon << ' '
2877 << it->forest_fights << ' ' << it->player_fights << ' '
2878 << it->getFlags() << ' ' << it->password << ' ' << it->inventory.Healing()
2879 << ' ' << it->inventory.Strength() << ' ' << it->inventory.Defense() << ' ' << it->inventory.HP() << endl;
2880 ptr = ptr->Next();
2881 }
2882outfile.close();
2883return 1;
2884}
2885
2886int load_gs_dbase()
2887{
2888 ifstream infile;
2889 aClient *temp;
2890 Player *p;
2891 char *tempname, *buf, *password;
2892 buf = new char[1023];
2893
2894 infile.open(playerdata);
2895
2896 if (infile.fail())
2897 {
2898 log("Error opening %s", playerdata);
2899 return 0;
2900 }
2901
2902 while (infile.getline(buf, 1024, '\n'))
2903 {
2904 temp = new aClient;
2905 tempname = strtok(buf, " ");
2906 temp->stats = new Player(tempname);
2907 p = temp->stats;
2908
2909 p->level = stringtoint(strtok(NULL, " "));
2910 p->exp = stringtoint(strtok(NULL, " "));
2911 p->gold = stringtoint(strtok(NULL, " "));
2912 p->bank = stringtoint(strtok(NULL, " "));
2913 p->hp = stringtoint(strtok(NULL, " "));
2914 p->maxhp = stringtoint(strtok(NULL, " "));
2915 p->strength = stringtoint(strtok(NULL, " "));
2916 p->defense = stringtoint(strtok(NULL, " "));
2917 p->armor = stringtoint(strtok(NULL, " "));
2918 p->weapon = stringtoint(strtok(NULL, " "));
2919 p->forest_fights = stringtoint(strtok(NULL, " "));
2920 p->player_fights = stringtoint(strtok(NULL, " "));
2921 p->setFlags(stringtoint(strtok(NULL, " ")));
2922
2923 password = strtok(NULL, " ");
2924 strcpy(p->password, password);
2925 temp->setNick("!NULL!");
2926
2927 p->inventory.reset(); // Set inventory to all 0s
2928 // Old player databases didn't have these three extra values
2929 // If they come up null, leave them to 0 as the default.
2930 // On the next gameserv database save, it will save the values.
2931 tempname = strtok(NULL, " ");
2932 if (tempname)
2933 p->inventory.setHealing(stringtoint(tempname));
2934
2935 tempname = strtok(NULL, " ");
2936 if (tempname)
2937 p->inventory.setStrength(stringtoint(tempname));
2938
2939 tempname = strtok(NULL, " ");
2940 if (tempname)
2941 p->inventory.setDefense(stringtoint(tempname));
2942
2943 tempname = strtok(NULL, " ");
2944 if (tempname)
2945 p->inventory.setHP(stringtoint(tempname));
2946
2947 players.insertAtBack(temp);
2948 delete temp;
2949 }
2950delete [] buf;
2951infile.close();
2952return 1;
2953}
2954
2955bool passcmp(char *encrypted, char *plaintext)
2956{
2957 char salt[3];
2958 char *plaintext2, *plainToencrypt;
2959 bool same = false;
2960
2961 plaintext2 = new char[strlen(encrypted) + strlen(plaintext)]; // Extra
2962 strcpy(plaintext2, plaintext);
2963
2964 salt[0] = encrypted[0];
2965 salt[1] = encrypted[1];
2966 salt[3] = '\0';
2967
2968 plainToencrypt = crypt(plaintext2, salt);
2969
2970 same = (strcmp((const char *)encrypted, plainToencrypt) == 0 ? true : false);
2971
2972 delete []plaintext2;
2973
2974 return same;
2975}
2976
2977bool check_password(char *name, char *plaintext)
2978{
2979 aClient *client;
2980
2981 if (!(client = findplayer(name)))
2982 return false;
2983 else
2984 {
2985 return passcmp(client->stats->password, plaintext);
2986 }
2987}
2988
2989void do_store(char *u)
2990{
2991 char *cmd = strtok(NULL, " ");
2992 char *item = strtok(NULL, " ");
2993 char *num = strtok(NULL, " ");
2994 char *space;
2995 int wep;
2996 aClient *user;
2997 Player *p;
2998
2999 if (!cmd || !item)
3000 {
3001 notice(s_GameServ, u, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
3002 notice(s_GameServ, u, " \ 2STORE SELL {ARMOR | WEAPON}\ 2");
3003 notice(s_GameServ, u, " \ 2STORE BUY {ARMOR | WEAPON} \1fNUMBER\1f\ 2");
3004 }
3005 else if (!(user = find(u)) || !is_playing(user))
3006 notice(s_GameServ, u, "You must be playing to use the store!");
3007 else if (!isAlive(user->stats))
3008 {
3009 notice(s_GameServ, u, "You are dead. Wait until tomorrow to purchase weapons and armor!");
3010 return;
3011 }
3012 else if (stricmp(cmd, "LIST") == 0)
3013 {
3014 if (stricmp(item, "WEAPONS") == 0)
3015 {
3016 notice(s_GameServ, u, "Welcome to Kain's Armory");
3017 notice(s_GameServ, u, "Here are the weapons we have available for the killing, sire:");
3018 for (int x = 1; x < WNA; x++)
3019 {
3020 space = spaces(strlen(weapons[x]), ".");
3021 notice(s_GameServ, u, "%s%d. %s%s%d",(x < 10 ? " " : ""), x, weapons[x], space, prices[x - 1]);
3022 free(space);
3023 }
3024 notice(s_GameServ, u, "To purchase a weapon, type /msg %S STORE BUY \ 2NUM\ 2.");
3025 notice(s_GameServ, u, "Where num. is the weapon number from the menu above.");
3026
3027 }
3028 else if (stricmp(item, "ARMOR") == 0)
3029 {
3030 notice(s_GameServ, u, "Welcome to Kain's Armory");
3031 notice(s_GameServ, u, "I hope you enjoy the fine armor we have available for your protection:");
3032 for (int x = 1; x < WNA; x++)
3033 {
3034 space = spaces(strlen(armors[x]), ".");
3035 notice(s_GameServ, u, "%s%d. %s%s%d",(x < 10 ? " " : ""), x, armors[x], space, prices[x - 1]);
3036 free(space);
3037 }
3038 notice(s_GameServ, u, "To purchase armor, type /msg %S store buy armor num.");
3039 notice(s_GameServ, u, "Where num. is the armor number from the menu above.");
3040
3041
3042 }
3043 } else if (stricmp(cmd, "BUY") == 0) {
3044 if (!num)
3045 {
3046 notice(s_GameServ, u, "SYNTAX: \ 2STORE BUY {ARMOR | WEAPON} \1fNUMBER\1f\ 2");
3047 return;
3048 }
3049 else if (!isstringnum(num))
3050 {
3051 notice(s_GameServ, u, "You must specify a number between 1 and %d. Not %s!", WNA - 1, num);
3052 return;
3053 }
3054 if (stricmp(item, "WEAPON") == 0)
3055 {
3056 wep = stringtoint(num);
3057 if (wep >= WNA || wep < 1)
3058 {
3059 notice(s_GameServ, u, "The number %d is out of range. The number you provide must be between 1 and %d.", wep, WNA - 1);
3060 return;
3061 }
3062
3063 p = user->stats;
3064
3065 if (p->weapon != 0)
3066 notice(s_GameServ, u, "You have to sell your %s first!", weapons[p->weapon]);
3067 else if (p->gold < prices[wep - 1])
3068 notice(s_GameServ, u, "You don't have enough gold for %s!", weapons[wep]);
3069 else
3070 {
3071 notice(s_GameServ, u, "You have purchased %s! Thanks for the gold!", weapons[wep]);
3072 p->weapon = wep;
3073 p->gold -= prices[wep - 1];
3074 }
3075 }
3076 else if (stricmp(item, "ARMOR") == 0)
3077 {
3078 wep = stringtoint(num);
3079 if (wep >= WNA || wep < 1)
3080 {
3081 notice(s_GameServ, u, "The number %d is out of range. The number you provide must be between 1 and %d.", wep, WNA - 1);
3082 return;
3083 }
3084
3085 p = user->stats;
3086
3087 if (p->armor != 0)
3088 notice(s_GameServ, u, "You have to sell your %s first!", armors[p->armor]);
3089 else if (p->gold < prices[wep - 1])
3090 notice(s_GameServ, u, "You don't have enough gold for %s!", armors[wep]);
3091 else
3092 {
3093 notice(s_GameServ, u, "You have purchased %s! Thanks for the gold!", armors[wep]);
3094 p->armor = wep;
3095 p->gold -= prices[wep - 1];
3096 }
3097 }
3098 }
3099 else if (stricmp(cmd, "SELL" ) == 0)
3100 {
3101 p = user->stats;
3102
3103 if (stricmp(item, "WEAPON") == 0)
3104 {
3105 if (p->weapon == 0)
3106 {
3107 notice(s_GameServ, u, "You want me to chop off your hands?");
3108 return;
3109 }
3110 else if (p->gold == 2000000000)
3111 {
3112 notice(s_GameServ, u, "You have enough gold. I'll just take that off your hands, sire.");
3113 p->weapon = 0;
3114 }
3115 else if (2000000000 - p->gold < (prices[p->weapon - 1] / 2))
3116 {
3117 notice(s_GameServ, u, "Thank you for your business! You now have as much gold as you can carry.");
3118 notice(s_GameServ, u, "However, you have no weapon... can I interest you in the %s?", weapons[WNA - 1]);
3119 p->gold = 2000000000;
3120 p->weapon = 0;
3121 }
3122 else
3123 {
3124 notice(s_GameServ, u, "Thank you for your business! You now have %d more gold but no weapon!", (prices[p->weapon - 1] / 2));
3125 p->gold += (prices[p->weapon - 1] / 2);
3126 p->weapon = 0;
3127 }
3128 }
3129 else if (stricmp(item, "ARMOR") == 0)
3130 {
3131 p = user->stats;
3132
3133 if (p->armor == 0)
3134 {
3135 notice(s_GameServ, u, "I don't think you can be any more naked...");
3136 return;
3137 }
3138 if (p->gold == 2000000000)
3139 {
3140 notice(s_GameServ, u, "You have enough gold. I'll just take that off your hands, sire.");
3141 p->armor = 0;
3142 }
3143 else if (2000000000 - p->gold < (prices[p->armor - 1] / 2))
3144 {
3145 notice(s_GameServ, u, "Thank you for your business! You now have as much gold as you can carry.");
3146 notice(s_GameServ, u, "However, you have no armor... can I interest you in %s?", armors[WNA - 1]);
3147 p->gold = 2000000000;
3148 p->armor = 0;
3149 }
3150 else
3151 {
3152 notice(s_GameServ, u, "Thank you for your business! You now have %d more gold but no armor!",
3153 (prices[p->armor - 1] / 2));
3154
3155 p->gold += (prices[p->armor - 1] / 2);
3156 p->armor = 0;
3157 }
3158 }
3159 else
3160 {
3161 notice(s_GameServ, u, "SYNTAX: STORE LIST {ARMOR | WEAPONS}");
3162 notice(s_GameServ, u, " \ 2STORE SELL {ARMOR | WEAPON}\ 2");
3163 notice(s_GameServ, u, " \ 2STORE BUY {ARMOR | WEAPON} \1fNUMBER\1f\ 2");
3164 }
3165 }
3166}
3167void do_inventory(char *u)
3168{
3169 aClient *user;
3170
3171 if (!(user = find(u)))
3172 {
3173 notice(s_GameServ, u, "Fatal Error. Contact a %S admin!");
3174 return;
3175 }
3176 else if (!is_playing(user))
3177 {
3178 notice(s_GameServ, u, "You must be playing to check your inventory!");
3179 return;
3180 }
3181 showinventory(user, user);
3182}
3183void showinventory(aClient *from, aClient *to)
3184{
3185 char *nick = to->getNick();
3186
3187 if (!to)
3188 to = from;
3189 if (is_playing(from))
3190 {
3191 Pouch *p = &from->stats->inventory;
3192 notice(s_GameServ, nick, "Inventory for %s:", from->getNick());
3193 notice(s_GameServ, nick, " Healing Potions: %d", p->Healing());
3194 notice(s_GameServ, nick, "Strength Potions: %d", p->Strength());
3195 notice(s_GameServ, nick, " Defense Potions: %d", p->Defense());
3196 notice(s_GameServ, nick, " HP Potions: %d", p->HP());
3197 }
3198}
3199void do_tavern(char *u)
3200{
3201 char *cmd = strtok(NULL, " ");
3202 long int price;
3203
3204 aClient *user;
3205 Player *p;
3206 if (!(user = find(u)))
3207 {
3208 notice(s_GameServ, u, "Fatal Error. See a %S admin for help");
3209 return;
3210 }
3211 else if (!is_playing(user))
3212 {
3213 notice(s_GameServ, u, "You must be playing to go to the Tavern");
3214 return;
3215 }
3216 else if (is_fighting(user))
3217 {
3218 notice(s_GameServ, u, "You cannot go to the Tavern during a fight!");
3219 return;
3220 }
3221 p = user->stats;
3222 if (!cmd)
3223 {
3224 notice(s_GameServ, u, "Welcome to Boot Liquors Mystic Apothecary");
3225 notice(s_GameServ, u, "Your commands:");
3226 notice(s_GameServ, u, "/msg %S TAVERN {LIST | BUY} [NUMBER]");
3227 notice(s_GameServ, u, "What'll it be?");
3228 }
3229 else if (stricmp(cmd, "LIST") == 0)
3230 {
3231 notice(s_GameServ, u, "Here is a list of what we have to offer:");
3232 notice(s_GameServ, u, "1. Healing Potions for %ld Gold", 1000 * p->level + (p->exp / 10));
3233 notice(s_GameServ, u, "2. Strength Potions for %ld Gold", 2050 * p->level + (p->exp / 10));
3234 notice(s_GameServ, u, "3. Defense Potions for %ld Gold", 2000 * p->level + (p->exp / 10));
3235 notice(s_GameServ, u, "4. HP Potions for %ld Gold", 2300 * p->level + (p->exp / 10));
3236 notice(s_GameServ, u, "To buy a potion, type /msg %S TAVERN BUY #");
3237 notice(s_GameServ, u, "Example: /msg %S TAVERN BUY 1 buys a healing potion!");
3238 notice(s_GameServ, u, "By something will ya!");
3239 }
3240 else if (stricmp(cmd, "BUY") == 0)
3241 {
3242 char *chnum = strtok(NULL, " ");
3243 int num = stringtoint(chnum);
3244
3245 if (!chnum)
3246 {
3247 notice(s_GameServ, u, "SYNTAX: TAVERN BUY #");
3248 notice(s_GameServ, u, "Example: /msg %S TAVERN BUY 1");
3249 return;
3250 }
3251 if (num < 1 || num > 4)
3252 {
3253 notice(s_GameServ, u, "Invalid Choice!");
3254 notice(s_GameServ, u, "Here is a list of what we have to offer:");
3255 notice(s_GameServ, u, "1. Healing Potions for %ld Gold", 1000 * p->level + (p->exp / 10));
3256 notice(s_GameServ, u, "2. Strength Potions for %ld Gold", 2050 * p->level + (p->exp / 10));
3257 notice(s_GameServ, u, "3. Defense Potions for %ld Gold", 2000 * p->level + (p->exp / 10));
3258 notice(s_GameServ, u, "4. HP Potions for %ld Gold", 2300 * p->level + (p->exp / 10));
3259 notice(s_GameServ, u, "To buy a potion, type /msg %S TAVERN BUY #");
3260 notice(s_GameServ, u, "Example: /msg %S TAVERN BUY 1 buys a healing potion!");
3261 return;
3262 }
3263 switch(num)
3264 {
3265 case 1:
3266 price = (1000 * p->level) + (p->exp / 10);
3267 if (p->gold >= price)
3268 {
3269 notice(s_GameServ, u, "One healing potion coming right up!");
3270 p->inventory.incHealing();
3271 p->gold -= price;
3272 }
3273 else
3274 notice(s_GameServ, u, "You don't have enough gold!");
3275 break;
3276 case 2:
3277 price = (2050 * p->level) + (p->exp / 10);
3278 if (p->gold >= price)
3279 {
3280 notice(s_GameServ, u, "One strength boost coming right up!");
3281 p->inventory.incStrength();
3282 p->gold -= price;
3283 }
3284 else
3285 notice(s_GameServ, u, "You don't have enough gold!");
3286 break;
3287 case 3:
3288 price = (2000 * p->level) + (p->exp / 10);
3289 if (p->gold >= price)
3290 {
3291 notice(s_GameServ, u, "One defense boost coming right up!");
3292 p->inventory.incDefense();
3293 p->gold -= price;
3294 }
3295 else
3296 notice(s_GameServ, u, "You don't have enough gold!");
3297 break;
3298 case 4:
3299 price = (2300 * p->level) + (p->exp / 10);
3300 if (p->gold >= price)
3301 {
3302 notice(s_GameServ, u, "One HP Potion coming right up!");
3303 p->inventory.incHP();
3304 p->gold -= price;
3305 }
3306 else
3307 notice(s_GameServ, u, "You don't have enough gold!");
3308 break;
3309 default:
3310 notice(s_GameServ, u, "Logical Error. See a %S admin for help!");
3311 break;
3312 }
3313 }
3314 else
3315 {
3316 notice(s_GameServ, u, "Improper Syntax.");
3317 notice(s_GameServ, u, "Type /msg %S HELP TAVERN for help");
3318 }
3319}
3320
3321void do_bank(char *u)
3322{
3323 char *cmd = strtok(NULL, " ");
3324 char *amount = strtok(NULL, " ");
3325 char *nick = strtok(NULL, " ");
3326
3327 aClient *user;
3328 Player *p;
3329
3330 if (!cmd || (!amount && stricmp(cmd, "BALANCE") != 0) || (stricmp(cmd, "TRANSFER") == 0 && !nick))
3331 {
3332 notice(s_GameServ, u, "BANK {WITHDRAW | DEPOSIT} {ALL | AMOUNT}");
3333 notice (s_GameServ, u, "BANK BALANCE");
3334 return;
3335 }
3336
3337 user = find(u);
3338 if (!is_playing(user))
3339 {
3340 notice(s_GameServ, u, "You must be playing to use the bank!");
3341 return;
3342 }
3343 else if (!isAlive(user->stats))
3344 {
3345 notice(s_GameServ, u, "You are dead. We don't accept gold from dead folk! Wait 'til tomorrow!");
3346 return;
3347 }
3348 else if (!isstringnum(amount) && stricmp(amount, "ALL") != 0)
3349 {
3350 notice(s_GameServ, u, "I don't know how to convert alphabet letters into currency, sire!");
3351 return;
3352 }
3353
3354 p = user->stats;
3355
3356 if (stricmp(cmd, "BALANCE") == 0)
3357 {
3358 showBankBalance(u);
3359 }
3360 else if (stricmp(cmd, "DEPOSIT") == 0)
3361 {
3362 if (p->bank == 2000000000)
3363 {
3364 notice(s_GameServ, u, "Your bank account is full, sire!");
3365 return;
3366 }
3367 else if (stricmp(amount, "ALL") == 0)
3368 {
3369 if (2000000000 - p->bank < p->gold)
3370 {
3371 notice(s_GameServ, u, "You don't have enough room for all of your gold.");
3372 notice(s_GameServ, u, "Depositing %ld gold into your account", (2000000000 - p->bank));
3373 p->gold -= (2000000000 - p->bank);
3374 p->bank = 2000000000;
3375 showBankBalance(u);
3376 }
3377 else
3378 {
3379 notice(s_GameServ, u, "Depositing %ld gold into your account!", p->gold);
3380 p->bank += p->gold;
3381 p->gold = 0;
3382 showBankBalance(u);
3383 }
3384 }
3385 else if (stringtoint(amount) > p->gold)
3386 {
3387 notice(s_GameServ, u, "Sire, you only have %ld gold!", p->gold);
3388 showBankBalance(u);
3389 return;
3390 }
3391 else
3392 {
3393 if (2000000000 - p->bank < stringtoint(amount))
3394 {
3395 notice(s_GameServ, u, "You don't have room in your account for that much.");
3396 notice(s_GameServ, u, "Capping off your account with %ld gold!", (2000000000 - p->bank));
3397 p->gold -= (2000000000 - p->bank);
3398 p->bank = 2000000000;
3399 showBankBalance(u);
3400 }
3401 else
3402 {
3403 notice(s_GameServ, u, "Depositing %d gold into your account!", stringtoint(amount));
3404 p->bank += stringtoint(amount);
3405 p->gold -= stringtoint(amount);
3406 showBankBalance(u);
3407 }
3408 }
3409 }
3410 else if (stricmp(cmd, "WITHDRAW") == 0)
3411 {
3412 if (p->gold == 2000000000)
3413 {
3414 notice(s_GameServ, u, "You cannot carry any more gold, sire!");
3415 showBankBalance(u);
3416 return;
3417 }
3418 else if (stricmp(amount, "ALL") == 0)
3419 {
3420 if (2000000000 - p->gold < p->bank)
3421 {
3422 notice(s_GameServ, u, "You don't have enough room to carry all that gold.");
3423 notice(s_GameServ, u, "Withdrawing %ld gold from your account", (2000000000 - p->gold));
3424 p->bank -= (2000000000 - p->gold);
3425 p->gold = 2000000000;
3426 showBankBalance(u);
3427 }
3428 else
3429 {
3430 notice(s_GameServ, u, "Withdrawing %ld gold from your account!", p->bank);
3431 p->gold += p->bank;
3432 p->bank = 0;
3433 showBankBalance(u);
3434 }
3435 }
3436 else if (stringtoint(amount) > p->bank)
3437 {
3438 notice(s_GameServ, u, "Sire, you only have %ld gold in the bank!", p->bank);
3439 showBankBalance(u);
3440 return;
3441 }
3442 else
3443 {
3444 if (2000000000 - p->gold < stringtoint(amount))
3445 {
3446 notice(s_GameServ, u, "You don't enough have room to carry that much gold!");
3447 notice(s_GameServ, u, "You fill your pockets with %ld gold!",
3448 (2000000000 - p->gold));
3449 p->bank -= (2000000000 - p->gold);
3450 p->gold = 2000000000;
3451 showBankBalance(u);
3452 }
3453 else
3454 {
3455 notice(s_GameServ, u, "Withdrawing %d gold from your account!", stringtoint(amount));
3456 p->gold += stringtoint(amount);
3457 p->bank -= stringtoint(amount);
3458 showBankBalance(u);
3459 }
3460 }
3461 }
3462
3463}
3464
3465void do_master(char *u)
3466{
3467 aClient *user;
3468 user = find(u);
3469
3470 if (!user)
3471 {
3472 notice(s_GameServ, u, "Fatal error. Contact a(n) %S admin. buf: %s", strtok(NULL, ""));
3473 return;
3474 }
3475 else if (is_fighting(user))
3476 {
3477 notice(s_GameServ, u, "You're in the middle of a fight! Pay attention!");
3478 return;
3479 }
3480 else if (!isAlive(user->stats))
3481 {
3482 notice(s_GameServ, u, "You're dead. Wait until tomorrow to see your master!");
3483 return;
3484 }
3485 else if (!is_playing(user))
3486 {
3487 notice(s_GameServ, u, "You must be playing to see your master!");
3488 return;
3489 }
3490
3491 char *cmd = strtok(NULL, " ");
3492 Player *p = user->stats;
3493 long int need = 0;
3494
3495 if (seenMaster(p))
3496 {
3497 notice(s_GameServ, u, "You have already seen your master today. Wait until tomorrow to try again");
3498 return;
3499 }
3500
3501 if (cmd != NULL)
3502 {
3503 switch(p->level)
3504 {
3505 case 1:
3506 need = 100;
3507 break;
3508 case 2:
3509 need = 400;
3510 break;
3511 case 3:
3512 need = 1000;
3513 break;
3514 case 4:
3515 need = 4000;
3516 break;
3517 case 5:
3518 need = 10000;
3519 break;
3520 case 6:
3521 need = 40000;
3522 break;
3523 case 7:
3524 need = 100000;
3525 break;
3526 case 8:
3527 need = 400000;
3528 break;
3529 case 9:
3530 need = 1000000;
3531 break;
3532 case 10:
3533 need = 4000000;
3534 break;
3535 case 11:
3536 need = 10000000;
3537 break;
3538 case 12:
3539 need = p->exp + 1;
3540 notice(s_GameServ, u, "You are at level 12. You are the master. What's left? The DRAGON!");
3541 break;
3542 default:
3543 need = p->exp + 1; // Unknown level... don't let them fight a fake master!
3544 break;
3545 }
3546 }
3547 else
3548 {
3549 notice(s_GameServ, u, "SYNTAX: MASTER {FIGHT | QUESTION}");
3550 return;
3551 }
3552
3553 if (stricmp(cmd, "FIGHT") == 0)
3554 {
3555 if (p->exp >= need)
3556 {
3557 setMaster(p);
3558 see_master(u);
3559 }
3560 else
3561 notice(s_GameServ, u, "You are not worthy of fighting %s! You need %ld more experience.", masters[p->level - 1]->name, (need - p->exp));
3562 return;
3563 }
3564 else if (stricmp(cmd, "QUESTION") == 0)
3565 {
3566 if (p->exp >= need)
3567 notice(s_GameServ, u, "%s looks you up and down and decides you are more ready than you will ever be.", masters[p->level - 1]->name);
3568 else
3569 notice(s_GameServ, u, "You pathetic fool! You are no match for %s, %s!", masters[p->level - 1]->name, p->name);
3570
3571 return;
3572 }
3573 else
3574 {
3575 notice(s_GameServ, u, "SYNTAX: MASTER {FIGHT | QUESTION}");
3576 }
3577}
3578
3579void see_master(char *u)
3580{
3581 aClient *user;
3582
3583 if (!(user = find(u)))
3584 {
3585 notice(s_GameServ, u, "Fatal error. Contact a(n) %S admin. buf: %s", strtok(NULL, ""));
3586 return;
3587 }
3588
3589 if (!is_fighting(user) && is_playing(user))
3590 {
3591 Player *p = user->stats;
3592 p->master = new Monster(masters[p->level - 1]);
3593 p->fight = p->master;
3594 display_monster(u); // Since master is the same structure, use this function
3595 }
3596}
3597
3598void showBankBalance(const char *u)
3599{
3600 aClient *user;
3601 Player *p;
3602
3603 if (!(user = find(u)))
3604 return;
3605
3606 p = user->stats;
3607
3608 if (!p)
3609 return;
3610
3611 notice(s_GameServ, u, "Account Balance: %ld Gold On hand: %ld", p->bank, p->gold);
3612
3613}
3614
3615void refreshall()
3616{
3617 ListNode <aClient> *it;
3618 Player *p;
3619
3620 it = players.First();
3621
3622 while (it)
3623 {
3624 p = it->getData()->stats;
3625 refresh(p);
3626 it = it->Next();
3627 }
3628}
3629
3630void refresh(Player *p)
3631{
3632 if (!p)
3633 return;
3634
3635 if (p->hp < p->maxhp)
3636 p->hp = p->maxhp;
3637 p->forest_fights = forestfights;
3638 p->player_fights = 3;
3639 setAlive(p);
3640 clearMaster(p);
3641}
3642
3643void do_refresh(char *u)
3644{
3645 char *nick = strtok(NULL, " ");
3646 aClient *user;
3647
3648 if (!(user = find(u)))
3649 {
3650 notice(s_GameServ, u, "Error: aClient not found. Contact a %S admin");
3651 log("Error: aClient not found: %s", u);
3652 return;
3653 }
3654 else if (!isAdmin(user))
3655 {
3656 notice(s_GameServ, u, "You must be a %S admin to use this command!");
3657 return;
3658 }
3659 if (!nick)
3660 {
3661 notice(s_GameServ, u, "SYNTAX: REFRESH {ALL | NICK}");
3662 return;
3663 }
3664 else if (stricmp(nick, "ALL") == 0)
3665 {
3666 notice(s_GameServ, u, "Refreshing everyone's stats!");
3667 refreshall();
3668 }
3669 else if ((user = find(nick)))
3670 {
3671 if (is_playing(user))
3672 {
3673 notice(s_GameServ, u, "Refreshing %s.", user->getNick());
3674 refresh(user->stats);
3675 }
3676 else
3677 {
3678 notice(s_GameServ, u, "%s is not playing.", user->getNick());
3679 }
3680 }
3681 else
3682 {
3683 notice(s_GameServ, u, "Nick %s not found.", nick);
3684 return;
3685 }
3686}
3687
3688
3689void resetall()
3690{
3691 ListNode <aClient> *it;
3692 Player *p;
3693
3694 it = players.First();
3695
3696 while (it)
3697 {
3698 p = it->getData()->stats;
3699 reset(p);
3700 it = it->Next();
3701 }
3702}
3703
3704void reset(Player *p)
3705{
3706 if (!p)
3707 return;
3708
3709 p->reset();
3710}
3711
3712void do_reset(char *u)
3713{
3714 char *nick = strtok(NULL, " ");
3715 aClient *user;
3716
3717 if (!(user = find(u)))
3718 {
3719 notice(s_GameServ, u, "Error: aClient not found. Contact a %S admin");
3720 log("Error: aClient not found: %s", u);
3721 return;
3722 }
3723 else if (!isAdmin(user))
3724 {
3725 notice(s_GameServ, u, "You must be a %S admin to use this command!");
3726 return;
3727 }
3728 if (!nick)
3729 {
3730 notice(s_GameServ, u, "SYNTAX: RESET {ALL | NICK}");
3731 return;
3732 }
3733 else if (stricmp(nick, "ALL") == 0)
3734 {
3735 notice(s_GameServ, u, "Resetting everyone's stats!");
3736 resetall();
3737 }
3738 else if ((user = find(nick)))
3739 {
3740 if (is_playing(user))
3741 {
3742 notice(s_GameServ, u, "Resetting %s.", user->getNick());
3743 reset(user->stats);
3744 }
3745 else
3746 {
3747 notice(s_GameServ, u, "%s is not playing.", user->getNick());
3748 }
3749 }
3750 else
3751 {
3752 notice(s_GameServ, u, "Nick %s not found.", nick);
3753 return;
3754 }
3755}
3756
3757void do_help(char *u)
3758{
3759 char *cmd = strtok(NULL, " ");
3760
3761 display_help(u, cmd);
3762}
3763
3764void display_help(char *u, char *file)
3765{
3766 ifstream infile;
3767 char *buf;
3768
3769 if (!file)
3770 {
3771 infile.open("helpfiles/help");
3772 if (infile.fail())
3773 {
3774 log("Error opening helpfiles/help");
3775 notice(s_GameServ, u, "Error opening helpfiles/help");
3776 return;
3777 }
3778 buf = new char[1024];
3779 while(infile.getline(buf, 1024))
3780 {
3781 // Written this way, it will process %S in the helpfiles
3782 // Instead of notice(s_GameServ, u, "%s", buf);
3783 notice(s_GameServ, u, buf);
3784 }
3785
3786 // Minor recursion
3787 aClient *user = find(u);
3788 if (user && isAdmin(user))
3789 display_help(u, "admin_commands");
3790 }
3791 else
3792 {
3793 char *filename;
3794 filename = new char[strlen(file) + 11];
3795 strcpy(filename, "helpfiles/");
3796 strcat(filename, file);
3797
3798 for (unsigned int x = 10; x < strlen(filename); x++)
3799 filename[x] = tolower(filename[x]);
3800
3801 infile.open(filename);
3802 delete [] filename;
3803 if (infile.fail())
3804 {
3805 notice(s_GameServ, u, "No help for \ 2%s\ 2", file);
3806 return;
3807 }
3808 buf = new char[1024];
3809 while(infile.getline(buf, 1024))
3810 {
3811 // Written this way, it will process %S in the helpfiles
3812 // Instead of notice(s_GameServ, u, "%s", buf);
3813 notice(s_GameServ, u, buf);
3814 }
3815 }
3816 infile.close();
3817 delete [] buf;
3818}
3819
3820void do_admin(char *u)
3821{
3822 aClient *user;
3823 char *pass = strtok(NULL, " ");
3824
3825 if (!(user = find(u)))
3826 {
3827 log("Error: aClient not found: %s", u);
3828 notice(s_GameServ, u, "Error: aClient not found. Contact %S admin.");
3829 return;
3830 }
3831 if (!pass)
3832 {
3833 notice(s_GameServ, u, "SYNTAX: \ 2ADMIN\ 2 \ 2\1fpassword\1f\ 2");
3834 return;
3835 }
3836
3837 if (isAdmin(user))
3838 {
3839 notice(s_GameServ, u, "You already have administrator privledges.");
3840 return;
3841 }
3842 else if (strcmp(pass, adminpass) == 0)
3843 {
3844 notice(s_GameServ, u, "Password accepted. You now have administrator privledges.");
3845 setAdmin(user);
3846 log("%s became an administrator.", user->getNick());
3847 }
3848 else
3849 {
3850 notice(s_GameServ, u, "Invalid password. Remember: case sensitive");
3851 return;
3852 }
3853}
3854
3855bool load_monsters()
3856{
3857 ifstream infile;
3858 infile.open("monsters.dat");
3859
3860 char *buf;
3861
3862 if (infile.fail())
3863 {
3864 log("Error opening monsters.dat");
3865 return false;
3866 }
3867 init_monsters();
3868 buf = new char[2048];
3869
3870 #ifdef DEBUGMODE
3871 log("Loading monsters from monsters.dat");
3872 #endif
3873
3874 for (int l = 0; l < REALLEVELS; l++)
3875 {
3876 for (int m = 0; m < MONSTERS;)
3877 {
3878 infile.getline(buf, 2048);
3879 if (buf[0] == '\n' || buf[0] == '\0' || buf[0] == '#')
3880 continue;
3881 else
3882 {
3883 strcpy(monsters[l][m]->name, strtok(buf, "~"));
3884 strcpy(monsters[l][m]->weapon, strtok(NULL, "~"));
3885 monsters[l][m]->strength = stringtoint(strtok(NULL, "~"));
3886 monsters[l][m]->gold = stringtoint(strtok(NULL, "~"));
3887 monsters[l][m]->exp = stringtoint(strtok(NULL, "~"));
3888 monsters[l][m]->maxhp = stringtoint(strtok(NULL, "~"));
3889 monsters[l][m]->hp = monsters[l][m]->maxhp;
3890 strcpy(monsters[l][m]->death, strtok(NULL, ""));
3891 m++;
3892 }
3893 }
3894 }
3895 delete [] buf;
3896return true;
3897}