… | |
… | |
125 | * create nonnmagic arrows, or even -1, etc... |
125 | * create nonnmagic arrows, or even -1, etc... |
126 | */ |
126 | */ |
127 | int |
127 | int |
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 bonus_plus = 0; |
131 | const char *missile_name; |
131 | const char *missile_name = "arrow"; |
132 | object *tmp, *missile; |
|
|
133 | |
132 | |
134 | missile_name = "arrow"; |
|
|
135 | |
|
|
136 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
133 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
137 | if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED)) |
134 | if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED)) |
138 | missile_name = tmp->race; |
135 | missile_name = tmp->race; |
139 | |
136 | |
140 | missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
137 | int missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
141 | |
138 | |
142 | if (archetype::find (missile_name) == NULL) |
139 | archetype *missile_arch = archetype::find (missile_name); |
|
|
140 | |
|
|
141 | if (!missile_arch) |
143 | { |
142 | { |
144 | LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name); |
143 | LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name); |
145 | return 0; |
144 | return 0; |
146 | } |
145 | } |
147 | |
146 | |
148 | missile = get_archetype (missile_name); |
147 | object *missile = missile_arch->instance (); |
149 | |
148 | |
150 | if (stringarg) |
149 | if (stringarg) |
151 | { |
150 | { |
152 | /* If it starts with a letter, presume it is a description */ |
151 | /* If it starts with a letter, presume it is a description */ |
153 | if (isalpha (*stringarg)) |
152 | if (isalpha (*stringarg)) |
… | |
… | |
171 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); |
170 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); |
172 | return 0; |
171 | return 0; |
173 | } |
172 | } |
174 | |
173 | |
175 | give_artifact_abilities (missile, al->item); |
174 | give_artifact_abilities (missile, al->item); |
176 | /* These special arrows cost something extra. Don't have them also be magical - |
175 | /* 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 |
176 | * 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. |
177 | * the parsing of having to do both plus and type. |
179 | */ |
178 | */ |
180 | bonus_plus = 1 + (al->item->value / 5); |
179 | bonus_plus = 1 + (al->item->value / 5); |
181 | missile_plus = 0; |
180 | missile_plus = 0; |
182 | } |
181 | } |
183 | else if (atoi (stringarg) < missile_plus) |
182 | else if (atoi (stringarg) < missile_plus) |
184 | missile_plus = atoi (stringarg); |
183 | missile_plus = atoi (stringarg); |
185 | } |
184 | } |
186 | |
185 | |
187 | if (missile_plus > 4) |
186 | missile_plus = clamp (missile_plus, -4, 4); |
188 | missile_plus = 4; |
|
|
189 | else if (missile_plus < -4) |
|
|
190 | missile_plus = -4; |
|
|
191 | |
187 | |
192 | missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell); |
188 | missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell); |
193 | missile->nrof -= 3 * (missile_plus + bonus_plus); |
189 | missile->nrof -= 3 * (missile_plus + bonus_plus); |
194 | |
190 | |
195 | if (missile->nrof < 1) |
191 | if (missile->nrof < 1) |