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.72 by root, Tue May 6 16:55:26 2008 UTC vs.
Revision 1.73 by root, Sat May 17 14:11:13 2008 UTC

473 * returns 0 on failure, 1 on success. 473 * returns 0 on failure, 1 on success.
474 */ 474 */
475int 475int
476fire_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)
477{ 477{
478 object *tmp;
479 int mflags;
480 maptile *m;
481
482 if (spell->other_arch == NULL) 478 if (!spell->other_arch)
483 return 0; 479 return 0;
484 480
485 m = op->map; 481 mapxy pos (op->map, x, y);//TODO, should not pass x, y
486 mflags = get_map_flags (m, &m, x, y, &x, &y);
487 if (mflags & P_OUT_OF_MAP)
488 {
489 return 0;
490 }
491 482
492 tmp = arch_to_object (spell->other_arch); 483 pos.move (dir ? dir : rndm (1, 8));
493 484
494 if (tmp == NULL) 485 if (!pos.normalise ())
495 return 0; 486 return 0;
496 487
497 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y))) 488 object *tmp = spell->other_arch->instance ();
489
490 if (!tmp)
491 return 0;
492
493 if (pos.ms ().blocks (tmp))
498 { 494 {
499 new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n"); 495 new_draw_info (NDI_UNIQUE, 0, op, "You can't cast this spell on top of a wall!\n");
500 tmp->destroy (); 496 tmp->destroy ();
501 return 0; 497 return 0;
502 } 498 }
503 499
504 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 500 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
508 tmp->range = spell->range + SP_level_range_adjust (caster, spell); 504 tmp->range = spell->range + SP_level_range_adjust (caster, spell);
509 tmp->attacktype = spell->attacktype; 505 tmp->attacktype = spell->attacktype;
510 tmp->x = x; 506 tmp->x = x;
511 tmp->y = y; 507 tmp->y = y;
512 tmp->direction = dir; 508 tmp->direction = dir;
513 if (op->owner != NULL)
514 tmp->set_owner (op); 509 tmp->set_owner (op);
515 else
516 tmp->set_owner (op);
517 tmp->level = caster_level (caster, spell); 510 tmp->level = caster_level (caster, spell);
518 set_spell_skill (op, caster, spell, tmp); 511 set_spell_skill (op, caster, spell, tmp);
519 512
520 /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ 513 /* needed for AT_HOLYWORD,AT_GODPOWER stuff */
521 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) 514 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER)
522 {
523 if (!tailor_god_spell (tmp, op)) 515 if (!tailor_god_spell (tmp, op))
524 return 0; 516 return 0;
525 } 517
526 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 518 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
527 SET_ANIMATION (tmp, dir); 519 SET_ANIMATION (tmp, dir);
528 520
529 if ((tmp = insert_ob_in_map (tmp, m, op, 0))) 521 if ((tmp = op->map->insert (tmp, x, y, op)))
530 move_spell_effect (tmp); 522 move_spell_effect (tmp);
531 523
532 return 1; 524 return 1;
533} 525}
534 526
589 if (!tmp) 581 if (!tmp)
590 tmp = op->ms ().player (); 582 tmp = op->ms ().player ();
591 583
592 return tmp; 584 return tmp;
593} 585}
594
595
596 586
597/* raytrace: 587/* raytrace:
598 * spell_find_dir(map, x, y, exclude) will search first the center square 588 * spell_find_dir(map, x, y, exclude) will search first the center square
599 * then some close squares in the given map at the given coordinates for 589 * then some close squares in the given map at the given coordinates for
600 * live objects. 590 * live objects.
603 * monsters/generators only. If not, the spell will hunt players only. 593 * monsters/generators only. If not, the spell will hunt players only.
604 * It returns the direction toward the first/closest live object if it finds 594 * It returns the direction toward the first/closest live object if it finds
605 * any, otherwise -1. 595 * any, otherwise -1.
606 * note that exclude can be NULL, in which case all bets are off. 596 * note that exclude can be NULL, in which case all bets are off.
607 */ 597 */
608
609int 598int
610spell_find_dir (maptile *m, int x, int y, object *exclude) 599spell_find_dir (maptile *m, int x, int y, object *exclude)
611{ 600{
612 int i, max = SIZEOFFREE; 601 int i, max = SIZEOFFREE;
613 sint16 nx, ny; 602 sint16 nx, ny;
1204 case SP_SMITE: 1193 case SP_SMITE:
1205 success = cast_smite_spell (op, caster, dir, spell_ob); 1194 success = cast_smite_spell (op, caster, dir, spell_ob);
1206 break; 1195 break;
1207 1196
1208 case SP_MAGIC_MISSILE: 1197 case SP_MAGIC_MISSILE:
1209 success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); 1198 success = fire_arch_from_position (op, caster, op->x, op->y, dir, spell_ob);
1210 break; 1199 break;
1211 1200
1212 case SP_SUMMON_GOLEM: 1201 case SP_SUMMON_GOLEM:
1213 success = summon_golem (op, caster, dir, spell_ob); 1202 success = summon_golem (op, caster, dir, spell_ob);
1214 break; 1203 break;
1325 { 1314 {
1326 op->failmsg (format ("You lack the proper attunement to cast %s!", &spell_ob->name)); 1315 op->failmsg (format ("You lack the proper attunement to cast %s!", &spell_ob->name));
1327 success = 0; 1316 success = 0;
1328 } 1317 }
1329 else 1318 else
1330 success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); 1319 success = fire_arch_from_position (op, caster, op->x, op->y, dir, spell_ob);
1331 break; 1320 break;
1332 1321
1333 case SP_SWARM: 1322 case SP_SWARM:
1334 success = fire_swarm (op, caster, spell_ob, dir); 1323 success = fire_swarm (op, caster, spell_ob, dir);
1335 break; 1324 break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines