… | |
… | |
133 | if (rndm (0, 9)) |
133 | if (rndm (0, 9)) |
134 | generate_artifact (head, gen->map->difficulty); |
134 | generate_artifact (head, gen->map->difficulty); |
135 | insert_ob_in_map_at (head, gen->map, gen, 0, gen->x + freearr_x[i], gen->y + freearr_y[i]); |
135 | insert_ob_in_map_at (head, gen->map, gen, 0, gen->x + freearr_x[i], gen->y + freearr_y[i]); |
136 | if (QUERY_FLAG (head, FLAG_FREED)) |
136 | if (QUERY_FLAG (head, FLAG_FREED)) |
137 | return; |
137 | return; |
138 | if (HAS_RANDOM_ITEMS (head)) |
138 | if (head->has_random_items ()) |
139 | create_treasure (head->randomitems, head, GT_APPLY, gen->map->difficulty, 0); |
139 | create_treasure (head->randomitems, head, GT_APPLY, gen->map->difficulty, 0); |
140 | } |
140 | } |
141 | |
141 | |
142 | void |
142 | void |
143 | generate_monster_arch (object *gen) |
143 | generate_monster_arch (object *gen) |
… | |
… | |
175 | if (rndm (0, 9)) |
175 | if (rndm (0, 9)) |
176 | generate_artifact (op, gen->map->difficulty); |
176 | generate_artifact (op, gen->map->difficulty); |
177 | insert_ob_in_map (op, gen->map, gen, 0); |
177 | insert_ob_in_map (op, gen->map, gen, 0); |
178 | if (QUERY_FLAG (op, FLAG_FREED)) |
178 | if (QUERY_FLAG (op, FLAG_FREED)) |
179 | return; |
179 | return; |
180 | if (HAS_RANDOM_ITEMS (op)) |
180 | if (op->has_random_items ()) |
181 | create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty, 0); |
181 | create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty, 0); |
182 | if (head == NULL) |
182 | if (head == NULL) |
183 | head = op; |
183 | head = op; |
184 | prev = op; |
184 | prev = op; |
185 | at = at->more; |
185 | at = at->more; |
… | |
… | |
459 | int last = op->value; |
459 | int last = op->value; |
460 | int detected; |
460 | int detected; |
461 | |
461 | |
462 | detected = 0; |
462 | detected = 0; |
463 | |
463 | |
464 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL && !detected; tmp = tmp->above) |
464 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL && !detected; tmp = tmp->above) |
465 | { |
465 | { |
466 | object *tmp2; |
466 | object *tmp2; |
467 | |
467 | |
468 | if (op->stats.hp) |
468 | if (op->stats.hp) |
469 | { |
469 | { |
… | |
… | |
656 | op->spellarg = NULL; |
656 | op->spellarg = NULL; |
657 | } |
657 | } |
658 | else |
658 | else |
659 | op->slaying = NULL; |
659 | op->slaying = NULL; |
660 | |
660 | |
661 | /* Reset these to zero, so that CAN_MERGE will work properly */ |
661 | /* Reset these to zero, so that object::can_merge will work properly */ |
662 | op->spellarg = NULL; |
662 | op->spellarg = NULL; |
663 | op->stats.sp = 0; |
663 | op->stats.sp = 0; |
664 | op->stats.hp = 0; |
664 | op->stats.hp = 0; |
665 | op->stats.grace = 0; |
665 | op->stats.grace = 0; |
666 | op->level = 0; |
666 | op->level = 0; |
… | |
… | |
687 | if (op->inv) |
687 | if (op->inv) |
688 | { |
688 | { |
689 | object *payload = op->inv; |
689 | object *payload = op->inv; |
690 | |
690 | |
691 | payload->remove (); |
691 | payload->remove (); |
692 | clear_owner (payload); |
692 | payload->owner = 0; |
693 | insert_ob_in_map (payload, op->map, payload, 0); |
693 | insert_ob_in_map (payload, op->map, payload, 0); |
694 | op->destroy (); |
694 | op->destroy (); |
695 | } |
695 | } |
696 | else |
696 | else |
697 | { |
697 | { |
… | |
… | |
766 | } |
766 | } |
767 | |
767 | |
768 | /* only need to look for living creatures if this flag is set */ |
768 | /* only need to look for living creatures if this flag is set */ |
769 | if (mflags & P_IS_ALIVE) |
769 | if (mflags & P_IS_ALIVE) |
770 | { |
770 | { |
771 | for (tmp = get_map_ob (m, new_x, new_y); tmp != NULL; tmp = tmp->above) |
771 | for (tmp = GET_MAP_OB (m, new_x, new_y); tmp != NULL; tmp = tmp->above) |
772 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
772 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
773 | break; |
773 | break; |
774 | |
774 | |
775 | /* Not really fair, but don't let monsters hit themselves with |
775 | /* Not really fair, but don't let monsters hit themselves with |
776 | * their own arrow - this can be because they fire it then |
776 | * their own arrow - this can be because they fire it then |
… | |
… | |
908 | * Modified this routine to allow held objects. b.t. */ |
908 | * Modified this routine to allow held objects. b.t. */ |
909 | |
909 | |
910 | void |
910 | void |
911 | change_object (object *op) |
911 | change_object (object *op) |
912 | { /* Doesn`t handle linked objs yet */ |
912 | { /* Doesn`t handle linked objs yet */ |
913 | object *tmp, *env, *pl; |
|
|
914 | int i, j; |
913 | int i, j; |
915 | |
914 | |
916 | if (op->other_arch == NULL) |
915 | if (op->other_arch == NULL) |
917 | { |
916 | { |
918 | LOG (llevError, "Change object (%s) without other_arch error.\n", &op->name); |
917 | LOG (llevError, "Change object (%s) without other_arch error.\n", &op->name); |
… | |
… | |
925 | if (op->stats.food-- > 0) |
924 | if (op->stats.food-- > 0) |
926 | return; |
925 | return; |
927 | else |
926 | else |
928 | op->stats.food = 1; /* so 1 other_arch is made */ |
927 | op->stats.food = 1; /* so 1 other_arch is made */ |
929 | } |
928 | } |
|
|
929 | |
|
|
930 | object *pl = op->in_player (); |
930 | env = op->env; |
931 | object *env = op->env; |
|
|
932 | |
931 | op->remove (); |
933 | op->remove (); |
932 | for (i = 0; i < NROFNEWOBJS (op); i++) |
934 | for (i = 0; i < NROFNEWOBJS (op); i++) |
933 | { |
935 | { |
934 | tmp = arch_to_object (op->other_arch); |
936 | object *tmp = arch_to_object (op->other_arch); |
|
|
937 | |
935 | if (op->type == LAMP) |
938 | if (op->type == LAMP) |
936 | tmp->stats.food = op->stats.food - 1; |
939 | tmp->stats.food = op->stats.food - 1; |
|
|
940 | |
937 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
941 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
938 | if (env) |
942 | if (env) |
939 | { |
943 | { |
940 | tmp->x = env->x, tmp->y = env->y; |
944 | tmp->x = env->x, tmp->y = env->y; |
941 | tmp = insert_ob_in_ob (tmp, env); |
945 | tmp = insert_ob_in_ob (tmp, env); |
|
|
946 | |
942 | /* If this object is the players inventory, we need to tell the |
947 | /* If this object is the players inventory, we need to tell the |
943 | * client of the change. Insert_ob_in_map takes care of the |
948 | * client of the change. Insert_ob_in_map takes care of the |
944 | * updating the client, so we don't need to do that below. |
949 | * updating the client, so we don't need to do that below. |
945 | */ |
950 | */ |
946 | if ((pl = is_player_inv (env)) != NULL) |
951 | if (pl) |
947 | { |
952 | { |
948 | esrv_del_item (pl->contr, op->count); |
953 | esrv_del_item (pl->contr, op->count); |
949 | esrv_send_item (pl, tmp); |
954 | esrv_send_item (pl, tmp); |
950 | } |
955 | } |
951 | } |
956 | } |
… | |
… | |
1121 | |
1126 | |
1122 | /* Determine direction now for random movers so we do the right thing */ |
1127 | /* Determine direction now for random movers so we do the right thing */ |
1123 | if (!dir) |
1128 | if (!dir) |
1124 | dir = rndm (1, 8); |
1129 | dir = rndm (1, 8); |
1125 | |
1130 | |
1126 | for (victim = get_map_ob (op->map, op->x, op->y); victim != NULL; victim = victim->above) |
1131 | for (victim = GET_MAP_OB (op->map, op->x, op->y); victim != NULL; victim = victim->above) |
1127 | { |
1132 | { |
1128 | if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_WIZPASS) && |
1133 | if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_WIZPASS) && |
1129 | (victim->move_type & op->move_type || !victim->move_type)) |
1134 | (victim->move_type & op->move_type || !victim->move_type)) |
1130 | { |
1135 | { |
1131 | |
1136 | |
… | |
… | |
1148 | } |
1153 | } |
1149 | |
1154 | |
1150 | if (should_director_abort (op, victim)) |
1155 | if (should_director_abort (op, victim)) |
1151 | return; |
1156 | return; |
1152 | |
1157 | |
1153 | for (nextmover = get_map_ob (m, nx, ny); nextmover != NULL; nextmover = nextmover->above) |
1158 | for (nextmover = GET_MAP_OB (m, nx, ny); nextmover != NULL; nextmover = nextmover->above) |
1154 | { |
1159 | { |
1155 | if (nextmover->type == PLAYERMOVER) |
1160 | if (nextmover->type == PLAYERMOVER) |
1156 | nextmover->speed_left = -.99; |
1161 | nextmover->speed_left = -.99; |
1157 | if (QUERY_FLAG (nextmover, FLAG_ALIVE)) |
1162 | if (QUERY_FLAG (nextmover, FLAG_ALIVE)) |
1158 | { |
1163 | { |
… | |
… | |
1327 | void |
1332 | void |
1328 | move_marker (object *op) |
1333 | move_marker (object *op) |
1329 | { |
1334 | { |
1330 | object *tmp, *tmp2; |
1335 | object *tmp, *tmp2; |
1331 | |
1336 | |
1332 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
1337 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
1333 | { |
1338 | { |
1334 | if (tmp->type == PLAYER) |
1339 | if (tmp->type == PLAYER) |
1335 | { /* we've got someone to MARK */ |
1340 | { /* we've got someone to MARK */ |
1336 | |
1341 | |
1337 | /* remove an old force with a slaying field == op->name */ |
1342 | /* remove an old force with a slaying field == op->name */ |
… | |
… | |
1428 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
1433 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
1429 | remove_force (op); |
1434 | remove_force (op); |
1430 | else |
1435 | else |
1431 | { |
1436 | { |
1432 | /* IF necessary, delete the item from the players inventory */ |
1437 | /* IF necessary, delete the item from the players inventory */ |
1433 | object *pl = is_player_inv (op); |
1438 | object *pl = op->in_player (); |
1434 | |
1439 | |
1435 | if (pl) |
1440 | if (pl) |
1436 | esrv_del_item (pl->contr, op->count); |
1441 | esrv_del_item (pl->contr, op->count); |
1437 | |
1442 | |
1438 | op->remove (); |
1443 | op->remove (); |