… | |
… | |
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 (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,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 | /* |
25 | /* |
… | |
… | |
442 | if (op->stats.sp == 1) |
443 | if (op->stats.sp == 1) |
443 | { |
444 | { |
444 | if (detected && last == 0) |
445 | if (detected && last == 0) |
445 | { |
446 | { |
446 | op->value = 1; |
447 | op->value = 1; |
447 | push_button (op); |
448 | push_button (op, tmp); |
448 | } |
449 | } |
449 | |
450 | |
450 | if (!detected && last == 1) |
451 | if (!detected && last == 1) |
451 | { |
452 | { |
452 | op->value = 0; |
453 | op->value = 0; |
453 | push_button (op); |
454 | push_button (op, tmp); |
454 | } |
455 | } |
455 | } |
456 | } |
456 | else |
457 | else |
457 | { /* in this case, we unset buttons */ |
458 | { /* in this case, we unset buttons */ |
458 | if (detected && last == 1) |
459 | if (detected && last == 1) |
459 | { |
460 | { |
460 | op->value = 0; |
461 | op->value = 0; |
461 | push_button (op); |
462 | push_button (op, tmp); |
462 | } |
463 | } |
463 | |
464 | |
464 | if (!detected && last == 0) |
465 | if (!detected && last == 0) |
465 | { |
466 | { |
466 | op->value = 1; |
467 | op->value = 1; |
467 | push_button (op); |
468 | push_button (op, tmp); |
468 | } |
469 | } |
469 | } |
470 | } |
470 | } |
471 | } |
471 | |
472 | |
472 | void |
473 | void |
… | |
… | |
599 | |
600 | |
600 | // restore original wc, dam, attacktype and slaying |
601 | // restore original wc, dam, attacktype and slaying |
601 | op->stats.wc = op->stats.sp; |
602 | op->stats.wc = op->stats.sp; |
602 | op->stats.dam = op->stats.hp; |
603 | op->stats.dam = op->stats.hp; |
603 | op->attacktype = op->stats.grace; |
604 | op->attacktype = op->stats.grace; |
|
|
605 | op->slaying = op->custom_name; |
604 | |
606 | |
605 | if (op->spellarg) |
|
|
606 | { |
|
|
607 | op->slaying = op->spellarg; |
|
|
608 | free (op->spellarg); |
|
|
609 | op->spellarg = 0; |
|
|
610 | } |
|
|
611 | else |
|
|
612 | op->slaying = 0; |
|
|
613 | |
|
|
614 | /* Reset these to zero, so that object::can_merge will work properly */ |
607 | /* Reset these to defaults, so that object::can_merge will work properly */ |
615 | op->spellarg = NULL; |
608 | op->custom_name = 0; |
616 | op->stats.sp = 0; |
609 | op->stats.sp = 0; |
617 | op->stats.hp = 0; |
610 | op->stats.hp = 0; |
618 | op->stats.grace = 0; |
611 | op->stats.grace = 0; |
619 | op->level = 0; |
612 | op->level = 0; |
620 | op->face = op->arch->face; |
613 | op->face = op->arch->face; |
621 | op->owner = NULL; /* So that stopped arrows will be saved */ |
614 | op->owner = 0; |
|
|
615 | |
622 | update_object (op, UP_OBJ_CHANGE); |
616 | update_object (op, UP_OBJ_CHANGE); |
|
|
617 | |
623 | return op; |
618 | return op; |
624 | } |
619 | } |
625 | |
620 | |
626 | /* stop_arrow() - what to do when a non-living flying object |
621 | /* stop_arrow() - what to do when a non-living flying object |
627 | * has to stop. Sept 96 - I added in thrown object code in |
622 | * has to stop. Sept 96 - I added in thrown object code in |
… | |
… | |
816 | return; |
811 | return; |
817 | } |
812 | } |
818 | |
813 | |
819 | /* update object image for new facing */ |
814 | /* update object image for new facing */ |
820 | /* many thrown objects *don't* have more than one face */ |
815 | /* many thrown objects *don't* have more than one face */ |
821 | if (GET_ANIM_ID (op)) |
816 | if (op->has_anim ()) |
822 | SET_ANIMATION (op, op->direction); |
817 | op->set_anim_frame (op->direction); |
823 | } /* object is reflected */ |
818 | } /* object is reflected */ |
824 | } /* object ran into a wall */ |
819 | } /* object ran into a wall */ |
825 | |
820 | |
826 | /* decrease the speed as it flies. 0.05 means a standard bow will shoot |
821 | /* decrease the speed as it flies. 0.05 means a standard bow will shoot |
827 | * about 17 squares. Tune as needed. |
822 | * about 17 squares. Tune as needed. |
… | |
… | |
856 | |
851 | |
857 | op->remove (); |
852 | op->remove (); |
858 | for (i = 0; i < op->stats.food; i++) |
853 | for (i = 0; i < op->stats.food; i++) |
859 | { |
854 | { |
860 | object *tmp = arch_to_object (op->other_arch); |
855 | object *tmp = arch_to_object (op->other_arch); |
861 | |
|
|
862 | if (op->type == LAMP) |
|
|
863 | tmp->stats.food = op->stats.food - 1; |
|
|
864 | |
856 | |
865 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
857 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
866 | |
858 | |
867 | if (env) |
859 | if (env) |
868 | env->insert (tmp); |
860 | env->insert (tmp); |
… | |
… | |
1238 | { |
1230 | { |
1239 | /* remove an old force with a slaying field == op->name */ |
1231 | /* remove an old force with a slaying field == op->name */ |
1240 | if (object *force = tmp->force_find (op->name)) |
1232 | if (object *force = tmp->force_find (op->name)) |
1241 | force->destroy (); |
1233 | force->destroy (); |
1242 | |
1234 | |
1243 | if (!tmp->force_find (op->slaying)) |
1235 | if (op->slaying && !tmp->force_find (op->slaying)) |
1244 | { |
1236 | { |
1245 | tmp->force_add (op->slaying, op->stats.food); |
1237 | tmp->force_add (op->slaying, op->stats.food); |
1246 | |
1238 | |
1247 | if (op->msg) |
1239 | if (op->msg) |
1248 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, tmp, op->msg); |
1240 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, tmp, op->msg); |
… | |
… | |
1260 | } |
1252 | } |
1261 | } |
1253 | } |
1262 | } |
1254 | } |
1263 | } |
1255 | } |
1264 | |
1256 | |
|
|
1257 | // mapscript objects activate themselves (only) then their timer fires |
|
|
1258 | // TODO: maybe they should simply trigger the link like any other object? |
|
|
1259 | void |
|
|
1260 | move_mapscript (object *op) |
|
|
1261 | { |
|
|
1262 | op->set_speed (0); |
|
|
1263 | cfperl_mapscript_activate (op, true, op, 0); |
|
|
1264 | } |
|
|
1265 | |
|
|
1266 | void move_lamp (object *op) |
|
|
1267 | { |
|
|
1268 | // if the lamp/torch is off, we should disable it. |
|
|
1269 | if (!op->glow_radius) |
|
|
1270 | { |
|
|
1271 | op->set_speed (0); |
|
|
1272 | return; |
|
|
1273 | } |
|
|
1274 | else |
|
|
1275 | { |
|
|
1276 | // check whether the face might need to be updated |
|
|
1277 | // (currently this is needed to have already switched on torches |
|
|
1278 | // on maps, as they just set the glow_radius in the archetype) |
|
|
1279 | if (op->other_arch |
|
|
1280 | && ( |
|
|
1281 | (op->flag [FLAG_ANIMATE] != op->other_arch->flag [FLAG_ANIMATE]) |
|
|
1282 | || (op->flag [FLAG_ANIMATE] |
|
|
1283 | ? (op->animation_id != op->other_arch->animation_id) |
|
|
1284 | : (op->face != op->other_arch->face)) |
|
|
1285 | )) |
|
|
1286 | get_animation_from_arch (op, op->other_arch); |
|
|
1287 | } |
|
|
1288 | |
|
|
1289 | // lamps and torches on maps don't use up their fuel |
|
|
1290 | if (op->is_on_map ()) |
|
|
1291 | return; |
|
|
1292 | |
|
|
1293 | if (op->stats.food > 0) |
|
|
1294 | { |
|
|
1295 | op->stats.food--; |
|
|
1296 | return; |
|
|
1297 | } |
|
|
1298 | |
|
|
1299 | apply_lamp (op, false); |
|
|
1300 | } |
|
|
1301 | |
1265 | void |
1302 | void |
1266 | process_object (object *op) |
1303 | process_object (object *op) |
1267 | { |
1304 | { |
1268 | if (expect_false (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE))) |
1305 | if (expect_false (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE))) |
1269 | return; |
1306 | return; |
… | |
… | |
1441 | |
1478 | |
1442 | case PLAYER: |
1479 | case PLAYER: |
1443 | // players have their own speed-management, so undo the --speed_left |
1480 | // players have their own speed-management, so undo the --speed_left |
1444 | ++op->speed_left; |
1481 | ++op->speed_left; |
1445 | break; |
1482 | break; |
1446 | } |
|
|
1447 | } |
|
|
1448 | |
1483 | |
|
|
1484 | case MAPSCRIPT: |
|
|
1485 | move_mapscript (op); |
|
|
1486 | break; |
|
|
1487 | |
|
|
1488 | case LAMP: |
|
|
1489 | case TORCH: |
|
|
1490 | move_lamp (op); |
|
|
1491 | break; |
|
|
1492 | } |
|
|
1493 | } |
|
|
1494 | |