]>
jfr.im git - irc/gameservirc.git/blob - gameserv/do_attack.cpp
10 void do_attack ( char * u
)
12 int hit
= 0 , mhit
= 0 ;
13 aClient
* ni
, * battle
; // The player and perhaps the player they're fighting
14 Monster
* fight
; // The monster they may be fighting
18 notice ( s_GameServ
, u
, "Fatal error in do_attack. Contact a(n) <S admin for help." );
21 else if ( isIgnore ( ni
))
24 log ( "Ignoring %s ." , ni
-> getNick ());
28 else if (! is_playing ( ni
))
30 notice ( s_GameServ
, u
, "You're not playing!" );
33 else if (! is_fighting ( ni
))
35 notice ( s_GameServ
, u
, "You're not in battle!" );
41 fight
= ni
-> stats
-> getMonster (); // Monster Could be NULL
42 battle
= ni
-> stats
-> getBattle (); // Player Could be NULL
44 // One has to be !NULL based on the previous else if
45 // We wouldn't be here if they were all NULL
49 if (! player_fight ( ni
))
52 if (( ni
-> stats
-> getStrength () / 2 ) == 0 )
58 hit
= ( ni
-> stats
-> getStrength ()/ 2 ) + ( rand () % ( ni
-> stats
-> getStrength () / 2 )) - fight
-> defense
;
62 if (( fight
-> strength
/ 2 ) == 0 )
68 mhit
= ( fight
-> strength
/ 2 ) +
69 ( rand () % ( fight
-> strength
/ 2 ) - ( ni
-> stats
-> getDefense ()));
75 mhit
= ((( battle
-> stats
-> getStrength ()) / 2 ) +
76 ( rand () % (( battle
-> stats
-> getStrength ())) / 2 ) -
77 ( ni
-> stats
-> getDefense ()));
80 hit
= ((( ni
-> stats
-> getStrength ()) / 2 ) +
81 ( rand () % (( ni
-> stats
-> getStrength ())) / 2 ) -
82 ( battle
-> stats
-> getDefense ()));
85 if (! player_fight ( ni
))
88 notice ( s_GameServ
, u
, "You attack \1f %s \1f for \ 2 %d \ 2 hp!", fight
-> name
. c_str (), hit
);
90 notice ( s_GameServ
, u
, "You miss \1f %s \1f completely!", fight
-> name
. c_str ());
94 if ( master_fight ( ni
) && ! dragon_fight ( ni
))
96 notice ( s_GameServ
, u
, "You have bested %s !" , fight
-> name
. c_str ());
97 addNews ( todaysnews
, " %s has bested %s and moved " \
98 "to level %d " , ni
-> stats
-> getName (). c_str (), fight
-> name
. c_str (),
99 ( ni
-> stats
-> getLevel () + 1 ));
102 notice ( s_GameServ
, u
, "You have killed \ 2 %s \ 2 !", fight
-> name
. c_str ());
104 notice ( s_GameServ
, u
, " %s " , fight
-> death
. c_str ());
105 notice ( s_GameServ
, u
, "You recieve \ 2 %d \ 2 experience and \ 2 %d \ 2 gold!",
106 fight
-> exp
, fight
-> gold
);
108 if ( dragon_fight ( ni
))
110 addNews ( todaysnews
, " %s is a true warrior! %s has beaten %s !!" \
111 " %s is now watching over the Dragon's lair!" ,
112 ni
-> stats
-> getName (). c_str (), ni
-> stats
-> getName (). c_str (),
113 ni
-> stats
-> getMonster ()-> name
. c_str (), ni
-> stats
-> getName (). c_str ());
114 dragon
. name
= "Dragon " + ni
-> stats
-> getName ();
115 dragon
. weapon
= "Breath of Fire" ;
116 dragon
. strength
= ni
-> stats
-> getStrength ();
117 dragon
. defense
= ni
-> stats
-> getDefense ();
118 dragon
. hp
= ni
-> stats
-> getMaxHP ();
119 dragon
. maxhp
= ni
-> stats
-> getMaxHP ();
121 clearDragonFight ( ni
-> stats
);
123 ni
-> stats
-> delMonster ();
127 ni
-> stats
-> addExp ( fight
-> exp
);
128 ni
-> stats
-> addGold ( fight
-> gold
);
130 if ( master_fight ( ni
))
132 notice ( s_GameServ
, u
, "You are now level %d !" , ni
-> stats
-> getLevel () + 1 );
133 notice ( s_GameServ
, u
, "You gain %d Strength, and %d Defense points!" ,
134 strbonus
[ ni
-> stats
-> getLevel () - 1 ], defbonus
[ ni
-> stats
-> getLevel () - 1 ]);
136 // Increase your level
138 // Increase your maximum hit points
139 ni
-> stats
-> addMaxHP ( hpbonus
[ ni
-> stats
-> getLevel () - 1 ]);
141 // Heal the player by setting hp to their max
142 ni
-> stats
-> healall ();
144 // Add to your strength
145 ni
-> stats
-> addStrength ( strbonus
[ ni
-> stats
-> getLevel () - 1 ]);
147 // Add to your defensive power
148 ni
-> stats
-> addDefense ( defbonus
[ ni
-> stats
-> getLevel () - 1 ]);
150 ni
-> stats
-> addLevel ( 1 );
154 // They're dead so remove the pointer
155 ni
-> stats
-> delMonster ();
157 // Clear the pointer for your master
158 ni
-> stats
-> delMaster ();
168 notice ( s_GameServ
, u
, "\1f %s \1f attacks with their \1f %s \1f for \ 2 %d \ 2 damage!",
169 fight
-> name
. c_str (), fight
-> weapon
. c_str (), mhit
);
172 notice ( s_GameServ
, u
, " %s completely misses you!" , fight
-> name
. c_str ());
174 if ( mhit
>= ni
-> stats
-> getHP ())
176 if (! master_fight ( ni
))
178 notice ( s_GameServ
, u
, "You have been \ 2 \1f killed\1f \ 2 by %s !" , fight
-> name
. c_str ());
179 notice ( s_GameServ
, u
, "You lose all gold on hand and lose 10 percent " \
180 "of your experience!" );
181 addNews ( todaysnews
, " %s has been killed by %s !" ,
182 ni
-> stats
-> getName (). c_str (), fight
-> name
. c_str ());
183 ni
-> stats
-> setGold ( 0 );
184 ni
-> stats
-> subtractExp (( long int )( ni
-> stats
-> getExp () * .10 ));
186 ni
-> stats
-> delMonster ();
187 clearAlive ( ni
-> stats
);
192 notice ( s_GameServ
, u
, " %s has bested you! You will have to wait " \
193 "until tomorrow to try again" , ni
-> stats
-> getMaster ()-> name
. c_str ());
194 addNews ( todaysnews
, " %s tried to best %s and failed!" ,
195 ni
-> stats
-> getName (). c_str (), fight
-> name
. c_str ());
196 ni
-> stats
-> delMonster ();
197 ni
-> stats
-> delMaster ();
204 ni
-> stats
-> subtractHP ( mhit
);
210 else if ( player_fight ( ni
))
212 if ( is_playing ( battle
))
214 if (! isYourTurn ( ni
-> stats
) && isYourTurn ( battle
-> stats
))
216 notice ( s_GameServ
, u
, "Please wait until %s decides what to do!" ,
217 battle
-> stats
-> getName (). c_str ());
220 else if (! isYourTurn ( ni
-> stats
) && ! isYourTurn ( battle
-> stats
))
222 // If somehow the player vs. player fight hangs, give the turn to the first attacker
223 setYourTurn ( ni
-> stats
);
227 notice ( s_GameServ
, u
, "You attack \1f %s \1f for \ 2 %d \ 2 points!", battle
-> stats
-> getName (). c_str (), hit
);
229 notice ( s_GameServ
, battle
-> getNick (), " %s has hit you with their %s for " \
230 "\ 2 %d \ 2 damage!", ni
-> stats
-> getName (). c_str (),
231 ( ni
-> stats
-> getWeapon () ? ni
-> stats
-> getWeapon ()-> getName (). c_str () : "Fists" ), hit
);
235 notice ( s_GameServ
, u
, "You miss \1f %s \1f completely!", battle
-> stats
-> getName (). c_str ());
236 notice ( s_GameServ
, battle
-> getNick (), " %s misses you completely!" , ni
-> stats
-> getName (). c_str ());
239 if ( hit
>= battle
-> stats
-> getHP ())
241 notice ( s_GameServ
, u
, "You have killed \ 2 %s \ 2 !", battle
-> stats
-> getName (). c_str ());
242 notice ( s_GameServ
, u
, "You recieve \ 2 %d \ 2 experience and \ 2 %l d\ 2 gold!" ,
243 ( long int )( battle
-> stats
-> getExp () * .10 ), battle
-> stats
-> getGold ());
244 addNews ( todaysnews
, " %s has defeated %s , leaving %s in a pool of blood" , ni
-> stats
-> getName (). c_str (), battle
-> stats
-> getName (). c_str (), battle
-> stats
-> getName (). c_str ()); /* DrLnet - Modified by kain for news instead of just a message */
245 notice ( s_GameServ
, battle
-> getNick (), "You have been killed by \ 2 %s \ 2 !",
246 ni
-> stats
-> getName (). c_str ());
247 battle
-> stats
-> setHP ( 0 );
248 clearAlive ( battle
-> stats
);
250 ni
-> stats
-> addHP (( long int )( battle
-> stats
-> getExp () * .10 ));
251 battle
-> stats
-> subtractExp (( long int )( battle
-> stats
-> getExp () * .10 ));
253 notice ( s_GameServ
, battle
-> getNick (), "You lose ten percent of experience and " \
254 "all gold on hand!" );
255 ni
-> stats
-> addGold ( battle
-> stats
-> getGold ());
256 battle
-> stats
-> setGold ( 0 );
259 clearYourTurn ( ni
-> stats
);
260 clearYourTurn ( battle
-> stats
);
262 battle
-> stats
-> delBattle ();
263 ni
-> stats
-> delBattle ();
269 battle
-> stats
-> subtractHP ( hit
);
271 clearYourTurn ( ni
-> stats
);
272 setYourTurn ( battle
-> stats
);
273 display_players ( battle
);
274 notice ( s_GameServ
, u
, "Please wait while %s decides what to do!" ,
275 battle
-> stats
-> getName (). c_str ());