… | |
… | |
58 | } |
58 | } |
59 | |
59 | |
60 | int |
60 | int |
61 | recharge (object *op, object *caster, object *spell_ob) |
61 | recharge (object *op, object *caster, object *spell_ob) |
62 | { |
62 | { |
63 | object *wand, *tmp; |
|
|
64 | int ncharges; |
63 | int ncharges; |
65 | |
64 | |
66 | wand = find_marked_object (op); |
65 | object *wand = op->mark (); |
|
|
66 | |
67 | if (!wand || wand->type != WAND) |
67 | if (!wand || wand->type != WAND) |
68 | { |
68 | { |
69 | op->failmsg ("You need to mark the wand you want to recharge."); |
69 | op->failmsg ("You need to mark the wand you want to recharge."); |
70 | return 0; |
70 | return 0; |
71 | } |
71 | } |
… | |
… | |
73 | if (!(random_roll (0, 3, op, PREFER_HIGH))) |
73 | if (!(random_roll (0, 3, op, PREFER_HIGH))) |
74 | { |
74 | { |
75 | op->failmsgf ("The %s vibrates violently, then explodes!", query_name (wand)); |
75 | op->failmsgf ("The %s vibrates violently, then explodes!", query_name (wand)); |
76 | op->play_sound (sound_find ("ob_explode")); |
76 | op->play_sound (sound_find ("ob_explode")); |
77 | wand->destroy (); |
77 | wand->destroy (); |
78 | tmp = get_archetype (shstr_fireball); |
78 | object *tmp = get_archetype (shstr_fireball); |
79 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
79 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
80 | |
80 | |
81 | if (!tmp->stats.dam) |
81 | if (!tmp->stats.dam) |
82 | tmp->stats.dam = 1; |
82 | tmp->stats.dam = 1; |
83 | |
83 | |
… | |
… | |
461 | |
461 | |
462 | void |
462 | void |
463 | execute_word_of_recall (object *op) |
463 | execute_word_of_recall (object *op) |
464 | { |
464 | { |
465 | if (object *pl = op->in_player ()) |
465 | if (object *pl = op->in_player ()) |
466 | { |
|
|
467 | if (pl->ms ().flags () & P_NO_CLERIC && !pl->flag [FLAG_WIZCAST]) |
466 | if (pl->ms ().flags () & P_NO_CLERIC && !pl->flag [FLAG_WIZCAST]) |
468 | new_draw_info (NDI_UNIQUE, 0, pl, "You feel something fizzle inside you."); |
467 | new_draw_info (NDI_UNIQUE, 0, pl, "You feel something fizzle inside you."); |
469 | else |
468 | else |
470 | pl->player_goto (op->slaying, op->stats.hp, op->stats.sp); |
469 | pl->player_goto (op->slaying, op->stats.hp, op->stats.sp); |
471 | } |
|
|
472 | |
470 | |
473 | op->destroy (); |
471 | op->destroy (); |
474 | } |
472 | } |
475 | |
473 | |
476 | /* Word of recall causes the player to return 'home'. |
474 | /* Word of recall causes the player to return 'home'. |
… | |
… | |
478 | * time delay effect. |
476 | * time delay effect. |
479 | */ |
477 | */ |
480 | int |
478 | int |
481 | cast_word_of_recall (object *op, object *caster, object *spell_ob) |
479 | cast_word_of_recall (object *op, object *caster, object *spell_ob) |
482 | { |
480 | { |
483 | object *dummy; |
481 | if (!op->is_player ()) |
484 | int time; |
|
|
485 | |
|
|
486 | if (op->type != PLAYER) |
|
|
487 | return 0; |
482 | return 0; |
488 | |
483 | |
489 | if (find_obj_by_type_subtype (op, SPELL_EFFECT, SP_WORD_OF_RECALL)) |
484 | if (find_obj_by_type_subtype (op, SPELL_EFFECT, SP_WORD_OF_RECALL)) |
490 | { |
485 | { |
491 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you."); |
486 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you."); |
492 | return 1; |
487 | return 1; |
493 | } |
488 | } |
494 | |
489 | |
495 | dummy = get_archetype (FORCE_NAME); |
490 | object *dummy = get_archetype (FORCE_NAME); |
496 | |
491 | |
497 | if (!dummy) |
|
|
498 | { |
|
|
499 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
|
|
500 | LOG (llevError, "cast_word_of_recall: get_archetype(force) failed!\n"); |
|
|
501 | return 0; |
|
|
502 | } |
|
|
503 | |
|
|
504 | time = spell_ob->duration - SP_level_duration_adjust (caster, spell_ob); |
492 | int time = max (1, spell_ob->duration - SP_level_duration_adjust (caster, spell_ob)); |
505 | if (time < 1) |
|
|
506 | time = 1; |
|
|
507 | |
493 | |
508 | /* value of speed really doesn't make much difference, as long as it is |
494 | /* value of speed really doesn't make much difference, as long as it is |
509 | * positive. Lower value may be useful so that the problem doesn't |
495 | * positive. Lower value may be useful so that the problem doesn't |
510 | * do anything really odd if it say a -1000 or something. |
496 | * do anything really odd if it say a -1000 or something. |
511 | */ |
497 | */ |
512 | dummy->set_speed (0.002); |
498 | dummy->set_speed (0.002); |
513 | dummy->speed_left = -dummy->speed * time; |
499 | dummy->speed_left = -dummy->speed * time; |
514 | dummy->type = SPELL_EFFECT; |
500 | dummy->type = SPELL_EFFECT; |
515 | dummy->subtype = SP_WORD_OF_RECALL; |
501 | dummy->subtype = SP_WORD_OF_RECALL; |
516 | |
502 | dummy->slaying = op->contr->savebed_map; |
517 | /* If we could take advantage of enter_player_savebed() here, it would be |
503 | dummy->stats.hp = op->contr->bed_x; |
518 | * nice, but until the map load fails, we can't. |
504 | dummy->stats.sp = op->contr->bed_y; |
519 | */ |
|
|
520 | EXIT_PATH (dummy) = op->contr->savebed_map; |
|
|
521 | EXIT_X (dummy) = op->contr->bed_x; |
|
|
522 | EXIT_Y (dummy) = op->contr->bed_y; |
|
|
523 | |
505 | |
524 | op->insert (dummy); |
506 | op->insert (dummy); |
525 | |
507 | |
526 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you."); |
508 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you."); |
527 | |
509 | |
… | |
… | |
1107 | force->speed_left = -1.0; |
1089 | force->speed_left = -1.0; |
1108 | force->set_flag (FLAG_APPLIED); |
1090 | force->set_flag (FLAG_APPLIED); |
1109 | |
1091 | |
1110 | /* Now start processing the effects. First, protections */ |
1092 | /* Now start processing the effects. First, protections */ |
1111 | for (i = 0; i < NROFATTACKS; i++) |
1093 | for (i = 0; i < NROFATTACKS; i++) |
1112 | { |
|
|
1113 | if (spell_ob->resist[i]) |
1094 | if (spell_ob->resist[i]) |
1114 | { |
|
|
1115 | force->resist[i] = spell_ob->resist[i] + SP_level_dam_adjust (caster, spell_ob); |
1095 | force->resist[i] = min (100, spell_ob->resist[i] + SP_level_dam_adjust (caster, spell_ob)); |
1116 | if (force->resist[i] > 100) |
|
|
1117 | force->resist[i] = 100; |
|
|
1118 | } |
|
|
1119 | } |
|
|
1120 | |
1096 | |
1121 | if (spell_ob->stats.hp) |
1097 | if (spell_ob->stats.hp) |
1122 | force->stats.hp = spell_ob->stats.hp + SP_level_dam_adjust (caster, spell_ob); |
1098 | force->stats.hp = spell_ob->stats.hp + SP_level_dam_adjust (caster, spell_ob); |
1123 | |
1099 | |
1124 | if (tmp->type == PLAYER) |
1100 | if (tmp->type == PLAYER) |
… | |
… | |
1235 | { |
1211 | { |
1236 | new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect."); |
1212 | new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect."); |
1237 | } |
1213 | } |
1238 | return 0; |
1214 | return 0; |
1239 | } |
1215 | } |
|
|
1216 | |
1240 | force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50; |
1217 | force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50; |
1241 | force->speed = 1.0; |
1218 | force->speed = 1.0; |
1242 | force->speed_left = -1.0; |
1219 | force->speed_left = -1.0; |
1243 | force->set_flag (FLAG_APPLIED); |
1220 | force->set_flag (FLAG_APPLIED); |
1244 | |
1221 | |
… | |
… | |
1392 | } |
1369 | } |
1393 | |
1370 | |
1394 | value -= rndm (value >> 4); |
1371 | value -= rndm (value >> 4); |
1395 | value = min (value, value_max); |
1372 | value = min (value, value_max); |
1396 | |
1373 | |
1397 | for (int i = 0; i < sizeof (nugget) / sizeof (nugget [0]); ++i) |
1374 | for (int i = 0; i < array_length (nugget); ++i) |
1398 | if (int nrof = value / nugget [i]->value) |
1375 | if (int nrof = value / nugget [i]->value) |
1399 | { |
1376 | { |
1400 | value -= nrof * nugget[i]->value; |
1377 | value -= nrof * nugget[i]->value; |
1401 | |
1378 | |
1402 | object *tmp = nugget[i]->instance (); |
1379 | object *tmp = nugget[i]->instance (); |
… | |
… | |
1420 | int |
1397 | int |
1421 | remove_curse (object *op, object *caster, object *spell) |
1398 | remove_curse (object *op, object *caster, object *spell) |
1422 | { |
1399 | { |
1423 | int success = 0, was_one = 0; |
1400 | int success = 0, was_one = 0; |
1424 | |
1401 | |
|
|
1402 | int num_uncurse = max (1, spell->stats.dam + SP_level_dam_adjust (caster, spell)); |
|
|
1403 | |
|
|
1404 | op->splay_marked (); |
|
|
1405 | |
1425 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1406 | for (object *tmp = op->inv; tmp && num_uncurse; tmp = tmp->below) |
1426 | if (tmp->flag [FLAG_APPLIED] && |
1407 | if (!tmp->invisible |
1427 | ((tmp->flag [FLAG_CURSED] && spell->flag [FLAG_CURSED]) || |
1408 | && (((tmp->flag [FLAG_CURSED] && spell->flag [FLAG_CURSED]) |
1428 | (tmp->flag [FLAG_DAMNED] && spell->flag [FLAG_DAMNED]))) |
1409 | || (tmp->flag [FLAG_DAMNED] && spell->flag [FLAG_DAMNED])))) |
1429 | { |
1410 | { |
1430 | was_one++; |
1411 | ++was_one; |
1431 | |
1412 | |
1432 | if (tmp->level <= casting_level (caster, spell)) |
1413 | if (tmp->level <= casting_level (caster, spell)) |
1433 | { |
1414 | { |
1434 | success++; |
1415 | ++success; |
|
|
1416 | --num_uncurse; |
|
|
1417 | |
1435 | if (spell->flag [FLAG_DAMNED]) |
1418 | if (spell->flag [FLAG_DAMNED]) |
1436 | tmp->clr_flag (FLAG_DAMNED); |
1419 | tmp->clr_flag (FLAG_DAMNED); |
1437 | |
1420 | |
1438 | tmp->clr_flag (FLAG_CURSED); |
1421 | tmp->clr_flag (FLAG_CURSED); |
1439 | tmp->clr_flag (FLAG_KNOWN_CURSED); |
1422 | tmp->clr_flag (FLAG_KNOWN_CURSED); |
… | |
… | |
1445 | } |
1428 | } |
1446 | |
1429 | |
1447 | if (op->type == PLAYER) |
1430 | if (op->type == PLAYER) |
1448 | { |
1431 | { |
1449 | if (success) |
1432 | if (success) |
1450 | new_draw_info (NDI_UNIQUE, 0, op, "You feel like some of your items are looser now."); |
1433 | new_draw_info (NDI_UNIQUE, 0, op, "You realise that some of your items look shinier now. H<You successfully removed some curses.>"); |
1451 | else |
1434 | else |
1452 | { |
1435 | { |
1453 | if (was_one) |
1436 | if (was_one) |
1454 | new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse."); |
1437 | new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove any curse. H<The spell was not strong enough.>"); |
1455 | else |
1438 | else |
1456 | new_draw_info (NDI_UNIQUE, 0, op, "You are not using any cursed items."); |
1439 | new_draw_info (NDI_UNIQUE, 0, op, "You are not having any cursed items."); |
1457 | } |
1440 | } |
1458 | } |
1441 | } |
1459 | |
1442 | |
1460 | return success; |
1443 | return success; |
1461 | } |
1444 | } |
1462 | |
1445 | |
1463 | /* Identifies objects in the players inventory/on the ground */ |
1446 | /* Identifies objects in the players inventory/on the ground */ |
1464 | int |
1447 | int |
1465 | cast_identify (object *op, object *caster, object *spell) |
1448 | cast_identify (object *op, object *caster, object *spell) |
1466 | { |
1449 | { |
1467 | object *tmp; |
|
|
1468 | dynbuf_text &buf = msg_dynbuf; buf.clear (); |
1450 | dynbuf_text &buf = msg_dynbuf; buf.clear (); |
1469 | |
1451 | |
1470 | int num_ident = max (1, spell->stats.dam + SP_level_dam_adjust (caster, spell)); |
1452 | int num_ident = max (1, spell->stats.dam + SP_level_dam_adjust (caster, spell)); |
1471 | |
1453 | |
|
|
1454 | op->splay_marked (); |
|
|
1455 | |
1472 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1456 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1473 | { |
1457 | { |
1474 | if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && need_identify (tmp)) |
1458 | if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && tmp->need_identify ()) |
1475 | { |
1459 | { |
1476 | identify (tmp); |
1460 | identify (tmp); |
1477 | |
1461 | |
1478 | if (op->type == PLAYER) |
1462 | if (op->type == PLAYER) |
1479 | { |
1463 | { |
… | |
… | |
1492 | * stuff on the floor. Only identify stuff on the floor if the spell |
1476 | * stuff on the floor. Only identify stuff on the floor if the spell |
1493 | * was not fully used. |
1477 | * was not fully used. |
1494 | */ |
1478 | */ |
1495 | if (num_ident) |
1479 | if (num_ident) |
1496 | { |
1480 | { |
1497 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above) |
1481 | for (object *tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above) |
1498 | if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && need_identify (tmp)) |
1482 | if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && tmp->need_identify ()) |
1499 | { |
1483 | { |
1500 | identify (tmp); |
1484 | identify (tmp); |
1501 | |
1485 | |
1502 | if (object *pl = tmp->visible_to ()) |
1486 | if (object *pl = tmp->visible_to ()) |
1503 | { |
1487 | { |
… | |
… | |
1616 | * difficult to see what object is magical/cursed, so the |
1600 | * difficult to see what object is magical/cursed, so the |
1617 | * effect wouldn't be as apparent. |
1601 | * effect wouldn't be as apparent. |
1618 | */ |
1602 | */ |
1619 | |
1603 | |
1620 | /* detect magic */ |
1604 | /* detect magic */ |
1621 | if (spell->flag [FLAG_KNOWN_MAGICAL] && |
1605 | if (spell->flag [FLAG_KNOWN_MAGICAL] |
1622 | !tmp->flag [FLAG_KNOWN_MAGICAL] && !tmp->flag [FLAG_IDENTIFIED] && is_magical (tmp)) |
1606 | && !tmp->flag [FLAG_KNOWN_MAGICAL] |
|
|
1607 | && !tmp->flag [FLAG_IDENTIFIED] |
|
|
1608 | && tmp->need_identify () |
|
|
1609 | && is_magical (tmp)) |
1623 | { |
1610 | { |
1624 | tmp->set_flag (FLAG_KNOWN_MAGICAL); |
1611 | tmp->set_flag (FLAG_KNOWN_MAGICAL); |
1625 | /* make runes more visible */ |
1612 | /* make runes more visible */ |
1626 | if (tmp->type == RUNE && tmp->attacktype & AT_MAGIC) |
1613 | if (tmp->type == RUNE && tmp->attacktype & AT_MAGIC) |
1627 | tmp->stats.Cha /= 4; |
1614 | tmp->stats.Cha /= 4; |
… | |
… | |
1650 | |
1637 | |
1651 | if (!detect) |
1638 | if (!detect) |
1652 | detect = tmp; |
1639 | detect = tmp; |
1653 | } |
1640 | } |
1654 | |
1641 | |
1655 | if (spell->flag [FLAG_KNOWN_CURSED] && !tmp->flag [FLAG_KNOWN_CURSED] && |
1642 | if (spell->flag [FLAG_KNOWN_CURSED] |
|
|
1643 | && !tmp->flag [FLAG_KNOWN_CURSED] |
|
|
1644 | && tmp->need_identify () |
1656 | (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED])) |
1645 | && (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED])) |
1657 | { |
1646 | { |
1658 | tmp->set_flag (FLAG_KNOWN_CURSED); |
1647 | tmp->set_flag (FLAG_KNOWN_CURSED); |
1659 | done_one = 1; |
1648 | done_one = 1; |
1660 | } |
1649 | } |
1661 | |
1650 | |
… | |
… | |
1978 | * player checks. MSW 2003-01-06 |
1967 | * player checks. MSW 2003-01-06 |
1979 | */ |
1968 | */ |
1980 | int |
1969 | int |
1981 | animate_weapon (object *op, object *caster, object *spell, int dir) |
1970 | animate_weapon (object *op, object *caster, object *spell, int dir) |
1982 | { |
1971 | { |
1983 | object *weapon, *tmp; |
|
|
1984 | char buf[MAX_BUF]; |
1972 | char buf[MAX_BUF]; |
1985 | int a, i; |
1973 | int a, i; |
1986 | sint16 x, y; |
1974 | sint16 x, y; |
1987 | maptile *m; |
1975 | maptile *m; |
1988 | |
1976 | |
… | |
… | |
2018 | op->failmsg ("There is something in the way."); |
2006 | op->failmsg ("There is something in the way."); |
2019 | return 0; |
2007 | return 0; |
2020 | } |
2008 | } |
2021 | |
2009 | |
2022 | /* Use the weapon marked by the player. */ |
2010 | /* Use the weapon marked by the player. */ |
2023 | weapon = find_marked_object (op); |
2011 | object *weapon = op->mark (); |
2024 | |
2012 | |
2025 | if (!weapon) |
2013 | if (!weapon) |
2026 | { |
2014 | { |
2027 | op->failmsg ("You must mark a weapon to use with this spell!"); |
2015 | op->failmsg ("You must mark a weapon to use with this spell!"); |
2028 | return 0; |
2016 | return 0; |
… | |
… | |
2047 | } |
2035 | } |
2048 | |
2036 | |
2049 | weapon = weapon->split (); |
2037 | weapon = weapon->split (); |
2050 | |
2038 | |
2051 | /* create the golem object */ |
2039 | /* create the golem object */ |
2052 | tmp = spell->other_arch->instance (); |
2040 | object *tmp = spell->other_arch->instance (); |
2053 | |
2041 | |
2054 | /* if animated by a player, give the player control of the golem */ |
2042 | /* if animated by a player, give the player control of the golem */ |
2055 | tmp->clr_flag (FLAG_MONSTER); |
2043 | tmp->clr_flag (FLAG_MONSTER); |
2056 | tmp->stats.exp = 0; |
2044 | tmp->stats.exp = 0; |
2057 | add_friendly_object (tmp); |
2045 | add_friendly_object (tmp); |