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.81 by root, Tue Apr 22 02:46:18 2008 UTC vs.
Revision 1.95 by root, Mon Sep 29 10:31:32 2008 UTC

62 CLEAR_FLAG (op, FLAG_DAMNED); 62 CLEAR_FLAG (op, FLAG_DAMNED);
63 CLEAR_FLAG (op, FLAG_CURSED); 63 CLEAR_FLAG (op, FLAG_CURSED);
64 CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL); 64 CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL);
65 CLEAR_FLAG (op, FLAG_KNOWN_CURSED); 65 CLEAR_FLAG (op, FLAG_KNOWN_CURSED);
66 66
67 if (op->env && op->env->type == PLAYER) 67 if (object *pl = op->visible_to ())
68 esrv_send_item (op->env, op); 68 esrv_update_item (UPD_FLAGS, pl, op);
69 } 69 }
70} 70}
71 71
72/* did_make_save_item just checks to make sure the item actually 72/* did_make_save_item just checks to make sure the item actually
73 * made its saving throw based on the tables. It does not take 73 * made its saving throw based on the tables. It does not take
77did_make_save_item (object *op, int type, object *originator) 77did_make_save_item (object *op, int type, object *originator)
78{ 78{
79 int i, roll, saves = 0, attacks = 0, number; 79 int i, roll, saves = 0, attacks = 0, number;
80 materialtype_t *mt; 80 materialtype_t *mt;
81 81
82 if (op->materialname == NULL) 82 if (!op->materialname)
83 { 83 {
84 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) 84 for (mt = materialt; mt && mt->next; mt = mt->next)
85 if (op->materials & mt->material) 85 if (op->materials & mt->material)
86 break; 86 break;
87 } 87 }
88 else 88 else
89 mt = name_to_material (op->materialname); 89 mt = name_to_material (op->materialname);
104 if (type != AT_MAGIC) 104 if (type != AT_MAGIC)
105 type &= ~(AT_CONFUSION | AT_DRAIN | AT_GHOSTHIT | AT_POISON | AT_SLOW | 105 type &= ~(AT_CONFUSION | AT_DRAIN | AT_GHOSTHIT | AT_POISON | AT_SLOW |
106 AT_PARALYZE | AT_TURN_UNDEAD | AT_FEAR | AT_DEPLETE | AT_DEATH | 106 AT_PARALYZE | AT_TURN_UNDEAD | AT_FEAR | AT_DEPLETE | AT_DEATH |
107 AT_COUNTERSPELL | AT_HOLYWORD | AT_BLIND | AT_LIFE_STEALING | AT_MAGIC); 107 AT_COUNTERSPELL | AT_HOLYWORD | AT_BLIND | AT_LIFE_STEALING | AT_MAGIC);
108 108
109 if (type == 0) 109 if (type == 0) return TRUE;
110 return TRUE; 110
111 if (roll == 20) 111 if (roll == 20) return TRUE;
112 return TRUE; 112 if (roll == 1) return FALSE;
113 if (roll == 1)
114 return FALSE;
115 113
116 for (number = 0; number < NROFATTACKS; number++) 114 for (number = 0; number < NROFATTACKS; number++)
117 { 115 {
118 i = 1 << number; 116 i = 1 << number;
117
119 if (!(i & type)) 118 if (!(i & type))
120 continue; 119 continue;
120
121 attacks++; 121 attacks++;
122 if (op->resist[number] == 100) 122 if (op->resist[number] == 100)
123 saves++; 123 saves++;
124 else if (roll >= mt->save[number] - op->magic - op->resist[number] / 100) 124 else if (roll >= mt->save[number] - op->magic - op->resist[number] / 100)
125 saves++; 125 saves++;
148 object *env = op->env; 148 object *env = op->env;
149 int x = op->x, y = op->y; 149 int x = op->x, y = op->y;
150 maptile *m = op->map; 150 maptile *m = op->map;
151 151
152 op = stop_item (op); 152 op = stop_item (op);
153 if (op == NULL) 153 if (!op)
154 return; 154 return;
155 155
156 /* Hacked the following so that type LIGHTER will work. 156 /* Hacked the following so that type LIGHTER will work.
157 * Also, objects which are potenital "lights" that are hit by 157 * Also, objects which are potential "lights" that are hit by
158 * flame/elect attacks will be set to glow. "lights" are any 158 * flame/elect attacks will be set to glow. "lights" are any
159 * object with +/- glow_radius and an "other_arch" to change to. 159 * object with +/- glow_radius and an "other_arch" to change to.
160 * (and please note that we cant fail our save and reach this 160 * (and please note that we cant fail our save and reach this
161 * function if the object doesnt contain a material that can burn. 161 * function if the object doesnt contain a material that can burn.
162 * So forget lighting magical swords on fire with this!) -b.t. 162 * So forget lighting magical swords on fire with this!) -b.t.
166 const char *arch = op->other_arch->archname; 166 const char *arch = op->other_arch->archname;
167 167
168 if (op->decrease ()) 168 if (op->decrease ())
169 fix_stopped_item (op, m, originator); 169 fix_stopped_item (op, m, originator);
170 170
171 if ((op = get_archetype (arch))) 171 if ((op = archetype::get (arch)))
172 { 172 {
173 if (env) 173 if (env)
174 { 174 env->insert (op);
175 op->x = env->x, op->y = env->y;
176 insert_ob_in_ob (op, env);
177 if (env->contr)
178 esrv_send_item (env, op);
179 }
180 else 175 else
181 {
182 op->x = x, op->y = y;
183 insert_ob_in_map (op, m, originator, 0); 176 m->insert (op, x, y, originator);
184 }
185 } 177 }
186 178
187 return; 179 return;
188 } 180 }
189 181
198 { 190 {
199 if (op->decrease (rndm (0, op->nrof - 1))) 191 if (op->decrease (rndm (0, op->nrof - 1)))
200 fix_stopped_item (op, m, originator); 192 fix_stopped_item (op, m, originator);
201 } 193 }
202 else 194 else
195 {
196 // drop everything to the ground, if possible
197 op->insert_at (originator);
203 op->destroy (); 198 op->drop_and_destroy ();
199 }
204 200
205 if (type & (AT_FIRE | AT_ELECTRICITY)) 201 if (type & (AT_FIRE | AT_ELECTRICITY))
206 if (env) 202 if (env)
207 { 203 {
208 op = get_archetype ("burnout"); 204 op = archetype::get (shstr_burnout);
209 op->x = env->x, op->y = env->y; 205 op->x = env->x, op->y = env->y;
210 insert_ob_in_ob (op, env); 206 env->insert (op);
211 } 207 }
212 else 208 else
213 replace_insert_ob_in_map ("burnout", originator); 209 replace_insert_ob_in_map (shstr_burnout, originator);
214 210
215 return; 211 return;
216 } 212 }
217 213
218 /* The value of 50 is arbitrary. */ 214 /* The value of 50 is arbitrary. */
219 if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && (RANDOM () & 2)) 215 if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && rndm (2))
220 { 216 {
221 object *tmp;
222 archetype *at = archetype::find ("icecube"); 217 archetype *at = archetype::find (shstr_icecube);
223 218
224 if (at == NULL) 219 if (at == NULL)
225 return; 220 return;
226 221
227 op = stop_item (op); 222 op = stop_item (op);
228 if (op == NULL) 223 if (op == NULL)
229 return; 224 return;
230 225
231 if ((tmp = present_arch (at, op->map, op->x, op->y)) == NULL) 226 object *tmp = present_arch (at, op->map, op->x, op->y);
227 if (!tmp)
232 { 228 {
233 tmp = arch_to_object (at); 229 tmp = arch_to_object (at);
234 tmp->x = op->x, tmp->y = op->y; 230 tmp->x = op->x, tmp->y = op->y;
235 /* This was in the old (pre new movement code) - 231 /* This was in the old (pre new movement code) -
236 * icecubes have slow_move set to 1 - don't want 232 * icecubes have slow_move set to 1 - don't want
239 tmp->move_slow_penalty = 0; 235 tmp->move_slow_penalty = 0;
240 tmp->move_slow = 0; 236 tmp->move_slow = 0;
241 insert_ob_in_map (tmp, op->map, originator, 0); 237 insert_ob_in_map (tmp, op->map, originator, 0);
242 } 238 }
243 239
244 if (!QUERY_FLAG (op, FLAG_REMOVED)) 240 tmp->insert (op);
245 op->remove ();
246
247 insert_ob_in_ob (op, tmp);
248 return; 241 return;
249 } 242 }
250} 243}
251 244
252/* Object op is hitting the map. 245/* Object op is hitting the map.
281 } 274 }
282 275
283 if (op->head) 276 if (op->head)
284 op = op->head; 277 op = op->head;
285 278
286 map = op->map; 279 mapxy pos (op);
287 x = op->x + freearr_x[dir]; 280 pos.move (dir);
288 y = op->y + freearr_y[dir];
289 281
290 if (!xy_normalise (map, x, y)) 282 if (!pos.normalise ())
291 return 0; 283 return 0;
292 284
293 // elmex: a safe map tile can't be hit! 285 // elmex: a safe map tile can't be hit!
294 // this should prevent most harmful effects on items and players there. 286 // this should prevent most harmful effects on items and players there.
295 mapspace &ms = map->at (x, y); 287 mapspace &ms = pos.ms ();
296 288
297 if (ms.flags () & P_SAFE) 289 if (ms.flags () & P_SAFE)
298 return 0; 290 return 0;
299 291
300 /* peterm: a few special cases for special attacktypes --counterspell 292 /* peterm: a few special cases for special attacktypes --counterspell
338 330
339 /* Something could have happened to 'tmp' while 'tmp->below' was processed. 331 /* Something could have happened to 'tmp' while 'tmp->below' was processed.
340 * For example, 'tmp' was put in an icecube. 332 * For example, 'tmp' was put in an icecube.
341 * This is one of the few cases where on_same_map should not be used. 333 * This is one of the few cases where on_same_map should not be used.
342 */ 334 */
343 if (tmp->map != map || tmp->x != x || tmp->y != y) 335 if (tmp->map != pos.m || tmp->x != pos.x || tmp->y != pos.y)
344 continue; 336 continue;
345 337
346 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 338 if (QUERY_FLAG (tmp, FLAG_ALIVE))
347 { 339 {
348 hit_player (tmp, op->stats.dam, op, type, full_hit); 340 hit_player (tmp, op->stats.dam, op, type, full_hit);
525 { 517 {
526 int mtype; 518 int mtype;
527 519
528 switch (hitter->current_weapon->weapontype) 520 switch (hitter->current_weapon->weapontype)
529 { 521 {
530 case WEAP_HIT: 522 case WEAP_HIT:
531 mtype = ATM_BASIC; 523 mtype = ATM_BASIC;
532 break; 524 break;
533 case WEAP_SLASH: 525 case WEAP_SLASH:
534 mtype = ATM_SLASH; 526 mtype = ATM_SLASH;
535 break; 527 break;
536 case WEAP_PIERCE: 528 case WEAP_PIERCE:
537 mtype = ATM_PIERCE; 529 mtype = ATM_PIERCE;
538 break; 530 break;
539 case WEAP_CLEAVE: 531 case WEAP_CLEAVE:
540 mtype = ATM_CLEAVE; 532 mtype = ATM_CLEAVE;
541 break; 533 break;
542 case WEAP_SLICE: 534 case WEAP_SLICE:
543 mtype = ATM_SLICE; 535 mtype = ATM_SLICE;
544 break; 536 break;
545 case WEAP_STAB: 537 case WEAP_STAB:
546 mtype = ATM_STAB; 538 mtype = ATM_STAB;
547 break; 539 break;
548 case WEAP_WHIP: 540 case WEAP_WHIP:
549 mtype = ATM_WHIP; 541 mtype = ATM_WHIP;
550 break; 542 break;
551 case WEAP_CRUSH: 543 case WEAP_CRUSH:
552 mtype = ATM_CRUSH; 544 mtype = ATM_CRUSH;
553 break; 545 break;
554 case WEAP_BLUD: 546 case WEAP_BLUD:
555 mtype = ATM_BLUD; 547 mtype = ATM_BLUD;
556 break; 548 break;
557 default: 549 default:
558 mtype = ATM_BASIC; 550 mtype = ATM_BASIC;
559 break; 551 break;
560 } 552 }
553
561 for (i = 0; i < MAXATTACKMESS && attack_mess[mtype][i].level != -1; i++) 554 for (i = 0; i < MAXATTACKMESS && attack_mess[mtype][i].level != -1; i++)
562 if (dam < attack_mess[mtype][i].level || attack_mess[mtype][i + 1].level == -1) 555 if (dam < attack_mess[mtype][i].level || attack_mess[mtype][i + 1].level == -1)
563 { 556 {
564 sprintf (buf1, "%s %s%s", attack_mess[mtype][i].buf1, &op->name, attack_mess[mtype][i].buf2); 557 sprintf (buf1, "%s %s%s", attack_mess[mtype][i].buf1, &op->name, attack_mess[mtype][i].buf2);
565 strcpy (buf2, attack_mess[mtype][i].buf3); 558 strcpy (buf2, attack_mess[mtype][i].buf3);
682 *target = (*target)->head; 675 *target = (*target)->head;
683 676
684 if ((*hitter)->head) 677 if ((*hitter)->head)
685 *hitter = (*hitter)->head; 678 *hitter = (*hitter)->head;
686 679
680 if ((*target)->type == LOCKED_DOOR)
681 return 1; // locked doors cannot be hit
682
687 if ((*hitter)->env != NULL || (*target)->env != NULL) 683 if ((*hitter)->env || (*target)->env)
688 { 684 {
689 *simple_attack = 1; 685 *simple_attack = 1;
690 return 0; 686 return 0;
691 } 687 }
692 688
871 * debate - 5000 is 5 kg, so arrows, knives, and other light weapons 867 * debate - 5000 is 5 kg, so arrows, knives, and other light weapons
872 * stick around. 868 * stick around.
873 */ 869 */
874 if (op->weight <= 5000 && tmp->stats.hp >= 0) 870 if (op->weight <= 5000 && tmp->stats.hp >= 0)
875 { 871 {
876 tmp = tmp->head_ (); 872 tmp->head_ ()->insert (op);
877
878 op->remove ();
879 op = insert_ob_in_ob (op, tmp);
880
881 if (tmp->type == PLAYER)
882 esrv_send_item (tmp, op);
883
884 return 1; 873 return 1;
885 } 874 }
886 else 875 else
887 return 0; 876 return 0;
888} 877}
902 /* Disassemble missile */ 891 /* Disassemble missile */
903 if (op->inv) 892 if (op->inv)
904 { 893 {
905 container = op; 894 container = op;
906 hitter = op->inv; 895 hitter = op->inv;
907 hitter->remove (); 896 container->insert_at (hitter, hitter, INS_NO_MERGE | INS_NO_WALK_ON);
908 insert_ob_in_map (hitter, container->map, hitter, INS_NO_MERGE | INS_NO_WALK_ON);
909 /* Note that we now have an empty THROWN_OBJ on the map. Code that 897 /* Note that we now have an empty THROWN_OBJ on the map. Code that
910 * might be called until this THROWN_OBJ is either reassembled or 898 * might be called until this THROWN_OBJ is either reassembled or
911 * removed at the end of this function must be able to deal with empty 899 * removed at the end of this function must be able to deal with empty
912 * THROWN_OBJs. */ 900 * THROWN_OBJs. */
913 } 901 }
927 * other places as well!) 915 * other places as well!)
928 */ 916 */
929 if (hitter->destroyed () || hitter->env != NULL) 917 if (hitter->destroyed () || hitter->env != NULL)
930 { 918 {
931 if (container) 919 if (container)
932 {
933 container->remove ();
934 container->destroy (); 920 container->destroy (true);
935 }
936 921
937 return 0; 922 return 0;
938 } 923 }
939 924
940 /* Missile hit victim */ 925 /* Missile hit victim */
949 hitter = fix_stopped_arrow (hitter); 934 hitter = fix_stopped_arrow (hitter);
950 if (!hitter) 935 if (!hitter)
951 return 0; 936 return 0;
952 } 937 }
953 else 938 else
954 container->destroy (); 939 container->destroy (true);
955 940
956 /* Try to stick arrow into victim */ 941 /* Try to stick arrow into victim */
957 if (!victim->destroyed () && stick_arrow (hitter, victim)) 942 if (!victim->destroyed () && stick_arrow (hitter, victim))
958 return 0; 943 return 0;
959 944
1003 } 988 }
1004 else if (!GET_ANIM_ID (op)) 989 else if (!GET_ANIM_ID (op))
1005 { 990 {
1006 /* Object has been called - no animations, so remove it */ 991 /* Object has been called - no animations, so remove it */
1007 if (op->stats.hp < 0) 992 if (op->stats.hp < 0)
1008 op->destroy (); 993 op->destroy (true);
1009 994
1010 return; /* no animations, so nothing more to do */ 995 return; /* no animations, so nothing more to do */
1011 } 996 }
1012 997
1013 perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp; 998 perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp;
1022 1007
1023 if (perc == NUM_ANIMATIONS (op) - 1) 1008 if (perc == NUM_ANIMATIONS (op) - 1)
1024 { /* Reached the last animation */ 1009 { /* Reached the last animation */
1025 if (op->face == blank_face) 1010 if (op->face == blank_face)
1026 /* If the last face is blank, remove the ob */ 1011 /* If the last face is blank, remove the ob */
1027 op->destroy (); 1012 op->destroy (true);
1028 else 1013 else
1029 { /* The last face was not blank, leave an image */ 1014 { /* The last face was not blank, leave an image */
1030 CLEAR_FLAG (op, FLAG_BLOCKSVIEW); 1015 CLEAR_FLAG (op, FLAG_BLOCKSVIEW);
1031 update_all_los (op->map, op->x, op->y); 1016 update_all_los (op->map, op->x, op->y);
1032 op->move_block = 0; 1017 op->move_block = 0;
1202 1187
1203 /* High damage acid has better chance of corroding 1188 /* High damage acid has better chance of corroding
1204 objects */ 1189 objects */
1205 if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic) 1190 if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic)
1206 { 1191 {
1207 if (op->type == PLAYER)
1208 /* Make this more visible */
1209 new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op,
1210 "The %s's acid corrodes your %s!", query_name (hitter), query_name (tmp));
1211 flag = 1; 1192 flag = 1;
1212 tmp->magic--; 1193 tmp->magic--;
1213 if (op->type == PLAYER) 1194
1214 esrv_send_item (op, tmp); 1195 if (object *pl = tmp->visible_to ())
1196 {
1197 /* Make this more visible */
1198 new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, pl,
1199 "The %s's acid corrodes your %s!", query_name (hitter), query_name (tmp));
1200
1201 esrv_send_item (op, tmp); //TODO: UPD_NAME should be enough (it's enough in other cases)
1202 }
1215 } 1203 }
1216 } 1204 }
1217 1205
1218 if (flag) 1206 if (flag)
1219 op->update_stats (); /* Something was corroded */ 1207 op->update_stats (); /* Something was corroded */
1389 */ 1377 */
1390int 1378int
1391kill_object (object *op, int dam, object *hitter, int type) 1379kill_object (object *op, int dam, object *hitter, int type)
1392{ 1380{
1393 char buf[MAX_BUF]; 1381 char buf[MAX_BUF];
1394 const char *skill; 1382 shstr skill;
1395 int maxdam = 0; 1383 int maxdam = 0;
1396 int battleg = 0; /* true if op standing on battleground */ 1384 int battleg = 0; /* true if op standing on battleground */
1397 int pk = 0; /* true if op and what controls hitter are both players */ 1385 int pk = 0; /* true if op and what controls hitter are both players */
1398 object *owner = 0; 1386 object *owner = 0;
1399 object *skop = 0; 1387 object *skop = 0;
1420 return maxdam; 1408 return maxdam;
1421 } 1409 }
1422 1410
1423 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) 1411 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER)
1424 { 1412 {
1425 op->destroy (); 1413 op->drop_and_destroy ();
1426 return maxdam; 1414 return maxdam;
1427 } 1415 }
1428 1416
1429 /* Now lets start dealing with experience we get for killing something */ 1417 /* Now lets start dealing with experience we get for killing something */
1430 1418
1431 owner = hitter->owner; 1419 owner = hitter->outer_owner ();
1432 if (!owner) 1420 if (!owner)
1433 owner = hitter; 1421 owner = hitter;
1434 1422
1435 /* is the victim (op) standing on battleground? */ 1423 /* is the victim (op) standing on battleground? */
1436 if (op_on_battleground (op, NULL, NULL)) 1424 if (op_on_battleground (op, NULL, NULL))
1441 pk = 1; 1429 pk = 1;
1442 1430
1443 /* Player killed something */ 1431 /* Player killed something */
1444 if (owner->type == PLAYER) 1432 if (owner->type == PLAYER)
1445 { 1433 {
1446 Log_Kill (owner->name,
1447 query_name (op), op->type, (owner != hitter) ? query_name (hitter) : NULL, (owner != hitter) ? hitter->type : 0);
1448
1449 /* Log players killing other players - makes it easier to detect 1434 /* Log players killing other players - makes it easier to detect
1450 * and filter out malicious player killers - that is why the 1435 * and filter out malicious player killers - that is why the
1451 * ip address is included. 1436 * ip address is included.
1452 */ 1437 */
1453 if (op->type == PLAYER && !battleg) 1438 if (op->type == PLAYER && !battleg)
1491 1476
1492 /* This code below deals with finding the appropriate skill 1477 /* This code below deals with finding the appropriate skill
1493 * to credit exp to. This is a bit problematic - we should 1478 * to credit exp to. This is a bit problematic - we should
1494 * probably never really have to look at current_weapon->skill 1479 * probably never really have to look at current_weapon->skill
1495 */ 1480 */
1496 skill = 0;
1497
1498 if (hitter->skill && hitter->type != PLAYER) 1481 if (hitter->skill && hitter->type != PLAYER)
1499 skill = hitter->skill; 1482 skill = hitter->skill;
1500 else if (owner->chosen_skill) 1483 else if (owner->chosen_skill)
1501 { 1484 {
1502 skop = owner->chosen_skill; 1485 skop = owner->chosen_skill;
1503 skill = skop->skill; 1486 skill = skop->skill;
1504 } 1487 }
1505 else if (QUERY_FLAG (owner, FLAG_READY_WEAPON)) 1488 else if (QUERY_FLAG (owner, FLAG_READY_WEAPON))
1506 skill = owner->current_weapon->skill; 1489 skill = owner->current_weapon->skill;
1507 else 1490 else
1491 {
1508 LOG (llevError, "kill_object - unable to find skill that killed monster\n"); 1492 LOG (llevError, "kill_object - unable to find skill that killed monster\n");
1493 skill = 0;
1494 }
1509 1495
1510 /* We have the skill we want to credit to - now find the object this goes 1496 /* We have the skill we want to credit to - now find the object this goes
1511 * to. Make sure skop is an actual skill, and not a skill tool! 1497 * to. Make sure skop is an actual skill, and not a skill tool!
1512 */ 1498 */
1513 if ((!skop || skop->type != SKILL) && skill) 1499 skop = owner->contr->find_skill (skill);
1514 {
1515 int i;
1516
1517 for (i = 0; i < NUM_SKILLS; i++)
1518 if (owner->contr->last_skill_ob[i] && !strcmp (owner->contr->last_skill_ob[i]->skill, skill))
1519 {
1520 skop = owner->contr->last_skill_ob[i];
1521 break;
1522 }
1523 }
1524 } /* Was it a player that hit somethign */ 1500 } /* Was it a player that hit somethign */
1525 else 1501 else
1526 skill = 0; 1502 skill = 0;
1527 1503
1528 /* Pet (or spell) killed something. */
1529 if (owner != hitter)
1530 sprintf (buf, "%s killed %s with %s%s%s.", &owner->name,
1531 query_name (op), query_name (hitter), battleg ? " (duel)" : "", pk ? " (pk)" : "");
1532 else
1533 sprintf (buf, "%s killed %s%s%s%s.", &hitter->name, &op->name,
1534 (QUERY_FLAG (hitter, FLAG_MONSTER)) || hitter->type == PLAYER ?
1535 " in hand to hand combat" : "", battleg ? " (duel)" : "", pk ? " (pk)" : "");
1536
1537 /* These may have been set in the player code section above */ 1504 /* These may have been set in the player code section above */
1538 if (!skop) 1505 if (!skop)
1539 skop = hitter->chosen_skill; 1506 skop = hitter->chosen_skill;
1540 1507
1541 if (!skill && skop) 1508 if (!skill && skop)
1542 skill = skop->skill; 1509 skill = skop->skill;
1543
1544 new_draw_info (NDI_ALL, op->type == PLAYER ? 1 : 10, NULL, buf);
1545 1510
1546 /* If you didn't kill yourself, and your not the wizard */ 1511 /* If you didn't kill yourself, and your not the wizard */
1547 if (owner != op && !QUERY_FLAG (op, FLAG_WIZ)) 1512 if (owner != op && !QUERY_FLAG (op, FLAG_WIZ))
1548 { 1513 {
1549 int exp; 1514 int exp;
1621 1586
1622 if (owner1 && owner1->type == PLAYER) 1587 if (owner1 && owner1->type == PLAYER)
1623 { 1588 {
1624 owner1->contr->play_sound (sound_find ("pet_is_killed")); 1589 owner1->contr->play_sound (sound_find ("pet_is_killed"));
1625 /* Maybe we should include the owner that killed this, maybe not */ 1590 /* Maybe we should include the owner that killed this, maybe not */
1626 new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, is killed by %s.", &op->name, &hitter->name); 1591 new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, was killed by %s.", &op->name, &hitter->name);
1627 } 1592 }
1628 1593
1629 remove_friendly_object (op); 1594 remove_friendly_object (op);
1630 } 1595 }
1631 1596
1632 op->destroy (); 1597 op->drop_and_destroy ();
1633 } 1598 }
1634 else 1599 else
1635 {
1636 /* Player has been killed! */ 1600 /* Player has been killed! */
1637 if (owner->type == PLAYER) 1601 op->contr->killer = owner->type == PLAYER ? owner : hitter;
1638 snprintf (op->contr->killer, sizeof (op->contr->killer), "%s the %s", &owner->name, owner->contr->title);
1639 else
1640 assign (op->contr->killer, hitter->name);
1641 }
1642 1602
1643 /* This was return -1 - that doesn't seem correct - if we return -1, process 1603 /* This was return -1 - that doesn't seem correct - if we return -1, process
1644 * continues in the calling function. 1604 * continues in the calling function.
1645 */ 1605 */
1646 return maxdam; 1606 return maxdam;
1928 /* See if the creature has been killed */ 1888 /* See if the creature has been killed */
1929 rtn_kill = kill_object (op, maxdam, hitter, type); 1889 rtn_kill = kill_object (op, maxdam, hitter, type);
1930 if (rtn_kill != -1) 1890 if (rtn_kill != -1)
1931 return rtn_kill; 1891 return rtn_kill;
1932 1892
1933
1934 /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note 1893 /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note
1935 * that before if the player was immune to ghosthit, the monster 1894 * that before if the player was immune to ghosthit, the monster
1936 * remained - that is no longer the case. 1895 * remained - that is no longer the case.
1937 */ 1896 */
1938 if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) 1897 if (QUERY_FLAG (hitter, FLAG_ONE_HIT))
1939 hitter->destroy (); 1898 hitter->drop_and_destroy ();
1940
1941 /* Lets handle creatures that are splitting now */ 1899 /* Lets handle creatures that are splitting now */
1942 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) 1900 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING))
1943 { 1901 {
1944 int i; 1902 int i;
1945 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); 1903 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY);
1974 SET_FLAG (tmp, FLAG_UNAGGRESSIVE); 1932 SET_FLAG (tmp, FLAG_UNAGGRESSIVE);
1975 1933
1976 j = find_first_free_spot (tmp, op->map, op->x, op->y); 1934 j = find_first_free_spot (tmp, op->map, op->x, op->y);
1977 1935
1978 if (j == -1) /* No spot to put this monster */ 1936 if (j == -1) /* No spot to put this monster */
1979 tmp->destroy (); 1937 tmp->destroy (true);
1980 else 1938 else
1981 { 1939 {
1982 tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; 1940 tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j];
1983 insert_ob_in_map (tmp, op->map, NULL, 0); 1941 insert_ob_in_map (tmp, op->map, NULL, 0);
1984 } 1942 }
1985 } 1943 }
1986 1944
1987 op->destroy (); 1945 op->destroy (true);
1988 } 1946 }
1989 else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) 1947 else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10)
1990 hitter->destroy (); 1948 hitter->drop_and_destroy ();
1991 1949
1992 return maxdam; 1950 return maxdam;
1993} 1951}
1994 1952
1995void 1953void
2198 return; 2156 return;
2199 2157
2200 def_lev = op->level; 2158 def_lev = op->level;
2201 if (def_lev < 1) 2159 if (def_lev < 1)
2202 { 2160 {
2203 LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->archname, &op->name); 2161 LOG (llevError, "BUG: arch %s with level < 1 (%s)\n", &op->arch->archname, op->debug_desc ());
2204 def_lev = 1; 2162 def_lev = 1;
2205 } 2163 }
2206 2164
2207 atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; 2165 atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2;
2208 /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", 2166 /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines