]>
jfr.im git - irc/gameservirc.git/blob - gameserv/do_attack.cpp
9 void do_attack ( char * u
)
11 int hit
= 0 , mhit
= 0 ;
12 aClient
* ni
, * battle
; // The player and perhaps the player they're fighting
13 Monster
* fight
; // The monster they may be fighting
17 notice ( s_GameServ
, u
, "Fatal error in do_attack. Contact a(n) <S admin for help." );
20 else if ( isIgnore ( ni
))
23 log ( "Ignoring %s ." , ni
-> getNick ());
27 else if (! is_playing ( ni
))
29 notice ( s_GameServ
, u
, "You're not playing!" );
32 else if (! is_fighting ( ni
))
34 notice ( s_GameServ
, u
, "You're not in battle!" );
40 fight
= ni
-> stats
-> getMonster (); // Monster Could be NULL
41 battle
= ni
-> stats
-> getBattle (); // Player Could be NULL
43 // One has to be !NULL based on the previous else if
44 // We wouldn't be here if they were all NULL
48 if (! player_fight ( ni
))
51 if (( ni
-> stats
-> getStrength () / 2 ) == 0 )
57 hit
= ( ni
-> stats
-> getStrength ()/ 2 ) + ( rand () % ( ni
-> stats
-> getStrength () / 2 )) - fight
-> defense
;
61 if (( fight
-> strength
/ 2 ) == 0 )
67 mhit
= ( fight
-> strength
/ 2 ) +
68 ( rand () % ( fight
-> strength
/ 2 ) - ( ni
-> stats
-> getDefense ()));
74 mhit
= ((( battle
-> stats
-> getStrength ()) / 2 ) +
75 ( rand () % (( battle
-> stats
-> getStrength ())) / 2 ) -
76 ( ni
-> stats
-> getDefense ()));
79 hit
= ((( ni
-> stats
-> getStrength ()) / 2 ) +
80 ( rand () % (( ni
-> stats
-> getStrength ())) / 2 ) -
81 ( battle
-> stats
-> getDefense ()));
84 if (! player_fight ( ni
))
87 notice ( s_GameServ
, u
, "You attack \1f %s \1f for \ 2 %d \ 2 hp!", fight
-> name
. c_str (), hit
);
89 notice ( s_GameServ
, u
, "You miss \1f %s \1f completely!", fight
-> name
. c_str ());
93 if ( master_fight ( ni
) && ! dragon_fight ( ni
))
95 notice ( s_GameServ
, u
, "You have bested %s !" , fight
-> name
. c_str ());
96 addNews ( todaysnews
, " %s has bested %s and moved " \
97 "to level %d " , ni
-> stats
-> getName (). c_str (), fight
-> name
. c_str (),
98 ( ni
-> stats
-> getLevel () + 1 ));
101 notice ( s_GameServ
, u
, "You have killed \ 2 %s \ 2 !", fight
-> name
. c_str ());
103 notice ( s_GameServ
, u
, " %s " , fight
-> death
. c_str ());
104 notice ( s_GameServ
, u
, "You recieve \ 2 %d \ 2 experience and \ 2 %d \ 2 gold!",
105 fight
-> exp
, fight
-> gold
);
107 if ( dragon_fight ( ni
))
109 addNews ( todaysnews
, " %s is a true warrior! %s has beaten %s !!" \
110 " %s is now watching over the Dragon's lair!" ,
111 ni
-> stats
-> getName (). c_str (), ni
-> stats
-> getName (). c_str (),
112 ni
-> stats
-> getMonster ()-> name
. c_str (), ni
-> stats
-> getName (). c_str ());
113 dragon
. name
= "Dragon " + ni
-> stats
-> getName ();
114 dragon
. weapon
= "Breath of Fire" ;
115 dragon
. strength
= ni
-> stats
-> getStrength ();
116 dragon
. defense
= ni
-> stats
-> getDefense ();
117 dragon
. hp
= ni
-> stats
-> getMaxHP ();
118 dragon
. maxhp
= ni
-> stats
-> getMaxHP ();
120 clearDragonFight ( ni
-> stats
);
122 ni
-> stats
-> delMonster ();
126 ni
-> stats
-> addExp ( fight
-> exp
);
127 ni
-> stats
-> addGold ( fight
-> gold
);
129 if ( master_fight ( ni
))
131 notice ( s_GameServ
, u
, "You are now level %d !" , ni
-> stats
-> getLevel () + 1 );
132 notice ( s_GameServ
, u
, "You gain %d Strength, and %d Defense points!" ,
133 strbonus
[ ni
-> stats
-> getLevel () - 1 ], defbonus
[ ni
-> stats
-> getLevel () - 1 ]);
135 // Increase your level
137 // Increase your maximum hit points
138 ni
-> stats
-> addMaxHP ( hpbonus
[ ni
-> stats
-> getLevel () - 1 ]);
140 // Heal the player by setting hp to their max
141 ni
-> stats
-> healall ();
143 // Add to your strength
144 ni
-> stats
-> addStrength ( strbonus
[ ni
-> stats
-> getLevel () - 1 ]);
146 // Add to your defensive power
147 ni
-> stats
-> addDefense ( defbonus
[ ni
-> stats
-> getLevel () - 1 ]);
149 ni
-> stats
-> addLevel ( 1 );
153 // They're dead so remove the pointer
154 ni
-> stats
-> delMonster ();
156 // Clear the pointer for your master
157 ni
-> stats
-> delMaster ();
167 notice ( s_GameServ
, u
, "\1f %s \1f attacks with their \1f %s \1f for \ 2 %d \ 2 damage!",
168 fight
-> name
. c_str (), fight
-> weapon
. c_str (), mhit
);
171 notice ( s_GameServ
, u
, " %s completely misses you!" , fight
-> name
. c_str ());
173 if ( mhit
>= ni
-> stats
-> getHP ())
175 if (! master_fight ( ni
))
177 notice ( s_GameServ
, u
, "You have been \ 2 \1f killed\1f \ 2 by %s !" , fight
-> name
. c_str ());
178 notice ( s_GameServ
, u
, "You lose all gold on hand and lose 10 percent " \
179 "of your experience!" );
180 addNews ( todaysnews
, " %s has been killed by %s !" ,
181 ni
-> stats
-> getName (). c_str (), fight
-> name
. c_str ());
182 ni
-> stats
-> setGold ( 0 );
183 ni
-> stats
-> subtractExp (( long int )( ni
-> stats
-> getExp () * .10 ));
185 ni
-> stats
-> delMonster ();
186 clearAlive ( ni
-> stats
);
191 notice ( s_GameServ
, u
, " %s has bested you! You will have to wait " \
192 "until tomorrow to try again" , ni
-> stats
-> getMaster ()-> name
. c_str ());
193 addNews ( todaysnews
, " %s tried to best %s and failed!" ,
194 ni
-> stats
-> getName (). c_str (), fight
-> name
. c_str ());
195 ni
-> stats
-> delMonster ();
196 ni
-> stats
-> delMaster ();
203 ni
-> stats
-> subtractHP ( mhit
);
209 else if ( player_fight ( ni
))
211 if ( is_playing ( battle
))
213 if (! isYourTurn ( ni
-> stats
) && isYourTurn ( battle
-> stats
))
215 notice ( s_GameServ
, u
, "Please wait until %s decides what to do!" ,
216 battle
-> stats
-> getName (). c_str ());
219 else if (! isYourTurn ( ni
-> stats
) && ! isYourTurn ( battle
-> stats
))
221 // If somehow the player vs. player fight hangs, give the turn to the first attacker
222 setYourTurn ( ni
-> stats
);
226 notice ( s_GameServ
, u
, "You attack \1f %s \1f for \ 2 %d \ 2 points!", battle
-> stats
-> getName (). c_str (), hit
);
228 notice ( s_GameServ
, battle
-> getNick (), " %s has hit you with their %s for " \
229 "\ 2 %d \ 2 damage!", ni
-> stats
-> getName (). c_str (),
230 ( ni
-> stats
-> getWeapon () ? ni
-> stats
-> getWeapon ()-> getName (). c_str () : "Fists" ), hit
);
234 notice ( s_GameServ
, u
, "You miss \1f %s \1f completely!", battle
-> stats
-> getName (). c_str ());
235 notice ( s_GameServ
, battle
-> getNick (), " %s misses you completely!" , ni
-> stats
-> getName (). c_str ());
238 if ( hit
>= battle
-> stats
-> getHP ())
240 notice ( s_GameServ
, u
, "You have killed \ 2 %s \ 2 !", battle
-> stats
-> getName (). c_str ());
241 notice ( s_GameServ
, u
, "You recieve \ 2 %d \ 2 experience and \ 2 %l d\ 2 gold!" ,
242 ( long int )( battle
-> stats
-> getExp () * .10 ), battle
-> stats
-> getGold ());
243 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 */
244 notice ( s_GameServ
, battle
-> getNick (), "You have been killed by \ 2 %s \ 2 !",
245 ni
-> stats
-> getName (). c_str ());
246 battle
-> stats
-> setHP ( 0 );
247 clearAlive ( battle
-> stats
);
249 ni
-> stats
-> addHP (( long int )( battle
-> stats
-> getExp () * .10 ));
250 battle
-> stats
-> subtractExp (( long int )( battle
-> stats
-> getExp () * .10 ));
252 notice ( s_GameServ
, battle
-> getNick (), "You lose ten percent of experience and " \
253 "all gold on hand!" );
254 ni
-> stats
-> addGold ( battle
-> stats
-> getGold ());
255 battle
-> stats
-> setGold ( 0 );
258 clearYourTurn ( ni
-> stats
);
259 clearYourTurn ( battle
-> stats
);
261 battle
-> stats
-> delBattle ();
262 ni
-> stats
-> delBattle ();
268 battle
-> stats
-> subtractHP ( hit
);
270 clearYourTurn ( ni
-> stats
);
271 setYourTurn ( battle
-> stats
);
272 display_players ( battle
);
273 notice ( s_GameServ
, u
, "Please wait while %s decides what to do!" ,
274 battle
-> stats
-> getName (). c_str ());