]>
jfr.im git - irc/gameservirc.git/blob - gameserv/gameserv.cpp
20 #if defined(HAVE_CRYPT_H)
24 #elif defined(HAVE_UNISTD_H)
30 Monster dragon
; // The current dragon
31 Level levels
[ LEVELS
]; // The newest way to store monsters
41 char * strtok ( char * str
, const char * delim
);
44 int stricmp ( const char * s1
, const char * s2
);
45 int strnicmp ( const char * s1
, const char * s2
, size_t len
);
48 /********** Password functions **********/
50 bool passcmp ( const char * encrypted
, char * plaintext
); // Compares an encrypted pass with a plain text one
52 bool check_password ( char * name
, char * plaintext
); // Finds a password for the given name, and checks it with passcmp against the plaintext password given.
54 /********** Password functions **********/
57 /********** GameServ Booleans **********/
60 bool timedOut ( Player
* p
);
61 void updateTS ( Player
* p
);
62 void timeOutEvent ( Player
* p
);
64 bool is_playing ( char * u
); // True if the given nickname in the clients list is playing.
65 bool is_playing ( aClient
* user
);
67 bool is_fighting ( char * u
); // True if the given nick in the clients list is fighting anything.
68 bool is_fighting ( aClient
* user
);
70 bool player_fight ( char * u
); // True if the player is fighting another player.
71 bool player_fight ( aClient
* user
);
73 bool master_fight ( char * u
); // True if the player is fighting their master.
74 bool master_fight ( aClient
* user
);
76 bool dragon_fight ( char * u
); // True if the player is fighting the dragon.
77 bool dragon_fight ( aClient
* user
);
79 /********** GameServ Booleans **********/
81 void display_help ( char * u
, char * file
= NULL
);
82 void display_monster ( char * u
);
83 void display_players ( char * u
);
84 void display_players ( aClient
* user
);
85 long int chartoint ( char ch
);
86 int isstringnum ( char * num
);
87 long int pow ( int x
, int y
);
88 long int stringtoint ( char * number
);
90 char * spaces ( int len
, char * seperator
);
91 void refresh ( Player
* p
);
93 void updateTS ( Player
* p
);
94 void reset ( Player
* p
);
98 void delete_monsters ();
100 void do_admin ( char * u
);
101 void do_attack ( char * u
);
102 void do_bank ( char * u
);
103 void do_check ( char * u
);
104 void do_fight ( char * u
);
105 void do_heal ( char * u
);
106 void do_help ( char * u
);
107 void do_identify ( char * u
);
108 void do_inventory ( char * u
);
109 void do_refresh ( char * u
);
110 void do_register ( char * u
);
111 void do_list ( char * u
);
112 void do_logout ( char * u
);
113 void do_master ( char * u
);
114 void do_dragon ( char * u
);
115 void do_play ( char * u
);
116 void do_quitg ( char * u
);
117 void do_reset ( char * u
);
118 void do_run ( char * u
);
119 void do_set ( char * u
);
120 void do_stats ( char * u
);
121 void do_store ( char * u
);
122 void do_tavern ( char * u
);
123 void do_use ( char * u
);
124 void see_master ( char * u
);
126 void logout ( aClient
* user
);
127 void showstats ( const char * u
, const char * nick
);
128 void showinventory ( aClient
* from
, aClient
* to
);
129 void showBankBalance ( const char * u
);
130 void end_turn ( aClient
* user
);
133 char * weapons
[ WNA
] = { "Fists" , "Stick" , "Dagger" , "Quarterstaff" , "Short Sword" ,
134 "Long Sword" , "Silver Spear" , "Battle Axe" , "The Ragnarok" ,
135 "Chain Saw" , "Poison Sword" , "Flame Sword" , "Earth Hammer" ,
136 "Light Saber" , "Masamune" , "Mystical Sword" };
138 char * armors
[ WNA
] = { "Birthday Suit" , "Clothes" , "Leather Vest" , "Chain Mail" , "Plate Armor" ,
139 "Full Body Armor" , "Magic Mail" , "Graphite Suit" , "Steel Suit" ,
140 "Force Field" , "Armor of Light" , "Mythril Vest" , "DemiGod Armor" ,
141 "Hades' Cloak" , "Dragon Scales" , "Adamantium" };
143 int prices
[ WNA
- 1 ] = { 200 , 1000 , 3000 , 10000 , 30000 , 100000 , 150000 , 200000 , 400000 ,
144 1000000 , 4000000 , 10000000 , 40000000 , 100000000 , 400000000 };
145 int webonus
[ WNA
] = { 2 , 10 , 15 , 25 , 35 , 45 , 65 , 85 , 125 , 185 , 255 , 355 , 505 , 805 , 1205 , 1805 };
146 int arbonus
[ WNA
] = { 2 , 3 , 5 , 10 , 15 , 25 , 35 , 50 , 75 , 100 , 150 , 225 , 300 , 400 , 600 , 1000 };
148 int hpbonus
[ 11 ] = { 10 , 15 , 20 , 30 , 50 , 75 , 125 , 185 , 250 , 350 , 550 };
149 int strbonus
[ 11 ] = { 5 , 7 , 10 , 12 , 20 , 35 , 50 , 75 , 110 , 150 , 200 };
150 int defbonus
[ 11 ] = { 2 , 3 , 5 , 10 , 15 , 22 , 35 , 60 , 80 , 120 , 150 };
152 void gameserv ( char * source
, char * buf
)
155 cmd
= strtok ( buf
, " " );
158 source
++; // Get rid of that : at the beginning of a :Nick privmsg Gameserv :text
163 cmd
++; // Get rid of that : at the beginning of the :text (command)
166 log ( "Source: %s Command: %s " , source
, cmd
);
169 if ( strnicmp ( cmd
, "\1PING" , 6 ) == 0 )
172 ts
= strtok ( NULL
, "\1" );
173 notice ( s_GameServ
, source
, "\1PING %s \1" , ts
);
174 } else if ( stricmp ( cmd
, "\1VERSION\1" ) == 0 ) {
175 notice ( s_GameServ
, source
, "\1VERSION %s %s \1" , PACKAGE
, VERSION
);
176 } else if ( stricmp ( cmd
, "SEARCH" ) == 0 ) {
177 cmd
= strtok ( NULL
, " " );
180 notice ( s_GameServ
, source
, "SYNTAX: /msg %S SEARCH FOREST" );
184 } else if ( stricmp ( cmd
, "FIGHT" ) == 0 ) {
186 } else if ( stricmp ( cmd
, "ATTACK" ) == 0 ) {
188 } else if ( stricmp ( cmd
, "CHECK" ) == 0 ) {
190 } else if ( stricmp ( cmd
, "RUN" ) == 0 ) {
192 } else if ( stricmp ( cmd
, "USE" ) == 0 ) {
194 } else if ( stricmp ( cmd
, "HEAL" ) == 0 ) {
196 } else if ( stricmp ( cmd
, "INVENTORY" ) == 0 ) {
197 do_inventory ( source
);
198 } else if ( stricmp ( cmd
, "MASTER" ) == 0 ) {
200 } else if ( stricmp ( cmd
, "DRAGON" ) == 0 ) {
202 } else if ( stricmp ( cmd
, "STORE" ) == 0 ) {
204 } else if ( stricmp ( cmd
, "BANK" ) == 0 ) {
206 } else if ( stricmp ( cmd
, "ADMIN" ) == 0 ) {
208 } else if ( stricmp ( cmd
, "REFRESH" ) == 0 ) {
210 } else if ( stricmp ( cmd
, "RESET" ) == 0 ) {
212 } else if ( stricmp ( cmd
, "TAVERN" ) == 0 ) {
214 } else if ( stricmp ( cmd
, "LIST" ) == 0 ) {
216 } else if ( stricmp ( cmd
, "LOGOUT" ) == 0 ) {
218 } else if ( stricmp ( cmd
, "NEWS" ) == 0 ) {
220 } else if ( stricmp ( cmd
, "REGISTER" ) == 0 ) {
222 } else if ( stricmp ( cmd
, "IDENTIFY" ) == 0 ) {
224 } else if ( stricmp ( cmd
, "HELP" ) == 0 ) {
226 } else if ( stricmp ( cmd
, "SET" ) == 0 ) {
228 } else if ( stricmp ( cmd
, "STATS" ) == 0 ) {
230 } else if ( stricmp ( cmd
, "SHUTDOWN" ) == 0 ) {
233 if (!( user
= find ( source
)))
235 notice ( s_GameServ
, source
, "Error: aClient not found. Contact a %S admin" );
236 log ( "Error: aClient not found: %s " , source
);
238 else if (! isAdmin ( user
))
240 notice ( s_GameServ
, source
, "You must be a %S admin to use this command!" );
246 raw ( "[] SQ %s 0 :leaving: %s used the Shutdown command." , servername
, user
-> getRealNick ());
248 raw ( "SQUIT %s :leaving: %s used the Shutdown command." , servername
, source
);
252 } else if ( stricmp ( cmd
, "SAVE" ) == 0 ) {
255 if (!( user
= find ( source
)))
257 notice ( s_GameServ
, source
, "Error: aClient not found. Contact a %S admin" );
258 log ( "Error: aClient not found: %s " , source
);
260 else if (! isAdmin ( user
))
262 notice ( s_GameServ
, source
, "You must be a %S admin to use this command!" );
268 } else if ( stricmp ( cmd
, "LOAD" ) == 0 ) {
271 if (!( user
= find ( source
)))
273 notice ( s_GameServ
, source
, "Error: aClient not found. Contact a %S admin" );
274 log ( "Error: aClient not found: %s " , source
);
276 else if (! isAdmin ( user
))
278 notice ( s_GameServ
, source
, "You must be a %S admin to use this command!" );
282 char * cmd2
= strtok ( NULL
, " " );
285 notice ( s_GameServ
, source
, "Loading player data from %s " , playerdata
);
288 else if ( stricmp ( cmd2
, "MONSTERS" ) == 0 )
290 notice ( s_GameServ
, source
, "Loading monster data" );
294 display_help ( source
, cmd
);
297 } else if ( stricmp ( cmd
, "RAW" ) == 0 ) {
300 if (!( user
= find ( source
)))
302 notice ( s_GameServ
, source
, "Error: aClient not found. Contact a %S admin" );
303 log ( "Error: aClient not found: %s " , source
);
305 else if (! isAdmin ( user
))
307 notice ( s_GameServ
, source
, "You must be a %S admin to use this command!" );
311 char * rest
= strtok ( NULL
, "" );
314 } else if ( stricmp ( cmd
, "PRINT" ) == 0 ) {
315 for ( int x
= 0 ; x
< LEVELS
; x
++)
316 levels
[ x
]. monsters
. print ();
317 } else if ( stricmp ( cmd
, "RANDOM" ) == 0 ) {
318 char * rstr
= strtok ( NULL
, "" );
320 trange
. setRange ( rstr
);
321 notice ( s_GameServ
, source
, "Random number in that range: %d " , trange
. random ());
325 if (( user
= find ( source
)))
330 log ( "Ignoring %s ." , user
-> getNick ());
335 notice ( s_GameServ
, source
, "Unknown command \002 %s \002 . Type /msg %S \002 HELP \002 to get a list of commands." , cmd
);
341 source
--; // Bring the ':' back so we don't leak memory
344 cmd
--; // Same thing :)
347 int stricmp ( const char * s1
, const char * s2
)
351 while (( c
= tolower (* s1
)) == tolower (* s2
)) {
357 if ( c
< tolower (* s2
))
362 void showstats ( const char * u
, const char * nick
)
364 aClient
* ni
, * sender
= find ( u
);
370 if (!( ni
= findplayer ( nick
)))
372 notice ( s_GameServ
, u
, " %s not found" , nick
);
376 notice ( s_GameServ
, sender
-> getNick (), "Stats for %s :" , ni
-> stats
-> name
. c_str ());
378 sprintf ( buf
, "Experience: %l d" , ni
-> stats
-> exp
);
379 space
= spaces ( strlen ( buf
), " " );
380 notice ( s_GameServ
, sender
-> getNick (), " %s%s Level: %d " , buf
, space
,
384 sprintf ( buf
, "Gold: %l d" , ni
-> stats
-> gold
);
385 space
= spaces ( strlen ( buf
), " " );
386 notice ( s_GameServ
, sender
-> getNick (), " %s%s Gold in Bank: %l d" , buf
, space
, ni
-> stats
-> bank
);
389 notice ( s_GameServ
, sender
-> getNick (), "Hit Points: %d of %d " , ni
-> stats
-> hp
,
392 sprintf ( buf
, "Strength: %d " , ni
-> stats
-> strength
+ webonus
[ ni
-> stats
-> wea
]);
393 space
= spaces ( strlen ( buf
), " " );
394 notice ( s_GameServ
, sender
-> getNick (), " %s%s Defense: %d " ,
395 buf
, space
, ni
-> stats
-> defense
+ arbonus
[ ni
-> stats
-> arm
]);
398 sprintf ( buf
, "Armor: %s " , armors
[ ni
-> stats
-> arm
]);
399 space
= spaces ( strlen ( buf
), " " );
400 notice ( s_GameServ
, sender
-> getNick (), " %s%s Weapon: %s " , buf
, space
,
401 weapons
[ ni
-> stats
-> wea
]);
404 sprintf ( buf
, "Forest Fights: %d " , ni
-> stats
-> forest_fights
);
405 space
= spaces ( strlen ( buf
), " " );
406 notice ( s_GameServ
, sender
-> getNick (), " %s%s Player Fights: %d " , buf
, space
, ni
-> stats
-> player_fights
);
408 showinventory ( ni
, ni
);
412 notice ( s_GameServ
, u
, " %s is not playing!" , ni
-> stats
-> name
. c_str ());
417 char * spaces ( int len
, char * seperator
)
420 final
= new char [ 30 ];
422 strcpy ( final
, seperator
);
423 for ( y
= 0 ; y
< 30 - len
; y
++)
424 strcat ( final
, seperator
);
428 void raw ( const char * fmt
, ...)
433 input
= new char [ 1024 ];
435 memset ( input
, 0 , sizeof ( input
)); // Initialize to NULL
441 case 'd' : sprintf ( input
, " %s%d " , input
, va_arg ( args
, int )); break ;
442 case 's' : sprintf ( input
, " %s%s " , input
, va_arg ( args
, char *)); break ;
443 case 'S' : sprintf ( input
, " %s%s " , input
, s_GameServ
); break ;
446 sprintf ( input
, " %s%l d" , input
, va_arg ( args
, long int )); break ;
451 sprintf ( input
, " %s%c " , input
, * t
);
456 log ( "Input: %s " , input
);
459 sprintf ( input
, " %s%s " , input
, " \r\n " );
460 sock_puts ( sock
, input
);
464 /* Send a NOTICE from the given source to the given nick. */
466 void notice ( const char * source
, const char * dest
, const char * fmt
, ...)
472 commanduse
= new char [ 16 ];
476 strcpy ( commanduse
, "P" );
478 strcpy ( commanduse
, "O" );
482 strcpy ( commanduse
, "PRIVMSG" );
484 strcpy ( commanduse
, "NOTICE" );
490 input
= new char [ 1024 ];
497 sprintf ( input
, ": %s %s %s :" , source
, commanduse
, dest
);
499 sprintf ( input
, " %s %s %s :" , gsnum
, commanduse
, dest
);
507 sprintf ( input
, ": %s %s %s :" , source
, commanduse
, dest
);
509 sprintf ( input
, " %s %s %s :" , gsnum
, commanduse
, dest
);
518 case 'd' : sprintf ( input
, " %s%d " , input
, va_arg ( args
, int )); break ;
519 case 's' : sprintf ( input
, " %s%s " , input
, va_arg ( args
, char *)); break ;
520 case 'S' : sprintf ( input
, " %s%s " , input
, s_GameServ
); break ;
523 sprintf ( input
, " %s%l d" , input
, va_arg ( args
, long int )); break ;
528 sprintf ( input
, " %s%c " , input
, * t
);
533 log ( "Input: %s " , input
);
535 sprintf ( input
, " %s%s " , input
, " \r\n " );
536 sock_puts ( sock
, input
);
537 delete [] commanduse
;
543 int strnicmp ( const char * s1
, const char * s2
, size_t len
)
549 while (( c
= tolower (* s1
)) == tolower (* s2
) && len
> 0 ) {
550 if ( c
== 0 || -- len
== 0 )
555 if ( c
< tolower (* s2
))
561 char * strtok ( char * str
, const char * delim
)
563 static char * current
= NULL
;
570 current
+= strspn ( current
, delim
);
571 ret
= * current
? current
: NULL
;
572 current
+= strcspn ( current
, delim
);
581 void do_check ( char * u
)
583 int days
, hours
, minutes
, seconds
;
585 complete
= ( lastrefresh
+ refreshperiod
) - time ( NULL
);
586 days
= complete
/ 86400 ;
587 hours
= ( complete
% 86400 ) / 3600 ;
588 minutes
= ( complete
% 86400 ) % 3600 / 60 ;
589 seconds
= ( complete
% 86400 ) % 3600 % 60 ;
591 notice ( s_GameServ
, u
, "Time left to next refresh: %d d %d h %d m %d s" ,
592 days
, hours
, minutes
, seconds
);
595 void do_list ( char * u
)
598 char * cmd
= strtok ( NULL
, " " );
600 if (!( user
= find ( u
)))
602 log ( "Fatal Error: Couldn't find %s in the client list" , u
);
605 else if ( isIgnore ( user
))
608 log ( "Ignoring %s . Command LIST" , user
-> getNick ());
613 ListNode
< aClient
> * temp
;
616 for ( unsigned long x
= 0 ; x
< U_TABLE_SIZE
; x
++)
618 temp
= players
[ x
]. First ();
619 if (! players
[ x
]. isEmpty ())
623 if ( cmd
|| is_playing ( temp
-> getData ()))
627 notice ( s_GameServ
, u
, "Players:" );
631 notice ( s_GameServ
, u
, "IRC: %s Game: %s " , temp
-> getData ()-> getRealNick (),
632 temp
-> getData ()-> stats
-> name
. c_str ());
634 notice ( s_GameServ
, u
, "IRC: %s Game: %s " , temp
-> getData ()-> getNick (),
635 temp
-> getData ()-> stats
-> name
. c_str ());
644 notice ( s_GameServ
, u
, "No one is playing" );
646 notice ( s_GameServ
, u
, "End of List" );
651 aClient
* user
, * target
;
652 char * name
= strtok ( NULL
, " " );
653 char * cmd
= strtok ( NULL
, " " );
656 if (!( user
= find ( u
)))
658 notice ( s_GameServ
, u
, "Fatal error. Cannot find aClient. " \
659 "Buf: %s LOGOUT" , u
);
662 else if ( isIgnore ( user
))
665 log ( "Ignoring %s ." , user
-> getNick ());
671 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}" );
674 else if (!( target
= findplayer ( name
)))
676 // Back the pointers up... they didn't send a name probably
681 if (! is_playing ( user
))
683 notice ( s_GameServ
, u
, "You must be playing to set things for yourself!" );
689 cmd2
= strtok ( NULL
, " " );
692 // Regardless of the previous if/else, if it got here, we know we have the cmd pointer at the right spot.
693 if ( stricmp ( cmd
, "PASSWORD" ) == 0 )
695 // Person is looking to change their password
696 // If they're an admin, or it's theirself, allow it
697 // cmd2 is pointing to the password now
698 if ( isAdmin ( user
) || user
== target
)
700 target
-> stats
-> setPassword ( cmd2
);
701 notice ( s_GameServ
, u
, "Password successfully changed" );
703 else if ( user
!= target
&& ! isAdmin ( user
))
705 notice ( s_GameServ
, u
, "You must be a %S admin to set other peoples' passwords." );
709 else if ( stricmp ( cmd
, "BANK" ) == 0 || stricmp ( cmd
, "BALANCE" ) == 0 )
713 notice ( s_GameServ
, u
, "Admins Only!" );
716 else if ( stricmp ( cmd
, "BANK" ) == 0 )
718 cmd2
= strtok ( NULL
, " " ); // Need an extra parameter for set bank balance
722 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] [BANK] BALANCE <NUMBER>" );
726 target
-> stats
-> bank
= stringtoint ( cmd2
);
728 // Cheap bounds checking
729 if ( target
-> stats
-> bank
> 2000000000 )
730 target
-> stats
-> bank
= 2000000000 ;
731 else if ( target
-> stats
-> bank
< 0 )
732 target
-> stats
-> bank
*= - 1 ;
734 notice ( s_GameServ
, u
, "Bank balance changed to %l d!" , target
-> stats
-> bank
);
736 else if ( stricmp ( cmd
, "PLAYER" ) == 0 )
740 notice ( s_GameServ
, u
, "Admins Only!" );
743 else if ( stricmp ( cmd2
, "FIGHTS" ) != 0 )
745 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] PLAYER FIGHTS <NUMBER>" );
750 cmd2
= strtok ( NULL
, " " );
753 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] PLAYER FIGHTS <NUMBER>" );
756 target
-> stats
-> player_fights
= stringtoint ( cmd2
);
758 if ( target
-> stats
-> player_fights
< 0 )
759 target
-> stats
-> player_fights
*= - 1 ;
761 notice ( s_GameServ
, u
, "Player fights changed to %d !" , target
-> stats
-> player_fights
);
764 else if ( stricmp ( cmd
, "FOREST" ) == 0 )
768 notice ( s_GameServ
, u
, "Admins Only!" );
771 else if ( stricmp ( cmd2
, "FIGHTS" ) != 0 )
773 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] FOREST FIGHTS <number>" );
778 cmd2
= strtok ( NULL
, " " );
781 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] FOREST FIGHTS <NUMBER>" );
785 target
-> stats
-> forest_fights
= stringtoint ( cmd2
);
787 if ( target
-> stats
-> forest_fights
< 0 )
788 target
-> stats
-> forest_fights
*= - 1 ;
790 notice ( s_GameServ
, u
, "Forest fights changed to %d !" , target
-> stats
-> forest_fights
);
793 else if ( stricmp ( cmd
, "GOLD" ) == 0 )
797 notice ( s_GameServ
, u
, "Admins Only!" );
804 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] GOLD <NUMBER>" );
807 target
-> stats
-> gold
= stringtoint ( cmd2
);
809 if ( target
-> stats
-> gold
> 2000000000 )
810 target
-> stats
-> gold
= 2000000000 ;
811 else if ( target
-> stats
-> gold
< 0 )
812 target
-> stats
-> gold
*= - 1 ;
814 notice ( s_GameServ
, u
, "Gold set to %l d" , target
-> stats
-> gold
);
818 else if ( stricmp ( cmd
, "STRENGTH" ) == 0 && stricmp ( cmd2
, "POTIONS" ) != 0 )
822 notice ( s_GameServ
, u
, "Admins Only!" );
829 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] STRENGTH <NUMBER>" );
833 target
-> stats
-> strength
= stringtoint ( cmd2
);
835 if ( target
-> stats
-> strength
< 0 )
836 target
-> stats
-> strength
*= - 1 ;
838 notice ( s_GameServ
, u
, "Strength set to %d " , target
-> stats
-> strength
);
842 else if ( stricmp ( cmd
, "DEFENSE" ) == 0 && stricmp ( cmd2
, "POTIONS" ) != 0 )
846 notice ( s_GameServ
, u
, "Admins Only!" );
853 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] DEFENSE <NUMBER>" );
857 target
-> stats
-> defense
= stringtoint ( cmd2
);
859 if ( target
-> stats
-> defense
< 0 )
860 target
-> stats
-> defense
*= - 1 ;
862 notice ( s_GameServ
, u
, "Defense set to %d " , target
-> stats
-> defense
);
866 else if ( stricmp ( cmd
, "HP" ) == 0 && stricmp ( cmd2
, "POTIONS" ) != 0 )
870 notice ( s_GameServ
, u
, "Admins Only!" );
877 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] HP <NUMBER>" );
880 target
-> stats
-> hp
= stringtoint ( cmd2
);
882 if ( target
-> stats
-> hp
< 0 )
883 target
-> stats
-> hp
*= - 1 ;
885 notice ( s_GameServ
, u
, "HP set to %d " , target
-> stats
-> hp
);
889 else if ( stricmp ( cmd
, "MAXHP" ) == 0 )
893 notice ( s_GameServ
, u
, "Admins Only!" );
900 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] MAXHP <NUMBER>" );
903 target
-> stats
-> maxhp
= stringtoint ( cmd2
);
905 if ( target
-> stats
-> maxhp
< 0 )
906 target
-> stats
-> maxhp
*= - 1 ;
908 notice ( s_GameServ
, u
, "MaxHP set to %d " , target
-> stats
-> maxhp
);
912 else if ( stricmp ( cmd
, "EXPERIENCE" ) == 0 || stricmp ( cmd
, "EXP" ) == 0 )
916 notice ( s_GameServ
, u
, "Admins Only!" );
923 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] {EXPERIENCE|EXP} <NUMBER>" );
927 target
-> stats
-> exp
= stringtoint ( cmd2
);
929 if ( target
-> stats
-> exp
> 2000000000 )
930 target
-> stats
-> exp
= 2000000000 ;
931 else if ( target
-> stats
-> exp
< 0 )
932 target
-> stats
-> exp
*= - 1 ;
934 notice ( s_GameServ
, u
, "Exp set to %l d" , target
-> stats
-> exp
);
938 else if ( stricmp ( cmd
, "LEVEL" ) == 0 )
942 notice ( s_GameServ
, u
, "Admins Only!" );
949 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] LEVEL <NUMBER>" );
952 target
-> stats
-> level
= stringtoint ( cmd2
);
954 if ( target
-> stats
-> level
< 0 )
955 target
-> stats
-> level
= 1 ;
956 else if ( target
-> stats
-> level
> REALLEVELS
)
957 target
-> stats
-> level
= REALLEVELS
;
959 notice ( s_GameServ
, u
, "Level set to %d " , target
-> stats
-> level
);
963 else if ( stricmp ( cmd
, "ALIVE" ) == 0 )
967 notice ( s_GameServ
, u
, "Admins Only!" );
972 cmd2
= strtok ( NULL
, " " );
973 if (! cmd2
|| ( stricmp ( cmd2
, "TRUE" ) != 0 && stricmp ( cmd2
, "FALSE" ) != 0 ))
975 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET ALIVE TRUE|FALSE" );
978 else if ( stricmp ( cmd2
, "TRUE" ) == 0 )
980 notice ( s_GameServ
, u
, " %s has been Resurrected!" , target
-> stats
-> name
. c_str ());
981 setAlive ( target
-> stats
);
985 notice ( s_GameServ
, u
, " %s is now dead!" , target
-> stats
-> name
. c_str ());
986 clearAlive ( target
-> stats
);
990 else if ( stricmp ( cmd
, "SEEN" ) == 0 )
994 notice ( s_GameServ
, u
, "Admins Only!" );
997 else if ( stricmp ( cmd2
, "MASTER" ) != 0 )
999 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] SEEN MASTER {TRUE|FALSE}" );
1004 cmd2
= strtok ( NULL
, " " );
1005 if (! cmd2
|| ( stricmp ( cmd2
, "TRUE" ) != 0 && stricmp ( cmd2
, "FALSE" ) != 0 ))
1007 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NICK] SEEN MASTER {TRUE|FALSE}" );
1010 else if ( stricmp ( cmd2
, "TRUE" ) == 0 )
1012 notice ( s_GameServ
, u
, " %s has seen their master now." , target
-> stats
-> name
. c_str ());
1013 target
-> addFlag ( FLAG_MASTER
);
1017 notice ( s_GameServ
, u
, " %s has not seen their master now." , target
-> stats
-> name
. c_str ());
1018 target
-> remFlag ( FLAG_MASTER
);
1024 notice ( s_GameServ
, u
, "Unknown command: SET %s " , cmd
);
1025 notice ( s_GameServ
, u
, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}" );
1030 void do_logout ( char * u
)
1033 char * name
= strtok ( NULL
, " " );
1035 if (!( user
= find ( u
)))
1037 notice ( s_GameServ
, u
, "Fatal error. Cannot find aClient. " \
1038 "Buf: %s LOGOUT" , u
);
1039 log ( "Could not find aClient Buf: %s LOGOUT" ,
1043 else if ( isIgnore ( user
))
1046 log ( "Ignoring %s ." , user
-> getNick ());
1055 notice ( s_GameServ
, u
, "You must be a %S admin to use this command!" );
1057 else if (!( user
= findplayer ( name
)))
1059 notice ( s_GameServ
, u
, "Couldn't find a player named %s " , name
);
1063 notice ( s_GameServ
, u
, "Logging out %s " , user
-> stats
-> name
. c_str ());
1069 if (! is_playing ( user
))
1071 notice ( s_GameServ
, u
, "You're not logged in!" );
1073 else if ( is_fighting ( user
))
1075 notice ( s_GameServ
, u
, "You can't logout while fighting!" );
1079 notice ( s_GameServ
, u
, "You have left the fields. You have lived to kill another day!" );
1085 void logout ( aClient
* user
)
1087 if ( is_playing ( user
))
1089 ListNode
< aClient
> * it
;
1091 unsigned long hv
= iHASH (( unsigned char *) user
-> stats
-> name
. c_str ());
1092 it
= players
[ hv
]. Find ( user
);
1096 notice ( s_GameServ
, user
-> getNick (), "Fatal error. Contact " \
1097 " %S Admin. Cannot find you in the players list." );
1098 log ( "Error on logout(). Can't find %s in the players list" ,
1109 temp
-> stats
= new Player
;
1110 temp
-> stats
-> setData ( user
-> stats
);
1111 user
-> stats
-> client
= NULL
;
1113 if ( player_fight ( user
))
1114 user
-> stats
-> battle
-> stats
-> battle
= NULL
;
1118 temp
-> stats
-> client
= NULL
;
1120 temp
-> setRealNick ( "Not Playing" );
1122 temp
-> setNick ( "Not Playing" );
1124 it
-> setNewPtr ( temp
);
1126 log ( "Logged out player %s " ,
1138 void do_register ( char * u
)
1140 char * password
, * name
;
1142 name
= strtok ( NULL
, " " );
1143 password
= strtok ( NULL
, " " );
1147 notice ( s_GameServ
, u
, "SYNTAX: /msg %S REGISTER NAME PASSWORD" );
1149 else if ( stricmp ( name
, s_GameServ
) == 0 )
1151 notice ( s_GameServ
, u
, "You can't use %S as a name!" );
1156 notice ( s_GameServ
, u
, "SYNTAX: /msg %S REGISTER NAME PASSWORD" );
1158 else if (( user
= findplayer ( name
)))
1160 notice ( s_GameServ
, u
, " %s is already registered!" , name
);
1161 notice ( s_GameServ
, u
, "Choose another name!" );
1163 else if (!( user
= find ( u
)))
1165 log ( "Fatal Error: Couldn't find %s in the clients list" , u
);
1167 else if ( isIgnore ( user
))
1170 log ( "Ignoring %s ." , user
-> getNick ());
1176 if (! is_playing ( user
))
1178 ListNode
< aClient
> * temp
;
1179 user
-> stats
= new Player ();
1180 user
-> stats
-> client
= user
; // Set the backwards pointer
1181 user
-> stats
-> reset (); // set the user up
1182 user
-> stats
-> setPassword ( password
);
1183 user
-> stats
-> name
= name
;
1184 unsigned long hv
= iHASH (( unsigned char *) name
);
1185 updateTS ( user
-> stats
);
1186 temp
= players
[ hv
]. insertAtBack_RLN ( user
);
1187 temp
-> setPtr ( user
); // This is an extra step, but necessary for now
1189 // Update the last login time
1190 user
-> stats
-> lastlogin
= time ( NULL
);
1192 notice ( s_GameServ
, u
, "Player %s registered with password %s ." , user
-> stats
-> name
. c_str (), password
);
1193 notice ( s_GameServ
, u
, "Write this password down. If you lose it, there is no way to retrieve it!" );
1194 log ( "Nickname %s registered player %s ." , u
, user
-> stats
-> name
. c_str ());
1195 setPlaying ( user
); // set the playing flag
1199 notice ( s_GameServ
, u
, "Already registered. Contact a %S admin for help." );
1204 void do_identify ( char * u
)
1206 char * password
, * name
;
1208 name
= strtok ( NULL
, " " );
1209 password
= strtok ( NULL
, " " );
1210 if (! password
|| ! name
)
1212 notice ( s_GameServ
, u
, "SYNTAX: /msg %S IDENTIFY NAME PASSWORD" );
1214 else if (!( user
= find ( u
)))
1216 notice ( s_GameServ
, u
, "Fatal error. Cannot find aClient. Buf: %s " , strtok ( NULL
, "" ));
1217 log ( "Error: aClient not found: %s " , u
);
1219 else if ( isIgnore ( user
))
1222 log ( "Ignoring %s ." , user
-> getNick ());
1226 else if (!( p
= findplayer ( name
)) || ! p
-> stats
)
1227 notice ( s_GameServ
, u
, "Player %s not found" , name
);
1228 else if ( is_playing ( user
))
1230 notice ( s_GameServ
, u
, "You are already playing!" );
1232 else if ( p
-> stats
-> client
!= NULL
&& ! isAdmin ( user
))
1234 notice ( s_GameServ
, u
, "That player has already identified." );
1236 else if (! check_password ( name
, password
) && ! isAdmin ( user
))
1238 notice ( s_GameServ
, u
, "Password incorrect" );
1241 ListNode
< aClient
> * temp
;
1242 unsigned long hv
= iHASH (( unsigned char *) p
-> stats
-> name
. c_str ());
1243 temp
= players
[ hv
]. Find ( p
);
1246 notice ( s_GameServ
, u
, "Fatal error. Contact %S Admin. Buf: %s " ,
1250 user
-> stats
= new Player ( p
-> stats
-> name
);
1252 log ( "Setting data for identified" );
1254 user
-> stats
-> setData ( p
-> stats
);
1255 user
-> stats
-> client
= user
;
1256 updateTS ( user
-> stats
);
1260 log ( "Player %s IRC: %s Identified" , user
-> stats
-> name
. c_str (),
1264 setPlaying ( user
); // set the playing flag
1268 // Update the last login time
1269 user
-> stats
-> lastlogin
= time ( NULL
);
1271 notice ( s_GameServ
, u
, "Password Accepted. Identified." );
1272 showNews ( u
, todaysnews
);
1276 void do_stats ( char * u
)
1281 nick
= strtok ( NULL
, " " );
1283 if (!( user
= find ( u
)))
1285 log ( "Fatal Error: %s not found in client list" , u
);
1288 else if ( isIgnore ( user
))
1291 log ( "Ignoring %s ." , user
-> getNick ());
1297 if (! is_playing ( user
))
1299 notice ( s_GameServ
, u
, "You're not playing, so you have no stats!" );
1304 updateTS ( user
-> stats
);
1305 showstats ( u
, user
-> stats
-> name
. c_str ());
1314 ifstream
infile ( masterdata
);
1317 buf
= new char [ 1024 ];
1321 log ( "Error opening %s " , masterdata
);
1326 log ( "Loading masters from %s " , masterdata
);
1329 for ( l
= 0 ; l
< LEVELS
- 1 ; l
++)
1331 infile
. getline ( buf
, 1024 , ' \n ' );
1334 if ( buf
[ 0 ] == '#' || buf
[ 0 ] == ' \n ' || buf
[ 0 ] == ' \r ' )
1339 else if ( buf
[ 0 ] == '^' )
1342 Monster
* master
= & levels
[ l
]. master
;
1344 char * name
, * weapon
, * strength
, * gold
, * exp
, * maxhp
, * death
;
1347 name
= strtok ( buf
, "~" );
1348 weapon
= strtok ( NULL
, "~" );
1349 strength
= strtok ( NULL
, "~" );
1350 gold
= strtok ( NULL
, "~" );
1351 exp
= strtok ( NULL
, "~" );
1352 maxhp
= strtok ( NULL
, "~" );
1353 death
= strtok ( NULL
, "~" );
1355 master
-> name
= name
;
1356 master
-> weapon
= weapon
;
1357 master
-> strength
= stringtoint ( strength
);
1358 master
-> gold
= stringtoint ( gold
);
1359 master
-> exp
= stringtoint ( exp
);
1360 master
-> maxhp
= stringtoint ( maxhp
);
1361 master
-> hp
= master
-> maxhp
;
1362 master
-> death
= death
;
1367 if ( l
< LEVELS
- 1 ) // We didn't load a master for every level - check data/masters.dat
1373 void delete_monsters ()
1375 for ( int x
= 0 ; x
< LEVELS
; x
++)
1376 levels
[ x
]. monsters
. deleteNodes ();
1379 void display_monster ( char * u
)
1383 aClient
* user
= find ( u
);
1384 Player
* ni
= user
-> stats
;
1386 notice ( s_GameServ
, u
, "Your Hitpoints: \ 2 %d \ 2 ", ni
-> hp
);
1387 notice ( s_GameServ
, u
, " %s 's Hitpoints: \ 2 %d \ 2 ", ni
-> fight
-> name
. c_str (), ni
-> fight
-> hp
);
1388 notice ( s_GameServ
, u
, "Here are your commands:" );
1389 notice ( s_GameServ
, u
, "/msg %S attack" );
1390 notice ( s_GameServ
, u
, "/msg %S run" );
1391 notice ( s_GameServ
, u
, "What will you do?" );
1395 void display_players ( char * u
)
1398 if (!( user
= find ( u
)))
1400 log ( "Fatal error in display_players(): Couldn't find %s " , u
);
1403 display_players ( user
);
1406 void display_players ( aClient
* user
)
1408 char * u
= user
-> getNick ();
1409 if ( is_playing ( user
) && player_fight ( user
))
1411 aClient
* battle
= user
-> stats
-> battle
;
1412 notice ( s_GameServ
, u
, "Your Hitpoints: \ 2 %d \ 2 ", user
-> stats
-> hp
);
1413 notice ( s_GameServ
, u
, " %s 's Hitpoints: \ 2 %d \ 2 ", battle
-> stats
-> name
. c_str (), battle
-> stats
-> hp
);
1414 notice ( s_GameServ
, u
, "Here are your commands:" );
1415 notice ( s_GameServ
, u
, "/msg %S attack" );
1416 notice ( s_GameServ
, u
, "/msg %S run" );
1417 notice ( s_GameServ
, u
, "What will you do?" );
1422 bool is_playing ( char * u
)
1425 if (!( user
= find ( u
)))
1428 return is_playing ( user
);
1431 bool is_playing ( aClient
* user
)
1433 if ( user
-> stats
== NULL
)
1437 else if ( user
-> stats
-> client
== NULL
)
1441 else if (! FL_is_playing ( user
))
1449 bool is_fighting ( char * u
)
1453 if (!( user
= find ( u
)))
1456 return is_fighting ( user
);
1459 bool is_fighting ( aClient
* user
)
1461 if (! is_playing ( user
))
1464 return player_fight ( user
) || master_fight ( user
) || user
-> stats
-> fight
!= NULL
;
1467 bool player_fight ( char * u
)
1471 if (!( user
= find ( u
)))
1474 return player_fight ( user
);
1477 bool player_fight ( aClient
* user
)
1479 if (! is_playing ( user
))
1481 else if ( user
-> stats
-> battle
!= NULL
&& is_playing ( user
-> stats
-> battle
))
1483 return user
-> stats
-> battle
-> stats
!= NULL
;
1488 bool master_fight ( char * u
)
1492 if (!( user
= find ( u
)))
1495 return master_fight ( user
);
1498 bool master_fight ( aClient
* user
)
1500 if (! is_playing ( user
))
1503 return user
-> stats
-> master
!= NULL
;
1506 bool dragon_fight ( char * u
)
1509 if (!( user
= find ( u
)))
1512 return dragon_fight ( user
);
1515 bool dragon_fight ( aClient
* user
)
1517 if (! is_playing ( user
))
1520 return ( isDragonFight ( user
-> stats
));
1522 void do_fight ( char * u
)
1524 aClient
* ni
, * battle
;
1526 char * nick
= strtok ( NULL
, " " );
1530 notice ( s_GameServ
, u
, "SYNTAX: /msg %S FIGHT PLAYER" );
1533 else if (!( ni
= find ( u
)))
1535 notice ( s_GameServ
, u
, "Fatal error. Contact a(n) %S admin. buf: %s " , strtok ( NULL
, "" ));
1538 else if ( isIgnore ( ni
))
1541 log ( "Ignoring %s ." , ni
-> getNick ());
1545 else if (! is_playing ( ni
))
1547 notice ( s_GameServ
, u
, "You are not playing!" );
1551 updateTS ( ni
-> stats
);
1553 if ( ni
-> stats
-> player_fights
<= 0 )
1555 ni
-> stats
-> player_fights
= 0 ; // just to be safe
1556 notice ( s_GameServ
, u
, "You are out of player fights for the " \
1557 "day. You have to wait until tomorrow!" );
1559 else if (!( battle
= findplayer ( nick
)))
1561 notice ( s_GameServ
, u
, "Player %s not found!" , nick
);
1563 else if (! isAlive ( ni
-> stats
))
1565 notice ( s_GameServ
, u
, "You are dead. Wait until tomorrow to fight others!" );
1567 else if (! is_playing ( battle
))
1569 notice ( s_GameServ
, u
, "You can't attack %s while they aren't playing!" , nick
);
1572 /* offline fighting not available yet
1573 else if (!(fight = finduser(nick)))
1575 ni->stats->battle = battle;
1576 battle->battle = ni;
1577 setYourTurn(ni->stats);
1578 clearYourTurn(battle->stats);
1580 notice(s_GameServ, u, "You decide to fight %s while they're "\
1581 "not in the realm!",
1582 battle->stats->name.c_str());
1586 else if ( stricmp ( ni
-> stats
-> name
. c_str (), battle
-> stats
-> name
. c_str ()) == 0 )
1588 notice ( s_GameServ
, u
, "Are you trying to commit suicide!?" );
1590 else if (! isAlive ( battle
-> stats
))
1592 notice ( s_GameServ
, u
, "They are dead. Cannot fight dead players!" );
1594 else if ( player_fight ( battle
))
1596 notice ( s_GameServ
, u
, " %s is fighting %s already!" , battle
-> stats
-> name
. c_str (), battle
-> stats
-> battle
-> stats
-> name
. c_str ());
1598 else if ( master_fight ( battle
))
1600 notice ( s_GameServ
, u
, " %s is fighting their master!" , battle
-> stats
-> name
. c_str ());
1602 else if ( is_fighting ( battle
))
1604 notice ( s_GameServ
, u
, " %s is fighting %s already!" , battle
-> stats
-> name
. c_str (), battle
-> stats
-> fight
-> name
. c_str ());
1606 else if ( ni
-> stats
-> level
- battle
-> stats
-> level
> maxbfightdistance
)
1608 // You can't fight someone below you by more than X level(s)
1609 // level 12 can fight level (12 - X) but not < (12 - X)
1610 notice ( s_GameServ
, u
, "You may not fight %s . You're too strong!" ,
1611 battle
-> stats
-> name
. c_str ());
1613 else if ( battle
-> stats
-> level
- ni
-> stats
-> level
> maxafightdistance
)
1615 // You can't fight someone above you by more than X level(S)
1616 // level 1 can fight level (1 + X), but not > (1 + X)
1617 notice ( s_GameServ
, u
, " %s , do you really have a death wish? Try the forest you " \
1618 "weakling!" , ni
-> stats
-> name
. c_str ());
1622 // Set your battle pointer to the other player
1623 ni
-> stats
-> battle
= battle
;
1625 // Set the other player's battle pointer to you
1626 ni
-> stats
-> battle
-> stats
-> battle
= ni
;
1628 // The initiator gets the first move (perhaps this should be 50/50)
1629 setYourTurn ( ni
-> stats
);
1630 clearYourTurn ( battle
-> stats
);
1632 // Initiate Battle sequence!
1633 ni
-> stats
-> player_fights
-= 1 ;
1635 notice ( s_GameServ
, u
, "You challenge %s to an online duel!" , battle
-> stats
-> name
. c_str ());
1636 notice ( s_GameServ
, battle
-> getNick (), " %s has challenged you to an online duel!" , ni
-> stats
-> name
. c_str ());
1637 notice ( s_GameServ
, battle
-> getNick (), " %s gets to go first " \
1638 "because they initiated!" , ni
-> stats
-> name
. c_str ());
1639 notice ( s_GameServ
, battle
-> getNick (), "Please wait while %s decides what to do." , ni
-> stats
-> name
. c_str ());
1640 display_players ( ni
);
1644 void do_use ( char * u
)
1650 char *item = strtok(NULL, " ");
1654 notice(s_GameServ, u, "SYNTAX: USE ITEM");
1655 notice(s_GameServ, u, "Type /msg %S HELP USE for more information.");
1658 else if (!(user = find(u)))
1660 notice(s_GameServ, u, "Fatal Error in do_use. Contact a(n) %S Admin");
1663 else if (isIgnore(user))
1666 log("Ignoring %s.", user->getNick());
1670 else if (!is_playing(user))
1672 notice(s_GameServ, u, "You must be playing to use items!");
1676 updateTS(user->stats);
1678 p = &user->stats->inventory;
1680 if (stricmp(item, "HEALING") == 0)
1682 if (p->Healing() <= 0)
1684 notice(s_GameServ, u, "You are out of Healing Potions!");
1687 int oldhealing = user->stats->hp;
1688 user->stats->hp += (10 * user->stats->level) + (rand() % 10) * user->stats->level;
1689 if (user->stats->hp - user->stats->maxhp >= 100)
1691 user->stats->hp = user->stats->maxhp + 100;
1693 if (oldhealing >= (user->stats->maxhp + 100))
1695 notice(s_GameServ, u, "You cannot hold anymore HP!");
1700 notice(s_GameServ, u, "You hastiliy gulp down the flask of cool life-giving waters.");
1701 notice(s_GameServ, u, "Rejuvination spreads throughout your body.");
1702 notice(s_GameServ, u, "You gain %d HP!", user->stats->hp - oldhealing);
1704 if (player_fight(user))
1706 notice(s_GameServ, user->stats->battle->getNick(),
1707 "%s has used a healing potion!");
1710 else if (stricmp(item, "STRENGTH") == 0)
1712 if (p->Strength() <= 0)
1714 notice(s_GameServ, u, "You are out of Strength Potions!");
1717 int oldstrength = user->stats->strength;
1718 notice(s_GameServ, u, "As you grip the flask containing pure power, you feel adrenaline coarse through your veins!");
1719 notice(s_GameServ, u, "In one swallow you drink the potion and feel your muscle fibers bulging andgrowing!");
1720 user->stats->strength += 1 + (rand() % 10 >= 8 ? 1 : 0); // 1-2
1721 notice(s_GameServ, u, "You gain %d Strength points!", user->stats->strength - oldstrength);
1723 if (player_fight(user))
1725 notice(s_GameServ, user->stats->battle->getNick(),
1726 "%s has used a strength potion!");
1729 else if (stricmp(item, "DEFENSE") == 0)
1731 if (p->Defense() <= 0)
1733 notice(s_GameServ, u, "You are out of Defense Potions!");
1736 int olddefense = user->stats->defense;
1737 notice(s_GameServ, u, "You drink the foul tasting viscous liquid while pinching your nose in disgust.");
1738 notice(s_GameServ, u, "It tasted bad, but you feel like you are unbeatable!");
1739 user->stats->defense += 1 + (rand() % 10 >= 8 ? 1 : 0); // 1-2
1740 notice(s_GameServ, u, "You gain %d Defense points!", user->stats->defense - olddefense);
1742 if (player_fight(user))
1744 notice(s_GameServ, user->stats->battle->getNick(),
1745 "%s has used a defense potion!");
1748 else if (stricmp(item, "HP") == 0)
1752 notice(s_GameServ, u, "You are out of HP Potions!");
1755 int oldHP = user->stats->maxhp;
1756 notice(s_GameServ, u, "You feel your life growing longer as you drink the green glowing liquid.");
1757 user->stats->maxhp += 2 +
1758 (rand() % 100 > 70 ? (rand() % 7) : (rand() % 2) );
1760 notice(s_GameServ, u, "You gain %d Maximum hit points!", user->stats->maxhp - oldHP);
1762 if (player_fight(user))
1764 notice(s_GameServ, user->stats->battle->getNick(),
1765 "%s has used a HP potion!");
1770 notice(s_GameServ, u, "SYNTAX: /msg %S USE {HEALING | STRENGTH | DEFENSE | HP}");
1774 end_turn(user); // If they're fighting, end their turn
1778 void do_run ( char * u
)
1781 Player
* p
, * p2
= NULL
;
1783 if (!( user
= find ( u
)))
1785 notice ( s_GameServ
, u
, "Couldn't find you. Error. Contact a %S admin" );
1788 else if ( isIgnore ( user
))
1791 log ( "Ignoring %s ." , user
-> getNick ());
1795 else if (! is_playing ( user
))
1797 notice ( s_GameServ
, u
, "You must be playing to run!" );
1801 updateTS ( user
-> stats
);
1805 p2
= p
-> battle
-> stats
;
1807 if (! is_fighting ( user
))
1808 notice ( s_GameServ
, u
, "You run in place... try fighting next time." );
1809 else if (! player_fight ( user
) && ! master_fight ( user
))
1811 notice ( s_GameServ
, u
, "You run away from \ 2 %s \ 2 like a little baby!", p
-> fight
-> name
. c_str ());
1815 else if ( player_fight ( user
) && isYourTurn ( p
))
1817 notice ( s_GameServ
, u
, "You run away from \ 2 %s \ 2 like a little baby!", p2
-> name
. c_str ());
1818 notice ( s_GameServ
, p
-> battle
-> getNick (), "\ 2 %s \ 2 ran away from you like a little baby!", p
-> name
. c_str ());
1821 else if ( player_fight ( user
) && ! isYourTurn ( p
))
1823 notice ( s_GameServ
, u
, "It is not your turn. Please wait until \ 2 %s \ 2 decides what to do.", p2
-> name
. c_str ());
1825 else if ( master_fight ( user
))
1827 notice ( s_GameServ
, u
, "You cannot run from \ 2 %s \ 2 ! FIGHT!", p
-> master
-> name
. c_str ());
1832 void end_turn ( aClient
* user
)
1834 char * nick
, * u
= user
-> getNick ();
1839 nick
= new char [ strlen ( user
-> getNick ()) + 1 ];
1841 if (! user
|| ! is_playing ( user
) || ! is_fighting ( user
))
1844 if (! player_fight ( user
) && ! master_fight ( user
))
1845 fight
= user
-> stats
-> fight
;
1847 fight
= user
-> stats
-> master
;
1848 battle
= user
-> stats
-> battle
;
1850 if (! player_fight ( user
))
1853 mhit
= ( fight
-> strength
/ 2 ) +
1854 ( rand () % ( fight
-> strength
/ 2 ) - ( user
-> stats
-> defense
+
1855 arbonus
[ user
-> stats
-> arm
]));
1860 mhit
= ((( battle
-> stats
-> strength
+ webonus
[ battle
-> stats
-> wea
]) / 2 ) +
1861 ( rand () % (( battle
-> stats
-> strength
+ webonus
[ battle
-> stats
-> wea
])) / 2 ) -
1862 ( user
-> stats
-> defense
+ arbonus
[ user
-> stats
-> arm
]));
1864 if (! player_fight ( user
))
1869 notice ( s_GameServ
, u
, "\1f %s \1f attacks with their \1f %s \1f for \ 2 %d \ 2 damage!",
1870 fight
-> name
. c_str (), fight
-> weapon
. c_str (), mhit
);
1873 notice ( s_GameServ
, u
, " %s completely misses you!" , fight
-> name
. c_str ());
1875 if ( mhit
>= user
-> stats
-> hp
)
1877 if (! master_fight ( user
))
1879 notice ( s_GameServ
, u
, "You have been \ 2 \1f killed\1f \ 2 by %s !" , fight
-> name
. c_str ());
1880 notice ( s_GameServ
, u
, "You lose all gold on hand and lose 10 percent " \
1881 "of your experience!" );
1882 user
-> stats
-> gold
= 0 ;
1883 user
-> stats
-> exp
-= ( long int )( user
-> stats
-> exp
* .10 );
1884 user
-> stats
-> hp
= 0 ;
1885 user
-> stats
-> fight
= NULL
;
1886 clearAlive ( user
-> stats
);
1891 notice ( s_GameServ
, u
, " %s has bested you! You will have to wait " \
1892 "until tomorrow to try again" , user
-> stats
-> master
-> name
. c_str ());
1893 user
-> stats
-> fight
= NULL
;
1894 user
-> stats
-> master
= NULL
;
1901 user
-> stats
-> hp
-= mhit
;
1908 clearYourTurn ( user
-> stats
);
1909 setYourTurn ( battle
-> stats
);
1910 display_players ( battle
);
1916 void do_heal ( char * u
)
1919 char * amount
= strtok ( NULL
, " " );
1924 notice ( s_GameServ
, u
, "SYNTAX: /msg %S HEAL {ALL | #}" );
1927 else if (!( ni
= find ( u
)))
1929 notice ( s_GameServ
, u
, "Fatal error. Contact a(n) %S admin. buf: %s " , strtok ( NULL
, "" ));
1932 else if ( isIgnore ( ni
))
1935 log ( "Ignoring %s ." , ni
-> getNick ());
1939 else if (! is_playing ( ni
))
1941 notice ( s_GameServ
, u
, "You aren't playing!" );
1944 else if (! isAlive ( ni
-> stats
))
1946 notice ( s_GameServ
, u
, "You are dead. Wait until tomorrow for healing." );
1949 else if ( is_fighting ( ni
))
1951 notice ( s_GameServ
, u
, "You can't heal in battle!" );
1954 else if ( ni
-> stats
-> hp
>= ni
-> stats
-> maxhp
)
1956 notice ( s_GameServ
, u
, "You don't need healing!" );
1960 updateTS ( ni
-> stats
);
1961 if ( stricmp ( amount
, "ALL" ) == 0 )
1963 price
= ni
-> stats
-> level
* 3 ;
1964 if ( ni
-> stats
-> gold
< ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
) * price
)
1966 notice ( s_GameServ
, u
, "Healing \ 2 %d \ 2 points for \ 2 %d \ 2 gold per point.",
1967 ( long int ) ni
-> stats
-> gold
/ price
, price
);
1968 ni
-> stats
-> hp
+= ni
-> stats
-> gold
/ price
;
1969 ni
-> stats
-> gold
%= price
;
1973 notice ( s_GameServ
, u
, "Healing all possible points at \ 2 %d \ 2 gold "\
1974 "per point." , price
);
1975 notice ( s_GameServ
, u
, "\ 2 %d \ 2 points healed for \ 2 %l d\ 2 gold. HP at MAX!" ,
1976 ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
),
1977 ( price
* ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
)) );
1978 ni
-> stats
-> gold
-= price
* ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
);
1979 ni
-> stats
-> hp
= ni
-> stats
-> maxhp
;
1982 else if ( isstringnum ( amount
))
1984 num
= stringtoint ( amount
);
1985 price
= ni
-> stats
-> level
* 3 ;
1986 if ( ni
-> stats
-> gold
< price
* num
)
1988 notice ( s_GameServ
, u
, "You only have enough gold to heal \ 2 %d \ 2 points!",
1989 ( long int ) ni
-> stats
-> gold
/ price
);
1991 else if ( num
<= ni
-> stats
-> maxhp
- ni
-> stats
-> hp
)
1993 notice ( s_GameServ
, u
, "Healing \ 2 %d \ 2 points at \ 2 %d \ 2 gold per point.",
1995 ni
-> stats
-> hp
+= num
;
1996 ni
-> stats
-> gold
-= num
* price
;
1998 else if ( num
> ni
-> stats
-> maxhp
- ni
-> stats
-> hp
)
2000 notice ( s_GameServ
, u
, "Healing all possible points at \ 2 %d \ 2 gold "\
2001 "per point." , price
);
2002 notice ( s_GameServ
, u
, "\ 2 %d \ 2 points healed. HP at MAX!",
2003 ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
));
2004 ni
-> stats
-> gold
-= price
* ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
);
2005 ni
-> stats
-> hp
= ni
-> stats
-> maxhp
;
2008 else if ( amount
[ 0 ] == '-' )
2009 notice ( s_GameServ
, u
, "You trying to cheat?" );
2011 notice ( s_GameServ
, u
, "SYNTAX: /msg %S HEAL {ALL | #}" );
2014 int isstringnum ( char * num
)
2017 for ( x
= 0 ; x
< strlen ( num
); x
++)
2019 if (( int ) num
[ x
] < 48 || ( int ) num
[ x
] > 57 )
2025 long int stringtoint ( char * number
)
2027 return atol ( number
);
2029 long int x, len = strlen(number), sum = 0;
2031 return chartoint(number[0]);
2032 sum += chartoint(number[len - 1]);
2033 for (x = len - 2; x >= 0; x--)
2034 sum += chartoint(number[x]) * pow(10, abs(x - len + 1));
2039 long int pow ( int x
, int y
)
2045 if ( x
!= 0 && y
!= 0 )
2047 for ( count
= 1 ; count
<= y
- 1 ; count
++)
2055 long int chartoint ( char ch
)
2057 if ( int ( ch
) >= 48 && int ( ch
) <= 57 )
2058 return int ( ch
) - 48 ;
2065 ListNode
< aClient
> * ptr
;
2069 outfile
. open ( playerdata
);
2073 log ( "Error opening %s " , playerdata
);
2077 for ( unsigned long x
= 0 ; x
< U_TABLE_SIZE
; x
++)
2079 ptr
= players
[ x
]. First ();
2082 it
= ptr
-> getData ()-> stats
;
2084 outfile
<< it
-> name
. c_str () << ' ' << it
-> level
<< ' ' << it
-> exp
<< ' ' << it
-> gold
<< ' ' << it
-> bank
<< ' '
2085 << it
-> hp
<< ' ' << it
-> maxhp
<< ' ' << it
-> strength
<< ' ' << it
-> defense
<< ' '
2086 << it
-> arm
<< ' ' << it
-> wea
<< ' '
2087 << it
-> forest_fights
<< ' ' << it
-> player_fights
<< ' '
2088 << it
-> getFlags () << ' ' << it
-> password
<< ' '
2089 /* fixing this << it->inventory.Healing()
2090 << ' ' << it->inventory.Strength() << ' ' << it->inventory.Defense() << ' ' << it->inventory.HP()
2091 << ' ' */ << it
-> lastlogin
<< endl
;
2104 infile
. open ( dragondata
);
2109 log ( "Error opening %s . Trying initialdragon.dat" , dragondata
);
2110 infile
. open ( "data/initialdragon.dat" );
2113 log ( "Error opening data/initialdragon.dat" );
2118 buf
= new char [ 1024 ];
2120 infile
. getline ( buf
, 1024 , ' \n ' );
2121 infile
. close (); // Done with the file... we have what we want
2123 dragon
. name
= strtok ( buf
, "~" );
2124 dragon
. weapon
= strtok ( NULL
, "~" );
2127 dragon
. strength
= stringtoint ( strtok ( NULL
, "~" ));
2128 dragon
. hp
= stringtoint ( strtok ( NULL
, "~" ));
2129 dragon
. defense
= stringtoint ( strtok ( NULL
, "~" ));
2130 dragon
. death
= strtok ( NULL
, "" );
2132 log ( "loaded dragon: %s " , dragon
. name
. c_str ());
2136 return save_dragon (); // Save the dragon file and return the status code :)
2143 outfile
. open ( dragondata
);
2147 log ( "Error opening %s . Exiting." , dragondata
);
2151 outfile
<< dragon
. name
. c_str () << '~' << dragon
. weapon
. c_str () << '~'
2152 << dragon
. strength
<< '~' << dragon
. hp
<< '~'
2153 << dragon
. defense
<< '~' << dragon
. death
. c_str () << " \n ^"
2166 char * tempname
, * buf
, * password
;
2167 buf
= new char [ 1024 ];
2169 infile
. open ( playerdata
);
2173 log ( "Error opening %s " , playerdata
);
2177 for ( int x
= 0 ; x
< U_TABLE_SIZE
; x
++)
2179 ListNode
< aClient
> * tempNode
;
2180 tempNode
= players
[ x
]. First ();
2183 if ( tempNode
-> getData ()-> stats
-> client
)
2184 logout ( tempNode
-> getData ()-> stats
-> client
);
2185 tempNode
= tempNode
-> Next ();
2187 players
[ x
]. deleteNodes ();
2190 while ( infile
. getline ( buf
, 1024 , ' \n ' ))
2193 testitem
= new weapon ( "Empty Weapon" );
2196 tempname
= strtok ( buf
, " " );
2197 temp
-> stats
= new Player ( tempname
);
2200 p
-> inventory
-> addItem ( testitem
);
2202 p
-> level
= stringtoint ( strtok ( NULL
, " " ));
2203 p
-> exp
= stringtoint ( strtok ( NULL
, " " ));
2204 p
-> gold
= stringtoint ( strtok ( NULL
, " " ));
2205 p
-> bank
= stringtoint ( strtok ( NULL
, " " ));
2206 p
-> hp
= stringtoint ( strtok ( NULL
, " " ));
2207 p
-> maxhp
= stringtoint ( strtok ( NULL
, " " ));
2208 p
-> strength
= stringtoint ( strtok ( NULL
, " " ));
2209 p
-> defense
= stringtoint ( strtok ( NULL
, " " ));
2210 p
-> arm
= stringtoint ( strtok ( NULL
, " " ));
2211 p
-> wea
= stringtoint ( strtok ( NULL
, " " ));
2212 p
-> forest_fights
= stringtoint ( strtok ( NULL
, " " ));
2213 p
-> player_fights
= stringtoint ( strtok ( NULL
, " " ));
2214 p
-> setFlags ( stringtoint ( strtok ( NULL
, " " )));
2218 password
= strtok ( NULL
, " " );
2219 p
-> password
= password
;
2220 temp
-> setNick ( "Not Playing" );
2222 temp
-> setRealNick ( "Not Playing" );
2225 // Old player databases didn't have these three extra values
2226 // If they come up null, leave them to 0 as the default.
2227 // On the next gameserv database save, it will save the values.
2228 tempname
= strtok ( NULL
, " " );
2230 // p->inventory.setHealing(stringtoint(tempname));
2232 tempname
= strtok ( NULL
, " " );
2234 // p->inventory.setStrength(stringtoint(tempname));
2236 tempname
= strtok ( NULL
, " " );
2238 // p->inventory.setDefense(stringtoint(tempname));
2240 tempname
= strtok ( NULL
, " " );
2242 // p->inventory.setHP(stringtoint(tempname));
2244 tempname
= strtok ( NULL
, " " );
2246 p
-> lastlogin
= stringtoint ( tempname
);
2248 p
-> lastlogin
= time ( NULL
);
2250 unsigned long hv
= iHASH (( unsigned char *) temp
-> stats
-> name
. c_str ());
2252 temp
-> stats
-> client
= NULL
;
2253 players
[ hv
]. insertAtBack ( temp
);
2261 bool passcmp ( const char * encrypted
, char * plaintext
)
2264 char * plaintext2
, * plainToencrypt
;
2267 plaintext2
= new char [ strlen ( encrypted
) + strlen ( plaintext
)]; // Extra
2268 strcpy ( plaintext2
, plaintext
);
2270 salt
[ 0 ] = encrypted
[ 0 ];
2271 salt
[ 1 ] = encrypted
[ 1 ];
2274 plainToencrypt
= crypt ( plaintext2
, salt
);
2276 same
= ( strcmp (( const char *) encrypted
, plainToencrypt
) == 0 ? true : false );
2278 delete [] plaintext2
;
2283 bool check_password ( char * name
, char * plaintext
)
2287 if (!( client
= findplayer ( name
)))
2291 return passcmp ( client
-> stats
-> password
. c_str (), plaintext
);
2295 void do_store ( char * u
)
2297 char * cmd
= strtok ( NULL
, " " );
2298 char * item
= strtok ( NULL
, " " );
2299 char * num
= strtok ( NULL
, " " );
2307 notice ( s_GameServ
, u
, "SYNTAX: STORE LIST {ARMOR | WEAPONS}" );
2308 notice ( s_GameServ
, u
, " \ 2 STORE SELL {ARMOR | WEAPON}\ 2 " );
2309 notice ( s_GameServ
, u
, " \ 2 STORE BUY {ARMOR | WEAPON} \1f NUMBER\1f \ 2 " );
2312 else if (!( user
= find ( u
)))
2314 log ( "Fatal Error: could not find %s in client list" , u
);
2317 else if ( isIgnore ( user
))
2320 log ( "Ignoring %s ." , user
-> getNick ());
2324 else if (! is_playing ( user
))
2326 notice ( s_GameServ
, u
, "You must be playing to use the store!" );
2329 else if (! isAlive ( user
-> stats
))
2331 notice ( s_GameServ
, u
, "You are dead. Wait until tomorrow to purchase weapons and armor!" );
2334 updateTS ( user
-> stats
);
2336 if ( stricmp ( cmd
, "LIST" ) == 0 )
2338 if ( stricmp ( item
, "WEAPONS" ) == 0 )
2340 notice ( s_GameServ
, u
, "Welcome to Kain's Armory" );
2341 notice ( s_GameServ
, u
, "Here are the weapons we have available for the killing, sire:" );
2342 for ( int x
= 1 ; x
< WNA
; x
++)
2344 space
= spaces ( strlen ( weapons
[ x
]), "." );
2345 notice ( s_GameServ
, u
, " %s%d . %s%s%d " ,( x
< 10 ? " " : "" ), x
, weapons
[ x
], space
, prices
[ x
- 1 ]);
2348 notice ( s_GameServ
, u
, "To purchase a weapon, type /msg %S STORE BUY \ 2 NUM\ 2 ." );
2349 notice ( s_GameServ
, u
, "Where num. is the weapon number from the menu above." );
2352 else if ( stricmp ( item
, "ARMOR" ) == 0 )
2354 notice ( s_GameServ
, u
, "Welcome to Kain's Armory" );
2355 notice ( s_GameServ
, u
, "I hope you enjoy the fine armor we have available for your protection:" );
2356 for ( int x
= 1 ; x
< WNA
; x
++)
2358 space
= spaces ( strlen ( armors
[ x
]), "." );
2359 notice ( s_GameServ
, u
, " %s%d . %s%s%d " ,( x
< 10 ? " " : "" ), x
, armors
[ x
], space
, prices
[ x
- 1 ]);
2362 notice ( s_GameServ
, u
, "To purchase armor, type /msg %S store buy armor num." );
2363 notice ( s_GameServ
, u
, "Where num. is the armor number from the menu above." );
2367 } else if ( stricmp ( cmd
, "BUY" ) == 0 ) {
2370 notice ( s_GameServ
, u
, "SYNTAX: \ 2 STORE BUY {ARMOR | WEAPON} \1f NUMBER\1f \ 2 " );
2373 else if (! isstringnum ( num
))
2375 notice ( s_GameServ
, u
, "You must specify a number between 1 and %d . Not %s !" , WNA
- 1 , num
);
2378 if ( stricmp ( item
, "WEAPON" ) == 0 )
2380 wep
= stringtoint ( num
);
2381 if ( wep
>= WNA
|| wep
< 1 )
2383 notice ( s_GameServ
, u
, "The number %d is out of range. The number you provide must be between 1 and %d ." , wep
, WNA
- 1 );
2390 notice ( s_GameServ
, u
, "You have to sell your %s first!" , weapons
[ p
-> wea
]);
2391 else if ( p
-> gold
< prices
[ wep
- 1 ])
2392 notice ( s_GameServ
, u
, "You don't have enough gold for %s !" , weapons
[ wep
]);
2395 notice ( s_GameServ
, u
, "You have purchased %s ! Thanks for the gold!" , weapons
[ wep
]);
2397 p
-> gold
-= prices
[ wep
- 1 ];
2400 else if ( stricmp ( item
, "ARMOR" ) == 0 )
2402 wep
= stringtoint ( num
);
2403 if ( wep
>= WNA
|| wep
< 1 )
2405 notice ( s_GameServ
, u
, "The number %d is out of range. The number you provide must be between 1 and %d ." , wep
, WNA
- 1 );
2412 notice ( s_GameServ
, u
, "You have to sell your %s first!" , armors
[ p
-> arm
]);
2413 else if ( p
-> gold
< prices
[ wep
- 1 ])
2414 notice ( s_GameServ
, u
, "You don't have enough gold for %s !" , armors
[ wep
]);
2417 notice ( s_GameServ
, u
, "You have purchased %s ! Thanks for the gold!" , armors
[ wep
]);
2419 p
-> gold
-= prices
[ wep
- 1 ];
2424 notice ( s_GameServ
, u
, "SYNTAX: \ 2 STORE BUY {ARMOR | WEAPON} \1f NUMBER\1f \ 2 " );
2428 else if ( stricmp ( cmd
, "SELL" ) == 0 )
2432 if ( stricmp ( item
, "WEAPON" ) == 0 )
2436 notice ( s_GameServ
, u
, "You want me to chop off your hands?" );
2439 else if ( p
-> gold
== 2000000000 )
2441 notice ( s_GameServ
, u
, "You have enough gold. I'll just take that off your hands, sire." );
2444 else if ( 2000000000 - p
-> gold
< ( prices
[ p
-> wea
- 1 ] / 2 ))
2446 notice ( s_GameServ
, u
, "Thank you for your business! You now have as much gold as you can carry." );
2447 notice ( s_GameServ
, u
, "However, you have no weapon... can I interest you in the %s ?" , weapons
[ WNA
- 1 ]);
2448 p
-> gold
= 2000000000 ;
2453 notice ( s_GameServ
, u
, "Thank you for your business! You now have %d more gold but no weapon!" , ( prices
[ p
-> wea
- 1 ] / 2 ));
2454 p
-> gold
+= ( prices
[ p
-> wea
- 1 ] / 2 );
2458 else if ( stricmp ( item
, "ARMOR" ) == 0 )
2464 notice ( s_GameServ
, u
, "I don't think you can be any more naked..." );
2467 if ( p
-> gold
== 2000000000 )
2469 notice ( s_GameServ
, u
, "You have enough gold. I'll just take that off your hands, sire." );
2472 else if ( 2000000000 - p
-> gold
< ( prices
[ p
-> arm
- 1 ] / 2 ))
2474 notice ( s_GameServ
, u
, "Thank you for your business! You now have as much gold as you can carry." );
2475 notice ( s_GameServ
, u
, "However, you have no armor... can I interest you in %s ?" , armors
[ WNA
- 1 ]);
2476 p
-> gold
= 2000000000 ;
2481 notice ( s_GameServ
, u
, "Thank you for your business! You now have %d more gold but no armor!" ,
2482 ( prices
[ p
-> arm
- 1 ] / 2 ));
2484 p
-> gold
+= ( prices
[ p
-> arm
- 1 ] / 2 );
2490 notice ( s_GameServ
, u
, "SYNTAX: STORE LIST {ARMOR | WEAPONS}" );
2491 notice ( s_GameServ
, u
, " \ 2 STORE SELL {ARMOR | WEAPON}\ 2 " );
2492 notice ( s_GameServ
, u
, " \ 2 STORE BUY {ARMOR | WEAPON} \1f NUMBER\1f \ 2 " );
2497 notice ( s_GameServ
, u
, "SYNTAX: STORE LIST {ARMOR | WEAPONS}" );
2498 notice ( s_GameServ
, u
, " \ 2 STORE SELL {ARMOR | WEAPON}\ 2 " );
2499 notice ( s_GameServ
, u
, " \ 2 STORE BUY {ARMOR | WEAPON} \1f NUMBER\1f \ 2 " );
2503 void do_inventory ( char * u
)
2507 if (!( user
= find ( u
)))
2509 notice ( s_GameServ
, u
, "Fatal Error. Contact a %S admin!" );
2512 else if ( isIgnore ( user
))
2515 log ( "Ignoring %s ." , user
-> getNick ());
2519 else if (! is_playing ( user
))
2521 notice ( s_GameServ
, u
, "You must be playing to check your inventory!" );
2524 updateTS ( user
-> stats
);
2525 showinventory ( user
, user
);
2528 void showinventory ( aClient
* from
, aClient
* to
)
2534 nick
= to
-> getNick ();
2536 if ( is_playing ( from
))
2538 if ( from
-> stats
-> inventory
-> isEmpty ())
2540 notice ( s_GameServ
, nick
, "You aren't carrying anything" );
2544 list
< item
*> * items
;
2545 items
= from
-> stats
-> inventory
-> getItems ();
2547 list
< item
*>:: iterator item_iter
;
2548 item_iter
= items
-> begin ();
2550 notice ( s_GameServ
, nick
, "Inventory for %s :" , from
-> stats
-> name
. c_str ());
2552 while ( item_iter
!= items
-> end ())
2554 notice ( s_GameServ
, nick
, " %d .) %s " , ++ x
, (* item_iter
)-> getName (). c_str ());
2560 void do_tavern ( char * u
)
2563 char *cmd = strtok(NULL, " ");
2569 if (!(user = find(u)))
2571 notice(s_GameServ, u, "Fatal Error. See a %S admin for help");
2574 else if (isIgnore(user))
2577 log("Ignoring %s.", user->getNick());
2581 else if (!is_playing(user))
2583 notice(s_GameServ, u, "You must be playing to go to the Tavern");
2586 else if (is_fighting(user))
2588 notice(s_GameServ, u, "You cannot go to the Tavern during a fight!");
2592 updateTS(user->stats);
2597 notice(s_GameServ, u, "Welcome to Boot Liquors Mystic Apothecary");
2598 notice(s_GameServ, u, "Your commands:");
2599 notice(s_GameServ, u, "/msg %S TAVERN {LIST | BUY} [NUMBER]");
2600 notice(s_GameServ, u, "What'll it be?");
2602 else if (stricmp(cmd, "LIST") == 0)
2604 notice(s_GameServ, u, "Here is a list of what we have to offer:");
2605 notice(s_GameServ, u, "1. Healing Potions for %ld Gold",
2606 1000 * p->level * 4);
2607 notice(s_GameServ, u, "2. Strength Potions for %ld Gold",
2608 2500 * p->level * 4);
2609 notice(s_GameServ, u, "3. Defense Potions for %ld Gold",
2610 3000 * p->level * 4);
2611 notice(s_GameServ, u, "4. HP Potions for %ld Gold",
2612 2000 * p->level * 4);
2613 notice(s_GameServ, u, "To buy a potion, type /msg %S TAVERN BUY #");
2614 notice(s_GameServ, u, "Example: /msg %S TAVERN BUY 1 buys a healing potion!");
2616 else if (stricmp(cmd, "BUY") == 0)
2618 char *chnum = strtok(NULL, " ");
2622 notice(s_GameServ, u, "SYNTAX: TAVERN BUY #");
2623 notice(s_GameServ, u, "Example: /msg %S TAVERN BUY 1");
2626 int num = stringtoint(chnum);
2628 if (num < 1 || num > 4)
2630 notice(s_GameServ, u, "Invalid Choice!");
2631 notice(s_GameServ, u, "Here is a list of what we have to offer:");
2632 notice(s_GameServ, u, "1. Healing Potions for %ld Gold",
2633 1000 * p->level * 4);
2634 notice(s_GameServ, u, "2. Strength Potions for %ld Gold",
2635 2500 * p->level * 4);
2636 notice(s_GameServ, u, "3. Defense Potions for %ld Gold",
2637 3000 * p->level * 4);
2638 notice(s_GameServ, u, "4. HP Potions for %ld Gold",
2639 2000 * p->level * 4);
2640 notice(s_GameServ, u, "To buy a potion, type /msg %S TAVERN BUY #");
2641 notice(s_GameServ, u, "Example: /msg %S TAVERN BUY 1 buys a healing potion!");
2647 price = (1000 * p->level * 4);
2648 if (p->gold >= price)
2650 notice(s_GameServ, u, "One healing potion coming right up!");
2651 p->inventory.incHealing();
2655 notice(s_GameServ, u, "You don't have enough gold!");
2658 price = 2500 * p->level * 4;
2659 if (p->gold >= price)
2661 notice(s_GameServ, u, "One strength boost coming right up!");
2662 p->inventory.incStrength();
2666 notice(s_GameServ, u, "You don't have enough gold!");
2669 price = 3000 * p->level * 4;
2670 if (p->gold >= price)
2672 notice(s_GameServ, u, "One defense boost coming right up!");
2673 p->inventory.incDefense();
2677 notice(s_GameServ, u, "You don't have enough gold!");
2680 price = 3000 * p->level * 4;
2681 if (p->gold >= price)
2683 notice(s_GameServ, u, "One HP Potion coming right up!");
2684 p->inventory.incHP();
2688 notice(s_GameServ, u, "You don't have enough gold!");
2691 notice(s_GameServ, u, "Logical Error. See a %S admin for help!");
2697 notice(s_GameServ, u, "Improper Syntax.");
2698 notice(s_GameServ, u, "Type /msg %S HELP TAVERN for help");
2704 void do_bank ( char * u
)
2706 char * cmd
= strtok ( NULL
, " " );
2707 char * amount
= strtok ( NULL
, " " );
2708 char * nick
= strtok ( NULL
, " " );
2713 if (! cmd
|| (! amount
&& stricmp ( cmd
, "BALANCE" ) != 0 ) || ( stricmp ( cmd
, "TRANSFER" ) == 0 && ! nick
))
2715 notice ( s_GameServ
, u
, "BANK {WITHDRAW | DEPOSIT} {ALL | AMOUNT}" );
2716 notice ( s_GameServ
, u
, "BANK BALANCE" );
2719 else if (!( user
= find ( u
)))
2721 notice ( s_GameServ
, u
, "Fatal Error. Couldn't find your aClient. Contact a(n) %S " \
2723 log ( "Fatal Error. Couldn't find %s while executing do_bank()" , u
);
2726 else if ( isIgnore ( user
))
2729 log ( "Ignoring %s ." , user
-> getNick ());
2733 else if (! is_playing ( user
))
2735 notice ( s_GameServ
, u
, "You must be playing to use the bank!" );
2738 else if ( is_fighting ( user
))
2740 notice ( s_GameServ
, u
, "You can't go to the bank during a fight!" );
2743 updateTS ( user
-> stats
);
2744 if ( stricmp ( cmd
, "BALANCE" ) == 0 )
2749 else if (! isAlive ( user
-> stats
))
2751 notice ( s_GameServ
, u
, "You are dead. We don't accept gold from dead folk! Wait 'til tomorrow!" );
2754 else if (! isstringnum ( amount
) && stricmp ( amount
, "ALL" ) != 0 )
2756 notice ( s_GameServ
, u
, "I don't know how to convert alphabet letters into currency, sire!" );
2759 if ( stringtoint ( amount
) < 0 )
2761 notice ( s_GameServ
, u
, "Sorry. This bank is not licensed " \
2762 "to handle such sums of cash, noble Lord." );
2767 if ( stricmp ( cmd
, "DEPOSIT" ) == 0 )
2769 if ( p
-> bank
== 2000000000 )
2771 notice ( s_GameServ
, u
, "Your bank account is full, sire!" );
2774 else if ( stricmp ( amount
, "ALL" ) == 0 )
2776 if ( 2000000000 - p
-> bank
< p
-> gold
)
2778 notice ( s_GameServ
, u
, "You don't have enough room for all of your gold." );
2779 notice ( s_GameServ
, u
, "Depositing %l d gold into your account" , ( 2000000000 - p
-> bank
));
2780 p
-> gold
-= ( 2000000000 - p
-> bank
);
2781 p
-> bank
= 2000000000 ;
2786 notice ( s_GameServ
, u
, "Depositing %l d gold into your account!" , p
-> gold
);
2792 else if ( stringtoint ( amount
) > p
-> gold
)
2794 notice ( s_GameServ
, u
, "Sire, you only have %l d gold!" , p
-> gold
);
2800 if ( 2000000000 - p
-> bank
< stringtoint ( amount
))
2802 notice ( s_GameServ
, u
, "You don't have room in your account for that much." );
2803 notice ( s_GameServ
, u
, "Capping off your account with %l d gold!" , ( 2000000000 - p
-> bank
));
2804 p
-> gold
-= ( 2000000000 - p
-> bank
);
2805 p
-> bank
= 2000000000 ;
2810 notice ( s_GameServ
, u
, "Depositing %d gold into your account!" , stringtoint ( amount
));
2811 p
-> bank
+= stringtoint ( amount
);
2812 p
-> gold
-= stringtoint ( amount
);
2817 else if ( stricmp ( cmd
, "WITHDRAW" ) == 0 )
2819 if ( p
-> gold
== 2000000000 )
2821 notice ( s_GameServ
, u
, "You cannot carry any more gold, sire!" );
2825 else if ( stricmp ( amount
, "ALL" ) == 0 )
2827 if ( 2000000000 - p
-> gold
< p
-> bank
)
2829 notice ( s_GameServ
, u
, "You don't have enough room to carry all that gold." );
2830 notice ( s_GameServ
, u
, "Withdrawing %l d gold from your account" , ( 2000000000 - p
-> gold
));
2831 p
-> bank
-= ( 2000000000 - p
-> gold
);
2832 p
-> gold
= 2000000000 ;
2837 notice ( s_GameServ
, u
, "Withdrawing %l d gold from your account!" , p
-> bank
);
2843 else if ( stringtoint ( amount
) > p
-> bank
)
2845 notice ( s_GameServ
, u
, "Sire, you only have %l d gold in the bank!" , p
-> bank
);
2851 if ( 2000000000 - p
-> gold
< stringtoint ( amount
))
2853 notice ( s_GameServ
, u
, "You don't enough have room to carry that much gold!" );
2854 notice ( s_GameServ
, u
, "You fill your pockets with %l d gold!" ,
2855 ( 2000000000 - p
-> gold
));
2856 p
-> bank
-= ( 2000000000 - p
-> gold
);
2857 p
-> gold
= 2000000000 ;
2862 notice ( s_GameServ
, u
, "Withdrawing %d gold from your account!" , stringtoint ( amount
));
2863 p
-> gold
+= stringtoint ( amount
);
2864 p
-> bank
-= stringtoint ( amount
);
2872 void do_dragon ( char * u
)
2876 if (!( user
= find ( u
)))
2878 notice ( s_GameServ
, u
, "Fatal error. Contact a(n) %S admin. buf: %s " , strtok ( NULL
, "" ));
2881 else if ( isIgnore ( user
))
2884 log ( "Ignoring %s ." , user
-> getNick ());
2888 else if (! is_playing ( user
))
2890 notice ( s_GameServ
, u
, "You must be playing to fight the dragon!" );
2893 else if ( is_fighting ( user
))
2895 notice ( s_GameServ
, u
, "You are already in a fight. How will you fight the almighty dragon!?" );
2898 else if (! isAlive ( user
-> stats
))
2900 notice ( s_GameServ
, u
, "You're dead. Wait until tomorrow to see your master!" );
2903 else if ( user
-> stats
-> level
< LEVELS
)
2905 notice ( s_GameServ
, u
, "You fool! Only those strong enough " \
2906 "to vanquish any foe should DARE fight the dragon!" );
2907 notice ( s_GameServ
, u
, "To put it in terms you can understand: " \
2908 "You are too weak. You must be Level %d !" , REALLEVELS
);
2912 updateTS ( user
-> stats
);
2914 Player
* p
= user
-> stats
;
2916 notice ( s_GameServ
, u
, "You approach the dragon's lair cautiously." );
2917 notice ( s_GameServ
, u
, "The stench of sulfer fills the air as a " \
2918 "deep, red fog rolls in. The air is filled with the " \
2919 "heated mist of deadly fire from beyond the cave " \
2921 notice ( s_GameServ
, u
, "You adjust your %s , tighten your grip on " \
2922 "your %s , and venture into the hot, dark cave. " \
2923 "You are surprised at the angle of descent as you climb " \
2924 "lower and lower, deeper into the dragon's den." ,
2925 armors
[ p
-> arm
], weapons
[ p
-> wea
]);
2926 notice ( s_GameServ
, u
, "You come to the end of the cave to find " \
2927 "a tooth. It is a large tooth... bigger than your torso." \
2928 " Suddenly the darkness lifts from the gleam of an eye " \
2929 " staring into your soul! The eye is large... HUGE!" );
2930 notice ( s_GameServ
, u
, "Just then you notice the eye begin to " \
2931 "glare orange! The tooth is moving... but it is still too " \
2932 "dark for you to make out.... THE DRAGON! You see it!" );
2933 p
-> fight
= new Monster ( dragon
);
2938 void do_master ( char * u
)
2943 if (!( user
= find ( u
)))
2945 notice ( s_GameServ
, u
, "Fatal error. Contact a(n) %S admin. buf: %s " , strtok ( NULL
, "" ));
2948 else if ( isIgnore ( user
))
2951 log ( "Ignoring %s ." , user
-> getNick ());
2955 else if (! is_playing ( user
))
2957 notice ( s_GameServ
, u
, "You must be playing to see your master!" );
2960 else if ( is_fighting ( user
))
2962 notice ( s_GameServ
, u
, "You're in the middle of a fight! Pay attention!" );
2965 else if (! isAlive ( user
-> stats
))
2967 notice ( s_GameServ
, u
, "You're dead. Wait until tomorrow to see your master!" );
2971 updateTS ( user
-> stats
);
2973 char * cmd
= strtok ( NULL
, " " );
2974 Player
* p
= user
-> stats
;
2979 notice ( s_GameServ
, u
, "You have already seen your master today. Wait until tomorrow to try again" );
3023 notice ( s_GameServ
, u
, "You are at level %d . You are the master. What's left? The DRAGON!" , REALLEVELS
);
3027 need
= p
-> exp
+ 1 ; // Unknown level... don't let them fight a fake master!
3033 notice ( s_GameServ
, u
, "SYNTAX: MASTER {FIGHT | QUESTION}" );
3037 if ( stricmp ( cmd
, "FIGHT" ) == 0 )
3045 notice ( s_GameServ
, u
, "You are not worthy of fighting %s ! You need %l d more experience." ,
3046 levels
[ p
-> level
- 1 ]. master
. name
. c_str (), ( need
- p
-> exp
));
3049 else if ( stricmp ( cmd
, "QUESTION" ) == 0 )
3052 notice ( s_GameServ
, u
, " %s looks you up and down and decides you are more ready than you will ever be." ,
3053 levels
[ p
-> level
- 1 ]. master
. name
. c_str ());
3055 notice ( s_GameServ
, u
, "You pathetic fool! You are no match for %s , %s !" ,
3056 levels
[ p
-> level
- 1 ]. master
. name
. c_str (), p
-> name
. c_str ());
3062 notice ( s_GameServ
, u
, "SYNTAX: MASTER {FIGHT | QUESTION}" );
3066 void see_master ( char * u
)
3070 if (!( user
= find ( u
)))
3072 notice ( s_GameServ
, u
, "Fatal error. Contact a(n) %S admin. buf: %s " , strtok ( NULL
, "" ));
3076 if (! is_fighting ( user
) && is_playing ( user
))
3078 Player
* p
= user
-> stats
;
3079 p
-> master
= new Monster (& levels
[ p
-> level
- 1 ]. master
);
3080 p
-> fight
= p
-> master
;
3081 display_monster ( u
); // Since master is the same structure, use this function
3085 void showBankBalance ( const char * u
)
3090 if (!( user
= find ( u
)))
3098 notice ( s_GameServ
, u
, "Account Balance: %l d Gold On hand: %l d" , p
-> bank
, p
-> gold
);
3104 ListNode
< aClient
> * it
;
3106 for ( unsigned long x
= 0 ; x
< U_TABLE_SIZE
; x
++)
3108 it
= players
[ x
]. First ();
3112 p
= it
-> getData ()-> stats
;
3119 void refresh ( Player
* p
)
3124 if ( p
-> hp
< p
-> maxhp
)
3126 p
-> forest_fights
= forestfights
;
3127 p
-> player_fights
= 3 ;
3132 void do_refresh ( char * u
)
3134 char * nick
= strtok ( NULL
, " " );
3137 if (!( user
= find ( u
)))
3139 notice ( s_GameServ
, u
, "Error: aClient not found. Contact a %S admin" );
3140 log ( "Error: aClient not found: %s " , u
);
3143 else if ( isIgnore ( user
))
3146 log ( "Ignoring %s ." , user
-> getNick ());
3150 else if (! isAdmin ( user
))
3152 notice ( s_GameServ
, u
, "You must be a %S admin to use this command!" );
3157 notice ( s_GameServ
, u
, "SYNTAX: REFRESH {ALL | NICK}" );
3160 else if ( stricmp ( nick
, "ALL" ) == 0 )
3162 notice ( s_GameServ
, u
, "Refreshing everyone's stats!" );
3165 else if (( user
= findplayer ( nick
)))
3167 if ( is_playing ( user
))
3170 notice ( s_GameServ
, u
, "Refreshing %s ." , user
-> getRealNick ());
3172 notice ( s_GameServ
, u
, "Refreshing %s ." , user
-> getNick ());
3174 refresh ( user
-> stats
);
3179 notice ( s_GameServ
, u
, " %s is not playing." , user
-> getRealNick ());
3181 notice ( s_GameServ
, u
, " %s is not playing." , user
-> getNick ());
3187 notice ( s_GameServ
, u
, "Nick %s not found." , nick
);
3195 ListNode
< aClient
> * it
;
3198 for ( unsigned long x
= 0 ; x
< U_TABLE_SIZE
; x
++)
3200 it
= players
[ x
]. First ();
3204 p
= it
-> getData ()-> stats
;
3211 void reset ( Player
* p
)
3218 myname
= new string ( p
-> name
);
3225 void updateTS ( Player
* p
)
3231 log ( "Old timestamp for %s : %l d" , p
-> name
. c_str (), p
-> lastcommand
);
3233 p
-> lastcommand
= time ( NULL
);
3235 log ( "New timestamp for %s : %l d" , p
-> name
. c_str (), p
-> lastcommand
);
3240 bool timedOut ( Player
* p
)
3244 else if ( p
-> lastcommand
== 0 )
3248 if (( time ( NULL
) - p
-> lastcommand
) >= maxidletime
)
3255 void timeOutEvent ( Player
* p
)
3257 aClient
* user
= findplayer ( p
-> name
. c_str ());
3259 if (! user
|| ! p
-> client
) // then they're not playing
3262 char * nick
= user
-> getNick ();
3264 if ( player_fight ( user
) && isYourTurn ( p
))
3266 // Check to see if they were the idler or if it was the other
3268 if ( p
-> lastcommand
!= p
-> battle
-> stats
-> lastcommand
)
3270 // This person's last command was given earlier,
3271 // so this person is the idler
3272 notice ( s_GameServ
, nick
, "You timed out " \
3273 "during a fight. You lose your turn!" );
3274 notice ( s_GameServ
, p
-> battle
-> getNick (),
3275 " %s hesitated for too long. Your move." , p
-> name
. c_str ());
3277 setYourTurn ( p
-> battle
-> stats
);
3279 // Update the TS for both players to give them another
3280 // Chance to wake up, but if the other player doesn't
3281 // Attack now, they both get logged out.
3283 p
-> battle
-> stats
-> lastcommand
= p
-> lastcommand
;
3284 display_players ( p
-> battle
);
3289 notice ( s_GameServ
, p
-> battle
-> getNick (),
3290 "You and %s timed out at the same time." \
3291 " Don't fight if you're just going to " \
3292 "sit there!" , p
-> name
. c_str ());
3293 notice ( s_GameServ
, user
-> getNick (),
3294 "You and %s timed out at the same time." \
3295 " Don't fight if you're just going to " \
3296 "sit there!" , p
-> battle
-> stats
-> name
. c_str ());
3302 else if (! player_fight ( user
))
3304 if ( isAlive ( user
-> stats
) && user
-> stats
-> gold
> 0 )
3306 // Place fun stuff here :)
3307 int randnum
= 1 + rand () % 100 ; // 1-100
3308 #define GSN(s) notice(s_GameServ, nick, s)
3309 #define GSN2(s, f) notice(s_GameServ, nick, s, f)
3313 // 35-100% of your gold goes pffft - kain
3314 int stolen
= ( 35 + ( rand () % 66 )) * user
-> stats
-> gold
/ 100 ;
3316 GSN ( "You stop for a moment to rest on the " \
3317 "street corner. All of a sudden, you " \
3318 "are ambushed from all sides by a hoarde " \
3319 "of knife wielding thugs." );
3320 GSN2 ( "The thugs beat you into utter submission " \
3321 "and steal %d gold from you!" , stolen
);
3322 user
-> stats
-> gold
-= stolen
;
3324 else if ( randnum
>= 50 && randnum
< 75 )
3326 // 25-65% of your gold goes pffft - kain
3327 int stolen
= ( 25 + ( rand () % 41 )) * user
-> stats
-> gold
/ 100 ;
3328 GSN ( "While dilly dallying around, you lose " \
3329 "your sense of time. Little did you know, " \
3330 "but thieves lifted your gold while you " \
3331 "weren't watching." );
3332 GSN2 ( "Better luck next time... you lose %d gold" , stolen
);
3333 user
-> stats
-> gold
-= stolen
;
3335 else if ( randnum
>= 75 )
3337 // 25-75% of your gold goes pffft - kain
3338 int stolen
= ( 25 + ( rand () % 51 )) * user
-> stats
-> gold
/ 100 ;
3339 GSN ( "Good grief! A gaggle of gooey green ghostlike " \
3340 "goblins grabbed your gold!" );
3341 GSN2 ( "They stole %d gold from you!" , stolen
);
3342 user
-> stats
-> gold
-= stolen
;
3346 // Always log out the user
3351 void do_reset ( char * u
)
3353 char * nick
= strtok ( NULL
, " " );
3356 if (!( user
= find ( u
)))
3358 notice ( s_GameServ
, u
, "Error: aClient not found. Contact a %S admin" );
3359 log ( "Error: aClient not found: %s " , u
);
3362 else if (! isAdmin ( user
))
3364 notice ( s_GameServ
, u
, "You must be a %S admin to use this command!" );
3370 notice ( s_GameServ
, u
, "SYNTAX: RESET {ALL | NICK}" );
3373 else if ( stricmp ( nick
, "ALL" ) == 0 )
3375 notice ( s_GameServ
, u
, "Resetting everyone's stats!" );
3378 else if (( user
= findplayer ( nick
)))
3380 if ( is_playing ( user
))
3383 notice ( s_GameServ
, u
, "Resetting %s ." , user
-> getRealNick ());
3385 notice ( s_GameServ
, u
, "Resetting %s ." , user
-> getNick ());
3391 notice ( s_GameServ
, u
, "Resetting %s " , user
-> stats
-> name
. c_str ());
3397 notice ( s_GameServ
, u
, "Nick %s not found." , nick
);
3402 void do_help ( char * u
)
3404 char * cmd
= strtok ( NULL
, " " );
3406 display_help ( u
, cmd
);
3409 void display_help ( char * u
, char * file
)
3416 infile
. open ( "helpfiles/help" );
3419 log ( "Error opening helpfiles/help" );
3420 notice ( s_GameServ
, u
, "Error opening helpfiles/help" );
3423 buf
= new char [ 1024 ];
3424 while ( infile
. getline ( buf
, 1024 ))
3426 // Written this way, it will process %S in the helpfiles
3427 // Instead of notice(s_GameServ, u, "%s", buf);
3428 notice ( s_GameServ
, u
, buf
);
3432 aClient
* user
= find ( u
);
3433 if ( user
&& isAdmin ( user
))
3434 display_help ( u
, "admin_commands" );
3439 filename
= new char [ strlen ( file
) + 11 ];
3440 strcpy ( filename
, "helpfiles/" );
3441 strcat ( filename
, file
);
3443 for ( unsigned int x
= 10 ; x
< strlen ( filename
); x
++)
3444 filename
[ x
] = tolower ( filename
[ x
]);
3446 infile
. open ( filename
);
3450 notice ( s_GameServ
, u
, "No help for \ 2 %s \ 2 ", file
);
3453 buf
= new char [ 1024 ];
3454 while ( infile
. getline ( buf
, 1024 ))
3456 // Written this way, it will process %S in the helpfiles
3457 // Instead of notice(s_GameServ, u, "%s", buf);
3458 notice ( s_GameServ
, u
, buf
);
3465 void do_admin ( char * u
)
3468 char * pass
= strtok ( NULL
, " " );
3470 if (!( user
= find ( u
)))
3472 log ( "Error: aClient not found: %s " , u
);
3473 notice ( s_GameServ
, u
, "Error: aClient not found. Contact %S admin." );
3479 notice ( s_GameServ
, u
, "SYNTAX: \ 2 ADMIN\ 2 \ 2 \1f password\1f \ 2 " );
3485 notice ( s_GameServ
, u
, "You already have administrator privledges." );
3488 else if ( strcmp ( pass
, adminpass
) == 0 )
3490 notice ( s_GameServ
, u
, "Password accepted. You now have administrator privledges." );
3493 log ( " %s became an administrator." , user
-> getRealNick ());
3495 log ( " %s became an administrator." , user
-> getNick ());
3500 notice ( s_GameServ
, u
, "Invalid password. Remember: case sensitive" );
3508 filename
= new char [ 256 ];
3510 for ( int x
= 1 ; x
<= LEVELS
; x
++)
3512 sprintf ( filename
, "data/levels/level %d .dat" , x
);
3513 if ( levels
[ x
- 1 ]. loadLevel ( filename
) == false )
3520 bool load_monsters ()
3525 buf
= new char [ 2048 ];
3527 for ( int level
= 1 ; level
<= LEVELS
; level
++)
3529 filename
= new char [ 256 ];
3530 sprintf ( filename
, "data/monsters/level %d .dat" , level
);
3531 infile
. open ( filename
);
3535 log ( "Error opening %s " , filename
);
3540 log ( "Loading monsters from %s " , filename
);
3543 while ( infile
. getline ( buf
, 2048 ))
3547 if ( buf
[ 0 ] == ' \n ' || buf
[ 0 ] == '\0' || buf
[ 0 ] == '#' )
3552 temp
-> name
= strtok ( buf
, "~" );
3553 temp
-> weapon
= strtok ( NULL
, "~" );
3554 temp
-> death
= strtok ( NULL
, "~" );
3556 levels
[ level
- 1 ]. monsters
. insertAtBack_RLN ( temp
);