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.88 by root, Mon Oct 12 14:00:59 2009 UTC vs.
Revision 1.93 by root, Sun Nov 29 17:41:08 2009 UTC

37/* this function checks to see if a spell pushes objects as well 37/* this function checks to see if a spell pushes objects as well
38 * as flies over and damages them (only used for cones for now) 38 * as flies over and damages them (only used for cones for now)
39 * but moved here so it could be applied to bolts too 39 * but moved here so it could be applied to bolts too
40 * op is the spell object. 40 * op is the spell object.
41 */ 41 */
42void 42static void
43check_spell_knockback (object *op) 43check_spell_knockback (object *op)
44{ 44{
45 int weight_move; 45 int weight_move;
46 int frictionmod = 2; /*poor man's physics - multipy targets weight by this amount */ 46 int frictionmod = 2; /*poor man's physics - multipy targets weight by this amount */
47 47
108 ***************************************************************************/ 108 ***************************************************************************/
109 109
110/* Causes op to fork. op is the original bolt, tmp 110/* Causes op to fork. op is the original bolt, tmp
111 * is the first piece of the fork. 111 * is the first piece of the fork.
112 */ 112 */
113void 113static void
114forklightning (object *op, object *tmp) 114forklightning (object *op, object *tmp)
115{ 115{
116 int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */ 116 int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */
117 int t_dir; /* stores temporary dir calculation */ 117 int t_dir; /* stores temporary dir calculation */
118 maptile *m; 118 maptile *m;
277 int mflags; 277 int mflags;
278 278
279 if (!spob->other_arch) 279 if (!spob->other_arch)
280 return 0; 280 return 0;
281 281
282 tmp = arch_to_object (spob->other_arch); 282 tmp = spob->other_arch->instance ();
283 if (tmp == NULL) 283 if (tmp == NULL)
284 return 0; 284 return 0;
285 285
286 /* peterm: level dependency for bolts */ 286 /* peterm: level dependency for bolts */
287 tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob); 287 tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob);
389 389
390/* Causes an object to explode, eg, a firebullet, 390/* Causes an object to explode, eg, a firebullet,
391 * poison cloud ball, etc. op is the object to 391 * poison cloud ball, etc. op is the object to
392 * explode. 392 * explode.
393 */ 393 */
394void 394static void
395explode_bullet (object *op) 395explode_bullet (object *op)
396{ 396{
397 object *tmp, *owner; 397 object *tmp, *owner;
398 398
399 if (!op->other_arch) 399 if (!op->other_arch)
439 if (op->destroyed ()) 439 if (op->destroyed ())
440 return; 440 return;
441 } 441 }
442 442
443 /* other_arch contains what this explodes into */ 443 /* other_arch contains what this explodes into */
444 tmp = arch_to_object (op->other_arch); 444 tmp = op->other_arch->instance ();
445 445
446 tmp->set_owner (op); 446 tmp->set_owner (op);
447 tmp->skill = op->skill; 447 tmp->skill = op->skill;
448 448
449 owner = op->owner; 449 owner = op->owner;
687 * CONE RELATED FUNCTIONS 687 * CONE RELATED FUNCTIONS
688 * 688 *
689 *****************************************************************************/ 689 *****************************************************************************/
690 690
691/* drops an object based on what is in the cone's "other_arch" */ 691/* drops an object based on what is in the cone's "other_arch" */
692void 692static void
693cone_drop (object *op) 693cone_drop (object *op)
694{ 694{
695 object *new_ob = arch_to_object (op->other_arch); 695 object *new_ob = op->other_arch->instance ();
696 696
697 new_ob->level = op->level; 697 new_ob->level = op->level;
698 new_ob->set_owner (op->owner); 698 new_ob->set_owner (op->owner);
699 699
700 /* preserve skill ownership */ 700 /* preserve skill ownership */
861 861
862 if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype) 862 if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype)
863 continue; 863 continue;
864 864
865 success = 1; 865 success = 1;
866 tmp = arch_to_object (spell->other_arch); 866 tmp = spell->other_arch->instance ();
867 tmp->set_owner (op); 867 tmp->set_owner (op);
868 set_spell_skill (op, caster, spell, tmp); 868 set_spell_skill (op, caster, spell, tmp);
869 tmp->level = casting_level (caster, spell); 869 tmp->level = casting_level (caster, spell);
870 tmp->attacktype = spell->attacktype; 870 tmp->attacktype = spell->attacktype;
871 871
973 for (int i = 1; i < 9; i++) 973 for (int i = 1; i < 9; i++)
974 { 974 {
975 if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) 975 if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i]))
976 continue; 976 continue;
977 977
978 object *tmp = arch_to_object (at); 978 object *tmp = at->instance ();
979 tmp->direction = i; 979 tmp->direction = i;
980 tmp->range = op->range; 980 tmp->range = op->range;
981 tmp->stats.dam = op->stats.dam; 981 tmp->stats.dam = op->stats.dam;
982 tmp->duration = op->duration; 982 tmp->duration = op->duration;
983 tmp->attacktype = op->attacktype; 983 tmp->attacktype = op->attacktype;
1017 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); 1017 new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
1018 return 0; 1018 return 0;
1019 } 1019 }
1020 } 1020 }
1021 1021
1022 tmp = arch_to_object (spell->other_arch); 1022 tmp = spell->other_arch->instance ();
1023 1023
1024 /* level dependencies for bomb */ 1024 /* level dependencies for bomb */
1025 tmp->range = spell->range + SP_level_range_adjust (caster, spell); 1025 tmp->range = spell->range + SP_level_range_adjust (caster, spell);
1026 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1026 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1027 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); 1027 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell);
1047 * dir is the direction to look in. 1047 * dir is the direction to look in.
1048 * range is how far out to look. 1048 * range is how far out to look.
1049 * type is the type of spell - either SPELL_MANA or SPELL_GRACE. 1049 * type is the type of spell - either SPELL_MANA or SPELL_GRACE.
1050 * this info is used for blocked magic/unholy spaces. 1050 * this info is used for blocked magic/unholy spaces.
1051 */ 1051 */
1052object * 1052static object *
1053get_pointed_target (object *op, int dir, int range, int type) 1053get_pointed_target (object *op, int dir, int range, int type)
1054{ 1054{
1055 object *target; 1055 object *target;
1056 sint16 x, y; 1056 sint16 x, y;
1057 int dist, mflags; 1057 int dist, mflags;
1121 new_draw_info (NDI_UNIQUE, 0, op, "Your request is unheeded."); 1121 new_draw_info (NDI_UNIQUE, 0, op, "Your request is unheeded.");
1122 return 0; 1122 return 0;
1123 } 1123 }
1124 1124
1125 if (spell->other_arch) 1125 if (spell->other_arch)
1126 effect = arch_to_object (spell->other_arch); 1126 effect = spell->other_arch->instance ();
1127 else 1127 else
1128 return 0; 1128 return 0;
1129 1129
1130 /* tailor the effect by priest level and worshipped God */ 1130 /* tailor the effect by priest level and worshipped God */
1131 effect->level = casting_level (caster, spell); 1131 effect->level = casting_level (caster, spell);
1244 * we do this by creating a force and inserting it in the 1244 * we do this by creating a force and inserting it in the
1245 * object. if time is 0, the object glows permanently. To truely 1245 * object. if time is 0, the object glows permanently. To truely
1246 * make this work for non-living objects, we would have to 1246 * make this work for non-living objects, we would have to
1247 * give them the capability to have an inventory. b.t. 1247 * give them the capability to have an inventory. b.t.
1248 */ 1248 */
1249int 1249static int
1250make_object_glow (object *op, int radius, int time) 1250make_object_glow (object *op, int radius, int time)
1251{ 1251{
1252 /* some things are unaffected... */ 1252 /* some things are unaffected... */
1253 if (op->path_denied & PATH_LIGHT) 1253 if (op->path_denied & PATH_LIGHT)
1254 return 0; 1254 return 0;
1305 if (spell_ob->subtype == SP_DESTRUCTION) 1305 if (spell_ob->subtype == SP_DESTRUCTION)
1306 { 1306 {
1307 hit_player (tmp, dam, op, spell_ob->attacktype, 0); 1307 hit_player (tmp, dam, op, spell_ob->attacktype, 0);
1308 1308
1309 if (spell_ob->other_arch) 1309 if (spell_ob->other_arch)
1310 m->insert (arch_to_object (spell_ob->other_arch), nx, ny, op); 1310 m->insert (spell_ob->other_arch->instance (), nx, ny, op);
1311 } 1311 }
1312 else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist [ATNR_MAGIC] != 100) 1312 else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist [ATNR_MAGIC] != 100)
1313 { 1313 {
1314 if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) 1314 if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch)
1315 m->insert (arch_to_object (spell_ob->other_arch), nx, ny, op); 1315 m->insert (spell_ob->other_arch->instance (), nx, ny, op);
1316 } 1316 }
1317 } 1317 }
1318 } 1318 }
1319 } 1319 }
1320 1320
1325/*************************************************************************** 1325/***************************************************************************
1326 * 1326 *
1327 * CURSE 1327 * CURSE
1328 * 1328 *
1329 ***************************************************************************/ 1329 ***************************************************************************/
1330
1331int 1330int
1332cast_curse (object *op, object *caster, object *spell_ob, int dir) 1331cast_curse (object *op, object *caster, object *spell_ob, int dir)
1333{ 1332{
1334 object *god = find_god (determine_god (op)); 1333 object *god = find_god (determine_god (op));
1335 object *tmp, *force; 1334 object *tmp, *force;
1413 force->stats.wc = spell_ob->stats.wc; 1412 force->stats.wc = spell_ob->stats.wc;
1414 1413
1415 change_abil (tmp, force); /* Mostly to display any messages */ 1414 change_abil (tmp, force); /* Mostly to display any messages */
1416 insert_ob_in_ob (force, tmp); 1415 insert_ob_in_ob (force, tmp);
1417 tmp->update_stats (); 1416 tmp->update_stats ();
1417
1418 return 1; 1418 return 1;
1419
1420} 1419}
1421 1420
1422/********************************************************************** 1421/**********************************************************************
1423 * mood change 1422 * mood change
1424 * Arguably, this may or may not be an attack spell. But since it 1423 * Arguably, this may or may not be an attack spell. But since it
1525 Ryo, august 14th 1524 Ryo, august 14th
1526 */ 1525 */
1527 if (head->level > level) 1526 if (head->level > level)
1528 continue; 1527 continue;
1529 1528
1530 if (random_roll (0, 100, caster, PREFER_LOW) >= (20 + MIN (50, 2 * (level - head->level)))) 1529 if (random_roll (0, 100, caster, PREFER_LOW) >= (20 + min (50, 2 * (level - head->level))))
1531 /* Failed, no effect */ 1530 /* Failed, no effect */
1532 continue; 1531 continue;
1533 } 1532 }
1534 1533
1535 /* Done with saving throw. Now start affecting the monster */ 1534 /* Done with saving throw. Now start affecting the monster */
1577 head->stats.exp = 0; 1576 head->stats.exp = 0;
1578 } 1577 }
1579 1578
1580 /* If a monster was effected, put an effect in */ 1579 /* If a monster was effected, put an effect in */
1581 if (done_one && spell->other_arch) 1580 if (done_one && spell->other_arch)
1582 m->insert (arch_to_object (spell->other_arch), nx, ny, op); 1581 m->insert (spell->other_arch->instance (), nx, ny, op);
1583 } 1582 }
1584 1583
1585 return 1; 1584 return 1;
1586} 1585}
1587 1586
1670 hit_map (op, j, op->attacktype, 1); 1669 hit_map (op, j, op->attacktype, 1);
1671 } 1670 }
1672 1671
1673 /* insert the other arch */ 1672 /* insert the other arch */
1674 if (op->other_arch && !(OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy)))) 1673 if (op->other_arch && !(OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy))))
1675 m->insert (arch_to_object (op->other_arch), hx, hy, op); 1674 m->insert (op->other_arch->instance (), hx, hy, op);
1676 } 1675 }
1677 1676
1678 /* restore to the center location and damage */ 1677 /* restore to the center location and damage */
1679 op->stats.dam = dam_save; 1678 op->stats.dam = dam_save;
1680 1679
1896 return 0; 1895 return 0;
1897 } 1896 }
1898 } 1897 }
1899 1898
1900 /* ok, looks groovy to just insert a new light on the map */ 1899 /* ok, looks groovy to just insert a new light on the map */
1901 tmp = arch_to_object (spell->other_arch); 1900 tmp = spell->other_arch->instance ();
1902 if (!tmp) 1901 if (!tmp)
1903 { 1902 {
1904 LOG (llevError, "Error: spell arch for cast_light() missing.\n"); 1903 LOG (llevError, "Error: spell arch for cast_light() missing.\n");
1905 return 0; 1904 return 0;
1906 } 1905 }
1972 { 1971 {
1973 /* search this square for a victim */ 1972 /* search this square for a victim */
1974 for (walk = GET_MAP_OB (m, x, y); walk; walk = walk->above) 1973 for (walk = GET_MAP_OB (m, x, y); walk; walk = walk->above)
1975 if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) 1974 if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER))
1976 { /* found a victim */ 1975 { /* found a victim */
1977 object *disease = arch_to_object (spell->other_arch); 1976 object *disease = spell->other_arch->instance ();
1978 1977
1979 disease->set_owner (op); 1978 disease->set_owner (op);
1980 set_spell_skill (op, caster, spell, disease); 1979 set_spell_skill (op, caster, spell, disease);
1981 disease->stats.exp = 0; 1980 disease->stats.exp = 0;
1982 disease->level = casting_level (caster, spell); 1981 disease->level = casting_level (caster, spell);
2032 if (infect_object (walk, disease, 1)) 2031 if (infect_object (walk, disease, 1))
2033 { 2032 {
2034 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); 2033 new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name);
2035 2034
2036 disease->destroy (); /* don't need this one anymore */ 2035 disease->destroy (); /* don't need this one anymore */
2037 walk->map->insert (get_archetype ("detect_magic"), x, y, op); 2036 walk->map->insert (get_archetype (shstr_detect_magic), x, y, op);
2038 return 1; 2037 return 1;
2039 } 2038 }
2040 2039
2041 disease->destroy (); 2040 disease->destroy ();
2042 } 2041 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines