1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
41 | /* did_make_save_item just checks to make sure the item actually |
41 | /* did_make_save_item just checks to make sure the item actually |
42 | * made its saving throw based on the tables. It does not take |
42 | * made its saving throw based on the tables. It does not take |
43 | * any further action (like destroying the item). |
43 | * any further action (like destroying the item). |
44 | */ |
44 | */ |
45 | static int |
45 | static int |
46 | did_make_save_item (object *op, int type, object *originator) |
46 | did_make_save_item (object *op, uint32_t type, object *originator) |
47 | { |
47 | { |
48 | int i, roll, saves = 0, attacks = 0, number; |
48 | int saves = 0, attacks = 0; |
49 | materialtype_t *mt = op->material; |
49 | materialtype_t *mt = op->material; |
50 | |
50 | |
|
|
51 | // destroying objects without material has many bad effects |
|
|
52 | if (mt == MATERIAL_NULL) |
|
|
53 | return 1; |
|
|
54 | |
51 | roll = rndm (1, 20); |
55 | int roll = rndm (1, 20); |
52 | |
56 | |
53 | /* the attacktypes have no meaning for object saves |
57 | /* the attacktypes have no meaning for object saves |
54 | * If the type is only magic, don't adjust type - basically, if |
58 | * If the type is only magic, don't adjust type - basically, if |
55 | * pure magic is hitting an object, it should save. However, if it |
59 | * pure magic is hitting an object, it should save. However, if it |
56 | * is magic teamed with something else, then strip out the |
60 | * is magic teamed with something else, then strip out the |
57 | * magic type, and instead let the fire, cold, or whatever component |
61 | * magic type, and instead let the fire, cold, or whatever component |
58 | * destroy the item. Otherwise, you get the case of poisoncloud |
62 | * destroy the item. Otherwise, you get the case of poisoncloud |
59 | * destroying objects because it has magic attacktype. |
63 | * destroying objects because it has magic attacktype. |
60 | */ |
64 | */ |
61 | if (type != AT_MAGIC) |
65 | if (type != AT_MAGIC) |
62 | type &= ~(AT_CONFUSION | AT_DRAIN | AT_GHOSTHIT | AT_POISON | AT_SLOW | |
66 | type &= ~(AT_CONFUSION | AT_DRAIN | AT_GHOSTHIT | AT_POISON | AT_SLOW | |
63 | AT_PARALYZE | AT_TURN_UNDEAD | AT_FEAR | AT_DEPLETE | AT_DEATH | |
67 | AT_PARALYZE | AT_TURN_UNDEAD | AT_FEAR | AT_DEPLETE | AT_DEATH | |
64 | AT_COUNTERSPELL | AT_HOLYWORD | AT_BLIND | AT_LIFE_STEALING | AT_MAGIC); |
68 | AT_COUNTERSPELL | AT_HOLYWORD | AT_BLIND | AT_LIFE_STEALING | AT_MAGIC); |
65 | |
69 | |
|
|
70 | |
66 | if (type == 0) return TRUE; |
71 | if (type == 0) return TRUE; |
67 | |
72 | |
68 | if (roll == 20) return TRUE; |
73 | if (roll == 20) return TRUE; |
69 | if (roll == 1) return FALSE; |
74 | if (roll == 1) return FALSE; |
70 | |
75 | |
71 | for (number = 0; number < NROFATTACKS; number++) |
76 | for_all_bits_sparse_32 (type, number) |
72 | { |
77 | { |
73 | i = 1 << number; |
|
|
74 | |
|
|
75 | if (!(i & type)) |
|
|
76 | continue; |
|
|
77 | |
|
|
78 | attacks++; |
78 | attacks++; |
|
|
79 | |
79 | if (op->resist[number] == 100) |
80 | if (op->resist[number] == 100) |
80 | saves++; |
81 | saves++; |
81 | else if (roll >= mt->save[number] - op->magic - op->resist[number] / 100) |
82 | else if (roll >= mt->save[number] - op->magic - op->resist[number] / 100) |
82 | saves++; |
83 | saves++; |
83 | else if ((20 - mt->save[number]) / 3 > originator->stats.dam) |
84 | else if ((20 - mt->save[number]) / 3 > originator->stats.dam) |
… | |
… | |
130 | * calling cancellation, etc.) |
131 | * calling cancellation, etc.) |
131 | */ |
132 | */ |
132 | void |
133 | void |
133 | save_throw_object (object *op, int type, object *originator) |
134 | save_throw_object (object *op, int type, object *originator) |
134 | { |
135 | { |
|
|
136 | op = op->head_ (); |
|
|
137 | |
135 | if (!did_make_save_item (op, type, originator)) |
138 | if (!did_make_save_item (op, type, originator)) |
136 | { |
139 | { |
137 | object *env = op->env; |
140 | object *env = op->env; |
138 | int x = op->x, y = op->y; |
141 | int x = op->x, y = op->y; |
139 | maptile *m = op->map; |
142 | maptile *m = op->map; |
… | |
… | |
148 | * object with +/- glow_radius and an "other_arch" to change to. |
151 | * object with +/- glow_radius and an "other_arch" to change to. |
149 | * (and please note that we cant fail our save and reach this |
152 | * (and please note that we cant fail our save and reach this |
150 | * function if the object doesnt contain a material that can burn. |
153 | * function if the object doesnt contain a material that can burn. |
151 | * So forget lighting magical swords on fire with this!) -b.t. |
154 | * So forget lighting magical swords on fire with this!) -b.t. |
152 | */ |
155 | */ |
153 | if (type & (AT_FIRE | AT_ELECTRICITY) |
156 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
154 | && (QUERY_FLAG (op, FLAG_IS_LIGHTABLE) |
|
|
155 | || op->type == LAMP |
|
|
156 | || op->type == TORCH |
|
|
157 | )) |
157 | { |
158 | { |
158 | // seems LAMPs and TORCHes are always IS_LIGHTABLE? |
159 | switch (op->type) |
159 | if (op->type == LAMP || op->type == TORCH) |
160 | { |
160 | { |
161 | case LAMP: |
|
|
162 | case TORCH: |
|
|
163 | // turn on a lamp |
|
|
164 | apply_lamp (op, true); |
161 | apply_lamp (op, true); // turn on a lamp |
165 | break; |
162 | return; |
166 | |
|
|
167 | default: |
|
|
168 | // for instance icecubes: |
|
|
169 | if (op->other_arch) |
|
|
170 | { |
|
|
171 | const char *arch = op->other_arch->archname; |
|
|
172 | |
|
|
173 | if (op->decrease ()) |
|
|
174 | fix_stopped_item (op, m, originator); |
|
|
175 | |
|
|
176 | if ((op = archetype::get (arch))) |
|
|
177 | { |
|
|
178 | if (env) |
|
|
179 | env->insert (op); |
|
|
180 | else |
|
|
181 | m->insert (op, x, y, originator); |
|
|
182 | } |
|
|
183 | } |
|
|
184 | } |
163 | } |
|
|
164 | else if (op->flag [FLAG_IS_LIGHTABLE]) |
|
|
165 | { |
|
|
166 | if (op->other_arch) |
|
|
167 | { |
|
|
168 | const char *arch = op->other_arch->archname; |
|
|
169 | |
|
|
170 | if (op->decrease ()) |
|
|
171 | fix_stopped_item (op, m, originator); |
|
|
172 | |
|
|
173 | if ((op = archetype::get (arch))) |
|
|
174 | { |
|
|
175 | if (env) |
|
|
176 | env->insert (op); |
|
|
177 | else |
|
|
178 | m->insert (op, x, y, originator); |
|
|
179 | } |
|
|
180 | } |
|
|
181 | |
185 | return; |
182 | return; |
|
|
183 | } |
186 | } |
184 | } |
187 | |
185 | |
188 | if (type & AT_CANCELLATION) |
186 | if (type & AT_CANCELLATION) |
189 | { /* Cancellation. */ |
187 | { /* Cancellation. */ |
190 | cancellation (op); |
188 | cancellation (op); |
191 | fix_stopped_item (op, m, originator); |
189 | fix_stopped_item (op, m, originator); |
|
|
190 | |
192 | return; |
191 | return; |
193 | } |
|
|
194 | |
|
|
195 | if (op->nrof > 1) |
|
|
196 | { |
|
|
197 | if (op->decrease (rndm (0, op->nrof - 1))) |
|
|
198 | fix_stopped_item (op, m, originator); |
|
|
199 | } |
|
|
200 | else |
|
|
201 | { |
|
|
202 | // drop everything to the ground, if possible |
|
|
203 | op->insert_at (originator); |
|
|
204 | op->drop_and_destroy (); |
|
|
205 | } |
192 | } |
206 | |
193 | |
207 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
194 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
208 | if (env) |
195 | if (env) |
209 | { |
196 | { |
210 | op = archetype::get (shstr_burnout); |
197 | object *op = archetype::get (shstr_burnout); |
211 | op->x = env->x, op->y = env->y; |
198 | op->x = env->x, op->y = env->y; |
212 | env->insert (op); |
199 | env->insert (op); |
213 | } |
200 | } |
214 | else |
201 | else |
215 | replace_insert_ob_in_map (shstr_burnout, originator); |
202 | replace_insert_ob_in_map (shstr_burnout, originator); |
216 | |
203 | |
|
|
204 | if (op->nrof > 1) |
|
|
205 | { |
|
|
206 | if (op->decrease (rndm (0, op->nrof - 1))) |
|
|
207 | fix_stopped_item (op, m, originator); |
|
|
208 | } |
|
|
209 | else |
|
|
210 | { |
|
|
211 | // drop everything to the ground, if possible |
|
|
212 | op->insert_at (originator); |
|
|
213 | op->drop_and_destroy (); |
|
|
214 | } |
|
|
215 | |
217 | return; |
216 | return; |
218 | } |
217 | } |
219 | |
218 | |
220 | /* The value of 50 is arbitrary. */ |
219 | /* The value of 50 is arbitrary. */ |
221 | if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && rndm (2)) |
220 | if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && rndm (2)) |
… | |
… | |
230 | return; |
229 | return; |
231 | |
230 | |
232 | object *tmp = present_arch (at, op->map, op->x, op->y); |
231 | object *tmp = present_arch (at, op->map, op->x, op->y); |
233 | if (!tmp) |
232 | if (!tmp) |
234 | { |
233 | { |
235 | tmp = arch_to_object (at); |
234 | tmp = at->instance (); |
236 | tmp->x = op->x, tmp->y = op->y; |
235 | tmp->x = op->x, tmp->y = op->y; |
237 | /* This was in the old (pre new movement code) - |
236 | /* This was in the old (pre new movement code) - |
238 | * icecubes have slow_move set to 1 - don't want |
237 | * icecubes have slow_move set to 1 - don't want |
239 | * that for ones we create. |
238 | * that for ones we create. |
240 | */ |
239 | */ |
… | |
… | |
253 | * type is the attacktype of the object. |
252 | * type is the attacktype of the object. |
254 | * full_hit is set if monster area does not matter. |
253 | * full_hit is set if monster area does not matter. |
255 | * returns 1 if it hits something, 0 otherwise. |
254 | * returns 1 if it hits something, 0 otherwise. |
256 | */ |
255 | */ |
257 | int |
256 | int |
258 | hit_map (object *op, int dir, int type, int full_hit) |
257 | hit_map (object *op, int dir, uint32_t type, int full_hit) |
259 | { |
258 | { |
260 | maptile *map; |
259 | maptile *map; |
261 | sint16 x, y; |
260 | sint16 x, y; |
262 | int retflag = 0; /* added this flag.. will return 1 if it hits a monster */ |
261 | int retflag = 0; /* added this flag.. will return 1 if it hits a monster */ |
263 | |
262 | |
… | |
… | |
353 | * NO_PASS set, it is also immune - you can't destroy walls. Note |
352 | * NO_PASS set, it is also immune - you can't destroy walls. Note |
354 | * that weak walls have is_alive set, which prevent objects from |
353 | * that weak walls have is_alive set, which prevent objects from |
355 | * passing over/through them. We don't care what type of movement |
354 | * passing over/through them. We don't care what type of movement |
356 | * the wall blocks - if it blocks any type of movement, can't be |
355 | * the wall blocks - if it blocks any type of movement, can't be |
357 | * destroyed right now. |
356 | * destroyed right now. |
|
|
357 | * Without the material check the server completely fails to work, |
|
|
358 | * objects detsroy themselves, floors get destroyed etc. etc. |
358 | */ |
359 | */ |
359 | else if (op->stats.dam > 0 && !tmp->move_block) |
360 | else if (op->stats.dam > 0 && !tmp->move_block && tmp->material != MATERIAL_NULL) |
360 | { |
361 | { |
361 | save_throw_object (tmp, type, op); |
362 | save_throw_object (tmp, type, op); |
362 | |
363 | |
363 | if (op->destroyed ()) |
364 | if (op->destroyed ()) |
364 | break; |
365 | break; |
… | |
… | |
522 | { |
523 | { |
523 | int mtype; |
524 | int mtype; |
524 | |
525 | |
525 | switch (hitter->current_weapon->weapontype) |
526 | switch (hitter->current_weapon->weapontype) |
526 | { |
527 | { |
527 | case WEAP_HIT: |
528 | case WEAP_HIT: mtype = ATM_BASIC; break; |
528 | mtype = ATM_BASIC; |
529 | case WEAP_SLASH: mtype = ATM_SLASH; break; |
529 | break; |
530 | case WEAP_PIERCE: mtype = ATM_PIERCE; break; |
530 | case WEAP_SLASH: |
531 | case WEAP_CLEAVE: mtype = ATM_CLEAVE; break; |
531 | mtype = ATM_SLASH; |
532 | case WEAP_SLICE: mtype = ATM_SLICE; break; |
532 | break; |
533 | case WEAP_STAB: mtype = ATM_STAB; break; |
533 | case WEAP_PIERCE: |
534 | case WEAP_WHIP: mtype = ATM_WHIP; break; |
534 | mtype = ATM_PIERCE; |
535 | case WEAP_CRUSH: mtype = ATM_CRUSH; break; |
535 | break; |
536 | case WEAP_BLUD: mtype = ATM_BLUD; break; |
536 | case WEAP_CLEAVE: |
537 | default: mtype = ATM_BASIC; break; |
537 | mtype = ATM_CLEAVE; |
|
|
538 | break; |
|
|
539 | case WEAP_SLICE: |
|
|
540 | mtype = ATM_SLICE; |
|
|
541 | break; |
|
|
542 | case WEAP_STAB: |
|
|
543 | mtype = ATM_STAB; |
|
|
544 | break; |
|
|
545 | case WEAP_WHIP: |
|
|
546 | mtype = ATM_WHIP; |
|
|
547 | break; |
|
|
548 | case WEAP_CRUSH: |
|
|
549 | mtype = ATM_CRUSH; |
|
|
550 | break; |
|
|
551 | case WEAP_BLUD: |
|
|
552 | mtype = ATM_BLUD; |
|
|
553 | break; |
|
|
554 | default: |
|
|
555 | mtype = ATM_BASIC; |
|
|
556 | break; |
|
|
557 | } |
538 | } |
558 | |
539 | |
559 | for (i = 0; i < MAXATTACKMESS && attack_mess[mtype][i].level != -1; i++) |
540 | 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) |
541 | if (dam < attack_mess[mtype][i].level || attack_mess[mtype][i + 1].level == -1) |
561 | { |
542 | { |
… | |
… | |
735 | switch (hitter->type) |
716 | switch (hitter->type) |
736 | { |
717 | { |
737 | case POTION: |
718 | case POTION: |
738 | /* should player get a save throw instead of checking magic protection? */ |
719 | /* should player get a save throw instead of checking magic protection? */ |
739 | if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_UNDEAD) && (victim->resist[ATNR_MAGIC] < 60)) |
720 | if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_UNDEAD) && (victim->resist[ATNR_MAGIC] < 60)) |
740 | (void) apply_potion (victim, hitter); |
721 | apply_potion (victim, hitter); |
741 | break; |
722 | break; |
742 | |
723 | |
743 | case POISON: /* poison drinks */ |
724 | case POISON: /* poison drinks */ |
744 | /* As with potions, should monster get a save? */ |
725 | /* As with potions, should monster get a save? */ |
745 | if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_UNDEAD) && (victim->resist[ATNR_POISON] < 60)) |
726 | if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_UNDEAD) && (victim->resist[ATNR_POISON] < 60)) |
… | |
… | |
865 | |
846 | |
866 | /* |
847 | /* |
867 | * A little check to make it more difficult to dance forward and back |
848 | * A little check to make it more difficult to dance forward and back |
868 | * to avoid ever being hit by monsters. |
849 | * to avoid ever being hit by monsters. |
869 | */ |
850 | */ |
870 | if (!simple_attack && QUERY_FLAG (op, FLAG_MONSTER) && op->speed_left > abs (op->speed) * -0.3f) |
851 | if (!simple_attack && QUERY_FLAG (op, FLAG_MONSTER) && op->speed_left > op->speed * -0.3f) |
871 | { |
852 | { |
872 | /* Decrease speed BEFORE calling process_object. Otherwise, an |
853 | /* Decrease speed BEFORE calling process_object. Otherwise, an |
873 | * infinite loop occurs, with process_object calling move_monster, |
854 | * infinite loop occurs, with process_object calling move_monster, |
874 | * which then gets here again. By decreasing the speed before |
855 | * which then gets here again. By decreasing the speed before |
875 | * we call process_object, the 'if' statement above will fail. |
856 | * we call process_object, the 'if' statement above will fail. |
… | |
… | |
1452 | * modify it. |
1433 | * modify it. |
1453 | */ |
1434 | */ |
1454 | /* Oct 95 - altered the following slightly for MULTIPLE_GODS hack |
1435 | /* Oct 95 - altered the following slightly for MULTIPLE_GODS hack |
1455 | * which needs new attacktype AT_HOLYWORD to work . b.t. */ |
1436 | * which needs new attacktype AT_HOLYWORD to work . b.t. */ |
1456 | int |
1437 | int |
1457 | hit_player (object *op, int dam, object *hitter, int type, int full_hit) |
1438 | hit_player (object *op, int dam, object *hitter, uint32_t type, int full_hit) |
1458 | { |
1439 | { |
1459 | int maxdam = 0, ndam = 0, attacktype = 1, magic = (type & AT_MAGIC); |
1440 | int magic = type & AT_MAGIC; |
1460 | int maxattacktype, attacknum; |
|
|
1461 | int body_attack = op && op->head; /* Did we hit op's head? */ |
1441 | int body_attack = op && op->head; /* Did we hit op's head? */ |
|
|
1442 | int maxdam = 0, ndam = 0, attacktype = 1; |
|
|
1443 | int maxattacktype; |
1462 | int simple_attack; |
1444 | int simple_attack; |
1463 | int rtn_kill = 0; |
1445 | int rtn_kill = 0; |
1464 | int friendlyfire; |
1446 | int friendlyfire; |
1465 | |
1447 | |
1466 | if (get_attack_mode (&op, &hitter, &simple_attack)) |
1448 | if (get_attack_mode (&op, &hitter, &simple_attack)) |
… | |
… | |
1576 | && god->race.contains (shstr_undead)))) |
1558 | && god->race.contains (shstr_undead)))) |
1577 | return 0; |
1559 | return 0; |
1578 | } |
1560 | } |
1579 | |
1561 | |
1580 | maxattacktype = type; /* initialise this to something */ |
1562 | maxattacktype = type; /* initialise this to something */ |
1581 | for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum) |
1563 | for_all_bits_sparse_32 (type, attacknum) |
1582 | { |
1564 | { |
|
|
1565 | uint32_t attacktype = 1 << attacknum; |
|
|
1566 | |
1583 | /* Magic isn't really a true attack type - it gets combined with other |
1567 | /* Magic isn't really a true attack type - it gets combined with other |
1584 | * attack types. As such, skip it over. However, if magic is |
1568 | * attack types. As such, skip it over. However, if magic is |
1585 | * the only attacktype in the group, then still attack with it |
1569 | * the only attacktype in the group, then still attack with it |
1586 | */ |
1570 | */ |
1587 | if ((attacktype == AT_MAGIC) && (type & ~AT_MAGIC)) |
1571 | if ((attacktype == AT_MAGIC) && (type & ~AT_MAGIC)) |
… | |
… | |
1590 | /* Go through and hit the player with each attacktype, one by one. |
1574 | /* Go through and hit the player with each attacktype, one by one. |
1591 | * hit_player_attacktype only figures out the damage, doesn't inflict |
1575 | * hit_player_attacktype only figures out the damage, doesn't inflict |
1592 | * it. It will do the appropriate action for attacktypes with |
1576 | * it. It will do the appropriate action for attacktypes with |
1593 | * effects (slow, paralization, etc. |
1577 | * effects (slow, paralization, etc. |
1594 | */ |
1578 | */ |
1595 | if (type & attacktype) |
|
|
1596 | { |
|
|
1597 | ndam = hit_player_attacktype (op, hitter, dam, attacknum, magic); |
1579 | ndam = hit_player_attacktype (op, hitter, dam, attacknum, magic); |
|
|
1580 | |
1598 | /* the >= causes us to prefer messages from special attacks, if |
1581 | /* the >= causes us to prefer messages from special attacks, if |
1599 | * the damage is equal. |
1582 | * the damage is equal. |
1600 | */ |
1583 | */ |
1601 | if (ndam >= maxdam) |
1584 | if (ndam >= maxdam) |
1602 | { |
1585 | { |
1603 | maxdam = ndam; |
1586 | maxdam = ndam; |
1604 | maxattacktype = 1 << attacknum; |
1587 | maxattacktype = 1 << attacknum; |
1605 | } |
|
|
1606 | } |
1588 | } |
1607 | } |
1589 | } |
1608 | |
1590 | |
1609 | /* if this is friendly fire then do a set % of damage only |
1591 | /* if this is friendly fire then do a set % of damage only |
1610 | * Note - put a check in to make sure this attack is actually |
1592 | * Note - put a check in to make sure this attack is actually |
… | |
… | |
1668 | attack_message (maxdam, maxattacktype, op, hitter); |
1650 | attack_message (maxdam, maxattacktype, op, hitter); |
1669 | |
1651 | |
1670 | op->stats.hp -= maxdam; |
1652 | op->stats.hp -= maxdam; |
1671 | |
1653 | |
1672 | /* Eneq(@csd.uu.se): Check to see if monster runs away. */ |
1654 | /* Eneq(@csd.uu.se): Check to see if monster runs away. */ |
1673 | if ((op->stats.hp >= 0) && |
1655 | if (op->stats.hp >= 0 |
1674 | (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) && |
1656 | && (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) |
1675 | op->stats.hp < (signed short) (((float) op->run_away / (float) 100) * (float) op->stats.maxhp)) |
1657 | && op->stats.hp * 100 < op->stats.maxhp * op->run_away) |
1676 | { |
1658 | { |
1677 | |
1659 | |
1678 | if (QUERY_FLAG (op, FLAG_MONSTER)) |
1660 | if (QUERY_FLAG (op, FLAG_MONSTER)) |
1679 | SET_FLAG (op, FLAG_RUN_AWAY); |
1661 | SET_FLAG (op, FLAG_RUN_AWAY); |
1680 | else |
1662 | else |
… | |
… | |
1701 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1683 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1702 | hitter->drop_and_destroy (); |
1684 | hitter->drop_and_destroy (); |
1703 | /* Lets handle creatures that are splitting now */ |
1685 | /* Lets handle creatures that are splitting now */ |
1704 | else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) |
1686 | else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) |
1705 | { |
1687 | { |
1706 | int i; |
|
|
1707 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
1688 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
1708 | int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE); |
1689 | int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE); |
1709 | object *owner = op->owner; |
1690 | object *owner = op->owner; |
1710 | |
1691 | |
1711 | if (!op->other_arch) |
1692 | if (!op->other_arch) |
… | |
… | |
1714 | return maxdam; |
1695 | return maxdam; |
1715 | } |
1696 | } |
1716 | |
1697 | |
1717 | op->remove (); |
1698 | op->remove (); |
1718 | |
1699 | |
1719 | for (i = 0; i < op->stats.food; i++) |
1700 | for (int i = 0; i < op->stats.food; i++) |
1720 | { /* This doesn't handle op->more yet */ |
1701 | { /* This doesn't handle op->more yet */ |
1721 | object *tmp = arch_to_object (op->other_arch); |
1702 | object *tmp = op->other_arch->instance (); |
1722 | int j; |
|
|
1723 | |
1703 | |
1724 | tmp->stats.hp = op->stats.hp; |
1704 | tmp->stats.hp = op->stats.hp; |
1725 | |
1705 | |
1726 | if (friendly) |
1706 | if (friendly) |
1727 | { |
1707 | { |
… | |
… | |
1733 | } |
1713 | } |
1734 | |
1714 | |
1735 | if (unaggressive) |
1715 | if (unaggressive) |
1736 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
1716 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
1737 | |
1717 | |
1738 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
1718 | int j = find_first_free_spot (tmp, op->map, op->x, op->y); |
1739 | |
1719 | |
1740 | if (j == -1) /* No spot to put this monster */ |
1720 | if (j == -1) /* No spot to put this monster */ |
1741 | tmp->destroy (); |
1721 | tmp->destroy (); |
1742 | else |
1722 | else |
1743 | { |
1723 | { |
… | |
… | |
1760 | archetype *at = archetype::find (shstr_poisoning); |
1740 | archetype *at = archetype::find (shstr_poisoning); |
1761 | object *tmp = present_arch_in_ob (at, op); |
1741 | object *tmp = present_arch_in_ob (at, op); |
1762 | |
1742 | |
1763 | if (tmp == NULL) |
1743 | if (tmp == NULL) |
1764 | { |
1744 | { |
1765 | if ((tmp = arch_to_object (at)) == NULL) |
1745 | tmp = insert_ob_in_ob (at->instance (), op); |
1766 | LOG (llevError, "Failed to clone arch poisoning.\n"); |
1746 | /* peterm: give poisoning some teeth. It should |
|
|
1747 | * be able to kill things better than it does: |
|
|
1748 | * damage should be dependent something--I choose to |
|
|
1749 | * do this: if it's a monster, the damage from the |
|
|
1750 | * poisoning goes as the level of the monster/2. |
|
|
1751 | * If anything else, goes as damage. |
|
|
1752 | */ |
|
|
1753 | |
|
|
1754 | if (QUERY_FLAG (hitter, FLAG_ALIVE)) |
|
|
1755 | tmp->stats.dam += hitter->level / 2; |
1767 | else |
1756 | else |
1768 | { |
|
|
1769 | tmp = insert_ob_in_ob (tmp, op); |
|
|
1770 | /* peterm: give poisoning some teeth. It should |
|
|
1771 | * be able to kill things better than it does: |
|
|
1772 | * damage should be dependent something--I choose to |
|
|
1773 | * do this: if it's a monster, the damage from the |
|
|
1774 | * poisoning goes as the level of the monster/2. |
|
|
1775 | * If anything else, goes as damage. |
|
|
1776 | */ |
|
|
1777 | |
|
|
1778 | if (QUERY_FLAG (hitter, FLAG_ALIVE)) |
|
|
1779 | tmp->stats.dam += hitter->level / 2; |
|
|
1780 | else |
|
|
1781 | tmp->stats.dam = dam; |
1757 | tmp->stats.dam = dam; |
1782 | |
1758 | |
1783 | tmp->set_owner (hitter); /* so we get credit for poisoning kills */ |
1759 | tmp->set_owner (hitter); /* so we get credit for poisoning kills */ |
1784 | if (hitter->skill && hitter->skill != tmp->skill) |
1760 | if (hitter->skill && hitter->skill != tmp->skill) |
1785 | { |
|
|
1786 | tmp->skill = hitter->skill; |
1761 | tmp->skill = hitter->skill; |
1787 | } |
|
|
1788 | |
1762 | |
1789 | tmp->stats.food += dam; /* more damage, longer poisoning */ |
1763 | tmp->stats.food += dam; /* more damage, longer poisoning */ |
1790 | |
1764 | |
1791 | if (op->type == PLAYER) |
1765 | if (op->type == PLAYER) |
1792 | { |
1766 | { |
1793 | /* player looses stats, maximum is -10 of each */ |
1767 | /* player looses stats, maximum is -10 of each */ |
1794 | tmp->stats.Con = max (-(dam / 4 + 1), -10); |
1768 | tmp->stats.Con = max (-(dam / 4 + 1), -10); |
1795 | tmp->stats.Str = max (-(dam / 3 + 2), -10); |
1769 | tmp->stats.Str = max (-(dam / 3 + 2), -10); |
1796 | tmp->stats.Dex = max (-(dam / 6 + 1), -10); |
1770 | tmp->stats.Dex = max (-(dam / 6 + 1), -10); |
1797 | tmp->stats.Int = max (-(dam / 7 ), -10); |
1771 | tmp->stats.Int = max (-(dam / 7 ), -10); |
1798 | SET_FLAG (tmp, FLAG_APPLIED); |
1772 | SET_FLAG (tmp, FLAG_APPLIED); |
1799 | op->update_stats (); |
1773 | op->update_stats (); |
1800 | new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill."); |
1774 | new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill."); |
1801 | op->play_sound (tmp->sound); |
1775 | op->play_sound (tmp->sound); |
1802 | } |
1776 | } |
1803 | |
1777 | |
1804 | if (hitter->type == PLAYER) |
1778 | if (hitter->type == PLAYER) |
1805 | new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); |
1779 | new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); |
1806 | else if (hitter->owner != NULL && hitter->owner->type == PLAYER) |
1780 | else if (hitter->owner != NULL && hitter->owner->type == PLAYER) |
1807 | new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name); |
1781 | new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name); |
1808 | } |
|
|
1809 | |
1782 | |
1810 | tmp->speed_left = 0; |
1783 | tmp->speed_left = 0; |
1811 | } |
1784 | } |
1812 | else |
1785 | else |
1813 | tmp->stats.food++; |
1786 | tmp->stats.food++; |
… | |
… | |
1822 | if (at == NULL) |
1795 | if (at == NULL) |
1823 | LOG (llevError, "Can't find slowness archetype.\n"); |
1796 | LOG (llevError, "Can't find slowness archetype.\n"); |
1824 | |
1797 | |
1825 | if ((tmp = present_arch_in_ob (at, op)) == NULL) |
1798 | if ((tmp = present_arch_in_ob (at, op)) == NULL) |
1826 | { |
1799 | { |
1827 | tmp = arch_to_object (at); |
1800 | tmp = at->instance (); |
1828 | tmp = insert_ob_in_ob (tmp, op); |
1801 | tmp = insert_ob_in_ob (tmp, op); |
1829 | new_draw_info (NDI_UNIQUE, 0, op, "The world suddenly moves very fast!"); |
1802 | new_draw_info (NDI_UNIQUE, 0, op, "The world suddenly moves very fast!"); |
1830 | } |
1803 | } |
1831 | else |
1804 | else |
1832 | tmp->stats.food++; |
1805 | tmp->stats.food++; |
… | |
… | |
1919 | */ |
1892 | */ |
1920 | |
1893 | |
1921 | /* Do this as a float - otherwise, rounding might very well reduce this to 0 */ |
1894 | /* Do this as a float - otherwise, rounding might very well reduce this to 0 */ |
1922 | float effect = dam * 3.f * (100.f - op->resist[ATNR_PARALYZE]) / 100.f; |
1895 | float effect = dam * 3.f * (100.f - op->resist[ATNR_PARALYZE]) / 100.f; |
1923 | |
1896 | |
1924 | op->speed_left -= fabs (op->speed) * effect; |
1897 | op->speed_left -= op->speed * effect; |
1925 | /* tmp->stats.food+=(signed short) effect/op->speed; */ |
1898 | /* tmp->stats.food+=(signed short) effect/op->speed; */ |
1926 | |
1899 | |
1927 | /* max number of ticks to be affected for. */ |
1900 | /* max number of ticks to be affected for. */ |
1928 | float max = (100 - op->resist[ATNR_PARALYZE]) / 2; |
1901 | float max = (100 - op->resist[ATNR_PARALYZE]) / 2; |
1929 | |
1902 | |
1930 | if (op->speed_left < -(fabs (op->speed) * max)) |
1903 | max_it (op->speed_left, -op->speed * max); |
1931 | op->speed_left = -(fabs (op->speed) * max); |
|
|
1932 | |
1904 | |
1933 | /* tmp->stats.food = (signed short) (max / fabs (op->speed)); */ |
1905 | /* tmp->stats.food = (signed short) (max / op->speed); */ |
1934 | } |
1906 | } |
1935 | |
1907 | |
1936 | /* Attempts to kill 'op'. hitter is the attack object, dam is |
1908 | /* Attempts to kill 'op'. hitter is the attack object, dam is |
1937 | * the computed damaged. |
1909 | * the computed damaged. |
1938 | */ |
1910 | */ |