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

Comparing deliantra/server/server/attack.C (file contents):
Revision 1.40 by root, Sun Jan 14 22:06:05 2007 UTC vs.
Revision 1.50 by pippijn, Thu Mar 1 12:28:16 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
3 3 *
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 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 *
8 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 * (at your option) any later version.
12 12 *
13 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 * GNU General Public License for more details.
17 17 *
18 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 21 *
22 The authors can be reached via e-mail to <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23*/ 23 */
24#include <assert.h> 24#include <assert.h>
25#include <global.h> 25#include <global.h>
26#include <living.h> 26#include <living.h>
27#include <material.h> 27#include <material.h>
28#include <skills.h> 28#include <skills.h>
45 * its magical benefits. 45 * its magical benefits.
46 */ 46 */
47void 47void
48cancellation (object *op) 48cancellation (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
86 materialtype_t *mt; 84 materialtype_t *mt;
87 85
88 if (op->materialname == NULL) 86 if (op->materialname == NULL)
89 { 87 {
90 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) 88 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next)
91 if (op->material & mt->material) 89 if (op->materials & mt->material)
92 break; 90 break;
93 } 91 }
94 else 92 else
95 mt = name_to_material (op->materialname); 93 mt = name_to_material (op->materialname);
96 94
133 saves++; 131 saves++;
134 } 132 }
135 133
136 if (saves == attacks || attacks == 0) 134 if (saves == attacks || attacks == 0)
137 return TRUE; 135 return TRUE;
136
138 if ((saves == 0) || (rndm (1, attacks) > saves)) 137 if (saves == 0 || (rndm (1, attacks) > saves))
139 return FALSE; 138 return FALSE;
139
140 return TRUE; 140 return TRUE;
141} 141}
142 142
143/* This function calls did_make_save_item. It then performs the 143/* This function calls did_make_save_item. It then performs the
144 * appropriate actions to the item (such as burning the item up, 144 * appropriate actions to the item (such as burning the item up,
145 * calling cancellation, etc.) 145 * calling cancellation, etc.)
146 */ 146 */
147
148void 147void
149save_throw_object (object *op, int type, object *originator) 148save_throw_object (object *op, int type, object *originator)
150{ 149{
151 if (!did_make_save_item (op, type, originator)) 150 if (!did_make_save_item (op, type, originator))
152 { 151 {
305 304
306 map = op->map; 305 map = op->map;
307 x = op->x + freearr_x[dir]; 306 x = op->x + freearr_x[dir];
308 y = op->y + freearr_y[dir]; 307 y = op->y + freearr_y[dir];
309 308
310 int mflags = get_map_flags (map, &map, x, y, &x, &y); 309 if (!xy_normalise (map, x, y))
310 return 0;
311 311
312 // elmex: a safe map tile can't be hit! 312 // elmex: a safe map tile can't be hit!
313 // this should prevent most harmful effects on items and players there. 313 // this should prevent most harmful effects on items and players there.
314 if (mflags & (P_OUT_OF_MAP | P_SAFE)) 314 mapspace &ms = map->at (x, y);
315
316 if (ms.flags () & P_SAFE)
315 return 0; 317 return 0;
316 318
317 /* peterm: a few special cases for special attacktypes --counterspell 319 /* peterm: a few special cases for special attacktypes --counterspell
318 * must be out here because it strikes things which are not alive 320 * must be out here because it strikes things which are not alive
319 */ 321 */
320 322 if (type & (AT_COUNTERSPELL | AT_CHAOS))
323 {
321 if (type & AT_COUNTERSPELL) 324 if (type & AT_COUNTERSPELL)
322 { 325 {
323 counterspell (op, dir); /* see spell_effect.c */ 326 counterspell (op, dir); /* see spell_effect.c */
324 327
325 /* If the only attacktype is counterspell or magic, don't need 328 /* If the only attacktype is counterspell or magic, don't need
326 * to do any further processing. 329 * to do any further processing.
327 */ 330 */
328 if (!(type & ~(AT_COUNTERSPELL | AT_MAGIC))) 331 if (!(type & ~(AT_COUNTERSPELL | AT_MAGIC)))
329 return 0; 332 return 0;
330 333
331 type &= ~AT_COUNTERSPELL; 334 type &= ~AT_COUNTERSPELL;
332 } 335 }
333 336
334 if (type & AT_CHAOS) 337 if (type & AT_CHAOS)
335 { 338 {
336 shuffle_attack (op, 1); /*1 flag tells it to change the face */ 339 shuffle_attack (op, 1); /* flag tells it to change the face */
337 update_object (op, UP_OBJ_FACE); 340 update_object (op, UP_OBJ_FACE);
338 type &= ~AT_CHAOS; 341 type &= ~AT_CHAOS;
342 }
339 } 343 }
340 344
341 /* There may still be objects that were above 'next', but there is no 345 /* There may still be objects that were above 'next', but there is no
342 * simple way to find out short of copying all object references and 346 * simple way to find out short of copying all object references and
343 * tags into a temporary array before we start processing the first 347 * tags into a temporary array before we start processing the first
344 * object. That's why we just abort on destroy. 348 * object. That's why we just abort on destroy.
345 * 349 *
346 * This happens whenever attack spells (like fire) hit a pile 350 * This happens whenever attack spells (like fire) hit a pile
347 * of objects. This is not a bug - nor an error. 351 * of objects. This is not a bug - nor an error.
348 */ 352 */
349 for (object *next = map->at (x, y).bot; next && !next->destroyed (); ) 353 for (object *next = ms.bot; next && !next->destroyed (); )
350 { 354 {
351 object *tmp = next; 355 object *tmp = next;
352 next = tmp->above; 356 next = tmp->above;
353 357
354 /* Something could have happened to 'tmp' while 'tmp->below' was processed. 358 /* Something could have happened to 'tmp' while 'tmp->below' was processed.
360 364
361 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 365 if (QUERY_FLAG (tmp, FLAG_ALIVE))
362 { 366 {
363 hit_player (tmp, op->stats.dam, op, type, full_hit); 367 hit_player (tmp, op->stats.dam, op, type, full_hit);
364 retflag |= 1; 368 retflag |= 1;
369
365 if (op->destroyed ()) 370 if (op->destroyed ())
366 break; 371 break;
367 } 372 }
368 /* Here we are potentially destroying an object. If the object has 373 /* Here we are potentially destroying an object. If the object has
369 * NO_PASS set, it is also immune - you can't destroy walls. Note 374 * NO_PASS set, it is also immune - you can't destroy walls. Note
370 * that weak walls have is_alive set, which prevent objects from 375 * that weak walls have is_alive set, which prevent objects from
371 * passing over/through them. We don't care what type of movement 376 * passing over/through them. We don't care what type of movement
372 * the wall blocks - if it blocks any type of movement, can't be 377 * the wall blocks - if it blocks any type of movement, can't be
373 * destroyed right now. 378 * destroyed right now.
374 */ 379 */
375 else if ((tmp->material || tmp->materialname) && op->stats.dam > 0 && !tmp->move_block) 380 else if (tmp->materialname && op->stats.dam > 0 && !tmp->move_block)
376 { 381 {
377 save_throw_object (tmp, type, op); 382 save_throw_object (tmp, type, op);
378 383
379 if (op->destroyed ()) 384 if (op->destroyed ())
380 break; 385 break;
1069 * appropriate attacktype. Only 1 attacktype should be set at a time. 1074 * appropriate attacktype. Only 1 attacktype should be set at a time.
1070 * This doesn't damage the player, but returns how much it should 1075 * This doesn't damage the player, but returns how much it should
1071 * take. However, it will do other effects (paralyzation, slow, etc.) 1076 * take. However, it will do other effects (paralyzation, slow, etc.)
1072 * Note - changed for PR code - we now pass the attack number and not 1077 * Note - changed for PR code - we now pass the attack number and not
1073 * the attacktype. Makes it easier for the PR code. */ 1078 * the attacktype. Makes it easier for the PR code. */
1074
1075int 1079int
1076hit_player_attacktype (object *op, object *hitter, int dam, uint32 attacknum, int magic) 1080hit_player_attacktype (object *op, object *hitter, int dam, uint32 attacknum, int magic)
1077{ 1081{
1078 int doesnt_slay = 1; 1082 int doesnt_slay = 1;
1079 1083
1084 return 0; 1088 return 0;
1085 } 1089 }
1086 1090
1087 if (dam < 0) 1091 if (dam < 0)
1088 { 1092 {
1089 LOG (llevError, "hit_player_attacktype called with negative damage: %d\n", dam); 1093 LOG (llevError, "hit_player_attacktype called with negative damage %d (hitter %s, target %s)\n", dam, hitter->debug_desc (), op->debug_desc2 ());
1090 return 0; 1094 return 0;
1091 } 1095 }
1092 1096
1093 /* AT_INTERNAL is supposed to do exactly dam. Put a case here so 1097 /* AT_INTERNAL is supposed to do exactly dam. Put a case here so
1094 * people can't mess with that or it otherwise get confused. */ 1098 * people can't mess with that or it otherwise get confused. */
1183 blind_player (op, hitter, dam); 1187 blind_player (op, hitter, dam);
1184 } 1188 }
1185 dam = 0; /* These are all effects and don't do real damage */ 1189 dam = 0; /* These are all effects and don't do real damage */
1186 } 1190 }
1187 break; 1191 break;
1192
1188 case ATNR_ACID: 1193 case ATNR_ACID:
1189 { 1194 {
1190 int flag = 0; 1195 int flag = 0;
1191 1196
1192 /* Items only get corroded if you're not on a battleground and 1197 /* Items only get corroded if you're not on a battleground and
1193 * if your acid resistance is below 50%. */ 1198 * if your acid resistance is below 50%. */
1194 if (!op_on_battleground (op, NULL, NULL) && (op->resist[ATNR_ACID] < 50)) 1199 if (!op_on_battleground (op, NULL, NULL) && (op->resist[ATNR_ACID] < 50))
1195 { 1200 {
1196 object *tmp;
1197
1198 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 1201 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1199 { 1202 {
1200 if (tmp->invisible) 1203 if (tmp->invisible)
1201 continue; 1204 continue;
1202 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10)) 1205 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10))
1203 /* >= 10% acid res. on itmes will protect these */ 1206 /* >= 10% acid res. on items will protect these */
1204 continue; 1207 continue;
1205 if (!(tmp->material & M_IRON)) 1208 if (!(tmp->materials & M_IRON))
1206 continue; 1209 continue;
1207 if (tmp->magic < -4) /* Let's stop at -5 */ 1210 if (tmp->magic < -4) /* Let's stop at -5 */
1208 continue; 1211 continue;
1209 if (tmp->type == RING || 1212 if (tmp->type == RING
1210 /* removed boots and gloves from exclusion list in 1213 /* removed boots and gloves from exclusion list in PR */
1211 PR */ 1214 || tmp->type == GIRDLE
1212 tmp->type == GIRDLE || tmp->type == AMULET || tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1215 || tmp->type == AMULET
1216 || tmp->type == WAND
1217 || tmp->type == ROD
1218 || tmp->type == HORN)
1213 continue; /* To avoid some strange effects */ 1219 continue; /* To avoid some strange effects */
1214 1220
1215 /* High damage acid has better chance of corroding 1221 /* High damage acid has better chance of corroding
1216 objects */ 1222 objects */
1217 if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic) 1223 if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic)
1224 tmp->magic--; 1230 tmp->magic--;
1225 if (op->type == PLAYER) 1231 if (op->type == PLAYER)
1226 esrv_send_item (op, tmp); 1232 esrv_send_item (op, tmp);
1227 } 1233 }
1228 } 1234 }
1235
1229 if (flag) 1236 if (flag)
1230 op->update_stats (); /* Something was corroded */ 1237 op->update_stats (); /* Something was corroded */
1231 } 1238 }
1232 } 1239 }
1233 break; 1240 break;
1241
1234 case ATNR_DRAIN: 1242 case ATNR_DRAIN:
1235 { 1243 {
1236 /* rate is the proportion of exp drained. High rate means 1244 /* rate is the proportion of exp drained. High rate means
1237 * not much is drained, low rate means a lot is drained. 1245 * not much is drained, low rate means a lot is drained.
1238 */ 1246 */
1280 change_exp (hitter, op->stats.exp / (rate * 2), 1288 change_exp (hitter, op->stats.exp / (rate * 2),
1281 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0); 1289 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0);
1282 } 1290 }
1283 change_exp (op, -op->stats.exp / rate, NULL, 0); 1291 change_exp (op, -op->stats.exp / rate, NULL, 0);
1284 } 1292 }
1293
1285 dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure 1294 dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure
1286 * drain attack, you won't know that you are actually sucking out EXP, 1295 * drain attack, you won't know that you are actually sucking out EXP,
1287 * as the messages will say you missed 1296 * as the messages will say you missed
1288 */ 1297 */
1289 } 1298 }
1290 } 1299 }
1291 break; 1300 break;
1301
1292 case ATNR_TURN_UNDEAD: 1302 case ATNR_TURN_UNDEAD:
1293 { 1303 {
1294 if (QUERY_FLAG (op, FLAG_UNDEAD)) 1304 if (QUERY_FLAG (op, FLAG_UNDEAD))
1295 { 1305 {
1296 object *owner = hitter->owner ? (object *)hitter->owner : hitter; 1306 object *owner = hitter->owner ? (object *)hitter->owner : hitter;
1308 else 1318 else
1309 dam = 0; /* don't damage non undead - should we damage 1319 dam = 0; /* don't damage non undead - should we damage
1310 undead? */ 1320 undead? */
1311 } 1321 }
1312 break; 1322 break;
1323
1313 case ATNR_DEATH: 1324 case ATNR_DEATH:
1314 deathstrike_player (op, hitter, &dam); 1325 deathstrike_player (op, hitter, &dam);
1315 break; 1326 break;
1327
1316 case ATNR_CHAOS: 1328 case ATNR_CHAOS:
1317 LOG (llevError, "%s was hit by %s with non-specific chaos.\n", op->debug_desc (), hitter->debug_desc2 ()); 1329 LOG (llevError, "%s was hit by %s with non-specific chaos.\n", op->debug_desc (), hitter->debug_desc2 ());
1318 dam = 0; 1330 dam = 0;
1319 break; 1331 break;
1332
1320 case ATNR_COUNTERSPELL: 1333 case ATNR_COUNTERSPELL:
1321 LOG (llevError, "%s was hit by %s with counterspell attack.\n", op->debug_desc (), hitter->debug_desc2 ()); 1334 LOG (llevError, "%s was hit by %s with counterspell attack.\n", op->debug_desc (), hitter->debug_desc2 ());
1322 dam = 0; 1335 dam = 0;
1323 /* This should never happen. Counterspell is handled 1336 /* This should never happen. Counterspell is handled
1324 * seperately and filtered out. If this does happen, 1337 * seperately and filtered out. If this does happen,
1325 * Counterspell has no effect on anything but spells, so it 1338 * Counterspell has no effect on anything but spells, so it
1326 * does no damage. */ 1339 * does no damage. */
1327 break; 1340 break;
1341
1328 case ATNR_HOLYWORD: 1342 case ATNR_HOLYWORD:
1329 { 1343 {
1330 /* This has already been handled by hit_player, 1344 /* This has already been handled by hit_player,
1331 * no need to check twice -- DAMN */ 1345 * no need to check twice -- DAMN */
1332 object *owner = hitter->owner ? (object *)hitter->owner : hitter; 1346 object *owner = hitter->owner ? (object *)hitter->owner : hitter;
1334 /* As with turn undead above, give a bonus on the saving throw */ 1348 /* As with turn undead above, give a bonus on the saving throw */
1335 if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis]) 1349 if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis])
1336 scare_creature (op, owner); 1350 scare_creature (op, owner);
1337 } 1351 }
1338 break; 1352 break;
1353
1339 case ATNR_LIFE_STEALING: 1354 case ATNR_LIFE_STEALING:
1340 { 1355 {
1341 int new_hp; 1356 int new_hp;
1342 1357
1343 /* this is replacement to drain for players, instead of taking 1358 /* this is replacement to drain for players, instead of taking
1350 * 1000). 1365 * 1000).
1351 */ 1366 */
1352 /* You can't steal life from something undead */ 1367 /* You can't steal life from something undead */
1353 if ((op->type == GOLEM) || (QUERY_FLAG (op, FLAG_UNDEAD))) 1368 if ((op->type == GOLEM) || (QUERY_FLAG (op, FLAG_UNDEAD)))
1354 return 0; 1369 return 0;
1370
1355 /* If drain protection is higher than life stealing, use that */ 1371 /* If drain protection is higher than life stealing, use that */
1356 if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING]) 1372 if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING])
1357 dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000; 1373 dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000;
1358 else 1374 else
1359 dam = (dam * (100 - op->resist[ATNR_LIFE_STEALING])) / 3000; 1375 dam = (dam * (100 - op->resist[ATNR_LIFE_STEALING])) / 3000;
1376
1360 /* You die at -1 hp, not zero. */ 1377 /* You die at -1 hp, not zero. */
1361 if (dam > (op->stats.hp + 1)) 1378 if (dam > (op->stats.hp + 1))
1362 dam = op->stats.hp + 1; 1379 dam = op->stats.hp + 1;
1380
1363 new_hp = hitter->stats.hp + dam; 1381 new_hp = hitter->stats.hp + dam;
1364 if (new_hp > hitter->stats.maxhp) 1382 if (new_hp > hitter->stats.maxhp)
1365 new_hp = hitter->stats.maxhp; 1383 new_hp = hitter->stats.maxhp;
1384
1366 if (new_hp > hitter->stats.hp) 1385 if (new_hp > hitter->stats.hp)
1367 hitter->stats.hp = new_hp; 1386 hitter->stats.hp = new_hp;
1368 } 1387 }
1369 } 1388 }
1370 1389
1583 if (owner->type != PLAYER || owner->contr->party == NULL) 1602 if (owner->type != PLAYER || owner->contr->party == NULL)
1584 change_exp (owner, exp, skill, 0); 1603 change_exp (owner, exp, skill, 0);
1585 else 1604 else
1586 { 1605 {
1587 int shares = 0, count = 0; 1606 int shares = 0, count = 0;
1588 player *pl;
1589 partylist *party = owner->contr->party; 1607 partylist *party = owner->contr->party;
1590 1608
1591 add_kill_to_party (party, query_name (owner), query_name (op), exp); 1609 add_kill_to_party (party, query_name (owner), query_name (op), exp);
1592 1610
1593 for_all_players (pl) 1611 for_all_players (pl)
1746 } 1764 }
1747 } 1765 }
1748 1766
1749 if (!simple_attack && op->type == DOOR) 1767 if (!simple_attack && op->type == DOOR)
1750 { 1768 {
1751 object *tmp;
1752
1753 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 1769 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1754 if (tmp->type == RUNE || tmp->type == TRAP) 1770 if (tmp->type == RUNE || tmp->type == TRAP)
1755 { 1771 {
1756 spring_trap (tmp, hitter); 1772 spring_trap (tmp, hitter);
1757 1773
1758 if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack)) 1774 if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack))
1765 if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) 1781 if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0)
1766 { 1782 {
1767 /* FIXME: If a player is killed by a rune in a door, the 1783 /* FIXME: If a player is killed by a rune in a door, the
1768 * destroyed() check above doesn't return, and might get here. 1784 * destroyed() check above doesn't return, and might get here.
1769 */ 1785 */
1770 LOG (llevDebug, "victim (arch %s, name %s) already dead in " "hit_player()\n", &op->arch->name, &op->name); 1786 LOG (llevDebug, "victim %s already dead in hit_player()\n", op->debug_desc ());
1771 return 0; 1787 return 0;
1772 } 1788 }
1773 1789
1774#ifdef ATTACK_DEBUG 1790#ifdef ATTACK_DEBUG
1775 LOG (llevDebug, "hit player: attacktype %d, dam %d\n", type, dam); 1791 LOG (llevDebug, "hit player: attacktype %d, dam %d\n", type, dam);
1781 * in case 0>dam>1, we try to "simulate" a float value-effect */ 1797 * in case 0>dam>1, we try to "simulate" a float value-effect */
1782 dam = dam * (100 - op->resist[ATNR_MAGIC]); 1798 dam = dam * (100 - op->resist[ATNR_MAGIC]);
1783 if (dam >= 100) 1799 if (dam >= 100)
1784 dam /= 100; 1800 dam /= 100;
1785 else 1801 else
1786 dam = (dam > (rndm (0, 99))) ? 1 : 0; 1802 dam = (dam > rndm (0, 99)) ? 1 : 0;
1787 } 1803 }
1788 1804
1789 /* AT_CHAOS here is a weapon or monster. Spells are handled by hit_map 1805 /* AT_CHAOS here is a weapon or monster. Spells are handled by hit_map
1790 * If the attacktype still has chaos, shuffle it, then clear the Chaos bit 1806 * If the attacktype still has chaos, shuffle it, then clear the Chaos bit
1791 */ 1807 */
1874 1890
1875 /* basically: maxdam /= area; we try to "simulate" a float 1891 /* basically: maxdam /= area; we try to "simulate" a float
1876 value-effect */ 1892 value-effect */
1877 remainder = 100 * (maxdam % area) / area; 1893 remainder = 100 * (maxdam % area) / area;
1878 maxdam /= area; 1894 maxdam /= area;
1879 if (RANDOM () % 100 < remainder) 1895 if (rndm (100) < remainder)
1880 maxdam++; 1896 maxdam++;
1881 } 1897 }
1882 1898
1883#ifdef ATTACK_DEBUG 1899#ifdef ATTACK_DEBUG
1884 LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam); 1900 LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines