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

Comparing deliantra/server/server/spell_util.C (file contents):
Revision 1.70 by root, Sun May 4 18:24:11 2008 UTC vs.
Revision 1.74 by root, Sat May 17 15:03:04 2008 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 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
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
261 */ 261 */
262object * 262object *
263check_spell_known (object *op, const char *name) 263check_spell_known (object *op, const char *name)
264{ 264{
265 object *spop; 265 object *spop;
266 shstr_cmp name_ (name);
266 267
267 for (spop = op->inv; spop; spop = spop->below) 268 for (spop = op->inv; spop; spop = spop->below)
268 if (spop->type == SPELL && !strcmp (spop->name, name)) 269 if (spop->type == SPELL && spop->name == name)
269 return spop; 270 return spop;
270 271
271 return NULL; 272 return 0;
272} 273}
273 274
274 275
275/* 276/*
276 * Look at object 'op' and see if they know the spell 277 * Look at object 'op' and see if they know the spell
472 * returns 0 on failure, 1 on success. 473 * returns 0 on failure, 1 on success.
473 */ 474 */
474int 475int
475fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, int dir, object *spell) 476fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, int dir, object *spell)
476{ 477{
477 object *tmp;
478 int mflags;
479 maptile *m;
480
481 if (spell->other_arch == NULL) 478 if (!spell->other_arch)
482 return 0; 479 return 0;
483 480
484 m = op->map; 481 object *tmp = spell->other_arch->instance ();
485 mflags = get_map_flags (m, &m, x, y, &x, &y);
486 if (mflags & P_OUT_OF_MAP)
487 {
488 return 0;
489 }
490 482
491 tmp = arch_to_object (spell->other_arch); 483 if (!tmp)
492
493 if (tmp == NULL)
494 return 0; 484 return 0;
495
496 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y)))
497 {
498 new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n");
499 tmp->destroy ();
500 return 0;
501 }
502 485
503 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 486 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
504 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); 487 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell);
505 /* code in time.c uses food for some things, duration for others */ 488 /* code in time.c uses food for some things, duration for others */
506 tmp->stats.food = tmp->duration; 489 tmp->stats.food = tmp->duration;
507 tmp->range = spell->range + SP_level_range_adjust (caster, spell); 490 tmp->range = spell->range + SP_level_range_adjust (caster, spell);
508 tmp->attacktype = spell->attacktype; 491 tmp->attacktype = spell->attacktype;
509 tmp->x = x;
510 tmp->y = y;
511 tmp->direction = dir; 492 tmp->direction = dir;
512 if (op->owner != NULL)
513 tmp->set_owner (op); 493 tmp->set_owner (op);
514 else
515 tmp->set_owner (op);
516 tmp->level = caster_level (caster, spell); 494 tmp->level = caster_level (caster, spell);
517 set_spell_skill (op, caster, spell, tmp); 495 set_spell_skill (op, caster, spell, tmp);
518 496
519 /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ 497 /* needed for AT_HOLYWORD,AT_GODPOWER stuff */
520 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) 498 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER)
521 {
522 if (!tailor_god_spell (tmp, op)) 499 if (!tailor_god_spell (tmp, op))
523 return 0; 500 return 0;
524 } 501
525 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 502 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
526 SET_ANIMATION (tmp, dir); 503 SET_ANIMATION (tmp, dir);
527 504
528 if ((tmp = insert_ob_in_map (tmp, m, op, 0))) 505 if ((tmp = op->map->insert (tmp, x, y, op)))
529 move_spell_effect (tmp); 506 move_spell_effect (tmp);
530 507
531 return 1; 508 return 1;
532} 509}
533 510
588 if (!tmp) 565 if (!tmp)
589 tmp = op->ms ().player (); 566 tmp = op->ms ().player ();
590 567
591 return tmp; 568 return tmp;
592} 569}
593
594
595 570
596/* raytrace: 571/* raytrace:
597 * spell_find_dir(map, x, y, exclude) will search first the center square 572 * spell_find_dir(map, x, y, exclude) will search first the center square
598 * then some close squares in the given map at the given coordinates for 573 * then some close squares in the given map at the given coordinates for
599 * live objects. 574 * live objects.
602 * monsters/generators only. If not, the spell will hunt players only. 577 * monsters/generators only. If not, the spell will hunt players only.
603 * It returns the direction toward the first/closest live object if it finds 578 * It returns the direction toward the first/closest live object if it finds
604 * any, otherwise -1. 579 * any, otherwise -1.
605 * note that exclude can be NULL, in which case all bets are off. 580 * note that exclude can be NULL, in which case all bets are off.
606 */ 581 */
607
608int 582int
609spell_find_dir (maptile *m, int x, int y, object *exclude) 583spell_find_dir (maptile *m, int x, int y, object *exclude)
610{ 584{
611 int i, max = SIZEOFFREE; 585 int i, max = SIZEOFFREE;
612 sint16 nx, ny; 586 sint16 nx, ny;
1203 case SP_SMITE: 1177 case SP_SMITE:
1204 success = cast_smite_spell (op, caster, dir, spell_ob); 1178 success = cast_smite_spell (op, caster, dir, spell_ob);
1205 break; 1179 break;
1206 1180
1207 case SP_MAGIC_MISSILE: 1181 case SP_MAGIC_MISSILE:
1208 success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); 1182 success = fire_arch_from_position (op, caster, op->x, op->y, dir, spell_ob);
1209 break; 1183 break;
1210 1184
1211 case SP_SUMMON_GOLEM: 1185 case SP_SUMMON_GOLEM:
1212 success = summon_golem (op, caster, dir, spell_ob); 1186 success = summon_golem (op, caster, dir, spell_ob);
1213 break; 1187 break;
1324 { 1298 {
1325 op->failmsg (format ("You lack the proper attunement to cast %s!", &spell_ob->name)); 1299 op->failmsg (format ("You lack the proper attunement to cast %s!", &spell_ob->name));
1326 success = 0; 1300 success = 0;
1327 } 1301 }
1328 else 1302 else
1329 success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); 1303 success = fire_arch_from_position (op, caster, op->x, op->y, dir, spell_ob);
1330 break; 1304 break;
1331 1305
1332 case SP_SWARM: 1306 case SP_SWARM:
1333 success = fire_swarm (op, caster, spell_ob, dir); 1307 success = fire_swarm (op, caster, spell_ob, dir);
1334 break; 1308 break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines