… | |
… | |
75 | { |
75 | { |
76 | if (caster == op && spob->skill) |
76 | if (caster == op && spob->skill) |
77 | dest->skill = spob->skill; |
77 | dest->skill = spob->skill; |
78 | else |
78 | else |
79 | dest->skill = caster->skill; |
79 | dest->skill = caster->skill; |
80 | } |
|
|
81 | |
|
|
82 | /* init_spells: This should really be called check_spells, as that |
|
|
83 | * is what it does. It goes through the spells looking for any |
|
|
84 | * obvious errors. This was most useful in debugging when re-doing |
|
|
85 | * all the spells to catch simple errors. To use it all the time |
|
|
86 | * will result in it spitting out messages that aren't really errors. |
|
|
87 | */ |
|
|
88 | void |
|
|
89 | init_spells (void) |
|
|
90 | { |
|
|
91 | #ifdef SPELL_DEBUG |
|
|
92 | static int init_spells_done = 0; |
|
|
93 | int i; |
|
|
94 | archetype *at; |
|
|
95 | |
|
|
96 | if (init_spells_done) |
|
|
97 | return; |
|
|
98 | LOG (llevDebug, "Checking spells...\n"); |
|
|
99 | |
|
|
100 | for_all_archetypes (at) |
|
|
101 | { |
|
|
102 | if (at->type == SPELL) |
|
|
103 | { |
|
|
104 | if (at->skill) |
|
|
105 | { |
|
|
106 | for (i = 1; i < NUM_SKILLS; i++) |
|
|
107 | if (!strcmp (skill_names[i], at->skill)) |
|
|
108 | break; |
|
|
109 | if (i == NUM_SKILLS) |
|
|
110 | { |
|
|
111 | LOG (llevError, "Spell %s has improper associated skill %s\n", at->name, at->skill); |
|
|
112 | } |
|
|
113 | } |
|
|
114 | /* other_arch is already checked for in the loader */ |
|
|
115 | } |
|
|
116 | } |
|
|
117 | |
|
|
118 | i = 0; |
|
|
119 | while (spell_mapping[i]) |
|
|
120 | { |
|
|
121 | if (!archetype::find (spell_mapping[i])) |
|
|
122 | { |
|
|
123 | LOG (llevError, "Unable to find spell mapping %s (%i)\n", spell_mapping[i], i); |
|
|
124 | } |
|
|
125 | i++; |
|
|
126 | } |
|
|
127 | LOG (llevDebug, "Checking spells completed.\n"); |
|
|
128 | #endif |
|
|
129 | } |
|
|
130 | |
|
|
131 | /* Dumps all the spells - now also dumps skill associated with the spell. |
|
|
132 | * not sure what this would be used for, as the data seems pretty |
|
|
133 | * minimal, but easy enough to keep around. |
|
|
134 | */ |
|
|
135 | void |
|
|
136 | dump_spells () |
|
|
137 | { |
|
|
138 | for_all_archetypes (at) |
|
|
139 | if (at->type == SPELL) |
|
|
140 | fprintf (stderr, "%s:%s:%s:%s:%d\n", &at->object::name, |
|
|
141 | &at->archname, at->other_arch ? &at->other_arch->archname : "<nil>", &at->skill, at->level); |
|
|
142 | } |
80 | } |
143 | |
81 | |
144 | /* pretty basic function - basically just takes |
82 | /* pretty basic function - basically just takes |
145 | * an object, sets the x,y, and calls insert_ob_in_map |
83 | * an object, sets the x,y, and calls insert_ob_in_map |
146 | */ |
84 | */ |
… | |
… | |
500 | /* |
438 | /* |
501 | * Combine similar spell effects into one spell effect. Needed for |
439 | * Combine similar spell effects into one spell effect. Needed for |
502 | * performance reasons with meteor swarm and the like, but also for |
440 | * performance reasons with meteor swarm and the like, but also for |
503 | * playability reasons. |
441 | * playability reasons. |
504 | */ |
442 | */ |
505 | if (tmp->arch == op->arch |
443 | if (tmp->arch == op->arch /* no harm if not comparing by name here */ |
506 | && tmp->type == op->type |
444 | && tmp->type == op->type |
507 | && tmp->subtype == op->subtype |
445 | && tmp->subtype == op->subtype |
508 | && tmp->owner == op->owner |
446 | && tmp->owner == op->owner |
509 | && ((tmp->subtype == SP_EXPLOSION) || (tmp->subtype == SP_CONE && tmp->stats.sp == op->stats.sp))) |
447 | && ((tmp->subtype == SP_EXPLOSION) || (tmp->subtype == SP_CONE && tmp->stats.sp == op->stats.sp))) |
510 | { |
448 | { |
… | |
… | |
754 | create_treasure (head->randomitems, head, GT_INVISIBLE, op->map->difficulty, 0); |
692 | create_treasure (head->randomitems, head, GT_INVISIBLE, op->map->difficulty, 0); |
755 | |
693 | |
756 | insert_ob_in_map (head, op->map, op, 0); |
694 | insert_ob_in_map (head, op->map, op, 0); |
757 | |
695 | |
758 | /* thought it'd be cool to insert a burnout, too. */ |
696 | /* thought it'd be cool to insert a burnout, too. */ |
759 | op->map->insert (get_archetype ("burnout"), op->x + freearr_x[dir], op->y + freearr_y[dir], op); |
697 | op->map->insert (archetype::get (shstr_burnout), op->x + freearr_x[dir], op->y + freearr_y[dir], op); |
760 | } |
698 | } |
761 | } |
699 | } |
762 | |
700 | |
763 | /* peterm: function which summons hostile monsters and |
701 | /* peterm: function which summons hostile monsters and |
764 | * places them in nearby squares. |
702 | * places them in nearby squares. |
… | |
… | |
1066 | { |
1004 | { |
1067 | skill = find_skill_by_name (op, spell_ob->skill); |
1005 | skill = find_skill_by_name (op, spell_ob->skill); |
1068 | |
1006 | |
1069 | if (!skill) |
1007 | if (!skill) |
1070 | { |
1008 | { |
1071 | op->failmsg (format ("You need the skill %s to cast %s!", &spell_ob->skill, &spell_ob->name)); |
1009 | op->failmsg (format ("You need the skill %s to cast %s! " |
|
|
1010 | "H<You either need to learn the skill via a skill scroll " |
|
|
1011 | "or you need to wear a talisman or holy symbol.>", |
|
|
1012 | &spell_ob->skill, &spell_ob->name)); |
1072 | return 0; |
1013 | return 0; |
1073 | } |
1014 | } |
1074 | |
1015 | |
|
|
1016 | int casting_level = min_casting_level (op, spell_ob); |
|
|
1017 | |
1075 | if (min_casting_level (op, spell_ob) > cast_level && !QUERY_FLAG (op, FLAG_WIZ)) |
1018 | if (casting_level > cast_level && !QUERY_FLAG (op, FLAG_WIZ)) |
1076 | { |
1019 | { |
1077 | op->failmsg ("You lack enough skill to cast that spell!"); |
1020 | op->failmsg (format ("You lack enough skill to cast that spell! " |
|
|
1021 | "H<Your cast level is %d, but level %d is required. Maybe you are repelled?>", |
|
|
1022 | cast_level, casting_level)); |
1078 | return 0; |
1023 | return 0; |
1079 | } |
1024 | } |
1080 | } |
1025 | } |
1081 | |
1026 | |
1082 | /* If the caster is the wiz, they don't ever fail, and don't have |
1027 | /* If the caster is the wiz, they don't ever fail, and don't have |