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.18 by root, Fri Nov 17 15:48:07 2006 UTC vs.
Revision 1.24 by root, Wed Dec 20 09:14:22 2006 UTC

441{ 441{
442 object *op; 442 object *op;
443 443
444 if (OUT_OF_REAL_MAP (m, x, y)) 444 if (OUT_OF_REAL_MAP (m, x, y))
445 return 0; 445 return 0;
446 for (op = get_map_ob (m, x, y); op != NULL; op = op->above) 446 for (op = GET_MAP_OB (m, x, y); op != NULL; op = op->above)
447 if (QUERY_FLAG (op, FLAG_REFL_SPELL) && (!QUERY_FLAG (op, FLAG_ALIVE) || 447 if (QUERY_FLAG (op, FLAG_REFL_SPELL)
448 sp_op->type == LIGHTNING || (rndm (0, 99)) < 90 - (sp_op->level / 10))) 448 && (!QUERY_FLAG (op, FLAG_ALIVE)
449 || sp_op->type == LIGHTNING // XXX: elmex: why is LIGHTNING special cased here?
450 // most spells use subtypes for bolts today...
451 || (rndm (0, 99)) < 90 - (sp_op->level / 10)))
449 return 1; 452 return 1;
450 453
451 return 0; 454 return 0;
452} 455}
453 456
504 return 0; 507 return 0;
505 508
506 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (mp, x, y))) 509 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (mp, x, y)))
507 return 0; 510 return 0;
508 511
509 for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) 512 for (tmp = GET_MAP_OB (mp, x, y); tmp != NULL; tmp = tmp->above)
510 { 513 {
511 /* If there is a counterspell on the space, and this 514 /* If there is a counterspell on the space, and this
512 * object is using magic, don't progress. I believe we could 515 * object is using magic, don't progress. I believe we could
513 * leave this out and let in progress, and other areas of the code 516 * leave this out and let in progress, and other areas of the code
514 * will then remove it, but that would seem to to use more 517 * will then remove it, but that would seem to to use more
589 return 0; 592 return 0;
590 593
591 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y))) 594 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y)))
592 { 595 {
593 new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n"); 596 new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n");
594 free_object (tmp); 597 tmp->destroy ();
595 return 0; 598 return 0;
596 } 599 }
597
598
599 600
600 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 601 tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
601 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); 602 tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell);
602 /* code in time.c uses food for some things, duration for others */ 603 /* code in time.c uses food for some things, duration for others */
603 tmp->stats.food = tmp->duration; 604 tmp->stats.food = tmp->duration;
604 tmp->range = spell->range + SP_level_range_adjust (caster, spell); 605 tmp->range = spell->range + SP_level_range_adjust (caster, spell);
605 tmp->attacktype = spell->attacktype; 606 tmp->attacktype = spell->attacktype;
606 tmp->x = x; 607 tmp->x = x;
607 tmp->y = y; 608 tmp->y = y;
608 tmp->direction = dir; 609 tmp->direction = dir;
609 if (get_owner (op) != NULL) 610 if (op->owner != NULL)
610 copy_owner (tmp, op); 611 tmp->set_owner (op);
611 else 612 else
612 set_owner (tmp, op); 613 tmp->set_owner (op);
613 tmp->level = caster_level (caster, spell); 614 tmp->level = caster_level (caster, spell);
614 set_spell_skill (op, caster, spell, tmp); 615 set_spell_skill (op, caster, spell, tmp);
615 616
616 /* needed for AT_HOLYWORD,AT_GODPOWER stuff */ 617 /* needed for AT_HOLYWORD,AT_GODPOWER stuff */
617 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) 618 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER)
679 * we then make the owner of this object the target. 680 * we then make the owner of this object the target.
680 * The owner could very well be no where near op. 681 * The owner could very well be no where near op.
681 */ 682 */
682 if (op->type != PLAYER && op->type != RUNE) 683 if (op->type != PLAYER && op->type != RUNE)
683 { 684 {
684 tmp = get_owner (op); 685 tmp = op->owner;
685 /* If the owner does not exist, or is not a monster, than apply the spell 686 /* If the owner does not exist, or is not a monster, than apply the spell
686 * to the caster. 687 * to the caster.
687 */ 688 */
688 if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER)) 689 if (!tmp || !QUERY_FLAG (tmp, FLAG_MONSTER))
689 tmp = op; 690 tmp = op;
698 699
699 if (mflags & P_OUT_OF_MAP) 700 if (mflags & P_OUT_OF_MAP)
700 tmp = NULL; 701 tmp = NULL;
701 else 702 else
702 { 703 {
703 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 704 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
704 if (tmp->type == PLAYER) 705 if (tmp->type == PLAYER)
705 break; 706 break;
706 } 707 }
707 } 708 }
708 /* didn't find a player there, look in current square for a player */ 709 /* didn't find a player there, look in current square for a player */
709 if (tmp == NULL) 710 if (tmp == NULL)
710 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 711 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
711 { 712 {
712 if (tmp->type == PLAYER) 713 if (tmp->type == PLAYER)
713 break; 714 break;
714 } 715 }
715 716
751 mp = m; 752 mp = m;
752 mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny); 753 mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny);
753 if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW)) 754 if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW))
754 continue; 755 continue;
755 756
756 tmp = get_map_ob (mp, nx, ny); 757 tmp = GET_MAP_OB (mp, nx, ny);
757 758
758 while (tmp != NULL && (((owner_type == PLAYER && 759 while (tmp != NULL && (((owner_type == PLAYER &&
759 !QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_GENERATOR)) || 760 !QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_GENERATOR)) ||
760 (owner_type != PLAYER && tmp->type != PLAYER)) || (tmp == exclude || (tmp->head && tmp->head == exclude)))) 761 (owner_type != PLAYER && tmp->type != PLAYER)) || (tmp == exclude || (tmp->head && tmp->head == exclude))))
761 tmp = tmp->above; 762 tmp = tmp->above;
957 if (failure <= -20 && failure > -40) /* wonder */ 958 if (failure <= -20 && failure > -40) /* wonder */
958 { 959 {
959 new_draw_info_format (NDI_UNIQUE, 0, op, "%s gives a sign to renew your faith.", godname); 960 new_draw_info_format (NDI_UNIQUE, 0, op, "%s gives a sign to renew your faith.", godname);
960 tmp = get_archetype (SPELL_WONDER); 961 tmp = get_archetype (SPELL_WONDER);
961 cast_cone (op, op, 0, tmp); 962 cast_cone (op, op, 0, tmp);
962 free_object (tmp); 963 tmp->destroy ();
963 } 964 }
964 965
965 else if (failure <= -40 && failure > -60) /* confusion */ 966 else if (failure <= -40 && failure > -60) /* confusion */
966 { 967 {
967 new_draw_info (NDI_UNIQUE, 0, op, "Your diety touches your mind!"); 968 new_draw_info (NDI_UNIQUE, 0, op, "Your diety touches your mind!");
1001 if (failure <= -20 && failure > -40) /* wonder */ 1002 if (failure <= -20 && failure > -40) /* wonder */
1002 { 1003 {
1003 new_draw_info (NDI_UNIQUE, 0, op, "Your spell causes an unexpected effect."); 1004 new_draw_info (NDI_UNIQUE, 0, op, "Your spell causes an unexpected effect.");
1004 tmp = get_archetype (SPELL_WONDER); 1005 tmp = get_archetype (SPELL_WONDER);
1005 cast_cone (op, op, 0, tmp); 1006 cast_cone (op, op, 0, tmp);
1006 free_object (tmp); 1007 tmp->destroy ();
1007 } 1008 }
1008 1009
1009 else if (failure <= -40 && failure > -60) /* confusion */ 1010 else if (failure <= -40 && failure > -60) /* confusion */
1010 { 1011 {
1011 new_draw_info (NDI_UNIQUE, 0, op, "Your magic recoils on you, making you confused!"); 1012 new_draw_info (NDI_UNIQUE, 0, op, "Your magic recoils on you, making you confused!");
1066 /* Always cast spell on caster */ 1067 /* Always cast spell on caster */
1067 success = cast_spell (op, caster, dir, spell, stringarg); 1068 success = cast_spell (op, caster, dir, spell, stringarg);
1068 1069
1069 if (caster->contr->party == NULL) 1070 if (caster->contr->party == NULL)
1070 { 1071 {
1071 remove_ob (spell); 1072 spell->remove ();
1072 return success; 1073 return success;
1073 } 1074 }
1074 for (pl = first_player; pl != NULL; pl = pl->next) 1075 for (pl = first_player; pl != NULL; pl = pl->next)
1075 if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) 1076 if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster)))
1076 { 1077 {
1077 cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); 1078 cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg);
1078 } 1079 }
1079 remove_ob (spell); 1080 spell->remove ();
1080 return success; 1081 return success;
1081} 1082}
1082 1083
1083/* This is where the main dispatch when someone casts a spell. 1084/* This is where the main dispatch when someone casts a spell.
1084 * 1085 *
1279 * spell is actually cast, it knows about the stringarg. 1280 * spell is actually cast, it knows about the stringarg.
1280 * necessary for the invoke command spells. 1281 * necessary for the invoke command spells.
1281 */ 1282 */
1282 if (stringarg) 1283 if (stringarg)
1283 { 1284 {
1284 op->spellarg = strdup_local (stringarg); 1285 op->spellarg = strdup (stringarg);
1285 } 1286 }
1286 else 1287 else
1287 op->spellarg = NULL; 1288 op->spellarg = NULL;
1288 return 0; 1289 return 0;
1289 } 1290 }
1682 if (QUERY_FLAG (victim, FLAG_ALIVE)) 1683 if (QUERY_FLAG (victim, FLAG_ALIVE))
1683 { 1684 {
1684 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); 1685 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1);
1685 1686
1686 if (!spell->destroyed ()) 1687 if (!spell->destroyed ())
1687 { 1688 spell->destroy ();
1688 remove_ob (spell);
1689 free_object (spell);
1690 }
1691 } 1689 }
1692 break; 1690 break;
1693 1691
1694 case SP_MOVING_BALL: 1692 case SP_MOVING_BALL:
1695 if (QUERY_FLAG (victim, FLAG_ALIVE)) 1693 if (QUERY_FLAG (victim, FLAG_ALIVE))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines