… | |
… | |
107 | if (gen->map == NULL) |
107 | if (gen->map == NULL) |
108 | { |
108 | { |
109 | //LOG(llevError,"Generator (%s) not on a map?\n", gen->name); |
109 | //LOG(llevError,"Generator (%s) not on a map?\n", gen->name); |
110 | return; |
110 | return; |
111 | } |
111 | } |
|
|
112 | |
112 | /*First count numer of objects in inv */ |
113 | /*First count numer of objects in inv */ |
113 | for (op = gen->inv; op; op = op->below) |
114 | for (op = gen->inv; op; op = op->below) |
114 | qty++; |
115 | qty++; |
|
|
116 | |
115 | if (!qty) |
117 | if (!qty) |
116 | { |
118 | { |
117 | LOG (llevError, "Generator (%s) has no inventory in generate_monster_inv?\n", &gen->name); |
119 | LOG (llevError, "Generator (%s) has no inventory in generate_monster_inv?\n", &gen->name); |
118 | return; /*No inventory */ |
120 | return; /*No inventory */ |
119 | } |
121 | } |
120 | qty = rndm (0, qty - 1); |
122 | qty = rndm (0, qty - 1); |
121 | for (op = gen->inv; qty; qty--) |
123 | for (op = gen->inv; qty; qty--) |
122 | op = op->below; |
124 | op = op->below; |
|
|
125 | |
123 | i = find_free_spot (op, gen->map, gen->x, gen->y, 1, 9); |
126 | i = find_free_spot (op, gen->map, gen->x, gen->y, 1, 9); |
124 | if (i == -1) |
127 | if (i == -1) |
125 | return; |
128 | return; |
|
|
129 | |
126 | head = object_create_clone (op); |
130 | head = object_create_clone (op); |
127 | CLEAR_FLAG (head, FLAG_IS_A_TEMPLATE); |
131 | CLEAR_FLAG (head, FLAG_IS_A_TEMPLATE); |
128 | unflag_inv (head, FLAG_IS_A_TEMPLATE); |
132 | unflag_inv (head, FLAG_IS_A_TEMPLATE); |
129 | if (rndm (0, 9)) |
133 | if (rndm (0, 9)) |
130 | generate_artifact (head, gen->map->difficulty); |
134 | generate_artifact (head, gen->map->difficulty); |
|
|
135 | |
131 | insert_ob_in_map_at (head, gen->map, gen, 0, gen->x + freearr_x[i], gen->y + freearr_y[i]); |
136 | insert_ob_in_map_at (head, gen->map, gen, 0, gen->x + freearr_x[i], gen->y + freearr_y[i]); |
132 | if (QUERY_FLAG (head, FLAG_FREED)) |
137 | if (QUERY_FLAG (head, FLAG_FREED)) |
133 | return; |
138 | return; |
|
|
139 | |
134 | if (head->has_random_items ()) |
140 | if (head->has_random_items ()) |
135 | create_treasure (head->randomitems, head, GT_APPLY, gen->map->difficulty, 0); |
141 | create_treasure (head->randomitems, head, GT_APPLY, gen->map->difficulty, 0); |
136 | } |
142 | } |
137 | |
143 | |
138 | void |
144 | void |
… | |
… | |
245 | return; |
251 | return; |
246 | } |
252 | } |
247 | |
253 | |
248 | if (op->stats.food == 1) |
254 | if (op->stats.food == 1) |
249 | { |
255 | { |
250 | /* need to remove the object before fix_player is called, else fix_player |
256 | /* need to unapply the object before update_stats is called, else fix_player |
251 | * will not do anything. |
257 | * will not do anything. |
252 | */ |
258 | */ |
253 | if (op->env->type == PLAYER) |
259 | if (op->env->type == PLAYER) |
254 | { |
260 | { |
255 | CLEAR_FLAG (op, FLAG_APPLIED); |
261 | CLEAR_FLAG (op, FLAG_APPLIED); |
… | |
… | |
455 | |
461 | |
456 | if (op->stats.hp) |
462 | if (op->stats.hp) |
457 | { |
463 | { |
458 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
464 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
459 | { |
465 | { |
460 | if (op->slaying && !strcmp (op->slaying, tmp->name)) |
466 | if (op->slaying && op->slaying == tmp->name) |
461 | detected = 1; |
467 | detected = 1; |
|
|
468 | |
462 | if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->slaying)) |
469 | if (tmp2->type == FORCE && tmp2->slaying && tmp2->slaying == op->slaying) |
463 | detected = 1; |
470 | detected = 1; |
464 | } |
471 | } |
465 | } |
472 | } |
|
|
473 | |
466 | if (op->slaying && !strcmp (op->slaying, tmp->name)) |
474 | if (op->slaying && op->slaying == tmp->name) |
467 | { |
|
|
468 | detected = 1; |
475 | detected = 1; |
469 | } |
|
|
470 | else if (tmp->type == SPECIAL_KEY && tmp->slaying == op->slaying) |
476 | else if (tmp->type == SPECIAL_KEY && tmp->slaying == op->slaying) |
471 | detected = 1; |
477 | detected = 1; |
472 | } |
478 | } |
473 | |
479 | |
474 | /* the detector sets the button if detection is found */ |
480 | /* the detector sets the button if detection is found */ |
… | |
… | |
604 | void |
610 | void |
605 | fix_stopped_item (object *op, maptile *map, object *originator) |
611 | fix_stopped_item (object *op, maptile *map, object *originator) |
606 | { |
612 | { |
607 | if (map == NULL) |
613 | if (map == NULL) |
608 | return; |
614 | return; |
|
|
615 | |
609 | if (QUERY_FLAG (op, FLAG_REMOVED)) |
616 | if (QUERY_FLAG (op, FLAG_REMOVED)) |
610 | insert_ob_in_map (op, map, originator, 0); |
617 | insert_ob_in_map (op, map, originator, 0); |
611 | else if (op->type == ARROW) |
618 | else if (op->type == ARROW) |
612 | merge_ob (op, NULL); /* only some arrows actually need this */ |
619 | merge_ob (op, NULL); /* only some arrows actually need this */ |
613 | } |
620 | } |
614 | |
|
|
615 | |
621 | |
616 | object * |
622 | object * |
617 | fix_stopped_arrow (object *op) |
623 | fix_stopped_arrow (object *op) |
618 | { |
624 | { |
619 | if (rndm (0, 99) < op->stats.food) |
625 | if (rndm (0, 99) < op->stats.food) |
… | |
… | |
648 | op->stats.hp = 0; |
654 | op->stats.hp = 0; |
649 | op->stats.grace = 0; |
655 | op->stats.grace = 0; |
650 | op->level = 0; |
656 | op->level = 0; |
651 | op->face = op->arch->clone.face; |
657 | op->face = op->arch->clone.face; |
652 | op->owner = NULL; /* So that stopped arrows will be saved */ |
658 | op->owner = NULL; /* So that stopped arrows will be saved */ |
653 | update_object (op, UP_OBJ_FACE); |
659 | update_object (op, UP_OBJ_CHANGE); |
654 | return op; |
660 | return op; |
655 | } |
661 | } |
656 | |
662 | |
657 | /* stop_arrow() - what to do when a non-living flying object |
663 | /* stop_arrow() - what to do when a non-living flying object |
658 | * has to stop. Sept 96 - I added in thrown object code in |
664 | * has to stop. Sept 96 - I added in thrown object code in |
… | |
… | |
684 | } |
690 | } |
685 | } |
691 | } |
686 | |
692 | |
687 | /* Move an arrow along its course. op is the arrow or thrown object. |
693 | /* Move an arrow along its course. op is the arrow or thrown object. |
688 | */ |
694 | */ |
689 | |
|
|
690 | void |
695 | void |
691 | move_arrow (object *op) |
696 | move_arrow (object *op) |
692 | { |
697 | { |
693 | object *tmp; |
698 | object *tmp; |
694 | sint16 new_x, new_y; |
699 | sint16 new_x, new_y; |
… | |
… | |
765 | * as below. (Note that for living creatures there is a small |
770 | * as below. (Note that for living creatures there is a small |
766 | * chance that reflect_missile fails.) |
771 | * chance that reflect_missile fails.) |
767 | */ |
772 | */ |
768 | if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && (rndm (0, 99)) < (90 - op->level / 10)) |
773 | if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && (rndm (0, 99)) < (90 - op->level / 10)) |
769 | { |
774 | { |
770 | int number = op->face->number; |
775 | int number = op->face; |
771 | |
776 | |
772 | op->direction = absdir (op->direction + 4); |
777 | op->direction = absdir (op->direction + 4); |
773 | op->state = 0; |
778 | update_turn_face (op); |
774 | |
|
|
775 | if (GET_ANIM_ID (op)) |
|
|
776 | { |
|
|
777 | number += 4; |
|
|
778 | |
|
|
779 | if (number > GET_ANIMATION (op, 8)) |
|
|
780 | number -= 8; |
|
|
781 | |
|
|
782 | op->face = &new_faces[number]; |
|
|
783 | } |
|
|
784 | |
|
|
785 | was_reflected = 1; /* skip normal movement calculations */ |
779 | was_reflected = 1; /* skip normal movement calculations */ |
786 | } |
780 | } |
787 | else |
781 | else |
788 | { |
782 | { |
789 | /* Attack the object. */ |
783 | /* Attack the object. */ |
… | |
… | |
1204 | return; |
1198 | return; |
1205 | } |
1199 | } |
1206 | |
1200 | |
1207 | if (op->above == NULL) |
1201 | if (op->above == NULL) |
1208 | return; |
1202 | return; |
|
|
1203 | |
1209 | for (tmp = op->above; tmp != NULL; tmp = tmp->above) |
1204 | for (tmp = op->above; tmp; tmp = tmp->above) |
1210 | { |
1205 | { |
1211 | if (strcmp (op->other_arch->name, tmp->arch->name) == 0) |
1206 | if (op->other_arch->name == tmp->arch->name) |
1212 | { |
1207 | { |
1213 | if (op->level <= 0) |
1208 | if (op->level <= 0) |
1214 | tmp->destroy (); |
1209 | tmp->destroy (); |
1215 | else |
1210 | else |
1216 | { |
1211 | { |
… | |
… | |
1307 | with a specific code as the slaying field. |
1302 | with a specific code as the slaying field. |
1308 | At that time, it writes the contents of its own message |
1303 | At that time, it writes the contents of its own message |
1309 | field to the player. The marker will decrement hp to |
1304 | field to the player. The marker will decrement hp to |
1310 | 0 and then delete itself every time it grants a mark. |
1305 | 0 and then delete itself every time it grants a mark. |
1311 | unless hp was zero to start with, in which case it is infinite.*/ |
1306 | unless hp was zero to start with, in which case it is infinite.*/ |
1312 | |
|
|
1313 | void |
1307 | void |
1314 | move_marker (object *op) |
1308 | move_marker (object *op) |
1315 | { |
1309 | { |
1316 | if (object *tmp = op->ms ().player ()) |
1310 | if (object *tmp = op->ms ().player ()) |
1317 | { |
1311 | { |
1318 | object *tmp2; |
1312 | object *tmp2; |
1319 | |
1313 | |
1320 | /* remove an old force with a slaying field == op->name */ |
1314 | /* remove an old force with a slaying field == op->name */ |
1321 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
1315 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
1322 | if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->name)) |
1316 | if (tmp2->type == FORCE && tmp2->slaying && tmp2->slaying == op->name) |
1323 | { |
1317 | { |
1324 | tmp2->destroy (); |
1318 | tmp2->destroy (); |
1325 | break; |
1319 | break; |
1326 | } |
1320 | } |
1327 | |
1321 | |
1328 | /* cycle through his inventory to look for the MARK we want to |
1322 | /* cycle through his inventory to look for the MARK we want to |
1329 | * place |
1323 | * place |
1330 | */ |
1324 | */ |
1331 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
1325 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
1332 | if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->slaying)) |
1326 | if (tmp2->type == FORCE && tmp2->slaying && tmp2->slaying == op->slaying) |
1333 | break; |
1327 | break; |
1334 | |
1328 | |
1335 | /* if we didn't find our own MARK */ |
1329 | /* if we didn't find our own MARK */ |
1336 | if (tmp2 == NULL) |
1330 | if (!tmp2) |
1337 | { |
1331 | { |
1338 | object *force = get_archetype (FORCE_NAME); |
1332 | object *force = get_archetype (FORCE_NAME); |
1339 | |
1333 | |
1340 | if (op->stats.food) |
1334 | if (op->stats.food) |
1341 | { |
1335 | { |