]>
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
, ...)
469 input
= new char [ 1024 ];
476 sprintf ( input
, ": %s NOTICE %s :" , source
, dest
);
478 sprintf ( input
, " %s O %s :" , gsnum
, dest
);
486 sprintf ( input
, ": %s NOTICE %s :" , source
, dest
);
488 sprintf ( input
, " %s O %s :" , gsnum
, dest
);
497 case 'd' : sprintf ( input
, " %s%d " , input
, va_arg ( args
, int )); break ;
498 case 's' : sprintf ( input
, " %s%s " , input
, va_arg ( args
, char *)); break ;
499 case 'S' : sprintf ( input
, " %s%s " , input
, s_GameServ
); break ;
502 sprintf ( input
, " %s%l d" , input
, va_arg ( args
, long int )); break ;
507 sprintf ( input
, " %s%c " , input
, * t
);
512 log ( "Input: %s " , input
);
514 sprintf ( input
, " %s%s " , input
, " \r\n " );
515 sock_puts ( sock
, input
);
521 int strnicmp ( const char * s1
, const char * s2
, size_t len
)
527 while (( c
= tolower (* s1
)) == tolower (* s2
) && len
> 0 ) {
528 if ( c
== 0 || -- len
== 0 )
533 if ( c
< tolower (* s2
))
539 char * strtok ( char * str
, const char * delim
)
541 static char * current
= NULL
;
548 current
+= strspn ( current
, delim
);
549 ret
= * current
? current
: NULL
;
550 current
+= strcspn ( current
, delim
);
559 void do_list ( char * u
)
562 if (!( user
= find ( u
)))
564 log ( "Fatal Error: Couldn't find %s in the client list" , u
);
567 else if ( isIgnore ( user
))
570 log ( "Ignoring %s . Command LIST" , user
-> getNick ());
575 ListNode
< aClient
> * temp
;
577 for ( unsigned long x
= 0 ; x
< U_TABLE_SIZE
; x
++)
579 temp
= players
[ x
]. First ();
580 if (! players
[ x
]. isEmpty ())
584 notice ( s_GameServ
, u
, "People Playing:" );
590 notice ( s_GameServ
, u
, "IRC: %s Game: %s " , temp
-> getData ()-> getRealNick (),
591 temp
-> getData ()-> stats
-> name
);
593 notice ( s_GameServ
, u
, "IRC: %s Game: %s " , temp
-> getData ()-> getNick (),
594 temp
-> getData ()-> stats
-> name
);
602 notice ( s_GameServ
, u
, "No one is playing" );
604 notice ( s_GameServ
, u
, "End of List" );
608 void do_logout ( char * u
)
611 if (!( user
= find ( u
)))
613 notice ( s_GameServ
, u
, "Fatal error. Cannot find aClient. " \
614 "Buf: %s LOGOUT" , u
);
615 log ( "Could not find aClient Buf: %s LOGOUT" ,
618 else if ( isIgnore ( user
))
621 log ( "Ignoring %s ." , user
-> getNick ());
625 else if (! is_playing ( user
))
627 notice ( s_GameServ
, u
, "You're not logged in!" );
629 else if ( is_fighting ( user
))
631 notice ( s_GameServ
, u
, "You can't logout while fighting!" );
635 notice ( s_GameServ
, u
, "You have left the fields. You have lived to kill another day!" );
640 void logout ( aClient
* user
)
642 if ( is_playing ( user
))
644 ListNode
< aClient
> * it
;
646 unsigned long hv
= iHASH (( unsigned char *) user
-> stats
-> name
);
647 it
= players
[ hv
]. Find ( user
);
651 notice ( s_GameServ
, user
-> getNick (), "Fatal error. Contact " \
652 " %S Admin. Cannot find you in the players list." );
653 log ( "Error on logout(). Can't find %s in the players list" ,
664 temp
-> stats
= new Player
;
665 temp
-> stats
-> setData ( user
-> stats
);
666 user
-> stats
-> client
= NULL
;
668 if ( player_fight ( user
))
669 user
-> stats
-> battle
-> stats
-> battle
= NULL
;
673 temp
-> stats
-> client
= NULL
;
675 temp
-> setRealNick ( "Not Playing" );
677 temp
-> setNick ( "Not Playing" );
681 log ( "Logged out player %s " ,
693 void do_register ( char * u
)
695 char * password
, * name
;
697 name
= strtok ( NULL
, " " );
698 password
= strtok ( NULL
, " " );
700 static char saltChars
[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./" ;
703 salt
[ 0 ] = saltChars
[ rand () % strlen ( saltChars
)];
704 salt
[ 1 ] = saltChars
[ rand () % strlen ( saltChars
)];
709 notice ( s_GameServ
, u
, "SYNTAX: /msg %S REGISTER NAME PASSWORD" );
713 notice ( s_GameServ
, u
, "SYNTAX: /msg %S REGISTER NAME PASSWORD" );
715 else if (( user
= findplayer ( name
)))
717 notice ( s_GameServ
, u
, " %s is already registered!" , name
);
718 notice ( s_GameServ
, u
, "Choose another name!" );
720 else if (!( user
= find ( u
)))
722 log ( "Fatal Error: Couldn't find %s in the clients list" , u
);
724 else if ( isIgnore ( user
))
727 log ( "Ignoring %s ." , user
-> getNick ());
733 if (! is_playing ( user
))
735 ListNode
< aClient
> * temp
;
736 user
-> stats
= new Player ( user
);
737 user
-> stats
-> client
= user
; // Set the backwards pointer
738 user
-> stats
-> reset (); // set the user up
739 strncpy ( user
-> stats
-> password
, crypt ( password
, salt
), 255 );
740 strncpy ( user
-> stats
-> name
, name
, 255 );
741 unsigned long hv
= iHASH (( unsigned char *) name
);
742 updateTS ( user
-> stats
);
743 temp
= players
[ hv
]. insertAtBack_RLN ( user
);
744 temp
-> setPtr ( user
); // This is an extra step, but necessary for now
746 notice ( s_GameServ
, u
, "Player %s registered with password %s ." , user
-> stats
-> name
, password
);
747 notice ( s_GameServ
, u
, "Write this password down. If you lose it, there is no way to retrieve it!" );
748 log ( "Nickname %s registered player %s ." , u
, user
-> stats
-> name
);
749 setPlaying ( user
); // set the playing flag
753 notice ( s_GameServ
, u
, "Already registered. Contact a %S admin for help." );
758 void do_identify ( char * u
)
760 char * password
, * name
;
762 name
= strtok ( NULL
, " " );
763 password
= strtok ( NULL
, " " );
764 if (! password
|| ! name
)
766 notice ( s_GameServ
, u
, "SYNTAX: /msg %S IDENTIFY NAME PASSWORD" );
768 else if (!( user
= find ( u
)))
770 notice ( s_GameServ
, u
, "Fatal error. Cannot find aClient. Buf: %s " , strtok ( NULL
, "" ));
771 log ( "Error: aClient not found: %s " , u
);
773 else if ( isIgnore ( user
))
776 log ( "Ignoring %s ." , user
-> getNick ());
780 else if (!( p
= findplayer ( name
)) || ! p
-> stats
)
781 notice ( s_GameServ
, u
, "Player %s not found" , name
);
782 else if ( is_playing ( user
))
784 notice ( s_GameServ
, u
, "You are already playing!" );
786 else if ( p
-> stats
-> client
!= NULL
&& ! isAdmin ( user
))
788 notice ( s_GameServ
, u
, "That player has already identified." );
790 else if (! check_password ( name
, password
) && ! isAdmin ( user
))
792 notice ( s_GameServ
, u
, "Password incorrect" );
795 ListNode
< aClient
> * temp
;
796 unsigned long hv
= iHASH (( unsigned char *) p
-> stats
-> name
);
797 temp
= players
[ hv
]. Find ( p
);
800 notice ( s_GameServ
, u
, "Fatal error. Contact %S Admin. Buf: %s " ,
804 user
-> stats
= new Player ( p
-> stats
-> name
);
806 log ( "Setting data for identified" );
808 user
-> stats
-> setData ( p
-> stats
);
809 user
-> stats
-> client
= user
;
810 updateTS ( user
-> stats
);
814 log ( "Player %s IRC: %s Identified" , user
-> stats
-> name
,
818 setPlaying ( user
); // set the playing flag
821 notice ( s_GameServ
, u
, "Password Accepted. Identified." );
825 void do_stats ( char * u
)
830 nick
= strtok ( NULL
, " " );
832 if (!( user
= find ( u
)))
834 log ( "Fatal Error: %s not found in client list" , u
);
837 else if ( isIgnore ( user
))
840 log ( "Ignoring %s ." , user
-> getNick ());
846 if (! is_playing ( user
))
848 notice ( s_GameServ
, u
, "You're not playing, so you have no stats!" );
853 updateTS ( user
-> stats
);
854 showstats ( u
, user
-> stats
-> name
);
864 log ( "Calling delete_masters()" );
870 log ( "Initializing masters" );
873 for ( int x
= 0 ; x
< LEVELS
; x
++)
874 masters
[ x
] = new Monster
;
876 strcpy ( masters
[ 0 ]-> name
, "Old Bones" );
877 strcpy ( masters
[ 0 ]-> weapon
, "Dull Sword Cane" );
878 masters
[ 0 ]-> strength
= 25 ;
879 masters
[ 0 ]-> gold
= 0 ;
881 masters
[ 0 ]-> maxhp
= 30 ;
883 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!" );
885 strcpy ( masters
[ 1 ]-> name
, "Master Chang" );
886 strcpy ( masters
[ 1 ]-> weapon
, "Nanchaku" );
887 masters
[ 1 ]-> strength
= 35 ;
888 masters
[ 1 ]-> gold
= 0 ;
890 masters
[ 1 ]-> maxhp
= 40 ;
892 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." );
894 strcpy ( masters
[ 2 ]-> name
, "Chuck Norris" );
895 strcpy ( masters
[ 2 ]-> weapon
, "Ranger Kick" );
896 masters
[ 2 ]-> strength
= 95 ;
897 masters
[ 2 ]-> gold
= 0 ;
899 masters
[ 2 ]-> maxhp
= 70 ;
901 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!" );
904 strcpy ( masters
[ 3 ]-> name
, "Mr. Miagi" );
905 strcpy ( masters
[ 3 ]-> weapon
, "Petrified Bonsai" );
906 masters
[ 3 ]-> strength
= 130 ;
907 masters
[ 3 ]-> gold
= 0 ;
909 masters
[ 3 ]-> maxhp
= 120 ;
910 masters
[ 3 ]-> hp
= 120 ;
911 strcpy ( masters
[ 3 ]-> death
, "Skill comes from repeating the correct but seemingly mundane actions. Wax ON, wax OFF!" );
913 strcpy ( masters
[ 4 ]-> name
, "Jackie Chan" );
914 strcpy ( masters
[ 4 ]-> weapon
, "Kung Fu Kick" );
915 masters
[ 4 ]-> strength
= 145 ;
916 masters
[ 4 ]-> gold
= 0 ;
918 masters
[ 4 ]-> maxhp
= 200 ;
919 masters
[ 4 ]-> hp
= 200 ;
920 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!" );
922 strcpy ( masters
[ 5 ]-> name
, "Jet Li" );
923 strcpy ( masters
[ 5 ]-> weapon
, "Motorcycle" );
924 masters
[ 5 ]-> strength
= 170 ;
925 masters
[ 5 ]-> gold
= 0 ;
927 masters
[ 5 ]-> maxhp
= 400 ;
928 masters
[ 5 ]-> hp
= 400 ;
929 strcpy ( masters
[ 5 ]-> death
, "Failure is a fuel for excuses. It's the doing the do, that makes the making." );
932 strcpy ( masters
[ 6 ]-> name
, "Muhammad Ali" );
933 strcpy ( masters
[ 6 ]-> weapon
, "Quick Jab" );
934 masters
[ 6 ]-> strength
= 195 ;
935 masters
[ 6 ]-> gold
= 0 ;
937 masters
[ 6 ]-> maxhp
= 600 ;
938 masters
[ 6 ]-> hp
= 600 ;
939 strcpy ( masters
[ 6 ]-> death
, "It's just a job. Grass grows, birds fly, waves pound the sand. I beat people up." );
941 strcpy ( masters
[ 7 ]-> name
, "Li Mu Bai" );
942 strcpy ( masters
[ 7 ]-> weapon
, "Green Destiny" );
943 masters
[ 7 ]-> strength
= 220 ;
944 masters
[ 7 ]-> gold
= 0 ;
946 masters
[ 7 ]-> maxhp
= 800 ;
947 masters
[ 7 ]-> hp
= 800 ;
948 strcpy ( masters
[ 7 ]-> death
, "No growth without resistance. No action without reaction. No desire without restraint." );
951 strcpy ( masters
[ 8 ]-> name
, "Jimmy Wang Yu" );
952 strcpy ( masters
[ 8 ]-> weapon
, "Flying Guillotine" );
953 masters
[ 8 ]-> strength
= 285 ;
954 masters
[ 8 ]-> gold
= 0 ;
956 masters
[ 8 ]-> maxhp
= 1200 ;
957 masters
[ 8 ]-> hp
= 1200 ;
958 strcpy ( masters
[ 8 ]-> death
, "You have beaten the one armed boxer. Proceed with caution!" );
960 strcpy ( masters
[ 9 ]-> name
, "Wong Fei Hung" );
961 strcpy ( masters
[ 9 ]-> weapon
, "Drunken Boxing" );
962 masters
[ 9 ]-> strength
= 375 ;
963 masters
[ 9 ]-> gold
= 0 ;
965 masters
[ 9 ]-> maxhp
= 1800 ;
966 masters
[ 9 ]-> hp
= 1800 ;
967 strcpy ( masters
[ 9 ]-> death
, "Hiccup! Monkey drinks master's wine!" );
969 strcpy ( masters
[ 10 ]-> name
, "Bruce Lee" );
970 strcpy ( masters
[ 10 ]-> weapon
, "Fists of fury" );
971 masters
[ 10 ]-> strength
= 590 ;
972 masters
[ 10 ]-> gold
= 0 ;
973 masters
[ 10 ]-> exp
= 0 ;
974 masters
[ 10 ]-> maxhp
= 2500 ;
975 masters
[ 10 ]-> hp
= 2500 ;
976 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." );
982 log ( "Calling delete_monsters" );
987 for ( int x
= 0 ; x
< LEVELS
; x
++)
988 for ( int y
= 0 ; y
< MONSTERS
; y
++)
989 monsters
[ x
][ y
] = new Monster ();
992 void delete_monsters ()
994 for ( int x
= 0 ; x
< LEVELS
; x
++)
995 for ( int y
= 0 ; y
< MONSTERS
; y
++)
997 delete monsters
[ x
][ y
];
1000 void delete_masters ()
1002 for ( int x
= 0 ; x
< LEVELS
; x
++)
1007 void display_monster ( char * u
)
1011 aClient
* user
= find ( u
);
1012 Player
* ni
= user
-> stats
;
1014 notice ( s_GameServ
, u
, "Your Hitpoints: \ 2 %d \ 2 ", ni
-> hp
);
1015 notice ( s_GameServ
, u
, " %s 's Hitpoints: \ 2 %d \ 2 ", ni
-> fight
-> name
, ni
-> fight
-> hp
);
1016 notice ( s_GameServ
, u
, "Here are your commands:" );
1017 notice ( s_GameServ
, u
, "/msg %S attack" );
1018 notice ( s_GameServ
, u
, "/msg %S run" );
1019 notice ( s_GameServ
, u
, "What will you do?" );
1023 void display_players ( char * u
)
1026 if (!( user
= find ( u
)))
1028 log ( "Fatal error in display_players(): Couldn't find %s " , u
);
1031 display_players ( user
);
1034 void display_players ( aClient
* user
)
1036 char * u
= user
-> getNick ();
1037 if ( is_playing ( user
) && player_fight ( user
))
1039 aClient
* battle
= user
-> stats
-> battle
;
1040 notice ( s_GameServ
, u
, "Your Hitpoints: \ 2 %d \ 2 ", user
-> stats
-> hp
);
1041 notice ( s_GameServ
, u
, " %s 's Hitpoints: \ 2 %d \ 2 ", battle
-> stats
-> name
, battle
-> stats
-> hp
);
1042 notice ( s_GameServ
, u
, "Here are your commands:" );
1043 notice ( s_GameServ
, u
, "/msg %S attack" );
1044 notice ( s_GameServ
, u
, "/msg %S run" );
1045 notice ( s_GameServ
, u
, "What will you do?" );
1050 bool is_playing ( char * u
)
1053 if (!( user
= find ( u
)))
1056 return is_playing ( user
);
1059 bool is_playing ( aClient
* user
)
1061 if ( user
-> stats
== NULL
)
1065 else if ( user
-> stats
-> client
== NULL
)
1069 else if (! FL_is_playing ( user
))
1077 bool is_fighting ( char * u
)
1081 if (!( user
= find ( u
)))
1084 return is_fighting ( user
);
1087 bool is_fighting ( aClient
* user
)
1089 if (! is_playing ( user
))
1092 return player_fight ( user
) || master_fight ( user
) || user
-> stats
-> fight
!= NULL
;
1095 bool player_fight ( char * u
)
1099 if (!( user
= find ( u
)))
1102 return player_fight ( user
);
1105 bool player_fight ( aClient
* user
)
1107 if (! is_playing ( user
))
1110 return user
-> stats
-> battle
!= NULL
;
1113 bool master_fight ( char * u
)
1117 if (!( user
= find ( u
)))
1120 return master_fight ( user
);
1123 bool master_fight ( aClient
* user
)
1125 if (! is_playing ( user
))
1128 return user
-> stats
-> master
!= NULL
;
1131 void do_fight ( char * u
)
1133 aClient
* ni
, * battle
;
1135 char * nick
= strtok ( NULL
, " " );
1139 notice ( s_GameServ
, u
, "SYNTAX: /msg %S FIGHT PLAYER" );
1142 else if (!( ni
= find ( u
)))
1144 notice ( s_GameServ
, u
, "Fatal error. Contact a(n) %S admin. buf: %s " , strtok ( NULL
, "" ));
1147 else if ( isIgnore ( ni
))
1150 log ( "Ignoring %s ." , ni
-> getNick ());
1154 else if (! is_playing ( ni
))
1156 notice ( s_GameServ
, u
, "You are not playing!" );
1160 updateTS ( ni
-> stats
);
1162 if ( ni
-> stats
-> player_fights
<= 0 )
1164 ni
-> stats
-> player_fights
= 0 ; // just to be safe
1165 notice ( s_GameServ
, u
, "You are out of player fights for the " \
1166 "day. You have to wait until tomorrow!" );
1168 else if (!( battle
= findplayer ( nick
)))
1170 notice ( s_GameServ
, u
, "Player %s not found!" , nick
);
1172 else if (! isAlive ( ni
-> stats
))
1174 notice ( s_GameServ
, u
, "You are dead. Wait until tomorrow to fight others!" );
1176 else if (! is_playing ( battle
))
1178 notice ( s_GameServ
, u
, "You can't attack %s while they aren't playing!" , nick
);
1181 * Offline fighting not implemented yet.
1182 * else if (!(fight = finduser(nick)))
1184 * ni->stats->battle = battle;
1185 * battle->battle = ni;
1187 * battle->yourturn = 0;
1188 * notice(s_GameServ, u, "You decide to fight %s while they're not online!",
1189 * battle->stats->name);
1190 * display_players(u);
1193 else if ( stricmp ( ni
-> stats
-> name
, battle
-> stats
-> name
) == 0 )
1195 notice ( s_GameServ
, u
, "Are you trying to commit suicide!?" );
1197 else if (! isAlive ( battle
-> stats
))
1199 notice ( s_GameServ
, u
, "They are dead. Cannot fight dead players!" );
1201 else if ( player_fight ( battle
))
1203 notice ( s_GameServ
, u
, " %s is fighting %s already!" , battle
-> stats
-> name
, battle
-> stats
-> battle
-> stats
-> name
);
1205 else if ( master_fight ( battle
))
1207 notice ( s_GameServ
, u
, " %s is fighting their master!" , battle
-> stats
-> name
);
1209 else if ( is_fighting ( battle
))
1211 notice ( s_GameServ
, u
, " %s is fighting %s already!" , battle
-> stats
-> name
, battle
-> stats
-> fight
-> name
);
1213 else if ( ni
-> stats
-> level
- battle
-> stats
-> level
> maxbfightdistance
)
1215 // You can't fight someone below you by more than X level(s)
1216 // level 12 can fight level (12 - X) but not < (12 - X)
1217 notice ( s_GameServ
, u
, "You may not fight %s . You're too strong!" ,
1218 battle
-> stats
-> name
);
1220 else if ( battle
-> stats
-> level
- ni
-> stats
-> level
> maxafightdistance
)
1222 // You can't fight someone above you by more than X level(S)
1223 // level 1 can fight level (1 + X), but not > (1 + X)
1224 notice ( s_GameServ
, u
, " %s , do you really have a death wish? Try the forest you " \
1225 "weakling!" , ni
-> stats
-> name
);
1229 // Set your battle pointer to the other player
1230 ni
-> stats
-> battle
= battle
;
1232 // Set the other player's battle pointer to you
1233 ni
-> stats
-> battle
-> stats
-> battle
= ni
;
1235 // The initiator gets the first move (perhaps this should be 50/50)
1236 setYourTurn ( ni
-> stats
);
1237 clearYourTurn ( battle
-> stats
);
1239 // Initiate Battle sequence!
1240 ni
-> stats
-> player_fights
-= 1 ;
1242 notice ( s_GameServ
, u
, "You challenge %s to an online duel!" , battle
-> stats
-> name
);
1243 notice ( s_GameServ
, battle
-> getNick (), " %s has challenged you to an online duel!" , ni
-> stats
-> name
);
1244 notice ( s_GameServ
, battle
-> getNick (), " %s gets to go first " \
1245 "because they initiated!" , ni
-> stats
-> name
);
1246 notice ( s_GameServ
, battle
-> getNick (), "Please wait while %s decides what to do." , ni
-> stats
-> name
);
1247 display_players ( ni
);
1251 void do_use ( char * u
)
1256 char * item
= strtok ( NULL
, " " );
1260 notice ( s_GameServ
, u
, "SYNTAX: USE ITEM" );
1261 notice ( s_GameServ
, u
, "Type /msg %S HELP USE for more information." );
1264 else if (!( user
= find ( u
)))
1266 notice ( s_GameServ
, u
, "Fatal Error in do_use. Contact a(n) %S Admin" );
1269 else if ( isIgnore ( user
))
1272 log ( "Ignoring %s ." , user
-> getNick ());
1276 else if (! is_playing ( user
))
1278 notice ( s_GameServ
, u
, "You must be playing to use items!" );
1282 updateTS ( user
-> stats
);
1284 p
= & user
-> stats
-> inventory
;
1286 if ( stricmp ( item
, "HEALTH" ) == 0 )
1288 if ( p
-> Healing () <= 0 )
1290 notice ( s_GameServ
, u
, "You are out of Health Potions!" );
1293 int oldhealth
= user
-> stats
-> hp
;
1294 notice ( s_GameServ
, u
, "You hastiliy gulp down the flask of cool life-giving waters." );
1295 notice ( s_GameServ
, u
, "Rejuvination spreads throughout your body." );
1296 user
-> stats
-> hp
+= ( 10 * user
-> stats
-> level
) + ( rand () % 10 ) * user
-> stats
-> level
;
1297 notice ( s_GameServ
, u
, "You gain %d HP!" , user
-> stats
-> hp
- oldhealth
);
1300 else if ( stricmp ( item
, "STRENGTH" ) == 0 )
1302 if ( p
-> Strength () <= 0 )
1304 notice ( s_GameServ
, u
, "You are out of Strength Potions!" );
1307 int oldstrength
= user
-> stats
-> strength
;
1308 notice ( s_GameServ
, u
, "As you grip the flask containing pure power, you feel adrenaline coarse through your veins!" );
1309 notice ( s_GameServ
, u
, "In one swallow you drink the potion and feel your muscle fibers bulging andgrowing!" );
1310 user
-> stats
-> strength
+= 1 + ( rand () % 10 >= 8 ? 1 : 0 ); // 1-2
1311 notice ( s_GameServ
, u
, "You gain %d Strength points!" , user
-> stats
-> strength
- oldstrength
);
1314 else if ( stricmp ( item
, "DEFENSE" ) == 0 )
1316 if ( p
-> Defense () <= 0 )
1318 notice ( s_GameServ
, u
, "You are out of Defense Potions!" );
1321 int olddefense
= user
-> stats
-> defense
;
1322 notice ( s_GameServ
, u
, "You drink the foul tasting viscous liquid while pinching your nose in disgust." );
1323 notice ( s_GameServ
, u
, "It tasted bad, but you feel like you are unbeatable!" );
1324 user
-> stats
-> defense
+= 1 + ( rand () % 10 >= 8 ? 1 : 0 ); // 1-2
1325 notice ( s_GameServ
, u
, "You gain %d Defense points!" , user
-> stats
-> defense
- olddefense
);
1328 else if ( stricmp ( item
, "HP" ) == 0 )
1332 notice ( s_GameServ
, u
, "You are out of HP Potions!" );
1335 int oldHP
= user
-> stats
-> maxhp
;
1336 notice ( s_GameServ
, u
, "You feel your life growing longer as you drink the green glowing liquid." );
1337 user
-> stats
-> maxhp
+= 4 +
1338 ( rand () % 100 > 50 ? ( rand () % 6 ) : ( rand () % 2 ) );
1340 notice ( s_GameServ
, u
, "You gain %d Maximum hit points!" , user
-> stats
-> maxhp
- oldHP
);
1345 notice ( s_GameServ
, u
, "SYNTAX: /msg %S USE {HEALTH | STRENGTH | DEFENSE}" );
1349 end_turn ( user
); // If they're fighting, end their turn
1351 void do_run ( char * u
)
1354 Player
* p
, * p2
= NULL
;
1356 if (!( user
= find ( u
)))
1358 notice ( s_GameServ
, u
, "Couldn't find you. Error. Contact a %S admin" );
1361 else if ( isIgnore ( user
))
1364 log ( "Ignoring %s ." , user
-> getNick ());
1368 else if (! is_playing ( user
))
1370 notice ( s_GameServ
, u
, "You must be playing to run!" );
1374 updateTS ( user
-> stats
);
1378 p2
= p
-> battle
-> stats
;
1380 if (! is_fighting ( user
))
1381 notice ( s_GameServ
, u
, "You run in place... try fighting next time." );
1382 else if (! player_fight ( user
) && ! master_fight ( user
))
1384 notice ( s_GameServ
, u
, "You run away from \ 2 %s \ 2 like a little baby!", p
-> fight
-> name
);
1388 else if ( player_fight ( user
) && isYourTurn ( p
))
1390 notice ( s_GameServ
, u
, "You run away from \ 2 %s \ 2 like a little baby!", p2
-> name
);
1391 notice ( s_GameServ
, p
-> battle
-> getNick (), "\ 2 %s \ 2 ran away from you like a little baby!", p
-> name
);
1394 else if ( player_fight ( user
) && ! isYourTurn ( p
))
1396 notice ( s_GameServ
, u
, "It is not your turn. Please wait until \ 2 %s \ 2 decides what to do.", p2
-> name
);
1398 else if ( master_fight ( user
))
1400 notice ( s_GameServ
, u
, "You cannot run from \ 2 %s \ 2 ! FIGHT!", p
-> master
-> name
);
1405 void end_turn ( aClient
* user
)
1407 char * nick
, * u
= user
-> getNick ();
1412 nick
= new char [ strlen ( user
-> getNick ()) + 1 ];
1414 if (! user
|| ! is_playing ( user
) || ! is_fighting ( user
))
1417 if (! player_fight ( user
) && ! master_fight ( user
))
1418 fight
= user
-> stats
-> fight
;
1420 fight
= user
-> stats
-> master
;
1421 battle
= user
-> stats
-> battle
;
1423 if (! player_fight ( user
))
1426 mhit
= ( fight
-> strength
/ 2 ) +
1427 ( rand () % ( fight
-> strength
/ 2 ) - ( user
-> stats
-> defense
+
1428 arbonus
[ user
-> stats
-> armor
]));
1433 mhit
= ((( battle
-> stats
-> strength
+ webonus
[ battle
-> stats
-> weapon
]) / 2 ) +
1434 ( rand () % (( battle
-> stats
-> strength
+ webonus
[ battle
-> stats
-> weapon
])) / 2 ) -
1435 ( user
-> stats
-> defense
+ arbonus
[ user
-> stats
-> armor
]));
1437 if (! player_fight ( user
))
1442 notice ( s_GameServ
, u
, "\1f %s \1f attacks with their \1f %s \1f for \ 2 %d \ 2 damage!",
1443 fight
-> name
, fight
-> weapon
, mhit
);
1446 notice ( s_GameServ
, u
, " %s completely misses you!" , fight
-> name
);
1448 if ( mhit
>= user
-> stats
-> hp
)
1450 if (! master_fight ( user
))
1452 notice ( s_GameServ
, u
, "You have been \ 2 \1f killed\1f \ 2 by %s !" , fight
-> name
);
1453 notice ( s_GameServ
, u
, "You lose all gold on hand and lose 10 percent " \
1454 "of your experience!" );
1455 user
-> stats
-> gold
= 0 ;
1456 user
-> stats
-> exp
-= ( long int )( user
-> stats
-> exp
* .10 );
1457 user
-> stats
-> fight
= NULL
;
1458 clearAlive ( user
-> stats
);
1463 notice ( s_GameServ
, u
, " %s has bested you! You will have to wait " \
1464 "until tomorrow to try again" , user
-> stats
-> master
-> name
);
1465 user
-> stats
-> fight
= NULL
;
1466 user
-> stats
-> master
= NULL
;
1473 user
-> stats
-> hp
-= mhit
;
1480 clearYourTurn ( user
-> stats
);
1481 setYourTurn ( battle
-> stats
);
1482 display_players ( battle
);
1488 void do_attack ( char * u
)
1491 aClient
* ni
, * battle
; // The player and perhaps the player they're fighting
1492 Monster
* fight
; // The monster they may be fighting
1494 if (!( ni
= find ( u
)))
1496 notice ( s_GameServ
, u
, "Fatal error in do_attack. Contact a(n) %S admin for help." );
1499 else if ( isIgnore ( ni
))
1502 log ( "Ignoring %s ." , ni
-> getNick ());
1506 else if (! is_playing ( ni
))
1508 notice ( s_GameServ
, u
, "You're not playing!" );
1511 else if (! is_fighting ( ni
))
1513 notice ( s_GameServ
, u
, "You're not in battle!" );
1518 if (! ni
-> stats
-> master
) // This is not a master fight
1519 fight
= ni
-> stats
-> fight
; // Monster Could be NULL
1520 else // This IS a master fight
1521 fight
= ni
-> stats
-> master
; // Master Could be NULL
1523 battle
= ni
-> stats
-> battle
; // Player Could be NULL
1525 // One has to be !NULL based on the previous else if
1526 // We wouldn't be here if they were all NULL
1528 updateTS ( ni
-> stats
);
1530 if (! player_fight ( ni
))
1533 hit
= (( ni
-> stats
-> strength
+ webonus
[ ni
-> stats
-> weapon
]) / 2 ) +
1534 ( rand () % (( ni
-> stats
-> strength
+ webonus
[ ni
-> stats
-> weapon
]) / 2 ));
1537 mhit
= ( fight
-> strength
/ 2 ) +
1538 ( rand () % ( fight
-> strength
/ 2 ) - ( ni
-> stats
-> defense
+
1539 arbonus
[ ni
-> stats
-> armor
]));
1544 mhit
= ((( battle
-> stats
-> strength
+ webonus
[ battle
-> stats
-> weapon
]) / 2 ) +
1545 ( rand () % (( battle
-> stats
-> strength
+ webonus
[ battle
-> stats
-> weapon
])) / 2 ) -
1546 ( ni
-> stats
-> defense
+ arbonus
[ ni
-> stats
-> armor
]));
1549 hit
= ((( ni
-> stats
-> strength
+ webonus
[ ni
-> stats
-> weapon
]) / 2 ) +
1550 ( rand () % (( ni
-> stats
-> strength
+ webonus
[ ni
-> stats
-> weapon
])) / 2 ) -
1551 ( battle
-> stats
-> defense
+ arbonus
[ battle
-> stats
-> armor
]));
1554 if (! player_fight ( ni
))
1557 notice ( s_GameServ
, u
, "You attack \1f %s \1f for \ 2 %d \ 2 points!", fight
-> name
, hit
);
1559 notice ( s_GameServ
, u
, "You miss \1f %s \1f completely!", fight
-> name
);
1561 if ( hit
>= fight
-> hp
)
1563 if ( master_fight ( ni
))
1564 notice ( s_GameServ
, u
, "You have bested %s !" , fight
-> name
);
1566 notice ( s_GameServ
, u
, "You have killed \ 2 %s \ 2 !", fight
-> name
);
1568 notice ( s_GameServ
, u
, " %s " , fight
-> death
);
1569 notice ( s_GameServ
, u
, "You recieve \ 2 %d \ 2 experience and \ 2 %d \ 2 gold!",
1570 fight
-> exp
, fight
-> gold
);
1572 // If your new experience (or gold) will be greater than 2 billion,
1573 // then set your exp to 2bil. (2 billion max)... otherwise add them.
1574 // This could be a problem with overflowing out of the sign bit.
1575 // Unsigned long int maybe? Leave it for now.
1576 ni
-> stats
-> exp
= ( ( ni
-> stats
-> exp
+ fight
-> exp
) > 2000000000 ? 2000000000 :
1577 ni
-> stats
-> exp
+ fight
-> exp
);
1579 ni
-> stats
-> gold
= ( ni
-> stats
-> gold
+ fight
-> gold
> 2000000000 ? 2000000000 :
1580 ni
-> stats
-> gold
+ fight
-> gold
);
1583 if ( master_fight ( ni
))
1585 notice ( s_GameServ
, u
, "You are now level %d !" , ni
-> stats
-> level
+ 1 );
1586 notice ( s_GameServ
, u
, "You gain %d Strength, and %d Defense points!" ,
1587 strbonus
[ ni
-> stats
-> level
- 1 ], defbonus
[ ni
-> stats
-> level
- 1 ]);
1589 // Increase your level
1592 // Increase your maximum hit points
1593 ni
-> stats
-> maxhp
+= hpbonus
[ ni
-> stats
-> level
- 1 ];
1595 // Heal the player by setting hp to their max
1596 ni
-> stats
-> hp
= ni
-> stats
-> maxhp
;
1598 // Add to your strength
1599 ni
-> stats
-> strength
+= strbonus
[ ni
-> stats
-> level
- 1 ];
1601 // Add to your defensive power
1602 ni
-> stats
-> defense
+= defbonus
[ ni
-> stats
-> level
- 1 ];
1604 // Clear the pointer for your master
1605 ni
-> stats
-> master
= NULL
;
1608 // They're dead so remove the pointer
1609 delete ni
-> stats
-> fight
;
1610 ni
-> stats
-> fight
= NULL
;
1611 ni
-> stats
-> master
= NULL
;
1621 notice ( s_GameServ
, u
, "\1f %s \1f attacks with their \1f %s \1f for \ 2 %d \ 2 damage!",
1622 fight
-> name
, fight
-> weapon
, mhit
);
1625 notice ( s_GameServ
, u
, " %s completely misses you!" , fight
-> name
);
1627 if ( mhit
>= ni
-> stats
-> hp
)
1629 if (! master_fight ( ni
))
1631 notice ( s_GameServ
, u
, "You have been \ 2 \1f killed\1f \ 2 by %s !" , fight
-> name
);
1632 notice ( s_GameServ
, u
, "You lose all gold on hand and lose 10 percent " \
1633 "of your experience!" );
1634 ni
-> stats
-> gold
= 0 ;
1635 ni
-> stats
-> exp
-= ( long int )( ni
-> stats
-> exp
* .10 );
1636 ni
-> stats
-> fight
= NULL
;
1637 clearAlive ( ni
-> stats
);
1642 notice ( s_GameServ
, u
, " %s has bested you! You will have to wait " \
1643 "until tomorrow to try again" , ni
-> stats
-> master
-> name
);
1644 ni
-> stats
-> fight
= NULL
;
1645 ni
-> stats
-> master
= NULL
;
1652 ni
-> stats
-> hp
-= mhit
;
1658 else if ( player_fight ( ni
))
1660 /* Offline fighting not available yet
1661 if (!(online = finduser(ni->stats->battle->nick)) || !nick_identified(online))
1664 notice(s_GameServ, u, "You attack \1f %s\1f for \ 2 %d\ 2 points!", battle->nick, hit);
1666 notice(s_GameServ, u, "You miss \1f %s\1f completely!", battle->nick);
1667 if (hit >= battle->stats->hp)
1669 notice(s_GameServ, u, "You have killed \ 2 %s\ 2 !", battle->nick);
1670 * notice(s_GameServ, u, "You recieve \ 2 %d\ 2 experience and \ 2 %ld\ 2 gold!",
1671 (long int)(battle->stats->exp * .10), battle->stats->gold);
1672 if (2000000000 - ni->stats->exp > (long int)(battle->stats->exp * .10))
1674 ni->stats->exp += (long int)(battle->stats->exp * .10);
1675 battle->stats->exp -= (long int)(battle->stats->exp * .10);
1679 battle->stats->exp -= (long int)(battle->stats->exp * .10);
1680 ni->stats->exp = 2000000000;
1683 if (2000000000 - ni->stats->gold > battle->stats->gold)
1685 * ni->stats->gold += battle->stats->gold;
1686 battle->stats->gold = 0;
1690 battle->stats->gold = 2000000000 - ni->stats->gold;
1691 ni->stats->gold = 2000000000;
1693 * ni->stats->battle->stats->alive = 0;
1694 ni->stats->battle->battle = NULL;
1695 ni->stats->battle = NULL;
1701 * battle->stats->hp -= hit;
1704 notice(s_GameServ, u, "\1f %s\1f hits you with their \1f %s\1f for \ 2 %d\ 2 damage!",
1705 battle->nick, weapons[battle->stats->weapon], mhit);
1708 notice(s_GameServ, u, "%s completely misses you!", battle->nick);
1710 if (mhit >= ni->stats->hp)
1712 notice(s_GameServ, u, "You have been \ 2 \1f killed\1f \ 2 by %s!", battle->nick);
1713 if (2000000000 - battle->stats->gold > ni->stats->gold)
1715 notice(s_GameServ, u, "%s took all your gold!", battle->nick);
1716 battle->stats->gold += ni->stats->gold;
1717 * ni->stats->gold = 0;
1721 notice(s_GameServ, u, "You're lucky, %s couldn't carry all your gold.",
1723 ni->stats->gold -= (2000000000 - battle->stats->gold);
1724 notice(s_GameServ, u, "You were left dead with %d gold.",
1725 * (long int)ni->stats->gold);
1726 battle->stats->gold = 2000000000;
1728 ni->stats->battle->battle = NULL;
1729 ni->stats->battle = NULL;
1730 ni->stats->alive = 0;
1736 ni->stats->hp -= mhit;
1742 * end offline fighting */
1744 if ( is_playing ( battle
))
1746 if (! isYourTurn ( ni
-> stats
))
1748 notice ( s_GameServ
, u
, "Please wait until %s decides what to do!" ,
1749 battle
-> stats
-> name
);
1754 notice ( s_GameServ
, u
, "You attack \1f %s \1f for \ 2 %d \ 2 points!", battle
-> stats
-> name
, hit
);
1756 notice ( s_GameServ
, battle
-> getNick (), " %s has hit you with their %s for " \
1757 "\ 2 %d \ 2 damage!", ni
-> stats
-> name
,
1758 weapons
[ ni
-> stats
-> weapon
], hit
);
1759 clearYourTurn ( ni
-> stats
);
1760 setYourTurn ( battle
-> stats
);
1761 display_players ( battle
);
1765 notice ( s_GameServ
, u
, "You miss \1f %s \1f completely!", battle
-> stats
-> name
);
1766 notice ( s_GameServ
, battle
-> getNick (), " %s misses you completely!" , ni
-> stats
-> name
);
1767 clearYourTurn ( ni
-> stats
);
1768 setYourTurn ( battle
-> stats
);
1769 display_players ( battle
);
1771 if ( hit
>= battle
-> stats
-> hp
)
1773 notice ( s_GameServ
, u
, "You have killed \ 2 %s \ 2 !", battle
-> stats
-> name
);
1774 notice ( s_GameServ
, u
, "You recieve \ 2 %d \ 2 experience and \ 2 %l d\ 2 gold!" ,
1775 ( long int )( battle
-> stats
-> exp
* .10 ), battle
-> stats
-> gold
);
1776 notice ( s_GameServ
, battle
-> getNick (), "You have been killed by \ 2 %s \ 2 !",
1778 battle
-> stats
-> hp
= 0 ;
1779 clearAlive ( battle
-> stats
);
1781 if ( 2000000000 - ni
-> stats
-> exp
> ( long int )( battle
-> stats
-> exp
* .10 ))
1783 ni
-> stats
-> exp
+= ( long int )( battle
-> stats
-> exp
* .10 );
1784 battle
-> stats
-> exp
-= ( long int )( battle
-> stats
-> exp
* .10 );
1788 battle
-> stats
-> exp
-= ( long int )( battle
-> stats
-> exp
* .10 );
1789 ni
-> stats
-> exp
= 2000000000 ;
1792 if ( 2000000000 - ni
-> stats
-> gold
> battle
-> stats
-> gold
)
1794 notice ( s_GameServ
, battle
-> getNick (), "You lose ten percent of experience and " \
1795 "all gold on hand!" );
1796 ni
-> stats
-> gold
+= battle
-> stats
-> gold
;
1797 battle
-> stats
-> gold
= 0 ;
1801 battle
-> stats
-> gold
= 2000000000 - ni
-> stats
-> gold
;
1802 notice ( s_GameServ
, battle
-> getNick (), "You lose ten percent of your experience!" );
1804 notice ( s_GameServ
, battle
-> getNick (), "However, %s could not carry all of your " \
1805 "gold." , ni
-> stats
-> name
);
1807 notice ( s_GameServ
, battle
-> getNick (), "Luckily, you still have \ 2 %l d\ 2 gold " \
1808 "left. All is not lost!" , battle
-> stats
-> gold
);
1810 ni
-> stats
-> gold
= 2000000000 ;
1812 battle
-> stats
-> battle
= NULL
;
1813 ni
-> stats
-> battle
= NULL
;
1819 battle
-> stats
-> hp
-= hit
;
1820 clearYourTurn ( ni
-> stats
);
1821 setYourTurn ( battle
-> stats
);
1822 notice ( s_GameServ
, u
, "Please wait while %s decides what to do!" ,
1823 battle
-> stats
-> name
);
1831 void do_heal ( char * u
)
1834 char * amount
= strtok ( NULL
, " " );
1839 notice ( s_GameServ
, u
, "SYNTAX: /msg %S HEAL {ALL | #}" );
1842 else if (!( ni
= find ( u
)))
1844 notice ( s_GameServ
, u
, "Fatal error. Contact a(n) %S admin. buf: %s " , strtok ( NULL
, "" ));
1847 else if ( isIgnore ( ni
))
1850 log ( "Ignoring %s ." , ni
-> getNick ());
1854 else if (! is_playing ( ni
))
1856 notice ( s_GameServ
, u
, "You aren't playing!" );
1859 else if (! isAlive ( ni
-> stats
))
1861 notice ( s_GameServ
, u
, "You are dead. Wait until tomorrow for healing." );
1864 else if ( is_fighting ( ni
))
1866 notice ( s_GameServ
, u
, "You can't heal in battle!" );
1869 else if ( ni
-> stats
-> hp
>= ni
-> stats
-> maxhp
)
1871 notice ( s_GameServ
, u
, "You don't need healing!" );
1875 updateTS ( ni
-> stats
);
1876 if ( stricmp ( amount
, "ALL" ) == 0 )
1878 price
= ni
-> stats
-> level
* 3 ;
1879 if ( ni
-> stats
-> gold
< ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
) * price
)
1881 notice ( s_GameServ
, u
, "Healing \ 2 %d \ 2 points for \ 2 %d \ 2 gold per point.",
1882 ( long int ) ni
-> stats
-> gold
/ price
, price
);
1883 ni
-> stats
-> hp
+= ni
-> stats
-> gold
/ price
;
1884 ni
-> stats
-> gold
%= price
;
1888 notice ( s_GameServ
, u
, "Healing all possible points at \ 2 %d \ 2 gold "\
1889 "per point." , price
);
1890 notice ( s_GameServ
, u
, "\ 2 %d \ 2 points healed for \ 2 %l d\ 2 gold. HP at MAX!" ,
1891 ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
),
1892 ( price
* ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
)) );
1893 ni
-> stats
-> gold
-= price
* ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
);
1894 ni
-> stats
-> hp
= ni
-> stats
-> maxhp
;
1897 else if ( isstringnum ( amount
))
1899 num
= stringtoint ( amount
);
1900 price
= ni
-> stats
-> level
* 3 ;
1901 if ( ni
-> stats
-> gold
< price
* num
)
1903 notice ( s_GameServ
, u
, "You only have enough gold to heal \ 2 %d \ 2 points!",
1904 ( long int ) ni
-> stats
-> gold
/ price
);
1906 else if ( num
<= ni
-> stats
-> maxhp
- ni
-> stats
-> hp
)
1908 notice ( s_GameServ
, u
, "Healing \ 2 %d \ 2 points at \ 2 %d \ 2 gold per point.",
1910 ni
-> stats
-> hp
+= num
;
1911 ni
-> stats
-> gold
-= num
* price
;
1913 else if ( num
> ni
-> stats
-> maxhp
- ni
-> stats
-> hp
)
1915 notice ( s_GameServ
, u
, "Healing all possible points at \ 2 %d \ 2 gold "\
1916 "per point." , price
);
1917 notice ( s_GameServ
, u
, "\ 2 %d \ 2 points healed. HP at MAX!",
1918 ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
));
1919 ni
-> stats
-> gold
-= price
* ( ni
-> stats
-> maxhp
- ni
-> stats
-> hp
);
1920 ni
-> stats
-> hp
= ni
-> stats
-> maxhp
;
1923 else if ( amount
[ 0 ] == '-' )
1924 notice ( s_GameServ
, u
, "You trying to cheat?" );
1926 notice ( s_GameServ
, u
, "SYNTAX: /msg %S HEAL {ALL | #}" );
1929 int isstringnum ( char * num
)
1932 for ( x
= 0 ; x
< strlen ( num
); x
++)
1934 if (( int ) num
[ x
] < 48 || ( int ) num
[ x
] > 57 )
1940 long int stringtoint ( char * number
)
1942 long int x
, len
= strlen ( number
), sum
= 0 ;
1944 return chartoint ( number
[ 0 ]);
1945 sum
+= chartoint ( number
[ len
- 1 ]);
1946 for ( x
= len
- 2 ; x
>= 0 ; x
--)
1947 sum
+= chartoint ( number
[ x
]) * pow ( 10 , abs ( x
- len
+ 1 ));
1951 long int pow ( int x
, int y
)
1957 if ( x
!= 0 && y
!= 0 )
1959 for ( count
= 1 ; count
<= y
- 1 ; count
++)
1967 long int chartoint ( char ch
)
1969 if ( int ( ch
) >= 48 && int ( ch
) <= 57 )
1970 return int ( ch
) - 48 ;
1977 ListNode
< aClient
> * ptr
;
1981 outfile
. open ( playerdata
);
1985 log ( "Error opening %s " , playerdata
);
1989 for ( unsigned long x
= 0 ; x
< U_TABLE_SIZE
; x
++)
1991 ptr
= players
[ x
]. First ();
1994 it
= ptr
-> getData ()-> stats
;
1996 outfile
<< it
-> name
<< ' ' << it
-> level
<< ' ' << it
-> exp
<< ' ' << it
-> gold
<< ' ' << it
-> bank
<< ' '
1997 << it
-> hp
<< ' ' << it
-> maxhp
<< ' ' << it
-> strength
<< ' ' << it
-> defense
<< ' '
1998 << it
-> armor
<< ' ' << it
-> weapon
<< ' '
1999 << it
-> forest_fights
<< ' ' << it
-> player_fights
<< ' '
2000 << it
-> getFlags () << ' ' << it
-> password
<< ' ' << it
-> inventory
. Healing ()
2001 << ' ' << it
-> inventory
. Strength () << ' ' << it
-> inventory
. Defense () << ' ' << it
-> inventory
. HP () << endl
;
2014 char * tempname
, * buf
, * password
;
2015 buf
= new char [ 1023 ];
2017 infile
. open ( playerdata
);
2021 log ( "Error opening %s " , playerdata
);
2025 while ( infile
. getline ( buf
, 1024 , ' \n ' ))
2028 tempname
= strtok ( buf
, " " );
2029 temp
-> stats
= new Player ( tempname
);
2032 p
-> level
= stringtoint ( strtok ( NULL
, " " ));
2033 p
-> exp
= stringtoint ( strtok ( NULL
, " " ));
2034 p
-> gold
= stringtoint ( strtok ( NULL
, " " ));
2035 p
-> bank
= stringtoint ( strtok ( NULL
, " " ));
2036 p
-> hp
= stringtoint ( strtok ( NULL
, " " ));
2037 p
-> maxhp
= stringtoint ( strtok ( NULL
, " " ));
2038 p
-> strength
= stringtoint ( strtok ( NULL
, " " ));
2039 p
-> defense
= stringtoint ( strtok ( NULL
, " " ));
2040 p
-> armor
= stringtoint ( strtok ( NULL
, " " ));
2041 p
-> weapon
= stringtoint ( strtok ( NULL
, " " ));
2042 p
-> forest_fights
= stringtoint ( strtok ( NULL
, " " ));
2043 p
-> player_fights
= stringtoint ( strtok ( NULL
, " " ));
2044 p
-> setFlags ( stringtoint ( strtok ( NULL
, " " )));
2046 password
= strtok ( NULL
, " " );
2047 strcpy ( p
-> password
, password
);
2048 temp
-> setNick ( "Not Playing" );
2050 temp
-> setRealNick ( "Not Playing" );
2053 p
-> inventory
. reset (); // Set inventory to all 0s
2054 // Old player databases didn't have these three extra values
2055 // If they come up null, leave them to 0 as the default.
2056 // On the next gameserv database save, it will save the values.
2057 tempname
= strtok ( NULL
, " " );
2059 p
-> inventory
. setHealing ( stringtoint ( tempname
));
2061 tempname
= strtok ( NULL
, " " );
2063 p
-> inventory
. setStrength ( stringtoint ( tempname
));
2065 tempname
= strtok ( NULL
, " " );
2067 p
-> inventory
. setDefense ( stringtoint ( tempname
));
2069 tempname
= strtok ( NULL
, " " );
2071 p
-> inventory
. setHP ( stringtoint ( tempname
));
2072 unsigned long hv
= iHASH (( unsigned char *) temp
-> stats
-> name
);
2074 temp
-> stats
-> client
= NULL
;
2075 players
[ hv
]. insertAtBack ( temp
);
2083 bool passcmp ( char * encrypted
, char * plaintext
)
2086 char * plaintext2
, * plainToencrypt
;
2089 plaintext2
= new char [ strlen ( encrypted
) + strlen ( plaintext
)]; // Extra
2090 strcpy ( plaintext2
, plaintext
);
2092 salt
[ 0 ] = encrypted
[ 0 ];
2093 salt
[ 1 ] = encrypted
[ 1 ];
2096 plainToencrypt
= crypt ( plaintext2
, salt
);
2098 same
= ( strcmp (( const char *) encrypted
, plainToencrypt
) == 0 ? true : false );
2100 delete [] plaintext2
;
2105 bool check_password ( char * name
, char * plaintext
)
2109 if (!( client
= findplayer ( name
)))
2113 return passcmp ( client
-> stats
-> password
, plaintext
);
2117 void do_store ( char * u
)
2119 char * cmd
= strtok ( NULL
, " " );
2120 char * item
= strtok ( NULL
, " " );
2121 char * num
= strtok ( NULL
, " " );
2129 notice ( s_GameServ
, u
, "SYNTAX: STORE LIST {ARMOR | WEAPONS}" );
2130 notice ( s_GameServ
, u
, " \ 2 STORE SELL {ARMOR | WEAPON}\ 2 " );
2131 notice ( s_GameServ
, u
, " \ 2 STORE BUY {ARMOR | WEAPON} \1f NUMBER\1f \ 2 " );
2134 else if (!( user
= find ( u
)))
2136 log ( "Fatal Error: could not find %s in client list" , u
);
2139 else if ( isIgnore ( user
))
2142 log ( "Ignoring %s ." , user
-> getNick ());
2146 else if (! is_playing ( user
))
2148 notice ( s_GameServ
, u
, "You must be playing to use the store!" );
2151 else if (! isAlive ( user
-> stats
))
2153 notice ( s_GameServ
, u
, "You are dead. Wait until tomorrow to purchase weapons and armor!" );
2156 updateTS ( user
-> stats
);
2158 if ( stricmp ( cmd
, "LIST" ) == 0 )
2160 if ( stricmp ( item
, "WEAPONS" ) == 0 )
2162 notice ( s_GameServ
, u
, "Welcome to Kain's Armory" );
2163 notice ( s_GameServ
, u
, "Here are the weapons we have available for the killing, sire:" );
2164 for ( int x
= 1 ; x
< WNA
; x
++)
2166 space
= spaces ( strlen ( weapons
[ x
]), "." );
2167 notice ( s_GameServ
, u
, " %s%d . %s%s%d " ,( x
< 10 ? " " : "" ), x
, weapons
[ x
], space
, prices
[ x
- 1 ]);
2170 notice ( s_GameServ
, u
, "To purchase a weapon, type /msg %S STORE BUY \ 2 NUM\ 2 ." );
2171 notice ( s_GameServ
, u
, "Where num. is the weapon number from the menu above." );
2174 else if ( stricmp ( item
, "ARMOR" ) == 0 )
2176 notice ( s_GameServ
, u
, "Welcome to Kain's Armory" );
2177 notice ( s_GameServ
, u
, "I hope you enjoy the fine armor we have available for your protection:" );
2178 for ( int x
= 1 ; x
< WNA
; x
++)
2180 space
= spaces ( strlen ( armors
[ x
]), "." );
2181 notice ( s_GameServ
, u
, " %s%d . %s%s%d " ,( x
< 10 ? " " : "" ), x
, armors
[ x
], space
, prices
[ x
- 1 ]);
2184 notice ( s_GameServ
, u
, "To purchase armor, type /msg %S store buy armor num." );
2185 notice ( s_GameServ
, u
, "Where num. is the armor number from the menu above." );
2189 } else if ( stricmp ( cmd
, "BUY" ) == 0 ) {
2192 notice ( s_GameServ
, u
, "SYNTAX: \ 2 STORE BUY {ARMOR | WEAPON} \1f NUMBER\1f \ 2 " );
2195 else if (! isstringnum ( num
))
2197 notice ( s_GameServ
, u
, "You must specify a number between 1 and %d . Not %s !" , WNA
- 1 , num
);
2200 if ( stricmp ( item
, "WEAPON" ) == 0 )
2202 wep
= stringtoint ( num
);
2203 if ( wep
>= WNA
|| wep
< 1 )
2205 notice ( s_GameServ
, u
, "The number %d is out of range. The number you provide must be between 1 and %d ." , wep
, WNA
- 1 );
2212 notice ( s_GameServ
, u
, "You have to sell your %s first!" , weapons
[ p
-> weapon
]);
2213 else if ( p
-> gold
< prices
[ wep
- 1 ])
2214 notice ( s_GameServ
, u
, "You don't have enough gold for %s !" , weapons
[ wep
]);
2217 notice ( s_GameServ
, u
, "You have purchased %s ! Thanks for the gold!" , weapons
[ wep
]);
2219 p
-> gold
-= prices
[ wep
- 1 ];
2222 else if ( stricmp ( item
, "ARMOR" ) == 0 )
2224 wep
= stringtoint ( num
);
2225 if ( wep
>= WNA
|| wep
< 1 )
2227 notice ( s_GameServ
, u
, "The number %d is out of range. The number you provide must be between 1 and %d ." , wep
, WNA
- 1 );
2234 notice ( s_GameServ
, u
, "You have to sell your %s first!" , armors
[ p
-> armor
]);
2235 else if ( p
-> gold
< prices
[ wep
- 1 ])
2236 notice ( s_GameServ
, u
, "You don't have enough gold for %s !" , armors
[ wep
]);
2239 notice ( s_GameServ
, u
, "You have purchased %s ! Thanks for the gold!" , armors
[ wep
]);
2241 p
-> gold
-= prices
[ wep
- 1 ];
2245 else if ( stricmp ( cmd
, "SELL" ) == 0 )
2249 if ( stricmp ( item
, "WEAPON" ) == 0 )
2253 notice ( s_GameServ
, u
, "You want me to chop off your hands?" );
2256 else if ( p
-> gold
== 2000000000 )
2258 notice ( s_GameServ
, u
, "You have enough gold. I'll just take that off your hands, sire." );
2261 else if ( 2000000000 - p
-> gold
< ( prices
[ p
-> weapon
- 1 ] / 2 ))
2263 notice ( s_GameServ
, u
, "Thank you for your business! You now have as much gold as you can carry." );
2264 notice ( s_GameServ
, u
, "However, you have no weapon... can I interest you in the %s ?" , weapons
[ WNA
- 1 ]);
2265 p
-> gold
= 2000000000 ;
2270 notice ( s_GameServ
, u
, "Thank you for your business! You now have %d more gold but no weapon!" , ( prices
[ p
-> weapon
- 1 ] / 2 ));
2271 p
-> gold
+= ( prices
[ p
-> weapon
- 1 ] / 2 );
2275 else if ( stricmp ( item
, "ARMOR" ) == 0 )
2281 notice ( s_GameServ
, u
, "I don't think you can be any more naked..." );
2284 if ( p
-> gold
== 2000000000 )
2286 notice ( s_GameServ
, u
, "You have enough gold. I'll just take that off your hands, sire." );
2289 else if ( 2000000000 - p
-> gold
< ( prices
[ p
-> armor
- 1 ] / 2 ))
2291 notice ( s_GameServ
, u
, "Thank you for your business! You now have as much gold as you can carry." );
2292 notice ( s_GameServ
, u
, "However, you have no armor... can I interest you in %s ?" , armors
[ WNA
- 1 ]);
2293 p
-> gold
= 2000000000 ;
2298 notice ( s_GameServ
, u
, "Thank you for your business! You now have %d more gold but no armor!" ,
2299 ( prices
[ p
-> armor
- 1 ] / 2 ));
2301 p
-> gold
+= ( prices
[ p
-> armor
- 1 ] / 2 );
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 " );
2313 void do_inventory ( char * u
)
2317 if (!( user
= find ( u
)))
2319 notice ( s_GameServ
, u
, "Fatal Error. Contact a %S admin!" );
2322 else if ( isIgnore ( user
))
2325 log ( "Ignoring %s ." , user
-> getNick ());
2329 else if (! is_playing ( user
))
2331 notice ( s_GameServ
, u
, "You must be playing to check your inventory!" );
2334 updateTS ( user
-> stats
);
2335 showinventory ( user
, user
);
2337 void showinventory ( aClient
* from
, aClient
* to
)
2339 char * nick
= to
-> getNick ();
2343 if ( is_playing ( from
))
2345 Pouch
* p
= & from
-> stats
-> inventory
;
2346 notice ( s_GameServ
, nick
, "Inventory for %s :" , from
-> stats
-> name
);
2347 notice ( s_GameServ
, nick
, " Healing Potions: %d " , p
-> Healing ());
2348 notice ( s_GameServ
, nick
, "Strength Potions: %d " , p
-> Strength ());
2349 notice ( s_GameServ
, nick
, " Defense Potions: %d " , p
-> Defense ());
2350 notice ( s_GameServ
, nick
, " HP Potions: %d " , p
-> HP ());
2353 void do_tavern ( char * u
)
2355 char * cmd
= strtok ( NULL
, " " );
2360 if (!( user
= find ( u
)))
2362 notice ( s_GameServ
, u
, "Fatal Error. See a %S admin for help" );
2365 else if ( isIgnore ( user
))
2368 log ( "Ignoring %s ." , user
-> getNick ());
2372 else if (! is_playing ( user
))
2374 notice ( s_GameServ
, u
, "You must be playing to go to the Tavern" );
2377 else if ( is_fighting ( user
))
2379 notice ( s_GameServ
, u
, "You cannot go to the Tavern during a fight!" );
2383 updateTS ( user
-> stats
);
2388 notice ( s_GameServ
, u
, "Welcome to Boot Liquors Mystic Apothecary" );
2389 notice ( s_GameServ
, u
, "Your commands:" );
2390 notice ( s_GameServ
, u
, "/msg %S TAVERN {LIST | BUY} [NUMBER]" );
2391 notice ( s_GameServ
, u
, "What'll it be?" );
2393 else if ( stricmp ( cmd
, "LIST" ) == 0 )
2395 notice ( s_GameServ
, u
, "Here is a list of what we have to offer:" );
2396 notice ( s_GameServ
, u
, "1. Healing Potions for %l d Gold" , 100 * p
-> level
+ ( p
-> exp
/ 10 ));
2397 notice ( s_GameServ
, u
, "2. Strength Potions for %l d Gold" , 205 * p
-> level
+ ( p
-> exp
/ 10 ));
2398 notice ( s_GameServ
, u
, "3. Defense Potions for %l d Gold" , 200 * p
-> level
+ ( p
-> exp
/ 10 ));
2399 notice ( s_GameServ
, u
, "4. HP Potions for %l d Gold" , 230 * p
-> level
+ ( p
-> exp
/ 10 ));
2400 notice ( s_GameServ
, u
, "To buy a potion, type /msg %S TAVERN BUY #" );
2401 notice ( s_GameServ
, u
, "Example: /msg %S TAVERN BUY 1 buys a healing potion!" );
2402 notice ( s_GameServ
, u
, "By something will ya!" );
2404 else if ( stricmp ( cmd
, "BUY" ) == 0 )
2406 char * chnum
= strtok ( NULL
, " " );
2407 int num
= stringtoint ( chnum
);
2411 notice ( s_GameServ
, u
, "SYNTAX: TAVERN BUY #" );
2412 notice ( s_GameServ
, u
, "Example: /msg %S TAVERN BUY 1" );
2415 if ( num
< 1 || num
> 4 )
2417 notice ( s_GameServ
, u
, "Invalid Choice!" );
2418 notice ( s_GameServ
, u
, "Here is a list of what we have to offer:" );
2419 notice ( s_GameServ
, u
, "1. Healing Potions for %l d Gold" , 100 * p
-> level
+ ( p
-> exp
/ 10 ));
2420 notice ( s_GameServ
, u
, "2. Strength Potions for %l d Gold" , 205 * p
-> level
+ ( p
-> exp
/ 10 ));
2421 notice ( s_GameServ
, u
, "3. Defense Potions for %l d Gold" , 200 * p
-> level
+ ( p
-> exp
/ 10 ));
2422 notice ( s_GameServ
, u
, "4. HP Potions for %l d Gold" , 230 * p
-> level
+ ( p
-> exp
/ 10 ));
2423 notice ( s_GameServ
, u
, "To buy a potion, type /msg %S TAVERN BUY #" );
2424 notice ( s_GameServ
, u
, "Example: /msg %S TAVERN BUY 1 buys a healing potion!" );
2430 price
= ( 100 * p
-> level
) + ( p
-> exp
/ 10 );
2431 if ( p
-> gold
>= price
)
2433 notice ( s_GameServ
, u
, "One healing potion coming right up!" );
2434 p
-> inventory
. incHealing ();
2438 notice ( s_GameServ
, u
, "You don't have enough gold!" );
2441 price
= ( 205 * p
-> level
) + ( p
-> exp
/ 10 );
2442 if ( p
-> gold
>= price
)
2444 notice ( s_GameServ
, u
, "One strength boost coming right up!" );
2445 p
-> inventory
. incStrength ();
2449 notice ( s_GameServ
, u
, "You don't have enough gold!" );
2452 price
= ( 200 * p
-> level
) + ( p
-> exp
/ 10 );
2453 if ( p
-> gold
>= price
)
2455 notice ( s_GameServ
, u
, "One defense boost coming right up!" );
2456 p
-> inventory
. incDefense ();
2460 notice ( s_GameServ
, u
, "You don't have enough gold!" );
2463 price
= ( 230 * p
-> level
) + ( p
-> exp
/ 10 );
2464 if ( p
-> gold
>= price
)
2466 notice ( s_GameServ
, u
, "One HP Potion coming right up!" );
2467 p
-> inventory
. incHP ();
2471 notice ( s_GameServ
, u
, "You don't have enough gold!" );
2474 notice ( s_GameServ
, u
, "Logical Error. See a %S admin for help!" );
2480 notice ( s_GameServ
, u
, "Improper Syntax." );
2481 notice ( s_GameServ
, u
, "Type /msg %S HELP TAVERN for help" );
2485 void do_bank ( char * u
)
2487 char * cmd
= strtok ( NULL
, " " );
2488 char * amount
= strtok ( NULL
, " " );
2489 char * nick
= strtok ( NULL
, " " );
2494 if (! cmd
|| (! amount
&& stricmp ( cmd
, "BALANCE" ) != 0 ) || ( stricmp ( cmd
, "TRANSFER" ) == 0 && ! nick
))
2496 notice ( s_GameServ
, u
, "BANK {WITHDRAW | DEPOSIT} {ALL | AMOUNT}" );
2497 notice ( s_GameServ
, u
, "BANK BALANCE" );
2500 else if (!( user
= find ( u
)))
2502 notice ( s_GameServ
, u
, "Fatal Error. Couldn't find your aClient. Contact a(n) %S " \
2504 log ( "Fatal Error. Couldn't find %s while executing do_bank()" , u
);
2507 else if ( isIgnore ( user
))
2510 log ( "Ignoring %s ." , user
-> getNick ());
2514 else if (! is_playing ( user
))
2516 notice ( s_GameServ
, u
, "You must be playing to use the bank!" );
2520 updateTS ( user
-> stats
);
2521 if ( stricmp ( cmd
, "BALANCE" ) == 0 )
2526 else if (! isAlive ( user
-> stats
))
2528 notice ( s_GameServ
, u
, "You are dead. We don't accept gold from dead folk! Wait 'til tomorrow!" );
2531 else if (! isstringnum ( amount
) && stricmp ( amount
, "ALL" ) != 0 )
2533 notice ( s_GameServ
, u
, "I don't know how to convert alphabet letters into currency, sire!" );
2539 if ( stricmp ( cmd
, "DEPOSIT" ) == 0 )
2541 if ( p
-> bank
== 2000000000 )
2543 notice ( s_GameServ
, u
, "Your bank account is full, sire!" );
2546 else if ( stricmp ( amount
, "ALL" ) == 0 )
2548 if ( 2000000000 - p
-> bank
< p
-> gold
)
2550 notice ( s_GameServ
, u
, "You don't have enough room for all of your gold." );
2551 notice ( s_GameServ
, u
, "Depositing %l d gold into your account" , ( 2000000000 - p
-> bank
));
2552 p
-> gold
-= ( 2000000000 - p
-> bank
);
2553 p
-> bank
= 2000000000 ;
2558 notice ( s_GameServ
, u
, "Depositing %l d gold into your account!" , p
-> gold
);
2564 else if ( stringtoint ( amount
) > p
-> gold
)
2566 notice ( s_GameServ
, u
, "Sire, you only have %l d gold!" , p
-> gold
);
2572 if ( 2000000000 - p
-> bank
< stringtoint ( amount
))
2574 notice ( s_GameServ
, u
, "You don't have room in your account for that much." );
2575 notice ( s_GameServ
, u
, "Capping off your account with %l d gold!" , ( 2000000000 - p
-> bank
));
2576 p
-> gold
-= ( 2000000000 - p
-> bank
);
2577 p
-> bank
= 2000000000 ;
2582 notice ( s_GameServ
, u
, "Depositing %d gold into your account!" , stringtoint ( amount
));
2583 p
-> bank
+= stringtoint ( amount
);
2584 p
-> gold
-= stringtoint ( amount
);
2589 else if ( stricmp ( cmd
, "WITHDRAW" ) == 0 )
2591 if ( p
-> gold
== 2000000000 )
2593 notice ( s_GameServ
, u
, "You cannot carry any more gold, sire!" );
2597 else if ( stricmp ( amount
, "ALL" ) == 0 )
2599 if ( 2000000000 - p
-> gold
< p
-> bank
)
2601 notice ( s_GameServ
, u
, "You don't have enough room to carry all that gold." );
2602 notice ( s_GameServ
, u
, "Withdrawing %l d gold from your account" , ( 2000000000 - p
-> gold
));
2603 p
-> bank
-= ( 2000000000 - p
-> gold
);
2604 p
-> gold
= 2000000000 ;
2609 notice ( s_GameServ
, u
, "Withdrawing %l d gold from your account!" , p
-> bank
);
2615 else if ( stringtoint ( amount
) > p
-> bank
)
2617 notice ( s_GameServ
, u
, "Sire, you only have %l d gold in the bank!" , p
-> bank
);
2623 if ( 2000000000 - p
-> gold
< stringtoint ( amount
))
2625 notice ( s_GameServ
, u
, "You don't enough have room to carry that much gold!" );
2626 notice ( s_GameServ
, u
, "You fill your pockets with %l d gold!" ,
2627 ( 2000000000 - p
-> gold
));
2628 p
-> bank
-= ( 2000000000 - p
-> gold
);
2629 p
-> gold
= 2000000000 ;
2634 notice ( s_GameServ
, u
, "Withdrawing %d gold from your account!" , stringtoint ( amount
));
2635 p
-> gold
+= stringtoint ( amount
);
2636 p
-> bank
-= stringtoint ( amount
);
2644 void do_master ( char * u
)
2649 if (!( user
= find ( u
)))
2651 notice ( s_GameServ
, u
, "Fatal error. Contact a(n) %S admin. buf: %s " , strtok ( NULL
, "" ));
2654 else if ( isIgnore ( user
))
2657 log ( "Ignoring %s ." , user
-> getNick ());
2661 else if ( is_fighting ( user
))
2663 notice ( s_GameServ
, u
, "You're in the middle of a fight! Pay attention!" );
2666 else if (! isAlive ( user
-> stats
))
2668 notice ( s_GameServ
, u
, "You're dead. Wait until tomorrow to see your master!" );
2671 else if (! is_playing ( user
))
2673 notice ( s_GameServ
, u
, "You must be playing to see your master!" );
2677 updateTS ( user
-> stats
);
2678 char * cmd
= strtok ( NULL
, " " );
2679 Player
* p
= user
-> stats
;
2684 notice ( s_GameServ
, u
, "You have already seen your master today. Wait until tomorrow to try again" );
2727 notice ( s_GameServ
, u
, "You are at level 12. You are the master. What's left? The DRAGON!" );
2730 need
= p
-> exp
+ 1 ; // Unknown level... don't let them fight a fake master!
2736 notice ( s_GameServ
, u
, "SYNTAX: MASTER {FIGHT | QUESTION}" );
2740 if ( stricmp ( cmd
, "FIGHT" ) == 0 )
2748 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
));
2751 else if ( stricmp ( cmd
, "QUESTION" ) == 0 )
2754 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
);
2756 notice ( s_GameServ
, u
, "You pathetic fool! You are no match for %s , %s !" , masters
[ p
-> level
- 1 ]-> name
, p
-> name
);
2762 notice ( s_GameServ
, u
, "SYNTAX: MASTER {FIGHT | QUESTION}" );
2766 void see_master ( char * u
)
2770 if (!( user
= find ( u
)))
2772 notice ( s_GameServ
, u
, "Fatal error. Contact a(n) %S admin. buf: %s " , strtok ( NULL
, "" ));
2776 if (! is_fighting ( user
) && is_playing ( user
))
2778 Player
* p
= user
-> stats
;
2779 p
-> master
= new Monster ( masters
[ p
-> level
- 1 ]);
2780 p
-> fight
= p
-> master
;
2781 display_monster ( u
); // Since master is the same structure, use this function
2785 void showBankBalance ( const char * u
)
2790 if (!( user
= find ( u
)))
2798 notice ( s_GameServ
, u
, "Account Balance: %l d Gold On hand: %l d" , p
-> bank
, p
-> gold
);
2804 ListNode
< aClient
> * it
;
2806 for ( unsigned long x
= 0 ; x
< U_TABLE_SIZE
; x
++)
2808 it
= players
[ x
]. First ();
2812 p
= it
-> getData ()-> stats
;
2819 void refresh ( Player
* p
)
2824 if ( p
-> hp
< p
-> maxhp
)
2826 p
-> forest_fights
= forestfights
;
2827 p
-> player_fights
= 3 ;
2832 void do_refresh ( char * u
)
2834 char * nick
= strtok ( NULL
, " " );
2837 if (!( user
= find ( u
)))
2839 notice ( s_GameServ
, u
, "Error: aClient not found. Contact a %S admin" );
2840 log ( "Error: aClient not found: %s " , u
);
2843 else if ( isIgnore ( user
))
2846 log ( "Ignoring %s ." , user
-> getNick ());
2850 else if (! isAdmin ( user
))
2852 notice ( s_GameServ
, u
, "You must be a %S admin to use this command!" );
2857 notice ( s_GameServ
, u
, "SYNTAX: REFRESH {ALL | NICK}" );
2860 else if ( stricmp ( nick
, "ALL" ) == 0 )
2862 notice ( s_GameServ
, u
, "Refreshing everyone's stats!" );
2865 else if (( user
= findplayer ( nick
)))
2867 if ( is_playing ( user
))
2870 notice ( s_GameServ
, u
, "Refreshing %s ." , user
-> getRealNick ());
2872 notice ( s_GameServ
, u
, "Refreshing %s ." , user
-> getNick ());
2874 refresh ( user
-> stats
);
2879 notice ( s_GameServ
, u
, " %s is not playing." , user
-> getRealNick ());
2881 notice ( s_GameServ
, u
, " %s is not playing." , user
-> getNick ());
2887 notice ( s_GameServ
, u
, "Nick %s not found." , nick
);
2895 ListNode
< aClient
> * it
;
2898 for ( unsigned long x
= 0 ; x
< U_TABLE_SIZE
; x
++)
2900 it
= players
[ x
]. First ();
2904 p
= it
-> getData ()-> stats
;
2911 void reset ( Player
* p
)
2919 void updateTS ( Player
* p
)
2925 log ( "Old timestamp for %s : %l d" , p
-> name
, p
-> lastcommand
);
2927 p
-> lastcommand
= time ( NULL
);
2929 log ( "New timestamp for %s : %l d" , p
-> name
, p
-> lastcommand
);
2934 bool timedOut ( Player
* p
)
2938 else if ( p
-> lastcommand
== 0 )
2942 if (( time ( NULL
) - p
-> lastcommand
) >= maxidletime
)
2949 void timeOutEvent ( Player
* p
)
2951 aClient
* user
= findplayer ( p
-> name
);
2953 if (! user
|| ! p
-> client
) // then they're not playing
2956 char * nick
= user
-> getNick ();
2958 if ( player_fight ( user
) && isYourTurn ( p
))
2960 // Check to see if they were the idler or if it was the other
2962 if ( p
-> lastcommand
!= p
-> battle
-> stats
-> lastcommand
)
2964 // This person's last command was given earlier,
2965 // so this person is the idler
2966 notice ( s_GameServ
, nick
, "You timed out " \
2967 "during a fight. You lose your turn!" );
2968 notice ( s_GameServ
, p
-> battle
-> getNick (),
2969 " %s hesitated for too long. Your move." , p
-> name
);
2971 setYourTurn ( p
-> battle
-> stats
);
2973 // Update the TS for both players to give them another
2974 // Chance to wake up, but if the other player doesn't
2975 // Attack now, they both get logged out.
2977 p
-> battle
-> stats
-> lastcommand
= p
-> lastcommand
;
2978 display_players ( p
-> battle
);
2983 notice ( s_GameServ
, p
-> battle
-> getNick (),
2984 "You and %s timed out at the same time." \
2985 " Don't fight if you're just going to " \
2986 "sit there!" , p
-> name
);
2987 notice ( s_GameServ
, user
-> getNick (),
2988 "You and %s timed out at the same time." \
2989 " Don't fight if you're just going to " \
2990 "sit there!" , p
-> battle
-> stats
-> name
);
2996 else if (! player_fight ( user
))
2998 // Place fun stuff here :)
2999 int randnum
= 1 + rand () % 100 ; // 1-100
3000 #define GSN(s) notice(s_GameServ, nick, s)
3001 #define GSN2(s, f) notice(s_GameServ, nick, s, f)
3005 // 35-100% of your gold goes pffft - kain
3006 int stolen
= ( 35 + ( rand () % 66 )) * user
-> stats
-> gold
/ 100 ;
3008 GSN ( "You stop for a moment to rest on the " \
3009 "street corner. All of a sudden, you " \
3010 "are ambushed from all sides by a hoarde " \
3011 "of knife wielding thugs." );
3012 GSN2 ( "The thugs beat you into utter submission " \
3013 "and steal %d gold from you!" , stolen
);
3014 user
-> stats
-> gold
-= stolen
;
3016 else if ( randnum
>= 50 && randnum
< 75 )
3018 // 25-65% of your gold goes pffft - kain
3019 int stolen
= ( 25 + ( rand () % 41 )) * user
-> stats
-> gold
/ 100 ;
3020 GSN ( "While dilly dallying around, you lose " \
3021 "your sense of time. Little did you know, " \
3022 "but thieves lifted your gold while you " \
3023 "weren't watching." );
3024 GSN2 ( "Better luck next time... you lose %d gold" , stolen
);
3025 user
-> stats
-> gold
-= stolen
;
3027 else if ( randnum
>= 75 )
3029 // 25-75% of your gold goes pffft - kain
3030 int stolen
= ( 25 + ( rand () % 51 )) * user
-> stats
-> gold
/ 100 ;
3031 GSN ( "Good grief! A gaggle of gooey green ghostlike " \
3032 "goblins grabbed your gold!" );
3033 GSN2 ( "They stole %d gold from you!" , stolen
);
3034 user
-> stats
-> gold
-= stolen
;
3038 // Always log out the user
3043 void do_reset ( char * u
)
3045 char * nick
= strtok ( NULL
, " " );
3048 if (!( user
= find ( u
)))
3050 notice ( s_GameServ
, u
, "Error: aClient not found. Contact a %S admin" );
3051 log ( "Error: aClient not found: %s " , u
);
3054 else if (! isAdmin ( user
))
3056 notice ( s_GameServ
, u
, "You must be a %S admin to use this command!" );
3062 notice ( s_GameServ
, u
, "SYNTAX: RESET {ALL | NICK}" );
3065 else if ( stricmp ( nick
, "ALL" ) == 0 )
3067 notice ( s_GameServ
, u
, "Resetting everyone's stats!" );
3070 else if (( user
= findbyrealnick ( nick
)))
3072 if ( is_playing ( user
))
3075 notice ( s_GameServ
, u
, "Resetting %s ." , user
-> getRealNick ());
3077 notice ( s_GameServ
, u
, "Resetting %s ." , user
-> getNick ());
3084 notice ( s_GameServ
, u
, " %s is not playing." , user
-> getRealNick ());
3086 notice ( s_GameServ
, u
, " %s is not playing." , user
-> getNick ());
3092 notice ( s_GameServ
, u
, "Nick %s not found." , nick
);
3097 void do_help ( char * u
)
3099 char * cmd
= strtok ( NULL
, " " );
3101 display_help ( u
, cmd
);
3104 void display_help ( char * u
, char * file
)
3111 infile
. open ( "helpfiles/help" );
3114 log ( "Error opening helpfiles/help" );
3115 notice ( s_GameServ
, u
, "Error opening helpfiles/help" );
3118 buf
= new char [ 1024 ];
3119 while ( infile
. getline ( buf
, 1024 ))
3121 // Written this way, it will process %S in the helpfiles
3122 // Instead of notice(s_GameServ, u, "%s", buf);
3123 notice ( s_GameServ
, u
, buf
);
3127 aClient
* user
= find ( u
);
3128 if ( user
&& isAdmin ( user
))
3129 display_help ( u
, "admin_commands" );
3134 filename
= new char [ strlen ( file
) + 11 ];
3135 strcpy ( filename
, "helpfiles/" );
3136 strcat ( filename
, file
);
3138 for ( unsigned int x
= 10 ; x
< strlen ( filename
); x
++)
3139 filename
[ x
] = tolower ( filename
[ x
]);
3141 infile
. open ( filename
);
3145 notice ( s_GameServ
, u
, "No help for \ 2 %s \ 2 ", file
);
3148 buf
= new char [ 1024 ];
3149 while ( infile
. getline ( buf
, 1024 ))
3151 // Written this way, it will process %S in the helpfiles
3152 // Instead of notice(s_GameServ, u, "%s", buf);
3153 notice ( s_GameServ
, u
, buf
);
3160 void do_admin ( char * u
)
3163 char * pass
= strtok ( NULL
, " " );
3165 if (!( user
= find ( u
)))
3167 log ( "Error: aClient not found: %s " , u
);
3168 notice ( s_GameServ
, u
, "Error: aClient not found. Contact %S admin." );
3174 notice ( s_GameServ
, u
, "SYNTAX: \ 2 ADMIN\ 2 \ 2 \1f password\1f \ 2 " );
3180 notice ( s_GameServ
, u
, "You already have administrator privledges." );
3183 else if ( strcmp ( pass
, adminpass
) == 0 )
3185 notice ( s_GameServ
, u
, "Password accepted. You now have administrator privledges." );
3188 log ( " %s became an administrator." , user
-> getRealNick ());
3190 log ( " %s became an administrator." , user
-> getNick ());
3195 notice ( s_GameServ
, u
, "Invalid password. Remember: case sensitive" );
3200 bool load_monsters ()
3203 infile
. open ( "monsters.dat" );
3209 log ( "Error opening monsters.dat" );
3213 buf
= new char [ 2048 ];
3216 log ( "Loading monsters from monsters.dat" );
3219 for ( int l
= 0 ; l
< REALLEVELS
; l
++)
3221 for ( int m
= 0 ; m
< MONSTERS
;)
3223 infile
. getline ( buf
, 2048 );
3224 if ( buf
[ 0 ] == ' \n ' || buf
[ 0 ] == '\0' || buf
[ 0 ] == '#' )
3228 strcpy ( monsters
[ l
][ m
]-> name
, strtok ( buf
, "~" ));
3229 strcpy ( monsters
[ l
][ m
]-> weapon
, strtok ( NULL
, "~" ));
3230 monsters
[ l
][ m
]-> strength
= stringtoint ( strtok ( NULL
, "~" ));
3231 monsters
[ l
][ m
]-> gold
= stringtoint ( strtok ( NULL
, "~" ));
3232 monsters
[ l
][ m
]-> exp
= stringtoint ( strtok ( NULL
, "~" ));
3233 monsters
[ l
][ m
]-> maxhp
= stringtoint ( strtok ( NULL
, "~" ));
3234 monsters
[ l
][ m
]-> hp
= monsters
[ l
][ m
]-> maxhp
;
3235 strcpy ( monsters
[ l
][ m
]-> death
, strtok ( NULL
, "" ));
3244 // this will be hash.cpp start
3245 // thank you wcampbel
3246 unsigned long sHASH ( const unsigned char * name
)
3248 unsigned long h
= 0 , g
;
3252 h
= ( h
<< 4 ) + (* name
++); // Case sensitive for numerics
3253 if (( g
= ( h
& 0xF0000000 )))
3257 return h
% U_TABLE_SIZE
;
3260 unsigned long iHASH ( const unsigned char * name
)
3262 unsigned long h
= 0 , g
;
3266 h
= ( h
<< 4 ) + tolower (* name
++);
3267 if (( g
= ( h
& 0xF0000000 )))
3271 return h
% U_TABLE_SIZE
;
3274 // this will be hash.cpp end