… | |
… | |
53 | char buf[MAX_BUF]; |
53 | char buf[MAX_BUF]; |
54 | maptile *m; |
54 | maptile *m; |
55 | sint16 nx, ny; |
55 | sint16 nx, ny; |
56 | |
56 | |
57 | if (!dir) |
57 | if (!dir) |
58 | { |
|
|
59 | dir = 1; |
58 | dir = 1; |
60 | } |
|
|
61 | |
59 | |
62 | nx = op->x + freearr_x[dir]; |
60 | nx = op->x + freearr_x[dir]; |
63 | ny = op->y + freearr_y[dir]; |
61 | ny = op->y + freearr_y[dir]; |
64 | m = op->map; |
62 | m = op->map; |
65 | |
63 | |
66 | if (get_map_flags (m, &m, nx, ny, &nx, &ny)) |
64 | if (get_map_flags (m, &m, nx, ny, &nx, &ny)) |
67 | { |
65 | { |
68 | new_draw_info (NDI_UNIQUE, 0, op, "Can't make a rune there!"); |
66 | new_draw_info (NDI_UNIQUE, 0, op, "Can't make a rune there!"); |
69 | return 0; |
67 | return 0; |
70 | } |
68 | } |
|
|
69 | |
71 | for (tmp = get_map_ob (m, nx, ny); tmp != NULL; tmp = tmp->above) |
70 | for (tmp = get_map_ob (m, nx, ny); tmp != NULL; tmp = tmp->above) |
72 | if (tmp->type == RUNE) |
71 | if (tmp->type == RUNE) |
73 | break; |
72 | break; |
74 | |
73 | |
75 | if (tmp) |
74 | if (tmp) |
… | |
… | |
77 | new_draw_info (NDI_UNIQUE, 0, op, "You can't write a rune there."); |
76 | new_draw_info (NDI_UNIQUE, 0, op, "You can't write a rune there."); |
78 | return 0; |
77 | return 0; |
79 | } |
78 | } |
80 | |
79 | |
81 | if (spell->other_arch) |
80 | if (spell->other_arch) |
82 | { |
|
|
83 | rune_spell = arch_to_object (spell->other_arch); |
81 | rune_spell = arch_to_object (spell->other_arch); |
84 | } |
|
|
85 | else |
82 | else |
86 | { |
83 | { |
87 | /* Player specified spell. The player has to know the spell, so |
84 | /* Player specified spell. The player has to know the spell, so |
88 | * lets just look through the players inventory see if they know it |
85 | * lets just look through the players inventory see if they know it |
89 | * use the item_matched_string for our typical matching method. |
86 | * use the item_matched_string for our typical matching method. |
… | |
… | |
107 | bestmatch = ms; |
104 | bestmatch = ms; |
108 | rune_spell = tmp; |
105 | rune_spell = tmp; |
109 | } |
106 | } |
110 | } |
107 | } |
111 | } |
108 | } |
|
|
109 | |
112 | if (!rune_spell) |
110 | if (!rune_spell) |
113 | { |
111 | { |
114 | new_draw_info_format (NDI_UNIQUE, 0, op, "You don't know any spell named %s", runename); |
112 | new_draw_info_format (NDI_UNIQUE, 0, op, "You don't know any spell named %s", runename); |
115 | return 0; |
113 | return 0; |
116 | } |
114 | } |
|
|
115 | |
117 | if (rune_spell->skill != spell->skill) |
116 | if (rune_spell->skill != spell->skill) |
118 | { |
117 | { |
119 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't cast %s with %s", &rune_spell->name, &spell->name); |
118 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't cast %s with %s", &rune_spell->name, &spell->name); |
120 | return 0; |
119 | return 0; |
121 | } |
120 | } |
|
|
121 | |
122 | if (caster->path_denied & spell->path_attuned) |
122 | if (caster->path_denied & spell->path_attuned) |
123 | { |
123 | { |
124 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s belongs to a spell path denied to you.", &rune_spell->name); |
124 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s belongs to a spell path denied to you.", &rune_spell->name); |
125 | return 0; |
125 | return 0; |
126 | } |
126 | } |
|
|
127 | |
127 | if (caster_level (caster, rune_spell) < rune_spell->level) |
128 | if (caster_level (caster, rune_spell) < rune_spell->level) |
128 | { |
129 | { |
129 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is beyond your ability to cast!", &rune_spell->name); |
130 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is beyond your ability to cast!", &rune_spell->name); |
130 | return 0; |
131 | return 0; |
131 | } |
132 | } |
|
|
133 | |
132 | if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA) > op->stats.sp) |
134 | if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA) > op->stats.sp) |
133 | { |
135 | { |
134 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough mana."); |
136 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough mana."); |
135 | return 0; |
137 | return 0; |
136 | } |
138 | } |
|
|
139 | |
137 | if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_GRACE) > op->stats.grace) |
140 | if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_GRACE) > op->stats.grace) |
138 | { |
141 | { |
139 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough grace."); |
142 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough grace."); |
140 | return 0; |
143 | return 0; |
141 | } |
144 | } |
|
|
145 | |
142 | op->stats.grace -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_GRACE); |
146 | op->stats.grace -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_GRACE); |
143 | op->stats.sp -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA); |
147 | op->stats.sp -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA); |
144 | } |
148 | } |
|
|
149 | |
145 | /* already proper rune. Note this should only be the case if other_arch was set */ |
150 | /* already proper rune. Note this should only be the case if other_arch was set */ |
146 | if (rune_spell->type == RUNE) |
151 | if (rune_spell->type == RUNE) |
147 | { |
152 | { |
148 | rune = rune_spell; |
153 | rune = rune_spell; |
149 | } |
154 | } |
150 | else |
155 | else |
151 | { |
156 | { |
152 | rune = get_archetype (GENERIC_RUNE); |
157 | rune = get_archetype (GENERIC_RUNE); |
153 | sprintf (buf, "You set off a rune of %s\n", &rune_spell->name); |
158 | sprintf (buf, "You set off a rune of %s\n", &rune_spell->name); |
154 | rune->msg = buf; |
159 | rune->msg = buf; |
155 | tmp = object::create (); |
160 | tmp = rune_spell->clone (); |
156 | rune_spell->copy_to (tmp); |
|
|
157 | insert_ob_in_ob (tmp, rune); |
161 | insert_ob_in_ob (tmp, rune); |
|
|
162 | |
158 | if (spell->face != blank_face) |
163 | if (spell->face != blank_face) |
159 | rune->face = spell->face; |
164 | rune->face = spell->face; |
160 | } |
165 | } |
|
|
166 | |
161 | rune->level = caster_level (caster, spell); |
167 | rune->level = caster_level (caster, spell); |
162 | rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ |
168 | rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ |
163 | rune->x = nx; |
169 | rune->x = nx; |
164 | rune->y = ny; |
170 | rune->y = ny; |
165 | rune->map = m; |
171 | rune->map = m; |