… | |
… | |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <cmath> |
25 | #include <cmath> |
25 | |
26 | |
… | |
… | |
100 | return 0; |
101 | return 0; |
101 | |
102 | |
102 | /* Check for MONEY type is a special hack - it prevents 'nothing needs |
103 | /* Check for MONEY type is a special hack - it prevents 'nothing needs |
103 | * identifying' from being printed out more than it needs to be. |
104 | * identifying' from being printed out more than it needs to be. |
104 | */ |
105 | */ |
105 | if (!check_altar_sacrifice (altar, money) || money->type != MONEY) |
106 | if (!check_altar_sacrifice (altar, money, pl) || money->type != MONEY) |
106 | return 0; |
107 | return 0; |
107 | |
108 | |
108 | /* if the player has a marked item, identify that if it needs to be |
109 | /* if the player has a marked item, identify that if it needs to be |
109 | * identified. If it doesn't, then go through the player inventory. |
110 | * identified. If it doesn't, then go through the player inventory. |
110 | */ |
111 | */ |
111 | if (object *marked = find_marked_object (pl)) |
112 | if (object *marked = find_marked_object (pl)) |
112 | if (!QUERY_FLAG (marked, FLAG_IDENTIFIED) && need_identify (marked)) |
113 | if (!QUERY_FLAG (marked, FLAG_IDENTIFIED) && need_identify (marked)) |
113 | { |
114 | { |
114 | if (operate_altar (altar, &money)) |
115 | if (operate_altar (altar, &money, pl)) |
115 | { |
116 | { |
116 | identify (marked); |
117 | identify (marked); |
117 | |
118 | |
118 | buf.printf ("You have %s.\r", long_desc (marked, pl)); |
119 | buf.printf ("You have %s.\r", long_desc (marked, pl)); |
119 | if (marked->msg) |
120 | if (marked->msg) |
… | |
… | |
125 | |
126 | |
126 | for (object *id = pl->inv; id; id = id->below) |
127 | for (object *id = pl->inv; id; id = id->below) |
127 | { |
128 | { |
128 | if (!QUERY_FLAG (id, FLAG_IDENTIFIED) && !id->invisible && need_identify (id)) |
129 | if (!QUERY_FLAG (id, FLAG_IDENTIFIED) && !id->invisible && need_identify (id)) |
129 | { |
130 | { |
130 | if (operate_altar (altar, &money)) |
131 | if (operate_altar (altar, &money, pl)) |
131 | { |
132 | { |
132 | identify (id); |
133 | identify (id); |
133 | |
134 | |
134 | buf.printf ("You have %s.\r", long_desc (id, pl)); |
135 | buf.printf ("You have %s.\r", long_desc (id, pl)); |
135 | if (id->msg) |
136 | if (id->msg) |
… | |
… | |
857 | * Takes one type of items and makes another. |
858 | * Takes one type of items and makes another. |
858 | * converter is the object that is doing the conversion. |
859 | * converter is the object that is doing the conversion. |
859 | * item is the object that triggered the converter - if it is not |
860 | * item is the object that triggered the converter - if it is not |
860 | * what the converter wants, this will not do anything. |
861 | * what the converter wants, this will not do anything. |
861 | */ |
862 | */ |
862 | static int |
863 | int |
863 | convert_item (object *item, object *converter) |
864 | convert_item (object *item, object *converter) |
864 | { |
865 | { |
865 | sint64 nr, price_in; |
866 | sint64 nr, price_in; |
866 | |
867 | |
867 | if (item->flag [FLAG_UNPAID]) |
868 | if (item->flag [FLAG_UNPAID]) |
… | |
… | |
1060 | { |
1061 | { |
1061 | /* Only players can make sacrifices on spell casting altars. */ |
1062 | /* Only players can make sacrifices on spell casting altars. */ |
1062 | if (altar->inv && (!originator || originator->type != PLAYER)) |
1063 | if (altar->inv && (!originator || originator->type != PLAYER)) |
1063 | return 0; |
1064 | return 0; |
1064 | |
1065 | |
1065 | if (operate_altar (altar, &sacrifice)) |
1066 | if (operate_altar (altar, &sacrifice, originator)) |
1066 | { |
1067 | { |
1067 | /* Simple check. Unfortunately, it means you can't cast magic bullet |
1068 | /* Simple check. Unfortunately, it means you can't cast magic bullet |
1068 | * with an altar. We call it a Potion - altars are stationary - it |
1069 | * with an altar. We call it a Potion - altars are stationary - it |
1069 | * is up to map designers to use them properly. |
1070 | * is up to map designers to use them properly. |
1070 | */ |
1071 | */ |
… | |
… | |
1106 | |
1107 | |
1107 | SET_FLAG (op, FLAG_NO_APPLY); /* prevent loops */ |
1108 | SET_FLAG (op, FLAG_NO_APPLY); /* prevent loops */ |
1108 | |
1109 | |
1109 | bool has_unpaid = false; |
1110 | bool has_unpaid = false; |
1110 | |
1111 | |
1111 | // quite inefficient to do this here twice, but the api doesn'T lend itself to |
1112 | // quite inefficient to do this here twice, but the api doesn't lend itself to |
1112 | // a quick and small change :( |
1113 | // a quick and small change :( |
1113 | for (object::depth_iterator item = op->begin (); item != op->end (); ++item) |
1114 | for (object::depth_iterator item = op->begin (); item != op->end (); ++item) |
1114 | if (item->flag [FLAG_UNPAID]) |
1115 | if (item->flag [FLAG_UNPAID]) |
1115 | { |
1116 | { |
1116 | has_unpaid = true; |
1117 | has_unpaid = true; |
… | |
… | |
1341 | |
1342 | |
1342 | recursion_depth++; |
1343 | recursion_depth++; |
1343 | if (trap->head) |
1344 | if (trap->head) |
1344 | trap = trap->head; |
1345 | trap = trap->head; |
1345 | |
1346 | |
1346 | if (INVOKE_OBJECT (MOVE_TRIGGER, trap, ARG_OBJECT (victim), ARG_OBJECT (originator))) |
1347 | if (!INVOKE_OBJECT (MOVE_TRIGGER, trap, ARG_OBJECT (victim), ARG_OBJECT (originator))) |
1347 | goto leave; |
|
|
1348 | |
|
|
1349 | switch (trap->type) |
1348 | switch (trap->type) |
1350 | { |
1349 | { |
1351 | case PLAYERMOVER: |
1350 | case PLAYERMOVER: |
1352 | if (trap->attacktype && (trap->level || victim->type != PLAYER) && !should_director_abort (trap, victim)) |
1351 | if (trap->attacktype && (trap->level || victim->type != PLAYER) && !should_director_abort (trap, victim)) |
|
|
1352 | { |
|
|
1353 | if (!trap->stats.maxsp) |
|
|
1354 | trap->stats.maxsp = 2; |
|
|
1355 | |
|
|
1356 | /* Is this correct? From the docs, it doesn't look like it |
|
|
1357 | * should be divided by trap->speed |
|
|
1358 | */ |
|
|
1359 | victim->speed_left = -FABS (trap->stats.maxsp * victim->speed / trap->speed); |
|
|
1360 | |
|
|
1361 | /* Just put in some sanity check. I think there is a bug in the |
|
|
1362 | * above with some objects have zero speed, and thus the player |
|
|
1363 | * getting permanently paralyzed. |
|
|
1364 | */ |
|
|
1365 | if (victim->speed_left < -50.f) |
|
|
1366 | victim->speed_left = -50.f; |
|
|
1367 | /* LOG(llevDebug, "apply, playermove, player speed_left=%f\n", victim->speed_left); */ |
|
|
1368 | } |
|
|
1369 | break; |
|
|
1370 | |
|
|
1371 | case SPINNER: |
|
|
1372 | if (victim->direction) |
|
|
1373 | { |
|
|
1374 | victim->direction = absdir (victim->direction - trap->stats.sp); |
|
|
1375 | update_turn_face (victim); |
|
|
1376 | } |
|
|
1377 | break; |
|
|
1378 | |
|
|
1379 | case DIRECTOR: |
|
|
1380 | if (victim->direction && !should_director_abort (trap, victim)) |
|
|
1381 | { |
|
|
1382 | victim->direction = trap->stats.sp; |
|
|
1383 | update_turn_face (victim); |
|
|
1384 | } |
|
|
1385 | break; |
|
|
1386 | |
|
|
1387 | case BUTTON: |
|
|
1388 | case PEDESTAL: |
|
|
1389 | update_button (trap, originator); |
|
|
1390 | break; |
|
|
1391 | |
|
|
1392 | case ALTAR: |
|
|
1393 | /* sacrifice victim on trap */ |
|
|
1394 | apply_altar (trap, victim, originator); |
|
|
1395 | break; |
|
|
1396 | |
|
|
1397 | case THROWN_OBJ: |
|
|
1398 | if (trap->inv == NULL) |
|
|
1399 | break; |
|
|
1400 | /* fallthrough */ |
|
|
1401 | |
|
|
1402 | case ARROW: |
|
|
1403 | /* bad bug: monster throw a object, make a step forwards, step on object , |
|
|
1404 | * trigger this here and get hit by own missile - and will be own enemy. |
|
|
1405 | * Victim then is his own enemy and will start to kill herself (this is |
|
|
1406 | * removed) but we have not synced victim and his missile. To avoid senseless |
|
|
1407 | * action, we avoid hits here |
|
|
1408 | */ |
|
|
1409 | if ((QUERY_FLAG (victim, FLAG_ALIVE) && trap->speed) && trap->owner != victim) |
|
|
1410 | hit_with_arrow (trap, victim); |
|
|
1411 | break; |
|
|
1412 | |
|
|
1413 | case SPELL_EFFECT: |
|
|
1414 | apply_spell_effect (trap, victim); |
|
|
1415 | break; |
|
|
1416 | |
|
|
1417 | case TRAPDOOR: |
1353 | { |
1418 | { |
|
|
1419 | int max, sound_was_played; |
|
|
1420 | object *ab, *ab_next; |
|
|
1421 | |
1354 | if (!trap->stats.maxsp) |
1422 | if (!trap->value) |
1355 | trap->stats.maxsp = 2; |
1423 | { |
|
|
1424 | int tot; |
1356 | |
1425 | |
1357 | /* Is this correct? From the docs, it doesn't look like it |
1426 | for (ab = trap->above, tot = 0; ab; ab = ab->above) |
1358 | * should be divided by trap->speed |
1427 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
|
|
1428 | tot += ab->head_ ()->total_weight (); |
|
|
1429 | |
|
|
1430 | if (!(trap->value = (tot > trap->weight) ? 1 : 0)) |
|
|
1431 | break; |
|
|
1432 | |
|
|
1433 | SET_ANIMATION (trap, trap->value); |
|
|
1434 | update_object (trap, UP_OBJ_FACE); |
|
|
1435 | } |
|
|
1436 | |
|
|
1437 | for (ab = trap->above, max = 100, sound_was_played = 0; --max && ab; ab = ab_next) |
|
|
1438 | { |
|
|
1439 | /* need to set this up, since if we do transfer the object, |
|
|
1440 | * ab->above would be bogus |
1359 | */ |
1441 | */ |
1360 | victim->speed_left = -FABS (trap->stats.maxsp * victim->speed / trap->speed); |
1442 | ab_next = ab->above; |
1361 | |
1443 | |
1362 | /* Just put in some sanity check. I think there is a bug in the |
1444 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1363 | * above with some objects have zero speed, and thus the player |
1445 | { |
1364 | * getting permanently paralyzed. |
1446 | if (!sound_was_played) |
|
|
1447 | { |
|
|
1448 | trap->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole")); |
|
|
1449 | sound_was_played = 1; |
|
|
1450 | } |
|
|
1451 | |
|
|
1452 | ab->statusmsg ("You fall into a trapdoor!", NDI_RED); |
|
|
1453 | transfer_ob (ab, EXIT_X (trap), EXIT_Y (trap), 0, ab); |
|
|
1454 | } |
1365 | */ |
1455 | } |
1366 | if (victim->speed_left < -50.f) |
1456 | break; |
1367 | victim->speed_left = -50.f; |
|
|
1368 | /* LOG(llevDebug, "apply, playermove, player speed_left=%f\n", victim->speed_left); */ |
|
|
1369 | } |
1457 | } |
1370 | goto leave; |
|
|
1371 | |
1458 | |
1372 | case SPINNER: |
1459 | case CONVERTER: |
1373 | if (victim->direction) |
1460 | if (convert_item (victim, trap) < 0) |
1374 | { |
|
|
1375 | victim->direction = absdir (victim->direction - trap->stats.sp); |
|
|
1376 | update_turn_face (victim); |
|
|
1377 | } |
|
|
1378 | goto leave; |
|
|
1379 | |
|
|
1380 | case DIRECTOR: |
|
|
1381 | if (victim->direction && !should_director_abort (trap, victim)) |
|
|
1382 | { |
|
|
1383 | victim->direction = trap->stats.sp; |
|
|
1384 | update_turn_face (victim); |
|
|
1385 | } |
|
|
1386 | goto leave; |
|
|
1387 | |
|
|
1388 | case BUTTON: |
|
|
1389 | case PEDESTAL: |
|
|
1390 | update_button (trap, originator); |
|
|
1391 | goto leave; |
|
|
1392 | |
|
|
1393 | case ALTAR: |
|
|
1394 | /* sacrifice victim on trap */ |
|
|
1395 | apply_altar (trap, victim, originator); |
|
|
1396 | goto leave; |
|
|
1397 | |
|
|
1398 | case THROWN_OBJ: |
|
|
1399 | if (trap->inv == NULL) |
|
|
1400 | goto leave; |
|
|
1401 | /* fallthrough */ |
|
|
1402 | |
|
|
1403 | case ARROW: |
|
|
1404 | /* bad bug: monster throw a object, make a step forwards, step on object , |
|
|
1405 | * trigger this here and get hit by own missile - and will be own enemy. |
|
|
1406 | * Victim then is his own enemy and will start to kill herself (this is |
|
|
1407 | * removed) but we have not synced victim and his missile. To avoid senseless |
|
|
1408 | * action, we avoid hits here |
|
|
1409 | */ |
|
|
1410 | if ((QUERY_FLAG (victim, FLAG_ALIVE) && trap->speed) && trap->owner != victim) |
|
|
1411 | hit_with_arrow (trap, victim); |
|
|
1412 | goto leave; |
|
|
1413 | |
|
|
1414 | case SPELL_EFFECT: |
|
|
1415 | apply_spell_effect (trap, victim); |
|
|
1416 | goto leave; |
|
|
1417 | |
|
|
1418 | case TRAPDOOR: |
|
|
1419 | { |
|
|
1420 | int max, sound_was_played; |
|
|
1421 | object *ab, *ab_next; |
|
|
1422 | |
|
|
1423 | if (!trap->value) |
|
|
1424 | { |
1461 | { |
1425 | int tot; |
1462 | originator->failmsg (format ("The %s seems to be broken!", query_name (trap))); |
1426 | |
1463 | archetype::get (shstr_burnout)->insert_at (trap, trap); |
1427 | for (ab = trap->above, tot = 0; ab; ab = ab->above) |
|
|
1428 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
|
|
1429 | tot += ab->head_ ()->total_weight (); |
|
|
1430 | |
|
|
1431 | if (!(trap->value = (tot > trap->weight) ? 1 : 0)) |
|
|
1432 | goto leave; |
|
|
1433 | |
|
|
1434 | SET_ANIMATION (trap, trap->value); |
|
|
1435 | update_object (trap, UP_OBJ_FACE); |
|
|
1436 | } |
1464 | } |
1437 | |
1465 | |
1438 | for (ab = trap->above, max = 100, sound_was_played = 0; --max && ab; ab = ab_next) |
1466 | break; |
|
|
1467 | |
|
|
1468 | case TRIGGER_BUTTON: |
|
|
1469 | case TRIGGER_PEDESTAL: |
|
|
1470 | case TRIGGER_ALTAR: |
|
|
1471 | check_trigger (trap, victim, originator); |
|
|
1472 | break; |
|
|
1473 | |
|
|
1474 | case DEEP_SWAMP: |
|
|
1475 | walk_on_deep_swamp (trap, victim); |
|
|
1476 | break; |
|
|
1477 | |
|
|
1478 | case CHECK_INV: |
|
|
1479 | check_inv (victim, trap); |
|
|
1480 | break; |
|
|
1481 | |
|
|
1482 | case HOLE: |
|
|
1483 | move_apply_hole (trap, victim); |
|
|
1484 | break; |
|
|
1485 | |
|
|
1486 | case EXIT: |
|
|
1487 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1439 | { |
1488 | { |
1440 | /* need to set this up, since if we do transfer the object, |
1489 | /* Basically, don't show exits leading to random maps the |
1441 | * ab->above would be bogus |
1490 | * players output. |
1442 | */ |
1491 | */ |
1443 | ab_next = ab->above; |
1492 | if (trap->msg && !EXIT_PATH (trap).starts_with ("/!")) |
|
|
1493 | victim->statusmsg (trap->msg, NDI_NAVY); |
1444 | |
1494 | |
1445 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1495 | trap->play_sound (trap->sound); |
1446 | { |
1496 | victim->enter_exit (trap); |
1447 | if (!sound_was_played) |
|
|
1448 | { |
|
|
1449 | trap->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole")); |
|
|
1450 | sound_was_played = 1; |
|
|
1451 | } |
|
|
1452 | |
|
|
1453 | ab->statusmsg ("You fall into a trapdoor!", NDI_RED); |
|
|
1454 | transfer_ob (ab, EXIT_X (trap), EXIT_Y (trap), 0, ab); |
|
|
1455 | } |
|
|
1456 | } |
1497 | } |
1457 | goto leave; |
1498 | break; |
1458 | } |
|
|
1459 | |
1499 | |
1460 | case CONVERTER: |
|
|
1461 | if (convert_item (victim, trap) < 0) |
|
|
1462 | { |
|
|
1463 | originator->failmsg (format ("The %s seems to be broken!", query_name (trap))); |
|
|
1464 | archetype::get (shstr_burnout)->insert_at (trap, trap); |
|
|
1465 | } |
|
|
1466 | |
|
|
1467 | goto leave; |
|
|
1468 | |
|
|
1469 | case TRIGGER_BUTTON: |
|
|
1470 | case TRIGGER_PEDESTAL: |
|
|
1471 | case TRIGGER_ALTAR: |
|
|
1472 | check_trigger (trap, victim); |
|
|
1473 | goto leave; |
|
|
1474 | |
|
|
1475 | case DEEP_SWAMP: |
|
|
1476 | walk_on_deep_swamp (trap, victim); |
|
|
1477 | goto leave; |
|
|
1478 | |
|
|
1479 | case CHECK_INV: |
|
|
1480 | check_inv (victim, trap); |
|
|
1481 | goto leave; |
|
|
1482 | |
|
|
1483 | case HOLE: |
|
|
1484 | move_apply_hole (trap, victim); |
|
|
1485 | goto leave; |
|
|
1486 | |
|
|
1487 | case EXIT: |
|
|
1488 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
|
|
1489 | { |
|
|
1490 | /* Basically, don't show exits leading to random maps the |
|
|
1491 | * players output. |
|
|
1492 | */ |
|
|
1493 | if (trap->msg && !EXIT_PATH (trap).starts_with ("/!")) |
|
|
1494 | victim->statusmsg (trap->msg, NDI_NAVY); |
|
|
1495 | |
|
|
1496 | trap->play_sound (trap->sound); |
|
|
1497 | victim->enter_exit (trap); |
|
|
1498 | } |
|
|
1499 | goto leave; |
|
|
1500 | |
|
|
1501 | case ENCOUNTER: |
1500 | case ENCOUNTER: |
1502 | /* may be some leftovers on this */ |
1501 | /* may be some leftovers on this */ |
1503 | goto leave; |
1502 | break; |
1504 | |
1503 | |
1505 | case SHOP_MAT: |
1504 | case SHOP_MAT: |
1506 | apply_shop_mat (trap, victim); |
1505 | apply_shop_mat (trap, victim); |
1507 | goto leave; |
1506 | break; |
1508 | |
1507 | |
1509 | /* Drop a certain amount of gold, and have one item identified */ |
1508 | /* Drop a certain amount of gold, and have one item identified */ |
1510 | case IDENTIFY_ALTAR: |
1509 | case IDENTIFY_ALTAR: |
1511 | apply_id_altar (victim, trap, originator); |
1510 | apply_id_altar (victim, trap, originator); |
1512 | goto leave; |
1511 | break; |
1513 | |
1512 | |
1514 | case SIGN: |
1513 | case SIGN: |
1515 | if (victim->type != PLAYER && trap->stats.food > 0) |
1514 | if (victim->type != PLAYER && trap->stats.food > 0) |
1516 | goto leave; /* monsters musn't apply magic_mouths with counters */ |
1515 | break; /* monsters musn't apply magic_mouths with counters */ |
1517 | |
1516 | |
1518 | apply_sign (victim, trap, 1); |
1517 | apply_sign (victim, trap, 1); |
1519 | goto leave; |
1518 | break; |
1520 | |
1519 | |
1521 | case CONTAINER: |
1520 | case CONTAINER: |
1522 | apply_container (victim, trap); |
1521 | apply_container (victim, trap); |
1523 | goto leave; |
1522 | break; |
1524 | |
1523 | |
1525 | case RUNE: |
1524 | case RUNE: |
1526 | case TRAP: |
1525 | case TRAP: |
1527 | if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) |
1526 | if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) |
1528 | spring_trap (trap, victim); |
1527 | spring_trap (trap, victim); |
1529 | goto leave; |
1528 | break; |
1530 | |
1529 | |
1531 | default: |
1530 | default: |
1532 | LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " |
1531 | LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " |
1533 | "handled in move_apply()\n", &trap->name, &trap->arch->archname, trap->type); |
1532 | "handled in move_apply()\n", &trap->name, &trap->arch->archname, trap->type); |
1534 | goto leave; |
1533 | break; |
1535 | } |
1534 | } |
1536 | |
1535 | |
1537 | leave: |
|
|
1538 | recursion_depth--; |
1536 | recursion_depth--; |
1539 | } |
1537 | } |
1540 | |
1538 | |
1541 | /** |
1539 | /** |
1542 | * Handles reading a regular (ie not containing a spell) book. |
1540 | * Handles reading a regular (ie not containing a spell) book. |
… | |
… | |
2310 | /** |
2308 | /** |
2311 | * This function will try to apply a lighter and in case no lighter |
2309 | * This function will try to apply a lighter and in case no lighter |
2312 | * is specified it will try to find a lighter in the players inventory, |
2310 | * is specified it will try to find a lighter in the players inventory, |
2313 | * and inform him about this requirement. |
2311 | * and inform him about this requirement. |
2314 | * |
2312 | * |
2315 | * who - the player |
2313 | * who - the player |
2316 | * op - the item we want to light |
2314 | * op - the item we want to light |
2317 | * ligher - the lighter or 0 if a lighter has yet to be found |
2315 | * lighter - the lighter or 0 if a lighter has yet to be found |
2318 | */ |
2316 | */ |
|
|
2317 | static object * |
2319 | object *auto_apply_lighter (object *who, object *op, object *lighter) |
2318 | auto_apply_lighter (object *who, object *op, object *lighter) |
2320 | { |
2319 | { |
2321 | if (lighter == 0) |
2320 | if (lighter == 0) |
2322 | { |
2321 | { |
2323 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2322 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2324 | { |
2323 | { |
… | |
… | |
2371 | int is_player_env = 0; |
2370 | int is_player_env = 0; |
2372 | |
2371 | |
2373 | item = find_marked_object (who); |
2372 | item = find_marked_object (who); |
2374 | if (item) |
2373 | if (item) |
2375 | { |
2374 | { |
2376 | if (!auto_apply_lighter (who, 0, lighter)) |
2375 | if (!auto_apply_lighter (who, item, lighter)) |
2377 | return; |
2376 | return; |
2378 | |
2377 | |
2379 | /* Perhaps we should split what we are trying to light on fire? |
2378 | /* Perhaps we should split what we are trying to light on fire? |
2380 | * I can't see many times when you would want to light multiple |
2379 | * I can't see many times when you would want to light multiple |
2381 | * objects at once. |
2380 | * objects at once. |
… | |
… | |
2597 | update_object (op, UP_OBJ_FACE); |
2596 | update_object (op, UP_OBJ_FACE); |
2598 | push_button (op, who); |
2597 | push_button (op, who); |
2599 | return 1; |
2598 | return 1; |
2600 | |
2599 | |
2601 | case TRIGGER: |
2600 | case TRIGGER: |
2602 | if (check_trigger (op, who)) |
2601 | if (check_trigger (op, who, who)) |
2603 | { |
2602 | { |
2604 | who->statusmsg ("You turn the handle."); |
2603 | who->statusmsg ("You turn the handle."); |
2605 | who->play_sound (sound_find ("turn_handle")); |
2604 | who->play_sound (sound_find ("turn_handle")); |
2606 | } |
2605 | } |
2607 | else |
2606 | else |
… | |
… | |
2612 | case EXIT: |
2611 | case EXIT: |
2613 | if (who->type != PLAYER) |
2612 | if (who->type != PLAYER) |
2614 | return 0; |
2613 | return 0; |
2615 | |
2614 | |
2616 | if (!EXIT_PATH (op) || !is_legal_2ways_exit (who, op)) |
2615 | if (!EXIT_PATH (op) || !is_legal_2ways_exit (who, op)) |
2617 | who->failmsg (format ("The %s is closed.", query_name (op))); |
2616 | 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))); |
2618 | else |
2617 | else |
2619 | { |
2618 | { |
2620 | /* Don't display messages for random maps. */ |
2619 | /* Don't display messages for random maps. */ |
2621 | if (op->msg && !EXIT_PATH (op).starts_with ("/!")) |
2620 | if (op->msg && !EXIT_PATH (op).starts_with ("/!")) |
2622 | who->statusmsg (op->msg, NDI_NAVY); |
2621 | who->statusmsg (op->msg, NDI_NAVY); |
… | |
… | |
3788 | } |
3787 | } |
3789 | |
3788 | |
3790 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
3789 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
3791 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
3790 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
3792 | if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) |
3791 | if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) |
3793 | check_trigger (tmp, tmp->above); |
3792 | check_trigger (tmp, tmp->above, tmp->above); |
3794 | } |
3793 | } |
3795 | |
3794 | |
3796 | /** |
3795 | /** |
3797 | * Handles player eating food that temporarily changes status (resistances, stats). |
3796 | * Handles player eating food that temporarily changes status (resistances, stats). |
3798 | * This used to call cast_change_attr(), but |
3797 | * This used to call cast_change_attr(), but |
… | |
… | |
3803 | eat_special_food (object *who, object *food) |
3802 | eat_special_food (object *who, object *food) |
3804 | { |
3803 | { |
3805 | object *force; |
3804 | object *force; |
3806 | int i, did_one = 0; |
3805 | int i, did_one = 0; |
3807 | |
3806 | |
3808 | force = get_archetype (FORCE_NAME); |
3807 | char buf[64]; |
|
|
3808 | snprintf (buf, sizeof(buf), "sp_food_%s", &food->title); |
|
|
3809 | shstr key (buf); |
3809 | |
3810 | |
3810 | for (i = 0; i < NUM_STATS; i++) |
|
|
3811 | if (sint8 k = food->stats.stat (i)) |
|
|
3812 | { |
|
|
3813 | force->stats.stat (i) = k; |
|
|
3814 | did_one = 1; |
|
|
3815 | } |
|
|
3816 | |
|
|
3817 | /* check if we can protect the eater */ |
|
|
3818 | for (i = 0; i < NROFATTACKS; i++) |
|
|
3819 | { |
|
|
3820 | if (food->resist[i] > 0) |
|
|
3821 | { |
|
|
3822 | force->resist[i] = food->resist[i] / 2; |
|
|
3823 | did_one = 1; |
|
|
3824 | } |
|
|
3825 | } |
|
|
3826 | |
|
|
3827 | if (did_one) |
|
|
3828 | { |
|
|
3829 | force->set_speed (0.1); |
|
|
3830 | /* bigger morsel of food = longer effect time */ |
3811 | /* bigger morsel of food = longer effect time */ |
3831 | force->duration = food->stats.food / 5; |
3812 | int duration = TIME2TICK (food->stats.food); |
3832 | SET_FLAG (force, FLAG_APPLIED); |
3813 | |
3833 | change_abil (who, force); |
3814 | if (force = who->force_find (key)) |
3834 | insert_ob_in_ob (force, who); |
3815 | { |
|
|
3816 | if (duration > abs (force->speed_left / force->speed)) |
|
|
3817 | { |
|
|
3818 | new_draw_info_format (NDI_UNIQUE, 0, who, "More magical force spreads through you. H<The effect will last for about %.10g more seconds.>", TICK2TIME (duration)); |
|
|
3819 | force->force_set_timer (duration); |
|
|
3820 | } |
|
|
3821 | else |
|
|
3822 | new_draw_info (NDI_UNIQUE, 0, who, "It had no additional effect."); |
|
|
3823 | |
|
|
3824 | return; |
3835 | } |
3825 | } |
3836 | else |
3826 | else |
|
|
3827 | { |
|
|
3828 | force = who->force_add (key, duration); |
|
|
3829 | force->name = key; |
|
|
3830 | |
|
|
3831 | /* check if the food affects a stat */ |
|
|
3832 | for (i = 0; i < NUM_STATS; i++) |
|
|
3833 | if (sint8 k = food->stats.stat (i)) |
|
|
3834 | { |
|
|
3835 | force->stats.stat (i) = k; |
|
|
3836 | did_one = 1; |
|
|
3837 | } |
|
|
3838 | |
|
|
3839 | /* check if we can protect the eater */ |
|
|
3840 | for (i = 0; i < NROFATTACKS; i++) |
|
|
3841 | { |
|
|
3842 | if (food->resist[i] > 0) |
|
|
3843 | { |
|
|
3844 | force->resist[i] = food->resist[i]; |
|
|
3845 | did_one = 1; |
|
|
3846 | } |
|
|
3847 | } |
|
|
3848 | |
|
|
3849 | if (did_one) |
|
|
3850 | { |
|
|
3851 | new_draw_info_format (NDI_UNIQUE, 0, who, "You are suffused with magical force. H<The effect will last for about %.10g seconds.>", TICK2TIME (duration)); |
|
|
3852 | |
|
|
3853 | /* make the force take effect and report effects to user */ |
|
|
3854 | change_abil (who, force); |
|
|
3855 | } |
|
|
3856 | else |
3837 | force->destroy (); |
3857 | force->destroy (); |
|
|
3858 | } |
3838 | |
3859 | |
3839 | /* check for hp, sp change */ |
3860 | /* check for hp, sp change */ |
3840 | if (food->stats.hp != 0) |
3861 | if (food->stats.hp != 0) |
3841 | { |
3862 | { |
3842 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3863 | if (QUERY_FLAG (food, FLAG_CURSED)) |