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.37 by root, Tue Feb 6 03:21:20 2007 UTC vs.
Revision 1.50 by root, Sat May 12 08:36:35 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
7 * 7 *
154 /* If it starts with a letter, presume it is a description */ 154 /* If it starts with a letter, presume it is a description */
155 if (isalpha (*stringarg)) 155 if (isalpha (*stringarg))
156 { 156 {
157 artifact *al = find_artifactlist (missile->type)->items; 157 artifact *al = find_artifactlist (missile->type)->items;
158 158
159 for (; al != NULL; al = al->next) 159 for (; al; al = al->next)
160 if (!strcasecmp (al->item->name, stringarg)) 160 if (!strcasecmp (al->item->name, stringarg))
161 break; 161 break;
162 162
163 if (!al) 163 if (!al)
164 { 164 {
373 * normal applies. 373 * normal applies.
374 */ 374 */
375int 375int
376cast_invisible (object *op, object *caster, object *spell_ob) 376cast_invisible (object *op, object *caster, object *spell_ob)
377{ 377{
378 object *tmp;
379
380 if (op->invisible > 1000) 378 if (op->invisible > 1000)
381 { 379 {
382 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");
383 return 0; 381 return 0;
384 } 382 }
400 else 398 else
401 op->contr->tmp_invis = 1; 399 op->contr->tmp_invis = 1;
402 400
403 op->contr->hidden = 0; 401 op->contr->hidden = 0;
404 } 402 }
403
405 if (makes_invisible_to (op, op)) 404 if (makes_invisible_to (op, op))
406 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!");
407 else 406 else
408 new_draw_info (NDI_UNIQUE, 0, op, "You feel more transparent!"); 407 new_draw_info (NDI_UNIQUE, 0, op, "You feel more transparent!");
409 408
410 update_object (op, UP_OBJ_FACE); 409 update_object (op, UP_OBJ_CHANGE);
411 410
412 /* Only search the active objects - only these should actually do 411 /* Only search the active objects - only these should actually do
413 * harm to the player. 412 * harm to the player.
414 */ 413 */
415 for_all_actives (tmp) 414 for_all_actives (tmp)
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));
678 */ 678 */
679 dummy->name = op->map->path; 679 dummy->name = op->map->path;
680 EXIT_X (dummy) = op->x; 680 EXIT_X (dummy) = op->x;
681 EXIT_Y (dummy) = op->y; 681 EXIT_Y (dummy) = op->y;
682 insert_ob_in_ob (dummy, op); 682 insert_ob_in_ob (dummy, op);
683 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You fix this place in your mind.\nYou feel you are able to come here from anywhere."); 683 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You fix this place in your mind. You feel you are able to come here from anywhere.");
684 return 1; 684 return 1;
685 } 685 }
686 686
687 dummy->destroy (); 687 dummy->destroy ();
688 688
760 exitmap = maptile::find_sync (force->name); 760 exitmap = maptile::find_sync (force->name);
761 761
762 /* If we were unable to load (ex. random map deleted), warn player */ 762 /* If we were unable to load (ex. random map deleted), warn player */
763 if (!exitmap) 763 if (!exitmap)
764 { 764 {
765 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?"); 765 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens. You can't remember where to go!?");
766 force->destroy (); 766 force->destroy ();
767 return 1; 767 return 1;
768 } 768 }
769 769
770 exitmap->load_sync (); 770 exitmap->load_sync ();
771 771
772 op_level = caster_level (caster, spell); 772 op_level = caster_level (caster, spell);
773 if (op_level < 15) 773 if (op_level < 15)
774 snprintf (portal_message, 1024, 774 snprintf (portal_message, 1024,
775 "\nThe air moves around you and\na huge smell of ammonia\nsurounds you as you pass\nthrough %s's tiny portal\nPouah!\n", 775 "The air moves around you and a huge smell of ammonia surounds you as you pass through %s's tiny portal. Pouah!\n",
776 &op->name); 776 &op->name);
777 else if (op_level < 30) 777 else if (op_level < 30)
778 snprintf (portal_message, 1024, 778 snprintf (portal_message, 1024,
779 "\n%s's portal smells of ozone.\nYou do a lot of movements and finally pass\nthrough the small hole in the air\n", &op->name); 779 "%s's portal smells of ozone. You do a lot of movements and finally pass through the small hole in the air\n", &op->name);
780 else if (op_level < 60) 780 else if (op_level < 60)
781 snprintf (portal_message, 1024, "\nA shining door opens in the air in front of you,\nshowing you the path to another place.\n"); 781 snprintf (portal_message, 1024, "A shining door opens in the air in front of you, showing you the path to another place.\n");
782 else 782 else
783 snprintf (portal_message, 1024, "\nAs you walk through %s's portal, flowers come out\nfrom the ground around you.\nYou feel awed.\n", 783 snprintf (portal_message, 1024, "As you walk through %s's portal, flowers come out from the ground around you. You feel awed.\n",
784 &op->name); 784 &op->name);
785 785
786 /* Create a portal in front of player 786 /* Create a portal in front of player
787 * dummy contain the portal and 787 * dummy contain the portal and
788 * force contain the track to kill it later 788 * force contain the track to kill it later
1161 object *poison; 1161 object *poison;
1162 int heal = 0, success = 0; 1162 int heal = 0, success = 0;
1163 1163
1164 tmp = find_target_for_friendly_spell (op, dir); 1164 tmp = find_target_for_friendly_spell (op, dir);
1165 1165
1166 if (tmp == NULL) 1166 if (!tmp)
1167 return 0; 1167 return 0;
1168 1168
1169 /* Figure out how many hp this spell might cure. 1169 /* Figure out how many hp this spell might cure.
1170 * could be zero if this spell heals effects, not damage. 1170 * could be zero if this spell heals effects, not damage.
1171 */ 1171 */
1174 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;
1175 1175
1176 if (heal) 1176 if (heal)
1177 { 1177 {
1178 if (tmp->stats.hp >= tmp->stats.maxhp) 1178 if (tmp->stats.hp >= tmp->stats.maxhp)
1179 {
1180 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.");
1181 }
1182 else 1180 else
1183 { 1181 {
1184 /* See how many points we actually heal. Instead of messages 1182 /* See how many points we actually heal. Instead of messages
1185 * based on type of spell, we instead do messages based 1183 * based on type of spell, we instead do messages based
1186 * on amount of damage healed. 1184 * on amount of damage healed.
1188 if (heal > (tmp->stats.maxhp - tmp->stats.hp)) 1186 if (heal > (tmp->stats.maxhp - tmp->stats.hp))
1189 heal = tmp->stats.maxhp - tmp->stats.hp; 1187 heal = tmp->stats.maxhp - tmp->stats.hp;
1190 tmp->stats.hp += heal; 1188 tmp->stats.hp += heal;
1191 1189
1192 if (tmp->stats.hp >= tmp->stats.maxhp) 1190 if (tmp->stats.hp >= tmp->stats.maxhp)
1193 {
1194 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel just fine!"); 1191 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel just fine!");
1195 }
1196 else if (heal > 50) 1192 else if (heal > 50)
1197 {
1198 new_draw_info (NDI_UNIQUE, 0, tmp, "Your wounds close!"); 1193 new_draw_info (NDI_UNIQUE, 0, tmp, "Your wounds close!");
1199 }
1200 else if (heal > 25) 1194 else if (heal > 25)
1201 {
1202 new_draw_info (NDI_UNIQUE, 0, tmp, "Your wounds mostly close."); 1195 new_draw_info (NDI_UNIQUE, 0, tmp, "Your wounds mostly close.");
1203 }
1204 else if (heal > 10) 1196 else if (heal > 10)
1205 {
1206 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.");
1207 }
1208 else 1198 else
1209 {
1210 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.");
1211 } 1200
1212 success = 1; 1201 success = 1;
1213 } 1202 }
1214 } 1203 }
1204
1215 if (spell->attacktype & AT_DISEASE) 1205 if (spell->attacktype & AT_DISEASE)
1216 if (cure_disease (tmp, op)) 1206 if (cure_disease (tmp, op))
1217 success = 1; 1207 success = 1;
1218 1208
1219 if (spell->attacktype & AT_POISON) 1209 if (spell->attacktype & AT_POISON)
1225 success = 1; 1215 success = 1;
1226 new_draw_info (NDI_UNIQUE, 0, tmp, "Your body feels cleansed"); 1216 new_draw_info (NDI_UNIQUE, 0, tmp, "Your body feels cleansed");
1227 poison->stats.food = 1; 1217 poison->stats.food = 1;
1228 } 1218 }
1229 } 1219 }
1220
1230 if (spell->attacktype & AT_CONFUSION) 1221 if (spell->attacktype & AT_CONFUSION)
1231 { 1222 {
1232 poison = present_in_ob_by_name (FORCE, "confusion", tmp); 1223 poison = present_in_ob_by_name (FORCE, "confusion", tmp);
1233 if (poison) 1224 if (poison)
1234 { 1225 {
1235 success = 1; 1226 success = 1;
1236 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 1227 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
1237 poison->duration = 1; 1228 poison->duration = 1;
1238 } 1229 }
1239 } 1230 }
1231
1240 if (spell->attacktype & AT_BLIND) 1232 if (spell->attacktype & AT_BLIND)
1241 { 1233 {
1242 at = archetype::find ("blindness"); 1234 at = archetype::find ("blindness");
1243 poison = present_arch_in_ob (at, tmp); 1235 poison = present_arch_in_ob (at, tmp);
1244 if (poison) 1236 if (poison)
1246 success = 1; 1238 success = 1;
1247 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.");
1248 poison->stats.food = 1; 1240 poison->stats.food = 1;
1249 } 1241 }
1250 } 1242 }
1243
1251 if (spell->last_sp && tmp->stats.sp < tmp->stats.maxsp) 1244 if (spell->last_sp && tmp->stats.sp < tmp->stats.maxsp)
1252 { 1245 {
1253 tmp->stats.sp += spell->last_sp; 1246 tmp->stats.sp += spell->last_sp;
1254 if (tmp->stats.sp > tmp->stats.maxsp) 1247 if (tmp->stats.sp > tmp->stats.maxsp)
1255 tmp->stats.sp = tmp->stats.maxsp; 1248 tmp->stats.sp = tmp->stats.maxsp;
1256 success = 1; 1249 success = 1;
1257 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!");
1258 } 1251 }
1252
1259 if (spell->last_grace && tmp->stats.grace < tmp->stats.maxgrace) 1253 if (spell->last_grace && tmp->stats.grace < tmp->stats.maxgrace)
1260 { 1254 {
1261 tmp->stats.grace += spell->last_grace; 1255 tmp->stats.grace += spell->last_grace;
1262 if (tmp->stats.grace > tmp->stats.maxgrace) 1256 if (tmp->stats.grace > tmp->stats.maxgrace)
1263 tmp->stats.grace = tmp->stats.maxgrace; 1257 tmp->stats.grace = tmp->stats.maxgrace;
1264 success = 1; 1258 success = 1;
1265 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!");
1266 } 1260 }
1261
1267 if (spell->stats.food && tmp->stats.food < 999) 1262 if (spell->stats.food && tmp->stats.food < 999)
1268 { 1263 {
1269 tmp->stats.food += spell->stats.food; 1264 tmp->stats.food += spell->stats.food;
1270 if (tmp->stats.food > 999) 1265 if (tmp->stats.food > 999)
1271 tmp->stats.food = 999; 1266 tmp->stats.food = 999;
1272 success = 1; 1267 success = 1;
1273 /* 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 */
1274 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");
1275 } 1270 }
1271
1276 return success; 1272 return success;
1277} 1273}
1278 1274
1279 1275
1280/* 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
1528 change_abil (tmp, force); /* Mostly to display any messages */ 1524 change_abil (tmp, force); /* Mostly to display any messages */
1529 insert_ob_in_ob (force, tmp); 1525 insert_ob_in_ob (force, tmp);
1530 tmp->update_stats (); 1526 tmp->update_stats ();
1531 return 1; 1527 return 1;
1532} 1528}
1533
1534
1535 1529
1536/* Alchemy code by Mark Wedel 1530/* Alchemy code by Mark Wedel
1537 * 1531 *
1538 * This code adds a new spell, called alchemy. Alchemy will turn 1532 * This code adds a new spell, called alchemy. Alchemy will turn
1539 * objects to gold nuggets, the value of the gold nuggets being 1533 * objects to gold nuggets, the value of the gold nuggets being
1551 * 1545 *
1552 * 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
1553 * 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
1554 * alchemised. 1548 * alchemised.
1555 */ 1549 */
1556
1557/* I didn't feel like passing these as argumeents to the
1558 * two functions that need them. Real values are put in them
1559 * when the spell is cast, and these are freed when the spell
1560 * is finished.
1561 */
1562static object *small, *large;
1563
1564static void 1550static void
1565alchemy_object (object *obj, int *small_nuggets, int *large_nuggets, int *weight) 1551alchemy_object (object *obj, uint64 &total_value, int &total_weight)
1566{ 1552{
1567 uint64 value = query_cost (obj, NULL, F_TRUE); 1553 uint64 value = query_cost (obj, NULL, F_TRUE);
1568 1554
1569 /* Give third price when we alchemy money (This should hopefully 1555 /* Give third price when we alchemy money (This should hopefully
1570 * 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
1571 * the nuggets, alchemy the gold from that, etc. 1557 * the nuggets, alchemy the gold from that, etc.
1572 * Otherwise, give 9 silver on the gold for other objects, 1558 * Otherwise, give 9 silver on the gold for other objects,
1573 * so that it would still be more affordable to haul 1559 * so that it would still be more affordable to haul
1574 * the stuff back to town. 1560 * the stuff back to town.
1575 */ 1561 */
1576
1577 if (QUERY_FLAG (obj, FLAG_UNPAID)) 1562 if (QUERY_FLAG (obj, FLAG_UNPAID))
1578 value = 0; 1563 value = 0;
1579 else if (obj->type == MONEY || obj->type == GEM) 1564 else if (obj->type == MONEY || obj->type == GEM)
1580 value /= 3; 1565 value /= 3;
1581 else 1566 else
1582 value = (value * 9) / 10; 1567 value = value * 9 / 10;
1583
1584 value /= 4; // fix by GHJ, don't understand, pcg
1585 1568
1586 if (obj->value > 0 && rndm (0, 29)) 1569 if (obj->value > 0 && rndm (0, 29))
1587 { 1570 total_value += value;
1588 int count;
1589 1571
1590 count = value / large->value;
1591 *large_nuggets += count;
1592 value -= (uint64) count *(uint64) large->value;
1593
1594 count = value / small->value;
1595 *small_nuggets += count;
1596 }
1597
1598 /* Turn 25 small nuggets into 1 large nugget. If the value
1599 * of large nuggets is not evenly divisable by the small nugget
1600 * value, take off an extra small_nugget (Assuming small_nuggets!=0)
1601 */
1602 if (*small_nuggets * small->value >= large->value)
1603 {
1604 (*large_nuggets)++;
1605 *small_nuggets -= large->value / small->value;
1606 if (*small_nuggets && large->value % small->value)
1607 (*small_nuggets)--;
1608 }
1609
1610 weight += obj->weight; 1572 total_weight += obj->total_weight ();
1573
1611 obj->destroy (); 1574 obj->destroy ();
1612} 1575}
1613 1576
1614static void 1577static void
1615update_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)
1616{ 1579{
1617 object *tmp;
1618 int flag = 0; 1580 int flag = 0;
1619 1581
1620 /* 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
1621 * flag if we are on the same space as the player 1583 * flag if we are on the same space as the player
1622 */ 1584 */
1623 if (x == op->x && y == op->y && op->map == m) 1585 if (x == op->x && y == op->y && op->map == m)
1624 flag = INS_BELOW_ORIGINATOR; 1586 flag = INS_BELOW_ORIGINATOR;
1625 1587
1626 if (small_nuggets) 1588 if (small_nuggets)
1627 { 1589 {
1628 tmp = small->clone (); 1590 object *tmp = small->clone ();
1629 tmp->nrof = small_nuggets; 1591 tmp->nrof = small_nuggets;
1630 m->insert (tmp, x, y, op, flag); 1592 m->insert (tmp, x, y, op, flag);
1631 } 1593 }
1632 1594
1633 if (large_nuggets) 1595 if (large_nuggets)
1634 { 1596 {
1635 tmp = large->clone (); 1597 object *tmp = large->clone ();
1636 tmp->nrof = large_nuggets; 1598 tmp->nrof = large_nuggets;
1637 m->insert (tmp, x, y, op, flag); 1599 m->insert (tmp, x, y, op, flag);
1638 } 1600 }
1601
1602 if (object *pl = m->at (x, y).player ())
1603 if (pl->contr->ns)
1604 pl->contr->ns->look_position = 0;
1639} 1605}
1640 1606
1641int 1607int
1642alchemy (object *op, object *caster, object *spell_ob) 1608alchemy (object *op, object *caster, object *spell_ob)
1643{ 1609{
1644 int x, y, weight = 0, weight_max, large_nuggets, small_nuggets, mflags;
1645 sint16 nx, ny;
1646 object *next, *tmp;
1647 maptile *mp;
1648
1649 if (op->type != PLAYER) 1610 if (op->type != PLAYER)
1650 return 0; 1611 return 0;
1651 1612
1613 object *large = get_archetype ("largenugget");
1614 object *small = get_archetype ("smallnugget");
1615
1652 /* 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
1653 * some, and also prevents people from alcheming every table/chair/clock 1617 * some, and also prevents people from alchemising every table/chair/clock
1654 * in sight 1618 * in sight
1655 */ 1619 */
1656 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);
1657 weight_max *= 1000; 1621 int weight_max = duration * 1000;
1658 small = get_archetype ("smallnugget"), large = get_archetype ("largenugget"); 1622 uint64 value_max = duration * 1000;
1659 1623
1624 int weight = 0;
1625
1660 for (y = op->y - 1; y <= op->y + 1; y++) 1626 for (int y = op->y - 1; y <= op->y + 1; y++)
1661 { 1627 {
1662 for (x = op->x - 1; x <= op->x + 1; x++) 1628 for (int x = op->x - 1; x <= op->x + 1; x++)
1663 { 1629 {
1630 uint64 value = 0;
1631
1664 nx = x; 1632 sint16 nx = x;
1665 ny = y; 1633 sint16 ny = y;
1666 1634
1667 mp = op->map; 1635 maptile *mp = op->map;
1668 1636
1669 mflags = get_map_flags (mp, &mp, nx, ny, &nx, &ny); 1637 int mflags = get_map_flags (mp, &mp, nx, ny, &nx, &ny);
1670 1638
1671 if (mflags & (P_OUT_OF_MAP | P_NO_MAGIC)) 1639 if (mflags & (P_OUT_OF_MAP | P_NO_MAGIC))
1672 continue; 1640 continue;
1673 1641
1674 /* Treat alchemy a little differently - most spell effects 1642 /* Treat alchemy a little differently - most spell effects
1676 * ground level effect. 1644 * ground level effect.
1677 */ 1645 */
1678 if (GET_MAP_MOVE_BLOCK (mp, nx, ny) & MOVE_WALK) 1646 if (GET_MAP_MOVE_BLOCK (mp, nx, ny) & MOVE_WALK)
1679 continue; 1647 continue;
1680 1648
1681 small_nuggets = 0;
1682 large_nuggets = 0;
1683
1684 for (tmp = mp->at (nx, ny).bot; tmp; tmp = next) 1649 for (object *next, *tmp = mp->at (nx, ny).bot; tmp; tmp = next)
1685 { 1650 {
1686 next = tmp->above; 1651 next = tmp->above;
1687 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))
1695 for (tmp1 = tmp->inv; tmp1; tmp1 = next1) 1660 for (tmp1 = tmp->inv; tmp1; tmp1 = next1)
1696 { 1661 {
1697 next1 = tmp1->below; 1662 next1 = tmp1->below;
1698 if (tmp1->weight > 0 && !QUERY_FLAG (tmp1, FLAG_NO_PICK) && 1663 if (tmp1->weight > 0 && !QUERY_FLAG (tmp1, FLAG_NO_PICK) &&
1699 !QUERY_FLAG (tmp1, FLAG_ALIVE) && !QUERY_FLAG (tmp1, FLAG_IS_CAULDRON)) 1664 !QUERY_FLAG (tmp1, FLAG_ALIVE) && !QUERY_FLAG (tmp1, FLAG_IS_CAULDRON))
1700 alchemy_object (tmp1, &small_nuggets, &large_nuggets, &weight); 1665 alchemy_object (tmp1, value, weight);
1701 } 1666 }
1702 } 1667 }
1703 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
1797 { 1764 {
1798 identify (tmp); 1765 identify (tmp);
1799 1766
1800 if (op->type == PLAYER) 1767 if (op->type == PLAYER)
1801 { 1768 {
1802 new_draw_info_format (NDI_UNIQUE, 0, op, "You have %s.", long_desc (tmp, op)); 1769 new_draw_info_format (NDI_UNIQUE, 0, op, "You identified: %s.", long_desc (tmp, op));
1803 1770
1804 if (tmp->msg) 1771 if (tmp->msg)
1805 { 1772 {
1806 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); 1773 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:");
1807 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); 1774 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg);
1819 * stuff on the floor. Only identify stuff on the floor if the spell 1786 * stuff on the floor. Only identify stuff on the floor if the spell
1820 * was not fully used. 1787 * was not fully used.
1821 */ 1788 */
1822 if (num_ident) 1789 if (num_ident)
1823 { 1790 {
1824 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 1791 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above)
1825 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) 1792 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp))
1826 { 1793 {
1827 identify (tmp); 1794 identify (tmp);
1828 1795
1829 if (op->type == PLAYER) 1796 if (op->type == PLAYER)
1830 { 1797 {
1831 new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground is %s.", long_desc (tmp, op)); 1798 new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground you identified: %s.", long_desc (tmp, op));
1832 1799
1833 if (tmp->msg) 1800 if (tmp->msg)
1834 { 1801 {
1835 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); 1802 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:");
1836 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); 1803 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg);
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
2269 * This code was very odd - code early on would only let players use the spell, 2243 * This code was very odd - code early on would only let players use the spell,
2270 * yet the code wass full of player checks. I've presumed that the code 2244 * yet the code wass full of player checks. I've presumed that the code
2271 * that only let players use it was correct, and removed all the other 2245 * that only let players use it was correct, and removed all the other
2272 * player checks. MSW 2003-01-06 2246 * player checks. MSW 2003-01-06
2273 */ 2247 */
2274
2275int 2248int
2276animate_weapon (object *op, object *caster, object *spell, int dir) 2249animate_weapon (object *op, object *caster, object *spell, int dir)
2277{ 2250{
2278 object *weapon, *tmp; 2251 object *weapon, *tmp;
2279 char buf[MAX_BUF]; 2252 char buf[MAX_BUF];
2291 /* exit if it's not a player using this spell. */ 2264 /* exit if it's not a player using this spell. */
2292 if (op->type != PLAYER) 2265 if (op->type != PLAYER)
2293 return 0; 2266 return 0;
2294 2267
2295 /* if player already has a golem, abort */ 2268 /* if player already has a golem, abort */
2296 if (op->contr->ranges[range_golem]) 2269 if (object *golem = op->contr->golem)
2297 { 2270 {
2298 control_golem (op->contr->ranges[range_golem], dir); 2271 control_golem (golem, dir);
2299 return 0; 2272 return 0;
2300 } 2273 }
2301 2274
2302 /* if no direction specified, pick one */ 2275 /* if no direction specified, pick one */
2303 if (!dir) 2276 if (!dir)
2353 CLEAR_FLAG (tmp, FLAG_MONSTER); 2326 CLEAR_FLAG (tmp, FLAG_MONSTER);
2354 tmp->stats.exp = 0; 2327 tmp->stats.exp = 0;
2355 add_friendly_object (tmp); 2328 add_friendly_object (tmp);
2356 tmp->type = GOLEM; 2329 tmp->type = GOLEM;
2357 tmp->set_owner (op); 2330 tmp->set_owner (op);
2331 op->contr->golem = tmp;
2358 set_spell_skill (op, caster, spell, tmp); 2332 set_spell_skill (op, caster, spell, tmp);
2359 op->contr->ranges[range_golem] = tmp;
2360 op->contr->shoottype = range_golem;
2361 2333
2362 /* Give the weapon to the golem now. A bit of a hack to check the 2334 /* Give the weapon to the golem now. A bit of a hack to check the
2363 * removed flag - it should only be set if get_split_object was 2335 * removed flag - it should only be set if get_split_object was
2364 * used above. 2336 * used above.
2365 */ 2337 */
2366 if (!QUERY_FLAG (weapon, FLAG_REMOVED)) 2338 if (!QUERY_FLAG (weapon, FLAG_REMOVED))
2367 weapon->remove (); 2339 weapon->remove ();
2340
2368 insert_ob_in_ob (weapon, tmp); 2341 insert_ob_in_ob (weapon, tmp);
2369 esrv_send_item (op, weapon); 2342 esrv_send_item (op, weapon);
2370 /* To do everything necessary to let a golem use the weapon is a pain, 2343 /* To do everything necessary to let a golem use the weapon is a pain,
2371 * so instead, just set it as equipped (otherwise, we need to update 2344 * so instead, just set it as equipped (otherwise, we need to update
2372 * body_info, skills, etc) 2345 * body_info, skills, etc)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines