… | |
… | |
91 | if (op->material & mt->material) |
91 | if (op->material & mt->material) |
92 | break; |
92 | break; |
93 | } |
93 | } |
94 | else |
94 | else |
95 | mt = name_to_material (op->materialname); |
95 | mt = name_to_material (op->materialname); |
|
|
96 | |
96 | if (mt == NULL) |
97 | if (mt == NULL) |
97 | return TRUE; |
98 | return TRUE; |
|
|
99 | |
98 | roll = rndm (1, 20); |
100 | roll = rndm (1, 20); |
99 | |
101 | |
100 | /* the attacktypes have no meaning for object saves |
102 | /* the attacktypes have no meaning for object saves |
101 | * If the type is only magic, don't adjust type - basically, if |
103 | * If the type is only magic, don't adjust type - basically, if |
102 | * pure magic is hitting an object, it should save. However, if it |
104 | * pure magic is hitting an object, it should save. However, if it |
… | |
… | |
770 | if (settings.casting_time == TRUE) |
772 | if (settings.casting_time == TRUE) |
771 | { |
773 | { |
772 | if ((hitter->type == PLAYER) && (hitter->casting_time > -1)) |
774 | if ((hitter->type == PLAYER) && (hitter->casting_time > -1)) |
773 | { |
775 | { |
774 | hitter->casting_time = -1; |
776 | hitter->casting_time = -1; |
775 | new_draw_info (NDI_UNIQUE, 0, hitter, "You attacked and lost " "your spell!"); |
777 | new_draw_info (NDI_UNIQUE, 0, hitter, "You attacked and lost your spell!"); |
776 | } |
778 | } |
777 | if ((op->casting_time > -1) && (hitdam > 0)) |
779 | if ((op->casting_time > -1) && (hitdam > 0)) |
778 | { |
780 | { |
779 | op->casting_time = -1; |
781 | op->casting_time = -1; |
780 | if (op->type == PLAYER) |
782 | if (op->type == PLAYER) |
781 | { |
783 | { |
782 | new_draw_info (NDI_UNIQUE, 0, op, "You were hit and lost " "your spell!"); |
784 | new_draw_info (NDI_UNIQUE, 0, op, "You were hit and lost your spell!"); |
783 | new_draw_info_format (NDI_ALL | NDI_UNIQUE, 5, NULL, "%s was hit by %s and lost a spell.", &op_name, &hitter->name); |
785 | new_draw_info_format (NDI_ALL | NDI_UNIQUE, 5, NULL, "%s was hit by %s and lost a spell.", &op_name, &hitter->name); |
784 | } |
786 | } |
785 | } |
787 | } |
786 | } |
788 | } |
787 | if (!simple_attack) |
789 | if (!simple_attack) |
… | |
… | |
1071 | * the attacktype. Makes it easier for the PR code. */ |
1073 | * the attacktype. Makes it easier for the PR code. */ |
1072 | |
1074 | |
1073 | int |
1075 | int |
1074 | hit_player_attacktype (object *op, object *hitter, int dam, uint32 attacknum, int magic) |
1076 | hit_player_attacktype (object *op, object *hitter, int dam, uint32 attacknum, int magic) |
1075 | { |
1077 | { |
1076 | |
|
|
1077 | int doesnt_slay = 1; |
1078 | int doesnt_slay = 1; |
1078 | |
1079 | |
1079 | /* Catch anyone that may be trying to send us a bitmask instead of the number */ |
1080 | /* Catch anyone that may be trying to send us a bitmask instead of the number */ |
1080 | if (attacknum >= NROFATTACKS) |
1081 | if (attacknum >= NROFATTACKS) |
1081 | { |
1082 | { |
… | |
… | |
1126 | |
1127 | |
1127 | /* Keep this in order - makes things easier to find */ |
1128 | /* Keep this in order - makes things easier to find */ |
1128 | |
1129 | |
1129 | switch (attacknum) |
1130 | switch (attacknum) |
1130 | { |
1131 | { |
1131 | case ATNR_PHYSICAL: |
1132 | case ATNR_PHYSICAL: |
1132 | /* here also check for diseases */ |
1133 | /* here also check for diseases */ |
1133 | check_physically_infect (op, hitter); |
1134 | check_physically_infect (op, hitter); |
1134 | break; |
1135 | break; |
1135 | |
1136 | |
1136 | /* Don't need to do anything for: |
1137 | /* Don't need to do anything for: |
1137 | magic, |
1138 | magic, |
1138 | fire, |
1139 | fire, |
1139 | electricity, |
1140 | electricity, |
1140 | cold */ |
1141 | cold */ |
1141 | |
1142 | |
1142 | case ATNR_CONFUSION: |
1143 | case ATNR_CONFUSION: |
1143 | case ATNR_POISON: |
1144 | case ATNR_POISON: |
1144 | case ATNR_SLOW: |
1145 | case ATNR_SLOW: |
1145 | case ATNR_PARALYZE: |
1146 | case ATNR_PARALYZE: |
1146 | case ATNR_FEAR: |
1147 | case ATNR_FEAR: |
1147 | case ATNR_CANCELLATION: |
1148 | case ATNR_CANCELLATION: |
1148 | case ATNR_DEPLETE: |
1149 | case ATNR_DEPLETE: |
1149 | case ATNR_BLIND: |
1150 | case ATNR_BLIND: |
1150 | { |
1151 | { |
1151 | /* chance for inflicting a special attack depends on the |
1152 | /* chance for inflicting a special attack depends on the |
1152 | * difference between attacker's and defender's level |
1153 | * difference between attacker's and defender's level |
1153 | */ |
1154 | */ |
1154 | int level_diff = MIN (110, MAX (0, op->level - hitter->level)); |
1155 | int level_diff = MIN (110, MAX (0, op->level - hitter->level)); |
1155 | |
1156 | |
1156 | /* First, only creatures/players with speed can be affected. |
1157 | /* First, only creatures/players with speed can be affected. |
1157 | * Second, just getting hit doesn't mean it always affects |
1158 | * Second, just getting hit doesn't mean it always affects |
1158 | * you. Third, you still get a saving through against the |
1159 | * you. Third, you still get a saving through against the |
1159 | * effect. |
1160 | * effect. |
1160 | */ |
1161 | */ |
1161 | if (op->speed && |
1162 | if (op->speed && |
1162 | (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) && |
1163 | (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) && |
1163 | !(rndm (0, (attacknum == ATNR_SLOW ? 6 : 3) - 1)) && !did_make_save (op, level_diff, op->resist[attacknum] / 10)) |
1164 | !(rndm (0, (attacknum == ATNR_SLOW ? 6 : 3) - 1)) && !did_make_save (op, level_diff, op->resist[attacknum] / 10)) |
1164 | { |
1165 | { |
1165 | |
1166 | |
1166 | /* Player has been hit by something */ |
1167 | /* Player has been hit by something */ |
1167 | if (attacknum == ATNR_CONFUSION) |
1168 | if (attacknum == ATNR_CONFUSION) |
1168 | confuse_player (op, hitter, dam); |
1169 | confuse_player (op, hitter, dam); |
1169 | else if (attacknum == ATNR_POISON) |
1170 | else if (attacknum == ATNR_POISON) |
1170 | poison_player (op, hitter, dam); |
1171 | poison_player (op, hitter, dam); |
1171 | else if (attacknum == ATNR_SLOW) |
1172 | else if (attacknum == ATNR_SLOW) |
1172 | slow_player (op, hitter, dam); |
1173 | slow_player (op, hitter, dam); |
1173 | else if (attacknum == ATNR_PARALYZE) |
1174 | else if (attacknum == ATNR_PARALYZE) |
1174 | paralyze_player (op, hitter, dam); |
1175 | paralyze_player (op, hitter, dam); |
1175 | else if (attacknum == ATNR_FEAR) |
1176 | else if (attacknum == ATNR_FEAR) |
1176 | scare_creature (op, hitter); |
1177 | scare_creature (op, hitter); |
1177 | else if (attacknum == ATNR_CANCELLATION) |
1178 | else if (attacknum == ATNR_CANCELLATION) |
1178 | cancellation (op); |
1179 | cancellation (op); |
1179 | else if (attacknum == ATNR_DEPLETE) |
1180 | else if (attacknum == ATNR_DEPLETE) |
1180 | op->drain_stat (); |
1181 | op->drain_stat (); |
1181 | else if (attacknum == ATNR_BLIND && !QUERY_FLAG (op, FLAG_UNDEAD) && !QUERY_FLAG (op, FLAG_GENERATOR)) |
1182 | else if (attacknum == ATNR_BLIND && !QUERY_FLAG (op, FLAG_UNDEAD) && !QUERY_FLAG (op, FLAG_GENERATOR)) |
1182 | blind_player (op, hitter, dam); |
1183 | blind_player (op, hitter, dam); |
1183 | } |
1184 | } |
1184 | dam = 0; /* These are all effects and don't do real damage */ |
1185 | dam = 0; /* These are all effects and don't do real damage */ |
1185 | } |
1186 | } |
1186 | break; |
1187 | break; |
1187 | case ATNR_ACID: |
1188 | case ATNR_ACID: |
1188 | { |
1189 | { |
1189 | int flag = 0; |
1190 | int flag = 0; |
1190 | |
1191 | |
1191 | /* Items only get corroded if you're not on a battleground and |
1192 | /* Items only get corroded if you're not on a battleground and |
1192 | * if your acid resistance is below 50%. */ |
1193 | * if your acid resistance is below 50%. */ |
1193 | if (!op_on_battleground (op, NULL, NULL) && (op->resist[ATNR_ACID] < 50)) |
1194 | if (!op_on_battleground (op, NULL, NULL) && (op->resist[ATNR_ACID] < 50)) |
1194 | { |
1195 | { |
1195 | object *tmp; |
1196 | object *tmp; |
1196 | |
1197 | |
1197 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1198 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1198 | { |
1199 | { |
1199 | if (tmp->invisible) |
1200 | if (tmp->invisible) |
1200 | continue; |
1201 | continue; |
1201 | if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10)) |
1202 | if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10)) |
1202 | /* >= 10% acid res. on itmes will protect these */ |
1203 | /* >= 10% acid res. on itmes will protect these */ |
1203 | continue; |
1204 | continue; |
1204 | if (!(tmp->material & M_IRON)) |
1205 | if (!(tmp->material & M_IRON)) |
1205 | continue; |
1206 | continue; |
1206 | if (tmp->magic < -4) /* Let's stop at -5 */ |
1207 | if (tmp->magic < -4) /* Let's stop at -5 */ |
1207 | continue; |
1208 | continue; |
1208 | if (tmp->type == RING || |
1209 | if (tmp->type == RING || |
1209 | /* removed boots and gloves from exclusion list in |
1210 | /* removed boots and gloves from exclusion list in |
1210 | PR */ |
1211 | PR */ |
1211 | tmp->type == GIRDLE || tmp->type == AMULET || tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1212 | tmp->type == GIRDLE || tmp->type == AMULET || tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1212 | continue; /* To avoid some strange effects */ |
1213 | continue; /* To avoid some strange effects */ |
1213 | |
1214 | |
1214 | /* High damage acid has better chance of corroding |
1215 | /* High damage acid has better chance of corroding |
1215 | objects */ |
1216 | objects */ |
1216 | if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic) |
1217 | if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic) |
1217 | { |
1218 | { |
1218 | if (op->type == PLAYER) |
1219 | if (op->type == PLAYER) |
1219 | /* Make this more visible */ |
1220 | /* Make this more visible */ |
1220 | new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, |
1221 | new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, |
1221 | "The %s's acid corrodes your %s!", query_name (hitter), query_name (tmp)); |
1222 | "The %s's acid corrodes your %s!", query_name (hitter), query_name (tmp)); |
1222 | flag = 1; |
1223 | flag = 1; |
1223 | tmp->magic--; |
1224 | tmp->magic--; |
1224 | if (op->type == PLAYER) |
1225 | if (op->type == PLAYER) |
1225 | esrv_send_item (op, tmp); |
1226 | esrv_send_item (op, tmp); |
1226 | } |
1227 | } |
1227 | } |
1228 | } |
1228 | if (flag) |
1229 | if (flag) |
1229 | op->update_stats (); /* Something was corroded */ |
1230 | op->update_stats (); /* Something was corroded */ |
1230 | } |
1231 | } |
1231 | } |
1232 | } |
1232 | break; |
1233 | break; |
1233 | case ATNR_DRAIN: |
1234 | case ATNR_DRAIN: |
1234 | { |
1235 | { |
1235 | /* rate is the proportion of exp drained. High rate means |
1236 | /* rate is the proportion of exp drained. High rate means |
1236 | * not much is drained, low rate means a lot is drained. |
1237 | * not much is drained, low rate means a lot is drained. |
1237 | */ |
1238 | */ |
1238 | int rate; |
1239 | int rate; |
1239 | |
1240 | |
1240 | if (op->resist[ATNR_DRAIN] >= 0) |
1241 | if (op->resist[ATNR_DRAIN] >= 0) |
1241 | rate = 400 + op->resist[ATNR_DRAIN] * 3; |
1242 | rate = 400 + op->resist[ATNR_DRAIN] * 3; |
1242 | else |
1243 | else |
1243 | rate = 400 * 100 / (100 - op->resist[ATNR_DRAIN]); |
1244 | rate = 400 * 100 / (100 - op->resist[ATNR_DRAIN]); |
1244 | |
1245 | |
1245 | if (op->stats.exp <= rate) |
1246 | if (op->stats.exp <= rate) |
1246 | { |
1247 | { |
1247 | if (op->type == GOLEM) |
1248 | if (op->type == GOLEM) |
1248 | dam = 999; /* Its force is "sucked" away. 8) */ |
1249 | dam = 999; /* Its force is "sucked" away. 8) */ |
1249 | else |
1250 | else |
1250 | /* If we can't drain, lets try to do physical damage */ |
1251 | /* If we can't drain, lets try to do physical damage */ |
1251 | dam = hit_player_attacktype (op, hitter, dam, ATNR_PHYSICAL, magic); |
1252 | dam = hit_player_attacktype (op, hitter, dam, ATNR_PHYSICAL, magic); |
1252 | } |
1253 | } |
1253 | else |
1254 | else |
1254 | { |
1255 | { |
1255 | /* Randomly give the hitter some hp */ |
1256 | /* Randomly give the hitter some hp */ |
1256 | if (hitter->stats.hp < hitter->stats.maxhp && |
1257 | if (hitter->stats.hp < hitter->stats.maxhp && |
1257 | (op->level > hitter->level) && random_roll (0, (op->level - hitter->level + 2), hitter, PREFER_HIGH) > 3) |
1258 | (op->level > hitter->level) && random_roll (0, (op->level - hitter->level + 2), hitter, PREFER_HIGH) > 3) |
1258 | hitter->stats.hp++; |
1259 | hitter->stats.hp++; |
1259 | |
1260 | |
1260 | /* Can't do drains on battleground spaces. |
1261 | /* Can't do drains on battleground spaces. |
1261 | * Move the wiz check up here - before, the hitter wouldn't gain exp |
1262 | * Move the wiz check up here - before, the hitter wouldn't gain exp |
1262 | * exp, but the wiz would still lose exp! If drainee is a wiz, |
1263 | * exp, but the wiz would still lose exp! If drainee is a wiz, |
1263 | * nothing happens. |
1264 | * nothing happens. |
1264 | * Try to credit the owner. We try to display player -> player drain |
1265 | * Try to credit the owner. We try to display player -> player drain |
1265 | * attacks, hence all the != PLAYER checks. |
1266 | * attacks, hence all the != PLAYER checks. |
1266 | */ |
1267 | */ |
1267 | if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1268 | if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1268 | { |
1269 | { |
1269 | object *owner = hitter->owner; |
1270 | object *owner = hitter->owner; |
1270 | |
1271 | |
1271 | if (owner && owner != hitter) |
1272 | if (owner && owner != hitter) |
1272 | { |
1273 | { |
1273 | if (op->type != PLAYER || owner->type != PLAYER) |
1274 | if (op->type != PLAYER || owner->type != PLAYER) |
1274 | change_exp (owner, op->stats.exp / (rate * 2), |
1275 | change_exp (owner, op->stats.exp / (rate * 2), |
1275 | hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, SK_EXP_TOTAL); |
1276 | hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, SK_EXP_TOTAL); |
1276 | } |
1277 | } |
1277 | else if (op->type != PLAYER || hitter->type != PLAYER) |
1278 | else if (op->type != PLAYER || hitter->type != PLAYER) |
1278 | { |
1279 | { |
1279 | change_exp (hitter, op->stats.exp / (rate * 2), |
1280 | change_exp (hitter, op->stats.exp / (rate * 2), |
1280 | hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0); |
1281 | hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0); |
1281 | } |
1282 | } |
1282 | change_exp (op, -op->stats.exp / rate, NULL, 0); |
1283 | change_exp (op, -op->stats.exp / rate, NULL, 0); |
1283 | } |
1284 | } |
1284 | dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure |
1285 | dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure |
1285 | * drain attack, you won't know that you are actually sucking out EXP, |
1286 | * drain attack, you won't know that you are actually sucking out EXP, |
1286 | * as the messages will say you missed |
1287 | * as the messages will say you missed |
1287 | */ |
1288 | */ |
1288 | } |
1289 | } |
1289 | } |
1290 | } |
1290 | break; |
1291 | break; |
1291 | case ATNR_TURN_UNDEAD: |
1292 | case ATNR_TURN_UNDEAD: |
1292 | { |
1293 | { |
1293 | if (QUERY_FLAG (op, FLAG_UNDEAD)) |
1294 | if (QUERY_FLAG (op, FLAG_UNDEAD)) |
1294 | { |
1295 | { |
1295 | object *owner = hitter->owner ? (object *)hitter->owner : hitter; |
1296 | object *owner = hitter->owner ? (object *)hitter->owner : hitter; |
1296 | object *god = find_god (determine_god (owner)); |
1297 | object *god = find_god (determine_god (owner)); |
1297 | int div = 1; |
1298 | int div = 1; |
1298 | |
1299 | |
1299 | /* if undead are not an enemy of your god, you turn them |
1300 | /* if undead are not an enemy of your god, you turn them |
1300 | * at half strength */ |
1301 | * at half strength */ |
1301 | if (!god || !god->slaying || strstr (god->slaying, undead_name) == NULL) |
1302 | if (!god || !god->slaying || strstr (god->slaying, undead_name) == NULL) |
1302 | div = 2; |
1303 | div = 2; |
1303 | /* Give a bonus if you resist turn undead */ |
1304 | /* Give a bonus if you resist turn undead */ |
1304 | if (op->level * div < (turn_bonus[owner->stats.Wis] + owner->level + (op->resist[ATNR_TURN_UNDEAD] / 100))) |
1305 | if (op->level * div < (turn_bonus[owner->stats.Wis] + owner->level + (op->resist[ATNR_TURN_UNDEAD] / 100))) |
1305 | scare_creature (op, owner); |
1306 | scare_creature (op, owner); |
1306 | } |
1307 | } |
1307 | else |
1308 | else |
1308 | dam = 0; /* don't damage non undead - should we damage |
1309 | dam = 0; /* don't damage non undead - should we damage |
1309 | undead? */ |
1310 | undead? */ |
1310 | } |
1311 | } |
1311 | break; |
1312 | break; |
1312 | case ATNR_DEATH: |
1313 | case ATNR_DEATH: |
1313 | deathstrike_player (op, hitter, &dam); |
1314 | deathstrike_player (op, hitter, &dam); |
1314 | break; |
1315 | break; |
1315 | case ATNR_CHAOS: |
1316 | case ATNR_CHAOS: |
1316 | LOG (llevError, "%s was hit by %s with non-specific chaos.\n", query_name (op), query_name (hitter)); |
1317 | LOG (llevError, "%s was hit by %s with non-specific chaos.\n", op->debug_desc (), hitter->debug_desc2 ()); |
1317 | dam = 0; |
1318 | dam = 0; |
1318 | break; |
1319 | break; |
1319 | case ATNR_COUNTERSPELL: |
1320 | case ATNR_COUNTERSPELL: |
1320 | LOG (llevError, "%s was hit by %s with counterspell attack.\n", query_name (op), query_name (hitter)); |
1321 | LOG (llevError, "%s was hit by %s with counterspell attack.\n", op->debug_desc (), hitter->debug_desc2 ()); |
1321 | dam = 0; |
1322 | dam = 0; |
1322 | /* This should never happen. Counterspell is handled |
1323 | /* This should never happen. Counterspell is handled |
1323 | * seperately and filtered out. If this does happen, |
1324 | * seperately and filtered out. If this does happen, |
1324 | * Counterspell has no effect on anything but spells, so it |
1325 | * Counterspell has no effect on anything but spells, so it |
1325 | * does no damage. */ |
1326 | * does no damage. */ |
1326 | break; |
1327 | break; |
1327 | case ATNR_HOLYWORD: |
1328 | case ATNR_HOLYWORD: |
1328 | { |
1329 | { |
1329 | /* This has already been handled by hit_player, |
1330 | /* This has already been handled by hit_player, |
1330 | * no need to check twice -- DAMN */ |
1331 | * no need to check twice -- DAMN */ |
1331 | object *owner = hitter->owner ? (object *)hitter->owner : hitter; |
1332 | object *owner = hitter->owner ? (object *)hitter->owner : hitter; |
1332 | |
1333 | |
1333 | /* As with turn undead above, give a bonus on the saving throw */ |
1334 | /* As with turn undead above, give a bonus on the saving throw */ |
1334 | if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis]) |
1335 | if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis]) |
1335 | scare_creature (op, owner); |
1336 | scare_creature (op, owner); |
1336 | } |
1337 | } |
1337 | break; |
1338 | break; |
1338 | case ATNR_LIFE_STEALING: |
1339 | case ATNR_LIFE_STEALING: |
1339 | { |
1340 | { |
1340 | int new_hp; |
1341 | int new_hp; |
1341 | |
1342 | |
1342 | /* this is replacement to drain for players, instead of taking |
1343 | /* this is replacement to drain for players, instead of taking |
1343 | * exp it takes hp. It is geared for players, probably not |
1344 | * exp it takes hp. It is geared for players, probably not |
1344 | * much use giving it to monsters |
1345 | * much use giving it to monsters |
1345 | * |
1346 | * |
1346 | * life stealing doesn't do a lot of damage, but it gives the |
1347 | * life stealing doesn't do a lot of damage, but it gives the |
1347 | * damage it does do to the player. Given that, |
1348 | * damage it does do to the player. Given that, |
1348 | * it only does 1/10'th normal damage (hence the divide by |
1349 | * it only does 1/10'th normal damage (hence the divide by |
1349 | * 1000). |
1350 | * 1000). |
1350 | */ |
1351 | */ |
1351 | /* You can't steal life from something undead */ |
1352 | /* You can't steal life from something undead */ |
1352 | if ((op->type == GOLEM) || (QUERY_FLAG (op, FLAG_UNDEAD))) |
1353 | if ((op->type == GOLEM) || (QUERY_FLAG (op, FLAG_UNDEAD))) |
1353 | return 0; |
1354 | return 0; |
1354 | /* If drain protection is higher than life stealing, use that */ |
1355 | /* If drain protection is higher than life stealing, use that */ |
1355 | if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING]) |
1356 | if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING]) |
1356 | dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000; |
1357 | dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000; |
1357 | else |
1358 | else |
1358 | dam = (dam * (100 - op->resist[ATNR_LIFE_STEALING])) / 3000; |
1359 | dam = (dam * (100 - op->resist[ATNR_LIFE_STEALING])) / 3000; |
1359 | /* You die at -1 hp, not zero. */ |
1360 | /* You die at -1 hp, not zero. */ |
1360 | if (dam > (op->stats.hp + 1)) |
1361 | if (dam > (op->stats.hp + 1)) |
1361 | dam = op->stats.hp + 1; |
1362 | dam = op->stats.hp + 1; |
1362 | new_hp = hitter->stats.hp + dam; |
1363 | new_hp = hitter->stats.hp + dam; |
1363 | if (new_hp > hitter->stats.maxhp) |
1364 | if (new_hp > hitter->stats.maxhp) |
1364 | new_hp = hitter->stats.maxhp; |
1365 | new_hp = hitter->stats.maxhp; |
1365 | if (new_hp > hitter->stats.hp) |
1366 | if (new_hp > hitter->stats.hp) |
1366 | hitter->stats.hp = new_hp; |
1367 | hitter->stats.hp = new_hp; |
1367 | } |
1368 | } |
1368 | } |
1369 | } |
|
|
1370 | |
1369 | return dam; |
1371 | return dam; |
1370 | } |
1372 | } |
1371 | |
|
|
1372 | |
1373 | |
1373 | /* GROS: This code comes from hit_player. It has been made external to |
1374 | /* GROS: This code comes from hit_player. It has been made external to |
1374 | * allow script procedures to "kill" objects in a combat-like fashion. |
1375 | * allow script procedures to "kill" objects in a combat-like fashion. |
1375 | * It was initially used by (kill-object) developed for the Collector's |
1376 | * It was initially used by (kill-object) developed for the Collector's |
1376 | * Sword. Note that nothing has been changed from the original version |
1377 | * Sword. Note that nothing has been changed from the original version |
… | |
… | |
1691 | * is what is hitting the object, type is the attacktype, and |
1692 | * is what is hitting the object, type is the attacktype, and |
1692 | * full_hit is set if monster area does not matter. |
1693 | * full_hit is set if monster area does not matter. |
1693 | * dam is base damage - protections/vulnerabilities/slaying matches can |
1694 | * dam is base damage - protections/vulnerabilities/slaying matches can |
1694 | * modify it. |
1695 | * modify it. |
1695 | */ |
1696 | */ |
1696 | |
|
|
1697 | /* Oct 95 - altered the following slightly for MULTIPLE_GODS hack |
1697 | /* Oct 95 - altered the following slightly for MULTIPLE_GODS hack |
1698 | * which needs new attacktype AT_HOLYWORD to work . b.t. */ |
1698 | * which needs new attacktype AT_HOLYWORD to work . b.t. */ |
1699 | |
|
|
1700 | int |
1699 | int |
1701 | hit_player (object *op, int dam, object *hitter, int type, int full_hit) |
1700 | hit_player (object *op, int dam, object *hitter, int type, int full_hit) |
1702 | { |
1701 | { |
1703 | int maxdam = 0, ndam = 0, attacktype = 1, magic = (type & AT_MAGIC); |
1702 | int maxdam = 0, ndam = 0, attacktype = 1, magic = (type & AT_MAGIC); |
1704 | int maxattacktype, attacknum; |
1703 | int maxattacktype, attacknum; |