]>
jfr.im git - irc/gameservirc.git/blob - gameserv/gameserv.cpp
15 #if defined(HAVE_CRYPT_H)
19 #elif defined(HAVE_UNISTD_H)
25 // this will be hash.cpp start
27 unsigned long sHASH ( const unsigned char * name
);
28 unsigned long iHASH ( const unsigned char * name
);
29 List
< aClient
> players
[ U_TABLE_SIZE
];
30 // this will be hash.cpp end
33 Monster
* monsters
[ LEVELS
][ MONSTERS
]; // Monsters per level. Total = MONSTERS * LEVELS
34 Monster boss
; // The boss monster
36 Monster
* masters
[ LEVELS
]; // A master for each level
44 char * strtok ( char * str
, const char * delim
);
47 int stricmp ( const char * s1
, const char * s2
);
48 int strnicmp ( const char * s1
, const char * s2
, size_t len
);
51 /********** Password functions **********/
53 bool passcmp ( char * encrypted
, char * plaintext
); // Compares an encrypted pass with a plain text one
55 bool check_password ( char * name
, char * plaintext
); // Finds a password for the given name, and checks it with passcmp against the plaintext password given.
57 /********** Password functions **********/
60 /********** GameServ Booleans **********/
63 bool timedOut ( Player
* p
);
64 void updateTS ( Player
* p
);
65 void timeOutEvent ( Player
* p
);
67 bool is_playing ( char * u
); // True if the given nickname in the clients list is playing.
68 bool is_playing ( aClient
* user
);
70 bool is_fighting ( char * u
); // True if the given nick in the clients list is fighting anything.
71 bool is_fighting ( aClient
* user
);
73 bool player_fight ( char * u
); // True if the player is fighting another player.
74 bool player_fight ( aClient
* user
);
76 bool master_fight ( char * u
); // True if the player is fighting their master.
77 bool master_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 ();
99 void delete_masters ();
101 void do_admin ( char * u
);
102 void do_attack ( char * u
);
103 void do_bank ( 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_play ( char * u
);
115 void do_quitg ( char * u
);
116 void do_reset ( char * u
);
117 void do_run ( char * u
);
118 void do_stats ( char * u
);
119 void do_store ( char * u
);
120 void do_tavern ( char * u
);
121 void do_use ( char * u
);
122 void see_master ( char * u
);
124 void logout ( aClient
* user
);
125 void showstats ( const char * u
, const char * nick
);
126 void showinventory ( aClient
* from
, aClient
* to
);
127 void showBankBalance ( const char * u
);
128 void end_turn ( aClient
* user
);
131 char * weapons
[ WNA
] = { "Fists" , "Stick" , "Dagger" , "Quarterstaff" , "Short Sword" ,
132 "Long Sword" , "Silver Spear" , "Battle Axe" , "The Ragnarok" ,
133 "Chain Saw" , "Poison Sword" , "Flame Sword" , "Earth Hammer" ,
134 "Light Saber" , "Masamune" , "Mystical Sword" };
136 char * armors
[ WNA
] = { "Nothing" , "Clothes" , "Leather Vest" , "Chain Mail" , "Plate Armor" ,
137 "Full Body Armor" , "Magic Mail" , "Graphite Suit" , "Steel Suit" ,
138 "Force Field" , "Armor of Light" , "Mythril Vest" , "DemiGod Armor" ,
139 "Hades' Cloak" , "Dragon Scales" , "Adamantium" };
141 int prices
[ WNA
- 1 ] = { 200 , 1000 , 3000 , 10000 , 30000 , 100000 , 150000 , 200000 , 400000 ,
142 1000000 , 4000000 , 10000000 , 40000000 , 100000000 , 400000000 };
143 int webonus
[ WNA
] = { 1 , 10 , 15 , 25 , 35 , 45 , 65 , 85 , 125 , 185 , 255 , 355 , 505 , 805 , 1205 , 1805 };
144 int arbonus
[ WNA
] = { 1 , 2 , 4 , 10 , 15 , 25 , 35 , 50 , 75 , 100 , 150 , 225 , 300 , 400 , 600 , 1000 };
146 int hpbonus
[ 11 ] = { 10 , 15 , 20 , 30 , 50 , 75 , 125 , 185 , 250 , 350 , 550 };
147 int strbonus
[ 11 ] = { 5 , 7 , 10 , 12 , 20 , 35 , 50 , 75 , 110 , 150 , 200 };
148 int defbonus
[ 11 ] = { 2 , 3 , 5 , 10 , 15 , 22 , 35 , 60 , 80 , 120 , 150 };
150 void gameserv ( char * source
, char * buf
)
153 cmd
= strtok ( buf
, " " );
156 source
++; // Get rid of that : at the beginning of a :Nick privmsg Gameserv :text
161 cmd
++; // Get rid of that : at the beginning of the :text (command)
164 log ( "Source: %s Command: %s " , source
, cmd
);
172 int curday
= tm
-> tm_mday
;
178 save_day (); // here i come to save the day!
181 if ( strnicmp ( cmd
, "\1PING" , 6 ) == 0 )
184 ts
= strtok ( NULL
, "\1" );
185 notice ( s_GameServ
, source
, "\1PING %s \1" , ts
);
186 } else if ( stricmp ( cmd
, "\1VERSION\1" ) == 0 ) {
187 notice ( s_GameServ
, source
, "\1VERSION %s %s \1" , PACKAGE
, VERSION
);
188 } else if ( stricmp ( cmd
, "SEARCH" ) == 0 ) {
189 cmd
= strtok ( NULL
, " " );
192 notice ( s_GameServ
, source
, "SYNTAX: /msg %S SEARCH FOREST" );
196 } else if ( stricmp ( cmd
, "FIGHT" ) == 0 ) {
198 } else if ( stricmp ( cmd
, "ATTACK" ) == 0 ) {
200 } else if ( stricmp ( cmd
, "RUN" ) == 0 ) {
202 } else if ( stricmp ( cmd
, "USE" ) == 0 ) {
204 } else if ( stricmp ( cmd
, "HEAL" ) == 0 ) {
206 } else if ( stricmp ( cmd
, "INVENTORY" ) == 0 ) {
207 do_inventory ( source
);
208 } else if ( stricmp ( cmd
, "MASTER" ) == 0 ) {
210 } else if ( stricmp ( cmd
, "STORE" ) == 0 ) {
212 } else if ( stricmp ( cmd
, "BANK" ) == 0 ) {
214 } else if ( stricmp ( cmd
, "ADMIN" ) == 0 ) {
216 } else if ( stricmp ( cmd
, "REFRESH" ) == 0 ) {
218 } else if ( stricmp ( cmd
, "RESET" ) == 0 ) {
220 } else if ( stricmp ( cmd
, "TAVERN" ) == 0 ) {
222 } else if ( stricmp ( cmd
, "LIST" ) == 0 ) {
224 } else if ( stricmp ( cmd
, "LOGOUT" ) == 0 ) {
226 } else if ( stricmp ( cmd
, "REGISTER" ) == 0 ) {
228 } else if ( stricmp ( cmd
, "IDENTIFY" ) == 0 ) {
230 } else if ( stricmp ( cmd
, "HELP" ) == 0 ) {
232 } else if ( stricmp ( cmd
, "STATS" ) == 0 ) {
234 } else if ( stricmp ( cmd
, "SHUTDOWN" ) == 0 ) {
237 if (!( user
= find ( source
)))
239 notice ( s_GameServ
, source
, "Error: aClient not found. Contact a %S admin" );
240 log ( "Error: aClient not found: %s " , source
);
242 else if (! isAdmin ( user
))
244 notice ( s_GameServ
, source
, "You must be a %S admin to use this command!" );
250 raw ( "[] SQ %s 0 :leaving: %s used the Shutdown command." , servername
, user
-> getRealNick ());
252 raw ( "SQUIT %s :leaving: %s used the Shutdown command." , servername
, source
);
256 } else if ( stricmp ( cmd
, "SAVE" ) == 0 ) {
259 if (!( user
= find ( source
)))
261 notice ( s_GameServ
, source
, "Error: aClient not found. Contact a %S admin" );
262 log ( "Error: aClient not found: %s " , source
);
264 else if (! isAdmin ( user
))
266 notice ( s_GameServ
, source
, "You must be a %S admin to use this command!" );
272 } else if ( stricmp ( cmd
, "LOAD" ) == 0 ) {
275 if (!( user
= find ( source
)))
277 notice ( s_GameServ
, source
, "Error: aClient not found. Contact a %S admin" );
278 log ( "Error: aClient not found: %s " , source
);
280 else if (! isAdmin ( user
))
282 notice ( s_GameServ
, source
, "You must be a %S admin to use this command!" );
286 char * cmd2
= strtok ( NULL
, " " );
289 notice ( s_GameServ
, source
, "Loading player data from %s " , playerdata
);
292 else if ( stricmp ( cmd2
, "MONSTERS" ) == 0 )
294 notice ( s_GameServ
, source
, "Loading monster data from %s " , monsterdata
);
298 display_help ( source
, cmd
);
301 } else if ( stricmp ( cmd
, "RAW" ) == 0 ) {
304 if (!( user
= find ( source
)))
306 notice ( s_GameServ
, source
, "Error: aClient not found. Contact a %S admin" );
307 log ( "Error: aClient not found: %s " , source
);
309 else if (! isAdmin ( user
))
311 notice ( s_GameServ
, source
, "You must be a %S admin to use this command!" );
315 char * rest
= strtok ( NULL
, "" );
321 if (( user
= find ( source
)))
326 log ( "Ignoring %s ." , user
-> getNick ());
331 notice ( s_GameServ
, source
, "Unknown command \002 %s \002 . Type /msg %S \002 HELP \002 to get a list of commands." , cmd
);
337 source
--; // Bring the ':' back so we don't leak memory
340 cmd
--; // Same thing :)
343 int stricmp ( const char * s1
, const char * s2
)
347 while (( c
= tolower (* s1
)) == tolower (* s2
)) {
353 if ( c
< tolower (* s2
))
358 void showstats ( const char * u
, const char * nick
)
360 aClient
* ni
, * sender
= find ( u
);
366 if (!( ni
= findplayer ( nick
)))
368 notice ( s_GameServ
, u
, " %s not found" , nick
);
372 notice ( s_GameServ
, sender
-> getNick (), "Stats for %s :" , ni
-> stats
-> name
);
374 sprintf ( buf
, "Experience: %l d" , ni
-> stats
-> exp
);
375 space
= spaces ( strlen ( buf
), " " );
376 notice ( s_GameServ
, sender
-> getNick (), " %s%s Level: %d " , buf
, space
,
380 sprintf ( buf
, "Gold: %l d" , ni
-> stats
-> gold
);
381 space
= spaces ( strlen ( buf
), " " );
382 notice ( s_GameServ
, sender
-> getNick (), " %s%s Gold in Bank: %l d" , buf
, space
, ni
-> stats
-> bank
);
385 notice ( s_GameServ
, sender
-> getNick (), "Hit Points: %d of %d " , ni
-> stats
-> hp
,
388 sprintf ( buf
, "Strength: %d " , ni
-> stats
-> strength
+ webonus
[ ni
-> stats
-> weapon
]);
389 space
= spaces ( strlen ( buf
), " " );
390 notice ( s_GameServ
, sender
-> getNick (), " %s%s Defense: %d " ,
391 buf
, space
, ni
-> stats
-> defense
+ arbonus
[ ni
-> stats
-> armor
]);
394 sprintf ( buf
, "Armor: %s " , armors
[ ni
-> stats
-> armor
]);
395 space
= spaces ( strlen ( buf
), " " );
396 notice ( s_GameServ
, sender
-> getNick (), " %s%s Weapon: %s " , buf
, space
,
397 weapons
[ ni
-> stats
-> weapon
]);
400 sprintf ( buf
, "Forest Fights: %d " , ni
-> stats
-> forest_fights
);
401 space
= spaces ( strlen ( buf
), " " );
402 notice ( s_GameServ
, sender
-> getNick (), " %s%s Player Fights: %d " , buf
, space
, ni
-> stats
-> player_fights
);
407 notice ( s_GameServ
, u
, " %s is not playing!" , ni
-> stats
-> name
);
412 char * spaces ( int len
, char * seperator
)
415 final
= new char [ 30 ];
417 strcpy ( final
, seperator
);
418 for ( y
= 0 ; y
< 30 - len
; y
++)
419 strcat ( final
, seperator
);
423 void raw ( const char * fmt
, ...)
428 input
= new char [ 1024 ];
430 memset ( input
, 0 , sizeof ( input
)); // Initialize to NULL
436 case 'd' : sprintf ( input
, " %s%d " , input
, va_arg ( args
, int )); break ;
437 case 's' : sprintf ( input
, " %s%s " , input
, va_arg ( args
, char *)); break ;
438 case 'S' : sprintf ( input
, " %s%s " , input
, s_GameServ
); break ;
441 sprintf ( input
, " %s%l d" , input
, va_arg ( args
, long int )); break ;
446 sprintf ( input
, " %s%c " , input
, * t
);
451 log ( "Input: %s " , input
);
454 sprintf ( input
, " %s%s " , input
, " \r\n " );
455 sock_puts ( sock
, input
);
459 /* Send a NOTICE from the given source to the given nick. */
461 void notice ( const char * source
, const char * dest
, const char * fmt
, ...)
467 commanduse
= new char [ 16 ];
471 strcpy ( commanduse
, "P" );
473 strcpy ( commanduse
, "N" );
477 strcpy ( commanduse
, "PRIVMSG" );
479 strcpy ( commanduse
, "NOTICE" );
485 input
= new char [ 1024 ];
492 sprintf ( input
, ": %s %s %s :" , source
, commanduse
, dest
);
494 sprintf ( input
, " %s %s %s :" , gsnum
, commanduse
, dest
);
502 sprintf ( input
, ": %s %s %s :" , source
, commanduse
, dest
);
504 sprintf ( input
, " %s %s %s :" , gsnum
, commanduse
, dest
);
513 case 'd' : sprintf ( input
, " %s%d " , input
, va_arg ( args
, int )); break ;
514 case 's' : sprintf ( input
, " %s%s " , input
, va_arg ( args
, char *)); break ;
515 case 'S' : sprintf ( input
, " %s%s " , input
, s_GameServ
); break ;
518 sprintf ( input
, " %s%l d" , input
, va_arg ( args
, long int )); break ;
523 sprintf ( input
, " %s%c " , input
, * t
);
528 log ( "Input: %s " , input
);
530 sprintf ( input
, " %s%s " , input
, " \r\n " );
531 sock_puts ( sock
, input
);
532 delete [] commanduse
;
538 int strnicmp ( const char * s1
, const char * s2
, size_t len
)
544 while (( c
= tolower (* s1
)) == tolower (* s2
) && len
> 0 ) {
545 if ( c
== 0 || -- len
== 0 )
550 if ( c
< tolower (* s2
))
556 char * strtok ( char * str
, const char * delim
)
558 static char * current
= NULL
;
565 current
+= strspn ( current
, delim
);
566 ret
= * current
? current
: NULL
;
567 current
+= strcspn ( current
, delim
);
576 void do_list ( char * u
)
579 if (!( user
= find ( u
)))
581 log ( "Fatal Error: Couldn't find %s in the client list" , u
);
584 else if ( isIgnore ( user
))
587 log ( "Ignoring %s . Command LIST" , user
-> getNick ());
592 ListNode
< aClient
> * temp
;
594 for ( unsigned long x
= 0 ; x
< U_TABLE_SIZE
; x
++)
596 temp
= players
[ x
]. First ();
597 if (! players
[ x
]. isEmpty ())
601 notice ( s_GameServ
, u
, "People Playing:" );
607 notice ( s_GameServ
, u
, "IRC: %s Game: %s " , temp
-> getData ()-> getRealNick (),
608 temp
-> getData ()-> stats
-> name
);
610 notice ( s_GameServ
, u
, "IRC: %s Game: %s " , temp
-> getData ()-> getNick (),
611 temp
-> getData ()-> stats
-> name
);
619 notice ( s_GameServ
, u
, "No one is playing" );
621 notice ( s_GameServ
, u
, "End of List" );
625 void do_logout ( char * u
)
628 if (!( user
= find ( u
)))
630 notice ( s_GameServ
, u
, "Fatal error. Cannot find aClient. " \
631 "Buf: %s LOGOUT" , u
);
632 log ( "Could not find aClient Buf: %s LOGOUT" ,
635 else if ( isIgnore ( user
))
638 log ( "Ignoring %s ." , user
-> getNick ());
642 else if (! is_playing ( user
))
644 notice ( s_GameServ
, u
, "You're not logged in!" );
646 else if ( is_fighting ( user
))
648 notice ( s_GameServ
, u
, "You can't logout while fighting!" );
652 notice ( s_GameServ
, u
, "You have left the fields. You have lived to kill another day!" );
657 void logout ( aClient
* user
)
659 if ( is_playing ( user
))
661 ListNode
< aClient
> * it
;
663 unsigned long hv
= iHASH (( unsigned char *) user
-> stats
-> name
);
664 it
= players
[ hv
]. Find ( user
);
668 notice ( s_GameServ
, user
-> getNick (), "Fatal error. Contact " \
669 " %S Admin. Cannot find you in the players list." );
670 log ( "Error on logout(). Can't find %s in the players list" ,
681 temp
-> stats
= new Player
;
682 temp
-> stats
-> setData ( user
-> stats
);
683 user
-> stats
-> client
= NULL
;
685 if ( player_fight ( user
))
686 user
-> stats
-> battle
-> stats
-> battle
= NULL
;
690 temp
-> stats
-> client
= NULL
;
692 temp
-> setRealNick ( "Not Playing" );
694 temp
-> setNick ( "Not Playing" );
698 log ( "Logged out player %s " ,
710 void do_register ( char * u
)
712 char * password
, * name
;
714 name
= strtok ( NULL
, " " );
715 password
= strtok ( NULL
, " " );
717 static char saltChars
[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./" ;
720 salt
[ 0 ] = saltChars
[ rand () % strlen ( saltChars
)];
721 salt
[ 1 ] = saltChars
[ rand () % strlen ( saltChars
)];
726 notice ( s_GameServ
, u
, "SYNTAX: /msg %S REGISTER NAME PASSWORD" );
730 notice ( s_GameServ
, u
, "SYNTAX: /msg %S REGISTER NAME PASSWORD" );
732 else if (( user
= findplayer ( name
)))
734 notice ( s_GameServ
, u
, " %s is already registered!" , name
);
735 notice ( s_GameServ
, u
, "Choose another name!" );
737 else if (!( user
= find ( u
)))
739 log ( "Fatal Error: Couldn't find %s in the clients list" , u
);
741 else if ( isIgnore ( user
))
744 log ( "Ignoring %s ." , user
-> getNick ());
750 if (! is_playing ( user
))
752 ListNode
< aClient
> * temp
;
753 user
-> stats
= new Player ( user
);
754 user
-> stats
-> client
= user
; // Set the backwards pointer
755 user
-> stats
-> reset (); // set the user up
756 strncpy ( user
-> stats
-> password
, crypt ( password
, salt
), 255 );
757 strncpy ( user
-> stats
-> name
, name
, 255 );
758 unsigned long hv
= iHASH (( unsigned char *) name
);
759 updateTS ( user
-> stats
);
760 temp
= players
[ hv
]. insertAtBack_RLN ( user
);
761 temp
-> setPtr ( user
); // This is an extra step, but necessary for now
763 notice ( s_GameServ
, u
, "Player %s registered with password %s ." , user
-> stats
-> name
, password
);
764 notice ( s_GameServ
, u
, "Write this password down. If you lose it, there is no way to retrieve it!" );
765 log ( "Nickname %s registered player %s ." , u
, user
-> stats
-> name
);
766 setPlaying ( user
); // set the playing flag
770 notice ( s_GameServ
, u
, "Already registered. Contact a %S admin for help." );
775 void do_identify ( char * u
)
777 char * password
, * name
;
779 name
= strtok ( NULL
, " " );
780 password
= strtok ( NULL
, " " );
781 if (! password
|| ! name
)
783 notice ( s_GameServ
, u
, "SYNTAX: /msg %S IDENTIFY NAME PASSWORD" );
785 else if (!( user
= find ( u
)))
787 notice ( s_GameServ
, u
, "Fatal error. Cannot find aClient. Buf: %s " , strtok ( NULL
, "" ));
788 log ( "Error: aClient not found: %s " , u
);
790 else if ( isIgnore ( user
))
793 log ( "Ignoring %s ." , user
-> getNick ());
797 else if (!( p
= findplayer ( name
)) || ! p
-> stats
)
798 notice ( s_GameServ
, u
, "Player %s not found" , name
);
799 else if ( is_playing ( user
))
801 notice ( s_GameServ
, u
, "You are already playing!" );
803 else if ( p
-> stats
-> client
!= NULL
&& ! isAdmin ( user
))
805 notice ( s_GameServ
, u
, "That player has already identified." );
807 else if (! check_password ( name
, password
) && ! isAdmin ( user
))
809 notice ( s_GameServ
, u
, "Password incorrect" );
812 ListNode
< aClient
> * temp
;
813 unsigned long hv
= iHASH (( unsigned char *) p
-> stats
-> name
);
814 temp
= players
[ hv
]. Find ( p
);
817 notice ( s_GameServ
, u
, "Fatal error. Contact %S Admin. Buf: %s " ,
821 user
-> stats
= new Player ( p
-> stats
-> name
);
823 log ( "Setting data for identified" );
825 user
-> stats
-> setData ( p
-> stats
);
826 user
-> stats
-> client
= user
;
827 updateTS ( user
-> stats
);
831 log ( "Player %s IRC: %s Identified" , user
-> stats
-> name
,
835 setPlaying ( user
); // set the playing flag
838 notice ( s_GameServ
, u
, "Password Accepted. Identified." );
842 void do_stats ( char * u
)
847 nick
= strtok ( NULL
, " " );
849 if (!( user
= find ( u
)))
851 log ( "Fatal Error: %s not found in client list" , u
);
854 else if ( isIgnore ( user
))
857 log ( "Ignoring %s ." , user
-> getNick ());
863 if (! is_playing ( user
))
865 notice ( s_GameServ
, u
, "You're not playing, so you have no stats!" );
870 updateTS ( user
-> stats
);
871 showstats ( u
, user
-> stats
-> name
);
881 log ( "Calling delete_masters()" );
887 log ( "Initializing masters" );
890 for ( int x
= 0 ; x
< LEVELS
; x
++)
891 masters
[ x
] = new Monster
;
893 strcpy ( masters
[ 0 ]-> name
, "Old Bones" );
894 strcpy ( masters
[ 0 ]-> weapon
, "Dull Sword Cane" );
895 masters
[ 0 ]-> strength
= 25 ;
896 masters
[ 0 ]-> gold
= 0 ;
898 masters
[ 0 ]-> maxhp
= 30 ;
900 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!" );
902 strcpy ( masters
[ 1 ]-> name
, "Master Chang" );
903 strcpy ( masters
[ 1 ]-> weapon
, "Nanchaku" );
904 masters
[ 1 ]-> strength
= 35 ;
905 masters
[ 1 ]-> gold
= 0 ;
907 masters
[ 1 ]-> maxhp
= 40 ;
909 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." );
911 strcpy ( masters
[ 2 ]-> name
, "Chuck Norris" );
912 strcpy ( masters
[ 2 ]-> weapon
, "Ranger Kick" );
913 masters
[ 2 ]-> strength
= 95 ;
914 masters
[ 2 ]-> gold
= 0 ;
916 masters
[ 2 ]-> maxhp
= 70 ;
918 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!" );
921 strcpy ( masters
[ 3 ]-> name
, "Mr. Miagi" );
922 strcpy ( masters
[ 3 ]-> weapon
, "Petrified Bonsai" );
923 masters
[ 3 ]-> strength
= 130 ;
924 masters
[ 3 ]-> gold
= 0 ;
926 masters
[ 3 ]-> maxhp
= 120 ;
927 masters
[ 3 ]-> hp
= 120 ;
928 strcpy ( masters
[ 3 ]-> death
, "Skill comes from repeating the correct but seemingly mundane actions. Wax ON, wax OFF!" );
930 strcpy ( masters
[ 4 ]-> name
, "Jackie Chan" );
931 strcpy ( masters
[ 4 ]-> weapon
, "Kung Fu Kick" );
932 masters
[ 4 ]-> strength
= 145 ;
933 masters
[ 4 ]-> gold
= 0 ;
935 masters
[ 4 ]-> maxhp
= 200 ;
936 masters
[ 4 ]-> hp
= 200 ;
937 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!" );
939 strcpy ( masters
[ 5 ]-> name
, "Jet Li" );
940 strcpy ( masters
[ 5 ]-> weapon
, "Motorcycle" );
941 masters
[ 5 ]-> strength
= 170 ;
942 masters
[ 5 ]-> gold
= 0 ;
944 masters
[ 5 ]-> maxhp
= 400 ;
945 masters
[ 5 ]-> hp
= 400 ;
946 strcpy ( masters
[ 5 ]-> death
, "Failure is a fuel for excuses. It's the doing the do, that makes the making." );
949 strcpy ( masters
[ 6 ]-> name
, "Muhammad Ali" );
950 strcpy ( masters
[ 6 ]-> weapon
, "Quick Jab" );
951 masters
[ 6 ]-> strength
= 195 ;
952 masters
[ 6 ]-> gold
= 0 ;
954 masters
[ 6 ]-> maxhp
= 600 ;
955 masters
[ 6 ]-> hp
= 600 ;
956 strcpy ( masters
[ 6 ]-> death
, "It's just a job. Grass grows, birds fly, waves pound the sand. I beat people up." );
958 strcpy ( masters
[ 7 ]-> name
, "Li Mu Bai" );
959 strcpy ( masters
[ 7 ]-> weapon
, "Green Destiny" );
960 masters
[ 7 ]-> strength
= 220 ;
961 masters
[ 7 ]-> gold
= 0 ;
963 masters
[ 7 ]-> maxhp
= 800 ;
964 masters
[ 7 ]-> hp
= 800 ;
965 strcpy ( masters
[ 7 ]-> death
, "No growth without resistance. No action without reaction. No desire without restraint." );
968 strcpy ( masters
[ 8 ]-> name
, "Jimmy Wang Yu" );
969 strcpy ( masters
[ 8 ]-> weapon
, "Flying Guillotine" );
970 masters
[ 8 ]-> strength
= 285 ;
971 masters
[ 8 ]-> gold
= 0 ;
973 masters
[ 8 ]-> maxhp
= 1200 ;
974 masters
[ 8 ]-> hp
= 1200 ;
975 strcpy ( masters
[ 8 ]-> death
, "You have beaten the one armed boxer. Proceed with caution!" );
977 strcpy ( masters
[ 9 ]-> name
, "Wong Fei Hung" );
978 strcpy ( masters
[ 9 ]-> weapon
, "Drunken Boxing" );
979 masters
[ 9 ]-> strength
= 375 ;
980 masters
[ 9 ]-> gold
= 0 ;
982 masters
[ 9 ]-> maxhp
= 1800 ;
983 masters
[ 9 ]-> hp
= 1800 ;
984 strcpy ( masters
[ 9 ]-> death
, "Hiccup! Monkey drinks master's wine!" );
986 strcpy ( masters
[ 10 ]-> name
, "Bruce Lee" );
987 strcpy ( masters
[ 10 ]-> weapon
, "Fists of fury" );
988 masters
[ 10 ]-> strength
= 590 ;
989 masters
[ 10 ]-> gold
= 0 ;
990 masters
[ 10 ]-> exp
= 0 ;
991 masters
[ 10 ]-> maxhp
= 2500 ;
992 masters
[ 10 ]-> hp
= 2500 ;
993 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." );
999 log ( "Calling delete_monsters" );
1004 for ( int x
= 0 ; x
< LEVELS
; x
++)
1005 for ( int y
= 0 ; y
< MONSTERS
; y
++)
1006 monsters
[ x
][ y
] = new Monster ();
1009 void delete_monsters ()
1011 for ( int x
= 0 ; x
< LEVELS
; x
++)
1012 for ( int y
= 0 ; y
< MONSTERS
; y
++)
1014 delete monsters
[ x
][ y
];
1017 void delete_masters ()
1019 for ( int x
= 0 ; x
< LEVELS
; x
++)
1024 void display_monster ( char * u
)
1028 aClient
* user
= find ( u
);
1029 Player
* ni
= user
-> stats
;
1031 notice ( s_GameServ
, u
, "Your Hitpoints: \ 2 %d \ 2 ", ni
-> hp
);
1032 notice ( s_GameServ
, u
, " %s 's Hitpoints: \ 2 %d \ 2 ", ni
-> fight
-> name
, ni
-> fight
-> hp
);
1033 notice ( s_GameServ
, u
, "Here are your commands:" );
1034 notice ( s_GameServ
, u
, "/msg %S attack" );
1035 notice ( s_GameServ
, u
, "/msg %S run" );
1036 notice ( s_GameServ
, u
, "What will you do?" );
1040 void display_players ( char * u
)
1043 if (!( user
= find ( u
)))
1045 log ( "Fatal error in display_players(): Couldn't find %s " , u
);
1048 display_players ( user
);
1051 void display_players ( aClient
* user
)
1053 char * u
= user
-> getNick ();
1054 if ( is_playing ( user
) && player_fight ( user
))
1056 aClient
* battle
= user
-> stats
-> battle
;
1057 notice ( s_GameServ
, u
, "Your Hitpoints: \ 2 %d \ 2 ", user
-> stats
-> hp
);
1058 notice ( s_GameServ
, u
, " %s 's Hitpoints: \ 2 %d \ 2 ", battle
-> stats
-> name
, battle
-> stats
-> hp
);
1059 notice ( s_GameServ
, u
, "Here are your commands:" );
1060 notice ( s_GameServ
, u
, "/msg %S attack" );
1061 notice ( s_GameServ
, u
, "/msg %S run" );
1062 notice ( s_GameServ
, u
, "What will you do?" );
1067 bool is_playing ( char * u
)
1070 if (!( user
= find ( u
)))
1073 return is_playing ( user
);
1076 bool is_playing ( aClient
* user
)
1078 if ( user
-> stats
== NULL
)
1082 else if ( user
-> stats
-> client
== NULL
)
1086 else if (! FL_is_playing ( user
))
1094 bool is_fighting ( char * u
)
1098 if (!( user
= find ( u
)))
1101 return is_fighting ( user
);
1104 bool is_fighting ( aClient
* user
)
1106 if (! is_playing ( user
))
1109 return player_fight ( user
) || master_fight ( user
) || user
-> stats
-> fight
!= NULL
;
1112 bool player_fight ( char * u
)
1116 if (!( user
= find ( u
)))
1119 return player_fight ( user
);
1122 bool player_fight ( aClient
* user
)
1124 if (! is_playing ( user
))
1127 return user
-> stats
-> battle
!= NULL
;
1130 bool master_fight ( char * u
)
1134 if (!( user
= find ( u
)))
1137 return master_fight ( user
);
1140 bool master_fight ( aClient
* user
)
1142 if (! is_playing ( user
))
1145 return user
-> stats
-> master
!= NULL
;
1148 void do_fight ( char * u
)
1150 aClient
* ni
, * battle
;
1152 char * nick
= strtok ( NULL
, " " );
1156 notice ( s_GameServ
, u
, "SYNTAX: /msg %S FIGHT PLAYER" );
1159 else if (!( ni
= find ( u
)))
1161 notice ( s_GameServ
, u
, "Fatal error. Contact a(n) %S admin. buf: %s " , strtok ( NULL
, "" ));
1164 else if ( isIgnore ( ni
))
1167 log ( "Ignoring %s ." , ni
-> getNick ());
1171 else if (! is_playing ( ni
))
1173 notice ( s_GameServ
, u
, "You are not playing!" );
1177 updateTS ( ni
-> stats
);
1179 if ( ni
-> stats
-> player_fights
<= 0 )
1181 ni
-> stats
-> player_fights
= 0 ; // just to be safe
1182 notice ( s_GameServ
, u
, "You are out of player fights for the " \
1183 "day. You have to wait until tomorrow!" );
1185 else if (!( battle
= findplayer ( nick
)))
1187 notice ( s_GameServ
, u
, "Player %s not found!" , nick
);
1189 else if (! isAlive ( ni
-> stats
))
1191 notice ( s_GameServ
, u
, "You are dead. Wait until tomorrow to fight others!" );
1193 else if (! is_playing ( battle
))
1195 notice ( s_GameServ
, u
, "You can't attack %s while they aren't playing!" , nick
);
1198 * Offline fighting not implemented yet.
1199 * else if (!(fight = finduser(nick)))
1201 * ni->stats->battle = battle;
1202 * battle->battle = ni;
1204 * battle->yourturn = 0;
1205 * notice(s_GameServ, u, "You decide to fight %s while they're not online!",
1206 * battle->stats->name);
1207 * display_players(u);
1210 else if ( stricmp ( ni
-> stats
-> name
, battle
-> stats
-> name
) == 0 )
1212 notice ( s_GameServ
, u
, "Are you trying to commit suicide!?" );
1214 else if (! isAlive ( battle
-> stats
))
1216 notice ( s_GameServ
, u
, "They are dead. Cannot fight dead players!" );
1218 else if ( player_fight ( battle
))
1220 notice ( s_GameServ
, u
, " %s is fighting %s already!" , battle
-> stats
-> name
, battle
-> stats
-> battle
-> stats
-> name
);
1222 else if ( master_fight ( battle
))
1224 notice ( s_GameServ
, u
, " %s is fighting their master!" , battle
-> stats
-> name
);
1226 else if ( is_fighting ( battle
))
1228 notice ( s_GameServ
, u
, " %s is fighting %s already!" , battle
-> stats
-> name
, battle
-> stats
-> fight
-> name
);
1230 else if ( ni
-> stats
-> level
- battle
-> stats
-> level
> maxbfightdistance
)
1232 // You can't fight someone below you by more than X level(s)
1233 // level 12 can fight level (12 - X) but not < (12 - X)
1234 notice ( s_GameServ
, u
, "You may not fight %s . You're too strong!" ,
1235 battle
-> stats
-> name
);
1237 else if ( battle
-> stats
-> level
- ni
-> stats
-> level
> maxafightdistance
)
1239 // You can't fight someone above you by more than X level(S)
1240 // level 1 can fight level (1 + X), but not > (1 + X)
1241 notice ( s_GameServ
, u
, " %s , do you really have a death wish? Try the forest you " \
1242 "weakling!" , ni
-> stats
-> name
);
1246 // Set your battle pointer to the other player
1247 ni
-> stats
-> battle
= battle
;
1249 // Set the other player's battle pointer to you
1250 ni
-> stats
-> battle
-> stats
-> battle
= ni
;
1252 // The initiator gets the first move (perhaps this should be 50/50)
1253 setYourTurn ( ni
-> stats
);
1254 clearYourTurn ( battle
-> stats
);
1256 // Initiate Battle sequence!
1257 ni
-> stats
-> player_fights
-= 1 ;
1259 notice ( s_GameServ
, u
, "You challenge %s to an online duel!" , battle
-> stats
-> name
);
1260 notice ( s_GameServ
, battle
-> getNick (), " %s has challenged you to an online duel!" , ni
-> stats
-> name
);
1261 notice ( s_GameServ
, battle
-> getNick (), " %s gets to go first " \
1262 "because they initiated!" , ni
-> stats
-> name
);
1263 notice ( s_GameServ
, battle
-> getNick (), "Please wait while %s decides what to do." , ni
-> stats
-> name
);
1264 display_players ( ni
);
1268 void do_use ( char * u
)
1273 char * item
= strtok ( NULL
, " " );
1277 notice ( s_GameServ
, u
, "SYNTAX: USE ITEM" );
1278 notice ( s_GameServ
, u
, "Type /msg %S HELP USE for more information." );
1281 else if (!( user
= find ( u
)))
1283 notice ( s_GameServ
, u
, "Fatal Error in do_use. Contact a(n) %S Admin" );
1286 else if ( isIgnore ( user
))
1289 log ( "Ignoring %s ." , user
-> getNick ());
1293 else if (! is_playing ( user
))
1295 notice ( s_GameServ
, u
, "You must be playing to use items!" );
1299 updateTS ( user
-> stats
);
1301 p
= & user
-> stats
-> inventory
;
1303 if ( stricmp ( item
, "HEALTH" ) == 0 )
1305 if ( p
-> Healing () <= 0 )
1307 notice ( s_GameServ
, u
, "You are out of Health Potions!" );
1310 int oldhealth
= user
-> stats
-> hp
;
1311 notice ( s_GameServ
, u
, "You hastiliy gulp down the flask of cool life-giving waters." );
1312 notice ( s_GameServ
, u
, "Rejuvination spreads throughout your body." );
1313 user
-> stats
-> hp
+= ( 10 * user
-> stats
-> level
) + ( rand () % 10 ) * user
-> stats
-> level
;
1314 notice ( s_GameServ
, u
, "You gain %d HP!" , user
-> stats
-> hp
- oldhealth
);
1317 else if ( stricmp ( item
, "STRENGTH" ) == 0 )
1319 if ( p
-> Strength () <= 0 )
1321 notice ( s_GameServ
, u
, "You are out of Strength Potions!" );
1324 int oldstrength
= user
-> stats
-> strength
;
1325 notice ( s_GameServ
, u
, "As you grip the flask containing pure power, you feel adrenaline coarse through your veins!" );
1326 notice ( s_GameServ
, u
, "In one swallow you drink the potion and feel your muscle fibers bulging andgrowing!" );
1327 user
-> stats
-> strength
+= 1 + ( rand () % 10 >= 8 ? 1 : 0 ); // 1-2
1328 notice ( s_GameServ
, u
, "You gain %d Strength points!" , user
-> stats
-> strength
- oldstrength
);
1331 else if ( stricmp ( item
, "DEFENSE" ) == 0 )
1333 if ( p
-> Defense () <= 0 )
1335 notice ( s_GameServ
, u
, "You are out of Defense Potions!" );
1338 int olddefense
= user
-> stats
-> defense
;
1339 notice ( s_GameServ
, u
, "You drink the foul tasting viscous liquid while pinching your nose in disgust." );
1340 notice ( s_GameServ
, u
, "It tasted bad, but you feel like you are unbeatable!" );
1341 user
-> stats
-> defense
+= 1 + ( rand () % 10 >= 8 ? 1 : 0 ); // 1-2
1342 notice ( s_GameServ
, u
, "You gain %d Defense points!" , user
-> stats
-> defense
- olddefense
);
1345 else if ( stricmp ( item
, "HP" ) == 0 )
1349 notice ( s_GameServ
, u
, "You are out of HP Potions!" );
1352 int oldHP
= user
-> stats
-> maxhp
;
1353 notice ( s_GameServ
, u
, "You feel your life growing longer as you drink the green glowing liquid." );
1354 user
-> stats
-> maxhp
+= 4 +
1355 ( rand () % 100 > 50 ? ( rand () % 6 ) : ( rand () % 2 ) );
1357 notice ( s_GameServ
, u
, "You gain %d Maximum hit points!" , user
-> stats
-> maxhp
- oldHP
);
1362 notice ( s_GameServ
, u
, "SYNTAX: /msg %S USE {HEALTH | STRENGTH | DEFENSE}" );
1366 end_turn ( user
); // If they're fighting, end their turn
1368 void do_run ( char * u
)
1371 Player
* p
, * p2
= NULL
;
1373 if (!( user
= find ( u
)))
1375 notice ( s_GameServ
, u
, "Couldn't find you. Error. Contact a %S admin" );
1378 else if ( isIgnore ( user
))
1381 log ( "Ignoring %s ." , user
-> getNick ());
1385 else if (! is_playing ( user
))
1387 notice ( s_GameServ
, u
, "You must be playing to run!" );
1391 updateTS ( user
-> stats
);
1395 p2
= p
-> battle
-> stats
;
1397 if (! is_fighting ( user
))
1398 notice ( s_GameServ
, u
, "You run in place... try fighting next time." );
1399 else if (! player_fight ( user
) && ! master_fight ( user
))
1401 notice ( s_GameServ
, u
, "You run away from \ 2 %s \ 2 like a little baby!", p
-> fight
-> name
);
1405 else if ( player_fight ( user
) && isYourTurn ( p
))
1407 notice ( s_GameServ
, u
, "You run away from \ 2 %s \ 2 like a little baby!", p2
-> name
);
1408 notice ( s_GameServ
, p
-> battle
-> getNick (), "\ 2 %s \ 2 ran away from you like a little baby!", p
-> name
);
1411 else if ( player_fight ( user
) && ! isYourTurn ( p
))
1413 notice ( s_GameServ
, u
, "It is not your turn. Please wait until \ 2 %s \ 2 decides what to do.", p2
-> name
);
1415 else if ( master_fight ( user
))
1417 notice ( s_GameServ
, u
, "You cannot run from \ 2 %s \ 2 ! FIGHT!", p
-> master
-> name
);
1422 void end_turn ( aClient
* user
)
1424 char * nick
, * u
= user
-> getNick ();
1429 nick
= new char [ strlen ( user
-> getNick ()) + 1 ];
1431 if (! user
|| ! is_playing ( user
) || ! is_fighting ( user
))
1434 if (! player_fight ( user
) && ! master_fight ( user
))
1435 fight
= user
-> stats
-> fight
;
1437 fight
= user
-> stats
-> master
;
1438 battle
= user
-> stats
-> battle
;
1440 if (! player_fight ( user
))
1443 mhit
= ( fight
-> strength
/ 2 ) +
1444 ( rand () % ( fight
-> strength
/ 2 ) - ( user
-> stats
-> defense
+
1445 arbonus
[ user
-> stats
-> armor
]));
1450 mhit
= ((( battle
-> stats
-> strength
+ webonus
[ battle
-> stats
-> weapon
]) / 2 ) +
1451 ( rand () % (( battle
-> stats
-> strength
+ webonus
[ battle
-> stats
-> weapon
])) / 2 ) -
1452 ( user
-> stats
-> defense
+ arbonus
[ user
-> stats
-> armor
]));
1454 if (! player_fight ( user
))
1459 notice ( s_GameServ
, u
, "\1f %s \1f attacks with their \1f %s \1f for \ 2 %d \ 2 damage!",
1460 fight
-> name
, fight
-> weapon
, mhit
);
1463 notice ( s_GameServ
, u
, " %s completely misses you!" , fight
-> name
);
1465 if ( mhit
>= user
-> stats
-> hp
)
1467 if (! master_fight ( user
))
1469 notice ( s_GameServ
, u
, "You have been \ 2 \1f killed\1f \ 2 by %s !" , fight
-> name
);
1470 notice ( s_GameServ
, u
, "You lose all gold on hand and lose 10 percent " \
1471 "of your experience!" );
1472 user
-> stats
-> gold
= 0 ;
1473 user
-> stats
-> exp
-= ( long int )( user
-> stats
-> exp
* .10 );
1474 user
-> stats
-> fight
= NULL
;
1475 clearAlive ( user
-> stats
);
1480 notice ( s_GameServ
, u
, " %s has bested you! You will have to wait " \
1481 "until tomorrow to try again" , user
-> stats
-> master
-> name
);
1482 user
-> stats
-> fight
= NULL
;
1483 user
-> stats
-> master
= NULL
;
1490 user
-> stats
-> hp
-= mhit
;
1497 clearYourTurn ( user
-> stats
);
1498 setYourTurn ( battle
-> stats
);
1499 display_players ( battle
);
1505 void do_attack ( char * u
)
1508 aClient
* ni
, * battle
; // The player and perhaps the player they're fighting
1509 Monster
* fight
; // The monster they may be fighting
1511 if (!( ni
= find ( u
)))
1513 notice ( s_GameServ
, u
, "Fatal error in do_attack. Contact a(n) %S admin for help." );
1516 else if ( isIgnore ( ni
))
1519 log ( "Ignoring %s ." , ni
-> getNick ());
1523 else if (! is_playing ( ni
))
1525 notice ( s_GameServ
, u
, "You're not playing!" );
1528 else if (! is_fighting ( ni
))
1530 notice ( s_GameServ
, u
, "You're not in battle!" );
1535 if (! ni
-> stats
-> master
) // This is not a master fight
1536 fight
= ni
-> stats
-> fight
; // Monster Could be NULL
1537 else // This IS a master fight
1538 fight
= ni
-> stats
-> master
; // Master Could be NULL
1540 battle
= ni
-> stats
-> battle
; // Player Could be NULL
1542 // One has to be !NULL based on the previous else if
1543 // We wouldn't be here if they were all NULL
1545 updateTS ( ni
-> stats
);
1547 if (! player_fight ( ni
))
1550 hit
= (( ni
-> stats
-> strength
+ webonus
[ ni
-> stats
-> weapon
]) / 2 ) +
1551 ( rand () % (( ni
-> stats
-> strength
+ webonus
[ ni
-> stats
-> weapon
]) / 2 ));
1554 mhit
= ( fight
-> strength
/ 2 ) +
1555 ( rand () % ( fight
-> strength
/ 2 ) - ( ni
-> stats
-> defense
+
1556 arbonus
[ ni
-> stats
-> armor
]));
1561 mhit
= ((( battle
-> stats
-> strength
+ webonus
[ battle
-> stats
-> weapon
]) / 2 ) +
1562 ( rand () % (( battle
-> stats
-> strength
+ webonus
[ battle
-> stats
-> weapon
])) / 2 ) -
1563 ( ni
-> stats
-> defense
+ arbonus
[ ni
-> stats
-> armor
]));
1566 hit
= ((( ni
-> stats
-> strength
+ webonus
[ ni
-> stats
-> weapon
]) / 2 ) +
1567 ( rand () % (( ni
-> stats
-> strength
+ webonus
[ ni
-> stats
-> weapon
])) / 2 ) -
1568 ( battle
-> stats
-> defense
+ arbonus
[ battle
-> stats
-> armor
]));
1571 if (! player_fight ( ni
))
1574 notice ( s_GameServ
, u
, "You attack \1f %s \1f for \ 2 %d \ 2 points!", fight
-> name
, hit
);
1576 notice ( s_GameServ
, u
, "You miss \1f %s \1f completely!", fight
-> name
);
1578 if ( hit
>= fight
-> hp
)
1580 if ( master_fight ( ni
))
1581 notice ( s_GameServ
, u
, "You have bested %s !" , fight
-> name
);
1583 notice ( s_GameServ
, u
, "You have killed \ 2 %s \ 2 !", fight
-> name
);
1585 notice ( s_GameServ
, u
, " %s " , fight
-> death
);
1586 notice ( s_GameServ
, u
, "You recieve \ 2 %d \ 2 experience and \ 2 %d \ 2 gold!",
1587 fight
-> exp
, fight
-> gold
);
1589 // If your new experience (or gold) will be greater than 2 billion,
1590 // then set your exp to 2bil. (2 billion max)... otherwise add them.
1591 // This could be a problem with overflowing out of the sign bit.
1592 // Unsigned long int maybe? Leave it for now.
1593 ni
-> stats
-> exp
= ( ( ni
-> stats
-> exp
+ fight
-> exp
) > 2000000000 ? 2000000000 :
1594 ni
-> stats
-> exp
+ fight
-> exp
);
1596 ni
-> stats
-> gold
= ( ni
-> stats
-> gold
+ fight
-> gold
> 2000000000 ? 2000000000 :
1597 ni
-> stats
-> gold
+ fight
-> gold
);
1600 if ( master_fight ( ni
))
1602 notice ( s_GameServ
, u
, "You are now level %d !" , ni
-> stats
-> level
+ 1 );
1603 notice ( s_GameServ
, u
, "You gain %d Strength, and %d Defense points!" ,
1604 strbonus
[ ni
-> stats
-> level
- 1 ], defbonus
[ ni
-> stats
-> level
- 1 ]);
1606 // Increase your level
1609 // Increase your maximum hit points
1610 ni
-> stats
-> maxhp
+= hpbonus
[ ni
-> stats
-> level
- 1 ];
1612 // Heal the player by setting hp to their max
1613 ni
-> stats
-> hp
= ni
-> stats
-> maxhp
;
1615 // Add to your strength
1616 ni
-> stats
-> strength
+= strbonus
[ ni
-> stats
-> level
- 1 ];
1618 // Add to your defensive power
1619 ni
-> stats
-> defense
+= defbonus
[ ni
-> stats
-> level
- 1 ];
1621 // Clear the pointer for your master
1622 ni
-> stats
-> master
= NULL
;
1625 // They're dead so remove the pointer
1626 delete ni
-> stats
-> fight
;
1627 ni
-> stats
-> fight
= NULL
;
1628 ni
-> stats
-> master
= NULL
;
1638 notice ( s_GameServ
, u
, "\1f %s \1f attacks with their \1f %s \1f for \ 2 %d \ 2 damage!",
1639 fight
-> name
, fight
-> weapon
, mhit
);
1642 notice ( s_GameServ
, u
, " %s completely misses you!" , fight
-> name
);
1644 if ( mhit
>= ni
-> stats
-> hp
)
1646 if (! master_fight ( ni
))
1648 notice ( s_GameServ
, u
, "You have been \ 2 \1f killed\1f \ 2 by %s !" , fight
-> name
);
1649 notice ( s_GameServ
, u
, "You lose all gold on hand and lose 10 percent " \
1650 "of your experience!" );
1651 ni
-> stats
-> gold
= 0 ;
1652 ni
-> stats
-> exp
-= ( long int )( ni
-> stats
-> exp
* .10 );
1653 ni
-> stats
-> fight
= NULL
;
1654 clearAlive ( ni
-> stats
);
1659 notice ( s_GameServ
, u
, " %s has bested you! You will have to wait " \
1660 "until tomorrow to try again" , ni
-> stats
-> master
-> name
);
1661 ni
-> stats
-> fight
= NULL
;
1662 ni
-> stats
-> master
= NULL
;
1669 ni
-> stats
-> hp
-= mhit
;
1675 else if ( player_fight ( ni
))
1677 /* Offline fighting not available yet
1678 if (!(online = finduser(ni->stats->battle->nick)) || !nick_identified(online))
1681 notice(s_GameServ, u, "You attack \1f %s\1f for \ 2 %d\ 2 points!", battle->nick, hit);
1683 notice(s_GameServ, u, "You miss \1f %s\1f completely!", battle->nick);
1684 if (hit >= battle->stats->hp)
1686 notice(s_GameServ, u, "You have killed \ 2 %s\ 2 !", battle->nick);
1687 * notice(s_GameServ, u, "You recieve \ 2 %d\ 2 experience and \ 2 %ld\ 2 gold!",
1688 (long int)(battle->stats->exp * .10), battle->stats->gold);
1689 if (2000000000 - ni->stats->exp > (long int)(battle->stats->exp * .10))
1691 ni->stats->exp += (long int)(battle->stats->exp * .10);
1692 battle->stats->exp -= (long int)(battle->stats->exp * .10);
1696 battle->stats->exp -= (long int)(battle->stats->exp * .10);
1697 ni->stats->exp = 2000000000;
1700 if (2000000000 - ni->stats->gold > battle->stats->gold)
1702 * ni->stats->gold += battle->stats->gold;
1703 battle->stats->gold = 0;
1707 battle->stats->gold = 2000000000 - ni->stats->gold;
1708 ni->stats->gold = 2000000000;
1710 * ni->stats->battle->stats->alive = 0;
1711 ni->stats->battle->battle = NULL;
1712 ni->stats->battle = NULL;
1718 * battle->stats->hp -= hit;
1721 notice(s_GameServ, u, "\1f %s\1f hits you with their \1f %s\1f for \ 2 %d\ 2 damage!",
1722 battle->nick, weapons[battle->stats->weapon], mhit);
1725 notice(s_GameServ, u, "%s completely misses you!", battle->nick);
1727 if (mhit >= ni->stats->hp)
1729 notice(s_GameServ, u, "You have been \ 2 \1f killed\1f \ 2 by %s!", battle->nick);
1730 if (2000000000 - battle->stats->gold > ni->stats->gold)
1732 notice(s_GameServ, u, "%s took all your gold!", battle->nick);
1733 battle->stats->gold += ni->stats->gold;
1734 * ni->stats->gold = 0;
1738 notice(s_GameServ, u, "You're lucky, %s couldn't carry all your gold.",
1740 ni->stats->gold -= (2000000000 - battle->stats->gold);
1741 notice(s_GameServ, u, "You were left dead with %d gold.",
1742 * (long int)ni->stats->gold);
1743 battle->stats->gold = 2000000000;
1745 ni->stats->battle->battle = NULL;
1746 ni->stats->battle = NULL;
1747 ni->stats->alive = 0;
1753 ni->stats->hp -= mhit;
1759 * end offline fighting */
1761 if ( is_playing ( battle
))
1763 if (! isYourTurn ( ni
-> stats
))
1765 notice ( s_GameServ
, u
, "Please wait until %s decides what to do!" ,
1766 battle
-> stats
-> name
);
1771 notice ( s_GameServ
, u
, "You attack \1f %s \1f for \ 2 %d \ 2 points!", battle
-> stats
-> name
, hit
);
1773 notice ( s_GameServ
, battle
-> getNick (), " %s has hit you with their %s for " \
1774 "\ 2 %d \ 2 damage!", ni
-> stats
-> name
,
1775 weapons
[ ni
-> stats
-> weapon
], hit
);
1776 clearYourTurn ( ni
-> stats
);
1777 setYourTurn ( battle
-> stats
);
1778 display_players ( battle
);
1782 notice ( s_GameServ
, u
, "You miss \1f %s \1f completely!", battle
-> stats
-> name
);
1783 notice ( s_GameServ
, battle
-> getNick (), " %s misses you completely!" , ni
-> stats
-> name
);
1784 clearYourTurn ( ni
-> stats
);
1785 setYourTurn ( battle
-> stats
);
1786 display_players ( battle
);
1788 if ( hit
>= battle
-> stats
-> hp
)
1790 notice ( s_GameServ
, u
, "You have killed \ 2 %s \ 2 !", battle
-> stats
-> name
);
1791 notice ( s_GameServ
, u
, "You recieve \ 2 %d \ 2 experience and \ 2 %l d\ 2 gold!" ,
1792 ( long int )( battle
-> stats
-> exp
* .10 ), battle
-> stats
-> gold
);
1793 notice ( s_GameServ
, battle
-> getNick (), "You have been killed by \ 2 %s \ 2 !",
1795 battle
-> stats
-> hp
= 0 ;
1796 clearAlive ( battle
-> stats
);
1798 if ( 2000000000 - ni
-> stats
-> exp
> ( long int )( battle
-> stats
-> exp
* .10 ))
1800 ni
-> stats
-> exp
+= ( long int )( battle
-> stats
-> exp
* .10 );
1801 battle
-> stats
-> exp
-= ( long int )( battle
-> stats
-> exp
* .10 );
1805 battle
-> stats
-> exp
-= ( long int )( battle
-> stats
-> exp
* .10 );
1806 ni
-> stats
-> exp
= 2000000000 ;
1809 if ( 2000000000 - ni
-> stats
-> gold
> battle
-> stats
-> gold
)
1811 notice ( s_GameServ
, battle
-> getNick (), "You lose ten percent of experience and " \
1812 "all gold on hand!" );
1813 ni
-> stats
-> gold
+= battle
-> stats
-> gold
;
1814 battle
-> stats
-> gold
= 0 ;
1818 battle
-> stats
-> gold
= 2000000000 - ni
-> stats
-> gold
;
1819 notice ( s_GameServ
, battle
-> getNick (), "You lose ten percent of your experience!" );
1821 notice ( s_GameServ
, battle
-> getNick (), "However, %s could not carry all of your " \
1822 "gold." , ni
-> stats
-> name
);
1824 notice ( s_GameServ
, battle
-> getNick (), "Luckily, you still have \ 2 %l d\ 2 gold " \
1825 "left. All is not lost!" , battle
-> stats
-> gold
);
1827 ni
-> stats
-> gold
= 2000000000 ;
1829 battle
-> stats
-> battle
= NULL
;
1830 ni
-> stats
-> battle
= NULL
;
1836 battle
-> stats
-> hp
-= hit
;
1837 clearYourTurn ( ni
-> stats
);
1838 setYourTurn ( battle
-> stats
);
1839 notice ( s_GameServ
, u
, "Please wait while %s decides what to do!" ,
1840 battle
-> stats
-> name
);
1848 void do_heal ( char * u
)
1851 char * amount
= strtok ( NULL
, " " );
1856 notice ( s_GameServ
, u
, "SYNTAX: /msg %S HEAL {ALL | #}" );
1859 else if (!( ni
= find ( u
)))
1861 notice ( s_GameServ
, u
, "Fatal error. Contact a(n) %S admin. buf: %s " , strtok ( NULL
, "" ));
1864 else if ( isIgnore ( ni
))
1867 log ( "Ignoring %s ." , ni
-> getNick ());
1871 else if (! is_playing ( ni
))
1873 notice ( s_GameServ
, u
, "You aren't playing!" );
1876 else if (! isAlive ( ni
-> stats
))
1878 notice ( s_GameServ
, u
, "You are dead. Wait until tomorrow for healing." );
1881 else if ( is_fighting ( ni
))
1883 notice ( s_GameServ
, u
, "You can't heal in battle!" );
1886 else if ( ni
-> stats
-> hp
>= ni
-> stats
-> maxhp
)
1888 notice ( s_GameServ
, u
, "You don't need healing!" );
1892 updateTS ( ni
-> stats
);
1893 if ( stricmp ( amount
, "ALL" ) == 0 )
1895 price
= ni
-> stats
-> level
* 3 ;
1896 if ( ni
-> stats
-> gold
< ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
) * price
)
1898 notice ( s_GameServ
, u
, "Healing \ 2 %d \ 2 points for \ 2 %d \ 2 gold per point.",
1899 ( long int ) ni
-> stats
-> gold
/ price
, price
);
1900 ni
-> stats
-> hp
+= ni
-> stats
-> gold
/ price
;
1901 ni
-> stats
-> gold
%= price
;
1905 notice ( s_GameServ
, u
, "Healing all possible points at \ 2 %d \ 2 gold "\
1906 "per point." , price
);
1907 notice ( s_GameServ
, u
, "\ 2 %d \ 2 points healed for \ 2 %l d\ 2 gold. HP at MAX!" ,
1908 ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
),
1909 ( price
* ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
)) );
1910 ni
-> stats
-> gold
-= price
* ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
);
1911 ni
-> stats
-> hp
= ni
-> stats
-> maxhp
;
1914 else if ( isstringnum ( amount
))
1916 num
= stringtoint ( amount
);
1917 price
= ni
-> stats
-> level
* 3 ;
1918 if ( ni
-> stats
-> gold
< price
* num
)
1920 notice ( s_GameServ
, u
, "You only have enough gold to heal \ 2 %d \ 2 points!",
1921 ( long int ) ni
-> stats
-> gold
/ price
);
1923 else if ( num
<= ni
-> stats
-> maxhp
- ni
-> stats
-> hp
)
1925 notice ( s_GameServ
, u
, "Healing \ 2 %d \ 2 points at \ 2 %d \ 2 gold per point.",
1927 ni
-> stats
-> hp
+= num
;
1928 ni
-> stats
-> gold
-= num
* price
;
1930 else if ( num
> ni
-> stats
-> maxhp
- ni
-> stats
-> hp
)
1932 notice ( s_GameServ
, u
, "Healing all possible points at \ 2 %d \ 2 gold "\
1933 "per point." , price
);
1934 notice ( s_GameServ
, u
, "\ 2 %d \ 2 points healed. HP at MAX!",
1935 ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
));
1936 ni
-> stats
-> gold
-= price
* ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
);
1937 ni
-> stats
-> hp
= ni
-> stats
-> maxhp
;
1940 else if ( amount
[ 0 ] == '-' )
1941 notice ( s_GameServ
, u
, "You trying to cheat?" );
1943 notice ( s_GameServ
, u
, "SYNTAX: /msg %S HEAL {ALL | #}" );
1946 int isstringnum ( char * num
)
1949 for ( x
= 0 ; x
< strlen ( num
); x
++)
1951 if (( int ) num
[ x
] < 48 || ( int ) num
[ x
] > 57 )
1957 long int stringtoint ( char * number
)
1959 long int x
, len
= strlen ( number
), sum
= 0 ;
1961 return chartoint ( number
[ 0 ]);
1962 sum
+= chartoint ( number
[ len
- 1 ]);
1963 for ( x
= len
- 2 ; x
>= 0 ; x
--)
1964 sum
+= chartoint ( number
[ x
]) * pow ( 10 , abs ( x
- len
+ 1 ));
1968 long int pow ( int x
, int y
)
1974 if ( x
!= 0 && y
!= 0 )
1976 for ( count
= 1 ; count
<= y
- 1 ; count
++)
1984 long int chartoint ( char ch
)
1986 if ( int ( ch
) >= 48 && int ( ch
) <= 57 )
1987 return int ( ch
) - 48 ;
1994 ListNode
< aClient
> * ptr
;
1998 outfile
. open ( playerdata
);
2002 log ( "Error opening %s " , playerdata
);
2006 for ( unsigned long x
= 0 ; x
< U_TABLE_SIZE
; x
++)
2008 ptr
= players
[ x
]. First ();
2011 it
= ptr
-> getData ()-> stats
;
2013 outfile
<< it
-> name
<< ' ' << it
-> level
<< ' ' << it
-> exp
<< ' ' << it
-> gold
<< ' ' << it
-> bank
<< ' '
2014 << it
-> hp
<< ' ' << it
-> maxhp
<< ' ' << it
-> strength
<< ' ' << it
-> defense
<< ' '
2015 << it
-> armor
<< ' ' << it
-> weapon
<< ' '
2016 << it
-> forest_fights
<< ' ' << it
-> player_fights
<< ' '
2017 << it
-> getFlags () << ' ' << it
-> password
<< ' ' << it
-> inventory
. Healing ()
2018 << ' ' << it
-> inventory
. Strength () << ' ' << it
-> inventory
. Defense () << ' ' << it
-> inventory
. HP () << endl
;
2031 char * tempname
, * buf
, * password
;
2032 buf
= new char [ 1023 ];
2034 infile
. open ( playerdata
);
2038 log ( "Error opening %s " , playerdata
);
2042 while ( infile
. getline ( buf
, 1024 , ' \n ' ))
2045 tempname
= strtok ( buf
, " " );
2046 temp
-> stats
= new Player ( tempname
);
2049 p
-> level
= stringtoint ( strtok ( NULL
, " " ));
2050 p
-> exp
= stringtoint ( strtok ( NULL
, " " ));
2051 p
-> gold
= stringtoint ( strtok ( NULL
, " " ));
2052 p
-> bank
= stringtoint ( strtok ( NULL
, " " ));
2053 p
-> hp
= stringtoint ( strtok ( NULL
, " " ));
2054 p
-> maxhp
= stringtoint ( strtok ( NULL
, " " ));
2055 p
-> strength
= stringtoint ( strtok ( NULL
, " " ));
2056 p
-> defense
= stringtoint ( strtok ( NULL
, " " ));
2057 p
-> armor
= stringtoint ( strtok ( NULL
, " " ));
2058 p
-> weapon
= stringtoint ( strtok ( NULL
, " " ));
2059 p
-> forest_fights
= stringtoint ( strtok ( NULL
, " " ));
2060 p
-> player_fights
= stringtoint ( strtok ( NULL
, " " ));
2061 p
-> setFlags ( stringtoint ( strtok ( NULL
, " " )));
2063 password
= strtok ( NULL
, " " );
2064 strcpy ( p
-> password
, password
);
2065 temp
-> setNick ( "Not Playing" );
2067 temp
-> setRealNick ( "Not Playing" );
2070 p
-> inventory
. reset (); // Set inventory to all 0s
2071 // Old player databases didn't have these three extra values
2072 // If they come up null, leave them to 0 as the default.
2073 // On the next gameserv database save, it will save the values.
2074 tempname
= strtok ( NULL
, " " );
2076 p
-> inventory
. setHealing ( stringtoint ( tempname
));
2078 tempname
= strtok ( NULL
, " " );
2080 p
-> inventory
. setStrength ( stringtoint ( tempname
));
2082 tempname
= strtok ( NULL
, " " );
2084 p
-> inventory
. setDefense ( stringtoint ( tempname
));
2086 tempname
= strtok ( NULL
, " " );
2088 p
-> inventory
. setHP ( stringtoint ( tempname
));
2089 unsigned long hv
= iHASH (( unsigned char *) temp
-> stats
-> name
);
2091 temp
-> stats
-> client
= NULL
;
2092 players
[ hv
]. insertAtBack ( temp
);
2100 bool passcmp ( char * encrypted
, char * plaintext
)
2103 char * plaintext2
, * plainToencrypt
;
2106 plaintext2
= new char [ strlen ( encrypted
) + strlen ( plaintext
)]; // Extra
2107 strcpy ( plaintext2
, plaintext
);
2109 salt
[ 0 ] = encrypted
[ 0 ];
2110 salt
[ 1 ] = encrypted
[ 1 ];
2113 plainToencrypt
= crypt ( plaintext2
, salt
);
2115 same
= ( strcmp (( const char *) encrypted
, plainToencrypt
) == 0 ? true : false );
2117 delete [] plaintext2
;
2122 bool check_password ( char * name
, char * plaintext
)
2126 if (!( client
= findplayer ( name
)))
2130 return passcmp ( client
-> stats
-> password
, plaintext
);
2134 void do_store ( char * u
)
2136 char * cmd
= strtok ( NULL
, " " );
2137 char * item
= strtok ( NULL
, " " );
2138 char * num
= strtok ( NULL
, " " );
2146 notice ( s_GameServ
, u
, "SYNTAX: STORE LIST {ARMOR | WEAPONS}" );
2147 notice ( s_GameServ
, u
, " \ 2 STORE SELL {ARMOR | WEAPON}\ 2 " );
2148 notice ( s_GameServ
, u
, " \ 2 STORE BUY {ARMOR | WEAPON} \1f NUMBER\1f \ 2 " );
2151 else if (!( user
= find ( u
)))
2153 log ( "Fatal Error: could not find %s in client list" , u
);
2156 else if ( isIgnore ( user
))
2159 log ( "Ignoring %s ." , user
-> getNick ());
2163 else if (! is_playing ( user
))
2165 notice ( s_GameServ
, u
, "You must be playing to use the store!" );
2168 else if (! isAlive ( user
-> stats
))
2170 notice ( s_GameServ
, u
, "You are dead. Wait until tomorrow to purchase weapons and armor!" );
2173 updateTS ( user
-> stats
);
2175 if ( stricmp ( cmd
, "LIST" ) == 0 )
2177 if ( stricmp ( item
, "WEAPONS" ) == 0 )
2179 notice ( s_GameServ
, u
, "Welcome to Kain's Armory" );
2180 notice ( s_GameServ
, u
, "Here are the weapons we have available for the killing, sire:" );
2181 for ( int x
= 1 ; x
< WNA
; x
++)
2183 space
= spaces ( strlen ( weapons
[ x
]), "." );
2184 notice ( s_GameServ
, u
, " %s%d . %s%s%d " ,( x
< 10 ? " " : "" ), x
, weapons
[ x
], space
, prices
[ x
- 1 ]);
2187 notice ( s_GameServ
, u
, "To purchase a weapon, type /msg %S STORE BUY \ 2 NUM\ 2 ." );
2188 notice ( s_GameServ
, u
, "Where num. is the weapon number from the menu above." );
2191 else if ( stricmp ( item
, "ARMOR" ) == 0 )
2193 notice ( s_GameServ
, u
, "Welcome to Kain's Armory" );
2194 notice ( s_GameServ
, u
, "I hope you enjoy the fine armor we have available for your protection:" );
2195 for ( int x
= 1 ; x
< WNA
; x
++)
2197 space
= spaces ( strlen ( armors
[ x
]), "." );
2198 notice ( s_GameServ
, u
, " %s%d . %s%s%d " ,( x
< 10 ? " " : "" ), x
, armors
[ x
], space
, prices
[ x
- 1 ]);
2201 notice ( s_GameServ
, u
, "To purchase armor, type /msg %S store buy armor num." );
2202 notice ( s_GameServ
, u
, "Where num. is the armor number from the menu above." );
2206 } else if ( stricmp ( cmd
, "BUY" ) == 0 ) {
2209 notice ( s_GameServ
, u
, "SYNTAX: \ 2 STORE BUY {ARMOR | WEAPON} \1f NUMBER\1f \ 2 " );
2212 else if (! isstringnum ( num
))
2214 notice ( s_GameServ
, u
, "You must specify a number between 1 and %d . Not %s !" , WNA
- 1 , num
);
2217 if ( stricmp ( item
, "WEAPON" ) == 0 )
2219 wep
= stringtoint ( num
);
2220 if ( wep
>= WNA
|| wep
< 1 )
2222 notice ( s_GameServ
, u
, "The number %d is out of range. The number you provide must be between 1 and %d ." , wep
, WNA
- 1 );
2229 notice ( s_GameServ
, u
, "You have to sell your %s first!" , weapons
[ p
-> weapon
]);
2230 else if ( p
-> gold
< prices
[ wep
- 1 ])
2231 notice ( s_GameServ
, u
, "You don't have enough gold for %s !" , weapons
[ wep
]);
2234 notice ( s_GameServ
, u
, "You have purchased %s ! Thanks for the gold!" , weapons
[ wep
]);
2236 p
-> gold
-= prices
[ wep
- 1 ];
2239 else if ( stricmp ( item
, "ARMOR" ) == 0 )
2241 wep
= stringtoint ( num
);
2242 if ( wep
>= WNA
|| wep
< 1 )
2244 notice ( s_GameServ
, u
, "The number %d is out of range. The number you provide must be between 1 and %d ." , wep
, WNA
- 1 );
2251 notice ( s_GameServ
, u
, "You have to sell your %s first!" , armors
[ p
-> armor
]);
2252 else if ( p
-> gold
< prices
[ wep
- 1 ])
2253 notice ( s_GameServ
, u
, "You don't have enough gold for %s !" , armors
[ wep
]);
2256 notice ( s_GameServ
, u
, "You have purchased %s ! Thanks for the gold!" , armors
[ wep
]);
2258 p
-> gold
-= prices
[ wep
- 1 ];
2262 else if ( stricmp ( cmd
, "SELL" ) == 0 )
2266 if ( stricmp ( item
, "WEAPON" ) == 0 )
2270 notice ( s_GameServ
, u
, "You want me to chop off your hands?" );
2273 else if ( p
-> gold
== 2000000000 )
2275 notice ( s_GameServ
, u
, "You have enough gold. I'll just take that off your hands, sire." );
2278 else if ( 2000000000 - p
-> gold
< ( prices
[ p
-> weapon
- 1 ] / 2 ))
2280 notice ( s_GameServ
, u
, "Thank you for your business! You now have as much gold as you can carry." );
2281 notice ( s_GameServ
, u
, "However, you have no weapon... can I interest you in the %s ?" , weapons
[ WNA
- 1 ]);
2282 p
-> gold
= 2000000000 ;
2287 notice ( s_GameServ
, u
, "Thank you for your business! You now have %d more gold but no weapon!" , ( prices
[ p
-> weapon
- 1 ] / 2 ));
2288 p
-> gold
+= ( prices
[ p
-> weapon
- 1 ] / 2 );
2292 else if ( stricmp ( item
, "ARMOR" ) == 0 )
2298 notice ( s_GameServ
, u
, "I don't think you can be any more naked..." );
2301 if ( p
-> gold
== 2000000000 )
2303 notice ( s_GameServ
, u
, "You have enough gold. I'll just take that off your hands, sire." );
2306 else if ( 2000000000 - p
-> gold
< ( prices
[ p
-> armor
- 1 ] / 2 ))
2308 notice ( s_GameServ
, u
, "Thank you for your business! You now have as much gold as you can carry." );
2309 notice ( s_GameServ
, u
, "However, you have no armor... can I interest you in %s ?" , armors
[ WNA
- 1 ]);
2310 p
-> gold
= 2000000000 ;
2315 notice ( s_GameServ
, u
, "Thank you for your business! You now have %d more gold but no armor!" ,
2316 ( prices
[ p
-> armor
- 1 ] / 2 ));
2318 p
-> gold
+= ( prices
[ p
-> armor
- 1 ] / 2 );
2324 notice ( s_GameServ
, u
, "SYNTAX: STORE LIST {ARMOR | WEAPONS}" );
2325 notice ( s_GameServ
, u
, " \ 2 STORE SELL {ARMOR | WEAPON}\ 2 " );
2326 notice ( s_GameServ
, u
, " \ 2 STORE BUY {ARMOR | WEAPON} \1f NUMBER\1f \ 2 " );
2330 void do_inventory ( char * u
)
2334 if (!( user
= find ( u
)))
2336 notice ( s_GameServ
, u
, "Fatal Error. Contact a %S admin!" );
2339 else if ( isIgnore ( user
))
2342 log ( "Ignoring %s ." , user
-> getNick ());
2346 else if (! is_playing ( user
))
2348 notice ( s_GameServ
, u
, "You must be playing to check your inventory!" );
2351 updateTS ( user
-> stats
);
2352 showinventory ( user
, user
);
2354 void showinventory ( aClient
* from
, aClient
* to
)
2356 char * nick
= to
-> getNick ();
2360 if ( is_playing ( from
))
2362 Pouch
* p
= & from
-> stats
-> inventory
;
2363 notice ( s_GameServ
, nick
, "Inventory for %s :" , from
-> stats
-> name
);
2364 notice ( s_GameServ
, nick
, " Healing Potions: %d " , p
-> Healing ());
2365 notice ( s_GameServ
, nick
, "Strength Potions: %d " , p
-> Strength ());
2366 notice ( s_GameServ
, nick
, " Defense Potions: %d " , p
-> Defense ());
2367 notice ( s_GameServ
, nick
, " HP Potions: %d " , p
-> HP ());
2370 void do_tavern ( char * u
)
2372 char * cmd
= strtok ( NULL
, " " );
2377 if (!( user
= find ( u
)))
2379 notice ( s_GameServ
, u
, "Fatal Error. See a %S admin for help" );
2382 else if ( isIgnore ( user
))
2385 log ( "Ignoring %s ." , user
-> getNick ());
2389 else if (! is_playing ( user
))
2391 notice ( s_GameServ
, u
, "You must be playing to go to the Tavern" );
2394 else if ( is_fighting ( user
))
2396 notice ( s_GameServ
, u
, "You cannot go to the Tavern during a fight!" );
2400 updateTS ( user
-> stats
);
2405 notice ( s_GameServ
, u
, "Welcome to Boot Liquors Mystic Apothecary" );
2406 notice ( s_GameServ
, u
, "Your commands:" );
2407 notice ( s_GameServ
, u
, "/msg %S TAVERN {LIST | BUY} [NUMBER]" );
2408 notice ( s_GameServ
, u
, "What'll it be?" );
2410 else if ( stricmp ( cmd
, "LIST" ) == 0 )
2412 notice ( s_GameServ
, u
, "Here is a list of what we have to offer:" );
2413 notice ( s_GameServ
, u
, "1. Healing Potions for %l d Gold" , 100 * p
-> level
+ ( p
-> exp
/ 10 ));
2414 notice ( s_GameServ
, u
, "2. Strength Potions for %l d Gold" , 205 * p
-> level
+ ( p
-> exp
/ 10 ));
2415 notice ( s_GameServ
, u
, "3. Defense Potions for %l d Gold" , 200 * p
-> level
+ ( p
-> exp
/ 10 ));
2416 notice ( s_GameServ
, u
, "4. HP Potions for %l d Gold" , 230 * p
-> level
+ ( p
-> exp
/ 10 ));
2417 notice ( s_GameServ
, u
, "To buy a potion, type /msg %S TAVERN BUY #" );
2418 notice ( s_GameServ
, u
, "Example: /msg %S TAVERN BUY 1 buys a healing potion!" );
2419 notice ( s_GameServ
, u
, "By something will ya!" );
2421 else if ( stricmp ( cmd
, "BUY" ) == 0 )
2423 char * chnum
= strtok ( NULL
, " " );
2424 int num
= stringtoint ( chnum
);
2428 notice ( s_GameServ
, u
, "SYNTAX: TAVERN BUY #" );
2429 notice ( s_GameServ
, u
, "Example: /msg %S TAVERN BUY 1" );
2432 if ( num
< 1 || num
> 4 )
2434 notice ( s_GameServ
, u
, "Invalid Choice!" );
2435 notice ( s_GameServ
, u
, "Here is a list of what we have to offer:" );
2436 notice ( s_GameServ
, u
, "1. Healing Potions for %l d Gold" , 100 * p
-> level
+ ( p
-> exp
/ 10 ));
2437 notice ( s_GameServ
, u
, "2. Strength Potions for %l d Gold" , 205 * p
-> level
+ ( p
-> exp
/ 10 ));
2438 notice ( s_GameServ
, u
, "3. Defense Potions for %l d Gold" , 200 * p
-> level
+ ( p
-> exp
/ 10 ));
2439 notice ( s_GameServ
, u
, "4. HP Potions for %l d Gold" , 230 * p
-> level
+ ( p
-> exp
/ 10 ));
2440 notice ( s_GameServ
, u
, "To buy a potion, type /msg %S TAVERN BUY #" );
2441 notice ( s_GameServ
, u
, "Example: /msg %S TAVERN BUY 1 buys a healing potion!" );
2447 price
= ( 100 * p
-> level
) + ( p
-> exp
/ 10 );
2448 if ( p
-> gold
>= price
)
2450 notice ( s_GameServ
, u
, "One healing potion coming right up!" );
2451 p
-> inventory
. incHealing ();
2455 notice ( s_GameServ
, u
, "You don't have enough gold!" );
2458 price
= ( 205 * p
-> level
) + ( p
-> exp
/ 10 );
2459 if ( p
-> gold
>= price
)
2461 notice ( s_GameServ
, u
, "One strength boost coming right up!" );
2462 p
-> inventory
. incStrength ();
2466 notice ( s_GameServ
, u
, "You don't have enough gold!" );
2469 price
= ( 200 * p
-> level
) + ( p
-> exp
/ 10 );
2470 if ( p
-> gold
>= price
)
2472 notice ( s_GameServ
, u
, "One defense boost coming right up!" );
2473 p
-> inventory
. incDefense ();
2477 notice ( s_GameServ
, u
, "You don't have enough gold!" );
2480 price
= ( 230 * p
-> level
) + ( p
-> exp
/ 10 );
2481 if ( p
-> gold
>= price
)
2483 notice ( s_GameServ
, u
, "One HP Potion coming right up!" );
2484 p
-> inventory
. incHP ();
2488 notice ( s_GameServ
, u
, "You don't have enough gold!" );
2491 notice ( s_GameServ
, u
, "Logical Error. See a %S admin for help!" );
2497 notice ( s_GameServ
, u
, "Improper Syntax." );
2498 notice ( s_GameServ
, u
, "Type /msg %S HELP TAVERN for help" );
2502 void do_bank ( char * u
)
2504 char * cmd
= strtok ( NULL
, " " );
2505 char * amount
= strtok ( NULL
, " " );
2506 char * nick
= strtok ( NULL
, " " );
2511 if (! cmd
|| (! amount
&& stricmp ( cmd
, "BALANCE" ) != 0 ) || ( stricmp ( cmd
, "TRANSFER" ) == 0 && ! nick
))
2513 notice ( s_GameServ
, u
, "BANK {WITHDRAW | DEPOSIT} {ALL | AMOUNT}" );
2514 notice ( s_GameServ
, u
, "BANK BALANCE" );
2517 else if (!( user
= find ( u
)))
2519 notice ( s_GameServ
, u
, "Fatal Error. Couldn't find your aClient. Contact a(n) %S " \
2521 log ( "Fatal Error. Couldn't find %s while executing do_bank()" , u
);
2524 else if ( isIgnore ( user
))
2527 log ( "Ignoring %s ." , user
-> getNick ());
2531 else if (! is_playing ( user
))
2533 notice ( s_GameServ
, u
, "You must be playing to use the bank!" );
2537 updateTS ( user
-> stats
);
2538 if ( stricmp ( cmd
, "BALANCE" ) == 0 )
2543 else if (! isAlive ( user
-> stats
))
2545 notice ( s_GameServ
, u
, "You are dead. We don't accept gold from dead folk! Wait 'til tomorrow!" );
2548 else if (! isstringnum ( amount
) && stricmp ( amount
, "ALL" ) != 0 )
2550 notice ( s_GameServ
, u
, "I don't know how to convert alphabet letters into currency, sire!" );
2556 if ( stricmp ( cmd
, "DEPOSIT" ) == 0 )
2558 if ( p
-> bank
== 2000000000 )
2560 notice ( s_GameServ
, u
, "Your bank account is full, sire!" );
2563 else if ( stricmp ( amount
, "ALL" ) == 0 )
2565 if ( 2000000000 - p
-> bank
< p
-> gold
)
2567 notice ( s_GameServ
, u
, "You don't have enough room for all of your gold." );
2568 notice ( s_GameServ
, u
, "Depositing %l d gold into your account" , ( 2000000000 - p
-> bank
));
2569 p
-> gold
-= ( 2000000000 - p
-> bank
);
2570 p
-> bank
= 2000000000 ;
2575 notice ( s_GameServ
, u
, "Depositing %l d gold into your account!" , p
-> gold
);
2581 else if ( stringtoint ( amount
) > p
-> gold
)
2583 notice ( s_GameServ
, u
, "Sire, you only have %l d gold!" , p
-> gold
);
2589 if ( 2000000000 - p
-> bank
< stringtoint ( amount
))
2591 notice ( s_GameServ
, u
, "You don't have room in your account for that much." );
2592 notice ( s_GameServ
, u
, "Capping off your account with %l d gold!" , ( 2000000000 - p
-> bank
));
2593 p
-> gold
-= ( 2000000000 - p
-> bank
);
2594 p
-> bank
= 2000000000 ;
2599 notice ( s_GameServ
, u
, "Depositing %d gold into your account!" , stringtoint ( amount
));
2600 p
-> bank
+= stringtoint ( amount
);
2601 p
-> gold
-= stringtoint ( amount
);
2606 else if ( stricmp ( cmd
, "WITHDRAW" ) == 0 )
2608 if ( p
-> gold
== 2000000000 )
2610 notice ( s_GameServ
, u
, "You cannot carry any more gold, sire!" );
2614 else if ( stricmp ( amount
, "ALL" ) == 0 )
2616 if ( 2000000000 - p
-> gold
< p
-> bank
)
2618 notice ( s_GameServ
, u
, "You don't have enough room to carry all that gold." );
2619 notice ( s_GameServ
, u
, "Withdrawing %l d gold from your account" , ( 2000000000 - p
-> gold
));
2620 p
-> bank
-= ( 2000000000 - p
-> gold
);
2621 p
-> gold
= 2000000000 ;
2626 notice ( s_GameServ
, u
, "Withdrawing %l d gold from your account!" , p
-> bank
);
2632 else if ( stringtoint ( amount
) > p
-> bank
)
2634 notice ( s_GameServ
, u
, "Sire, you only have %l d gold in the bank!" , p
-> bank
);
2640 if ( 2000000000 - p
-> gold
< stringtoint ( amount
))
2642 notice ( s_GameServ
, u
, "You don't enough have room to carry that much gold!" );
2643 notice ( s_GameServ
, u
, "You fill your pockets with %l d gold!" ,
2644 ( 2000000000 - p
-> gold
));
2645 p
-> bank
-= ( 2000000000 - p
-> gold
);
2646 p
-> gold
= 2000000000 ;
2651 notice ( s_GameServ
, u
, "Withdrawing %d gold from your account!" , stringtoint ( amount
));
2652 p
-> gold
+= stringtoint ( amount
);
2653 p
-> bank
-= stringtoint ( amount
);
2661 void do_master ( char * u
)
2666 if (!( user
= find ( u
)))
2668 notice ( s_GameServ
, u
, "Fatal error. Contact a(n) %S admin. buf: %s " , strtok ( NULL
, "" ));
2671 else if ( isIgnore ( user
))
2674 log ( "Ignoring %s ." , user
-> getNick ());
2678 else if ( is_fighting ( user
))
2680 notice ( s_GameServ
, u
, "You're in the middle of a fight! Pay attention!" );
2683 else if (! isAlive ( user
-> stats
))
2685 notice ( s_GameServ
, u
, "You're dead. Wait until tomorrow to see your master!" );
2688 else if (! is_playing ( user
))
2690 notice ( s_GameServ
, u
, "You must be playing to see your master!" );
2694 updateTS ( user
-> stats
);
2695 char * cmd
= strtok ( NULL
, " " );
2696 Player
* p
= user
-> stats
;
2701 notice ( s_GameServ
, u
, "You have already seen your master today. Wait until tomorrow to try again" );
2744 notice ( s_GameServ
, u
, "You are at level 12. You are the master. What's left? The DRAGON!" );
2747 need
= p
-> exp
+ 1 ; // Unknown level... don't let them fight a fake master!
2753 notice ( s_GameServ
, u
, "SYNTAX: MASTER {FIGHT | QUESTION}" );
2757 if ( stricmp ( cmd
, "FIGHT" ) == 0 )
2765 notice ( s_GameServ
, u
, "You are not worthy of fighting %s ! You need %l d more experience." , masters
[ p
-> level
- 1 ]-> name
, ( need
- p
-> exp
));
2768 else if ( stricmp ( cmd
, "QUESTION" ) == 0 )
2771 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
);
2773 notice ( s_GameServ
, u
, "You pathetic fool! You are no match for %s , %s !" , masters
[ p
-> level
- 1 ]-> name
, p
-> name
);
2779 notice ( s_GameServ
, u
, "SYNTAX: MASTER {FIGHT | QUESTION}" );
2783 void see_master ( char * u
)
2787 if (!( user
= find ( u
)))
2789 notice ( s_GameServ
, u
, "Fatal error. Contact a(n) %S admin. buf: %s " , strtok ( NULL
, "" ));
2793 if (! is_fighting ( user
) && is_playing ( user
))
2795 Player
* p
= user
-> stats
;
2796 p
-> master
= new Monster ( masters
[ p
-> level
- 1 ]);
2797 p
-> fight
= p
-> master
;
2798 display_monster ( u
); // Since master is the same structure, use this function
2802 void showBankBalance ( const char * u
)
2807 if (!( user
= find ( u
)))
2815 notice ( s_GameServ
, u
, "Account Balance: %l d Gold On hand: %l d" , p
-> bank
, p
-> gold
);
2821 ListNode
< aClient
> * it
;
2823 for ( unsigned long x
= 0 ; x
< U_TABLE_SIZE
; x
++)
2825 it
= players
[ x
]. First ();
2829 p
= it
-> getData ()-> stats
;
2836 void refresh ( Player
* p
)
2841 if ( p
-> hp
< p
-> maxhp
)
2843 p
-> forest_fights
= forestfights
;
2844 p
-> player_fights
= 3 ;
2849 void do_refresh ( char * u
)
2851 char * nick
= strtok ( NULL
, " " );
2854 if (!( user
= find ( u
)))
2856 notice ( s_GameServ
, u
, "Error: aClient not found. Contact a %S admin" );
2857 log ( "Error: aClient not found: %s " , u
);
2860 else if ( isIgnore ( user
))
2863 log ( "Ignoring %s ." , user
-> getNick ());
2867 else if (! isAdmin ( user
))
2869 notice ( s_GameServ
, u
, "You must be a %S admin to use this command!" );
2874 notice ( s_GameServ
, u
, "SYNTAX: REFRESH {ALL | NICK}" );
2877 else if ( stricmp ( nick
, "ALL" ) == 0 )
2879 notice ( s_GameServ
, u
, "Refreshing everyone's stats!" );
2882 else if (( user
= findplayer ( nick
)))
2884 if ( is_playing ( user
))
2887 notice ( s_GameServ
, u
, "Refreshing %s ." , user
-> getRealNick ());
2889 notice ( s_GameServ
, u
, "Refreshing %s ." , user
-> getNick ());
2891 refresh ( user
-> stats
);
2896 notice ( s_GameServ
, u
, " %s is not playing." , user
-> getRealNick ());
2898 notice ( s_GameServ
, u
, " %s is not playing." , user
-> getNick ());
2904 notice ( s_GameServ
, u
, "Nick %s not found." , nick
);
2912 ListNode
< aClient
> * it
;
2915 for ( unsigned long x
= 0 ; x
< U_TABLE_SIZE
; x
++)
2917 it
= players
[ x
]. First ();
2921 p
= it
-> getData ()-> stats
;
2928 void reset ( Player
* p
)
2936 void updateTS ( Player
* p
)
2942 log ( "Old timestamp for %s : %l d" , p
-> name
, p
-> lastcommand
);
2944 p
-> lastcommand
= time ( NULL
);
2946 log ( "New timestamp for %s : %l d" , p
-> name
, p
-> lastcommand
);
2951 bool timedOut ( Player
* p
)
2955 else if ( p
-> lastcommand
== 0 )
2959 if (( time ( NULL
) - p
-> lastcommand
) >= maxidletime
)
2966 void timeOutEvent ( Player
* p
)
2968 aClient
* user
= findplayer ( p
-> name
);
2970 if (! user
|| ! p
-> client
) // then they're not playing
2973 char * nick
= user
-> getNick ();
2975 if ( player_fight ( user
) && isYourTurn ( p
))
2977 // Check to see if they were the idler or if it was the other
2979 if ( p
-> lastcommand
!= p
-> battle
-> stats
-> lastcommand
)
2981 // This person's last command was given earlier,
2982 // so this person is the idler
2983 notice ( s_GameServ
, nick
, "You timed out " \
2984 "during a fight. You lose your turn!" );
2985 notice ( s_GameServ
, p
-> battle
-> getNick (),
2986 " %s hesitated for too long. Your move." , p
-> name
);
2988 setYourTurn ( p
-> battle
-> stats
);
2990 // Update the TS for both players to give them another
2991 // Chance to wake up, but if the other player doesn't
2992 // Attack now, they both get logged out.
2994 p
-> battle
-> stats
-> lastcommand
= p
-> lastcommand
;
2995 display_players ( p
-> battle
);
3000 notice ( s_GameServ
, p
-> battle
-> getNick (),
3001 "You and %s timed out at the same time." \
3002 " Don't fight if you're just going to " \
3003 "sit there!" , p
-> name
);
3004 notice ( s_GameServ
, user
-> getNick (),
3005 "You and %s timed out at the same time." \
3006 " Don't fight if you're just going to " \
3007 "sit there!" , p
-> battle
-> stats
-> name
);
3013 else if (! player_fight ( user
))
3015 // Place fun stuff here :)
3016 int randnum
= 1 + rand () % 100 ; // 1-100
3017 #define GSN(s) notice(s_GameServ, nick, s)
3018 #define GSN2(s, f) notice(s_GameServ, nick, s, f)
3022 // 35-100% of your gold goes pffft - kain
3023 int stolen
= ( 35 + ( rand () % 66 )) * user
-> stats
-> gold
/ 100 ;
3025 GSN ( "You stop for a moment to rest on the " \
3026 "street corner. All of a sudden, you " \
3027 "are ambushed from all sides by a hoarde " \
3028 "of knife wielding thugs." );
3029 GSN2 ( "The thugs beat you into utter submission " \
3030 "and steal %d gold from you!" , stolen
);
3031 user
-> stats
-> gold
-= stolen
;
3033 else if ( randnum
>= 50 && randnum
< 75 )
3035 // 25-65% of your gold goes pffft - kain
3036 int stolen
= ( 25 + ( rand () % 41 )) * user
-> stats
-> gold
/ 100 ;
3037 GSN ( "While dilly dallying around, you lose " \
3038 "your sense of time. Little did you know, " \
3039 "but thieves lifted your gold while you " \
3040 "weren't watching." );
3041 GSN2 ( "Better luck next time... you lose %d gold" , stolen
);
3042 user
-> stats
-> gold
-= stolen
;
3044 else if ( randnum
>= 75 )
3046 // 25-75% of your gold goes pffft - kain
3047 int stolen
= ( 25 + ( rand () % 51 )) * user
-> stats
-> gold
/ 100 ;
3048 GSN ( "Good grief! A gaggle of gooey green ghostlike " \
3049 "goblins grabbed your gold!" );
3050 GSN2 ( "They stole %d gold from you!" , stolen
);
3051 user
-> stats
-> gold
-= stolen
;
3055 // Always log out the user
3060 void do_reset ( char * u
)
3062 char * nick
= strtok ( NULL
, " " );
3065 if (!( user
= find ( u
)))
3067 notice ( s_GameServ
, u
, "Error: aClient not found. Contact a %S admin" );
3068 log ( "Error: aClient not found: %s " , u
);
3071 else if (! isAdmin ( user
))
3073 notice ( s_GameServ
, u
, "You must be a %S admin to use this command!" );
3079 notice ( s_GameServ
, u
, "SYNTAX: RESET {ALL | NICK}" );
3082 else if ( stricmp ( nick
, "ALL" ) == 0 )
3084 notice ( s_GameServ
, u
, "Resetting everyone's stats!" );
3087 else if (( user
= findbyrealnick ( nick
)))
3089 if ( is_playing ( user
))
3092 notice ( s_GameServ
, u
, "Resetting %s ." , user
-> getRealNick ());
3094 notice ( s_GameServ
, u
, "Resetting %s ." , user
-> getNick ());
3101 notice ( s_GameServ
, u
, " %s is not playing." , user
-> getRealNick ());
3103 notice ( s_GameServ
, u
, " %s is not playing." , user
-> getNick ());
3109 notice ( s_GameServ
, u
, "Nick %s not found." , nick
);
3114 void do_help ( char * u
)
3116 char * cmd
= strtok ( NULL
, " " );
3118 display_help ( u
, cmd
);
3121 void display_help ( char * u
, char * file
)
3128 infile
. open ( "helpfiles/help" );
3131 log ( "Error opening helpfiles/help" );
3132 notice ( s_GameServ
, u
, "Error opening helpfiles/help" );
3135 buf
= new char [ 1024 ];
3136 while ( infile
. getline ( buf
, 1024 ))
3138 // Written this way, it will process %S in the helpfiles
3139 // Instead of notice(s_GameServ, u, "%s", buf);
3140 notice ( s_GameServ
, u
, buf
);
3144 aClient
* user
= find ( u
);
3145 if ( user
&& isAdmin ( user
))
3146 display_help ( u
, "admin_commands" );
3151 filename
= new char [ strlen ( file
) + 11 ];
3152 strcpy ( filename
, "helpfiles/" );
3153 strcat ( filename
, file
);
3155 for ( unsigned int x
= 10 ; x
< strlen ( filename
); x
++)
3156 filename
[ x
] = tolower ( filename
[ x
]);
3158 infile
. open ( filename
);
3162 notice ( s_GameServ
, u
, "No help for \ 2 %s \ 2 ", file
);
3165 buf
= new char [ 1024 ];
3166 while ( infile
. getline ( buf
, 1024 ))
3168 // Written this way, it will process %S in the helpfiles
3169 // Instead of notice(s_GameServ, u, "%s", buf);
3170 notice ( s_GameServ
, u
, buf
);
3177 void do_admin ( char * u
)
3180 char * pass
= strtok ( NULL
, " " );
3182 if (!( user
= find ( u
)))
3184 log ( "Error: aClient not found: %s " , u
);
3185 notice ( s_GameServ
, u
, "Error: aClient not found. Contact %S admin." );
3191 notice ( s_GameServ
, u
, "SYNTAX: \ 2 ADMIN\ 2 \ 2 \1f password\1f \ 2 " );
3197 notice ( s_GameServ
, u
, "You already have administrator privledges." );
3200 else if ( strcmp ( pass
, adminpass
) == 0 )
3202 notice ( s_GameServ
, u
, "Password accepted. You now have administrator privledges." );
3205 log ( " %s became an administrator." , user
-> getRealNick ());
3207 log ( " %s became an administrator." , user
-> getNick ());
3212 notice ( s_GameServ
, u
, "Invalid password. Remember: case sensitive" );
3217 bool load_monsters ()
3220 infile
. open ( "monsters.dat" );
3226 log ( "Error opening monsters.dat" );
3230 buf
= new char [ 2048 ];
3233 log ( "Loading monsters from monsters.dat" );
3236 for ( int l
= 0 ; l
< REALLEVELS
; l
++)
3238 for ( int m
= 0 ; m
< MONSTERS
;)
3240 infile
. getline ( buf
, 2048 );
3241 if ( buf
[ 0 ] == ' \n ' || buf
[ 0 ] == '\0' || buf
[ 0 ] == '#' )
3245 strcpy ( monsters
[ l
][ m
]-> name
, strtok ( buf
, "~" ));
3246 strcpy ( monsters
[ l
][ m
]-> weapon
, strtok ( NULL
, "~" ));
3247 monsters
[ l
][ m
]-> strength
= stringtoint ( strtok ( NULL
, "~" ));
3248 monsters
[ l
][ m
]-> gold
= stringtoint ( strtok ( NULL
, "~" ));
3249 monsters
[ l
][ m
]-> exp
= stringtoint ( strtok ( NULL
, "~" ));
3250 monsters
[ l
][ m
]-> maxhp
= stringtoint ( strtok ( NULL
, "~" ));
3251 monsters
[ l
][ m
]-> hp
= monsters
[ l
][ m
]-> maxhp
;
3252 strcpy ( monsters
[ l
][ m
]-> death
, strtok ( NULL
, "" ));
3261 // this will be hash.cpp start
3262 // thank you wcampbel
3263 unsigned long sHASH ( const unsigned char * name
)
3265 unsigned long h
= 0 , g
;
3269 h
= ( h
<< 4 ) + (* name
++); // Case sensitive for numerics
3270 if (( g
= ( h
& 0xF0000000 )))
3274 return h
% U_TABLE_SIZE
;
3277 unsigned long iHASH ( const unsigned char * name
)
3279 unsigned long h
= 0 , g
;
3283 h
= ( h
<< 4 ) + tolower (* name
++);
3284 if (( g
= ( h
& 0xF0000000 )))
3288 return h
% U_TABLE_SIZE
;
3291 // this will be hash.cpp end