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.71 by root, Mon May 5 15:05:26 2008 UTC vs.
Revision 1.75 by root, Mon Jul 14 00:04:57 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
394{ 394{
395 if (!xy_normalise (m, x, y)) 395 if (!xy_normalise (m, x, y))
396 return 0; 396 return 0;
397 397
398 mapspace &ms = m->at (x, y); 398 mapspace &ms = m->at (x, y);
399 ms.update ();
399 400
400 if (OB_TYPE_MOVE_BLOCK (op, ms.move_block)) 401 if (OB_TYPE_MOVE_BLOCK (op, ms.move_block))
401 return 0; 402 return 0;
402 403
403 for (object *tmp = ms.bot; tmp; tmp = tmp->above) 404 for (object *tmp = ms.bot; tmp; tmp = tmp->above)
473 * returns 0 on failure, 1 on success. 474 * returns 0 on failure, 1 on success.
474 */ 475 */
475int 476int
476fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, int dir, object *spell) 477fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, int dir, object *spell)
477{ 478{
478 object *tmp;
479 int mflags;
480 maptile *m;
481
482 if (spell->other_arch == NULL) 479 if (!spell->other_arch)
483 return 0; 480 return 0;
484 481
485 m = op->map; 482 object *tmp = spell->other_arch->instance ();
486 mflags = get_map_flags (m, &m, x, y, &x, &y);
487 if (mflags & P_OUT_OF_MAP)
488 {
489 return 0;
490 }
491 483
492 tmp = arch_to_object (spell->other_arch); 484 if (!tmp)
493
494 if (tmp == NULL)
495 return 0; 485 return 0;
496
497 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y)))
498 {
499 new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n");
500 tmp->destroy ();
501 return 0;
502 }
503 486
504 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 487 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
505 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); 488 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell);
506 /* code in time.c uses food for some things, duration for others */ 489 /* code in time.c uses food for some things, duration for others */
507 tmp->stats.food = tmp->duration; 490 tmp->stats.food = tmp->duration;
508 tmp->range = spell->range + SP_level_range_adjust (caster, spell); 491 tmp->range = spell->range + SP_level_range_adjust (caster, spell);
509 tmp->attacktype = spell->attacktype; 492 tmp->attacktype = spell->attacktype;
510 tmp->x = x;
511 tmp->y = y;
512 tmp->direction = dir; 493 tmp->direction = dir;
513 if (op->owner != NULL)
514 tmp->set_owner (op); 494 tmp->set_owner (op);
515 else
516 tmp->set_owner (op);
517 tmp->level = caster_level (caster, spell); 495 tmp->level = caster_level (caster, spell);
518 set_spell_skill (op, caster, spell, tmp); 496 set_spell_skill (op, caster, spell, tmp);
519 497
520 /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ 498 /* needed for AT_HOLYWORD,AT_GODPOWER stuff */
521 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) 499 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER)
522 {
523 if (!tailor_god_spell (tmp, op)) 500 if (!tailor_god_spell (tmp, op))
524 return 0; 501 return 0;
525 } 502
526 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 503 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
527 SET_ANIMATION (tmp, dir); 504 SET_ANIMATION (tmp, dir);
528 505
529 if ((tmp = insert_ob_in_map (tmp, m, op, 0))) 506 if ((tmp = op->map->insert (tmp, x, y, op)))
530 move_spell_effect (tmp); 507 move_spell_effect (tmp);
531 508
532 return 1; 509 return 1;
533} 510}
534 511
589 if (!tmp) 566 if (!tmp)
590 tmp = op->ms ().player (); 567 tmp = op->ms ().player ();
591 568
592 return tmp; 569 return tmp;
593} 570}
594
595
596 571
597/* raytrace: 572/* raytrace:
598 * spell_find_dir(map, x, y, exclude) will search first the center square 573 * 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 574 * then some close squares in the given map at the given coordinates for
600 * live objects. 575 * live objects.
603 * monsters/generators only. If not, the spell will hunt players only. 578 * 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 579 * It returns the direction toward the first/closest live object if it finds
605 * any, otherwise -1. 580 * any, otherwise -1.
606 * note that exclude can be NULL, in which case all bets are off. 581 * note that exclude can be NULL, in which case all bets are off.
607 */ 582 */
608
609int 583int
610spell_find_dir (maptile *m, int x, int y, object *exclude) 584spell_find_dir (maptile *m, int x, int y, object *exclude)
611{ 585{
612 int i, max = SIZEOFFREE; 586 int i, max = SIZEOFFREE;
613 sint16 nx, ny; 587 sint16 nx, ny;
1204 case SP_SMITE: 1178 case SP_SMITE:
1205 success = cast_smite_spell (op, caster, dir, spell_ob); 1179 success = cast_smite_spell (op, caster, dir, spell_ob);
1206 break; 1180 break;
1207 1181
1208 case SP_MAGIC_MISSILE: 1182 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); 1183 success = fire_arch_from_position (op, caster, op->x, op->y, dir, spell_ob);
1210 break; 1184 break;
1211 1185
1212 case SP_SUMMON_GOLEM: 1186 case SP_SUMMON_GOLEM:
1213 success = summon_golem (op, caster, dir, spell_ob); 1187 success = summon_golem (op, caster, dir, spell_ob);
1214 break; 1188 break;
1325 { 1299 {
1326 op->failmsg (format ("You lack the proper attunement to cast %s!", &spell_ob->name)); 1300 op->failmsg (format ("You lack the proper attunement to cast %s!", &spell_ob->name));
1327 success = 0; 1301 success = 0;
1328 } 1302 }
1329 else 1303 else
1330 success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); 1304 success = fire_arch_from_position (op, caster, op->x, op->y, dir, spell_ob);
1331 break; 1305 break;
1332 1306
1333 case SP_SWARM: 1307 case SP_SWARM:
1334 success = fire_swarm (op, caster, spell_ob, dir); 1308 success = fire_swarm (op, caster, spell_ob, dir);
1335 break; 1309 break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines