… | |
… | |
128 | cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg) |
128 | cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg) |
129 | { |
129 | { |
130 | int missile_plus = 0, bonus_plus = 0; |
130 | int missile_plus = 0, bonus_plus = 0; |
131 | const char *missile_name; |
131 | const char *missile_name; |
132 | object *tmp, *missile; |
132 | object *tmp, *missile; |
133 | tag_t tag; |
|
|
134 | |
133 | |
135 | missile_name = "arrow"; |
134 | missile_name = "arrow"; |
136 | |
135 | |
137 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
136 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
138 | if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED)) |
137 | if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED)) |
139 | { |
|
|
140 | missile_name = tmp->race; |
138 | missile_name = tmp->race; |
141 | } |
|
|
142 | |
139 | |
143 | missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
140 | missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
144 | |
141 | |
145 | if (archetype::find (missile_name) == NULL) |
142 | if (archetype::find (missile_name) == NULL) |
146 | { |
143 | { |
147 | LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name); |
144 | LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name); |
148 | return 0; |
145 | return 0; |
149 | } |
146 | } |
|
|
147 | |
150 | missile = get_archetype (missile_name); |
148 | missile = get_archetype (missile_name); |
151 | |
149 | |
152 | if (stringarg) |
150 | if (stringarg) |
153 | { |
151 | { |
154 | /* If it starts with a letter, presume it is a description */ |
152 | /* If it starts with a letter, presume it is a description */ |
… | |
… | |
164 | { |
162 | { |
165 | free_object (missile); |
163 | free_object (missile); |
166 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such object %ss of %s", missile_name, stringarg); |
164 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such object %ss of %s", missile_name, stringarg); |
167 | return 0; |
165 | return 0; |
168 | } |
166 | } |
|
|
167 | |
169 | if (al->item->slaying) |
168 | if (al->item->slaying) |
170 | { |
169 | { |
171 | free_object (missile); |
170 | free_object (missile); |
172 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); |
171 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); |
173 | return 0; |
172 | return 0; |
174 | } |
173 | } |
|
|
174 | |
175 | give_artifact_abilities (missile, al->item); |
175 | give_artifact_abilities (missile, al->item); |
176 | /* These special arrows cost something extra. Don't have them also be magical - |
176 | /* These special arrows cost something extra. Don't have them also be magical - |
177 | * otherwise, in most cases, not enough will be created. I don't want to get into |
177 | * otherwise, in most cases, not enough will be created. I don't want to get into |
178 | * the parsing of having to do both plus and type. |
178 | * the parsing of having to do both plus and type. |
179 | */ |
179 | */ |
… | |
… | |
181 | missile_plus = 0; |
181 | missile_plus = 0; |
182 | } |
182 | } |
183 | else if (atoi (stringarg) < missile_plus) |
183 | else if (atoi (stringarg) < missile_plus) |
184 | missile_plus = atoi (stringarg); |
184 | missile_plus = atoi (stringarg); |
185 | } |
185 | } |
|
|
186 | |
186 | if (missile_plus > 4) |
187 | if (missile_plus > 4) |
187 | missile_plus = 4; |
188 | missile_plus = 4; |
188 | else if (missile_plus < -4) |
189 | else if (missile_plus < -4) |
189 | missile_plus = -4; |
190 | missile_plus = -4; |
190 | |
191 | |
191 | missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell); |
192 | missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell); |
192 | missile->nrof -= 3 * (missile_plus + bonus_plus); |
193 | missile->nrof -= 3 * (missile_plus + bonus_plus); |
|
|
194 | |
193 | if (missile->nrof < 1) |
195 | if (missile->nrof < 1) |
194 | missile->nrof = 1; |
196 | missile->nrof = 1; |
195 | |
197 | |
196 | missile->magic = missile_plus; |
198 | missile->magic = missile_plus; |
197 | /* Can't get any money for these objects */ |
199 | /* Can't get any money for these objects */ |
198 | missile->value = 0; |
200 | missile->value = 0; |
199 | |
201 | |
200 | SET_FLAG (missile, FLAG_IDENTIFIED); |
202 | SET_FLAG (missile, FLAG_IDENTIFIED); |
201 | tag = missile->count; |
|
|
202 | |
203 | |
203 | if (!cast_create_obj (op, caster, missile, dir) && op->type == PLAYER && !was_destroyed (missile, tag)) |
204 | if (!cast_create_obj (op, caster, missile, dir) && op->type == PLAYER && !missile->destroyed ()) |
204 | { |
|
|
205 | pick_up (op, missile); |
205 | pick_up (op, missile); |
206 | } |
206 | |
207 | return 1; |
207 | return 1; |
208 | } |
208 | } |
209 | |
209 | |
210 | |
210 | |
211 | /* allows the choice of what sort of food object to make. |
211 | /* allows the choice of what sort of food object to make. |