… | |
… | |
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++; |
… | |
… | |
152 | op = stop_item (op); |
152 | op = stop_item (op); |
153 | if (op == NULL) |
153 | if (op == NULL) |
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 | { |
|
|
175 | op->x = env->x, op->y = env->y; //???? wtf |
|
|
176 | env->insert (op); |
174 | env->insert (op); |
177 | } |
|
|
178 | else |
175 | else |
179 | { |
|
|
180 | op->x = x, op->y = y; |
|
|
181 | insert_ob_in_map (op, m, originator, 0); |
176 | m->insert (op, x, y, originator); |
182 | } |
|
|
183 | } |
177 | } |
184 | |
178 | |
185 | return; |
179 | return; |
186 | } |
180 | } |
187 | |
181 | |
… | |
… | |
196 | { |
190 | { |
197 | if (op->decrease (rndm (0, op->nrof - 1))) |
191 | if (op->decrease (rndm (0, op->nrof - 1))) |
198 | fix_stopped_item (op, m, originator); |
192 | fix_stopped_item (op, m, originator); |
199 | } |
193 | } |
200 | else |
194 | else |
|
|
195 | { |
|
|
196 | // drop everything to the ground, if possible |
|
|
197 | while (op->inv) |
|
|
198 | op->inv->insert_at (originator); |
|
|
199 | |
201 | op->destroy (); |
200 | op->destroy (); |
|
|
201 | } |
202 | |
202 | |
203 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
203 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
204 | if (env) |
204 | if (env) |
205 | { |
205 | { |
206 | op = get_archetype ("burnout"); |
206 | op = archetype::get (shstr_burnout); |
207 | op->x = env->x, op->y = env->y; |
207 | op->x = env->x, op->y = env->y; |
208 | insert_ob_in_ob (op, env); |
208 | env->insert (op); |
209 | } |
209 | } |
210 | else |
210 | else |
211 | replace_insert_ob_in_map ("burnout", originator); |
211 | replace_insert_ob_in_map (shstr_burnout, originator); |
212 | |
212 | |
213 | return; |
213 | return; |
214 | } |
214 | } |
215 | |
215 | |
216 | /* The value of 50 is arbitrary. */ |
216 | /* The value of 50 is arbitrary. */ |
217 | if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && (RANDOM () & 2)) |
217 | if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && (RANDOM () & 2)) |
218 | { |
218 | { |
219 | object *tmp; |
|
|
220 | archetype *at = archetype::find ("icecube"); |
219 | archetype *at = archetype::find (shstr_icecube); |
221 | |
220 | |
222 | if (at == NULL) |
221 | if (at == NULL) |
223 | return; |
222 | return; |
224 | |
223 | |
225 | op = stop_item (op); |
224 | op = stop_item (op); |
226 | if (op == NULL) |
225 | if (op == NULL) |
227 | return; |
226 | return; |
228 | |
227 | |
229 | if ((tmp = present_arch (at, op->map, op->x, op->y)) == NULL) |
228 | object *tmp = present_arch (at, op->map, op->x, op->y); |
|
|
229 | if (!tmp) |
230 | { |
230 | { |
231 | tmp = arch_to_object (at); |
231 | tmp = arch_to_object (at); |
232 | tmp->x = op->x, tmp->y = op->y; |
232 | tmp->x = op->x, tmp->y = op->y; |
233 | /* This was in the old (pre new movement code) - |
233 | /* This was in the old (pre new movement code) - |
234 | * icecubes have slow_move set to 1 - don't want |
234 | * icecubes have slow_move set to 1 - don't want |
… | |
… | |
237 | tmp->move_slow_penalty = 0; |
237 | tmp->move_slow_penalty = 0; |
238 | tmp->move_slow = 0; |
238 | tmp->move_slow = 0; |
239 | insert_ob_in_map (tmp, op->map, originator, 0); |
239 | insert_ob_in_map (tmp, op->map, originator, 0); |
240 | } |
240 | } |
241 | |
241 | |
242 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
242 | tmp->insert (op); |
243 | op->remove (); |
|
|
244 | |
|
|
245 | insert_ob_in_ob (op, tmp); |
|
|
246 | return; |
243 | return; |
247 | } |
244 | } |
248 | } |
245 | } |
249 | |
246 | |
250 | /* Object op is hitting the map. |
247 | /* Object op is hitting the map. |
… | |
… | |
279 | } |
276 | } |
280 | |
277 | |
281 | if (op->head) |
278 | if (op->head) |
282 | op = op->head; |
279 | op = op->head; |
283 | |
280 | |
284 | map = op->map; |
281 | mapxy pos (op); |
285 | x = op->x + freearr_x[dir]; |
282 | pos.move (dir); |
286 | y = op->y + freearr_y[dir]; |
|
|
287 | |
283 | |
288 | if (!xy_normalise (map, x, y)) |
284 | if (!pos.normalise ()) |
289 | return 0; |
285 | return 0; |
290 | |
286 | |
291 | // elmex: a safe map tile can't be hit! |
287 | // elmex: a safe map tile can't be hit! |
292 | // this should prevent most harmful effects on items and players there. |
288 | // this should prevent most harmful effects on items and players there. |
293 | mapspace &ms = map->at (x, y); |
289 | mapspace &ms = pos.ms (); |
294 | |
290 | |
295 | if (ms.flags () & P_SAFE) |
291 | if (ms.flags () & P_SAFE) |
296 | return 0; |
292 | return 0; |
297 | |
293 | |
298 | /* peterm: a few special cases for special attacktypes --counterspell |
294 | /* peterm: a few special cases for special attacktypes --counterspell |
… | |
… | |
336 | |
332 | |
337 | /* Something could have happened to 'tmp' while 'tmp->below' was processed. |
333 | /* Something could have happened to 'tmp' while 'tmp->below' was processed. |
338 | * For example, 'tmp' was put in an icecube. |
334 | * For example, 'tmp' was put in an icecube. |
339 | * This is one of the few cases where on_same_map should not be used. |
335 | * This is one of the few cases where on_same_map should not be used. |
340 | */ |
336 | */ |
341 | if (tmp->map != map || tmp->x != x || tmp->y != y) |
337 | if (tmp->map != pos.m || tmp->x != pos.x || tmp->y != pos.y) |
342 | continue; |
338 | continue; |
343 | |
339 | |
344 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
340 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
345 | { |
341 | { |
346 | hit_player (tmp, op->stats.dam, op, type, full_hit); |
342 | hit_player (tmp, op->stats.dam, op, type, full_hit); |
… | |
… | |
523 | { |
519 | { |
524 | int mtype; |
520 | int mtype; |
525 | |
521 | |
526 | switch (hitter->current_weapon->weapontype) |
522 | switch (hitter->current_weapon->weapontype) |
527 | { |
523 | { |
528 | case WEAP_HIT: |
524 | case WEAP_HIT: |
529 | mtype = ATM_BASIC; |
525 | mtype = ATM_BASIC; |
530 | break; |
526 | break; |
531 | case WEAP_SLASH: |
527 | case WEAP_SLASH: |
532 | mtype = ATM_SLASH; |
528 | mtype = ATM_SLASH; |
533 | break; |
529 | break; |
534 | case WEAP_PIERCE: |
530 | case WEAP_PIERCE: |
535 | mtype = ATM_PIERCE; |
531 | mtype = ATM_PIERCE; |
536 | break; |
532 | break; |
537 | case WEAP_CLEAVE: |
533 | case WEAP_CLEAVE: |
538 | mtype = ATM_CLEAVE; |
534 | mtype = ATM_CLEAVE; |
539 | break; |
535 | break; |
540 | case WEAP_SLICE: |
536 | case WEAP_SLICE: |
541 | mtype = ATM_SLICE; |
537 | mtype = ATM_SLICE; |
542 | break; |
538 | break; |
543 | case WEAP_STAB: |
539 | case WEAP_STAB: |
544 | mtype = ATM_STAB; |
540 | mtype = ATM_STAB; |
545 | break; |
541 | break; |
546 | case WEAP_WHIP: |
542 | case WEAP_WHIP: |
547 | mtype = ATM_WHIP; |
543 | mtype = ATM_WHIP; |
548 | break; |
544 | break; |
549 | case WEAP_CRUSH: |
545 | case WEAP_CRUSH: |
550 | mtype = ATM_CRUSH; |
546 | mtype = ATM_CRUSH; |
551 | break; |
547 | break; |
552 | case WEAP_BLUD: |
548 | case WEAP_BLUD: |
553 | mtype = ATM_BLUD; |
549 | mtype = ATM_BLUD; |
554 | break; |
550 | break; |
555 | default: |
551 | default: |
556 | mtype = ATM_BASIC; |
552 | mtype = ATM_BASIC; |
557 | break; |
553 | break; |
558 | } |
554 | } |
|
|
555 | |
559 | for (i = 0; i < MAXATTACKMESS && attack_mess[mtype][i].level != -1; i++) |
556 | for (i = 0; i < MAXATTACKMESS && attack_mess[mtype][i].level != -1; i++) |
560 | if (dam < attack_mess[mtype][i].level || attack_mess[mtype][i + 1].level == -1) |
557 | if (dam < attack_mess[mtype][i].level || attack_mess[mtype][i + 1].level == -1) |
561 | { |
558 | { |
562 | sprintf (buf1, "%s %s%s", attack_mess[mtype][i].buf1, &op->name, attack_mess[mtype][i].buf2); |
559 | sprintf (buf1, "%s %s%s", attack_mess[mtype][i].buf1, &op->name, attack_mess[mtype][i].buf2); |
563 | strcpy (buf2, attack_mess[mtype][i].buf3); |
560 | strcpy (buf2, attack_mess[mtype][i].buf3); |
… | |
… | |
680 | *target = (*target)->head; |
677 | *target = (*target)->head; |
681 | |
678 | |
682 | if ((*hitter)->head) |
679 | if ((*hitter)->head) |
683 | *hitter = (*hitter)->head; |
680 | *hitter = (*hitter)->head; |
684 | |
681 | |
|
|
682 | if ((*target)->type == LOCKED_DOOR) |
|
|
683 | return 1; // locked doors cannot be hit |
|
|
684 | |
685 | if ((*hitter)->env != NULL || (*target)->env != NULL) |
685 | if ((*hitter)->env || (*target)->env) |
686 | { |
686 | { |
687 | *simple_attack = 1; |
687 | *simple_attack = 1; |
688 | return 0; |
688 | return 0; |
689 | } |
689 | } |
690 | |
690 | |
… | |
… | |
1435 | pk = 1; |
1435 | pk = 1; |
1436 | |
1436 | |
1437 | /* Player killed something */ |
1437 | /* Player killed something */ |
1438 | if (owner->type == PLAYER) |
1438 | if (owner->type == PLAYER) |
1439 | { |
1439 | { |
1440 | Log_Kill (owner->name, |
|
|
1441 | query_name (op), op->type, (owner != hitter) ? query_name (hitter) : NULL, (owner != hitter) ? hitter->type : 0); |
|
|
1442 | |
|
|
1443 | /* Log players killing other players - makes it easier to detect |
1440 | /* Log players killing other players - makes it easier to detect |
1444 | * and filter out malicious player killers - that is why the |
1441 | * and filter out malicious player killers - that is why the |
1445 | * ip address is included. |
1442 | * ip address is included. |
1446 | */ |
1443 | */ |
1447 | if (op->type == PLAYER && !battleg) |
1444 | if (op->type == PLAYER && !battleg) |
… | |
… | |
1624 | } |
1621 | } |
1625 | |
1622 | |
1626 | op->destroy (); |
1623 | op->destroy (); |
1627 | } |
1624 | } |
1628 | else |
1625 | else |
1629 | { |
|
|
1630 | /* Player has been killed! */ |
1626 | /* Player has been killed! */ |
1631 | if (owner->type == PLAYER) |
1627 | op->contr->killer = owner->type == PLAYER ? owner : hitter; |
1632 | snprintf (op->contr->killer, sizeof (op->contr->killer), "%s the %s", &owner->name, owner->contr->title); |
|
|
1633 | else |
|
|
1634 | assign (op->contr->killer, hitter->name); |
|
|
1635 | } |
|
|
1636 | |
1628 | |
1637 | /* This was return -1 - that doesn't seem correct - if we return -1, process |
1629 | /* This was return -1 - that doesn't seem correct - if we return -1, process |
1638 | * continues in the calling function. |
1630 | * continues in the calling function. |
1639 | */ |
1631 | */ |
1640 | return maxdam; |
1632 | return maxdam; |