1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
132 | void |
132 | void |
133 | send_party_message (object *op, const char *msg) |
133 | send_party_message (object *op, const char *msg) |
134 | { |
134 | { |
135 | for_all_players (pl) |
135 | for_all_players (pl) |
136 | if (pl->ob->contr->party == op->contr->party && pl->ob != op) |
136 | if (pl->ob->contr->party == op->contr->party && pl->ob != op) |
137 | new_draw_info (NDI_WHITE, 0, pl->ob, msg); |
137 | pl->send_msg (NDI_UNIQUE, MSG_CHANNEL ("party"), msg); |
138 | } |
138 | } |
139 | |
139 | |
140 | void |
140 | void |
141 | receive_party_password (object *op, char k) |
141 | receive_party_password (object *op, char k) |
142 | { |
142 | { |
… | |
… | |
178 | } |
178 | } |
179 | |
179 | |
180 | int |
180 | int |
181 | command_party (object *op, char *params) |
181 | command_party (object *op, char *params) |
182 | { |
182 | { |
183 | dynbuf_text buf; |
183 | dynbuf_text &buf = msg_dynbuf; buf.clear (); |
|
|
184 | |
184 | partylist *party = op->contr->party; |
185 | partylist *party = op->contr->party; |
185 | |
186 | |
186 | if (!params) |
187 | if (!params) |
187 | params = (char *)""; |
188 | params = (char *)""; |
188 | |
189 | |
189 | if (!strcmp (params, "help")) |
190 | if (!strcmp (params, "help")) |
|
|
191 | buf << "\n" |
190 | buf << "To form a party type: C<party form> <partyname>\n\n" |
192 | " - To form a party type: C<party form> <partyname>\n" |
191 | "To join a party type: C<party join> <partyname>\n\n" |
193 | " - To join a party type: C<party join> <partyname>\n" |
192 | "If the party has a passwd, it will you prompt you for it.\n\n" |
194 | " - If the party has a passwd, it will you prompt you for it.\n" |
193 | "For a list of current parties type: C<party list>\n\n" |
195 | " - For a list of current parties type: C<party list>\n" |
194 | "To leave a party type: C<party leave>\n\n" |
196 | " - To leave a party type: C<party leave>\n" |
195 | "To change a passwd for a party type: C<party passwd> <password>\n\n" |
197 | " - To change a passwd for a party type: C<party passwd> <password>\n" |
196 | "There is an 8 character max\n\n" |
198 | " - There is an 8 character max\n" |
197 | "To talk to party members type: C<party say> <msg>\n\n" |
199 | " - To talk to party members type: C<party say> <msg>\n" |
198 | "To see who is in your party: C<party who>\n\n" |
200 | " - To see who is in your party: C<party who>\n" |
199 | "To see what you've killed, type: C<party kills>"; |
201 | " - To see what you've killed, type: C<party kills>\n"; |
200 | else if (strncmp (params, "form ", 5) == 0) |
202 | else if (strncmp (params, "form ", 5) == 0) |
201 | { |
203 | { |
202 | params += 5; |
204 | params += 5; |
203 | |
205 | |
204 | if (party) |
206 | if (party) |
… | |
… | |
287 | buf << "You haven't killed anything yet."; |
289 | buf << "You haven't killed anything yet."; |
288 | else |
290 | else |
289 | { |
291 | { |
290 | int max = min (party->kills - 1, PARTY_KILL_LOG - 1); |
292 | int max = min (party->kills - 1, PARTY_KILL_LOG - 1); |
291 | |
293 | |
292 | buf << "Killed | Killer| Exp\n\n" |
294 | buf << " Killed | Killer| Exp\n" |
293 | << "----------------+----------------+--------\n\n"; |
295 | << " ----------------+----------------+--------\n"; |
294 | |
296 | |
295 | for (int i = 0; i <= max; i++) |
297 | for (int i = 0; i <= max; i++) |
296 | { |
298 | { |
297 | sint64 exp = party->party_kills[i].exp; |
299 | sint64 exp = party->party_kills[i].exp; |
298 | char suffix = ' '; |
300 | char suffix = ' '; |
… | |
… | |
305 | { |
307 | { |
306 | exp /= 1000; |
308 | exp /= 1000; |
307 | suffix = 'k'; |
309 | suffix = 'k'; |
308 | } |
310 | } |
309 | |
311 | |
310 | buf.printf ("%16s|%16s|%6.1f%c\n\n", party->party_kills[i].dead, party->party_kills[i].killer, (double)exp, suffix); |
312 | buf.printf (" %16s|%16s|%6.1f%c\n", party->party_kills[i].dead, party->party_kills[i].killer, (double)exp, suffix); |
311 | } |
313 | } |
312 | |
314 | |
313 | buf << "----------------+----------------+--------\n\n"; |
315 | buf << " ----------------+----------------+--------\n"; |
314 | |
316 | |
315 | { |
317 | { |
316 | sint64 exp = party->total_exp; |
318 | sint64 exp = party->total_exp; |
317 | char suffix = ' '; |
319 | char suffix = ' '; |
318 | |
320 | |
… | |
… | |
325 | { |
327 | { |
326 | exp /= 1000; |
328 | exp /= 1000; |
327 | suffix = 'k'; |
329 | suffix = 'k'; |
328 | } |
330 | } |
329 | |
331 | |
330 | buf.printf ("Totals: %d kills, %.1f%c exp", party->kills, (double)exp, suffix); |
332 | buf.printf (" Totals: %d kills, %.1f%c exp", party->kills, (double)exp, suffix); |
331 | } |
333 | } |
332 | } |
334 | } |
333 | } |
335 | } |
334 | else if (strncmp (params, "say ", 4) == 0) |
336 | else if (strncmp (params, "say ", 4) == 0) |
335 | { |
337 | { |
… | |
… | |
352 | op->contr->party = 0; |
354 | op->contr->party = 0; |
353 | obsolete_parties (); |
355 | obsolete_parties (); |
354 | } |
356 | } |
355 | else if (strcmp (params, "who") == 0) |
357 | else if (strcmp (params, "who") == 0) |
356 | { |
358 | { |
357 | buf << "Members of party " << party->partyname << ".\n\n"; |
359 | buf << "Members of party " << party->partyname << ".\n"; |
358 | |
360 | |
359 | for_all_players (pl) |
361 | for_all_players (pl) |
360 | if (pl->ob->contr->party == party) |
362 | if (pl->ob->contr->party == party) |
361 | buf.printf ("%s/%d %s", &pl->ob->name, pl->ob->level, |
363 | buf.printf (" - %s/%d %s\n\n", &pl->ob->name, pl->ob->level, |
362 | *pl->ob->contr->own_title ? pl->ob->contr->own_title : pl->ob->contr->title); |
364 | *pl->ob->contr->own_title ? pl->ob->contr->own_title : pl->ob->contr->title); |
363 | } |
365 | } |
364 | else if (strncmp (params, "passwd ", 7) == 0) |
366 | else if (strncmp (params, "passwd ", 7) == 0) |
365 | { |
367 | { |
366 | params += 7; |
368 | params += 7; |
… | |
… | |
375 | } |
377 | } |
376 | else |
378 | else |
377 | buf << "I did not understand your command. For help try: C<party help>"; |
379 | buf << "I did not understand your command. For help try: C<party help>"; |
378 | |
380 | |
379 | reply: |
381 | reply: |
380 | op->contr->send_msg (NDI_UNIQUE | NDI_REPLY, MSG_CHANNEL("party"), buf); |
382 | op->contr->send_msg (NDI_UNIQUE | NDI_REPLY, MSG_CHANNEL ("party"), buf); |
381 | |
383 | |
382 | return 1; |
384 | return 1; |
383 | } |
385 | } |