… | |
… | |
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 |
… | |
… | |
77 | did_make_save_item (object *op, int type, object *originator) |
77 | did_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->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 | } |
… | |
… | |
1202 | |
1191 | |
1203 | /* High damage acid has better chance of corroding |
1192 | /* High damage acid has better chance of corroding |
1204 | objects */ |
1193 | objects */ |
1205 | if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic) |
1194 | if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic) |
1206 | { |
1195 | { |
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; |
1196 | flag = 1; |
1212 | tmp->magic--; |
1197 | tmp->magic--; |
1213 | if (op->type == PLAYER) |
1198 | |
1214 | esrv_send_item (op, tmp); |
1199 | if (object *pl = tmp->visible_to ()) |
|
|
1200 | { |
|
|
1201 | /* Make this more visible */ |
|
|
1202 | new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, pl, |
|
|
1203 | "The %s's acid corrodes your %s!", query_name (hitter), query_name (tmp)); |
|
|
1204 | |
|
|
1205 | esrv_send_item (op, tmp); //TODO: UPD_NAME should be enough (it's enough in other cases) |
|
|
1206 | } |
1215 | } |
1207 | } |
1216 | } |
1208 | } |
1217 | |
1209 | |
1218 | if (flag) |
1210 | if (flag) |
1219 | op->update_stats (); /* Something was corroded */ |
1211 | op->update_stats (); /* Something was corroded */ |
… | |
… | |
1389 | */ |
1381 | */ |
1390 | int |
1382 | int |
1391 | kill_object (object *op, int dam, object *hitter, int type) |
1383 | kill_object (object *op, int dam, object *hitter, int type) |
1392 | { |
1384 | { |
1393 | char buf[MAX_BUF]; |
1385 | char buf[MAX_BUF]; |
1394 | const char *skill; |
1386 | shstr skill; |
1395 | int maxdam = 0; |
1387 | int maxdam = 0; |
1396 | int battleg = 0; /* true if op standing on battleground */ |
1388 | int battleg = 0; /* true if op standing on battleground */ |
1397 | int pk = 0; /* true if op and what controls hitter are both players */ |
1389 | int pk = 0; /* true if op and what controls hitter are both players */ |
1398 | object *owner = 0; |
1390 | object *owner = 0; |
1399 | object *skop = 0; |
1391 | object *skop = 0; |
… | |
… | |
1426 | return maxdam; |
1418 | return maxdam; |
1427 | } |
1419 | } |
1428 | |
1420 | |
1429 | /* Now lets start dealing with experience we get for killing something */ |
1421 | /* Now lets start dealing with experience we get for killing something */ |
1430 | |
1422 | |
1431 | owner = hitter->owner; |
1423 | owner = hitter->outer_owner (); |
1432 | if (!owner) |
1424 | if (!owner) |
1433 | owner = hitter; |
1425 | owner = hitter; |
1434 | |
1426 | |
1435 | /* is the victim (op) standing on battleground? */ |
1427 | /* is the victim (op) standing on battleground? */ |
1436 | if (op_on_battleground (op, NULL, NULL)) |
1428 | if (op_on_battleground (op, NULL, NULL)) |
… | |
… | |
1441 | pk = 1; |
1433 | pk = 1; |
1442 | |
1434 | |
1443 | /* Player killed something */ |
1435 | /* Player killed something */ |
1444 | if (owner->type == PLAYER) |
1436 | if (owner->type == PLAYER) |
1445 | { |
1437 | { |
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 |
1438 | /* Log players killing other players - makes it easier to detect |
1450 | * and filter out malicious player killers - that is why the |
1439 | * and filter out malicious player killers - that is why the |
1451 | * ip address is included. |
1440 | * ip address is included. |
1452 | */ |
1441 | */ |
1453 | if (op->type == PLAYER && !battleg) |
1442 | if (op->type == PLAYER && !battleg) |
… | |
… | |
1491 | |
1480 | |
1492 | /* This code below deals with finding the appropriate skill |
1481 | /* This code below deals with finding the appropriate skill |
1493 | * to credit exp to. This is a bit problematic - we should |
1482 | * to credit exp to. This is a bit problematic - we should |
1494 | * probably never really have to look at current_weapon->skill |
1483 | * probably never really have to look at current_weapon->skill |
1495 | */ |
1484 | */ |
1496 | skill = 0; |
|
|
1497 | |
|
|
1498 | if (hitter->skill && hitter->type != PLAYER) |
1485 | if (hitter->skill && hitter->type != PLAYER) |
1499 | skill = hitter->skill; |
1486 | skill = hitter->skill; |
1500 | else if (owner->chosen_skill) |
1487 | else if (owner->chosen_skill) |
1501 | { |
1488 | { |
1502 | skop = owner->chosen_skill; |
1489 | skop = owner->chosen_skill; |
1503 | skill = skop->skill; |
1490 | skill = skop->skill; |
1504 | } |
1491 | } |
1505 | else if (QUERY_FLAG (owner, FLAG_READY_WEAPON)) |
1492 | else if (QUERY_FLAG (owner, FLAG_READY_WEAPON)) |
1506 | skill = owner->current_weapon->skill; |
1493 | skill = owner->current_weapon->skill; |
1507 | else |
1494 | else |
|
|
1495 | { |
1508 | LOG (llevError, "kill_object - unable to find skill that killed monster\n"); |
1496 | LOG (llevError, "kill_object - unable to find skill that killed monster\n"); |
|
|
1497 | skill = 0; |
|
|
1498 | } |
1509 | |
1499 | |
1510 | /* We have the skill we want to credit to - now find the object this goes |
1500 | /* 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! |
1501 | * to. Make sure skop is an actual skill, and not a skill tool! |
1512 | */ |
1502 | */ |
1513 | if ((!skop || skop->type != SKILL) && skill) |
1503 | 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 */ |
1504 | } /* Was it a player that hit somethign */ |
1525 | else |
1505 | else |
1526 | skill = 0; |
1506 | skill = 0; |
1527 | |
1507 | |
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 */ |
1508 | /* These may have been set in the player code section above */ |
1538 | if (!skop) |
1509 | if (!skop) |
1539 | skop = hitter->chosen_skill; |
1510 | skop = hitter->chosen_skill; |
1540 | |
1511 | |
1541 | if (!skill && skop) |
1512 | if (!skill && skop) |
1542 | skill = skop->skill; |
1513 | skill = skop->skill; |
1543 | |
|
|
1544 | new_draw_info (NDI_ALL, op->type == PLAYER ? 1 : 10, NULL, buf); |
|
|
1545 | |
1514 | |
1546 | /* If you didn't kill yourself, and your not the wizard */ |
1515 | /* If you didn't kill yourself, and your not the wizard */ |
1547 | if (owner != op && !QUERY_FLAG (op, FLAG_WIZ)) |
1516 | if (owner != op && !QUERY_FLAG (op, FLAG_WIZ)) |
1548 | { |
1517 | { |
1549 | int exp; |
1518 | int exp; |
… | |
… | |
1621 | |
1590 | |
1622 | if (owner1 && owner1->type == PLAYER) |
1591 | if (owner1 && owner1->type == PLAYER) |
1623 | { |
1592 | { |
1624 | owner1->contr->play_sound (sound_find ("pet_is_killed")); |
1593 | owner1->contr->play_sound (sound_find ("pet_is_killed")); |
1625 | /* Maybe we should include the owner that killed this, maybe not */ |
1594 | /* 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); |
1595 | new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, was killed by %s.", &op->name, &hitter->name); |
1627 | } |
1596 | } |
1628 | |
1597 | |
1629 | remove_friendly_object (op); |
1598 | remove_friendly_object (op); |
1630 | } |
1599 | } |
1631 | |
1600 | |
1632 | op->destroy (); |
1601 | op->destroy (); |
1633 | } |
1602 | } |
1634 | else |
1603 | else |
1635 | { |
|
|
1636 | /* Player has been killed! */ |
1604 | /* Player has been killed! */ |
1637 | if (owner->type == PLAYER) |
1605 | 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 | |
1606 | |
1643 | /* This was return -1 - that doesn't seem correct - if we return -1, process |
1607 | /* This was return -1 - that doesn't seem correct - if we return -1, process |
1644 | * continues in the calling function. |
1608 | * continues in the calling function. |
1645 | */ |
1609 | */ |
1646 | return maxdam; |
1610 | return maxdam; |
… | |
… | |
2198 | return; |
2162 | return; |
2199 | |
2163 | |
2200 | def_lev = op->level; |
2164 | def_lev = op->level; |
2201 | if (def_lev < 1) |
2165 | if (def_lev < 1) |
2202 | { |
2166 | { |
2203 | LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->archname, &op->name); |
2167 | LOG (llevError, "BUG: arch %s with level < 1 (%s)\n", &op->arch->archname, op->debug_desc ()); |
2204 | def_lev = 1; |
2168 | def_lev = 1; |
2205 | } |
2169 | } |
2206 | |
2170 | |
2207 | atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; |
2171 | atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; |
2208 | /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", |
2172 | /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", |