ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/spell_attack.C
(Generate patch)

Comparing deliantra/server/server/spell_attack.C (file contents):
Revision 1.75 by root, Sun Dec 28 08:08:25 2008 UTC vs.
Revision 1.87 by root, Mon Oct 12 04:02:17 2009 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002-2003,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002-2003,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
9 * 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
545 * fired arches (eg, bolts). 545 * fired arches (eg, bolts).
546 */ 546 */
547void 547void
548move_bullet (object *op) 548move_bullet (object *op)
549{ 549{
550 sint16 new_x, new_y;
551 int mflags;
552 maptile *m;
553
554#if 0 550#if 0
555 /* We need a better general purpose way to do this */ 551 /* We need a better general purpose way to do this */
556 552
557 /* peterm: added to make comet leave a trail of burnouts 553 /* peterm: added to make comet leave a trail of burnouts
558 it's an unadulterated hack, but the effect is cool. */ 554 it's an unadulterated hack, but the effect is cool. */
573 op->destroy (); 569 op->destroy ();
574 570
575 return; 571 return;
576 } 572 }
577 573
578 new_x = op->x + DIRX (op); 574 mapxy pos (op);
579 new_y = op->y + DIRY (op); 575 pos.move (op->direction);
580 m = op->map;
581 mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y);
582 576
583 if (mflags & P_OUT_OF_MAP) 577 if (!pos.normalise ())
584 { 578 {
585 op->destroy (); 579 op->destroy ();
586 return; 580 return;
587 } 581 }
588 582
589 if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) 583 mapspace &ms = pos.ms ();
584
585 ms.update ();
586
587 if (!op->direction || OB_TYPE_MOVE_BLOCK (op, ms.move_block))
590 { 588 {
591 if (op->other_arch) 589 if (op->other_arch)
592 explode_bullet (op); 590 explode_bullet (op);
593 else 591 else
594 op->destroy (); 592 op->destroy ();
595 593
596 return; 594 return;
597 } 595 }
598 596
599 if (!(op = m->insert (op, new_x, new_y, op))) 597 if (!(op = pos.insert (op, op)))
600 return; 598 return;
601 599
602 if (reflwall (op->map, op->x, op->y, op)) 600 if (reflwall (op->map, op->x, op->y, op))
603 { 601 {
604 op->direction = absdir (op->direction + 4); 602 op->direction = absdir (op->direction + 4);
828 */ 826 */
829 movetype = spell->other_arch->move_type; 827 movetype = spell->other_arch->move_type;
830 828
831 for (i = range_min; i <= range_max; i++) 829 for (i = range_min; i <= range_max; i++)
832 { 830 {
833 sint16 x, y, d; 831 sint16 x, y;
834 832
835 /* We can't use absdir here, because it never returns 833 /* We can't use absdir here, because it never returns
836 * 0. If this is a rune, we want to hit the person on top 834 * 0. If this is a rune, we want to hit the person on top
837 * of the trap (d==0). If it is not a rune, then we don't want 835 * of the trap (d==0). If it is not a rune, then we don't want
838 * to hit that person. 836 * to hit that person.
839 */ 837 */
840 d = dir + i; 838 int d = dir ? absdir (dir + i) : i;
841 while (d < 0)
842 d += 8;
843 while (d > 8)
844 d -= 8;
845 839
846 /* If it's not a rune, we don't want to blast the caster. 840 /* If it's not a rune, we don't want to blast the caster.
847 * In that case, we have to see - if dir is specified, 841 * In that case, we have to see - if dir is specified,
848 * turn this into direction 8. If dir is not specified (all 842 * turn this into direction 8. If dir is not specified (all
849 * direction) skip - otherwise, one line would do more damage 843 * direction) skip - otherwise, one line would do more damage
951 945
952 object *env = op->outer_env (); 946 object *env = op->outer_env ();
953 947
954 if (op->env) 948 if (op->env)
955 { 949 {
956 if (env->map == NULL) 950 if (!env->map)
957 return; 951 return;
958 952
959 if (!(op = op->insert_at (env, op))) 953 if (!(op = op->insert_at (env, op)))
960 return; 954 return;
961 } 955 }
962 956
963 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding 957 // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding
964 // on a safe map. I don't like this special casing, but it seems to be neccessary 958 // on a safe map. I don't like this special casing, but it seems to be neccessary
965 // as bombs can be carried. 959 // as bombs can be carried.
966 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 960 if (op->ms ().flags () & P_SAFE)
967 { 961 {
968 op->destroy (); 962 op->destroy ();
969 return; 963 return;
970 } 964 }
971 965
1115 * interesting spell. 1109 * interesting spell.
1116 * if it is a cleric spell, you need a god, and the creature 1110 * if it is a cleric spell, you need a god, and the creature
1117 * can't be friendly to your god. 1111 * can't be friendly to your god.
1118 */ 1112 */
1119 1113
1120 if (!target || QUERY_FLAG (target, FLAG_REFL_SPELL) 1114 if (!target
1115 || target->flag [FLAG_REFL_SPELL]
1121 || (!god && spell->stats.grace) 1116 || (!god && spell->stats.grace)
1122 || (target->title && god && !strcmp (target->title, god->name)) || (target->race && god && strstr (target->race, god->race))) 1117 || (god && target->title == god->name)
1118 || (god && target->race.contains (god->race)))
1123 { 1119 {
1124 new_draw_info (NDI_UNIQUE, 0, op, "Your request is unheeded."); 1120 new_draw_info (NDI_UNIQUE, 0, op, "Your request is unheeded.");
1125 return 0; 1121 return 0;
1126 } 1122 }
1127 1123
1134 effect->level = casting_level (caster, spell); 1130 effect->level = casting_level (caster, spell);
1135 effect->attacktype = spell->attacktype; 1131 effect->attacktype = spell->attacktype;
1136 if (effect->attacktype & (AT_HOLYWORD | AT_GODPOWER)) 1132 if (effect->attacktype & (AT_HOLYWORD | AT_GODPOWER))
1137 { 1133 {
1138 if (tailor_god_spell (effect, op)) 1134 if (tailor_god_spell (effect, op))
1139 new_draw_info_format (NDI_UNIQUE, 0, op, "%s answers your call!", determine_god (op)); 1135 new_draw_info_format (NDI_UNIQUE, 0, op, "%s answers your call!", (const char *)determine_god (op));
1140 else 1136 else
1141 { 1137 {
1142 new_draw_info (NDI_UNIQUE, 0, op, "Your request is ignored."); 1138 new_draw_info (NDI_UNIQUE, 0, op, "Your request is ignored.");
1143 return 0; 1139 return 0;
1144 } 1140 }
1258 1254
1259 object *tmp = get_archetype (FORCE_NAME); 1255 object *tmp = get_archetype (FORCE_NAME);
1260 tmp->speed = 0.01; 1256 tmp->speed = 0.01;
1261 tmp->stats.food = time; 1257 tmp->stats.food = time;
1262 SET_FLAG (tmp, FLAG_IS_USED_UP); 1258 SET_FLAG (tmp, FLAG_IS_USED_UP);
1263 tmp->glow_radius = min (MAX_LIGHT_RADIUS, radius); 1259 tmp->set_glow_radius (min (MAX_LIGHT_RADIUS, radius));
1264 tmp = insert_ob_in_ob (tmp, op); 1260 tmp = insert_ob_in_ob (tmp, op);
1265 1261
1266 if (tmp->glow_radius > op->glow_radius) 1262 if (tmp->glow_radius > op->glow_radius)
1267 op->glow_radius = tmp->glow_radius; 1263 op->set_glow_radius (tmp->glow_radius);
1268 1264
1269 return 1; 1265 return 1;
1270} 1266}
1271 1267
1272int 1268int
1449 * so even if the player doesn't worship a god, if race=GOD_.., it 1445 * so even if the player doesn't worship a god, if race=GOD_.., it
1450 * won't ever match anything. 1446 * won't ever match anything.
1451 */ 1447 */
1452 if (!spell->race) 1448 if (!spell->race)
1453 race = NULL; 1449 race = NULL;
1454 else if (god && !strcmp (spell->race, "GOD_SLAYING")) 1450 else if (god && spell->race == shstr_GOD_SLAYING)
1455 race = god->slaying; 1451 race = god->slaying;
1456 else if (god && !strcmp (spell->race, "GOD_FRIEND")) 1452 else if (god && spell->race == shstr_GOD_FRIEND)
1457 race = god->race; 1453 race = god->race;
1458 else 1454 else
1459 race = spell->race; 1455 race = spell->race;
1460 1456
1461 unordered_mapwalk (op, -range, -range, range, range) 1457 unordered_mapwalk (op, -range, -range, range, range)
1909 } 1905 }
1910 1906
1911 tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); 1907 tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell);
1912 1908
1913 if (tmp->glow_radius) 1909 if (tmp->glow_radius)
1914 tmp->glow_radius = min (MAX_LIGHT_RADIUS, spell->range + SP_level_range_adjust (caster, spell)); 1910 tmp->set_glow_radius (
1911 clamp (spell->range + SP_level_range_adjust (caster, spell), 1, MAX_LIGHT_RADIUS)
1912 );
1915 1913
1916 if (dir) 1914 if (dir)
1917 m->insert (tmp, x, y, op); 1915 m->insert (tmp, x, y, op);
1918 else 1916 else
1919 caster->outer_env ()->insert (tmp); 1917 caster->outer_env_or_self ()->insert (tmp);
1920 1918
1921 return 1; 1919 return 1;
1922} 1920}
1923 1921
1924/* cast_cause_disease: this spell looks along <dir> from the 1922/* cast_cause_disease: this spell looks along <dir> from the

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines