… | |
… | |
158 | |
158 | |
159 | /* This loads the first map an puts the player on it. */ |
159 | /* This loads the first map an puts the player on it. */ |
160 | static void |
160 | static void |
161 | set_first_map (object *op) |
161 | set_first_map (object *op) |
162 | { |
162 | { |
163 | strcpy (op->contr->maplevel, first_map_path); |
163 | op->contr->maplevel = first_map_path; |
164 | op->x = -1; |
164 | op->x = -1; |
165 | op->y = -1; |
165 | op->y = -1; |
|
|
166 | } |
|
|
167 | |
|
|
168 | void |
|
|
169 | player::enter_map () |
|
|
170 | { |
|
|
171 | object *tmp = object::create (); |
|
|
172 | |
|
|
173 | EXIT_PATH (tmp) = maplevel; |
|
|
174 | EXIT_X (tmp) = ob->x; |
|
|
175 | EXIT_Y (tmp) = ob->y; |
166 | enter_exit (op, 0); |
176 | ob->enter_exit (tmp); |
|
|
177 | |
|
|
178 | tmp->destroy (); |
167 | } |
179 | } |
168 | |
180 | |
169 | // connect the player with a specific client |
181 | // connect the player with a specific client |
170 | // also changed, rationalises, and fixes some incorrect settings |
182 | // also changed, rationalises, and fixes some incorrect settings |
171 | void |
183 | void |
… | |
… | |
191 | |
203 | |
192 | ob->carrying = sum_weight (ob); |
204 | ob->carrying = sum_weight (ob); |
193 | link_player_skills (ob); |
205 | link_player_skills (ob); |
194 | |
206 | |
195 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
207 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
196 | update_ob_speed (ob); |
|
|
197 | |
208 | |
198 | assign (title, ob->arch->clone.name); |
209 | assign (title, ob->arch->clone.name); |
199 | |
210 | |
200 | /* can_use_shield is a new flag. However, the can_use.. seems to largely come |
211 | /* can_use_shield is a new flag. However, the can_use.. seems to largely come |
201 | * from the class, and not race. I don't see any way to get the class information |
212 | * from the class, and not race. I don't see any way to get the class information |
… | |
… | |
229 | add_friendly_object (ob); |
240 | add_friendly_object (ob); |
230 | |
241 | |
231 | LOG (llevInfo, "LOGIN: Player named %s from ip %s\n", &ob->name, ns->host); |
242 | LOG (llevInfo, "LOGIN: Player named %s from ip %s\n", &ob->name, ns->host); |
232 | |
243 | |
233 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
244 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
234 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &ob->name); |
|
|
235 | |
245 | |
236 | esrv_new_player (this, ob->weight + ob->carrying); |
246 | esrv_new_player (this, ob->weight + ob->carrying); |
237 | |
247 | |
238 | ob->update_stats (); |
248 | ob->update_stats (); |
239 | ns->floorbox_update (); |
249 | ns->floorbox_update (); |
240 | |
250 | |
241 | esrv_send_inventory (ob, ob); |
251 | esrv_send_inventory (ob, ob); |
242 | esrv_add_spells (this, 0); |
252 | esrv_add_spells (this, 0); |
243 | |
253 | |
244 | enter_exit (ob, 0); |
254 | ob->activate_recursive (); |
|
|
255 | enter_map (); |
245 | |
256 | |
246 | send_rules (ob); |
257 | send_rules (ob); |
247 | send_news (ob); |
258 | send_news (ob); |
248 | display_motd (ob); |
259 | display_motd (ob); |
|
|
260 | |
|
|
261 | INVOKE_PLAYER (CONNECT, this); |
249 | INVOKE_PLAYER (LOGIN, this); |
262 | INVOKE_PLAYER (LOGIN, this); |
250 | } |
263 | } |
251 | |
264 | |
252 | void |
265 | void |
253 | player::disconnect () |
266 | player::disconnect () |
254 | { |
267 | { |
|
|
268 | if (ob) |
|
|
269 | ob->deactivate_recursive (); |
|
|
270 | |
255 | //TODO: don't be so harsh and destroy :) |
271 | //TODO: don't be so harsh and destroy :) |
256 | if (ns) |
272 | if (ns) |
|
|
273 | { |
|
|
274 | if (enable_save) |
|
|
275 | { |
|
|
276 | INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); |
|
|
277 | save (true); |
|
|
278 | } |
|
|
279 | |
|
|
280 | INVOKE_PLAYER (DISCONNECT, this); |
|
|
281 | |
|
|
282 | client *ns = this->ns; |
|
|
283 | ns->send_packet ("goodbye"); |
|
|
284 | ns->flush (); |
|
|
285 | ns->pl = 0; |
|
|
286 | this->ns = 0; |
|
|
287 | |
|
|
288 | ns->destroy (); |
257 | destroy (); |
289 | destroy (); |
|
|
290 | } |
258 | } |
291 | } |
259 | |
292 | |
260 | // the need for this function can be explained |
293 | // the need for this function can be explained |
261 | // by load_object not returning the object |
294 | // by load_object not returning the object |
262 | void |
295 | void |
… | |
… | |
269 | ob->speed = 1.0; |
302 | ob->speed = 1.0; |
270 | ob->direction = 5; /* So player faces south */ |
303 | ob->direction = 5; /* So player faces south */ |
271 | ob->stats.wc = 2; |
304 | ob->stats.wc = 2; |
272 | ob->run_away = 25; /* Then we panick... */ |
305 | ob->run_away = 25; /* Then we panick... */ |
273 | |
306 | |
274 | set_first_map (ob); |
|
|
275 | |
|
|
276 | ob->roll_stats (); |
307 | ob->roll_stats (); |
277 | } |
308 | } |
278 | |
309 | |
279 | player::player () |
310 | player::player () |
280 | { |
311 | { |
281 | /* There are some elements we want initialized to non zero value - |
312 | /* There are some elements we want initialised to non zero value - |
282 | * we deal with that below this point. |
313 | * we deal with that below this point. |
283 | */ |
314 | */ |
284 | outputs_sync = 16; /* Every 2 seconds */ |
315 | outputs_sync = 16; /* Every 2 seconds */ |
285 | outputs_count = 8; /* Keeps present behaviour */ |
316 | outputs_count = 8; /* Keeps present behaviour */ |
286 | unapply = unapply_nochoice; |
317 | unapply = unapply_nochoice; |
287 | |
318 | |
288 | assign (savebed_map, first_map_path); /* Init. respawn position */ |
319 | savebed_map = first_map_path; /* Init. respawn position */ |
289 | |
320 | |
290 | gen_sp_armour = 10; |
321 | gen_sp_armour = 10; |
291 | last_speed = -1; |
322 | last_speed = -1; |
292 | shoottype = range_none; |
323 | shoottype = range_none; |
293 | bowtype = bow_normal; |
324 | bowtype = bow_normal; |
… | |
… | |
314 | } |
345 | } |
315 | |
346 | |
316 | void |
347 | void |
317 | player::do_destroy () |
348 | player::do_destroy () |
318 | { |
349 | { |
|
|
350 | disconnect (); |
|
|
351 | |
|
|
352 | save (false); |
|
|
353 | enable_save = false; |
|
|
354 | |
319 | attachable::do_destroy (); |
355 | attachable::do_destroy (); |
320 | |
|
|
321 | disconnect (); |
|
|
322 | |
356 | |
323 | terminate_all_pets (ob); |
357 | terminate_all_pets (ob); |
324 | |
358 | |
325 | if (first_player != this) |
359 | if (first_player != this) |
326 | { |
360 | { |
… | |
… | |
339 | } |
373 | } |
340 | else |
374 | else |
341 | first_player = next; |
375 | first_player = next; |
342 | |
376 | |
343 | if (ob) |
377 | if (ob) |
|
|
378 | { |
344 | ob->destroy (true); |
379 | ob->destroy_inv (false); |
345 | |
|
|
346 | if (ns) |
|
|
347 | { |
|
|
348 | client *ns = this->ns; |
|
|
349 | ns->send_packet ("goodbye"); |
|
|
350 | ns->flush (); |
|
|
351 | ns->pl = 0; |
|
|
352 | this->ns = 0; |
|
|
353 | ns->destroy (); |
380 | ob->destroy (); |
354 | } |
381 | } |
355 | } |
382 | } |
356 | |
383 | |
357 | player::~player () |
384 | player::~player () |
358 | { |
385 | { |
… | |
… | |
368 | player::create () |
395 | player::create () |
369 | { |
396 | { |
370 | player *pl = new player; |
397 | player *pl = new player; |
371 | |
398 | |
372 | pl->set_object (arch_to_object (get_player_archetype (0))); |
399 | pl->set_object (arch_to_object (get_player_archetype (0))); |
|
|
400 | set_first_map (pl->ob); |
373 | |
401 | |
374 | return pl; |
402 | return pl; |
375 | } |
403 | } |
376 | |
404 | |
377 | /* |
405 | /* |
… | |
… | |
843 | |
871 | |
844 | contr->orig_stats = stats; |
872 | contr->orig_stats = stats; |
845 | } |
873 | } |
846 | } |
874 | } |
847 | |
875 | |
|
|
876 | static void |
|
|
877 | start_info (object *op) |
|
|
878 | { |
|
|
879 | char buf[MAX_BUF]; |
|
|
880 | |
|
|
881 | sprintf (buf, "Welcome to Crossfire v%s!", VERSION); |
|
|
882 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
883 | //new_draw_info (NDI_UNIQUE, 0, op, "Press `?' for help"); |
|
|
884 | //new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
885 | } |
|
|
886 | |
848 | /* This function takes the key that is passed, and does the |
887 | /* This function takes the key that is passed, and does the |
849 | * appropriate action with it (change race, or other things). |
888 | * appropriate action with it (change race, or other things). |
850 | * The function name is for historical reasons - now we have |
889 | * The function name is for historical reasons - now we have |
851 | * separate race and class; this actually changes the RACE, |
890 | * separate race and class; this actually changes the RACE, |
852 | * not the class. |
891 | * not the class. |
… | |
… | |
897 | if (*first_map_ext_path) |
936 | if (*first_map_ext_path) |
898 | { |
937 | { |
899 | object *tmp; |
938 | object *tmp; |
900 | char mapname[MAX_BUF]; |
939 | char mapname[MAX_BUF]; |
901 | |
940 | |
902 | snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); |
941 | snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &op->arch->name); |
903 | tmp = object::create (); |
942 | tmp = object::create (); |
904 | EXIT_PATH (tmp) = mapname; |
943 | EXIT_PATH (tmp) = mapname; |
905 | EXIT_X (tmp) = op->x; |
944 | EXIT_X (tmp) = op->x; |
906 | EXIT_Y (tmp) = op->y; |
945 | EXIT_Y (tmp) = op->y; |
907 | enter_exit (op, tmp); /* we don't really care if it succeeded; |
946 | op->enter_exit (tmp); /* we don't really care if it succeeded; |
908 | * if the map isn't there, then stay on the |
947 | * if the map isn't there, then stay on the |
909 | * default initial map */ |
948 | * default initial map */ |
910 | tmp->destroy (); |
949 | tmp->destroy (); |
911 | } |
950 | } |
912 | else |
951 | else |
… | |
… | |
969 | INVOKE_PLAYER (QUIT, op->contr); |
1008 | INVOKE_PLAYER (QUIT, op->contr); |
970 | |
1009 | |
971 | op->contr->enable_save = false; |
1010 | op->contr->enable_save = false; |
972 | |
1011 | |
973 | terminate_all_pets (op); |
1012 | terminate_all_pets (op); |
974 | leave_map (op); |
1013 | op->remove (); |
975 | op->direction = 0; |
1014 | op->direction = 0; |
976 | new_draw_info_format (NDI_UNIQUE | NDI_ALL, 5, NULL, "%s quits the game.", &op->name); |
1015 | new_draw_info_format (NDI_UNIQUE | NDI_ALL, 5, NULL, "%s quits the game.", &op->name); |
977 | |
1016 | |
978 | strcpy (op->contr->killer, "quit"); |
1017 | strcpy (op->contr->killer, "quit"); |
979 | check_score (op); |
1018 | check_score (op); |
980 | op->contr->party = 0; |
1019 | op->contr->party = 0; |
981 | op->contr->own_title[0] = '\0'; |
1020 | op->contr->own_title[0] = '\0'; |
982 | |
|
|
983 | object_ptr ob = op; |
|
|
984 | |
|
|
985 | /* We need to hunt for any per player unique maps in memory and |
|
|
986 | * get rid of them. The trailing slash in the path is intentional, |
|
|
987 | * so that players named 'Ab' won't match against players 'Abe' pathname |
|
|
988 | */ |
|
|
989 | char buf[MAX_BUF]; |
|
|
990 | sprintf (buf, "%s/%s/%s/", settings.localdir, settings.playerdir, &op->name); |
|
|
991 | |
|
|
992 | for (maptile *next, *mp = first_map; mp; mp = next) |
|
|
993 | { |
|
|
994 | next = mp->next; |
|
|
995 | |
|
|
996 | if (!strncmp (mp->path, buf, strlen (buf))) |
|
|
997 | delete_map (mp); |
|
|
998 | } |
|
|
999 | |
|
|
1000 | delete_character (ob->name, 1); |
|
|
1001 | ob->contr->destroy (); |
1021 | op->contr->destroy (); |
1002 | |
1022 | |
1003 | return 1; |
1023 | return 1; |
1004 | } |
1024 | } |
1005 | |
1025 | |
1006 | void |
1026 | void |
… | |
… | |
1662 | return 0; |
1682 | return 0; |
1663 | } |
1683 | } |
1664 | |
1684 | |
1665 | arrow->set_owner (op); |
1685 | arrow->set_owner (op); |
1666 | arrow->skill = bow->skill; |
1686 | arrow->skill = bow->skill; |
1667 | |
|
|
1668 | arrow->direction = dir; |
1687 | arrow->direction = dir; |
1669 | arrow->x = sx; |
|
|
1670 | arrow->y = sy; |
|
|
1671 | |
1688 | |
1672 | if (op->type == PLAYER) |
1689 | if (op->type == PLAYER) |
1673 | { |
1690 | { |
1674 | op->speed_left = 0.01 - (float) FABS (op->speed) * 100 / bowspeed; |
1691 | op->speed_left = 0.01 - (float) FABS (op->speed) * 100 / bowspeed; |
1675 | op->update_stats (); |
1692 | op->update_stats (); |
… | |
… | |
1690 | |
1707 | |
1691 | /* update the speed */ |
1708 | /* update the speed */ |
1692 | arrow->speed = (float) ((QUERY_FLAG (bow, FLAG_NO_STRENGTH) ? |
1709 | arrow->speed = (float) ((QUERY_FLAG (bow, FLAG_NO_STRENGTH) ? |
1693 | 0 : dam_bonus[op->stats.Str]) + bow->magic + arrow->magic) / 5.0 + (float) bow->stats.dam / 7.0; |
1710 | 0 : dam_bonus[op->stats.Str]) + bow->magic + arrow->magic) / 5.0 + (float) bow->stats.dam / 7.0; |
1694 | |
1711 | |
1695 | if (arrow->speed < 1.0) |
1712 | arrow->set_speed (max (arrow->speed, 1.0)); |
1696 | arrow->speed = 1.0; |
|
|
1697 | update_ob_speed (arrow); |
|
|
1698 | arrow->speed_left = 0; |
1713 | arrow->speed_left = 0; |
1699 | |
1714 | |
1700 | if (op->type == PLAYER) |
1715 | if (op->type == PLAYER) |
1701 | { |
1716 | { |
1702 | arrow->stats.wc = 20 - bow->magic - arrow->magic - |
1717 | arrow->stats.wc = 20 - bow->magic - arrow->magic - |
… | |
… | |
1715 | arrow->attacktype |= bow->attacktype; |
1730 | arrow->attacktype |= bow->attacktype; |
1716 | |
1731 | |
1717 | if (bow->slaying) |
1732 | if (bow->slaying) |
1718 | arrow->slaying = bow->slaying; |
1733 | arrow->slaying = bow->slaying; |
1719 | |
1734 | |
1720 | arrow->map = m; |
|
|
1721 | arrow->move_type = MOVE_FLY_LOW; |
1735 | arrow->move_type = MOVE_FLY_LOW; |
1722 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1736 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1723 | |
1737 | |
1724 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1738 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1725 | insert_ob_in_map (arrow, m, op, 0); |
1739 | m->insert (arrow, sx, sy, op); |
1726 | |
1740 | |
1727 | if (!arrow->destroyed ()) |
1741 | if (!arrow->destroyed ()) |
1728 | move_arrow (arrow); |
1742 | move_arrow (arrow); |
1729 | |
1743 | |
1730 | if (op->type == PLAYER) |
1744 | if (op->type == PLAYER) |
… | |
… | |
1756 | } |
1770 | } |
1757 | else if (op->contr->bowtype >= bow_n && op->contr->bowtype <= bow_nw) |
1771 | else if (op->contr->bowtype >= bow_n && op->contr->bowtype <= bow_nw) |
1758 | { |
1772 | { |
1759 | if (!similar_direction (dir, op->contr->bowtype - bow_n + 1)) |
1773 | if (!similar_direction (dir, op->contr->bowtype - bow_n + 1)) |
1760 | wcmod = -1; |
1774 | wcmod = -1; |
|
|
1775 | |
1761 | ret = fire_bow (op, op, NULL, op->contr->bowtype - bow_n + 1, wcmod, op->x, op->y); |
1776 | ret = fire_bow (op, op, NULL, op->contr->bowtype - bow_n + 1, wcmod, op->x, op->y); |
1762 | } |
1777 | } |
1763 | else if (op->contr->bowtype == bow_threewide) |
1778 | else if (op->contr->bowtype == bow_threewide) |
1764 | { |
1779 | { |
1765 | ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1780 | ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
… | |
… | |
1835 | |
1850 | |
1836 | if (item->arch) |
1851 | if (item->arch) |
1837 | { |
1852 | { |
1838 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1853 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1839 | item->face = item->arch->clone.face; |
1854 | item->face = item->arch->clone.face; |
1840 | item->speed = 0; |
1855 | item->set_speed (0); |
1841 | update_ob_speed (item); |
|
|
1842 | } |
1856 | } |
|
|
1857 | |
1843 | if ((tmp = item->in_player ())) |
1858 | if ((tmp = item->in_player ())) |
1844 | esrv_update_item (UPD_ANIM, tmp, item); |
1859 | esrv_update_item (UPD_ANIM, tmp, item); |
1845 | } |
1860 | } |
1846 | } |
1861 | } |
1847 | else if (item->type == ROD || item->type == HORN) |
1862 | else if (item->type == ROD || item->type == HORN) |
1848 | { |
|
|
1849 | drain_rod_charge (item); |
1863 | drain_rod_charge (item); |
1850 | } |
|
|
1851 | } |
1864 | } |
1852 | } |
1865 | } |
1853 | |
1866 | |
1854 | /* Received a fire command for the player - go and do it. |
1867 | /* Received a fire command for the player - go and do it. |
1855 | */ |
1868 | */ |
… | |
… | |
2339 | |
2352 | |
2340 | /* call this here - we also will call this in do_ericserver, but |
2353 | /* call this here - we also will call this in do_ericserver, but |
2341 | * the players time has been increased when doericserver has been |
2354 | * the players time has been increased when doericserver has been |
2342 | * called, so we recheck it here. |
2355 | * called, so we recheck it here. |
2343 | */ |
2356 | */ |
2344 | //TODO: better than handling 8 commands, use some more intelligent rate-limiting |
2357 | op->contr->ns->handle_command (); |
2345 | for (int rep = 8; --rep && op->contr->ns->handle_command (); ) |
|
|
2346 | ; |
|
|
2347 | |
2358 | |
2348 | if (op->speed_left < 0) |
2359 | if (op->speed_left < 0) |
2349 | return 0; |
2360 | return 0; |
2350 | |
2361 | |
2351 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2362 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
… | |
… | |
2411 | { |
2422 | { |
2412 | object *next; |
2423 | object *next; |
2413 | |
2424 | |
2414 | while (op) |
2425 | while (op) |
2415 | { |
2426 | { |
2416 | next = op->below; /* Make sure we have a good value, in case |
2427 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2417 | * we remove object 'op' |
2428 | |
2418 | */ |
|
|
2419 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2429 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2420 | { |
2430 | { |
2421 | op->remove (); |
|
|
2422 | op->x = env->x; |
|
|
2423 | op->y = env->y; |
|
|
2424 | if (env->type == PLAYER) |
2431 | if (env->type == PLAYER) |
2425 | esrv_del_item (env->contr, op->count); |
2432 | esrv_del_item (env->contr, op->count); |
2426 | insert_ob_in_map (op, env->map, NULL, 0); |
2433 | |
|
|
2434 | op->insert_at (env); |
2427 | } |
2435 | } |
2428 | else if (op->inv) |
2436 | else if (op->inv) |
2429 | remove_unpaid_objects (op->inv, env); |
2437 | remove_unpaid_objects (op->inv, env); |
2430 | |
2438 | |
2431 | op = next; |
2439 | op = next; |
… | |
… | |
2724 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); |
2732 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); |
2725 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); |
2733 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); |
2726 | |
2734 | |
2727 | /* restore player */ |
2735 | /* restore player */ |
2728 | at = archetype::find ("poisoning"); |
2736 | at = archetype::find ("poisoning"); |
2729 | tmp = present_arch_in_ob (at, op); |
2737 | if (object *tmp = present_arch_in_ob (at, op)) |
2730 | if (tmp) |
|
|
2731 | { |
2738 | { |
2732 | tmp->destroy (); |
2739 | tmp->destroy (); |
2733 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2740 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2734 | } |
2741 | } |
2735 | |
2742 | |
2736 | at = archetype::find ("confusion"); |
2743 | at = archetype::find ("confusion"); |
2737 | tmp = present_arch_in_ob (at, op); |
2744 | if (object *tmp = present_arch_in_ob (at, op)) |
2738 | if (tmp) |
|
|
2739 | { |
2745 | { |
2740 | tmp->destroy (); |
2746 | tmp->destroy (); |
2741 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2747 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2742 | } |
2748 | } |
2743 | |
2749 | |
… | |
… | |
2745 | op->stats.hp = op->stats.maxhp; |
2751 | op->stats.hp = op->stats.maxhp; |
2746 | if (op->stats.food <= 0) |
2752 | if (op->stats.food <= 0) |
2747 | op->stats.food = 999; |
2753 | op->stats.food = 999; |
2748 | |
2754 | |
2749 | /* create a bodypart-trophy to make the winner happy */ |
2755 | /* create a bodypart-trophy to make the winner happy */ |
2750 | tmp = arch_to_object (archetype::find ("finger")); |
2756 | if (object *tmp = arch_to_object (archetype::find ("finger"))) |
2751 | if (tmp != NULL) |
|
|
2752 | { |
2757 | { |
2753 | sprintf (buf, "%s's finger", &op->name); |
2758 | sprintf (buf, "%s's finger", &op->name); |
2754 | tmp->name = buf; |
2759 | tmp->name = buf; |
2755 | sprintf (buf, " This finger has been cut off %s\n" |
2760 | sprintf (buf, " This finger has been cut off %s\n" |
2756 | " the %s, when he was defeated at\n level %d by %s.\n", |
2761 | " the %s, when he was defeated at\n level %d by %s.\n", |
2757 | &op->name, op->contr->title, (int) (op->level), op->contr->killer); |
2762 | &op->name, op->contr->title, (int) (op->level), op->contr->killer); |
2758 | tmp->msg = buf; |
2763 | tmp->msg = buf; |
2759 | tmp->value = 0, tmp->material = 0, tmp->type = 0; |
2764 | tmp->value = 0, tmp->material = 0, tmp->type = 0; |
2760 | tmp->materialname = NULL; |
2765 | tmp->materialname = NULL; |
2761 | tmp->x = op->x, tmp->y = op->y; |
2766 | op->insert_at (tmp, op); |
2762 | insert_ob_in_map (tmp, op->map, op, 0); |
|
|
2763 | } |
2767 | } |
2764 | |
2768 | |
2765 | /* teleport defeated player to new destination */ |
2769 | /* teleport defeated player to new destination */ |
2766 | transfer_ob (op, x, y, 0, NULL); |
2770 | transfer_ob (op, x, y, 0, NULL); |
2767 | op->contr->braced = 0; |
2771 | op->contr->braced = 0; |
… | |
… | |
2793 | op->stats.hp = op->stats.maxhp; |
2797 | op->stats.hp = op->stats.maxhp; |
2794 | return; |
2798 | return; |
2795 | } |
2799 | } |
2796 | sprintf (buf, "%s died.", &op->name); |
2800 | sprintf (buf, "%s died.", &op->name); |
2797 | } |
2801 | } |
|
|
2802 | |
2798 | play_sound_player_only (op->contr, SOUND_PLAYER_DIES, 0, 0); |
2803 | play_sound_player_only (op->contr, SOUND_PLAYER_DIES, 0, 0); |
2799 | |
2804 | |
2800 | /* save the map location for corpse, gravestone */ |
2805 | /* save the map location for corpse, gravestone */ |
2801 | x = op->x; |
2806 | x = op->x; |
2802 | y = op->y; |
2807 | y = op->y; |
2803 | map = op->map; |
2808 | map = op->map; |
2804 | |
|
|
2805 | |
2809 | |
2806 | /* NOT_PERMADEATH code. This basically brings the character back to |
2810 | /* NOT_PERMADEATH code. This basically brings the character back to |
2807 | * life if they are dead - it takes some exp and a random stat. |
2811 | * life if they are dead - it takes some exp and a random stat. |
2808 | * See the config.h file for a little more in depth detail about this. |
2812 | * See the config.h file for a little more in depth detail about this. |
2809 | */ |
2813 | */ |
… | |
… | |
2826 | num_stats_lose = 1; |
2830 | num_stats_lose = 1; |
2827 | else |
2831 | else |
2828 | num_stats_lose = 1 + op->level / BALSL_NUMBER_LOSSES_RATIO; |
2832 | num_stats_lose = 1 + op->level / BALSL_NUMBER_LOSSES_RATIO; |
2829 | } |
2833 | } |
2830 | else |
2834 | else |
2831 | { |
|
|
2832 | num_stats_lose = 1; |
2835 | num_stats_lose = 1; |
2833 | } |
2836 | |
2834 | lost_a_stat = 0; |
2837 | lost_a_stat = 0; |
2835 | |
2838 | |
2836 | for (z = 0; z < num_stats_lose; z++) |
2839 | for (z = 0; z < num_stats_lose; z++) |
2837 | { |
2840 | { |
2838 | i = RANDOM () % NUM_STATS; |
2841 | i = RANDOM () % NUM_STATS; |
… | |
… | |
3321 | if (pl->type != PLAYER) |
3324 | if (pl->type != PLAYER) |
3322 | { |
3325 | { |
3323 | LOG (llevError, "player_can_view() called for non-player object\n"); |
3326 | LOG (llevError, "player_can_view() called for non-player object\n"); |
3324 | return -1; |
3327 | return -1; |
3325 | } |
3328 | } |
|
|
3329 | |
3326 | if (!pl || !op) |
3330 | if (!pl || !op) |
3327 | return 0; |
3331 | return 0; |
3328 | |
3332 | |
3329 | if (op->head) |
|
|
3330 | { |
|
|
3331 | op = op->head; |
3333 | op = op->head_ (); |
3332 | } |
3334 | |
3333 | get_rangevector (pl, op, &rv, 0x1); |
3335 | get_rangevector (pl, op, &rv, 0x1); |
3334 | |
3336 | |
3335 | /* starting with the 'head' part, lets loop |
3337 | /* starting with the 'head' part, lets loop |
3336 | * through the object and find if it has any |
3338 | * through the object and find if it has any |
3337 | * part that is in the los array but isnt on |
3339 | * part that is in the los array but isnt on |
… | |
… | |
3467 | if (trlist == NULL || who->type != PLAYER) |
3469 | if (trlist == NULL || who->type != PLAYER) |
3468 | return; |
3470 | return; |
3469 | |
3471 | |
3470 | for (i = 0, tr = trlist->items; tr != NULL && i < level - 1; tr = tr->next, i++); |
3472 | for (i = 0, tr = trlist->items; tr != NULL && i < level - 1; tr = tr->next, i++); |
3471 | |
3473 | |
3472 | if (tr == NULL || tr->item == NULL) |
3474 | if (!tr || !tr->item) |
3473 | { |
3475 | { |
3474 | /* LOG(llevDebug, "-> no more treasure for %s\n", change_resist_msg[atnr]); */ |
3476 | /* LOG(llevDebug, "-> no more treasure for %s\n", change_resist_msg[atnr]); */ |
3475 | return; |
3477 | return; |
3476 | } |
3478 | } |
3477 | |
3479 | |