1 | /* |
1 | /* |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
… | |
… | |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * |
20 | * |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include <global.h> |
24 | #include <global.h> |
25 | #include <object.h> |
25 | #include <object.h> |
26 | #include <living.h> |
26 | #include <living.h> |
… | |
… | |
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) |
… | |
… | |
215 | { |
211 | { |
216 | int food_value; |
212 | int food_value; |
217 | archetype *at = NULL; |
213 | archetype *at = NULL; |
218 | object *new_op; |
214 | object *new_op; |
219 | |
215 | |
220 | food_value = spell_ob->stats.food + +50 * SP_level_duration_adjust (caster, spell_ob); |
216 | food_value = spell_ob->stats.food + 50 * SP_level_duration_adjust (caster, spell_ob); |
221 | |
217 | |
222 | if (stringarg) |
218 | if (stringarg) |
223 | { |
219 | { |
224 | at = find_archetype_by_object_type_name (FOOD, stringarg); |
220 | at = find_archetype_by_object_type_name (FOOD, stringarg); |
225 | if (at == NULL) |
221 | if (at == NULL) |
… | |
… | |
1299 | static void |
1295 | static void |
1300 | alchemy_object (object *obj, uint64 &total_value, int &total_weight) |
1296 | alchemy_object (object *obj, uint64 &total_value, int &total_weight) |
1301 | { |
1297 | { |
1302 | uint64 value = query_cost (obj, NULL, F_TRUE); |
1298 | uint64 value = query_cost (obj, NULL, F_TRUE); |
1303 | |
1299 | |
1304 | /* Give third price when we alchemy money (This should hopefully |
1300 | /* Give third price when we alchemy money (this should hopefully |
1305 | * make it so that it isn't worth it to alchemy money, sell |
1301 | * make it so that it isn't worth it to alchemy money, sell |
1306 | * the nuggets, alchemy the gold from that, etc. |
1302 | * the nuggets, alchemy the gold from that, etc. |
1307 | * Otherwise, give 9 silver on the gold for other objects, |
1303 | * Otherwise, give 9 silver on the gold for other objects, |
1308 | * so that it would still be more affordable to haul |
1304 | * so that it would still be more affordable to haul |
1309 | * the stuff back to town. |
1305 | * the stuff back to town. |
… | |
… | |
1463 | |
1459 | |
1464 | return success; |
1460 | return success; |
1465 | } |
1461 | } |
1466 | |
1462 | |
1467 | /* Identifies objects in the players inventory/on the ground */ |
1463 | /* Identifies objects in the players inventory/on the ground */ |
1468 | |
|
|
1469 | int |
1464 | int |
1470 | cast_identify (object *op, object *caster, object *spell) |
1465 | cast_identify (object *op, object *caster, object *spell) |
1471 | { |
1466 | { |
|
|
1467 | dynbuf_text buf; |
1472 | object *tmp; |
1468 | object *tmp; |
1473 | int success = 0, num_ident; |
|
|
1474 | |
1469 | |
1475 | num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1470 | int num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1476 | |
1471 | |
1477 | if (num_ident < 1) |
1472 | if (num_ident < 1) |
1478 | num_ident = 1; |
1473 | num_ident = 1; |
1479 | |
1474 | |
1480 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1475 | for (tmp = op->inv; tmp; tmp = tmp->below) |
… | |
… | |
1483 | { |
1478 | { |
1484 | identify (tmp); |
1479 | identify (tmp); |
1485 | |
1480 | |
1486 | if (op->type == PLAYER) |
1481 | if (op->type == PLAYER) |
1487 | { |
1482 | { |
1488 | new_draw_info_format (NDI_UNIQUE, 0, op, "You identified: %s.", long_desc (tmp, op)); |
1483 | buf.printf ("You identified: %s.\n\n", long_desc (tmp, op)); |
1489 | |
1484 | |
1490 | if (tmp->msg) |
1485 | if (tmp->msg) |
1491 | { |
1486 | buf << "The item has a story:\n\n" << tmp->msg << "\n\n"; |
1492 | new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); |
|
|
1493 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
|
|
1494 | } |
|
|
1495 | } |
1487 | } |
1496 | |
1488 | |
1497 | num_ident--; |
1489 | num_ident--; |
1498 | success = 1; |
|
|
1499 | if (!num_ident) |
1490 | if (!num_ident) |
1500 | break; |
1491 | break; |
1501 | } |
1492 | } |
1502 | } |
1493 | } |
1503 | |
1494 | |
… | |
… | |
1512 | { |
1503 | { |
1513 | identify (tmp); |
1504 | identify (tmp); |
1514 | |
1505 | |
1515 | if (op->type == PLAYER) |
1506 | if (op->type == PLAYER) |
1516 | { |
1507 | { |
1517 | new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground you identified: %s.", long_desc (tmp, op)); |
1508 | buf.printf ("On the ground you identified: %s.\n\n", long_desc (tmp, op)); |
1518 | |
1509 | |
1519 | if (tmp->msg) |
1510 | if (tmp->msg) |
1520 | { |
1511 | buf << "The item has a story:\n\n" << tmp->msg << "\n\n"; |
1521 | new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); |
|
|
1522 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
|
|
1523 | } |
|
|
1524 | |
1512 | |
1525 | esrv_send_item (op, tmp); |
1513 | esrv_send_item (op, tmp); |
1526 | } |
1514 | } |
1527 | |
1515 | |
1528 | num_ident--; |
1516 | num_ident--; |
1529 | success = 1; |
|
|
1530 | if (!num_ident) |
1517 | if (!num_ident) |
1531 | break; |
1518 | break; |
1532 | } |
1519 | } |
1533 | } |
1520 | } |
1534 | |
1521 | |
1535 | if (!success) |
1522 | if (buf.empty ()) |
1536 | new_draw_info (NDI_UNIQUE, 0, op, "You can't reach anything unidentified."); |
1523 | { |
|
|
1524 | op->failmsg ("You can't reach anything unidentified."); |
|
|
1525 | return 0; |
|
|
1526 | } |
1537 | else |
1527 | else |
|
|
1528 | { |
|
|
1529 | if (op->contr) |
|
|
1530 | op->contr->infobox (MSG_CHANNEL ("identify"), buf); |
|
|
1531 | |
1538 | spell_effect (spell, op->x, op->y, op->map, op); |
1532 | spell_effect (spell, op->x, op->y, op->map, op); |
1539 | |
1533 | return 1; |
1540 | return success; |
1534 | } |
1541 | } |
1535 | } |
1542 | |
1536 | |
1543 | int |
1537 | int |
1544 | cast_detection (object *op, object *caster, object *spell, object *skill) |
1538 | cast_detection (object *op, object *caster, object *spell, object *skill) |
1545 | { |
1539 | { |
… | |
… | |
2210 | new_aura->set_owner (op); |
2204 | new_aura->set_owner (op); |
2211 | |
2205 | |
2212 | return 1; |
2206 | return 1; |
2213 | } |
2207 | } |
2214 | |
2208 | |
2215 | |
|
|
2216 | /* move aura function. An aura is a part of someone's inventory, |
2209 | /* move aura function. An aura is a part of someone's inventory, |
2217 | * which he carries with him, but which acts on the map immediately |
2210 | * which he carries with him, but which acts on the map immediately |
2218 | * around him. |
2211 | * around him. |
2219 | * Aura parameters: |
2212 | * Aura parameters: |
2220 | * duration: duration counter. |
2213 | * duration: duration counter. |
2221 | * attacktype: aura's attacktype |
2214 | * attacktype: aura's attacktype |
2222 | * other_arch: archetype to drop where we attack |
2215 | * other_arch: archetype to drop where we attack |
2223 | */ |
2216 | */ |
2224 | |
|
|
2225 | void |
2217 | void |
2226 | move_aura (object *aura) |
2218 | move_aura (object *aura) |
2227 | { |
2219 | { |
2228 | int i, mflags; |
|
|
2229 | object *env; |
|
|
2230 | maptile *m; |
|
|
2231 | |
|
|
2232 | /* auras belong in inventories */ |
2220 | /* auras belong in inventories */ |
2233 | env = aura->env; |
2221 | object *env = aura->env; |
|
|
2222 | object *owner = aura->owner; |
2234 | |
2223 | |
2235 | /* no matter what we've gotta remove the aura... |
2224 | /* no matter what we've gotta remove the aura... |
2236 | * we'll put it back if its time isn't up. |
2225 | * we'll put it back if its time isn't up. |
2237 | */ |
2226 | */ |
2238 | aura->remove (); |
2227 | aura->remove (); |
… | |
… | |
2243 | aura->destroy (); |
2232 | aura->destroy (); |
2244 | return; |
2233 | return; |
2245 | } |
2234 | } |
2246 | |
2235 | |
2247 | /* auras only exist in inventories */ |
2236 | /* auras only exist in inventories */ |
2248 | if (env == NULL || env->map == NULL) |
2237 | if (!env || !env->map) |
2249 | { |
2238 | { |
2250 | aura->destroy (); |
2239 | aura->destroy (); |
2251 | return; |
2240 | return; |
2252 | } |
2241 | } |
2253 | |
2242 | |
2254 | /* we need to jump out of the inventory for a bit |
2243 | /* we need to jump out of the inventory for a bit |
2255 | * in order to hit the map conveniently. |
2244 | * in order to hit the map conveniently. |
2256 | */ |
2245 | */ |
2257 | aura->insert_at (env, aura); |
2246 | aura->insert_at (env, aura); |
2258 | |
2247 | |
2259 | for (i = 1; i < 9; i++) |
2248 | for (int i = 1; i < 9; i++) |
2260 | { |
2249 | { |
2261 | sint16 nx, ny; |
2250 | mapxy pos (env); |
|
|
2251 | pos.move (i); |
2262 | |
2252 | |
2263 | nx = aura->x + freearr_x[i]; |
|
|
2264 | ny = aura->y + freearr_y[i]; |
|
|
2265 | mflags = get_map_flags (env->map, &m, nx, ny, &nx, &ny); |
|
|
2266 | |
|
|
2267 | /* Consider the movement tyep of the person with the aura as |
2253 | /* Consider the movement type of the person with the aura as |
2268 | * movement type of the aura. Eg, if the player is flying, the aura |
2254 | * movement type of the aura. Eg, if the player is flying, the aura |
2269 | * is flying also, if player is walking, it is on the ground, etc. |
2255 | * is flying also, if player is walking, it is on the ground, etc. |
2270 | */ |
2256 | */ |
2271 | if (!(mflags & P_OUT_OF_MAP) && !(OB_TYPE_MOVE_BLOCK (env, GET_MAP_MOVE_BLOCK (m, nx, ny)))) |
2257 | if (pos.normalise () && !(OB_TYPE_MOVE_BLOCK (env, pos->move_block))) |
2272 | { |
2258 | { |
2273 | hit_map (aura, i, aura->attacktype, 0); |
2259 | hit_map (aura, i, aura->attacktype, 0); |
2274 | |
2260 | |
2275 | if (aura->other_arch) |
2261 | if (aura->other_arch) |
2276 | m->insert (arch_to_object (aura->other_arch), nx, ny, aura); |
2262 | pos.insert (arch_to_object (aura->other_arch), aura); |
2277 | } |
2263 | } |
2278 | } |
2264 | } |
2279 | |
2265 | |
2280 | /* put the aura back in the player's inventory */ |
2266 | /* put the aura back in the player's inventory */ |
2281 | aura->remove (); |
2267 | env->insert (aura); |
2282 | insert_ob_in_ob (aura, env); |
2268 | aura->set_owner (owner); |
2283 | } |
2269 | } |
2284 | |
2270 | |
2285 | /* moves the peacemaker spell. |
2271 | /* moves the peacemaker spell. |
2286 | * op is the piece object. |
2272 | * op is the piece object. |
2287 | */ |
2273 | */ |