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.27 by root, Mon Dec 25 11:25:50 2006 UTC vs.
Revision 1.30 by root, Sun Dec 31 19:02:24 2006 UTC

24 24
25#include <global.h> 25#include <global.h>
26#include <spells.h> 26#include <spells.h>
27#include <object.h> 27#include <object.h>
28#include <errno.h> 28#include <errno.h>
29#ifndef __CEXTRACT__
30# include <sproto.h> 29#include <sproto.h>
31#endif
32#include <sounds.h> 30#include <sounds.h>
33 31
34extern char *spell_mapping[]; 32extern char *spell_mapping[];
35 33
36/* This returns a random spell from 'ob'. If skill is set, then 34/* This returns a random spell from 'ob'. If skill is set, then
151} 149}
152 150
153/* pretty basic function - basically just takes 151/* pretty basic function - basically just takes
154 * an object, sets the x,y, and calls insert_ob_in_map 152 * an object, sets the x,y, and calls insert_ob_in_map
155 */ 153 */
156
157void 154void
158spell_effect (object *spob, int x, int y, maptile *map, object *originator) 155spell_effect (object *spob, int x, int y, maptile *map, object *originator)
159{ 156{
160
161 if (spob->other_arch != NULL) 157 if (spob->other_arch)
162 { 158 map->insert (arch_to_object (spob->other_arch), x, y, originator);
163 object *effect = arch_to_object (spob->other_arch);
164
165 effect->x = x;
166 effect->y = y;
167
168 insert_ob_in_map (effect, map, originator, 0);
169 }
170} 159}
171 160
172/* 161/*
173 * This function takes a caster and spell and presents the 162 * This function takes a caster and spell and presents the
174 * effective level the caster needs to be to cast the spell. 163 * effective level the caster needs to be to cast the spell.
175 * basically, it just adjusts the spell->level with attuned/repelled 164 * basically, it just adjusts the spell->level with attuned/repelled
176 * spellpaths. Was called path_level_mod 165 * spellpaths. Was called path_level_mod.
177 * 166 *
178 * caster is person casting hte spell. 167 * caster is person casting the spell.
179 * spell is the spell object. 168 * spell is the spell object.
180 * Returns modified level. 169 * Returns modified level.
181 */ 170 */
182int 171int
183min_casting_level (object *caster, object *spell) 172min_casting_level (object *caster, object *spell)
186 175
187 if (caster->path_denied & spell->path_attuned) 176 if (caster->path_denied & spell->path_attuned)
188 return 1; 177 return 1;
189 178
190 new_level = spell->level 179 new_level = spell->level
191 + ((caster->path_repelled & spell->path_attuned) ? +2 : 0) + ((caster->path_attuned & spell->path_attuned) ? -2 : 0); 180 + (caster->path_repelled & spell->path_attuned ? +2 : 0)
181 + (caster->path_attuned & spell->path_attuned ? -2 : 0);
192 182
193 return (new_level < 1) ? 1 : new_level; 183 return max (1, new_level);
194} 184}
195
196 185
197/* This function returns the effective level the spell 186/* This function returns the effective level the spell
198 * is being cast at. 187 * is being cast at.
199 * Note that I changed the repelled/attuned bonus to 2 from 5. 188 * Note that I changed the repelled/attuned bonus to 2 from 5.
200 * This is because the new code compares casting_level against 189 * This is because the new code compares casting_level against
471 { 460 {
472 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 461 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way.");
473 new_draw_info (NDI_UNIQUE, 0, op, "You cast it at your feet."); 462 new_draw_info (NDI_UNIQUE, 0, op, "You cast it at your feet.");
474 dir = 0; 463 dir = 0;
475 } 464 }
476 new_op->x = op->x + freearr_x[dir]; 465
477 new_op->y = op->y + freearr_y[dir]; 466 op->map->insert (new_op,
478 if (dir == 0) 467 op->x + freearr_x[dir], op->y + freearr_y[dir],
479 insert_ob_in_map (new_op, op->map, op, INS_BELOW_ORIGINATOR); 468 op,
480 else 469 dir ? 0 : INS_BELOW_ORIGINATOR);
481 insert_ob_in_map (new_op, op->map, op, 0); 470
482 return dir; 471 return dir;
483} 472}
484 473
485/* Returns true if it is ok to put spell *op on the space/may provided. 474/* Returns true if it is ok to put spell *op on the space/may provided.
486 * immune_stop is basically the attacktype of the spell (why 475 * immune_stop is basically the attacktype of the spell (why
619 return 0; 608 return 0;
620 } 609 }
621 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) 610 if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE))
622 SET_ANIMATION (tmp, dir); 611 SET_ANIMATION (tmp, dir);
623 612
624 if ((tmp = insert_ob_in_map (tmp, m, op, 0)) == NULL) 613 if ((tmp = insert_ob_in_map (tmp, m, op, 0)))
625 return 1;
626
627 move_spell_effect (tmp); 614 move_spell_effect (tmp);
628 615
629 return 1; 616 return 1;
630} 617}
631
632
633 618
634/***************************************************************************** 619/*****************************************************************************
635 * 620 *
636 * Code related to rods - perhaps better located in another file? 621 * Code related to rods - perhaps better located in another file?
637 * 622 *
638 ****************************************************************************/ 623 ****************************************************************************/
639
640void 624void
641regenerate_rod (object *rod) 625regenerate_rod (object *rod)
642{ 626{
643 if (rod->stats.hp < rod->stats.maxhp) 627 if (rod->stats.hp < rod->stats.maxhp)
644 { 628 {
808 create_treasure (head->randomitems, head, GT_INVISIBLE, op->map->difficulty, 0); 792 create_treasure (head->randomitems, head, GT_INVISIBLE, op->map->difficulty, 0);
809 793
810 insert_ob_in_map (head, op->map, op, 0); 794 insert_ob_in_map (head, op->map, op, 0);
811 795
812 /* thought it'd be cool to insert a burnout, too. */ 796 /* thought it'd be cool to insert a burnout, too. */
813 tmp = get_archetype ("burnout"); 797 op->map->insert (get_archetype ("burnout"), op->x + freearr_x[dir], op->y + freearr_y[dir], op);
814 tmp->map = op->map;
815 tmp->x = op->x + freearr_x[dir];
816 tmp->y = op->y + freearr_y[dir];
817 insert_ob_in_map (tmp, op->map, op, 0);
818 } 798 }
819} 799}
820 800
821/* peterm: function which summons hostile monsters and 801/* peterm: function which summons hostile monsters and
822 * places them in nearby squares. 802 * places them in nearby squares.
1022 else 1002 else
1023 { 1003 {
1024 new_draw_info (NDI_UNIQUE, 0, op, "You lose control of the mana! The uncontrolled magic blasts you!"); 1004 new_draw_info (NDI_UNIQUE, 0, op, "You lose control of the mana! The uncontrolled magic blasts you!");
1025 tmp = get_archetype (LOOSE_MANA); 1005 tmp = get_archetype (LOOSE_MANA);
1026 tmp->level = skill->level; 1006 tmp->level = skill->level;
1027 tmp->x = op->x;
1028 tmp->y = op->y;
1029 1007
1030 /* increase the area of destruction a little for more powerful spells */ 1008 /* increase the area of destruction a little for more powerful spells */
1031 tmp->range += isqrt (power); 1009 tmp->range += isqrt (power);
1032 1010
1033 if (power > 25) 1011 if (power > 25)
1034 tmp->stats.dam = 25 + isqrt (power); 1012 tmp->stats.dam = 25 + isqrt (power);
1035 else 1013 else
1036 tmp->stats.dam = power; /* nasty recoils! */ 1014 tmp->stats.dam = power; /* nasty recoils! */
1037 1015
1038 tmp->stats.maxhp = tmp->count; 1016 tmp->stats.maxhp = tmp->count;
1039 insert_ob_in_map (tmp, op->map, NULL, 0); 1017
1018 tmp->insert_at (op);
1040 } 1019 }
1041 } 1020 }
1042} 1021}
1043 1022
1044int 1023int
1169 SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) > op->stats.sp) 1148 SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) > op->stats.sp)
1170 { 1149 {
1171 new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough mana."); 1150 new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough mana.");
1172 return 0; 1151 return 0;
1173 } 1152 }
1153
1174 if (SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) && 1154 if (SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) &&
1175 SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) > op->stats.grace) 1155 SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) > op->stats.grace)
1176 { 1156 {
1177 if (random_roll (0, op->stats.Wis - 1, op, PREFER_HIGH) + op->stats.grace - 1157 if (random_roll (0, op->stats.Wis - 1, op, PREFER_HIGH) + op->stats.grace -
1178 10 * SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) / op->stats.maxgrace > 0) 1158 10 * SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) / op->stats.maxgrace > 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines