ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/spell_effect.C
(Generate patch)

Comparing deliantra/server/server/spell_effect.C (file contents):
Revision 1.31 by root, Thu Jan 4 16:19:32 2007 UTC vs.
Revision 1.45 by root, Mon Apr 16 06:23:43 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
3 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 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
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 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,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 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
18 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 21 *
21 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
22*/ 23 */
23 24
24#include <global.h> 25#include <global.h>
25#include <object.h> 26#include <object.h>
26#include <living.h> 27#include <living.h>
27#ifndef __CEXTRACT__
28# include <sproto.h> 28#include <sproto.h>
29#endif
30#include <spells.h> 29#include <spells.h>
31#include <sounds.h> 30#include <sounds.h>
32 31
33/* cast_magic_storm: This is really used mostly for spell 32/* cast_magic_storm: This is really used mostly for spell
34 * fumbles at the like. tmp is the object to propogate. 33 * fumbles at the like. tmp is the object to propogate.
155 /* If it starts with a letter, presume it is a description */ 154 /* If it starts with a letter, presume it is a description */
156 if (isalpha (*stringarg)) 155 if (isalpha (*stringarg))
157 { 156 {
158 artifact *al = find_artifactlist (missile->type)->items; 157 artifact *al = find_artifactlist (missile->type)->items;
159 158
160 for (; al != NULL; al = al->next) 159 for (; al; al = al->next)
161 if (!strcasecmp (al->item->name, stringarg)) 160 if (!strcasecmp (al->item->name, stringarg))
162 break; 161 break;
163 162
164 if (!al) 163 if (!al)
165 { 164 {
374 * normal applies. 373 * normal applies.
375 */ 374 */
376int 375int
377cast_invisible (object *op, object *caster, object *spell_ob) 376cast_invisible (object *op, object *caster, object *spell_ob)
378{ 377{
379 object *tmp;
380
381 if (op->invisible > 1000) 378 if (op->invisible > 1000)
382 { 379 {
383 new_draw_info (NDI_UNIQUE, 0, op, "You can not extend the duration of your invisibility any further"); 380 new_draw_info (NDI_UNIQUE, 0, op, "You can not extend the duration of your invisibility any further");
384 return 0; 381 return 0;
385 } 382 }
401 else 398 else
402 op->contr->tmp_invis = 1; 399 op->contr->tmp_invis = 1;
403 400
404 op->contr->hidden = 0; 401 op->contr->hidden = 0;
405 } 402 }
403
406 if (makes_invisible_to (op, op)) 404 if (makes_invisible_to (op, op))
407 new_draw_info (NDI_UNIQUE, 0, op, "You can't see your hands!"); 405 new_draw_info (NDI_UNIQUE, 0, op, "You can't see your hands!");
408 else 406 else
409 new_draw_info (NDI_UNIQUE, 0, op, "You feel more transparent!"); 407 new_draw_info (NDI_UNIQUE, 0, op, "You feel more transparent!");
410 408
411 update_object (op, UP_OBJ_FACE); 409 update_object (op, UP_OBJ_CHANGE);
412 410
413 /* Only search the active objects - only these should actually do 411 /* Only search the active objects - only these should actually do
414 * harm to the player. 412 * harm to the player.
415 */ 413 */
416 for (tmp = active_objects; tmp != NULL; tmp = tmp->active_next) 414 for_all_actives (tmp)
417 if (tmp->enemy == op) 415 if (tmp->enemy == op)
418 tmp->enemy = NULL; 416 tmp->enemy = 0;
417
419 return 1; 418 return 1;
420} 419}
421 420
422/* earth to dust spell. Basically destroys earthwalls in the area. 421/* earth to dust spell. Basically destroys earthwalls in the area.
423 */ 422 */
566} 565}
567 566
568int 567int
569perceive_self (object *op) 568perceive_self (object *op)
570{ 569{
570 char buf[MAX_BUF];
571 char *cp = describe_item (op, op), buf[MAX_BUF]; 571 const char *cp = describe_item (op, op);
572 archetype *at = archetype::find (ARCH_DEPLETION); 572 archetype *at = archetype::find (ARCH_DEPLETION);
573 object *tmp; 573 object *tmp;
574 int i; 574 int i;
575 575
576 tmp = find_god (determine_god (op)); 576 tmp = find_god (determine_god (op));
605 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 605 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
606 { 606 {
607 if (tmp->type == FORCE && !strcmp (tmp->arch->name, "dragon_ability_force")) 607 if (tmp->type == FORCE && !strcmp (tmp->arch->name, "dragon_ability_force"))
608 { 608 {
609 if (tmp->stats.exp == 0) 609 if (tmp->stats.exp == 0)
610 {
611 sprintf (buf, "Your metabolism isn't focused on anything."); 610 sprintf (buf, "Your metabolism isn't focused on anything.");
612 }
613 else 611 else
614 {
615 sprintf (buf, "Your metabolism is focused on %s.", change_resist_msg[tmp->stats.exp]); 612 sprintf (buf, "Your metabolism is focused on %s.", change_resist_msg[tmp->stats.exp]);
616 } 613
617 new_draw_info (NDI_UNIQUE, 0, op, buf); 614 new_draw_info (NDI_UNIQUE, 0, op, buf);
618 break; 615 break;
619 } 616 }
620 } 617 }
621 } 618 }
619
622 return 1; 620 return 1;
623} 621}
624 622
625/* int cast_create_town_portal (object *op, object *caster, int dir) 623/* int cast_create_town_portal (object *op, object *caster, int dir)
626 * 624 *
1163 object *poison; 1161 object *poison;
1164 int heal = 0, success = 0; 1162 int heal = 0, success = 0;
1165 1163
1166 tmp = find_target_for_friendly_spell (op, dir); 1164 tmp = find_target_for_friendly_spell (op, dir);
1167 1165
1168 if (tmp == NULL) 1166 if (!tmp)
1169 return 0; 1167 return 0;
1170 1168
1171 /* Figure out how many hp this spell might cure. 1169 /* Figure out how many hp this spell might cure.
1172 * could be zero if this spell heals effects, not damage. 1170 * could be zero if this spell heals effects, not damage.
1173 */ 1171 */
1176 heal += random_roll (spell->stats.hp, 6, op, PREFER_HIGH) + spell->stats.hp; 1174 heal += random_roll (spell->stats.hp, 6, op, PREFER_HIGH) + spell->stats.hp;
1177 1175
1178 if (heal) 1176 if (heal)
1179 { 1177 {
1180 if (tmp->stats.hp >= tmp->stats.maxhp) 1178 if (tmp->stats.hp >= tmp->stats.maxhp)
1181 {
1182 new_draw_info (NDI_UNIQUE, 0, tmp, "You are already fully healed."); 1179 new_draw_info (NDI_UNIQUE, 0, tmp, "You are already fully healed.");
1183 }
1184 else 1180 else
1185 { 1181 {
1186 /* See how many points we actually heal. Instead of messages 1182 /* See how many points we actually heal. Instead of messages
1187 * based on type of spell, we instead do messages based 1183 * based on type of spell, we instead do messages based
1188 * on amount of damage healed. 1184 * on amount of damage healed.
1190 if (heal > (tmp->stats.maxhp - tmp->stats.hp)) 1186 if (heal > (tmp->stats.maxhp - tmp->stats.hp))
1191 heal = tmp->stats.maxhp - tmp->stats.hp; 1187 heal = tmp->stats.maxhp - tmp->stats.hp;
1192 tmp->stats.hp += heal; 1188 tmp->stats.hp += heal;
1193 1189
1194 if (tmp->stats.hp >= tmp->stats.maxhp) 1190 if (tmp->stats.hp >= tmp->stats.maxhp)
1195 {
1196 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel just fine!"); 1191 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel just fine!");
1197 }
1198 else if (heal > 50) 1192 else if (heal > 50)
1199 {
1200 new_draw_info (NDI_UNIQUE, 0, tmp, "Your wounds close!"); 1193 new_draw_info (NDI_UNIQUE, 0, tmp, "Your wounds close!");
1201 }
1202 else if (heal > 25) 1194 else if (heal > 25)
1203 {
1204 new_draw_info (NDI_UNIQUE, 0, tmp, "Your wounds mostly close."); 1195 new_draw_info (NDI_UNIQUE, 0, tmp, "Your wounds mostly close.");
1205 }
1206 else if (heal > 10) 1196 else if (heal > 10)
1207 {
1208 new_draw_info (NDI_UNIQUE, 0, tmp, "Your wounds start to fade."); 1197 new_draw_info (NDI_UNIQUE, 0, tmp, "Your wounds start to fade.");
1209 }
1210 else 1198 else
1211 {
1212 new_draw_info (NDI_UNIQUE, 0, tmp, "Your wounds start to close."); 1199 new_draw_info (NDI_UNIQUE, 0, tmp, "Your wounds start to close.");
1213 } 1200
1214 success = 1; 1201 success = 1;
1215 } 1202 }
1216 } 1203 }
1204
1217 if (spell->attacktype & AT_DISEASE) 1205 if (spell->attacktype & AT_DISEASE)
1218 if (cure_disease (tmp, op)) 1206 if (cure_disease (tmp, op))
1219 success = 1; 1207 success = 1;
1220 1208
1221 if (spell->attacktype & AT_POISON) 1209 if (spell->attacktype & AT_POISON)
1227 success = 1; 1215 success = 1;
1228 new_draw_info (NDI_UNIQUE, 0, tmp, "Your body feels cleansed"); 1216 new_draw_info (NDI_UNIQUE, 0, tmp, "Your body feels cleansed");
1229 poison->stats.food = 1; 1217 poison->stats.food = 1;
1230 } 1218 }
1231 } 1219 }
1220
1232 if (spell->attacktype & AT_CONFUSION) 1221 if (spell->attacktype & AT_CONFUSION)
1233 { 1222 {
1234 poison = present_in_ob_by_name (FORCE, "confusion", tmp); 1223 poison = present_in_ob_by_name (FORCE, "confusion", tmp);
1235 if (poison) 1224 if (poison)
1236 { 1225 {
1237 success = 1; 1226 success = 1;
1238 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 1227 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
1239 poison->duration = 1; 1228 poison->duration = 1;
1240 } 1229 }
1241 } 1230 }
1231
1242 if (spell->attacktype & AT_BLIND) 1232 if (spell->attacktype & AT_BLIND)
1243 { 1233 {
1244 at = archetype::find ("blindness"); 1234 at = archetype::find ("blindness");
1245 poison = present_arch_in_ob (at, tmp); 1235 poison = present_arch_in_ob (at, tmp);
1246 if (poison) 1236 if (poison)
1248 success = 1; 1238 success = 1;
1249 new_draw_info (NDI_UNIQUE, 0, tmp, "Your vision begins to return."); 1239 new_draw_info (NDI_UNIQUE, 0, tmp, "Your vision begins to return.");
1250 poison->stats.food = 1; 1240 poison->stats.food = 1;
1251 } 1241 }
1252 } 1242 }
1243
1253 if (spell->last_sp && tmp->stats.sp < tmp->stats.maxsp) 1244 if (spell->last_sp && tmp->stats.sp < tmp->stats.maxsp)
1254 { 1245 {
1255 tmp->stats.sp += spell->last_sp; 1246 tmp->stats.sp += spell->last_sp;
1256 if (tmp->stats.sp > tmp->stats.maxsp) 1247 if (tmp->stats.sp > tmp->stats.maxsp)
1257 tmp->stats.sp = tmp->stats.maxsp; 1248 tmp->stats.sp = tmp->stats.maxsp;
1258 success = 1; 1249 success = 1;
1259 new_draw_info (NDI_UNIQUE, 0, tmp, "Magical energy surges through your body!"); 1250 new_draw_info (NDI_UNIQUE, 0, tmp, "Magical energy surges through your body!");
1260 } 1251 }
1252
1261 if (spell->last_grace && tmp->stats.grace < tmp->stats.maxgrace) 1253 if (spell->last_grace && tmp->stats.grace < tmp->stats.maxgrace)
1262 { 1254 {
1263 tmp->stats.grace += spell->last_grace; 1255 tmp->stats.grace += spell->last_grace;
1264 if (tmp->stats.grace > tmp->stats.maxgrace) 1256 if (tmp->stats.grace > tmp->stats.maxgrace)
1265 tmp->stats.grace = tmp->stats.maxgrace; 1257 tmp->stats.grace = tmp->stats.maxgrace;
1266 success = 1; 1258 success = 1;
1267 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel redeemed with your god!"); 1259 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel redeemed with your god!");
1268 } 1260 }
1261
1269 if (spell->stats.food && tmp->stats.food < 999) 1262 if (spell->stats.food && tmp->stats.food < 999)
1270 { 1263 {
1271 tmp->stats.food += spell->stats.food; 1264 tmp->stats.food += spell->stats.food;
1272 if (tmp->stats.food > 999) 1265 if (tmp->stats.food > 999)
1273 tmp->stats.food = 999; 1266 tmp->stats.food = 999;
1274 success = 1; 1267 success = 1;
1275 /* We could do something a bit better like the messages for healing above */ 1268 /* We could do something a bit better like the messages for healing above */
1276 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel your belly fill with food"); 1269 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel your belly fill with food");
1277 } 1270 }
1271
1278 return success; 1272 return success;
1279} 1273}
1280 1274
1281 1275
1282/* This is used for the spells that gain stats. There are no spells 1276/* This is used for the spells that gain stats. There are no spells
1530 change_abil (tmp, force); /* Mostly to display any messages */ 1524 change_abil (tmp, force); /* Mostly to display any messages */
1531 insert_ob_in_ob (force, tmp); 1525 insert_ob_in_ob (force, tmp);
1532 tmp->update_stats (); 1526 tmp->update_stats ();
1533 return 1; 1527 return 1;
1534} 1528}
1535
1536
1537 1529
1538/* Alchemy code by Mark Wedel 1530/* Alchemy code by Mark Wedel
1539 * 1531 *
1540 * This code adds a new spell, called alchemy. Alchemy will turn 1532 * This code adds a new spell, called alchemy. Alchemy will turn
1541 * objects to gold nuggets, the value of the gold nuggets being 1533 * objects to gold nuggets, the value of the gold nuggets being
1551 * For example, if an item is worth 110 gold, you will get 1543 * For example, if an item is worth 110 gold, you will get
1552 * 4 large nuggets, and from 0-10 small nuggets. 1544 * 4 large nuggets, and from 0-10 small nuggets.
1553 * 1545 *
1554 * There is also a chance (1:30) that you will get nothing at all 1546 * There is also a chance (1:30) that you will get nothing at all
1555 * for the object. There is also a maximum weight that will be 1547 * for the object. There is also a maximum weight that will be
1556 * alchemied. 1548 * alchemised.
1557 */ 1549 */
1558
1559/* I didn't feel like passing these as arguements to the
1560 * two functions that need them. Real values are put in them
1561 * when the spell is cast, and these are freed when the spell
1562 * is finished.
1563 */
1564static object *small, *large;
1565
1566static void 1550static void
1567alchemy_object (object *obj, int *small_nuggets, int *large_nuggets, int *weight) 1551alchemy_object (object *obj, uint64 &total_value, int &total_weight)
1568{ 1552{
1569 uint64 value = query_cost (obj, NULL, F_TRUE); 1553 uint64 value = query_cost (obj, NULL, F_TRUE);
1570 1554
1571 /* Give third price when we alchemy money (This should hopefully 1555 /* Give third price when we alchemy money (This should hopefully
1572 * make it so that it isn't worth it to alchemy money, sell 1556 * make it so that it isn't worth it to alchemy money, sell
1573 * the nuggets, alchemy the gold from that, etc. 1557 * the nuggets, alchemy the gold from that, etc.
1574 * Otherwise, give 9 silver on the gold for other objects, 1558 * Otherwise, give 9 silver on the gold for other objects,
1575 * so that it would still be more affordable to haul 1559 * so that it would still be more affordable to haul
1576 * the stuff back to town. 1560 * the stuff back to town.
1577 */ 1561 */
1578
1579 if (QUERY_FLAG (obj, FLAG_UNPAID)) 1562 if (QUERY_FLAG (obj, FLAG_UNPAID))
1580 value = 0; 1563 value = 0;
1581 else if (obj->type == MONEY || obj->type == GEM) 1564 else if (obj->type == MONEY || obj->type == GEM)
1582 value /= 3; 1565 value /= 3;
1583 else 1566 else
1584 value = (value * 9) / 10; 1567 value = value * 9 / 10;
1585 1568
1586 value /= 4; // fix by GHJ, don't understand, pcg
1587
1588 if ((obj->value > 0) && rndm (0, 29)) 1569 if (obj->value > 0 && rndm (0, 29))
1589 { 1570 total_value += value;
1590 int count;
1591 1571
1592 count = value / large->value;
1593 *large_nuggets += count;
1594 value -= (uint64) count *(uint64) large->value;
1595
1596 count = value / small->value;
1597 *small_nuggets += count;
1598 }
1599
1600 /* Turn 25 small nuggets into 1 large nugget. If the value
1601 * of large nuggets is not evenly divisable by the small nugget
1602 * value, take off an extra small_nugget (Assuming small_nuggets!=0)
1603 */
1604 if (*small_nuggets * small->value >= large->value)
1605 {
1606 (*large_nuggets)++;
1607 *small_nuggets -= large->value / small->value;
1608 if (*small_nuggets && large->value % small->value)
1609 (*small_nuggets)--;
1610 }
1611 weight += obj->weight; 1572 total_weight += obj->total_weight ();
1573
1612 obj->destroy (); 1574 obj->destroy ();
1613} 1575}
1614 1576
1615static void 1577static void
1616update_map (object *op, maptile *m, int small_nuggets, int large_nuggets, int x, int y) 1578update_map (object *op, maptile *m, int small_nuggets, object *small, int large_nuggets, object *large, int x, int y)
1617{ 1579{
1618 object *tmp;
1619 int flag = 0; 1580 int flag = 0;
1620 1581
1621 /* Put any nuggets below the player, but we can only pass this 1582 /* Put any nuggets below the player, but we can only pass this
1622 * flag if we are on the same space as the player 1583 * flag if we are on the same space as the player
1623 */ 1584 */
1624 if (x == op->x && y == op->y && op->map == m) 1585 if (x == op->x && y == op->y && op->map == m)
1625 flag = INS_BELOW_ORIGINATOR; 1586 flag = INS_BELOW_ORIGINATOR;
1626 1587
1627 if (small_nuggets) 1588 if (small_nuggets)
1628 { 1589 {
1629 tmp = small->clone (); 1590 object *tmp = small->clone ();
1630 tmp->nrof = small_nuggets; 1591 tmp->nrof = small_nuggets;
1631 m->insert (tmp, x, y, op, flag); 1592 m->insert (tmp, x, y, op, flag);
1632 } 1593 }
1633 1594
1634 if (large_nuggets) 1595 if (large_nuggets)
1635 { 1596 {
1636 tmp = large->clone (); 1597 object *tmp = large->clone ();
1637 tmp->nrof = large_nuggets; 1598 tmp->nrof = large_nuggets;
1638 m->insert (tmp, x, y, op, flag); 1599 m->insert (tmp, x, y, op, flag);
1639 } 1600 }
1601
1602 if (object *pl = m->at (x, y).player ())
1603 if (pl->contr->ns)
1604 pl->contr->ns->look_position = 0;
1640} 1605}
1641 1606
1642int 1607int
1643alchemy (object *op, object *caster, object *spell_ob) 1608alchemy (object *op, object *caster, object *spell_ob)
1644{ 1609{
1645 int x, y, weight = 0, weight_max, large_nuggets, small_nuggets, mflags;
1646 sint16 nx, ny;
1647 object *next, *tmp;
1648 maptile *mp;
1649
1650 if (op->type != PLAYER) 1610 if (op->type != PLAYER)
1651 return 0; 1611 return 0;
1652 1612
1613 object *large = get_archetype ("largenugget");
1614 object *small = get_archetype ("smallnugget");
1615
1653 /* Put a maximum weight of items that can be alchemied. Limits the power 1616 /* Put a maximum weight of items that can be alchemised. Limits the power
1654 * some, and also prevents people from alcheming every table/chair/clock 1617 * some, and also prevents people from alchemising every table/chair/clock
1655 * in sight 1618 * in sight
1656 */ 1619 */
1657 weight_max = spell_ob->duration + +SP_level_duration_adjust (caster, spell_ob); 1620 int duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
1658 weight_max *= 1000; 1621 int weight_max = duration * 1000;
1659 small = get_archetype ("smallnugget"), large = get_archetype ("largenugget"); 1622 uint64 value_max = duration * 1000;
1660 1623
1624 int weight = 0;
1625
1661 for (y = op->y - 1; y <= op->y + 1; y++) 1626 for (int y = op->y - 1; y <= op->y + 1; y++)
1662 { 1627 {
1663 for (x = op->x - 1; x <= op->x + 1; x++) 1628 for (int x = op->x - 1; x <= op->x + 1; x++)
1664 { 1629 {
1630 uint64 value = 0;
1631
1665 nx = x; 1632 sint16 nx = x;
1666 ny = y; 1633 sint16 ny = y;
1667 1634
1668 mp = op->map; 1635 maptile *mp = op->map;
1669 1636
1670 mflags = get_map_flags (mp, &mp, nx, ny, &nx, &ny); 1637 int mflags = get_map_flags (mp, &mp, nx, ny, &nx, &ny);
1671 1638
1672 if (mflags & (P_OUT_OF_MAP | P_NO_MAGIC)) 1639 if (mflags & (P_OUT_OF_MAP | P_NO_MAGIC))
1673 continue; 1640 continue;
1674 1641
1675 /* Treat alchemy a little differently - most spell effects 1642 /* Treat alchemy a little differently - most spell effects
1677 * ground level effect. 1644 * ground level effect.
1678 */ 1645 */
1679 if (GET_MAP_MOVE_BLOCK (mp, nx, ny) & MOVE_WALK) 1646 if (GET_MAP_MOVE_BLOCK (mp, nx, ny) & MOVE_WALK)
1680 continue; 1647 continue;
1681 1648
1682 small_nuggets = 0; 1649 for (object *next, *tmp = mp->at (nx, ny).bot; tmp; tmp = next)
1683 large_nuggets = 0;
1684
1685 for (tmp = GET_MAP_OB (mp, nx, ny); tmp != NULL; tmp = next)
1686 { 1650 {
1687 next = tmp->above; 1651 next = tmp->above;
1652
1688 if (tmp->weight > 0 && !QUERY_FLAG (tmp, FLAG_NO_PICK) && 1653 if (tmp->weight > 0 && !QUERY_FLAG (tmp, FLAG_NO_PICK) &&
1689 !QUERY_FLAG (tmp, FLAG_ALIVE) && !QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) 1654 !QUERY_FLAG (tmp, FLAG_ALIVE) && !QUERY_FLAG (tmp, FLAG_IS_CAULDRON))
1690 { 1655 {
1691
1692 if (tmp->inv) 1656 if (tmp->inv)
1693 { 1657 {
1694 object *next1, *tmp1; 1658 object *next1, *tmp1;
1695 1659
1696 for (tmp1 = tmp->inv; tmp1 != NULL; tmp1 = next1) 1660 for (tmp1 = tmp->inv; tmp1; tmp1 = next1)
1697 { 1661 {
1698 next1 = tmp1->below; 1662 next1 = tmp1->below;
1699 if (tmp1->weight > 0 && !QUERY_FLAG (tmp1, FLAG_NO_PICK) && 1663 if (tmp1->weight > 0 && !QUERY_FLAG (tmp1, FLAG_NO_PICK) &&
1700 !QUERY_FLAG (tmp1, FLAG_ALIVE) && !QUERY_FLAG (tmp1, FLAG_IS_CAULDRON)) 1664 !QUERY_FLAG (tmp1, FLAG_ALIVE) && !QUERY_FLAG (tmp1, FLAG_IS_CAULDRON))
1701 alchemy_object (tmp1, &small_nuggets, &large_nuggets, &weight); 1665 alchemy_object (tmp1, value, weight);
1702 } 1666 }
1703 } 1667 }
1668
1704 alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight); 1669 alchemy_object (tmp, value, weight);
1705 1670
1706 if (weight > weight_max) 1671 if (weight > weight_max)
1707 { 1672 break;
1708 update_map (op, mp, small_nuggets, large_nuggets, nx, ny);
1709 large->destroy ();
1710 small->destroy ();
1711 return 1;
1712 } 1673 }
1713 } /* is alchemable object */ 1674 }
1714 } /* process all objects on this space */ 1675
1676 value = min (value, value_max);
1677
1678 uint64 count = value / large->value;
1679 int large_nuggets = count;
1680 value -= count * large->value;
1681
1682 count = value / small->value;
1683 int small_nuggets = count;
1715 1684
1716 /* Insert all the nuggets at one time. This probably saves time, but 1685 /* Insert all the nuggets at one time. This probably saves time, but
1717 * it also prevents us from alcheming nuggets that were just created 1686 * it also prevents us from alcheming nuggets that were just created
1718 * with this spell. 1687 * with this spell.
1719 */ 1688 */
1720 update_map (op, mp, small_nuggets, large_nuggets, nx, ny); 1689 update_map (op, mp, small_nuggets, small, large_nuggets, large, nx, ny);
1721 }
1722 }
1723 1690
1691 if (weight > weight_max)
1692 goto bailout;
1693 }
1694 }
1695
1696bailout:
1724 large->destroy (); 1697 large->destroy ();
1725 small->destroy (); 1698 small->destroy ();
1726 /* reset this so that if player standing on a big pile of stuff,
1727 * it is redrawn properly.
1728 */
1729 op->contr->ns->look_position = 0;
1730 return 1; 1699 return 1;
1731} 1700}
1732 1701
1733 1702
1734/* This function removes the cursed/damned status on equipped 1703/* This function removes the cursed/damned status on equipped
1761 } 1730 }
1762 1731
1763 if (op->type == PLAYER) 1732 if (op->type == PLAYER)
1764 { 1733 {
1765 if (success) 1734 if (success)
1766 {
1767 new_draw_info (NDI_UNIQUE, 0, op, "You feel like some of your items are looser now."); 1735 new_draw_info (NDI_UNIQUE, 0, op, "You feel like some of your items are looser now.");
1768 }
1769 else 1736 else
1770 { 1737 {
1771 if (was_one) 1738 if (was_one)
1772 new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse."); 1739 new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse.");
1773 else 1740 else
2186 /* Basically, if the object is magical and not counterspell, 2153 /* Basically, if the object is magical and not counterspell,
2187 * we will more or less remove the object. Don't counterspell 2154 * we will more or less remove the object. Don't counterspell
2188 * monsters either. 2155 * monsters either.
2189 */ 2156 */
2190 2157
2191 if (head->attacktype & AT_MAGIC && 2158 if (head->attacktype & AT_MAGIC
2192 !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level)) 2159 && !(head->attacktype & AT_COUNTERSPELL)
2160 && !QUERY_FLAG (head, FLAG_MONSTER)
2161 && (op->level > head->level))
2193 head->destroy (); 2162 head->destroy ();
2194 else 2163 else
2195 switch (head->type) 2164 switch (head->type)
2196 { 2165 {
2197 case SPELL_EFFECT: 2166 case SPELL_EFFECT:
2167 // XXX: Don't affect floor spelleffects. See also XXX comment
2168 // about sanctuary in spell_util.C
2169 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
2170 continue;
2171
2198 if (op->level > head->level) 2172 if (op->level > head->level)
2199 head->destroy (); 2173 head->destroy ();
2200 2174
2201 break; 2175 break;
2202 2176
2349 /* create the golem object */ 2323 /* create the golem object */
2350 tmp = arch_to_object (spell->other_arch); 2324 tmp = arch_to_object (spell->other_arch);
2351 2325
2352 /* if animated by a player, give the player control of the golem */ 2326 /* if animated by a player, give the player control of the golem */
2353 CLEAR_FLAG (tmp, FLAG_MONSTER); 2327 CLEAR_FLAG (tmp, FLAG_MONSTER);
2354 SET_FLAG (tmp, FLAG_FRIENDLY);
2355 tmp->stats.exp = 0; 2328 tmp->stats.exp = 0;
2356 add_friendly_object (tmp); 2329 add_friendly_object (tmp);
2357 tmp->type = GOLEM; 2330 tmp->type = GOLEM;
2358 tmp->set_owner (op); 2331 tmp->set_owner (op);
2359 set_spell_skill (op, caster, spell, tmp); 2332 set_spell_skill (op, caster, spell, tmp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines