1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
3 | |
3 | |
|
|
4 | Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | |
7 | This program is free software; you can redistribute it and/or modify |
8 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | it under the terms of the GNU General Public License as published by |
… | |
… | |
411 | update_object (op, UP_OBJ_FACE); |
412 | update_object (op, UP_OBJ_FACE); |
412 | |
413 | |
413 | /* Only search the active objects - only these should actually do |
414 | /* Only search the active objects - only these should actually do |
414 | * harm to the player. |
415 | * harm to the player. |
415 | */ |
416 | */ |
416 | for (tmp = active_objects; tmp != NULL; tmp = tmp->active_next) |
417 | for_all_actives (tmp) |
417 | if (tmp->enemy == op) |
418 | if (tmp->enemy == op) |
418 | tmp->enemy = NULL; |
419 | tmp->enemy = 0; |
|
|
420 | |
419 | return 1; |
421 | return 1; |
420 | } |
422 | } |
421 | |
423 | |
422 | /* earth to dust spell. Basically destroys earthwalls in the area. |
424 | /* earth to dust spell. Basically destroys earthwalls in the area. |
423 | */ |
425 | */ |
… | |
… | |
451 | next = tmp->above; |
453 | next = tmp->above; |
452 | if (QUERY_FLAG (tmp, FLAG_TEAR_DOWN)) |
454 | if (QUERY_FLAG (tmp, FLAG_TEAR_DOWN)) |
453 | hit_player (tmp, 9998, op, AT_PHYSICAL, 0); |
455 | hit_player (tmp, 9998, op, AT_PHYSICAL, 0); |
454 | } |
456 | } |
455 | } |
457 | } |
|
|
458 | |
456 | return 1; |
459 | return 1; |
457 | } |
460 | } |
458 | |
|
|
459 | |
461 | |
460 | void |
462 | void |
461 | execute_word_of_recall (object *op) |
463 | execute_word_of_recall (object *op) |
462 | { |
464 | { |
463 | object *wor = op; |
465 | if (object *pl = op->in_player ()) |
464 | |
466 | { |
465 | while (op != NULL && op->type != PLAYER) |
467 | if (pl->ms ().flags () & P_NO_CLERIC && !QUERY_FLAG (pl, FLAG_WIZCAST)) |
466 | op = op->env; |
|
|
467 | |
|
|
468 | if (op != NULL && op->map) |
|
|
469 | if ((get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) && (!QUERY_FLAG (op, FLAG_WIZCAST))) |
|
|
470 | new_draw_info (NDI_UNIQUE, 0, op, "You feel something fizzle inside you."); |
468 | new_draw_info (NDI_UNIQUE, 0, pl, "You feel something fizzle inside you."); |
471 | else |
469 | else |
|
|
470 | { |
|
|
471 | // remove first so we do not call update_stats |
|
|
472 | op->remove (); |
472 | op->enter_exit (wor); |
473 | pl->enter_exit (op); |
|
|
474 | } |
|
|
475 | } |
473 | |
476 | |
474 | wor->destroy (); |
477 | op->destroy (); |
475 | } |
478 | } |
476 | |
479 | |
477 | /* Word of recall causes the player to return 'home'. |
480 | /* Word of recall causes the player to return 'home'. |
478 | * we put a force into the player object, so that there is a |
481 | * we put a force into the player object, so that there is a |
479 | * time delay effect. |
482 | * time delay effect. |
… | |
… | |
498 | { |
501 | { |
499 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
502 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
500 | LOG (llevError, "cast_word_of_recall: get_archetype(force) failed!\n"); |
503 | LOG (llevError, "cast_word_of_recall: get_archetype(force) failed!\n"); |
501 | return 0; |
504 | return 0; |
502 | } |
505 | } |
|
|
506 | |
503 | time = spell_ob->duration - SP_level_duration_adjust (caster, spell_ob); |
507 | time = spell_ob->duration - SP_level_duration_adjust (caster, spell_ob); |
504 | if (time < 1) |
508 | if (time < 1) |
505 | time = 1; |
509 | time = 1; |
506 | |
510 | |
507 | /* value of speed really doesn't make much difference, as long as it is |
511 | /* value of speed really doesn't make much difference, as long as it is |
… | |
… | |
515 | |
519 | |
516 | /* If we could take advantage of enter_player_savebed() here, it would be |
520 | /* If we could take advantage of enter_player_savebed() here, it would be |
517 | * nice, but until the map load fails, we can't. |
521 | * nice, but until the map load fails, we can't. |
518 | */ |
522 | */ |
519 | EXIT_PATH (dummy) = op->contr->savebed_map; |
523 | EXIT_PATH (dummy) = op->contr->savebed_map; |
520 | EXIT_X (dummy) = op->contr->bed_x; |
524 | EXIT_X (dummy) = op->contr->bed_x; |
521 | EXIT_Y (dummy) = op->contr->bed_y; |
525 | EXIT_Y (dummy) = op->contr->bed_y; |
522 | |
526 | |
523 | (void) insert_ob_in_ob (dummy, op); |
527 | op->insert (dummy); |
|
|
528 | |
524 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you."); |
529 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you."); |
|
|
530 | |
525 | return 1; |
531 | return 1; |
526 | } |
532 | } |
527 | |
533 | |
528 | /* cast_wonder |
534 | /* cast_wonder |
529 | * wonder is really just a spell that will likely cast another |
535 | * wonder is really just a spell that will likely cast another |
… | |
… | |
636 | * Code by Tchize (david.delbecq@usa.net) |
642 | * Code by Tchize (david.delbecq@usa.net) |
637 | */ |
643 | */ |
638 | int |
644 | int |
639 | cast_create_town_portal (object *op, object *caster, object *spell, int dir) |
645 | cast_create_town_portal (object *op, object *caster, object *spell, int dir) |
640 | { |
646 | { |
641 | object *dummy, *force, *old_force, *tmp; |
647 | object *dummy, *force, *old_force; |
642 | archetype *perm_portal; |
648 | archetype *perm_portal; |
643 | char portal_name[1024], portal_message[1024]; |
649 | char portal_name[1024], portal_message[1024]; |
644 | maptile *exitmap; |
650 | maptile *exitmap; |
645 | int op_level; |
651 | int op_level; |
646 | |
652 | |
… | |
… | |
718 | * If it has the good name, we destruct it. |
724 | * If it has the good name, we destruct it. |
719 | * -We destruct the force indicating that portal. |
725 | * -We destruct the force indicating that portal. |
720 | */ |
726 | */ |
721 | while ((old_force = check_inv_recursive (op, dummy))) |
727 | while ((old_force = check_inv_recursive (op, dummy))) |
722 | { |
728 | { |
723 | exitmap = maptile::find_map (old_force->race, op->map); |
729 | exitmap = maptile::find_sync (old_force->race, op->map); |
724 | |
730 | |
725 | if (exitmap) |
731 | if (exitmap) |
726 | { |
732 | { |
|
|
733 | exitmap->load_sync (); |
|
|
734 | |
727 | int exitx = EXIT_X (old_force); |
735 | int exitx = EXIT_X (old_force); |
728 | int exity = EXIT_Y (old_force); |
736 | int exity = EXIT_Y (old_force); |
729 | |
737 | |
730 | tmp = present_arch (perm_portal, exitmap, exitx, exity); |
738 | for (object *tmp = present_arch (perm_portal, exitmap, exitx, exity); tmp; tmp = tmp->above) |
731 | while (tmp) |
|
|
732 | { |
739 | { |
733 | if (tmp->name == old_force->name) |
740 | if (tmp->name == old_force->name) |
734 | { |
741 | { |
735 | tmp->destroy (); |
742 | tmp->destroy (); |
736 | break; |
743 | break; |
737 | } |
744 | } |
738 | |
|
|
739 | tmp = tmp->above; |
|
|
740 | } |
745 | } |
741 | } |
746 | } |
742 | |
747 | |
743 | old_force->destroy (); |
748 | old_force->destroy (); |
744 | } |
749 | } |
… | |
… | |
754 | * 'force' is the destination of the town portal, which we got |
759 | * 'force' is the destination of the town portal, which we got |
755 | * from the players inventory above. |
760 | * from the players inventory above. |
756 | */ |
761 | */ |
757 | |
762 | |
758 | /* Ensure exit map is loaded */ |
763 | /* Ensure exit map is loaded */ |
759 | exitmap = maptile::find_map (force->name, 0); |
764 | exitmap = maptile::find_sync (force->name); |
760 | |
765 | |
761 | /* If we were unable to load (ex. random map deleted), warn player */ |
766 | /* If we were unable to load (ex. random map deleted), warn player */ |
762 | if (!exitmap) |
767 | if (!exitmap) |
763 | { |
768 | { |
764 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?"); |
769 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?"); |
765 | force->destroy (); |
770 | force->destroy (); |
766 | return 1; |
771 | return 1; |
767 | } |
772 | } |
|
|
773 | |
|
|
774 | exitmap->load_sync (); |
768 | |
775 | |
769 | op_level = caster_level (caster, spell); |
776 | op_level = caster_level (caster, spell); |
770 | if (op_level < 15) |
777 | if (op_level < 15) |
771 | snprintf (portal_message, 1024, |
778 | snprintf (portal_message, 1024, |
772 | "\nThe air moves around you and\na huge smell of ammonia\nsurounds you as you pass\nthrough %s's tiny portal\nPouah!\n", |
779 | "\nThe air moves around you and\na huge smell of ammonia\nsurounds you as you pass\nthrough %s's tiny portal\nPouah!\n", |
… | |
… | |
803 | |
810 | |
804 | /* Now we need to to create a town portal marker inside the player |
811 | /* Now we need to to create a town portal marker inside the player |
805 | * object, so on future castings, we can know that he has an active |
812 | * object, so on future castings, we can know that he has an active |
806 | * town portal. |
813 | * town portal. |
807 | */ |
814 | */ |
808 | tmp = get_archetype (spell->race); |
815 | object *tmp = get_archetype (spell->race); |
809 | if (tmp == NULL) |
816 | |
|
|
817 | if (!tmp) |
810 | { |
818 | { |
811 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
819 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
812 | LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name); |
820 | LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name); |
813 | return 0; |
821 | return 0; |
814 | } |
822 | } |