… | |
… | |
34 | #include <functional> |
34 | #include <functional> |
35 | |
35 | |
36 | player * |
36 | player * |
37 | find_player (const char *plname) |
37 | find_player (const char *plname) |
38 | { |
38 | { |
39 | player *pl; |
39 | for_all_players (pl) |
40 | |
|
|
41 | for (pl = first_player; pl; pl = pl->next) |
|
|
42 | if (pl->ob && !strcmp (query_name (pl->ob), plname)) |
40 | if (pl->ob && !strcmp (query_name (pl->ob), plname)) |
43 | return pl; |
41 | return pl; |
44 | |
42 | |
45 | return 0; |
43 | return 0; |
46 | } |
44 | } |
… | |
… | |
160 | |
158 | |
161 | /* This loads the first map an puts the player on it. */ |
159 | /* This loads the first map an puts the player on it. */ |
162 | static void |
160 | static void |
163 | set_first_map (object *op) |
161 | set_first_map (object *op) |
164 | { |
162 | { |
165 | strcpy (op->contr->maplevel, first_map_path); |
163 | op->contr->maplevel = first_map_path; |
166 | op->x = -1; |
164 | op->x = -1; |
167 | 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; |
168 | enter_exit (op, 0); |
176 | ob->enter_exit (tmp); |
169 | } |
|
|
170 | |
177 | |
|
|
178 | tmp->destroy (); |
|
|
179 | } |
|
|
180 | |
|
|
181 | // connect the player with a specific client |
|
|
182 | // also changed, rationalises, and fixes some incorrect settings |
171 | void |
183 | void |
172 | player::connect (client *ns) |
184 | player::connect (client *ns) |
173 | { |
185 | { |
174 | this->ns = ns; |
186 | this->ns = ns; |
175 | ns->pl = this; |
187 | ns->pl = this; |
… | |
… | |
180 | ns->update_look = 0; |
192 | ns->update_look = 0; |
181 | ns->look_position = 0; |
193 | ns->look_position = 0; |
182 | |
194 | |
183 | clear_los (ob); |
195 | clear_los (ob); |
184 | |
196 | |
|
|
197 | /* make sure he's a player -- needed because of class change. */ |
185 | ob->type = PLAYER; // we are paranoid |
198 | ob->type = PLAYER; // we are paranoid |
186 | ob->race = ob->arch->clone.race; |
199 | ob->race = ob->arch->clone.race; |
187 | |
200 | |
188 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
201 | if (!legal_range (ob, shoottype)) |
189 | ob->update_stats (); |
202 | shoottype = range_none; |
190 | update_ob_speed (ob); |
|
|
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 | if (!legal_range (ob, shoottype)) |
207 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
196 | shoottype = range_none; |
|
|
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 | |
|
|
246 | esrv_new_player (this, ob->weight + ob->carrying); |
|
|
247 | |
|
|
248 | ob->update_stats (); |
236 | ns->floorbox_update (); |
249 | ns->floorbox_update (); |
237 | |
250 | |
238 | esrv_new_player (this, ob->weight + ob->carrying); |
|
|
239 | esrv_send_inventory (ob, ob); |
251 | esrv_send_inventory (ob, ob); |
240 | esrv_add_spells (this, 0); |
252 | esrv_add_spells (this, 0); |
241 | |
253 | |
242 | enter_exit (ob, 0); |
254 | ob->activate_recursive (); |
|
|
255 | enter_map (); |
243 | |
256 | |
244 | // send_rules (ob);//TODO |
257 | send_rules (ob); |
245 | // send_news (ob);//TODO |
258 | send_news (ob); |
246 | // display_motd (ob);//TODO |
259 | display_motd (ob); |
|
|
260 | |
|
|
261 | INVOKE_PLAYER (CONNECT, this); |
247 | INVOKE_PLAYER (LOGIN, this); |
262 | INVOKE_PLAYER (LOGIN, this); |
|
|
263 | } |
|
|
264 | |
|
|
265 | void |
|
|
266 | player::disconnect () |
|
|
267 | { |
|
|
268 | if (ob) |
|
|
269 | ob->deactivate_recursive (); |
|
|
270 | |
|
|
271 | //TODO: don't be so harsh and destroy :) |
|
|
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 (); |
|
|
289 | destroy (); |
|
|
290 | } |
248 | } |
291 | } |
249 | |
292 | |
250 | // the need for this function can be explained |
293 | // the need for this function can be explained |
251 | // by load_object not returning the object |
294 | // by load_object not returning the object |
252 | void |
295 | void |
… | |
… | |
259 | ob->speed = 1.0; |
302 | ob->speed = 1.0; |
260 | ob->direction = 5; /* So player faces south */ |
303 | ob->direction = 5; /* So player faces south */ |
261 | ob->stats.wc = 2; |
304 | ob->stats.wc = 2; |
262 | ob->run_away = 25; /* Then we panick... */ |
305 | ob->run_away = 25; /* Then we panick... */ |
263 | |
306 | |
264 | set_first_map (ob); |
|
|
265 | |
|
|
266 | ob->roll_stats (); |
307 | ob->roll_stats (); |
267 | } |
308 | } |
268 | |
309 | |
269 | player::player () |
310 | player::player () |
270 | { |
311 | { |
271 | /* There are some elements we want initialized to non zero value - |
312 | /* There are some elements we want initialised to non zero value - |
272 | * we deal with that below this point. |
313 | * we deal with that below this point. |
273 | */ |
314 | */ |
274 | outputs_sync = 16; /* Every 2 seconds */ |
315 | outputs_sync = 16; /* Every 2 seconds */ |
275 | outputs_count = 8; /* Keeps present behaviour */ |
316 | outputs_count = 8; /* Keeps present behaviour */ |
276 | unapply = unapply_nochoice; |
317 | unapply = unapply_nochoice; |
277 | |
318 | |
278 | assign (savebed_map, first_map_path); /* Init. respawn position */ |
319 | savebed_map = first_map_path; /* Init. respawn position */ |
279 | |
320 | |
280 | gen_sp_armour = 10; |
321 | gen_sp_armour = 10; |
281 | last_speed = -1; |
322 | last_speed = -1; |
282 | shoottype = range_none; |
323 | shoottype = range_none; |
283 | bowtype = bow_normal; |
324 | bowtype = bow_normal; |
… | |
… | |
301 | |
342 | |
302 | last_stats.exp = -1; |
343 | last_stats.exp = -1; |
303 | last_weight = (uint32) - 1; |
344 | last_weight = (uint32) - 1; |
304 | } |
345 | } |
305 | |
346 | |
306 | player::~player () |
347 | void |
|
|
348 | player::do_destroy () |
307 | { |
349 | { |
|
|
350 | disconnect (); |
|
|
351 | |
|
|
352 | save (false); |
|
|
353 | enable_save = false; |
|
|
354 | |
|
|
355 | attachable::do_destroy (); |
|
|
356 | |
308 | terminate_all_pets (ob); |
357 | terminate_all_pets (ob); |
309 | |
358 | |
310 | if (first_player != this) |
359 | if (first_player != this) |
311 | { |
360 | { |
312 | player *prev = first_player; |
361 | player *prev = first_player; |
… | |
… | |
325 | else |
374 | else |
326 | first_player = next; |
375 | first_player = next; |
327 | |
376 | |
328 | if (ob) |
377 | if (ob) |
329 | { |
378 | { |
330 | ob->contr = 0; |
379 | ob->destroy_inv (false); |
331 | ob->destroy (1); |
380 | ob->destroy (); |
332 | } |
|
|
333 | |
|
|
334 | if (ns) |
|
|
335 | { |
381 | } |
336 | ns->send_packet ("goodbye"); |
382 | } |
337 | ns->flush (); |
|
|
338 | ns->pl = 0; |
|
|
339 | ns->destroy (); |
|
|
340 | } |
|
|
341 | |
383 | |
|
|
384 | player::~player () |
|
|
385 | { |
342 | /* Clear item stack */ |
386 | /* Clear item stack */ |
343 | free (stack_items); |
387 | free (stack_items); |
344 | } |
388 | } |
345 | |
389 | |
346 | /* Tries to add player on the connection passed in ns. |
390 | /* Tries to add player on the connection passed in ns. |
… | |
… | |
351 | player::create () |
395 | player::create () |
352 | { |
396 | { |
353 | player *pl = new player; |
397 | player *pl = new player; |
354 | |
398 | |
355 | 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); |
356 | |
401 | |
357 | return pl; |
402 | return pl; |
358 | } |
403 | } |
359 | |
404 | |
360 | /* |
405 | /* |
… | |
… | |
387 | |
432 | |
388 | object * |
433 | object * |
389 | get_nearest_player (object *mon) |
434 | get_nearest_player (object *mon) |
390 | { |
435 | { |
391 | object *op = NULL; |
436 | object *op = NULL; |
392 | player *pl = NULL; |
|
|
393 | objectlink *ol; |
437 | objectlink *ol; |
394 | unsigned lastdist; |
438 | unsigned lastdist; |
395 | rv_vector rv; |
439 | rv_vector rv; |
396 | |
440 | |
397 | for (ol = first_friendly_object, lastdist = 1000; ol != NULL; ol = ol->next) |
441 | for (ol = first_friendly_object, lastdist = 1000; ol != NULL; ol = ol->next) |
… | |
… | |
429 | { |
473 | { |
430 | op = ol->ob; |
474 | op = ol->ob; |
431 | lastdist = rv.distance; |
475 | lastdist = rv.distance; |
432 | } |
476 | } |
433 | } |
477 | } |
434 | for (pl = first_player; pl != NULL; pl = pl->next) |
478 | |
435 | { |
479 | for_all_players (pl) |
436 | if (can_detect_enemy (mon, pl->ob, &rv)) |
480 | if (can_detect_enemy (mon, pl->ob, &rv)) |
437 | { |
|
|
438 | |
|
|
439 | if (lastdist > rv.distance) |
481 | if (lastdist > rv.distance) |
440 | { |
482 | { |
441 | op = pl->ob; |
483 | op = pl->ob; |
442 | lastdist = rv.distance; |
484 | lastdist = rv.distance; |
443 | } |
485 | } |
444 | } |
486 | |
445 | } |
|
|
446 | #if 0 |
487 | #if 0 |
447 | LOG (llevDebug, "get_nearest_player() finds player: %s\n", op ? &op->name : "(null)"); |
488 | LOG (llevDebug, "get_nearest_player() finds player: %s\n", op ? &op->name : "(null)"); |
448 | #endif |
489 | #endif |
449 | return op; |
490 | return op; |
450 | } |
491 | } |
… | |
… | |
830 | |
871 | |
831 | contr->orig_stats = stats; |
872 | contr->orig_stats = stats; |
832 | } |
873 | } |
833 | } |
874 | } |
834 | |
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 | |
835 | /* This function takes the key that is passed, and does the |
887 | /* This function takes the key that is passed, and does the |
836 | * appropriate action with it (change race, or other things). |
888 | * appropriate action with it (change race, or other things). |
837 | * The function name is for historical reasons - now we have |
889 | * The function name is for historical reasons - now we have |
838 | * separate race and class; this actually changes the RACE, |
890 | * separate race and class; this actually changes the RACE, |
839 | * not the class. |
891 | * not the class. |
… | |
… | |
884 | if (*first_map_ext_path) |
936 | if (*first_map_ext_path) |
885 | { |
937 | { |
886 | object *tmp; |
938 | object *tmp; |
887 | char mapname[MAX_BUF]; |
939 | char mapname[MAX_BUF]; |
888 | |
940 | |
889 | 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); |
890 | tmp = object::create (); |
942 | tmp = object::create (); |
891 | EXIT_PATH (tmp) = mapname; |
943 | EXIT_PATH (tmp) = mapname; |
892 | EXIT_X (tmp) = op->x; |
944 | EXIT_X (tmp) = op->x; |
893 | EXIT_Y (tmp) = op->y; |
945 | EXIT_Y (tmp) = op->y; |
894 | 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; |
895 | * if the map isn't there, then stay on the |
947 | * if the map isn't there, then stay on the |
896 | * default initial map */ |
948 | * default initial map */ |
897 | tmp->destroy (); |
949 | tmp->destroy (); |
898 | } |
950 | } |
899 | else |
951 | else |
… | |
… | |
953 | } |
1005 | } |
954 | |
1006 | |
955 | INVOKE_PLAYER (LOGOUT, op->contr); |
1007 | INVOKE_PLAYER (LOGOUT, op->contr); |
956 | INVOKE_PLAYER (QUIT, op->contr); |
1008 | INVOKE_PLAYER (QUIT, op->contr); |
957 | |
1009 | |
|
|
1010 | op->contr->enable_save = false; |
|
|
1011 | |
958 | terminate_all_pets (op); |
1012 | terminate_all_pets (op); |
959 | leave_map (op); |
1013 | op->remove (); |
960 | op->direction = 0; |
1014 | op->direction = 0; |
961 | 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); |
962 | |
1016 | |
963 | strcpy (op->contr->killer, "quit"); |
1017 | strcpy (op->contr->killer, "quit"); |
964 | check_score (op); |
1018 | check_score (op); |
965 | op->contr->party = 0; |
1019 | op->contr->party = 0; |
966 | op->contr->own_title[0] = '\0'; |
1020 | op->contr->own_title[0] = '\0'; |
967 | |
1021 | op->contr->destroy (); |
968 | object_ptr ob = op; |
|
|
969 | |
|
|
970 | delete ob->contr; |
|
|
971 | |
|
|
972 | /* We need to hunt for any per player unique maps in memory and |
|
|
973 | * get rid of them. The trailing slash in the path is intentional, |
|
|
974 | * so that players named 'Ab' won't match against players 'Abe' pathname |
|
|
975 | */ |
|
|
976 | char buf[MAX_BUF]; |
|
|
977 | sprintf (buf, "%s/%s/%s/", settings.localdir, settings.playerdir, &op->name); |
|
|
978 | |
|
|
979 | for (maptile *next, *mp = first_map; mp; mp = next) |
|
|
980 | { |
|
|
981 | next = mp->next; |
|
|
982 | |
|
|
983 | if (!strncmp (mp->path, buf, strlen (buf))) |
|
|
984 | delete_map (mp); |
|
|
985 | } |
|
|
986 | |
|
|
987 | delete_character (ob->name, 1); |
|
|
988 | |
1022 | |
989 | return 1; |
1023 | return 1; |
990 | } |
1024 | } |
991 | |
1025 | |
992 | void |
1026 | void |
… | |
… | |
1131 | sprintf (putstring, "item name: %s item type: %d weight/value: %d", |
1165 | sprintf (putstring, "item name: %s item type: %d weight/value: %d", |
1132 | &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1166 | &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1133 | else |
1167 | else |
1134 | sprintf (putstring, "item name: %s item type: %d weight/value: %d", |
1168 | sprintf (putstring, "item name: %s item type: %d weight/value: %d", |
1135 | &tmp->arch->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1169 | &tmp->arch->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
|
|
1170 | |
1136 | new_draw_info (NDI_UNIQUE, 0, op, putstring); |
1171 | new_draw_info (NDI_UNIQUE, 0, op, putstring); |
1137 | |
|
|
1138 | sprintf (putstring, "...flags: "); |
|
|
1139 | for (k = 0; k < 4; k++) |
|
|
1140 | { |
|
|
1141 | for (j = 0; j < 32; j++) |
|
|
1142 | { |
|
|
1143 | if ((tmp->flags[k] >> j) & 0x01) |
|
|
1144 | { |
|
|
1145 | sprintf (tmpstr, "%d ", k * 32 + j); |
|
|
1146 | strcat (putstring, tmpstr); |
|
|
1147 | } |
|
|
1148 | } |
|
|
1149 | } |
|
|
1150 | new_draw_info (NDI_UNIQUE, 0, op, putstring); |
|
|
1151 | |
|
|
1152 | #if 0 |
|
|
1153 | /* print the flags too */ |
|
|
1154 | for (k = 0; k < 4; k++) |
|
|
1155 | { |
|
|
1156 | fprintf (stderr, "%d [%d] ", k, k * 32 + 31); |
|
|
1157 | for (j = 0; j < 32; j++) |
|
|
1158 | { |
|
|
1159 | fprintf (stderr, "%d", tmp->flags[k] >> (31 - j) & 0x01); |
|
|
1160 | if (!((j + 1) % 4)) |
|
|
1161 | fprintf (stderr, " "); |
|
|
1162 | } |
|
|
1163 | fprintf (stderr, " [%d]\n", k * 32); |
|
|
1164 | } |
|
|
1165 | #endif |
|
|
1166 | } |
1172 | } |
|
|
1173 | |
1167 | /* philosophy: |
1174 | /* philosophy: |
1168 | * It's easy to grab an item type from a pile, as long as it's |
1175 | * It's easy to grab an item type from a pile, as long as it's |
1169 | * generic. This takes no game-time. For more detailed pickups |
1176 | * generic. This takes no game-time. For more detailed pickups |
1170 | * and selections, select-items shoul dbe used. This is a |
1177 | * and selections, select-items should be used. This is a |
1171 | * grab-as-you-run type mode that's really useful for arrows for |
1178 | * grab-as-you-run type mode that's really useful for arrows for |
1172 | * example. |
1179 | * example. |
1173 | * The drawback: right now it has no frontend, so you need to |
1180 | * The drawback: right now it has no frontend, so you need to |
1174 | * stick the bits you want into a calculator in hex mode and then |
1181 | * stick the bits you want into a calculator in hex mode and then |
1175 | * convert to decimal and then 'pickup <#> |
1182 | * convert to decimal and then 'pickup <#> |
… | |
… | |
1675 | return 0; |
1682 | return 0; |
1676 | } |
1683 | } |
1677 | |
1684 | |
1678 | arrow->set_owner (op); |
1685 | arrow->set_owner (op); |
1679 | arrow->skill = bow->skill; |
1686 | arrow->skill = bow->skill; |
1680 | |
|
|
1681 | arrow->direction = dir; |
1687 | arrow->direction = dir; |
1682 | arrow->x = sx; |
|
|
1683 | arrow->y = sy; |
|
|
1684 | |
1688 | |
1685 | if (op->type == PLAYER) |
1689 | if (op->type == PLAYER) |
1686 | { |
1690 | { |
1687 | op->speed_left = 0.01 - (float) FABS (op->speed) * 100 / bowspeed; |
1691 | op->speed_left = 0.01 - (float) FABS (op->speed) * 100 / bowspeed; |
1688 | op->update_stats (); |
1692 | op->update_stats (); |
… | |
… | |
1703 | |
1707 | |
1704 | /* update the speed */ |
1708 | /* update the speed */ |
1705 | arrow->speed = (float) ((QUERY_FLAG (bow, FLAG_NO_STRENGTH) ? |
1709 | arrow->speed = (float) ((QUERY_FLAG (bow, FLAG_NO_STRENGTH) ? |
1706 | 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; |
1707 | |
1711 | |
1708 | if (arrow->speed < 1.0) |
1712 | arrow->set_speed (max (arrow->speed, 1.0)); |
1709 | arrow->speed = 1.0; |
|
|
1710 | update_ob_speed (arrow); |
|
|
1711 | arrow->speed_left = 0; |
1713 | arrow->speed_left = 0; |
1712 | |
1714 | |
1713 | if (op->type == PLAYER) |
1715 | if (op->type == PLAYER) |
1714 | { |
1716 | { |
1715 | arrow->stats.wc = 20 - bow->magic - arrow->magic - |
1717 | arrow->stats.wc = 20 - bow->magic - arrow->magic - |
… | |
… | |
1728 | arrow->attacktype |= bow->attacktype; |
1730 | arrow->attacktype |= bow->attacktype; |
1729 | |
1731 | |
1730 | if (bow->slaying) |
1732 | if (bow->slaying) |
1731 | arrow->slaying = bow->slaying; |
1733 | arrow->slaying = bow->slaying; |
1732 | |
1734 | |
1733 | arrow->map = m; |
|
|
1734 | arrow->move_type = MOVE_FLY_LOW; |
1735 | arrow->move_type = MOVE_FLY_LOW; |
1735 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1736 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1736 | |
1737 | |
1737 | 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); |
1738 | insert_ob_in_map (arrow, m, op, 0); |
1739 | m->insert (arrow, sx, sy, op); |
1739 | |
1740 | |
1740 | if (!arrow->destroyed ()) |
1741 | if (!arrow->destroyed ()) |
1741 | move_arrow (arrow); |
1742 | move_arrow (arrow); |
1742 | |
1743 | |
1743 | if (op->type == PLAYER) |
1744 | if (op->type == PLAYER) |
… | |
… | |
1769 | } |
1770 | } |
1770 | 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) |
1771 | { |
1772 | { |
1772 | if (!similar_direction (dir, op->contr->bowtype - bow_n + 1)) |
1773 | if (!similar_direction (dir, op->contr->bowtype - bow_n + 1)) |
1773 | wcmod = -1; |
1774 | wcmod = -1; |
|
|
1775 | |
1774 | 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); |
1775 | } |
1777 | } |
1776 | else if (op->contr->bowtype == bow_threewide) |
1778 | else if (op->contr->bowtype == bow_threewide) |
1777 | { |
1779 | { |
1778 | 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); |
… | |
… | |
1848 | |
1850 | |
1849 | if (item->arch) |
1851 | if (item->arch) |
1850 | { |
1852 | { |
1851 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1853 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1852 | item->face = item->arch->clone.face; |
1854 | item->face = item->arch->clone.face; |
1853 | item->speed = 0; |
1855 | item->set_speed (0); |
1854 | update_ob_speed (item); |
|
|
1855 | } |
1856 | } |
|
|
1857 | |
1856 | if ((tmp = item->in_player ())) |
1858 | if ((tmp = item->in_player ())) |
1857 | esrv_update_item (UPD_ANIM, tmp, item); |
1859 | esrv_update_item (UPD_ANIM, tmp, item); |
1858 | } |
1860 | } |
1859 | } |
1861 | } |
1860 | else if (item->type == ROD || item->type == HORN) |
1862 | else if (item->type == ROD || item->type == HORN) |
1861 | { |
|
|
1862 | drain_rod_charge (item); |
1863 | drain_rod_charge (item); |
1863 | } |
|
|
1864 | } |
1864 | } |
1865 | } |
1865 | } |
1866 | |
1866 | |
1867 | /* Received a fire command for the player - go and do it. |
1867 | /* Received a fire command for the player - go and do it. |
1868 | */ |
1868 | */ |
… | |
… | |
2352 | |
2352 | |
2353 | /* 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 |
2354 | * the players time has been increased when doericserver has been |
2354 | * the players time has been increased when doericserver has been |
2355 | * called, so we recheck it here. |
2355 | * called, so we recheck it here. |
2356 | */ |
2356 | */ |
2357 | //TODO: better than handling 8 commands, use some more intelligent rate-limiting |
2357 | op->contr->ns->handle_command (); |
2358 | for (int rep = 8; --rep && op->contr->ns->handle_command (); ) |
|
|
2359 | ; |
|
|
2360 | |
2358 | |
2361 | if (op->speed_left < 0) |
2359 | if (op->speed_left < 0) |
2362 | return 0; |
2360 | return 0; |
2363 | |
2361 | |
2364 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2362 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
… | |
… | |
2424 | { |
2422 | { |
2425 | object *next; |
2423 | object *next; |
2426 | |
2424 | |
2427 | while (op) |
2425 | while (op) |
2428 | { |
2426 | { |
2429 | 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' */ |
2430 | * we remove object 'op' |
2428 | |
2431 | */ |
|
|
2432 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2429 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2433 | { |
2430 | { |
2434 | op->remove (); |
|
|
2435 | op->x = env->x; |
|
|
2436 | op->y = env->y; |
|
|
2437 | if (env->type == PLAYER) |
2431 | if (env->type == PLAYER) |
2438 | esrv_del_item (env->contr, op->count); |
2432 | esrv_del_item (env->contr, op->count); |
2439 | insert_ob_in_map (op, env->map, NULL, 0); |
2433 | |
|
|
2434 | op->insert_at (env); |
2440 | } |
2435 | } |
2441 | else if (op->inv) |
2436 | else if (op->inv) |
2442 | remove_unpaid_objects (op->inv, env); |
2437 | remove_unpaid_objects (op->inv, env); |
2443 | |
2438 | |
2444 | op = next; |
2439 | op = next; |
2445 | } |
2440 | } |
2446 | } |
2441 | } |
2447 | |
|
|
2448 | |
2442 | |
2449 | /* |
2443 | /* |
2450 | * Returns pointer a static string containing gravestone text |
2444 | * Returns pointer a static string containing gravestone text |
2451 | * Moved from apply.c to player.c - player.c is what |
2445 | * Moved from apply.c to player.c - player.c is what |
2452 | * actually uses this function. player.c may not be quite the |
2446 | * actually uses this function. player.c may not be quite the |
… | |
… | |
2486 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2480 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2487 | strcat (buf2, buf); |
2481 | strcat (buf2, buf); |
2488 | |
2482 | |
2489 | return buf2; |
2483 | return buf2; |
2490 | } |
2484 | } |
2491 | |
|
|
2492 | |
|
|
2493 | |
2485 | |
2494 | void |
2486 | void |
2495 | do_some_living (object *op) |
2487 | do_some_living (object *op) |
2496 | { |
2488 | { |
2497 | int last_food = op->stats.food; |
2489 | int last_food = op->stats.food; |
… | |
… | |
2506 | const int max_grace = 1; |
2498 | const int max_grace = 1; |
2507 | |
2499 | |
2508 | if (op->contr->outputs_sync) |
2500 | if (op->contr->outputs_sync) |
2509 | { |
2501 | { |
2510 | for (i = 0; i < NUM_OUTPUT_BUFS; i++) |
2502 | for (i = 0; i < NUM_OUTPUT_BUFS; i++) |
2511 | if (op->contr->outputs[i].buf != NULL && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) |
2503 | if (op->contr->outputs[i].buf && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) |
2512 | flush_output_element (op, &op->contr->outputs[i]); |
2504 | flush_output_element (op, &op->contr->outputs[i]); |
2513 | } |
2505 | } |
2514 | |
2506 | |
2515 | if (op->contr->ns->state == ST_PLAYING) |
2507 | if (op->contr->ns->state == ST_PLAYING) |
2516 | { |
2508 | { |
2517 | |
|
|
2518 | /* these next three if clauses make it possible to SLOW DOWN |
2509 | /* these next three if clauses make it possible to SLOW DOWN |
2519 | hp/grace/spellpoint regeneration. */ |
2510 | hp/grace/spellpoint regeneration. */ |
2520 | if (op->contr->gen_hp >= 0) |
2511 | if (op->contr->gen_hp >= 0) |
2521 | gen_hp = (op->contr->gen_hp + 1) * op->stats.maxhp; |
2512 | gen_hp = (op->contr->gen_hp + 1) * op->stats.maxhp; |
2522 | else |
2513 | else |
2523 | { |
2514 | { |
2524 | gen_hp = op->stats.maxhp; |
2515 | gen_hp = op->stats.maxhp; |
2525 | rate_hp -= rate_hp / 2 * op->contr->gen_hp; |
2516 | rate_hp -= rate_hp / 2 * op->contr->gen_hp; |
2526 | } |
2517 | } |
|
|
2518 | |
2527 | if (op->contr->gen_sp >= 0) |
2519 | if (op->contr->gen_sp >= 0) |
2528 | gen_sp = (op->contr->gen_sp + 1) * op->stats.maxsp; |
2520 | gen_sp = (op->contr->gen_sp + 1) * op->stats.maxsp; |
2529 | else |
2521 | else |
2530 | { |
2522 | { |
2531 | gen_sp = op->stats.maxsp; |
2523 | gen_sp = op->stats.maxsp; |
2532 | rate_sp -= rate_sp / 2 * op->contr->gen_sp; |
2524 | rate_sp -= rate_sp / 2 * op->contr->gen_sp; |
2533 | } |
2525 | } |
|
|
2526 | |
2534 | if (op->contr->gen_grace >= 0) |
2527 | if (op->contr->gen_grace >= 0) |
2535 | gen_grace = (op->contr->gen_grace + 1) * op->stats.maxgrace; |
2528 | gen_grace = (op->contr->gen_grace + 1) * op->stats.maxgrace; |
2536 | else |
2529 | else |
2537 | { |
2530 | { |
2538 | gen_grace = op->stats.maxgrace; |
2531 | gen_grace = op->stats.maxgrace; |
… | |
… | |
2554 | op->stats.food += op->contr->digestion; |
2547 | op->stats.food += op->contr->digestion; |
2555 | else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH)) |
2548 | else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH)) |
2556 | op->stats.food = last_food; |
2549 | op->stats.food = last_food; |
2557 | } |
2550 | } |
2558 | } |
2551 | } |
|
|
2552 | |
2559 | if (max_sp > 1) |
2553 | if (max_sp > 1) |
2560 | { |
2554 | { |
2561 | over_sp = (gen_sp + 10) / rate_sp; |
2555 | over_sp = (gen_sp + 10) / rate_sp; |
2562 | if (over_sp > 0) |
2556 | if (over_sp > 0) |
2563 | { |
2557 | { |
2564 | if (op->stats.sp < op->stats.maxsp) |
2558 | if (op->stats.sp < op->stats.maxsp) |
2565 | { |
2559 | { |
2566 | op->stats.sp += over_sp > max_sp ? max_sp : over_sp; |
2560 | op->stats.sp += over_sp > max_sp ? max_sp : over_sp; |
|
|
2561 | |
2567 | if (random_roll (0, rate_sp - 1, op, PREFER_LOW) > ((gen_sp + 10) % rate_sp)) |
2562 | if (random_roll (0, rate_sp - 1, op, PREFER_LOW) > ((gen_sp + 10) % rate_sp)) |
2568 | op->stats.sp--; |
2563 | op->stats.sp--; |
|
|
2564 | |
2569 | if (op->stats.sp > op->stats.maxsp) |
2565 | if (op->stats.sp > op->stats.maxsp) |
2570 | op->stats.sp = op->stats.maxsp; |
2566 | op->stats.sp = op->stats.maxsp; |
2571 | } |
2567 | } |
2572 | op->last_sp = 0; |
2568 | op->last_sp = 0; |
2573 | } |
2569 | } |
2574 | else |
2570 | else |
2575 | { |
|
|
2576 | op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10); |
2571 | op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10); |
2577 | } |
|
|
2578 | } |
2572 | } |
2579 | else |
2573 | else |
2580 | { |
|
|
2581 | op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10); |
2574 | op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10); |
2582 | } |
|
|
2583 | } |
2575 | } |
2584 | |
2576 | |
2585 | /* Regenerate Grace */ |
2577 | /* Regenerate Grace */ |
2586 | /* I altered this a little - maximum grace is ony achieved through prayer -b.t. */ |
2578 | /* I altered this a little - maximum grace is ony achieved through prayer -b.t. */ |
2587 | if (--op->last_grace < 0) |
2579 | if (--op->last_grace < 0) |
2588 | { |
2580 | { |
2589 | if (op->stats.grace < op->stats.maxgrace / 2) |
2581 | if (op->stats.grace < op->stats.maxgrace / 2) |
2590 | op->stats.grace++; /* no penalty in food for regaining grace */ |
2582 | op->stats.grace++; /* no penalty in food for regaining grace */ |
|
|
2583 | |
2591 | if (max_grace > 1) |
2584 | if (max_grace > 1) |
2592 | { |
2585 | { |
2593 | over_grace = (gen_grace < 20 ? 30 : gen_grace + 10) / rate_grace; |
2586 | over_grace = (gen_grace < 20 ? 30 : gen_grace + 10) / rate_grace; |
2594 | if (over_grace > 0) |
2587 | if (over_grace > 0) |
2595 | { |
2588 | { |
… | |
… | |
2623 | op->stats.food += op->contr->digestion; |
2616 | op->stats.food += op->contr->digestion; |
2624 | else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH)) |
2617 | else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH)) |
2625 | op->stats.food = last_food; |
2618 | op->stats.food = last_food; |
2626 | } |
2619 | } |
2627 | } |
2620 | } |
|
|
2621 | |
2628 | if (max_hp > 1) |
2622 | if (max_hp > 1) |
2629 | { |
2623 | { |
2630 | over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp; |
2624 | over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp; |
2631 | if (over_hp > 0) |
2625 | if (over_hp > 0) |
2632 | { |
2626 | { |
… | |
… | |
2656 | |
2650 | |
2657 | if (op->contr->gen_hp > 0) |
2651 | if (op->contr->gen_hp > 0) |
2658 | op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1); |
2652 | op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1); |
2659 | else |
2653 | else |
2660 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |
2654 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |
|
|
2655 | |
2661 | /* dms do not consume food */ |
2656 | /* dms do not consume food */ |
2662 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2657 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2663 | op->stats.food--; |
2658 | op->stats.food--; |
2664 | } |
2659 | } |
2665 | } |
|
|
2666 | |
2660 | |
2667 | if (op->contr->ns->state == ST_PLAYING && op->stats.food < 0 && op->stats.hp >= 0) |
2661 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2668 | { |
2662 | { |
2669 | object *tmp, *flesh = NULL; |
2663 | object *tmp, *flesh = 0; |
2670 | |
2664 | |
2671 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2665 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2672 | { |
2666 | { |
2673 | if (!QUERY_FLAG (tmp, FLAG_UNPAID)) |
2667 | if (!QUERY_FLAG (tmp, FLAG_UNPAID)) |
2674 | { |
|
|
2675 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
|
|
2676 | { |
2668 | { |
|
|
2669 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
|
|
2670 | { |
2677 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
2671 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
2678 | manual_apply (op, tmp, 0); |
2672 | manual_apply (op, tmp, 0); |
2679 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2673 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2680 | break; |
2674 | break; |
2681 | } |
2675 | } |
2682 | else if (tmp->type == FLESH) |
2676 | else if (tmp->type == FLESH) |
2683 | flesh = tmp; |
2677 | flesh = tmp; |
2684 | } /* End if paid for object */ |
2678 | } /* End if paid for object */ |
2685 | } /* end of for loop */ |
2679 | } /* end of for loop */ |
|
|
2680 | |
2686 | /* If player is still starving, it means they don't have any food, so |
2681 | /* If player is still starving, it means they don't have any food, so |
2687 | * eat flesh instead. |
2682 | * eat flesh instead. |
2688 | */ |
2683 | */ |
2689 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2684 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2690 | { |
2685 | { |
2691 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
2686 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
2692 | manual_apply (op, flesh, 0); |
2687 | manual_apply (op, flesh, 0); |
2693 | } |
2688 | } |
2694 | } /* end if player is starving */ |
2689 | } |
2695 | |
2690 | |
2696 | while (op->stats.food < 0 && op->stats.hp > 0) |
2691 | while (op->stats.food < 0 && op->stats.hp >= 0) |
2697 | op->stats.food++, op->stats.hp--; |
2692 | op->stats.food++, op->stats.hp--; |
2698 | |
2693 | |
2699 | if (!op->contr->ns->state && !QUERY_FLAG (op, FLAG_WIZ) && (op->stats.hp < 0 || op->stats.food < 0)) |
2694 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2700 | kill_player (op); |
2695 | kill_player (op); |
|
|
2696 | } |
2701 | } |
2697 | } |
2702 | |
|
|
2703 | |
|
|
2704 | |
2698 | |
2705 | /* If the player should die (lack of hp, food, etc), we call this. |
2699 | /* If the player should die (lack of hp, food, etc), we call this. |
2706 | * op is the player in jeopardy. If the player can not be saved (not |
2700 | * op is the player in jeopardy. If the player can not be saved (not |
2707 | * permadeath, no lifesave), this will take care of removing the player |
2701 | * permadeath, no lifesave), this will take care of removing the player |
2708 | * file. |
2702 | * file. |
… | |
… | |
2738 | 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!"); |
2739 | 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..."); |
2740 | |
2734 | |
2741 | /* restore player */ |
2735 | /* restore player */ |
2742 | at = archetype::find ("poisoning"); |
2736 | at = archetype::find ("poisoning"); |
2743 | tmp = present_arch_in_ob (at, op); |
2737 | if (object *tmp = present_arch_in_ob (at, op)) |
2744 | if (tmp) |
|
|
2745 | { |
2738 | { |
2746 | tmp->destroy (); |
2739 | tmp->destroy (); |
2747 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2740 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2748 | } |
2741 | } |
2749 | |
2742 | |
2750 | at = archetype::find ("confusion"); |
2743 | at = archetype::find ("confusion"); |
2751 | tmp = present_arch_in_ob (at, op); |
2744 | if (object *tmp = present_arch_in_ob (at, op)) |
2752 | if (tmp) |
|
|
2753 | { |
2745 | { |
2754 | tmp->destroy (); |
2746 | tmp->destroy (); |
2755 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2747 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2756 | } |
2748 | } |
2757 | |
2749 | |
… | |
… | |
2759 | op->stats.hp = op->stats.maxhp; |
2751 | op->stats.hp = op->stats.maxhp; |
2760 | if (op->stats.food <= 0) |
2752 | if (op->stats.food <= 0) |
2761 | op->stats.food = 999; |
2753 | op->stats.food = 999; |
2762 | |
2754 | |
2763 | /* create a bodypart-trophy to make the winner happy */ |
2755 | /* create a bodypart-trophy to make the winner happy */ |
2764 | tmp = arch_to_object (archetype::find ("finger")); |
2756 | if (object *tmp = arch_to_object (archetype::find ("finger"))) |
2765 | if (tmp != NULL) |
|
|
2766 | { |
2757 | { |
2767 | sprintf (buf, "%s's finger", &op->name); |
2758 | sprintf (buf, "%s's finger", &op->name); |
2768 | tmp->name = buf; |
2759 | tmp->name = buf; |
2769 | sprintf (buf, " This finger has been cut off %s\n" |
2760 | sprintf (buf, " This finger has been cut off %s\n" |
2770 | " 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", |
2771 | &op->name, op->contr->title, (int) (op->level), op->contr->killer); |
2762 | &op->name, op->contr->title, (int) (op->level), op->contr->killer); |
2772 | tmp->msg = buf; |
2763 | tmp->msg = buf; |
2773 | tmp->value = 0, tmp->material = 0, tmp->type = 0; |
2764 | tmp->value = 0, tmp->material = 0, tmp->type = 0; |
2774 | tmp->materialname = NULL; |
2765 | tmp->materialname = NULL; |
2775 | tmp->x = op->x, tmp->y = op->y; |
2766 | op->insert_at (tmp, op); |
2776 | insert_ob_in_map (tmp, op->map, op, 0); |
|
|
2777 | } |
2767 | } |
2778 | |
2768 | |
2779 | /* teleport defeated player to new destination */ |
2769 | /* teleport defeated player to new destination */ |
2780 | transfer_ob (op, x, y, 0, NULL); |
2770 | transfer_ob (op, x, y, 0, NULL); |
2781 | op->contr->braced = 0; |
2771 | op->contr->braced = 0; |
… | |
… | |
2807 | op->stats.hp = op->stats.maxhp; |
2797 | op->stats.hp = op->stats.maxhp; |
2808 | return; |
2798 | return; |
2809 | } |
2799 | } |
2810 | sprintf (buf, "%s died.", &op->name); |
2800 | sprintf (buf, "%s died.", &op->name); |
2811 | } |
2801 | } |
|
|
2802 | |
2812 | play_sound_player_only (op->contr, SOUND_PLAYER_DIES, 0, 0); |
2803 | play_sound_player_only (op->contr, SOUND_PLAYER_DIES, 0, 0); |
2813 | |
2804 | |
2814 | /* save the map location for corpse, gravestone */ |
2805 | /* save the map location for corpse, gravestone */ |
2815 | x = op->x; |
2806 | x = op->x; |
2816 | y = op->y; |
2807 | y = op->y; |
2817 | map = op->map; |
2808 | map = op->map; |
2818 | |
|
|
2819 | |
2809 | |
2820 | /* NOT_PERMADEATH code. This basically brings the character back to |
2810 | /* NOT_PERMADEATH code. This basically brings the character back to |
2821 | * 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. |
2822 | * 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. |
2823 | */ |
2813 | */ |
… | |
… | |
2840 | num_stats_lose = 1; |
2830 | num_stats_lose = 1; |
2841 | else |
2831 | else |
2842 | num_stats_lose = 1 + op->level / BALSL_NUMBER_LOSSES_RATIO; |
2832 | num_stats_lose = 1 + op->level / BALSL_NUMBER_LOSSES_RATIO; |
2843 | } |
2833 | } |
2844 | else |
2834 | else |
2845 | { |
|
|
2846 | num_stats_lose = 1; |
2835 | num_stats_lose = 1; |
2847 | } |
2836 | |
2848 | lost_a_stat = 0; |
2837 | lost_a_stat = 0; |
2849 | |
2838 | |
2850 | for (z = 0; z < num_stats_lose; z++) |
2839 | for (z = 0; z < num_stats_lose; z++) |
2851 | { |
2840 | { |
2852 | i = RANDOM () % NUM_STATS; |
2841 | i = RANDOM () % NUM_STATS; |
… | |
… | |
3094 | */ |
3083 | */ |
3095 | |
3084 | |
3096 | void |
3085 | void |
3097 | fix_weight (void) |
3086 | fix_weight (void) |
3098 | { |
3087 | { |
3099 | for (player *pl = first_player; pl; pl = pl->next) |
3088 | for_all_players (pl) |
3100 | { |
3089 | { |
3101 | int old = pl->ob->carrying, sum = sum_weight (pl->ob); |
3090 | int old = pl->ob->carrying, sum = sum_weight (pl->ob); |
3102 | |
3091 | |
3103 | if (old == sum) |
3092 | if (old == sum) |
3104 | continue; |
3093 | continue; |
… | |
… | |
3108 | } |
3097 | } |
3109 | |
3098 | |
3110 | void |
3099 | void |
3111 | fix_luck (void) |
3100 | fix_luck (void) |
3112 | { |
3101 | { |
3113 | for (player *pl = first_player; pl; pl = pl->next) |
3102 | for_all_players (pl) |
3114 | if (!pl->ob->contr->ns->state) |
3103 | if (!pl->ob->contr->ns->state) |
3115 | pl->ob->change_luck (0); |
3104 | pl->ob->change_luck (0); |
3116 | } |
3105 | } |
3117 | |
3106 | |
3118 | /* cast_dust() - handles op throwing objects of type 'DUST'. |
3107 | /* cast_dust() - handles op throwing objects of type 'DUST'. |
… | |
… | |
3335 | if (pl->type != PLAYER) |
3324 | if (pl->type != PLAYER) |
3336 | { |
3325 | { |
3337 | LOG (llevError, "player_can_view() called for non-player object\n"); |
3326 | LOG (llevError, "player_can_view() called for non-player object\n"); |
3338 | return -1; |
3327 | return -1; |
3339 | } |
3328 | } |
|
|
3329 | |
3340 | if (!pl || !op) |
3330 | if (!pl || !op) |
3341 | return 0; |
3331 | return 0; |
3342 | |
3332 | |
3343 | if (op->head) |
|
|
3344 | { |
|
|
3345 | op = op->head; |
3333 | op = op->head_ (); |
3346 | } |
3334 | |
3347 | get_rangevector (pl, op, &rv, 0x1); |
3335 | get_rangevector (pl, op, &rv, 0x1); |
3348 | |
3336 | |
3349 | /* starting with the 'head' part, lets loop |
3337 | /* starting with the 'head' part, lets loop |
3350 | * through the object and find if it has any |
3338 | * through the object and find if it has any |
3351 | * part that is in the los array but isnt on |
3339 | * part that is in the los array but isnt on |
… | |
… | |
3481 | if (trlist == NULL || who->type != PLAYER) |
3469 | if (trlist == NULL || who->type != PLAYER) |
3482 | return; |
3470 | return; |
3483 | |
3471 | |
3484 | 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++); |
3485 | |
3473 | |
3486 | if (tr == NULL || tr->item == NULL) |
3474 | if (!tr || !tr->item) |
3487 | { |
3475 | { |
3488 | /* 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]); */ |
3489 | return; |
3477 | return; |
3490 | } |
3478 | } |
3491 | |
3479 | |