1 | /* |
1 | /* |
2 | * static char *rcsid_spell_util_c = |
2 | * static char *rcsid_spell_util_c = |
3 | * "$Id: spell_util.C,v 1.9 2006/08/29 11:58:02 elmex Exp $"; |
3 | * "$Id: spell_util.C,v 1.10 2006/09/03 00:18:42 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | |
6 | |
7 | /* |
7 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
… | |
… | |
73 | * then they get exp for the skill that you need to use for |
73 | * then they get exp for the skill that you need to use for |
74 | * that object (use magic device). |
74 | * that object (use magic device). |
75 | */ |
75 | */ |
76 | void set_spell_skill(object *op, object *caster, object *spob, object *dest) |
76 | void set_spell_skill(object *op, object *caster, object *spob, object *dest) |
77 | { |
77 | { |
78 | if (dest->skill) FREE_AND_CLEAR_STR(dest->skill); |
|
|
79 | if (caster == op && spob->skill) |
78 | if (caster == op && spob->skill) |
80 | dest->skill = add_refcount(spob->skill); |
79 | dest->skill = spob->skill; |
81 | else if (caster->skill) |
80 | else |
82 | dest->skill = add_refcount(caster->skill); |
81 | dest->skill = caster->skill; |
83 | } |
82 | } |
84 | |
83 | |
85 | /* init_spells: This should really be called check_spells, as that |
84 | /* init_spells: This should really be called check_spells, as that |
86 | * is what it does. It goes through the spells looking for any |
85 | * is what it does. It goes through the spells looking for any |
87 | * obvious errors. This was most useful in debugging when re-doing |
86 | * obvious errors. This was most useful in debugging when re-doing |
… | |
… | |
130 | { |
129 | { |
131 | archetype *at; |
130 | archetype *at; |
132 | |
131 | |
133 | for (at=first_archetype; at; at=at->next) { |
132 | for (at=first_archetype; at; at=at->next) { |
134 | if (at->clone.type == SPELL) { |
133 | if (at->clone.type == SPELL) { |
135 | fprintf(stderr, "%s:%s:%s:%s:%d\n", at->clone.name?at->clone.name:"null", |
134 | fprintf(stderr, "%s:%s:%s:%s:%d\n", &at->clone.name, |
136 | at->name, at->clone.other_arch?at->clone.other_arch->name:"null", |
135 | &at->name, at->clone.other_arch ? &at->clone.other_arch->name : "<nil>", |
137 | at->clone.skill?at->clone.skill:"null", at->clone.level); |
136 | &at->clone.skill, at->clone.level); |
138 | } |
137 | } |
139 | } |
138 | } |
140 | } |
139 | } |
141 | |
140 | |
142 | /* pretty basic function - basically just takes |
141 | /* pretty basic function - basically just takes |
… | |
… | |
379 | * fall into this category). It shouldn't be hard to |
378 | * fall into this category). It shouldn't be hard to |
380 | * make sure spell names don't overlap in that fashion. |
379 | * make sure spell names don't overlap in that fashion. |
381 | */ |
380 | */ |
382 | if (spob2) |
381 | if (spob2) |
383 | LOG(llevError,"Found multiple spells with overlapping base names: %s, %s\n", |
382 | LOG(llevError,"Found multiple spells with overlapping base names: %s, %s\n", |
384 | spob2->name, spob->name); |
383 | &spob2->name, &spob->name); |
385 | spob2 = spob; |
384 | spob2 = spob; |
386 | } |
385 | } |
387 | } |
386 | } |
388 | } |
387 | } |
389 | /* if we have best match, return it. Otherwise, if we have one match |
388 | /* if we have best match, return it. Otherwise, if we have one match |
… | |
… | |
1043 | cast_level = caster_level(caster, spell_ob); |
1042 | cast_level = caster_level(caster, spell_ob); |
1044 | if (spell_ob->skill) { |
1043 | if (spell_ob->skill) { |
1045 | skill = find_skill_by_name(op, spell_ob->skill); |
1044 | skill = find_skill_by_name(op, spell_ob->skill); |
1046 | if (!skill) { |
1045 | if (!skill) { |
1047 | new_draw_info_format(NDI_UNIQUE, 0,op,"You need the skill %s to cast %s.", |
1046 | new_draw_info_format(NDI_UNIQUE, 0,op,"You need the skill %s to cast %s.", |
1048 | spell_ob->skill, spell_ob->name); |
1047 | &spell_ob->skill, &spell_ob->name); |
1049 | return 0; |
1048 | return 0; |
1050 | } |
1049 | } |
1051 | if (min_casting_level(op, spell_ob) > cast_level && !QUERY_FLAG(op, FLAG_WIZ)) { |
1050 | if (min_casting_level(op, spell_ob) > cast_level && !QUERY_FLAG(op, FLAG_WIZ)) { |
1052 | new_draw_info(NDI_UNIQUE, 0,op, "You lack enough skill to cast that spell."); |
1051 | new_draw_info(NDI_UNIQUE, 0,op, "You lack enough skill to cast that spell."); |
1053 | return 0; |
1052 | return 0; |
… | |
… | |
1209 | */ |
1208 | */ |
1210 | if (op != caster && !skill && caster->skill) { |
1209 | if (op != caster && !skill && caster->skill) { |
1211 | skill = find_skill_by_name(op, caster->skill); |
1210 | skill = find_skill_by_name(op, caster->skill); |
1212 | if (!skill) { |
1211 | if (!skill) { |
1213 | new_draw_info_format(NDI_UNIQUE, 0,op,"You lack the skill %s to use the %s", |
1212 | new_draw_info_format(NDI_UNIQUE, 0,op,"You lack the skill %s to use the %s", |
1214 | caster->skill, query_name(caster)); |
1213 | &caster->skill, query_name(caster)); |
1215 | return 0; |
1214 | return 0; |
1216 | } |
1215 | } |
1217 | change_skill(op, skill, 0); /* needed for proper exp credit */ |
1216 | change_skill(op, skill, 0); /* needed for proper exp credit */ |
1218 | } |
1217 | } |
1219 | |
1218 | |
… | |
… | |
1374 | |
1373 | |
1375 | case SP_MOVING_BALL: |
1374 | case SP_MOVING_BALL: |
1376 | if (spell_ob->path_repelled && |
1375 | if (spell_ob->path_repelled && |
1377 | (spell_ob->path_repelled & caster->path_attuned) != spell_ob->path_repelled) { |
1376 | (spell_ob->path_repelled & caster->path_attuned) != spell_ob->path_repelled) { |
1378 | new_draw_info_format(NDI_UNIQUE, 0, op, |
1377 | new_draw_info_format(NDI_UNIQUE, 0, op, |
1379 | "You lack the proper attunement to cast %s", spell_ob->name); |
1378 | "You lack the proper attunement to cast %s", &spell_ob->name); |
1380 | success = 0; |
1379 | success = 0; |
1381 | } else |
1380 | } else |
1382 | success = fire_arch_from_position(op,caster, |
1381 | success = fire_arch_from_position(op,caster, |
1383 | op->x + freearr_x[dir], op->y + freearr_y[dir], |
1382 | op->x + freearr_x[dir], op->y + freearr_y[dir], |
1384 | dir, spell_ob); |
1383 | dir, spell_ob); |