… | |
… | |
139 | if (!item) |
139 | if (!item) |
140 | return 0; |
140 | return 0; |
141 | |
141 | |
142 | for (op = op->below; op; op = op->below) |
142 | for (op = op->below; op; op = op->below) |
143 | if (op->arch->archname == item) |
143 | if (op->arch->archname == item) |
144 | if (!QUERY_FLAG (op, FLAG_CURSED) && !QUERY_FLAG (op, FLAG_DAMNED) |
144 | if (!op->flag [FLAG_CURSED] && !op->flag [FLAG_DAMNED] |
145 | && /* Loophole bug? -FD- */ !QUERY_FLAG (op, FLAG_UNPAID)) |
145 | && /* Loophole bug? -FD- */ !op->flag [FLAG_UNPAID]) |
146 | count += op->number_of (); |
146 | count += op->number_of (); |
147 | |
147 | |
148 | return count; |
148 | return count; |
149 | } |
149 | } |
150 | |
150 | |
… | |
… | |
197 | if (improver->slaying) |
197 | if (improver->slaying) |
198 | { |
198 | { |
199 | count = check_item (op, improver->slaying); |
199 | count = check_item (op, improver->slaying); |
200 | if (count < 1) |
200 | if (count < 1) |
201 | { |
201 | { |
202 | op->failmsg (format ("The gods want more %ss", &improver->slaying)); |
202 | op->failmsgf ("The gods want more %ss", &improver->slaying); |
203 | return 0; |
203 | return 0; |
204 | } |
204 | } |
205 | } |
205 | } |
206 | else |
206 | else |
207 | count = 1; |
207 | count = 1; |
… | |
… | |
332 | { |
332 | { |
333 | op->failmsg ("This weapon cannot be improved any more."); |
333 | op->failmsg ("This weapon cannot be improved any more."); |
334 | return 0; |
334 | return 0; |
335 | } |
335 | } |
336 | |
336 | |
337 | if (QUERY_FLAG (weapon, FLAG_APPLIED) |
337 | if (weapon->flag [FLAG_APPLIED] |
338 | && !check_item_power (op, weapon->item_power + 1)) |
338 | && !check_item_power (op, weapon->item_power + 1)) |
339 | { |
339 | { |
340 | op->failmsg ("Improving the weapon will make it too " |
340 | op->failmsg ("Improving the weapon will make it too " |
341 | "powerful for you to use. Unready it if you " |
341 | "powerful for you to use. Unready it if you " |
342 | "really want to improve it."); |
342 | "really want to improve it."); |
… | |
… | |
392 | sacrifice_needed *= 2; |
392 | sacrifice_needed *= 2; |
393 | |
393 | |
394 | sacrifice_count = check_sacrifice (op, improver); |
394 | sacrifice_count = check_sacrifice (op, improver); |
395 | if (sacrifice_count < sacrifice_needed) |
395 | if (sacrifice_count < sacrifice_needed) |
396 | { |
396 | { |
397 | op->failmsg (format ("You need at least %d %s.", sacrifice_needed, &improver->slaying)); |
397 | op->failmsgf ("You need at least %d %s.", sacrifice_needed, &improver->slaying); |
398 | return 0; |
398 | return 0; |
399 | } |
399 | } |
400 | |
400 | |
401 | eat_item (op, improver->slaying, sacrifice_needed); |
401 | eat_item (op, improver->slaying, sacrifice_needed); |
402 | weapon->item_power++; |
402 | weapon->item_power++; |
… | |
… | |
424 | * then calls improve_weapon to do the dirty work. |
424 | * then calls improve_weapon to do the dirty work. |
425 | */ |
425 | */ |
426 | static int |
426 | static int |
427 | check_improve_weapon (object *op, object *tmp) |
427 | check_improve_weapon (object *op, object *tmp) |
428 | { |
428 | { |
429 | object *otmp; |
|
|
430 | |
|
|
431 | if (op->type != PLAYER) |
429 | if (op->type != PLAYER) |
432 | return 0; |
430 | return 0; |
433 | |
431 | |
434 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
432 | if (!op->flag [FLAG_WIZCAST] && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
435 | { |
433 | { |
436 | op->failmsg ("Something blocks the magic of the scroll!"); |
434 | op->failmsg ("Something blocks the magic of the scroll!"); |
437 | return 0; |
435 | return 0; |
438 | } |
436 | } |
439 | |
437 | |
440 | otmp = find_marked_object (op); |
438 | object *otmp = op->mark (); |
441 | |
439 | |
442 | if (!otmp) |
440 | if (!otmp) |
443 | { |
441 | { |
444 | op->failmsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>"); |
442 | op->failmsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>"); |
445 | return 0; |
443 | return 0; |
446 | } |
444 | } |
447 | |
445 | |
448 | if (otmp->type != WEAPON && otmp->type != BOW) |
446 | if (otmp->type != WEAPON && otmp->type != BOW) |
449 | { |
447 | { |
450 | op->failmsg ("Marked item is not a weapon or bow!"); |
448 | op->failmsg ("Marked item is not a weapon or bow!"); |
|
|
449 | return 0; |
|
|
450 | } |
|
|
451 | |
|
|
452 | if (!op->apply (otmp, AP_UNAPPLY)) |
|
|
453 | { |
|
|
454 | op->failmsg ("You are unable to take off your weapon to improve it!"); |
451 | return 0; |
455 | return 0; |
452 | } |
456 | } |
453 | |
457 | |
454 | op->statusmsg ("Applied weapon builder."); |
458 | op->statusmsg ("Applied weapon builder."); |
455 | |
459 | |
… | |
… | |
481 | * changing of physical area right now. |
485 | * changing of physical area right now. |
482 | */ |
486 | */ |
483 | static int |
487 | static int |
484 | improve_armour (object *op, object *improver, object *armour) |
488 | improve_armour (object *op, object *improver, object *armour) |
485 | { |
489 | { |
486 | object *tmp; |
|
|
487 | |
|
|
488 | if (armour->magic >= settings.armor_max_enchant) |
490 | if (armour->magic >= settings.armor_max_enchant) |
489 | { |
491 | { |
490 | op->failmsg ("This armour can not be enchanted any further!"); |
492 | op->failmsg ("This armour can not be enchanted any further!"); |
491 | return 0; |
493 | return 0; |
492 | } |
494 | } |
… | |
… | |
503 | } |
505 | } |
504 | |
506 | |
505 | /* Split objects if needed. Can't insert tmp until the |
507 | /* Split objects if needed. Can't insert tmp until the |
506 | * end of this function - otherwise it will just re-merge. |
508 | * end of this function - otherwise it will just re-merge. |
507 | */ |
509 | */ |
508 | tmp = armour->nrof > 1 ? armour->split (armour->nrof - 1) : 0; |
510 | object *tmp = armour->nrof > 1 ? armour->split (armour->nrof - 1) : 0; |
509 | |
511 | |
510 | armour->magic++; |
512 | armour->magic++; |
511 | |
513 | |
512 | if (!settings.armor_speed_linear) |
514 | if (!settings.armor_speed_linear) |
513 | { |
515 | { |
… | |
… | |
551 | |
553 | |
552 | if (op->type == PLAYER) |
554 | if (op->type == PLAYER) |
553 | { |
555 | { |
554 | esrv_send_item (op, armour); |
556 | esrv_send_item (op, armour); |
555 | |
557 | |
556 | if (QUERY_FLAG (armour, FLAG_APPLIED)) |
558 | if (armour->flag [FLAG_APPLIED]) |
557 | op->update_stats (); |
559 | op->update_stats (); |
558 | } |
560 | } |
559 | |
561 | |
560 | improver->decrease (); |
562 | improver->decrease (); |
561 | |
563 | |
… | |
… | |
641 | for (ob = converter->inv->below, i = 1; ob; ob = ob->below, i++) |
643 | for (ob = converter->inv->below, i = 1; ob; ob = ob->below, i++) |
642 | if (rndm (0, i) == 0) |
644 | if (rndm (0, i) == 0) |
643 | ob_to_copy = ob; |
645 | ob_to_copy = ob; |
644 | |
646 | |
645 | item = ob_to_copy->deep_clone (); |
647 | item = ob_to_copy->deep_clone (); |
646 | CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); |
648 | item->clr_flag (FLAG_IS_A_TEMPLATE); |
647 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
649 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
648 | } |
650 | } |
649 | else |
651 | else |
650 | { |
652 | { |
651 | if (!conv_to) |
653 | if (!conv_to) |
… | |
… | |
664 | |
666 | |
665 | if (nr) |
667 | if (nr) |
666 | item->nrof *= nr; |
668 | item->nrof *= nr; |
667 | |
669 | |
668 | if (converter->flag [FLAG_PRECIOUS]) |
670 | if (converter->flag [FLAG_PRECIOUS]) |
669 | SET_FLAG (item, FLAG_UNPAID); |
671 | item->set_flag (FLAG_UNPAID); |
670 | |
672 | |
671 | if (converter->is_in_shop ()) |
673 | if (converter->is_in_shop ()) |
672 | { |
674 | { |
673 | // converters on shop floors don't work anymore, bug lets check for it |
675 | // converters on shop floors don't work anymore, bug lets check for it |
674 | // and report in case someone still does it. |
676 | // and report in case someone still does it. |
675 | LOG (llevDebug, "ITEMBUG: broken converter, converters on shop floor don't work: %s\n", |
677 | LOG (llevDebug, "ITEMBUG: broken converter, converters on shop floor don't work: %s\n", |
676 | converter->debug_desc ()); |
678 | converter->debug_desc ()); |
677 | SET_FLAG (item, FLAG_UNPAID); |
679 | item->set_flag (FLAG_UNPAID); |
678 | } |
680 | } |
679 | else if (price_in < sint64 (item->nrof) * item->value) |
681 | else if (price_in < sint64 (item->nrof) * item->value) |
680 | { |
682 | { |
681 | LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", |
683 | LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", |
682 | &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); |
684 | &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); |
… | |
… | |
731 | return 1; |
733 | return 1; |
732 | } |
734 | } |
733 | else if (!sack->env) |
735 | else if (!sack->env) |
734 | { |
736 | { |
735 | // active, but not ours: some other player has opened it |
737 | // active, but not ours: some other player has opened it |
736 | op->failmsg (format ("Somebody else is using the %s already.", query_name (sack))); |
738 | op->failmsgf ("Somebody else is using the %s already.", query_name (sack)); |
737 | return 1; |
739 | return 1; |
738 | } |
740 | } |
739 | |
741 | |
740 | // fall through to opening it (active in inv) |
742 | // fall through to opening it (active in inv) |
741 | } |
743 | } |
… | |
… | |
817 | { |
819 | { |
818 | int rv = 0; |
820 | int rv = 0; |
819 | double opinion; |
821 | double opinion; |
820 | object *tmp, *next; |
822 | object *tmp, *next; |
821 | |
823 | |
822 | SET_FLAG (op, FLAG_NO_APPLY); /* prevent loops */ |
824 | op->set_flag (FLAG_NO_APPLY); /* prevent loops */ |
823 | |
825 | |
824 | bool has_unpaid = false; |
826 | bool has_unpaid = false; |
825 | |
827 | |
826 | // quite inefficient to do this here twice, but the api doesn't lend itself to |
828 | // quite inefficient to do this here twice, but the api doesn't lend itself to |
827 | // a quick and small change :( |
829 | // a quick and small change :( |
… | |
… | |
840 | */ |
842 | */ |
841 | for (tmp = op->inv; tmp; tmp = next) |
843 | for (tmp = op->inv; tmp; tmp = next) |
842 | { |
844 | { |
843 | next = tmp->below; |
845 | next = tmp->below; |
844 | |
846 | |
845 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
847 | if (tmp->flag [FLAG_UNPAID]) |
846 | { |
848 | { |
847 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
849 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
848 | |
850 | |
849 | if (i >= 0) |
851 | if (i >= 0) |
850 | tmp->move (i); |
852 | tmp->move (i); |
851 | } |
853 | } |
852 | } |
854 | } |
853 | |
855 | |
854 | /* Don't teleport things like spell effects */ |
856 | /* Don't teleport things like spell effects */ |
855 | if (QUERY_FLAG (op, FLAG_NO_PICK)) |
857 | if (op->flag [FLAG_NO_PICK]) |
856 | return 0; |
858 | return 0; |
857 | |
859 | |
858 | /* unpaid objects, or non living objects, can't transfer by |
860 | /* unpaid objects, or non living objects, can't transfer by |
859 | * shop mats. Instead, put it on a nearby space. |
861 | * shop mats. Instead, put it on a nearby space. |
860 | */ |
862 | */ |
861 | if (QUERY_FLAG (op, FLAG_UNPAID) || !QUERY_FLAG (op, FLAG_ALIVE)) |
863 | if (op->flag [FLAG_UNPAID] || !op->flag [FLAG_ALIVE]) |
862 | { |
864 | { |
863 | /* Somebody dropped an unpaid item, just move to an adjacent place. */ |
865 | /* Somebody dropped an unpaid item, just move to an adjacent place. */ |
864 | int i = find_free_spot (op, op->map, op->x, op->y, 1, 9); |
866 | int i = find_free_spot (op, op->map, op->x, op->y, 1, 9); |
865 | |
867 | |
866 | if (i != -1) |
868 | if (i != -1) |
… | |
… | |
921 | op->y += freearr_y[i]; |
923 | op->y += freearr_y[i]; |
922 | rv = insert_ob_in_map (op, op->map, shop_mat, 0) == NULL; |
924 | rv = insert_ob_in_map (op, op->map, shop_mat, 0) == NULL; |
923 | } |
925 | } |
924 | } |
926 | } |
925 | |
927 | |
926 | CLEAR_FLAG (op, FLAG_NO_APPLY); |
928 | op->clr_flag (FLAG_NO_APPLY); |
927 | return rv; |
929 | return rv; |
928 | } |
930 | } |
929 | |
931 | |
930 | /** |
932 | /** |
931 | * Handles applying a sign. |
933 | * Handles applying a sign. |
… | |
… | |
959 | op->failmsg ("You cannot read it anymore."); |
961 | op->failmsg ("You cannot read it anymore."); |
960 | |
962 | |
961 | return; |
963 | return; |
962 | } |
964 | } |
963 | |
965 | |
964 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
966 | if (!op->flag [FLAG_WIZPASS]) |
965 | sign->last_eat++; |
967 | sign->last_eat++; |
966 | } |
968 | } |
967 | |
969 | |
968 | /* Sign or magic mouth? Do we need to see it, or does it talk to us? |
970 | /* Sign or magic mouth? Do we need to see it, or does it talk to us? |
969 | * No way to know for sure. The presumption is basically that if |
971 | * No way to know for sure. The presumption is basically that if |
970 | * move_on is zero, it needs to be manually applied (doesn't talk |
972 | * move_on is zero, it needs to be manually applied (doesn't talk |
971 | * to us). |
973 | * to us). |
972 | */ |
974 | */ |
973 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ) && !sign->move_on) |
975 | if (op->flag [FLAG_BLIND] && !op->flag [FLAG_WIZ] && !sign->move_on) |
974 | { |
976 | { |
975 | op->failmsg ("You are unable to read while blind!"); |
977 | op->failmsg ("You are unable to read while blind!"); |
976 | return; |
978 | return; |
977 | } |
979 | } |
978 | |
980 | |
… | |
… | |
1075 | who->statusmsg (format ("You unready %s.", query_name (op))); |
1077 | who->statusmsg (format ("You unready %s.", query_name (op))); |
1076 | change_abil (who, op); |
1078 | change_abil (who, op); |
1077 | } |
1079 | } |
1078 | else |
1080 | else |
1079 | { |
1081 | { |
1080 | who->change_skill (0); |
|
|
1081 | |
|
|
1082 | if (op->type == BOW) |
1082 | if (op->type == BOW) |
1083 | op->flag [FLAG_READY_BOW ] = false; |
1083 | op->flag [FLAG_READY_BOW ] = false; |
1084 | else |
1084 | else |
1085 | op->flag [FLAG_READY_RANGE] = false; |
1085 | op->flag [FLAG_READY_RANGE] = false; |
1086 | } |
1086 | } |
… | |
… | |
1167 | static bool |
1167 | static bool |
1168 | unapply_for_ob (object *who, object *op, int aflags) |
1168 | unapply_for_ob (object *who, object *op, int aflags) |
1169 | { |
1169 | { |
1170 | if (op->is_range ()) |
1170 | if (op->is_range ()) |
1171 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
1171 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
1172 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->is_range ()) |
1172 | if (tmp->flag [FLAG_APPLIED] && tmp->is_range ()) |
1173 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED))) |
1173 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!tmp->flag [FLAG_CURSED] && !tmp->flag [FLAG_DAMNED])) |
1174 | { |
1174 | { |
1175 | if (aflags & AP_PRINT) |
1175 | if (aflags & AP_PRINT) |
1176 | who->failmsg (query_name (tmp)); |
1176 | who->failmsg (query_name (tmp)); |
1177 | else |
1177 | else |
1178 | unapply_special (who, tmp, aflags); |
1178 | unapply_special (who, tmp, aflags); |
… | |
… | |
1181 | { |
1181 | { |
1182 | /* In this case, we want to try and remove a cursed item. |
1182 | /* In this case, we want to try and remove a cursed item. |
1183 | * While we know it won't work, we want unapply_special to |
1183 | * While we know it won't work, we want unapply_special to |
1184 | * at least generate the message. |
1184 | * at least generate the message. |
1185 | */ |
1185 | */ |
1186 | who->failmsg (format ("No matter how hard you try, you just can't remove the %s." CANNOT_REMOVE_CURSED, query_name (tmp))); |
1186 | who->failmsgf ("No matter how hard you try, you just can't remove the %s." CANNOT_REMOVE_CURSED, query_name (tmp)); |
1187 | return 1; |
1187 | return 1; |
1188 | } |
1188 | } |
1189 | |
1189 | |
1190 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1190 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1191 | { |
1191 | { |
… | |
… | |
1211 | #endif |
1211 | #endif |
1212 | return 1; |
1212 | return 1; |
1213 | } |
1213 | } |
1214 | |
1214 | |
1215 | /* If we are just printing, we don't care about cursed status */ |
1215 | /* If we are just printing, we don't care about cursed status */ |
1216 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!(QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)))) |
1216 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!(tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]))) |
1217 | { |
1217 | { |
1218 | if (aflags & AP_PRINT) |
1218 | if (aflags & AP_PRINT) |
1219 | who->failmsg (query_name (tmp)); |
1219 | who->failmsg (query_name (tmp)); |
1220 | else |
1220 | else |
1221 | unapply_special (who, tmp, aflags); |
1221 | unapply_special (who, tmp, aflags); |
… | |
… | |
1225 | /* Cursed item that we can't unequip - tell the player. |
1225 | /* Cursed item that we can't unequip - tell the player. |
1226 | * Note this could be annoying if this is just one of a few, |
1226 | * Note this could be annoying if this is just one of a few, |
1227 | * so it may not be critical (eg, putting on a ring and you have |
1227 | * so it may not be critical (eg, putting on a ring and you have |
1228 | * one cursed ring.) |
1228 | * one cursed ring.) |
1229 | */ |
1229 | */ |
1230 | who->failmsg (format ("The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp))); |
1230 | who->failmsgf ("The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp)); |
1231 | } |
1231 | } |
1232 | |
1232 | |
1233 | last = tmp->below; |
1233 | last = tmp->below; |
1234 | } |
1234 | } |
1235 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
1235 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
… | |
… | |
1333 | * the weapon/shield checks, and the range checks for monsters, |
1333 | * the weapon/shield checks, and the range checks for monsters, |
1334 | * because you can't control those just by body location - bows, shields, |
1334 | * because you can't control those just by body location - bows, shields, |
1335 | * and weapons all use the same slot. Similar for horn/rod/wand - they |
1335 | * and weapons all use the same slot. Similar for horn/rod/wand - they |
1336 | * all use the same location. |
1336 | * all use the same location. |
1337 | */ |
1337 | */ |
1338 | if (op->type == WEAPON && !QUERY_FLAG (who, FLAG_USE_WEAPON)) |
1338 | if (op->type == WEAPON && !who->flag [FLAG_USE_WEAPON]) |
1339 | retval |= CAN_APPLY_RESTRICTION; |
1339 | retval |= CAN_APPLY_RESTRICTION; |
1340 | |
1340 | |
1341 | if (op->type == SHIELD && !QUERY_FLAG (who, FLAG_USE_SHIELD)) |
1341 | if (op->type == SHIELD && !who->flag [FLAG_USE_SHIELD]) |
1342 | retval |= CAN_APPLY_RESTRICTION; |
1342 | retval |= CAN_APPLY_RESTRICTION; |
1343 | |
1343 | |
1344 | if (who->type != PLAYER) |
1344 | if (who->type != PLAYER) |
1345 | { |
1345 | { |
1346 | if ((op->type == WAND || op->type == HORN || op->type == ROD) && !QUERY_FLAG (who, FLAG_USE_RANGE)) |
1346 | if ((op->type == WAND || op->type == HORN || op->type == ROD) && !who->flag [FLAG_USE_RANGE]) |
1347 | retval |= CAN_APPLY_RESTRICTION; |
1347 | retval |= CAN_APPLY_RESTRICTION; |
1348 | |
1348 | |
1349 | if (op->type == BOW && !QUERY_FLAG (who, FLAG_USE_BOW)) |
1349 | if (op->type == BOW && !who->flag [FLAG_USE_BOW]) |
1350 | retval |= CAN_APPLY_RESTRICTION; |
1350 | retval |= CAN_APPLY_RESTRICTION; |
1351 | |
1351 | |
1352 | if (op->type == RING && !QUERY_FLAG (who, FLAG_USE_RING)) |
1352 | if (op->type == RING && !who->flag [FLAG_USE_RING]) |
1353 | retval |= CAN_APPLY_RESTRICTION; |
1353 | retval |= CAN_APPLY_RESTRICTION; |
1354 | |
1354 | |
1355 | if (op->type == BOW && !QUERY_FLAG (who, FLAG_USE_BOW)) |
1355 | if (op->type == BOW && !who->flag [FLAG_USE_BOW]) |
1356 | retval |= CAN_APPLY_RESTRICTION; |
1356 | retval |= CAN_APPLY_RESTRICTION; |
1357 | } |
1357 | } |
1358 | |
1358 | |
1359 | return retval; |
1359 | return retval; |
1360 | } |
1360 | } |
… | |
… | |
1401 | //TODO: remove these when apply_special is no longer exposed |
1401 | //TODO: remove these when apply_special is no longer exposed |
1402 | if (op->env != who) |
1402 | if (op->env != who) |
1403 | return 1; /* op is not in inventory */ |
1403 | return 1; /* op is not in inventory */ |
1404 | |
1404 | |
1405 | /* trying to unequip op */ |
1405 | /* trying to unequip op */ |
1406 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
1406 | if (op->flag [FLAG_APPLIED]) |
1407 | { |
1407 | { |
1408 | /* always apply, so no reason to unapply */ |
1408 | /* always apply, so no reason to unapply */ |
1409 | if (basic_flag == AP_APPLY) |
1409 | if (basic_flag == AP_APPLY) |
1410 | return 0; |
1410 | return 0; |
1411 | |
1411 | |
1412 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
1412 | if (!(aflags & AP_IGNORE_CURSE) && (op->flag [FLAG_CURSED] || op->flag [FLAG_DAMNED])) |
1413 | { |
1413 | { |
1414 | who->failmsg (format ("No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, query_name (op))); |
1414 | who->failmsgf ("No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, query_name (op)); |
1415 | return 1; |
1415 | return 1; |
1416 | } |
1416 | } |
1417 | |
1417 | |
1418 | return unapply_special (who, op, aflags); |
1418 | return unapply_special (who, op, aflags); |
1419 | } |
1419 | } |
… | |
… | |
1425 | /* Can't just apply this object. Lets see what not and what to do */ |
1425 | /* Can't just apply this object. Lets see what not and what to do */ |
1426 | if (int i = can_apply_object (who, op)) |
1426 | if (int i = can_apply_object (who, op)) |
1427 | { |
1427 | { |
1428 | if (i & CAN_APPLY_NEVER) |
1428 | if (i & CAN_APPLY_NEVER) |
1429 | { |
1429 | { |
1430 | who->failmsg (format ("You don't have the body to use a %s. H<You can never apply this item.>", query_name (op))); |
1430 | who->failmsgf ("You don't have the body to use a %s. H<You can never apply this item.>", query_name (op)); |
1431 | return 1; |
1431 | return 1; |
1432 | } |
1432 | } |
1433 | else if (i & CAN_APPLY_RESTRICTION) |
1433 | else if (i & CAN_APPLY_RESTRICTION) |
1434 | { |
1434 | { |
1435 | who->failmsg (format ( |
1435 | who->failmsgf ( |
1436 | "You have a prohibition against using a %s. " |
1436 | "You have a prohibition against using a %s. " |
1437 | "H<Your belief, profession or class prevents you from applying this item.>", |
1437 | "H<Your belief, profession or class prevents you from applying this item.>", |
1438 | query_name (op) |
1438 | query_name (op) |
1439 | )); |
1439 | ); |
1440 | return 1; |
1440 | return 1; |
1441 | } |
1441 | } |
1442 | |
1442 | |
1443 | if (who->type != PLAYER) |
1443 | if (who->type != PLAYER) |
1444 | { |
1444 | { |
… | |
… | |
1465 | // try to ready attached skill first |
1465 | // try to ready attached skill first |
1466 | skop = find_skill_by_name (who, op->skill); |
1466 | skop = find_skill_by_name (who, op->skill); |
1467 | |
1467 | |
1468 | if (!skop) |
1468 | if (!skop) |
1469 | { |
1469 | { |
1470 | who->failmsg (format ("You need the %s skill to use this item!", &op->skill)); |
1470 | who->failmsgf ("You need the %s skill to use this item!", &op->skill); |
1471 | return 1; |
1471 | return 1; |
1472 | } |
1472 | } |
1473 | else if (!who->apply (skop, AP_APPLY | AP_NO_SLOT)) |
1473 | else if (!who->apply (skop, AP_APPLY | AP_NO_SLOT)) |
1474 | { |
1474 | { |
1475 | who->failmsg (format ("You can't use the required %s skill!", &op->skill)); |
1475 | who->failmsgf ("You can't use the required %s skill!", &op->skill); |
1476 | return 1; |
1476 | return 1; |
1477 | } |
1477 | } |
1478 | } |
1478 | } |
1479 | |
1479 | |
1480 | if (!check_item_power (who, op->item_power)) |
1480 | if (!check_item_power (who, op->item_power)) |
… | |
… | |
1512 | if (player *pl = who->contr) |
1512 | if (player *pl = who->contr) |
1513 | { |
1513 | { |
1514 | who->statusmsg (format ("You wield %s.", query_name (op))); |
1514 | who->statusmsg (format ("You wield %s.", query_name (op))); |
1515 | change_abil (who, op); |
1515 | change_abil (who, op); |
1516 | } |
1516 | } |
1517 | else |
|
|
1518 | who->change_skill (skop); |
|
|
1519 | |
1517 | |
1520 | op->flag [FLAG_READY_WEAPON] = true; |
1518 | op->flag [FLAG_READY_WEAPON] = true; |
1521 | break; |
1519 | break; |
1522 | |
1520 | |
1523 | case ARMOUR: |
1521 | case ARMOUR: |
… | |
… | |
1528 | case GIRDLE: |
1526 | case GIRDLE: |
1529 | case BRACERS: |
1527 | case BRACERS: |
1530 | case CLOAK: |
1528 | case CLOAK: |
1531 | case RING: |
1529 | case RING: |
1532 | case AMULET: |
1530 | case AMULET: |
1533 | SET_FLAG (op, FLAG_APPLIED); |
1531 | op->set_flag (FLAG_APPLIED); |
1534 | who->statusmsg (format ("You wear %s.", query_name (op))); |
1532 | who->statusmsg (format ("You wear %s.", query_name (op))); |
1535 | change_abil (who, op); |
1533 | change_abil (who, op); |
1536 | break; |
1534 | break; |
1537 | |
1535 | |
1538 | case SKILL_TOOL: |
1536 | case SKILL_TOOL: |
1539 | // applying a skill tool does not ready the skill |
1537 | // applying a skill tool does not ready the skill |
1540 | // if something needs the skill, it has to ready it itself |
1538 | // if something needs the skill, it has to ready it itself |
1541 | //TODO: unapplying should unapply the skill, though |
1539 | //TODO: unapplying should unapply the skill, though |
1542 | SET_FLAG (op, FLAG_APPLIED); |
1540 | op->set_flag (FLAG_APPLIED); |
1543 | break; |
1541 | break; |
1544 | |
1542 | |
1545 | case SKILL: |
1543 | case SKILL: |
1546 | if (!(aflags & AP_NO_SLOT)) |
1544 | if (!(aflags & AP_NO_SLOT)) |
1547 | { |
1545 | { |
1548 | // skill is used on it's own, as opposed to being a chosen_skill |
1546 | // skill is used on it's own, as opposed to being a chosen_skill |
1549 | |
1547 | |
1550 | if (skill_flags [op->subtype] & (SF_NEED_ITEM | SF_MANA)) |
1548 | if (skill_flags [op->subtype] & (SF_NEED_ITEM | SF_MANA)) |
1551 | { |
1549 | { |
1552 | who->failmsg (format ( |
1550 | who->failmsgf ( |
1553 | "You feel as if you wanted to do something funny, but you can't remember what. " |
1551 | "You feel as if you wanted to do something funny, but you can't remember what. " |
1554 | "H<The %s skill needs something else to function, for example a tool, weapon, rod, or spell. " |
1552 | "H<The %s skill needs something else to function, for example a tool, weapon, rod, or spell. " |
1555 | "It cannot be used on its own.>", |
1553 | "It cannot be used on its own.>", |
1556 | &op->skill |
1554 | &op->skill |
1557 | )); |
1555 | ); |
1558 | if (tmp) who->insert (tmp); |
1556 | if (tmp) who->insert (tmp); |
1559 | return 1; |
1557 | return 1; |
1560 | } |
1558 | } |
1561 | |
1559 | |
1562 | if (skill_flags [op->subtype] & SF_AUTARK |
1560 | if (skill_flags [op->subtype] & SF_AUTARK |
1563 | || !(skill_flags [op->subtype] & (SF_COMBAT | SF_RANGED))) |
1561 | || !(skill_flags [op->subtype] & (SF_COMBAT | SF_RANGED))) |
1564 | { |
1562 | { |
1565 | if (skill_flags [op->subtype] & SF_USE) |
1563 | if (skill_flags [op->subtype] & SF_USE) |
1566 | who->failmsg (format ( |
1564 | who->failmsgf ( |
1567 | "You feel as if you wanted to do something funny, but you can't remember what. " |
1565 | "You feel as if you wanted to do something funny, but you can't remember what. " |
1568 | "H<The %s skill cannot be readied, instead, try C<use_skill %s>.>", |
1566 | "H<The %s skill cannot be readied, instead, try C<use_skill %s>.>", |
1569 | &op->skill, &op->skill |
1567 | &op->skill, &op->skill |
1570 | )); |
1568 | ); |
1571 | else |
1569 | else |
1572 | who->failmsg (format ( |
1570 | who->failmsgf ( |
1573 | "You feel as if you wanted to do something funny, but you can't remember what. " |
1571 | "You feel as if you wanted to do something funny, but you can't remember what. " |
1574 | "H<The %s skill cannot be readied or used, it is always active.>", |
1572 | "H<The %s skill cannot be readied or used, it is always active.>", |
1575 | &op->skill |
1573 | &op->skill |
1576 | )); |
1574 | ); |
1577 | |
1575 | |
1578 | if (tmp) who->insert (tmp); |
1576 | if (tmp) who->insert (tmp); |
1579 | |
1577 | |
1580 | return 1; |
1578 | return 1; |
1581 | } |
1579 | } |
… | |
… | |
1585 | who->statusmsg (format ("You can now use the %s skill.", &op->skill)); |
1583 | who->statusmsg (format ("You can now use the %s skill.", &op->skill)); |
1586 | else |
1584 | else |
1587 | who->statusmsg (format ("You ready %s.", query_name (op))); |
1585 | who->statusmsg (format ("You ready %s.", query_name (op))); |
1588 | } |
1586 | } |
1589 | |
1587 | |
1590 | SET_FLAG (who, FLAG_READY_SKILL); |
1588 | who->set_flag (FLAG_READY_SKILL); |
1591 | SET_FLAG (op, FLAG_APPLIED); |
1589 | op->set_flag (FLAG_APPLIED); |
1592 | change_abil (who, op); |
1590 | change_abil (who, op); |
1593 | break; |
1591 | break; |
1594 | |
1592 | |
1595 | case BOW: |
1593 | case BOW: |
1596 | if (op->level && (!op->name.starts_with (who->name) || op->name [who->name.length ()] != '\'')) |
1594 | if (op->level && (!op->name.starts_with (who->name) || op->name [who->name.length ()] != '\'')) |
… | |
… | |
1627 | |
1625 | |
1628 | /*FALLTHROUGH*/ |
1626 | /*FALLTHROUGH*/ |
1629 | case WAND: |
1627 | case WAND: |
1630 | case ROD: |
1628 | case ROD: |
1631 | case HORN: |
1629 | case HORN: |
1632 | /* check for skill, alter player status */ |
|
|
1633 | |
|
|
1634 | if (!skop) |
|
|
1635 | { |
|
|
1636 | who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO |
|
|
1637 | if (tmp) who->insert (tmp); |
|
|
1638 | return 1; |
|
|
1639 | } |
|
|
1640 | |
|
|
1641 | op->flag [FLAG_APPLIED] = true; |
1630 | op->flag [FLAG_APPLIED] = true; |
1642 | |
1631 | |
1643 | if (player *pl = who->contr) |
1632 | if (player *pl = who->contr) |
1644 | { |
1633 | { |
1645 | who->statusmsg (format ("You ready %s.", query_name (op))); |
1634 | who->statusmsg (format ("You ready %s.", query_name (op))); |
… | |
… | |
1649 | |
1638 | |
1650 | change_abil (who, op); |
1639 | change_abil (who, op); |
1651 | } |
1640 | } |
1652 | else |
1641 | else |
1653 | { |
1642 | { |
1654 | who->change_skill (skop); |
|
|
1655 | |
|
|
1656 | if (op->type == BOW) |
1643 | if (op->type == BOW) |
1657 | op->flag [FLAG_READY_BOW ] = true; |
1644 | op->flag [FLAG_READY_BOW ] = true; |
1658 | else |
1645 | else |
1659 | op->flag [FLAG_READY_RANGE] = true; |
1646 | op->flag [FLAG_READY_RANGE] = true; |
1660 | } |
1647 | } |
… | |
… | |
1671 | |
1658 | |
1672 | default: |
1659 | default: |
1673 | who->statusmsg (format ("You apply %s.", query_name (op))); |
1660 | who->statusmsg (format ("You apply %s.", query_name (op))); |
1674 | } |
1661 | } |
1675 | |
1662 | |
1676 | SET_FLAG (op, FLAG_APPLIED); |
1663 | op->set_flag (FLAG_APPLIED); |
1677 | |
1664 | |
1678 | if (tmp) who->insert (tmp); |
1665 | if (tmp) who->insert (tmp); |
1679 | |
1666 | |
1680 | who->update_stats (); |
1667 | who->update_stats (); |
1681 | |
1668 | |
1682 | /* We exclude spell casting objects. The fire code will set the |
1669 | /* We exclude spell casting objects. The fire code will set the |
1683 | * been applied flag when they are used - until that point, |
1670 | * been applied flag when they are used - until that point, |
1684 | * you don't know anything about them. |
1671 | * you don't know anything about them. |
1685 | */ |
1672 | */ |
1686 | if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD) |
1673 | if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD) |
1687 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
1674 | op->set_flag (FLAG_BEEN_APPLIED); |
1688 | |
1675 | |
1689 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
1676 | if (op->flag [FLAG_CURSED] || op->flag [FLAG_DAMNED]) |
1690 | if (who->type == PLAYER) |
1677 | if (who->type == PLAYER) |
1691 | { |
1678 | { |
1692 | who->failmsg ( |
1679 | who->failmsg ( |
1693 | "Oops, it feels deadly cold! " |
1680 | "Oops, it feels deadly cold! " |
1694 | "H<Maybe it wasn't such a bright idea to apply this cursed or damned item.>" |
1681 | "H<Maybe it wasn't such a bright idea to apply this cursed or damned item.>" |
1695 | ); |
1682 | ); |
1696 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
1683 | op->set_flag (FLAG_KNOWN_CURSED); |
1697 | } |
1684 | } |
1698 | |
1685 | |
1699 | if (object *pl = op->visible_to ()) |
1686 | if (object *pl = op->visible_to ()) |
1700 | esrv_send_item (pl, op); |
1687 | esrv_send_item (pl, op); |
1701 | |
1688 | |
… | |
… | |
1774 | return 0; |
1761 | return 0; |
1775 | |
1762 | |
1776 | /* if the player has a marked item, identify that if it needs to be |
1763 | /* if the player has a marked item, identify that if it needs to be |
1777 | * identified. If it doesn't, then go through the player inventory. |
1764 | * identified. If it doesn't, then go through the player inventory. |
1778 | */ |
1765 | */ |
1779 | if (object *marked = find_marked_object (pl)) |
1766 | if (object *marked = pl->mark ()) |
1780 | if (!QUERY_FLAG (marked, FLAG_IDENTIFIED) && need_identify (marked)) |
1767 | if (!marked->flag [FLAG_IDENTIFIED] && need_identify (marked)) |
1781 | { |
1768 | { |
1782 | if (operate_altar (altar, &money, pl)) |
1769 | if (operate_altar (altar, &money, pl)) |
1783 | { |
1770 | { |
1784 | identify (marked); |
1771 | identify (marked); |
1785 | |
1772 | |
… | |
… | |
1791 | } |
1778 | } |
1792 | } |
1779 | } |
1793 | |
1780 | |
1794 | for (object *id = pl->inv; id; id = id->below) |
1781 | for (object *id = pl->inv; id; id = id->below) |
1795 | { |
1782 | { |
1796 | if (!QUERY_FLAG (id, FLAG_IDENTIFIED) && !id->invisible && need_identify (id)) |
1783 | if (!id->flag [FLAG_IDENTIFIED] && !id->invisible && need_identify (id)) |
1797 | { |
1784 | { |
1798 | if (operate_altar (altar, &money, pl)) |
1785 | if (operate_altar (altar, &money, pl)) |
1799 | { |
1786 | { |
1800 | identify (id); |
1787 | identify (id); |
1801 | |
1788 | |
… | |
… | |
1847 | |
1834 | |
1848 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
1835 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
1849 | { |
1836 | { |
1850 | op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); |
1837 | op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); |
1851 | |
1838 | |
1852 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
1839 | tmp->clr_flag (FLAG_APPLIED); |
1853 | return 0; |
1840 | return 0; |
1854 | } |
1841 | } |
1855 | |
1842 | |
1856 | if (op->type == PLAYER) |
1843 | if (op->type == PLAYER) |
1857 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1844 | if (!tmp->flag [FLAG_IDENTIFIED]) |
1858 | identify (tmp); |
1845 | identify (tmp); |
1859 | |
1846 | |
1860 | handle_apply_yield (tmp); |
1847 | handle_apply_yield (tmp); |
1861 | |
1848 | |
1862 | /* Potion of restoration - only for players */ |
1849 | /* Potion of restoration - only for players */ |
1863 | if (op->type == PLAYER && (tmp->attacktype & AT_DEPLETE)) |
1850 | if (op->type == PLAYER && (tmp->attacktype & AT_DEPLETE)) |
1864 | { |
1851 | { |
1865 | object *depl; |
1852 | object *depl; |
1866 | archetype *at; |
1853 | archetype *at; |
1867 | |
1854 | |
1868 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
1855 | if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]) |
1869 | { |
1856 | { |
1870 | op->drain_stat (); |
1857 | op->drain_stat (); |
1871 | op->update_stats (); |
1858 | op->update_stats (); |
1872 | tmp->decrease (); |
1859 | tmp->decrease (); |
1873 | return 1; |
1860 | return 1; |
… | |
… | |
1900 | /* improvement potion - only for players */ |
1887 | /* improvement potion - only for players */ |
1901 | if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) |
1888 | if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) |
1902 | { |
1889 | { |
1903 | for (i = 1; i < min (11, op->level); i++) |
1890 | for (i = 1; i < min (11, op->level); i++) |
1904 | { |
1891 | { |
1905 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
1892 | if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]) |
1906 | { |
1893 | { |
1907 | if (op->contr->levhp[i] != 1) |
1894 | if (op->contr->levhp[i] != 1) |
1908 | { |
1895 | { |
1909 | op->contr->levhp[i] = 1; |
1896 | op->contr->levhp[i] = 1; |
1910 | break; |
1897 | break; |
… | |
… | |
1946 | |
1933 | |
1947 | /* Just makes checking easier */ |
1934 | /* Just makes checking easier */ |
1948 | if (i < min (11, op->level)) |
1935 | if (i < min (11, op->level)) |
1949 | got_one = 1; |
1936 | got_one = 1; |
1950 | |
1937 | |
1951 | if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED)) |
1938 | if (!tmp->flag [FLAG_CURSED] && !tmp->flag [FLAG_DAMNED]) |
1952 | { |
1939 | { |
1953 | if (got_one) |
1940 | if (got_one) |
1954 | { |
1941 | { |
1955 | op->update_stats (); |
1942 | op->update_stats (); |
1956 | op->statusmsg ("The Gods smile upon you and remake you " |
1943 | op->statusmsg ("The Gods smile upon you and remake you " |
… | |
… | |
1981 | * there is no limit to the number of spells that potions can be cast, |
1968 | * there is no limit to the number of spells that potions can be cast, |
1982 | * but direction is problematic to try and imbue fireball potions for example. |
1969 | * but direction is problematic to try and imbue fireball potions for example. |
1983 | */ |
1970 | */ |
1984 | if (tmp->inv) |
1971 | if (tmp->inv) |
1985 | { |
1972 | { |
1986 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
1973 | if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]) |
1987 | { |
1974 | { |
1988 | op->failmsg ("Yech! Your lungs are on fire!"); |
1975 | op->failmsg ("Yech! Your lungs are on fire!"); |
1989 | create_exploding_ball_at (op, op->level); |
1976 | create_exploding_ball_at (op, op->level); |
1990 | } |
1977 | } |
1991 | else |
1978 | else |
1992 | cast_spell (op, tmp, op->facing, tmp->inv, NULL); |
1979 | cast_spell (op, tmp, op->facing, tmp->inv, NULL); |
1993 | |
1980 | |
1994 | tmp->decrease (); |
1981 | tmp->decrease (); |
1995 | |
1982 | |
1996 | /* if youre dead, no point in doing this... */ |
1983 | /* if youre dead, no point in doing this... */ |
1997 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1984 | if (!op->flag [FLAG_REMOVED]) |
1998 | op->update_stats (); |
1985 | op->update_stats (); |
1999 | |
1986 | |
2000 | return 1; |
1987 | return 1; |
2001 | } |
1988 | } |
2002 | |
1989 | |
… | |
… | |
2017 | |
2004 | |
2018 | /* This is a protection potion */ |
2005 | /* This is a protection potion */ |
2019 | if (force) |
2006 | if (force) |
2020 | { |
2007 | { |
2021 | /* cursed items last longer */ |
2008 | /* cursed items last longer */ |
2022 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
2009 | if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]) |
2023 | { |
2010 | { |
2024 | force->stats.food *= 10; |
2011 | force->stats.food *= 10; |
2025 | for (i = 0; i < NROFATTACKS; i++) |
2012 | for (i = 0; i < NROFATTACKS; i++) |
2026 | if (force->resist[i] > 0) |
2013 | if (force->resist[i] > 0) |
2027 | force->resist[i] = -force->resist[i]; /* prot => vuln */ |
2014 | force->resist[i] = -force->resist[i]; /* prot => vuln */ |
2028 | } |
2015 | } |
2029 | |
2016 | |
2030 | force->speed_left = -1; |
2017 | force->speed_left = -1; |
2031 | force = insert_ob_in_ob (force, op); |
2018 | force = insert_ob_in_ob (force, op); |
2032 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
2019 | tmp->clr_flag (FLAG_APPLIED); |
2033 | SET_FLAG (force, FLAG_APPLIED); |
2020 | force->set_flag (FLAG_APPLIED); |
2034 | change_abil (op, force); |
2021 | change_abil (op, force); |
2035 | tmp->decrease (); |
2022 | tmp->decrease (); |
2036 | return 1; |
2023 | return 1; |
2037 | } |
2024 | } |
2038 | |
2025 | |
2039 | /* Only thing left are the stat potions */ |
2026 | /* Only thing left are the stat potions */ |
2040 | if (op->type == PLAYER) |
2027 | if (op->type == PLAYER) |
2041 | { /* only for players */ |
2028 | { /* only for players */ |
2042 | if ((QUERY_FLAG (tmp, FLAG_CURSED) |
2029 | if ((tmp->flag [FLAG_CURSED] |
2043 | || QUERY_FLAG (tmp, FLAG_DAMNED)) |
2030 | || tmp->flag [FLAG_DAMNED]) |
2044 | && tmp->value != 0) |
2031 | && tmp->value != 0) |
2045 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
2032 | tmp->clr_flag (FLAG_APPLIED); |
2046 | else |
2033 | else |
2047 | SET_FLAG (tmp, FLAG_APPLIED); |
2034 | tmp->set_flag (FLAG_APPLIED); |
2048 | |
2035 | |
2049 | if (!change_abil (op, tmp)) |
2036 | if (!change_abil (op, tmp)) |
2050 | op->statusmsg ("Nothing happened."); |
2037 | op->statusmsg ("Nothing happened."); |
2051 | } |
2038 | } |
2052 | |
2039 | |
2053 | /* CLEAR_FLAG is so that if the character has other potions |
2040 | /* CLEAR_FLAG is so that if the character has other potions |
2054 | * that were grouped with the one consumed, his |
2041 | * that were grouped with the one consumed, his |
2055 | * stat will not be raised by them. fix_player just clears |
2042 | * stat will not be raised by them. fix_player just clears |
2056 | * up all the stats. |
2043 | * up all the stats. |
2057 | */ |
2044 | */ |
2058 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
2045 | tmp->clr_flag (FLAG_APPLIED); |
2059 | op->update_stats (); |
2046 | op->update_stats (); |
2060 | tmp->decrease (); |
2047 | tmp->decrease (); |
2061 | return 1; |
2048 | return 1; |
2062 | } |
2049 | } |
2063 | |
2050 | |
… | |
… | |
2074 | move_apply (object *trap, object *victim, object *originator) |
2061 | move_apply (object *trap, object *victim, object *originator) |
2075 | { |
2062 | { |
2076 | static int recursion_depth = 0; |
2063 | static int recursion_depth = 0; |
2077 | |
2064 | |
2078 | /* Only exits affect DMs. */ |
2065 | /* Only exits affect DMs. */ |
2079 | if (QUERY_FLAG (victim, FLAG_WIZPASS) && trap->type != EXIT && trap->type != SIGN) |
2066 | if (victim->flag [FLAG_WIZPASS] && trap->type != EXIT && trap->type != SIGN) |
2080 | return; |
2067 | return; |
2081 | |
2068 | |
2082 | /* move_apply() is the most likely candidate for causing unwanted and |
2069 | /* move_apply() is the most likely candidate for causing unwanted and |
2083 | * possibly unlimited recursion. |
2070 | * possibly unlimited recursion. |
2084 | */ |
2071 | */ |
… | |
… | |
2160 | * trigger this here and get hit by own missile - and will be own enemy. |
2147 | * trigger this here and get hit by own missile - and will be own enemy. |
2161 | * Victim then is his own enemy and will start to kill herself (this is |
2148 | * Victim then is his own enemy and will start to kill herself (this is |
2162 | * removed) but we have not synced victim and his missile. To avoid senseless |
2149 | * removed) but we have not synced victim and his missile. To avoid senseless |
2163 | * action, we avoid hits here |
2150 | * action, we avoid hits here |
2164 | */ |
2151 | */ |
2165 | if ((QUERY_FLAG (victim, FLAG_ALIVE) && trap->has_active_speed ()) |
2152 | if ((victim->flag [FLAG_ALIVE] && trap->has_active_speed ()) |
2166 | && trap->owner != victim) |
2153 | && trap->owner != victim) |
2167 | hit_with_arrow (trap, victim); |
2154 | hit_with_arrow (trap, victim); |
2168 | break; |
2155 | break; |
2169 | |
2156 | |
2170 | case SPELL_EFFECT: |
2157 | case SPELL_EFFECT: |
… | |
… | |
2214 | } |
2201 | } |
2215 | |
2202 | |
2216 | case CONVERTER: |
2203 | case CONVERTER: |
2217 | if (convert_item (victim, trap) < 0) |
2204 | if (convert_item (victim, trap) < 0) |
2218 | { |
2205 | { |
2219 | originator->failmsg (format ("The %s seems to be broken!", query_name (trap))); |
2206 | originator->failmsgf ("The %s seems to be broken!", query_name (trap)); |
2220 | archetype::get (shstr_burnout)->insert_at (trap, trap); |
2207 | archetype::get (shstr_burnout)->insert_at (trap, trap); |
2221 | } |
2208 | } |
2222 | |
2209 | |
2223 | break; |
2210 | break; |
2224 | |
2211 | |
… | |
… | |
2278 | apply_container (victim, trap); |
2265 | apply_container (victim, trap); |
2279 | break; |
2266 | break; |
2280 | |
2267 | |
2281 | case RUNE: |
2268 | case RUNE: |
2282 | case TRAP: |
2269 | case TRAP: |
2283 | if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) |
2270 | if (trap->level && victim->flag [FLAG_ALIVE]) |
2284 | spring_trap (trap, victim); |
2271 | spring_trap (trap, victim); |
2285 | break; |
2272 | break; |
2286 | |
2273 | |
2287 | default: |
2274 | default: |
2288 | LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " |
2275 | LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " |
… | |
… | |
2300 | apply_book (object *op, object *tmp) |
2287 | apply_book (object *op, object *tmp) |
2301 | { |
2288 | { |
2302 | int lev_diff; |
2289 | int lev_diff; |
2303 | object *skill_ob; |
2290 | object *skill_ob; |
2304 | |
2291 | |
2305 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
2292 | if (op->flag [FLAG_BLIND] && !op->flag [FLAG_WIZ]) |
2306 | { |
2293 | { |
2307 | op->failmsg ("You are unable to read while blind!"); |
2294 | op->failmsg ("You are unable to read while blind!"); |
2308 | return; |
2295 | return; |
2309 | } |
2296 | } |
2310 | |
2297 | |
2311 | if (!tmp->msg) |
2298 | if (!tmp->msg) |
2312 | { |
2299 | { |
2313 | op->failmsg (format ("The %s contains nothing but meaningless gibberish. H<There is nothing interesting to read here.>", &tmp->name)); |
2300 | op->failmsgf ("The %s contains nothing but meaningless gibberish. H<There is nothing interesting to read here.>", &tmp->name); |
2314 | return; |
2301 | return; |
2315 | } |
2302 | } |
2316 | |
2303 | |
2317 | /* need a literacy skill to read stuff! */ |
2304 | /* need a literacy skill to read stuff! */ |
2318 | skill_ob = find_skill_by_name (op, tmp->skill); |
2305 | skill_ob = find_skill_by_name (op, tmp->skill); |
2319 | if (!skill_ob) |
2306 | if (!skill_ob) |
2320 | { |
2307 | { |
2321 | op->failmsg (format ("You are unable to decipher the strange symbols. H<You lack the %s skill to read this.>", &tmp->skill)); |
2308 | op->failmsgf ("You are unable to decipher the strange symbols. H<You lack the %s skill to read this.>", &tmp->skill); |
2322 | return; |
2309 | return; |
2323 | } |
2310 | } |
2324 | |
2311 | |
2325 | lev_diff = tmp->level - (skill_ob->level + 5); |
2312 | lev_diff = tmp->level - (skill_ob->level + 5); |
2326 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
2313 | if (!op->flag [FLAG_WIZ] && lev_diff > 0) |
2327 | { |
2314 | { |
2328 | op->failmsg (lev_diff < 2 ? "This book is just barely beyond your comprehension." |
2315 | op->failmsg (lev_diff < 2 ? "This book is just barely beyond your comprehension." |
2329 | : lev_diff < 3 ? "This book is slightly beyond your comprehension." |
2316 | : lev_diff < 3 ? "This book is slightly beyond your comprehension." |
2330 | : lev_diff < 5 ? "This book is beyond your comprehension." |
2317 | : lev_diff < 5 ? "This book is beyond your comprehension." |
2331 | : lev_diff < 8 ? "This book is quite a bit beyond your comprehension." |
2318 | : lev_diff < 8 ? "This book is quite a bit beyond your comprehension." |
… | |
… | |
2342 | if (player *pl = op->contr) |
2329 | if (player *pl = op->contr) |
2343 | if (client *ns = pl->ns) |
2330 | if (client *ns = pl->ns) |
2344 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
2331 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
2345 | |
2332 | |
2346 | /* gain xp from reading */ |
2333 | /* gain xp from reading */ |
2347 | if (!QUERY_FLAG (tmp, FLAG_NO_SKILL_IDENT)) |
2334 | if (!tmp->flag [FLAG_NO_SKILL_IDENT]) |
2348 | { /* only if not read before */ |
2335 | { /* only if not read before */ |
2349 | int exp_gain = calc_skill_exp (op, tmp, skill_ob); |
2336 | int exp_gain = calc_skill_exp (op, tmp, skill_ob); |
2350 | |
2337 | |
2351 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
2338 | if (!tmp->flag [FLAG_IDENTIFIED]) |
2352 | { |
2339 | { |
2353 | /*exp_gain *= 2; because they just identified it too */ |
2340 | /*exp_gain *= 2; because they just identified it too */ |
2354 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
2341 | tmp->set_flag (FLAG_IDENTIFIED); |
2355 | |
2342 | |
2356 | if (object *pl = tmp->visible_to ()) |
2343 | if (object *pl = tmp->visible_to ()) |
2357 | esrv_update_item (UPD_FLAGS | UPD_NAME, pl, tmp); |
2344 | esrv_update_item (UPD_FLAGS | UPD_NAME, pl, tmp); |
2358 | } |
2345 | } |
2359 | |
2346 | |
2360 | change_exp (op, exp_gain, skill_ob->skill, 0); |
2347 | change_exp (op, exp_gain, skill_ob->skill, 0); |
2361 | SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
2348 | tmp->set_flag (FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
2362 | } |
2349 | } |
2363 | } |
2350 | } |
2364 | |
2351 | |
2365 | /** |
2352 | /** |
2366 | * op made some mistake with a scroll, this takes care of punishment. |
2353 | * op made some mistake with a scroll, this takes care of punishment. |
… | |
… | |
2424 | { |
2411 | { |
2425 | switch (learn_skill (op, tmp)) |
2412 | switch (learn_skill (op, tmp)) |
2426 | { |
2413 | { |
2427 | case 0: |
2414 | case 0: |
2428 | op->play_sound (sound_find ("generic_fail")); |
2415 | op->play_sound (sound_find ("generic_fail")); |
2429 | op->failmsg (format ("You already possess the knowledge held within the %s.", query_name (tmp))); |
2416 | op->failmsgf ("You already possess the knowledge held within the %s.", query_name (tmp)); |
2430 | break; |
2417 | break; |
2431 | |
2418 | |
2432 | case 1: |
2419 | case 1: |
2433 | tmp->decrease (); |
2420 | tmp->decrease (); |
2434 | op->play_sound (sound_find ("skill_learn")); |
2421 | op->play_sound (sound_find ("skill_learn")); |
… | |
… | |
2436 | break; |
2423 | break; |
2437 | |
2424 | |
2438 | default: |
2425 | default: |
2439 | tmp->decrease (); |
2426 | tmp->decrease (); |
2440 | op->play_sound (sound_find ("generic_fail")); |
2427 | op->play_sound (sound_find ("generic_fail")); |
2441 | op->failmsg (format ("You fail to learn the knowledge of the %s.\n", query_name (tmp))); |
2428 | op->failmsgf ("You fail to learn the knowledge of the %s.\n", query_name (tmp)); |
2442 | break; |
2429 | break; |
2443 | } |
2430 | } |
2444 | } |
2431 | } |
2445 | |
2432 | |
2446 | /** |
2433 | /** |
… | |
… | |
2459 | } |
2446 | } |
2460 | |
2447 | |
2461 | /* Upgrade special prayers to normal prayers */ |
2448 | /* Upgrade special prayers to normal prayers */ |
2462 | if ((tmp = check_spell_known (op, spell->name)) != NULL) |
2449 | if ((tmp = check_spell_known (op, spell->name)) != NULL) |
2463 | { |
2450 | { |
2464 | if (special_prayer && !QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
2451 | if (special_prayer && !tmp->flag [FLAG_STARTEQUIP]) |
2465 | { |
2452 | { |
2466 | LOG (llevError, "BUG: do_learn_spell(): spell already known, but not marked as startequip\n"); |
2453 | LOG (llevError, "BUG: do_learn_spell(): spell already known, but not marked as startequip\n"); |
2467 | return; |
2454 | return; |
2468 | } |
2455 | } |
2469 | return; |
2456 | return; |
… | |
… | |
2473 | |
2460 | |
2474 | tmp = spell->clone (); |
2461 | tmp = spell->clone (); |
2475 | insert_ob_in_ob (tmp, op); |
2462 | insert_ob_in_ob (tmp, op); |
2476 | |
2463 | |
2477 | if (special_prayer) |
2464 | if (special_prayer) |
2478 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
2465 | tmp->set_flag (FLAG_STARTEQUIP); |
2479 | |
2466 | |
2480 | esrv_add_spells (op->contr, tmp); |
2467 | esrv_add_spells (op->contr, tmp); |
2481 | } |
2468 | } |
2482 | |
2469 | |
2483 | /** |
2470 | /** |
… | |
… | |
2497 | { |
2484 | { |
2498 | LOG (llevError, "BUG: do_forget_spell(): spell not known\n"); |
2485 | LOG (llevError, "BUG: do_forget_spell(): spell not known\n"); |
2499 | return; |
2486 | return; |
2500 | } |
2487 | } |
2501 | |
2488 | |
2502 | op->failmsg (format ("You lose knowledge of %s.", spell)); |
2489 | op->failmsgf ("You lose knowledge of %s.", spell); |
2503 | esrv_remove_spell (op->contr, spob); |
2490 | esrv_remove_spell (op->contr, spob); |
2504 | spob->destroy (); |
2491 | spob->destroy (); |
2505 | } |
2492 | } |
2506 | |
2493 | |
2507 | /** |
2494 | /** |
… | |
… | |
2512 | static void |
2499 | static void |
2513 | apply_spellbook (object *op, object *tmp) |
2500 | apply_spellbook (object *op, object *tmp) |
2514 | { |
2501 | { |
2515 | object *skop, *spell, *spell_skill; |
2502 | object *skop, *spell, *spell_skill; |
2516 | |
2503 | |
2517 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
2504 | if (op->flag [FLAG_BLIND] && !op->flag [FLAG_WIZ]) |
2518 | { |
2505 | { |
2519 | op->failmsg ("You are unable to read while blind."); |
2506 | op->failmsg ("You are unable to read while blind."); |
2520 | return; |
2507 | return; |
2521 | } |
2508 | } |
2522 | |
2509 | |
… | |
… | |
2528 | { |
2515 | { |
2529 | spell = find_archetype_by_object_name (tmp->slaying)->instance (); |
2516 | spell = find_archetype_by_object_name (tmp->slaying)->instance (); |
2530 | |
2517 | |
2531 | if (!spell) |
2518 | if (!spell) |
2532 | { |
2519 | { |
2533 | op->failmsg (format ("The book's formula for %s is incomplete.", &tmp->slaying)); |
2520 | op->failmsgf ("The book's formula for %s is incomplete.", &tmp->slaying); |
2534 | return; |
2521 | return; |
2535 | } |
2522 | } |
2536 | else |
2523 | else |
2537 | insert_ob_in_ob (spell, tmp); |
2524 | insert_ob_in_ob (spell, tmp); |
2538 | |
2525 | |
… | |
… | |
2543 | |
2530 | |
2544 | /* need a literacy skill to learn spells. Also, having a literacy level |
2531 | /* need a literacy skill to learn spells. Also, having a literacy level |
2545 | * lower than the spell will make learning the spell more difficult */ |
2532 | * lower than the spell will make learning the spell more difficult */ |
2546 | if (!skop) |
2533 | if (!skop) |
2547 | { |
2534 | { |
2548 | op->failmsg (format ("You can't read! Your attempt fails. H<You lack the %s skill.>", &tmp->skill)); |
2535 | op->failmsgf ("You can't read! Your attempt fails. H<You lack the %s skill.>", &tmp->skill); |
2549 | return; |
2536 | return; |
2550 | } |
2537 | } |
2551 | |
2538 | |
2552 | spell = tmp->inv; |
2539 | spell = tmp->inv; |
2553 | |
2540 | |
… | |
… | |
2559 | } |
2546 | } |
2560 | |
2547 | |
2561 | int learn_level = sqrtf (spell->level) * 1.5f; |
2548 | int learn_level = sqrtf (spell->level) * 1.5f; |
2562 | if (skop->level < learn_level) |
2549 | if (skop->level < learn_level) |
2563 | { |
2550 | { |
2564 | op->failmsg (format ("You are unable to decipher the strange symbols. H<Your %s level is too low, it must be at least %d.>", |
2551 | op->failmsgf ("You are unable to decipher the strange symbols. H<Your %s level is too low, it must be at least %d.>", |
2565 | &tmp->skill, learn_level)); |
2552 | &tmp->skill, learn_level); |
2566 | return; |
2553 | return; |
2567 | } |
2554 | } |
2568 | |
2555 | |
2569 | op->statusmsg (format ("The spellbook contains the %s level spell %s.", ordinal (spell->level), &spell->name)); |
2556 | op->statusmsg (format ("The spellbook contains the %s level spell %s.", ordinal (spell->level), &spell->name)); |
2570 | |
2557 | |
2571 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
2558 | if (!tmp->flag [FLAG_IDENTIFIED]) |
2572 | identify (tmp); |
2559 | identify (tmp); |
2573 | |
2560 | |
2574 | /* I removed the check for special_prayer_mark here - it didn't make |
2561 | /* I removed the check for special_prayer_mark here - it didn't make |
2575 | * a lot of sense - special prayers are not found in spellbooks, and |
2562 | * a lot of sense - special prayers are not found in spellbooks, and |
2576 | * if the player doesn't know the spell, doesn't make a lot of sense that |
2563 | * if the player doesn't know the spell, doesn't make a lot of sense that |
… | |
… | |
2586 | { |
2573 | { |
2587 | spell_skill = find_skill_by_name (op, spell->skill); |
2574 | spell_skill = find_skill_by_name (op, spell->skill); |
2588 | |
2575 | |
2589 | if (!spell_skill) |
2576 | if (!spell_skill) |
2590 | { |
2577 | { |
2591 | op->failmsg (format ("You lack the %s skill to use this spell.", &spell->skill)); |
2578 | op->failmsgf ("You lack the %s skill to use this spell.", &spell->skill); |
2592 | return; |
2579 | return; |
2593 | } |
2580 | } |
2594 | |
2581 | |
2595 | if (spell_skill->level < spell->level) |
2582 | if (spell_skill->level < spell->level) |
2596 | { |
2583 | { |
2597 | op->failmsg (format ("You need to be level %d in %s to learn this spell.", spell->level, &spell->skill)); |
2584 | op->failmsgf ("You need to be level %d in %s to learn this spell.", spell->level, &spell->skill); |
2598 | return; |
2585 | return; |
2599 | } |
2586 | } |
2600 | } |
2587 | } |
2601 | |
2588 | |
2602 | /* Logic as follows |
2589 | /* Logic as follows |
… | |
… | |
2609 | * 3 -Automatically fail to learn if you read while confused |
2596 | * 3 -Automatically fail to learn if you read while confused |
2610 | * |
2597 | * |
2611 | * Overall, chances are the same but a player will find having a high |
2598 | * Overall, chances are the same but a player will find having a high |
2612 | * literacy rate very useful! -b.t. |
2599 | * literacy rate very useful! -b.t. |
2613 | */ |
2600 | */ |
2614 | if (QUERY_FLAG (op, FLAG_CONFUSED)) |
2601 | if (op->flag [FLAG_CONFUSED]) |
2615 | { |
2602 | { |
2616 | op->failmsg ("In your confused state you flub the wording of the text!"); |
2603 | op->failmsg ("In your confused state you flub the wording of the text!"); |
2617 | scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), max (spell->stats.sp, spell->stats.grace)); |
2604 | scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), max (spell->stats.sp, spell->stats.grace)); |
2618 | } |
2605 | } |
2619 | else if (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || |
2606 | else if (tmp->flag [FLAG_STARTEQUIP] || |
2620 | (random_roll (0, 100, op, PREFER_LOW) - (5 * skop->level)) < learn_spell[spell->stats.grace ? op->stats.Wis : op->stats.Int]) |
2607 | (random_roll (0, 100, op, PREFER_LOW) - (5 * skop->level)) < learn_spell[spell->stats.grace ? op->stats.Wis : op->stats.Int]) |
2621 | { |
2608 | { |
2622 | op->statusmsg ("You succeed in learning the spell!", NDI_GREEN); |
2609 | op->statusmsg ("You succeed in learning the spell!", NDI_GREEN); |
2623 | do_learn_spell (op, spell, 0); |
2610 | do_learn_spell (op, spell, 0); |
2624 | |
2611 | |
2625 | /* xp gain to literacy for spell learning */ |
2612 | /* xp gain to literacy for spell learning */ |
2626 | if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
2613 | if (!tmp->flag [FLAG_STARTEQUIP]) |
2627 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
2614 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
2628 | } |
2615 | } |
2629 | else |
2616 | else |
2630 | { |
2617 | { |
2631 | op->contr->play_sound (sound_find ("fumble_spell")); |
2618 | op->contr->play_sound (sound_find ("fumble_spell")); |
… | |
… | |
2641 | void |
2628 | void |
2642 | apply_scroll (object *op, object *tmp, int dir) |
2629 | apply_scroll (object *op, object *tmp, int dir) |
2643 | { |
2630 | { |
2644 | object *skop; |
2631 | object *skop; |
2645 | |
2632 | |
2646 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
2633 | if (op->flag [FLAG_BLIND] && !op->flag [FLAG_WIZ]) |
2647 | { |
2634 | { |
2648 | op->failmsg ("You are unable to read while blind."); |
2635 | op->failmsg ("You are unable to read while blind."); |
2649 | return; |
2636 | return; |
2650 | } |
2637 | } |
2651 | |
2638 | |
… | |
… | |
2661 | int exp_gain = 0; |
2648 | int exp_gain = 0; |
2662 | |
2649 | |
2663 | /* hard code literacy - tmp->skill points to where the exp |
2650 | /* hard code literacy - tmp->skill points to where the exp |
2664 | * should go for anything killed by the spell. |
2651 | * should go for anything killed by the spell. |
2665 | */ |
2652 | */ |
2666 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
2653 | skop = find_skill_by_name (op, shstr_literacy); |
2667 | |
2654 | |
2668 | if (!skop) |
2655 | if (!skop) |
2669 | { |
2656 | { |
2670 | op->failmsg (format ("You are unable to decipher the strange symbols. H<You lack the %s skill.>", &skill_names[SK_LITERACY])); |
2657 | op->failmsgf ("You are unable to decipher the strange symbols. H<You lack the literacy skill.>"); |
2671 | return; |
2658 | return; |
2672 | } |
2659 | } |
2673 | |
2660 | |
2674 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
2661 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
2675 | change_exp (op, exp_gain, skop->skill, 0); |
2662 | change_exp (op, exp_gain, skop->skill, 0); |
2676 | } |
2663 | } |
2677 | |
2664 | |
2678 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
2665 | if (!tmp->flag [FLAG_IDENTIFIED]) |
2679 | identify (tmp); |
2666 | identify (tmp); |
2680 | |
2667 | |
2681 | op->statusmsg (format ("The scroll of %s turns to dust.", &tmp->inv->name)); |
2668 | op->statusmsg (format ("The scroll of %s turns to dust.", &tmp->inv->name)); |
2682 | |
2669 | |
2683 | cast_spell (op, tmp, dir, tmp->inv, NULL); |
2670 | cast_spell (op, tmp, dir, tmp->inv, NULL); |
… | |
… | |
2714 | |
2701 | |
2715 | treas->x = op->x; |
2702 | treas->x = op->x; |
2716 | treas->y = op->y; |
2703 | treas->y = op->y; |
2717 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
2704 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
2718 | |
2705 | |
2719 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE)) |
2706 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && op->flag [FLAG_ALIVE]) |
2720 | spring_trap (treas, op); |
2707 | spring_trap (treas, op); |
2721 | |
2708 | |
2722 | /* If either player or container was destroyed, no need to do |
2709 | /* If either player or container was destroyed, no need to do |
2723 | * further processing. I think this should be enclused with |
2710 | * further processing. I think this should be enclused with |
2724 | * spring trap above, as I don't think there is otherwise |
2711 | * spring trap above, as I don't think there is otherwise |
… | |
… | |
2923 | : tmp->type == DRINK |
2910 | : tmp->type == DRINK |
2924 | ? sound_find ("eat_drink") |
2911 | ? sound_find ("eat_drink") |
2925 | : sound_find ("eat_food") |
2912 | : sound_find ("eat_food") |
2926 | ); |
2913 | ); |
2927 | |
2914 | |
2928 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2915 | if (!tmp->flag [FLAG_CURSED]) |
2929 | { |
2916 | { |
2930 | const char *buf; |
2917 | const char *buf; |
2931 | |
2918 | |
2932 | if (!op->is_dragon ()) |
2919 | if (!op->is_dragon ()) |
2933 | { |
2920 | { |
… | |
… | |
2953 | min_it (op->stats.hp, op->stats.maxhp); |
2940 | min_it (op->stats.hp, op->stats.maxhp); |
2954 | min_it (op->stats.food, MAX_FOOD); |
2941 | min_it (op->stats.food, MAX_FOOD); |
2955 | } |
2942 | } |
2956 | |
2943 | |
2957 | /* special food hack -b.t. */ |
2944 | /* special food hack -b.t. */ |
2958 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
2945 | if (tmp->title || tmp->flag [FLAG_CURSED]) |
2959 | eat_special_food (op, tmp); |
2946 | eat_special_food (op, tmp); |
2960 | } |
2947 | } |
2961 | } |
2948 | } |
2962 | |
2949 | |
2963 | handle_apply_yield (tmp); |
2950 | handle_apply_yield (tmp); |
… | |
… | |
2969 | * Does some sanity checks, then calls improve_armour. |
2956 | * Does some sanity checks, then calls improve_armour. |
2970 | */ |
2957 | */ |
2971 | static void |
2958 | static void |
2972 | apply_armour_improver (object *op, object *tmp) |
2959 | apply_armour_improver (object *op, object *tmp) |
2973 | { |
2960 | { |
2974 | object *armor; |
|
|
2975 | |
|
|
2976 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) |
2961 | if (!op->flag [FLAG_WIZCAST] && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) |
2977 | { |
2962 | { |
2978 | op->failmsg ("Something blocks the magic of the scroll. H<This area prevents magic effects.>"); |
2963 | op->failmsg ("Something blocks the magic of the scroll. H<This area prevents magic effects.>"); |
2979 | return; |
2964 | return; |
2980 | } |
2965 | } |
2981 | |
2966 | |
2982 | armor = find_marked_object (op); |
2967 | object *armor = op->mark (); |
2983 | |
2968 | |
2984 | if (!armor) |
2969 | if (!armor) |
2985 | { |
2970 | { |
2986 | op->failmsg ("You need to mark an armor object. Use the right mouse button popup or the mark command to do this."); |
2971 | op->failmsg ("You need to mark an armor object. Use the right mouse button popup or the mark command to do this."); |
2987 | return; |
2972 | return; |
… | |
… | |
2990 | if (armor->type != ARMOUR |
2975 | if (armor->type != ARMOUR |
2991 | && armor->type != CLOAK |
2976 | && armor->type != CLOAK |
2992 | && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) |
2977 | && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) |
2993 | { |
2978 | { |
2994 | op->failmsg ("Your marked item is not armour!\n"); |
2979 | op->failmsg ("Your marked item is not armour!\n"); |
|
|
2980 | return; |
|
|
2981 | } |
|
|
2982 | |
|
|
2983 | if (!op->apply (armor, AP_UNAPPLY)) |
|
|
2984 | { |
|
|
2985 | op->failmsg ("You are unable to take off your armour to improve it!"); |
2995 | return; |
2986 | return; |
2996 | } |
2987 | } |
2997 | |
2988 | |
2998 | op->statusmsg ("Applying armour enchantment."); |
2989 | op->statusmsg ("Applying armour enchantment."); |
2999 | improve_armour (op, tmp, armor); |
2990 | improve_armour (op, tmp, armor); |
… | |
… | |
3047 | } |
3038 | } |
3048 | } |
3039 | } |
3049 | |
3040 | |
3050 | if (!lighter) |
3041 | if (!lighter) |
3051 | { |
3042 | { |
3052 | who->failmsg (format ( |
3043 | who->failmsgf ( |
3053 | "You can't light up the %s with your bare hands! " |
3044 | "You can't light up the %s with your bare hands! " |
3054 | "H<You need a lighter in your inventory, for example a flint and steel.>", |
3045 | "H<You need a lighter in your inventory, for example a flint and steel.>", |
3055 | &op->name)); |
3046 | &op->name |
|
|
3047 | ); |
3056 | return 0; |
3048 | return 0; |
3057 | } |
3049 | } |
3058 | } |
3050 | } |
3059 | |
3051 | |
3060 | // last_eat == 0 means the lighter is not being used up! |
3052 | // last_eat == 0 means the lighter is not being used up! |
… | |
… | |
3066 | who->insert (lighter); |
3058 | who->insert (lighter); |
3067 | } |
3059 | } |
3068 | else if (lighter->last_eat) |
3060 | else if (lighter->last_eat) |
3069 | { |
3061 | { |
3070 | /* no charges left in lighter */ |
3062 | /* no charges left in lighter */ |
3071 | who->failmsg (format ( |
3063 | who->failmsgf ( |
3072 | "You attempt to light the %s with a used up %s.", |
3064 | "You attempt to light the %s with a used up %s.", |
3073 | &op->name, &lighter->name)); |
3065 | &op->name, &lighter->name |
|
|
3066 | ); |
3074 | return 0; |
3067 | return 0; |
3075 | } |
3068 | } |
3076 | |
3069 | |
3077 | return lighter; |
3070 | return lighter; |
3078 | } |
3071 | } |
… | |
… | |
3083 | * the selected object to "burn". -b.t. |
3076 | * the selected object to "burn". -b.t. |
3084 | */ |
3077 | */ |
3085 | static void |
3078 | static void |
3086 | apply_lighter (object *who, object *lighter) |
3079 | apply_lighter (object *who, object *lighter) |
3087 | { |
3080 | { |
3088 | object *item; |
|
|
3089 | int is_player_env = 0; |
3081 | int is_player_env = 0; |
3090 | |
3082 | |
3091 | item = find_marked_object (who); |
3083 | if (object *item = who->mark ()) |
3092 | if (item) |
|
|
3093 | { |
3084 | { |
3094 | if (!auto_apply_lighter (who, item, lighter)) |
3085 | if (!auto_apply_lighter (who, item, lighter)) |
3095 | return; |
3086 | return; |
3096 | |
3087 | |
3097 | /* Perhaps we should split what we are trying to light on fire? |
3088 | /* Perhaps we should split what we are trying to light on fire? |
… | |
… | |
3104 | if (item->destroyed () |
3095 | if (item->destroyed () |
3105 | || ((item->type == LAMP || item->type == TORCH) |
3096 | || ((item->type == LAMP || item->type == TORCH) |
3106 | && item->glow_radius > 0)) |
3097 | && item->glow_radius > 0)) |
3107 | who->statusmsg (format ( |
3098 | who->statusmsg (format ( |
3108 | "You light the %s with the %s.", |
3099 | "You light the %s with the %s.", |
3109 | &item->name, &lighter->name)); |
3100 | &item->name, &lighter->name |
|
|
3101 | )); |
3110 | else |
3102 | else |
3111 | who->failmsg (format ( |
3103 | who->failmsgf ( |
3112 | "You attempt to light the %s with the %s and fail.", |
3104 | "You attempt to light the %s with the %s and fail.", |
3113 | &item->name, &lighter->name)); |
3105 | &item->name, &lighter->name |
|
|
3106 | ); |
3114 | } |
3107 | } |
3115 | else |
3108 | else |
3116 | who->failmsg ("You need to mark a lightable object."); |
3109 | who->failmsg ("You need to mark a lightable object."); |
3117 | } |
3110 | } |
3118 | |
3111 | |
… | |
… | |
3122 | static void |
3115 | static void |
3123 | player_apply_lamp_cursed_effect (object *who, object *op) |
3116 | player_apply_lamp_cursed_effect (object *who, object *op) |
3124 | { |
3117 | { |
3125 | if (op->level) |
3118 | if (op->level) |
3126 | { |
3119 | { |
3127 | who->failmsg (format ( |
3120 | who->failmsgf ( |
3128 | "The %s was cursed, it explodes in a big fireball!", |
3121 | "The %s was cursed, it explodes in a big fireball!", |
3129 | &op->name)); |
3122 | &op->name |
|
|
3123 | ); |
3130 | create_exploding_ball_at (who, op->level); |
3124 | create_exploding_ball_at (who, op->level); |
3131 | } |
3125 | } |
3132 | else |
3126 | else |
3133 | { |
3127 | { |
3134 | who->failmsg (format ( |
3128 | who->failmsgf ( |
3135 | "The %s was cursed, it crumbles to dust, at least it didn't explode.!", |
3129 | "The %s was cursed, it crumbles to dust, at least it didn't explode.!", |
3136 | &op->name)); |
3130 | &op->name |
|
|
3131 | ); |
3137 | } |
3132 | } |
3138 | |
3133 | |
3139 | op->destroy (); |
3134 | op->destroy (); |
3140 | } |
3135 | } |
3141 | |
3136 | |
… | |
… | |
3159 | return; |
3154 | return; |
3160 | |
3155 | |
3161 | if (op->stats.food < 1) |
3156 | if (op->stats.food < 1) |
3162 | { |
3157 | { |
3163 | if (op->type == LAMP) |
3158 | if (op->type == LAMP) |
3164 | who->failmsg (format ( |
3159 | who->failmsgf ( |
3165 | "The %s is out of fuel! " |
3160 | "The %s is out of fuel! " |
3166 | "H<Lamps and similar items need fuel. They cannot be refilled.>", |
3161 | "H<Lamps and similar items need fuel. They cannot be refilled.>", |
3167 | &op->name)); |
3162 | &op->name |
|
|
3163 | ); |
3168 | else |
3164 | else |
3169 | who->failmsg (format ( |
3165 | who->failmsgf ( |
3170 | "The %s is burnt out! " |
3166 | "The %s is burnt out! " |
3171 | "H<Torches and similar items burn out and become worthless.>", |
3167 | "H<Torches and similar items burn out and become worthless.>", |
3172 | &op->name)); |
3168 | &op->name |
|
|
3169 | ); |
3173 | return; |
3170 | return; |
3174 | } |
3171 | } |
3175 | |
3172 | |
3176 | if (op->flag [FLAG_CURSED]) |
3173 | if (op->flag [FLAG_CURSED]) |
3177 | { |
3174 | { |
… | |
… | |
3282 | * The 'slaying' field for transformer is used as verb for the action. |
3279 | * The 'slaying' field for transformer is used as verb for the action. |
3283 | */ |
3280 | */ |
3284 | static void |
3281 | static void |
3285 | apply_item_transformer (object *pl, object *transformer) |
3282 | apply_item_transformer (object *pl, object *transformer) |
3286 | { |
3283 | { |
3287 | object *marked; |
|
|
3288 | object *new_item; |
3284 | object *new_item; |
3289 | const char *find; |
3285 | const char *find; |
3290 | char *separator; |
3286 | char *separator; |
3291 | int yield; |
3287 | int yield; |
3292 | char got[MAX_BUF]; |
3288 | char got[MAX_BUF]; |
3293 | int len; |
3289 | int len; |
3294 | |
3290 | |
3295 | if (!pl || !transformer) |
3291 | if (!pl || !transformer) |
3296 | return; |
3292 | return; |
3297 | |
3293 | |
3298 | marked = find_marked_object (pl); |
3294 | object *marked = pl->mark (); |
3299 | |
3295 | |
3300 | if (!marked) |
3296 | if (!marked) |
3301 | { |
3297 | { |
3302 | pl->failmsg (format ("Use the %s with what item?", query_name (transformer))); |
3298 | pl->failmsgf ("Use the %s with what item?", query_name (transformer)); |
3303 | return; |
3299 | return; |
3304 | } |
3300 | } |
3305 | |
3301 | |
3306 | if (!marked->slaying) |
3302 | if (!marked->slaying) |
3307 | { |
3303 | { |
3308 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
3304 | pl->failmsgf ("You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
3309 | return; |
3305 | return; |
3310 | } |
3306 | } |
3311 | |
3307 | |
3312 | /* check whether they are compatible or not */ |
3308 | /* check whether they are compatible or not */ |
3313 | find = strstr (&marked->slaying, transformer->arch->archname); |
3309 | find = strstr (&marked->slaying, transformer->arch->archname); |
3314 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
3310 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
3315 | { |
3311 | { |
3316 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
3312 | pl->failmsgf ("You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
3317 | return; |
3313 | return; |
3318 | } |
3314 | } |
3319 | |
3315 | |
3320 | find += strlen (transformer->arch->archname) + 1; |
3316 | find += strlen (transformer->arch->archname) + 1; |
3321 | /* Item can be used, now find how many and what it yields */ |
3317 | /* Item can be used, now find how many and what it yields */ |
… | |
… | |
3351 | |
3347 | |
3352 | /* Now create new item, remove used ones when required. */ |
3348 | /* Now create new item, remove used ones when required. */ |
3353 | new_item = get_archetype (got); |
3349 | new_item = get_archetype (got); |
3354 | if (!new_item) |
3350 | if (!new_item) |
3355 | { |
3351 | { |
3356 | pl->failmsg (format ("This %s is strange, better to not use it.", query_base_name (marked, 0))); |
3352 | pl->failmsgf ("This %s is strange, better to not use it.", query_base_name (marked, 0)); |
3357 | return; |
3353 | return; |
3358 | } |
3354 | } |
3359 | |
3355 | |
3360 | new_item->nrof = yield; |
3356 | new_item->nrof = yield; |
3361 | |
3357 | |
… | |
… | |
3407 | { |
3403 | { |
3408 | // special item, using slot system, needs to be in inv |
3404 | // special item, using slot system, needs to be in inv |
3409 | if (op->env == who) |
3405 | if (op->env == who) |
3410 | return apply_special (who, op, aflag); |
3406 | return apply_special (who, op, aflag); |
3411 | |
3407 | |
3412 | who->failmsg (format ("You must get it first! H<You can only apply the %s if it is in your inventory.>\n", query_name (op))); |
3408 | who->failmsgf ("You must get it first! H<You can only apply the %s if it is in your inventory.>\n", query_name (op)); |
3413 | } |
3409 | } |
3414 | else if (!who->contr && apply_types_player_only [op->type]) |
3410 | else if (!who->contr && apply_types_player_only [op->type]) |
3415 | return 0; // monsters shouldn't try to apply player-only stuff |
3411 | return 0; // monsters shouldn't try to apply player-only stuff |
3416 | else if (apply_types [op->type]) |
3412 | else if (apply_types [op->type]) |
3417 | { |
3413 | { |
… | |
… | |
3438 | |
3434 | |
3439 | break; |
3435 | break; |
3440 | |
3436 | |
3441 | case EXIT: |
3437 | case EXIT: |
3442 | if (!EXIT_PATH (op)) |
3438 | if (!EXIT_PATH (op)) |
3443 | who->failmsg (format ("The %s is closed. H<And will stay closed, until somebody fires up the map editor and adds it.>", query_name (op))); |
3439 | who->failmsgf ("The %s is closed. H<And will stay closed, until somebody fires up the map editor and adds it.>", query_name (op)); |
3444 | else |
3440 | else |
3445 | { |
3441 | { |
3446 | /* Don't display messages for random maps. */ |
3442 | /* Don't display messages for random maps. */ |
3447 | if (op->msg && EXIT_PATH (op) != shstr_random_map_exit) |
3443 | if (op->msg && EXIT_PATH (op) != shstr_random_map_exit) |
3448 | who->statusmsg (op->msg, NDI_NAVY); |
3444 | who->statusmsg (op->msg, NDI_NAVY); |
… | |
… | |
3599 | case ALTAR: |
3595 | case ALTAR: |
3600 | case IDENTIFY_ALTAR: |
3596 | case IDENTIFY_ALTAR: |
3601 | case TRIGGER_ALTAR: |
3597 | case TRIGGER_ALTAR: |
3602 | case CONVERTER: |
3598 | case CONVERTER: |
3603 | //case TRIGGER_PEDESTAL: |
3599 | //case TRIGGER_PEDESTAL: |
3604 | pl->failmsg (format ( |
3600 | pl->failmsgf ( |
3605 | "You see no obvious mechanism on the %s." |
3601 | "You see no obvious mechanism on the %s." |
3606 | "H<You have to drop one or more specific items here.>", |
3602 | "H<You have to drop one or more specific items here.>", |
3607 | query_short_name (top) |
3603 | query_short_name (top) |
3608 | )); |
3604 | ); |
3609 | break; |
3605 | break; |
3610 | |
3606 | |
3611 | case BUTTON: |
3607 | case BUTTON: |
3612 | case TRIGGER_BUTTON: |
3608 | case TRIGGER_BUTTON: |
3613 | pl->failmsg (format ( |
3609 | pl->failmsgf ( |
3614 | "The %s looks as if you could activate it with somehting heavy. " |
3610 | "The %s looks as if you could activate it with somehting heavy. " |
3615 | "H<You must put enough items here to activate it.>", |
3611 | "H<You must put enough items here to activate it.>", |
3616 | query_short_name (top) |
3612 | query_short_name (top) |
3617 | )); |
3613 | ); |
3618 | break; |
3614 | break; |
3619 | |
3615 | |
3620 | default: |
3616 | default: |
3621 | examine (pl, top); |
3617 | examine (pl, top); |
3622 | break; |
3618 | break; |
… | |
… | |
3740 | auto_apply (object *op) |
3736 | auto_apply (object *op) |
3741 | { |
3737 | { |
3742 | object *tmp = NULL, *tmp2; |
3738 | object *tmp = NULL, *tmp2; |
3743 | int i; |
3739 | int i; |
3744 | |
3740 | |
3745 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
3741 | op->clr_flag (FLAG_AUTO_APPLY); |
3746 | |
3742 | |
3747 | switch (op->type) |
3743 | switch (op->type) |
3748 | { |
3744 | { |
3749 | case SHOP_FLOOR: |
3745 | case SHOP_FLOOR: |
3750 | if (!op->has_random_items ()) |
3746 | if (!op->has_random_items ()) |
… | |
… | |
3760 | == NULL && --i); |
3756 | == NULL && --i); |
3761 | |
3757 | |
3762 | if (tmp == NULL) |
3758 | if (tmp == NULL) |
3763 | return 0; |
3759 | return 0; |
3764 | |
3760 | |
3765 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3761 | if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]) |
3766 | { |
3762 | { |
3767 | tmp->destroy (); |
3763 | tmp->destroy (); |
3768 | tmp = NULL; |
3764 | tmp = NULL; |
3769 | } |
3765 | } |
3770 | } |
3766 | } |
3771 | while (!tmp); |
3767 | while (!tmp); |
3772 | |
3768 | |
3773 | tmp->x = op->x; |
3769 | tmp->x = op->x; |
3774 | tmp->y = op->y; |
3770 | tmp->y = op->y; |
3775 | SET_FLAG (tmp, FLAG_UNPAID); |
3771 | tmp->set_flag (FLAG_UNPAID); |
3776 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3772 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3777 | identify (tmp); |
3773 | identify (tmp); |
3778 | break; |
3774 | break; |
3779 | |
3775 | |
3780 | case TREASURE: |
3776 | case TREASURE: |
3781 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
3777 | if (op->flag [FLAG_IS_A_TEMPLATE]) |
3782 | return 0; |
3778 | return 0; |
3783 | |
3779 | |
3784 | while (op->stats.hp-- > 0) |
3780 | while (op->stats.hp-- > 0) |
3785 | create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, |
3781 | create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, |
3786 | op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); |
3782 | op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); |
… | |
… | |
3824 | |
3820 | |
3825 | for (invtmp = tmp->inv; invtmp; invtmp = invnext) |
3821 | for (invtmp = tmp->inv; invtmp; invtmp = invnext) |
3826 | { |
3822 | { |
3827 | invnext = invtmp->below; |
3823 | invnext = invtmp->below; |
3828 | |
3824 | |
3829 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3825 | if (invtmp->flag [FLAG_AUTO_APPLY]) |
3830 | auto_apply (invtmp); |
3826 | auto_apply (invtmp); |
3831 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3827 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3832 | { |
3828 | { |
3833 | while (invtmp->stats.hp-- > 0) |
3829 | while (invtmp->stats.hp-- > 0) |
3834 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3830 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
… | |
… | |
3859 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL |
3855 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL |
3860 | || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) |
3856 | || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) |
3861 | tmp->randomitems = NULL; |
3857 | tmp->randomitems = NULL; |
3862 | } |
3858 | } |
3863 | |
3859 | |
3864 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3860 | if (tmp->flag [FLAG_AUTO_APPLY]) |
3865 | auto_apply (tmp); |
3861 | auto_apply (tmp); |
3866 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
3862 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
3867 | { |
3863 | { |
3868 | while ((tmp->stats.hp--) > 0) |
3864 | while ((tmp->stats.hp--) > 0) |
3869 | create_treasure (tmp->randomitems, tmp, 0, difficulty, 0); |
3865 | create_treasure (tmp->randomitems, tmp, 0, difficulty, 0); |
… | |
… | |
3871 | } |
3867 | } |
3872 | else if (tmp->type == TIMED_GATE) |
3868 | else if (tmp->type == TIMED_GATE) |
3873 | { |
3869 | { |
3874 | object *head = tmp->head != NULL ? tmp->head : tmp; |
3870 | object *head = tmp->head != NULL ? tmp->head : tmp; |
3875 | |
3871 | |
3876 | if (QUERY_FLAG (head, FLAG_IS_LINKED)) |
3872 | if (head->flag [FLAG_IS_LINKED]) |
3877 | tmp->set_speed (0); |
3873 | tmp->set_speed (0); |
3878 | } |
3874 | } |
3879 | /* This function can be called everytime a map is loaded, even when |
3875 | /* This function can be called everytime a map is loaded, even when |
3880 | * swapping back in. As such, we don't want to create the treasure |
3876 | * swapping back in. As such, we don't want to create the treasure |
3881 | * over and ove again, so after we generate the treasure, blank out |
3877 | * over and ove again, so after we generate the treasure, blank out |
… | |
… | |
3970 | } |
3966 | } |
3971 | |
3967 | |
3972 | /* check for hp, sp change */ |
3968 | /* check for hp, sp change */ |
3973 | if (food->stats.hp != 0) |
3969 | if (food->stats.hp != 0) |
3974 | { |
3970 | { |
3975 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3971 | if (food->flag [FLAG_CURSED]) |
3976 | { |
3972 | { |
3977 | who->contr->killer = food; |
3973 | who->contr->killer = food; |
3978 | hit_player (who, food->stats.hp, food, AT_POISON, 1); |
3974 | hit_player (who, food->stats.hp, food, AT_POISON, 1); |
3979 | who->failmsg ("Eck!...that was poisonous!"); |
3975 | who->failmsg ("Eck!...that was poisonous!"); |
3980 | } |
3976 | } |
… | |
… | |
3989 | } |
3985 | } |
3990 | } |
3986 | } |
3991 | |
3987 | |
3992 | if (food->stats.sp != 0) |
3988 | if (food->stats.sp != 0) |
3993 | { |
3989 | { |
3994 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3990 | if (food->flag [FLAG_CURSED]) |
3995 | { |
3991 | { |
3996 | who->failmsg ("You are drained of mana!"); |
3992 | who->failmsg ("You are drained of mana!"); |
3997 | who->stats.sp -= food->stats.sp; |
3993 | who->stats.sp -= food->stats.sp; |
3998 | if (who->stats.sp < 0) |
3994 | if (who->stats.sp < 0) |
3999 | who->stats.sp = 0; |
3995 | who->stats.sp = 0; |
… | |
… | |
4082 | pl->animation_id = change->animation_id; |
4078 | pl->animation_id = change->animation_id; |
4083 | pl->flag [FLAG_ANIMATE] = change->flag [FLAG_ANIMATE]; |
4079 | pl->flag [FLAG_ANIMATE] = change->flag [FLAG_ANIMATE]; |
4084 | } |
4080 | } |
4085 | |
4081 | |
4086 | /* check the special case of can't use weapons */ |
4082 | /* check the special case of can't use weapons */ |
4087 | /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */ |
4083 | /*if(change->flag [FLAG_USE_WEAPON]) pl->clr_flag (FLAG_USE_WEAPON); */ |
4088 | if (change->name == shstr_monk) |
4084 | if (change->name == shstr_monk) |
4089 | CLEAR_FLAG (pl, FLAG_USE_WEAPON); |
4085 | pl->clr_flag (FLAG_USE_WEAPON); |
4090 | |
4086 | |
4091 | break; |
4087 | break; |
4092 | } |
4088 | } |
4093 | } |
4089 | } |
4094 | } |
4090 | } |