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.102 by root, Sun Dec 28 06:59:27 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 = 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
784 * for help. */ 780 * for help. */
785 if (op->type != PLAYER && !can_see_enemy (op, hitter) && !op->owner && rndm (0, op->stats.Int)) 781 if (op->type != PLAYER && !can_see_enemy (op, hitter) && !op->owner && rndm (0, op->stats.Int))
786 npc_call_help (op); 782 npc_call_help (op);
787 783
788 /* if you were hidden and hit by a creature, you are discovered */ 784 /* if you were hidden and hit by a creature, you are discovered */
789 if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE)) 785 if (op->flag [FLAG_HIDDEN] && hitter->flag [FLAG_ALIVE])
790 { 786 {
791 make_visible (op); 787 make_visible (op);
792 788
793 if (op->type == PLAYER) 789 if (op->type == PLAYER)
794 new_draw_info (NDI_UNIQUE, 0, op, "You were hit by a wild attack. " "You are no longer hidden!"); 790 new_draw_info (NDI_UNIQUE, 0, op, "You were hit by a wild attack. " "You are no longer hidden!");
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 ();
908 insert_ob_in_map (hitter, container->map, hitter, INS_NO_MERGE | INS_NO_WALK_ON); 896 hitter->insert_at (container, 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 ();
935 }
936 921
937 return 0; 922 return 0;
938 } 923 }
939 924
940 /* Missile hit victim */ 925 /* Missile hit victim */
964 * can fly over but not otherwise move over. What is the correct 949 * can fly over but not otherwise move over. What is the correct
965 * way to handle those otherwise? 950 * way to handle those otherwise?
966 */ 951 */
967 if (victim->x != hitter->x || victim->y != hitter->y) 952 if (victim->x != hitter->x || victim->y != hitter->y)
968 { 953 {
954 if (victim->destroyed ())
955 hitter->destroy ();
956 else
957 {
969 hitter->remove (); 958 hitter->remove ();
970 hitter->x = victim->x; 959 hitter->x = victim->x;
971 hitter->y = victim->y; 960 hitter->y = victim->y;
972 insert_ob_in_map (hitter, victim->map, hitter, 0); 961 insert_ob_in_map (hitter, victim->map, hitter, 0);
962 }
973 } 963 }
974 else 964 else
975 /* Else leave arrow where it is */ 965 /* Else leave arrow where it is */
976 merge_ob (hitter, NULL); 966 merge_ob (hitter, NULL);
977 967
1202 1192
1203 /* High damage acid has better chance of corroding 1193 /* High damage acid has better chance of corroding
1204 objects */ 1194 objects */
1205 if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic) 1195 if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic)
1206 { 1196 {
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; 1197 flag = 1;
1212 tmp->magic--; 1198 tmp->magic--;
1213 if (op->type == PLAYER) 1199
1214 esrv_send_item (op, tmp); 1200 if (object *pl = tmp->visible_to ())
1201 {
1202 /* Make this more visible */
1203 new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, pl,
1204 "The %s's acid corrodes your %s!", query_name (hitter), query_name (tmp));
1205
1206 esrv_send_item (op, tmp); //TODO: UPD_NAME should be enough (it's enough in other cases)
1207 }
1215 } 1208 }
1216 } 1209 }
1217 1210
1218 if (flag) 1211 if (flag)
1219 op->update_stats (); /* Something was corroded */ 1212 op->update_stats (); /* Something was corroded */
1389 */ 1382 */
1390int 1383int
1391kill_object (object *op, int dam, object *hitter, int type) 1384kill_object (object *op, int dam, object *hitter, int type)
1392{ 1385{
1393 char buf[MAX_BUF]; 1386 char buf[MAX_BUF];
1394 const char *skill; 1387 shstr skill;
1395 int maxdam = 0; 1388 int maxdam = 0;
1396 int battleg = 0; /* true if op standing on battleground */ 1389 int battleg = 0; /* true if op standing on battleground */
1397 int pk = 0; /* true if op and what controls hitter are both players */ 1390 int pk = 0; /* true if op and what controls hitter are both players */
1398 object *owner = 0; 1391 object *owner = 0;
1399 object *skop = 0; 1392 object *skop = 0;
1420 return maxdam; 1413 return maxdam;
1421 } 1414 }
1422 1415
1423 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) 1416 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER)
1424 { 1417 {
1425 op->destroy (); 1418 op->drop_and_destroy ();
1426 return maxdam; 1419 return maxdam;
1427 } 1420 }
1428 1421
1429 /* Now lets start dealing with experience we get for killing something */ 1422 /* Now lets start dealing with experience we get for killing something */
1430 1423
1431 owner = hitter->owner; 1424 owner = hitter->outer_owner ();
1432 if (!owner) 1425 if (!owner)
1433 owner = hitter; 1426 owner = hitter;
1434 1427
1435 /* is the victim (op) standing on battleground? */ 1428 /* is the victim (op) standing on battleground? */
1436 if (op_on_battleground (op, NULL, NULL)) 1429 if (op_on_battleground (op, NULL, NULL))
1441 pk = 1; 1434 pk = 1;
1442 1435
1443 /* Player killed something */ 1436 /* Player killed something */
1444 if (owner->type == PLAYER) 1437 if (owner->type == PLAYER)
1445 { 1438 {
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 1439 /* Log players killing other players - makes it easier to detect
1450 * and filter out malicious player killers - that is why the 1440 * and filter out malicious player killers - that is why the
1451 * ip address is included. 1441 * ip address is included.
1452 */ 1442 */
1453 if (op->type == PLAYER && !battleg) 1443 if (op->type == PLAYER && !battleg)
1491 1481
1492 /* This code below deals with finding the appropriate skill 1482 /* This code below deals with finding the appropriate skill
1493 * to credit exp to. This is a bit problematic - we should 1483 * to credit exp to. This is a bit problematic - we should
1494 * probably never really have to look at current_weapon->skill 1484 * probably never really have to look at current_weapon->skill
1495 */ 1485 */
1496 skill = 0;
1497
1498 if (hitter->skill && hitter->type != PLAYER) 1486 if (hitter->skill && hitter->type != PLAYER)
1499 skill = hitter->skill; 1487 skill = hitter->skill;
1500 else if (owner->chosen_skill) 1488 else if (owner->chosen_skill)
1501 { 1489 {
1502 skop = owner->chosen_skill; 1490 skop = owner->chosen_skill;
1503 skill = skop->skill; 1491 skill = skop->skill;
1504 } 1492 }
1505 else if (QUERY_FLAG (owner, FLAG_READY_WEAPON)) 1493 else if (QUERY_FLAG (owner, FLAG_READY_WEAPON) && owner->current_weapon)
1506 skill = owner->current_weapon->skill; 1494 skill = owner->current_weapon->skill;
1507 else 1495 else
1496 {
1508 LOG (llevError, "kill_object - unable to find skill that killed monster\n"); 1497 LOG (llevError, "BUG: kill_object - unable to find skill that killed monster\n"
1498 "op: %s\n" "hitter: %s\n" "owner: %s\n",
1499 owner->debug_desc (), hitter->debug_desc (), op->debug_desc ());
1500 skill = 0;
1501 }
1509 1502
1510 /* We have the skill we want to credit to - now find the object this goes 1503 /* 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! 1504 * to. Make sure skop is an actual skill, and not a skill tool!
1512 */ 1505 */
1513 if ((!skop || skop->type != SKILL) && skill) 1506 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 */ 1507 } /* Was it a player that hit somethign */
1525 else 1508 else
1526 skill = 0; 1509 skill = 0;
1527 1510
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 */ 1511 /* These may have been set in the player code section above */
1538 if (!skop) 1512 if (!skop)
1539 skop = hitter->chosen_skill; 1513 skop = hitter->chosen_skill;
1540 1514
1541 if (!skill && skop) 1515 if (!skill && skop)
1542 skill = skop->skill; 1516 skill = skop->skill;
1543
1544 new_draw_info (NDI_ALL, op->type == PLAYER ? 1 : 10, NULL, buf);
1545 1517
1546 /* If you didn't kill yourself, and your not the wizard */ 1518 /* If you didn't kill yourself, and your not the wizard */
1547 if (owner != op && !QUERY_FLAG (op, FLAG_WIZ)) 1519 if (owner != op && !QUERY_FLAG (op, FLAG_WIZ))
1548 { 1520 {
1549 int exp; 1521 int exp;
1621 1593
1622 if (owner1 && owner1->type == PLAYER) 1594 if (owner1 && owner1->type == PLAYER)
1623 { 1595 {
1624 owner1->contr->play_sound (sound_find ("pet_is_killed")); 1596 owner1->contr->play_sound (sound_find ("pet_is_killed"));
1625 /* Maybe we should include the owner that killed this, maybe not */ 1597 /* 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); 1598 new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, was killed by %s.", &op->name, &hitter->name);
1627 } 1599 }
1628 1600
1629 remove_friendly_object (op); 1601 remove_friendly_object (op);
1630 } 1602 }
1631 1603
1632 op->destroy (); 1604 op->drop_and_destroy ();
1633 } 1605 }
1634 else 1606 else
1635 {
1636 /* Player has been killed! */ 1607 /* Player has been killed! */
1637 if (owner->type == PLAYER) 1608 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 1609
1643 /* This was return -1 - that doesn't seem correct - if we return -1, process 1610 /* This was return -1 - that doesn't seem correct - if we return -1, process
1644 * continues in the calling function. 1611 * continues in the calling function.
1645 */ 1612 */
1646 return maxdam; 1613 return maxdam;
1928 /* See if the creature has been killed */ 1895 /* See if the creature has been killed */
1929 rtn_kill = kill_object (op, maxdam, hitter, type); 1896 rtn_kill = kill_object (op, maxdam, hitter, type);
1930 if (rtn_kill != -1) 1897 if (rtn_kill != -1)
1931 return rtn_kill; 1898 return rtn_kill;
1932 1899
1933
1934 /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note 1900 /* 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 1901 * that before if the player was immune to ghosthit, the monster
1936 * remained - that is no longer the case. 1902 * remained - that is no longer the case.
1937 */ 1903 */
1938 if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) 1904 if (QUERY_FLAG (hitter, FLAG_ONE_HIT))
1939 hitter->destroy (); 1905 hitter->drop_and_destroy ();
1940
1941 /* Lets handle creatures that are splitting now */ 1906 /* Lets handle creatures that are splitting now */
1942 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) 1907 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING))
1943 { 1908 {
1944 int i; 1909 int i;
1945 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); 1910 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY);
1985 } 1950 }
1986 1951
1987 op->destroy (); 1952 op->destroy ();
1988 } 1953 }
1989 else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) 1954 else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10)
1990 hitter->destroy (); 1955 hitter->drop_and_destroy ();
1991 1956
1992 return maxdam; 1957 return maxdam;
1993} 1958}
1994 1959
1995void 1960void
2198 return; 2163 return;
2199 2164
2200 def_lev = op->level; 2165 def_lev = op->level;
2201 if (def_lev < 1) 2166 if (def_lev < 1)
2202 { 2167 {
2203 LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->archname, &op->name); 2168 LOG (llevError, "BUG: arch %s with level < 1 (%s)\n", &op->arch->archname, op->debug_desc ());
2204 def_lev = 1; 2169 def_lev = 1;
2205 } 2170 }
2206 2171
2207 atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; 2172 atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2;
2208 /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", 2173 /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n",
2301 { 2266 {
2302 /* target is unseen */ 2267 /* target is unseen */
2303 if (target->invisible || QUERY_FLAG (attacker, FLAG_BLIND)) 2268 if (target->invisible || QUERY_FLAG (attacker, FLAG_BLIND))
2304 adjust -= 10; 2269 adjust -= 10;
2305 /* dark map penalty for the hitter (lacks infravision if we got here). */ 2270 /* dark map penalty for the hitter (lacks infravision if we got here). */
2306 else if (target->map && target->map->darkness > 0 && !stand_in_light (target)) 2271 else if (target->map && target->map->darklevel () > 0 && !stand_in_light (target))
2307 adjust -= target->map->darkness; 2272 adjust -= target->map->darklevel ();
2308 } 2273 }
2309 2274
2310 if (QUERY_FLAG (attacker, FLAG_SCARED)) 2275 if (QUERY_FLAG (attacker, FLAG_SCARED))
2311 adjust -= 3; 2276 adjust -= 3;
2312 2277

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines