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 | */ |
375 | int |
375 | int |
376 | cast_invisible (object *op, object *caster, object *spell_ob) |
376 | cast_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 | |
568 | int |
567 | int |
569 | perceive_self (object *op) |
568 | perceive_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 |
… | |
… | |
1566 | if (QUERY_FLAG (obj, FLAG_UNPAID)) |
1562 | if (QUERY_FLAG (obj, FLAG_UNPAID)) |
1567 | value = 0; |
1563 | value = 0; |
1568 | else if (obj->type == MONEY || obj->type == GEM) |
1564 | else if (obj->type == MONEY || obj->type == GEM) |
1569 | value /= 3; |
1565 | value /= 3; |
1570 | else |
1566 | else |
1571 | value = (value * 9) / 10; |
1567 | value = value * 9 / 10; |
1572 | |
|
|
1573 | value /= 4; // fix by GHJ, don't understand, pcg |
|
|
1574 | |
1568 | |
1575 | if (obj->value > 0 && rndm (0, 29)) |
1569 | if (obj->value > 0 && rndm (0, 29)) |
1576 | total_value += value; |
1570 | total_value += value; |
1577 | |
1571 | |
1578 | total_weight += obj->total_weight (); |
1572 | total_weight += obj->total_weight (); |
… | |
… | |
1611 | } |
1605 | } |
1612 | |
1606 | |
1613 | int |
1607 | int |
1614 | alchemy (object *op, object *caster, object *spell_ob) |
1608 | alchemy (object *op, object *caster, object *spell_ob) |
1615 | { |
1609 | { |
1616 | int weight = 0, mflags; |
|
|
1617 | maptile *mp; |
|
|
1618 | |
|
|
1619 | if (op->type != PLAYER) |
1610 | if (op->type != PLAYER) |
1620 | return 0; |
1611 | return 0; |
|
|
1612 | |
|
|
1613 | object *large = get_archetype ("largenugget"); |
|
|
1614 | object *small = get_archetype ("smallnugget"); |
1621 | |
1615 | |
1622 | /* Put a maximum weight of items that can be alchemised. Limits the power |
1616 | /* Put a maximum weight of items that can be alchemised. Limits the power |
1623 | * some, and also prevents people from alchemising every table/chair/clock |
1617 | * some, and also prevents people from alchemising every table/chair/clock |
1624 | * in sight |
1618 | * in sight |
1625 | */ |
1619 | */ |
1626 | int duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
1620 | int duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
1627 | int weight_max = duration * 1000; |
1621 | int weight_max = duration * 1000; |
1628 | uint64 value_max = duration * 1000; |
1622 | uint64 value_max = duration * 1000; |
1629 | |
1623 | |
1630 | object *large = get_archetype ("largenugget"); |
1624 | int weight = 0; |
1631 | object *small = get_archetype ("smallnugget"); |
|
|
1632 | |
1625 | |
1633 | for (int y = op->y - 1; y <= op->y + 1; y++) |
1626 | for (int y = op->y - 1; y <= op->y + 1; y++) |
1634 | { |
1627 | { |
1635 | for (int x = op->x - 1; x <= op->x + 1; x++) |
1628 | for (int x = op->x - 1; x <= op->x + 1; x++) |
1636 | { |
1629 | { |
1637 | uint64 value = 0; |
1630 | uint64 value = 0; |
1638 | |
1631 | |
1639 | sint16 nx = x; |
1632 | sint16 nx = x; |
1640 | sint16 ny = y; |
1633 | sint16 ny = y; |
1641 | |
1634 | |
1642 | mp = op->map; |
1635 | maptile *mp = op->map; |
1643 | |
1636 | |
1644 | mflags = get_map_flags (mp, &mp, nx, ny, &nx, &ny); |
1637 | int mflags = get_map_flags (mp, &mp, nx, ny, &nx, &ny); |
1645 | |
1638 | |
1646 | if (mflags & (P_OUT_OF_MAP | P_NO_MAGIC)) |
1639 | if (mflags & (P_OUT_OF_MAP | P_NO_MAGIC)) |
1647 | continue; |
1640 | continue; |
1648 | |
1641 | |
1649 | /* Treat alchemy a little differently - most spell effects |
1642 | /* Treat alchemy a little differently - most spell effects |
… | |
… | |
1771 | { |
1764 | { |
1772 | identify (tmp); |
1765 | identify (tmp); |
1773 | |
1766 | |
1774 | if (op->type == PLAYER) |
1767 | if (op->type == PLAYER) |
1775 | { |
1768 | { |
1776 | 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)); |
1777 | |
1770 | |
1778 | if (tmp->msg) |
1771 | if (tmp->msg) |
1779 | { |
1772 | { |
1780 | 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:"); |
1781 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
1774 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
… | |
… | |
1793 | * 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 |
1794 | * was not fully used. |
1787 | * was not fully used. |
1795 | */ |
1788 | */ |
1796 | if (num_ident) |
1789 | if (num_ident) |
1797 | { |
1790 | { |
1798 | 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) |
1799 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) |
1792 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) |
1800 | { |
1793 | { |
1801 | identify (tmp); |
1794 | identify (tmp); |
1802 | |
1795 | |
1803 | if (op->type == PLAYER) |
1796 | if (op->type == PLAYER) |
1804 | { |
1797 | { |
1805 | 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)); |
1806 | |
1799 | |
1807 | if (tmp->msg) |
1800 | if (tmp->msg) |
1808 | { |
1801 | { |
1809 | 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:"); |
1810 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
1803 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
… | |
… | |
2160 | /* Basically, if the object is magical and not counterspell, |
2153 | /* Basically, if the object is magical and not counterspell, |
2161 | * we will more or less remove the object. Don't counterspell |
2154 | * we will more or less remove the object. Don't counterspell |
2162 | * monsters either. |
2155 | * monsters either. |
2163 | */ |
2156 | */ |
2164 | |
2157 | |
2165 | if (head->attacktype & AT_MAGIC && |
2158 | if (head->attacktype & AT_MAGIC |
2166 | !(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)) |
2167 | head->destroy (); |
2162 | head->destroy (); |
2168 | else |
2163 | else |
2169 | switch (head->type) |
2164 | switch (head->type) |
2170 | { |
2165 | { |
2171 | 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 | |
2172 | if (op->level > head->level) |
2172 | if (op->level > head->level) |
2173 | head->destroy (); |
2173 | head->destroy (); |
2174 | |
2174 | |
2175 | break; |
2175 | break; |
2176 | |
2176 | |
… | |
… | |
2243 | * 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, |
2244 | * 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 |
2245 | * 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 |
2246 | * player checks. MSW 2003-01-06 |
2246 | * player checks. MSW 2003-01-06 |
2247 | */ |
2247 | */ |
2248 | |
|
|
2249 | int |
2248 | int |
2250 | animate_weapon (object *op, object *caster, object *spell, int dir) |
2249 | animate_weapon (object *op, object *caster, object *spell, int dir) |
2251 | { |
2250 | { |
2252 | object *weapon, *tmp; |
2251 | object *weapon, *tmp; |
2253 | char buf[MAX_BUF]; |
2252 | char buf[MAX_BUF]; |
… | |
… | |
2265 | /* exit if it's not a player using this spell. */ |
2264 | /* exit if it's not a player using this spell. */ |
2266 | if (op->type != PLAYER) |
2265 | if (op->type != PLAYER) |
2267 | return 0; |
2266 | return 0; |
2268 | |
2267 | |
2269 | /* if player already has a golem, abort */ |
2268 | /* if player already has a golem, abort */ |
2270 | if (op->contr->ranges[range_golem]) |
2269 | if (object *golem = op->contr->golem) |
2271 | { |
2270 | { |
2272 | control_golem (op->contr->ranges[range_golem], dir); |
2271 | control_golem (golem, dir); |
2273 | return 0; |
2272 | return 0; |
2274 | } |
2273 | } |
2275 | |
2274 | |
2276 | /* if no direction specified, pick one */ |
2275 | /* if no direction specified, pick one */ |
2277 | if (!dir) |
2276 | if (!dir) |
… | |
… | |
2327 | CLEAR_FLAG (tmp, FLAG_MONSTER); |
2326 | CLEAR_FLAG (tmp, FLAG_MONSTER); |
2328 | tmp->stats.exp = 0; |
2327 | tmp->stats.exp = 0; |
2329 | add_friendly_object (tmp); |
2328 | add_friendly_object (tmp); |
2330 | tmp->type = GOLEM; |
2329 | tmp->type = GOLEM; |
2331 | tmp->set_owner (op); |
2330 | tmp->set_owner (op); |
|
|
2331 | op->contr->golem = tmp; |
2332 | set_spell_skill (op, caster, spell, tmp); |
2332 | set_spell_skill (op, caster, spell, tmp); |
2333 | op->contr->ranges[range_golem] = tmp; |
|
|
2334 | op->contr->shoottype = range_golem; |
|
|
2335 | |
2333 | |
2336 | /* 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 |
2337 | * 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 |
2338 | * used above. |
2336 | * used above. |
2339 | */ |
2337 | */ |
2340 | if (!QUERY_FLAG (weapon, FLAG_REMOVED)) |
2338 | if (!QUERY_FLAG (weapon, FLAG_REMOVED)) |
2341 | weapon->remove (); |
2339 | weapon->remove (); |
|
|
2340 | |
2342 | insert_ob_in_ob (weapon, tmp); |
2341 | insert_ob_in_ob (weapon, tmp); |
2343 | esrv_send_item (op, weapon); |
2342 | esrv_send_item (op, weapon); |
2344 | /* 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, |
2345 | * 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 |
2346 | * body_info, skills, etc) |
2345 | * body_info, skills, etc) |