… | |
… | |
45 | * its magical benefits. |
45 | * its magical benefits. |
46 | */ |
46 | */ |
47 | void |
47 | void |
48 | cancellation (object *op) |
48 | cancellation (object *op) |
49 | { |
49 | { |
50 | object *tmp; |
|
|
51 | |
|
|
52 | if (op->invisible) |
50 | if (op->invisible) |
53 | return; |
51 | return; |
54 | |
52 | |
55 | if (QUERY_FLAG (op, FLAG_ALIVE) || op->type == CONTAINER || op->type == THROWN_OBJ) |
53 | if (QUERY_FLAG (op, FLAG_ALIVE) || op->type == CONTAINER || op->type == THROWN_OBJ) |
56 | { |
54 | { |
57 | /* Recur through the inventory */ |
55 | /* Recurse through the inventory */ |
58 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
56 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
59 | if (!did_make_save_item (tmp, AT_CANCELLATION, op)) |
57 | if (!did_make_save_item (tmp, AT_CANCELLATION, op)) |
60 | cancellation (tmp); |
58 | cancellation (tmp); |
61 | } |
59 | } |
62 | else if (FABS (op->magic) <= (rndm (0, 5))) |
60 | else if (FABS (op->magic) <= rndm (0, 5)) |
63 | { |
61 | { |
64 | /* Nullify this object. This code could probably be more complete */ |
62 | /* Nullify this object. This code could probably be more complete */ |
65 | /* in what abilities it should cancel */ |
63 | /* in what abilities it should cancel */ |
66 | op->magic = 0; |
64 | op->magic = 0; |
|
|
65 | |
67 | CLEAR_FLAG (op, FLAG_DAMNED); |
66 | CLEAR_FLAG (op, FLAG_DAMNED); |
68 | CLEAR_FLAG (op, FLAG_CURSED); |
67 | CLEAR_FLAG (op, FLAG_CURSED); |
69 | CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL); |
68 | CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL); |
70 | CLEAR_FLAG (op, FLAG_KNOWN_CURSED); |
69 | CLEAR_FLAG (op, FLAG_KNOWN_CURSED); |
|
|
70 | |
71 | if (op->env && op->env->type == PLAYER) |
71 | if (op->env && op->env->type == PLAYER) |
72 | { |
|
|
73 | esrv_send_item (op->env, op); |
72 | esrv_send_item (op->env, op); |
74 | } |
|
|
75 | } |
73 | } |
76 | } |
74 | } |
77 | |
75 | |
78 | /* did_make_save_item just checks to make sure the item actually |
76 | /* did_make_save_item just checks to make sure the item actually |
79 | * made its saving throw based on the tables. It does not take |
77 | * made its saving throw based on the tables. It does not take |
… | |
… | |
142 | |
140 | |
143 | /* This function calls did_make_save_item. It then performs the |
141 | /* This function calls did_make_save_item. It then performs the |
144 | * appropriate actions to the item (such as burning the item up, |
142 | * appropriate actions to the item (such as burning the item up, |
145 | * calling cancellation, etc.) |
143 | * calling cancellation, etc.) |
146 | */ |
144 | */ |
147 | |
|
|
148 | void |
145 | void |
149 | save_throw_object (object *op, int type, object *originator) |
146 | save_throw_object (object *op, int type, object *originator) |
150 | { |
147 | { |
151 | if (!did_make_save_item (op, type, originator)) |
148 | if (!did_make_save_item (op, type, originator)) |
152 | { |
149 | { |
… | |
… | |
1075 | * appropriate attacktype. Only 1 attacktype should be set at a time. |
1072 | * appropriate attacktype. Only 1 attacktype should be set at a time. |
1076 | * This doesn't damage the player, but returns how much it should |
1073 | * This doesn't damage the player, but returns how much it should |
1077 | * take. However, it will do other effects (paralyzation, slow, etc.) |
1074 | * take. However, it will do other effects (paralyzation, slow, etc.) |
1078 | * Note - changed for PR code - we now pass the attack number and not |
1075 | * Note - changed for PR code - we now pass the attack number and not |
1079 | * the attacktype. Makes it easier for the PR code. */ |
1076 | * the attacktype. Makes it easier for the PR code. */ |
1080 | |
|
|
1081 | int |
1077 | int |
1082 | hit_player_attacktype (object *op, object *hitter, int dam, uint32 attacknum, int magic) |
1078 | hit_player_attacktype (object *op, object *hitter, int dam, uint32 attacknum, int magic) |
1083 | { |
1079 | { |
1084 | int doesnt_slay = 1; |
1080 | int doesnt_slay = 1; |
1085 | |
1081 | |
… | |
… | |
1189 | blind_player (op, hitter, dam); |
1185 | blind_player (op, hitter, dam); |
1190 | } |
1186 | } |
1191 | dam = 0; /* These are all effects and don't do real damage */ |
1187 | dam = 0; /* These are all effects and don't do real damage */ |
1192 | } |
1188 | } |
1193 | break; |
1189 | break; |
|
|
1190 | |
1194 | case ATNR_ACID: |
1191 | case ATNR_ACID: |
1195 | { |
1192 | { |
1196 | int flag = 0; |
1193 | int flag = 0; |
1197 | |
1194 | |
1198 | /* Items only get corroded if you're not on a battleground and |
1195 | /* Items only get corroded if you're not on a battleground and |
1199 | * if your acid resistance is below 50%. */ |
1196 | * if your acid resistance is below 50%. */ |
1200 | if (!op_on_battleground (op, NULL, NULL) && (op->resist[ATNR_ACID] < 50)) |
1197 | if (!op_on_battleground (op, NULL, NULL) && (op->resist[ATNR_ACID] < 50)) |
1201 | { |
1198 | { |
1202 | object *tmp; |
|
|
1203 | |
|
|
1204 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1199 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1205 | { |
1200 | { |
1206 | if (tmp->invisible) |
1201 | if (tmp->invisible) |
1207 | continue; |
1202 | continue; |
1208 | if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10)) |
1203 | if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10)) |
1209 | /* >= 10% acid res. on itmes will protect these */ |
1204 | /* >= 10% acid res. on items will protect these */ |
1210 | continue; |
1205 | continue; |
1211 | if (!(tmp->material & M_IRON)) |
1206 | if (!(tmp->material & M_IRON)) |
1212 | continue; |
1207 | continue; |
1213 | if (tmp->magic < -4) /* Let's stop at -5 */ |
1208 | if (tmp->magic < -4) /* Let's stop at -5 */ |
1214 | continue; |
1209 | continue; |
1215 | if (tmp->type == RING || |
1210 | if (tmp->type == RING |
1216 | /* removed boots and gloves from exclusion list in |
1211 | /* removed boots and gloves from exclusion list in PR */ |
1217 | PR */ |
1212 | || tmp->type == GIRDLE |
1218 | tmp->type == GIRDLE || tmp->type == AMULET || tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1213 | || tmp->type == AMULET |
|
|
1214 | || tmp->type == WAND |
|
|
1215 | || tmp->type == ROD |
|
|
1216 | || tmp->type == HORN) |
1219 | continue; /* To avoid some strange effects */ |
1217 | continue; /* To avoid some strange effects */ |
1220 | |
1218 | |
1221 | /* High damage acid has better chance of corroding |
1219 | /* High damage acid has better chance of corroding |
1222 | objects */ |
1220 | objects */ |
1223 | if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic) |
1221 | if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic) |
… | |
… | |
1230 | tmp->magic--; |
1228 | tmp->magic--; |
1231 | if (op->type == PLAYER) |
1229 | if (op->type == PLAYER) |
1232 | esrv_send_item (op, tmp); |
1230 | esrv_send_item (op, tmp); |
1233 | } |
1231 | } |
1234 | } |
1232 | } |
|
|
1233 | |
1235 | if (flag) |
1234 | if (flag) |
1236 | op->update_stats (); /* Something was corroded */ |
1235 | op->update_stats (); /* Something was corroded */ |
1237 | } |
1236 | } |
1238 | } |
1237 | } |
1239 | break; |
1238 | break; |
|
|
1239 | |
1240 | case ATNR_DRAIN: |
1240 | case ATNR_DRAIN: |
1241 | { |
1241 | { |
1242 | /* rate is the proportion of exp drained. High rate means |
1242 | /* rate is the proportion of exp drained. High rate means |
1243 | * not much is drained, low rate means a lot is drained. |
1243 | * not much is drained, low rate means a lot is drained. |
1244 | */ |
1244 | */ |
… | |
… | |
1286 | change_exp (hitter, op->stats.exp / (rate * 2), |
1286 | change_exp (hitter, op->stats.exp / (rate * 2), |
1287 | hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0); |
1287 | hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0); |
1288 | } |
1288 | } |
1289 | change_exp (op, -op->stats.exp / rate, NULL, 0); |
1289 | change_exp (op, -op->stats.exp / rate, NULL, 0); |
1290 | } |
1290 | } |
|
|
1291 | |
1291 | dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure |
1292 | dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure |
1292 | * drain attack, you won't know that you are actually sucking out EXP, |
1293 | * drain attack, you won't know that you are actually sucking out EXP, |
1293 | * as the messages will say you missed |
1294 | * as the messages will say you missed |
1294 | */ |
1295 | */ |
1295 | } |
1296 | } |
1296 | } |
1297 | } |
1297 | break; |
1298 | break; |
|
|
1299 | |
1298 | case ATNR_TURN_UNDEAD: |
1300 | case ATNR_TURN_UNDEAD: |
1299 | { |
1301 | { |
1300 | if (QUERY_FLAG (op, FLAG_UNDEAD)) |
1302 | if (QUERY_FLAG (op, FLAG_UNDEAD)) |
1301 | { |
1303 | { |
1302 | object *owner = hitter->owner ? (object *)hitter->owner : hitter; |
1304 | object *owner = hitter->owner ? (object *)hitter->owner : hitter; |
… | |
… | |
1314 | else |
1316 | else |
1315 | dam = 0; /* don't damage non undead - should we damage |
1317 | dam = 0; /* don't damage non undead - should we damage |
1316 | undead? */ |
1318 | undead? */ |
1317 | } |
1319 | } |
1318 | break; |
1320 | break; |
|
|
1321 | |
1319 | case ATNR_DEATH: |
1322 | case ATNR_DEATH: |
1320 | deathstrike_player (op, hitter, &dam); |
1323 | deathstrike_player (op, hitter, &dam); |
1321 | break; |
1324 | break; |
|
|
1325 | |
1322 | case ATNR_CHAOS: |
1326 | case ATNR_CHAOS: |
1323 | LOG (llevError, "%s was hit by %s with non-specific chaos.\n", op->debug_desc (), hitter->debug_desc2 ()); |
1327 | LOG (llevError, "%s was hit by %s with non-specific chaos.\n", op->debug_desc (), hitter->debug_desc2 ()); |
1324 | dam = 0; |
1328 | dam = 0; |
1325 | break; |
1329 | break; |
|
|
1330 | |
1326 | case ATNR_COUNTERSPELL: |
1331 | case ATNR_COUNTERSPELL: |
1327 | LOG (llevError, "%s was hit by %s with counterspell attack.\n", op->debug_desc (), hitter->debug_desc2 ()); |
1332 | LOG (llevError, "%s was hit by %s with counterspell attack.\n", op->debug_desc (), hitter->debug_desc2 ()); |
1328 | dam = 0; |
1333 | dam = 0; |
1329 | /* This should never happen. Counterspell is handled |
1334 | /* This should never happen. Counterspell is handled |
1330 | * seperately and filtered out. If this does happen, |
1335 | * seperately and filtered out. If this does happen, |
1331 | * Counterspell has no effect on anything but spells, so it |
1336 | * Counterspell has no effect on anything but spells, so it |
1332 | * does no damage. */ |
1337 | * does no damage. */ |
1333 | break; |
1338 | break; |
|
|
1339 | |
1334 | case ATNR_HOLYWORD: |
1340 | case ATNR_HOLYWORD: |
1335 | { |
1341 | { |
1336 | /* This has already been handled by hit_player, |
1342 | /* This has already been handled by hit_player, |
1337 | * no need to check twice -- DAMN */ |
1343 | * no need to check twice -- DAMN */ |
1338 | object *owner = hitter->owner ? (object *)hitter->owner : hitter; |
1344 | object *owner = hitter->owner ? (object *)hitter->owner : hitter; |
… | |
… | |
1340 | /* As with turn undead above, give a bonus on the saving throw */ |
1346 | /* As with turn undead above, give a bonus on the saving throw */ |
1341 | if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis]) |
1347 | if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis]) |
1342 | scare_creature (op, owner); |
1348 | scare_creature (op, owner); |
1343 | } |
1349 | } |
1344 | break; |
1350 | break; |
|
|
1351 | |
1345 | case ATNR_LIFE_STEALING: |
1352 | case ATNR_LIFE_STEALING: |
1346 | { |
1353 | { |
1347 | int new_hp; |
1354 | int new_hp; |
1348 | |
1355 | |
1349 | /* this is replacement to drain for players, instead of taking |
1356 | /* this is replacement to drain for players, instead of taking |
… | |
… | |
1356 | * 1000). |
1363 | * 1000). |
1357 | */ |
1364 | */ |
1358 | /* You can't steal life from something undead */ |
1365 | /* You can't steal life from something undead */ |
1359 | if ((op->type == GOLEM) || (QUERY_FLAG (op, FLAG_UNDEAD))) |
1366 | if ((op->type == GOLEM) || (QUERY_FLAG (op, FLAG_UNDEAD))) |
1360 | return 0; |
1367 | return 0; |
|
|
1368 | |
1361 | /* If drain protection is higher than life stealing, use that */ |
1369 | /* If drain protection is higher than life stealing, use that */ |
1362 | if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING]) |
1370 | if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING]) |
1363 | dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000; |
1371 | dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000; |
1364 | else |
1372 | else |
1365 | dam = (dam * (100 - op->resist[ATNR_LIFE_STEALING])) / 3000; |
1373 | dam = (dam * (100 - op->resist[ATNR_LIFE_STEALING])) / 3000; |
|
|
1374 | |
1366 | /* You die at -1 hp, not zero. */ |
1375 | /* You die at -1 hp, not zero. */ |
1367 | if (dam > (op->stats.hp + 1)) |
1376 | if (dam > (op->stats.hp + 1)) |
1368 | dam = op->stats.hp + 1; |
1377 | dam = op->stats.hp + 1; |
|
|
1378 | |
1369 | new_hp = hitter->stats.hp + dam; |
1379 | new_hp = hitter->stats.hp + dam; |
1370 | if (new_hp > hitter->stats.maxhp) |
1380 | if (new_hp > hitter->stats.maxhp) |
1371 | new_hp = hitter->stats.maxhp; |
1381 | new_hp = hitter->stats.maxhp; |
|
|
1382 | |
1372 | if (new_hp > hitter->stats.hp) |
1383 | if (new_hp > hitter->stats.hp) |
1373 | hitter->stats.hp = new_hp; |
1384 | hitter->stats.hp = new_hp; |
1374 | } |
1385 | } |
1375 | } |
1386 | } |
1376 | |
1387 | |
… | |
… | |
1752 | } |
1763 | } |
1753 | } |
1764 | } |
1754 | |
1765 | |
1755 | if (!simple_attack && op->type == DOOR) |
1766 | if (!simple_attack && op->type == DOOR) |
1756 | { |
1767 | { |
1757 | object *tmp; |
|
|
1758 | |
|
|
1759 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1768 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1760 | if (tmp->type == RUNE || tmp->type == TRAP) |
1769 | if (tmp->type == RUNE || tmp->type == TRAP) |
1761 | { |
1770 | { |
1762 | spring_trap (tmp, hitter); |
1771 | spring_trap (tmp, hitter); |
1763 | |
1772 | |
1764 | if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack)) |
1773 | if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack)) |