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.118 by root, Tue Nov 10 04:38:45 2009 UTC vs.
Revision 1.129 by root, Sat Jan 9 13:43:19 2010 UTC

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 */
45static int 45static int
46did_make_save_item (object *op, int type, object *originator) 46did_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 */
132void 133void
133save_throw_object (object *op, int type, object *originator) 134save_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 */
257int 256int
258hit_map (object *op, int dir, int type, int full_hit) 257hit_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;
735 switch (hitter->type) 736 switch (hitter->type)
736 { 737 {
737 case POTION: 738 case POTION:
738 /* should player get a save throw instead of checking magic protection? */ 739 /* 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)) 740 if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_UNDEAD) && (victim->resist[ATNR_MAGIC] < 60))
740 (void) apply_potion (victim, hitter); 741 apply_potion (victim, hitter);
741 break; 742 break;
742 743
743 case POISON: /* poison drinks */ 744 case POISON: /* poison drinks */
744 /* As with potions, should monster get a save? */ 745 /* 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)) 746 if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_UNDEAD) && (victim->resist[ATNR_POISON] < 60))
865 866
866 /* 867 /*
867 * A little check to make it more difficult to dance forward and back 868 * A little check to make it more difficult to dance forward and back
868 * to avoid ever being hit by monsters. 869 * to avoid ever being hit by monsters.
869 */ 870 */
870 if (!simple_attack && QUERY_FLAG (op, FLAG_MONSTER) && op->speed_left > abs (op->speed) * -0.3f) 871 if (!simple_attack && QUERY_FLAG (op, FLAG_MONSTER) && op->speed_left > op->speed * -0.3f)
871 { 872 {
872 /* Decrease speed BEFORE calling process_object. Otherwise, an 873 /* Decrease speed BEFORE calling process_object. Otherwise, an
873 * infinite loop occurs, with process_object calling move_monster, 874 * infinite loop occurs, with process_object calling move_monster,
874 * which then gets here again. By decreasing the speed before 875 * which then gets here again. By decreasing the speed before
875 * we call process_object, the 'if' statement above will fail. 876 * we call process_object, the 'if' statement above will fail.
1452 * modify it. 1453 * modify it.
1453 */ 1454 */
1454/* Oct 95 - altered the following slightly for MULTIPLE_GODS hack 1455/* Oct 95 - altered the following slightly for MULTIPLE_GODS hack
1455 * which needs new attacktype AT_HOLYWORD to work . b.t. */ 1456 * which needs new attacktype AT_HOLYWORD to work . b.t. */
1456int 1457int
1457hit_player (object *op, int dam, object *hitter, int type, int full_hit) 1458hit_player (object *op, int dam, object *hitter, uint32_t type, int full_hit)
1458{ 1459{
1459 int maxdam = 0, ndam = 0, attacktype = 1, magic = (type & AT_MAGIC); 1460 int magic = type & AT_MAGIC;
1460 int maxattacktype, attacknum;
1461 int body_attack = op && op->head; /* Did we hit op's head? */ 1461 int body_attack = op && op->head; /* Did we hit op's head? */
1462 int maxdam = 0, ndam = 0, attacktype = 1;
1463 int maxattacktype;
1462 int simple_attack; 1464 int simple_attack;
1463 int rtn_kill = 0; 1465 int rtn_kill = 0;
1464 int friendlyfire; 1466 int friendlyfire;
1465 1467
1466 if (get_attack_mode (&op, &hitter, &simple_attack)) 1468 if (get_attack_mode (&op, &hitter, &simple_attack))
1576 && god->race.contains (shstr_undead)))) 1578 && god->race.contains (shstr_undead))))
1577 return 0; 1579 return 0;
1578 } 1580 }
1579 1581
1580 maxattacktype = type; /* initialise this to something */ 1582 maxattacktype = type; /* initialise this to something */
1581 for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum) 1583 for_all_bits_sparse_32 (type, attacknum)
1582 { 1584 {
1585 uint32_t attacktype = 1 << attacknum;
1586
1583 /* Magic isn't really a true attack type - it gets combined with other 1587 /* 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 1588 * attack types. As such, skip it over. However, if magic is
1585 * the only attacktype in the group, then still attack with it 1589 * the only attacktype in the group, then still attack with it
1586 */ 1590 */
1587 if ((attacktype == AT_MAGIC) && (type & ~AT_MAGIC)) 1591 if ((attacktype == AT_MAGIC) && (type & ~AT_MAGIC))
1590 /* Go through and hit the player with each attacktype, one by one. 1594 /* Go through and hit the player with each attacktype, one by one.
1591 * hit_player_attacktype only figures out the damage, doesn't inflict 1595 * hit_player_attacktype only figures out the damage, doesn't inflict
1592 * it. It will do the appropriate action for attacktypes with 1596 * it. It will do the appropriate action for attacktypes with
1593 * effects (slow, paralization, etc. 1597 * effects (slow, paralization, etc.
1594 */ 1598 */
1595 if (type & attacktype)
1596 {
1597 ndam = hit_player_attacktype (op, hitter, dam, attacknum, magic); 1599 ndam = hit_player_attacktype (op, hitter, dam, attacknum, magic);
1600
1598 /* the >= causes us to prefer messages from special attacks, if 1601 /* the >= causes us to prefer messages from special attacks, if
1599 * the damage is equal. 1602 * the damage is equal.
1600 */ 1603 */
1601 if (ndam >= maxdam) 1604 if (ndam >= maxdam)
1602 { 1605 {
1603 maxdam = ndam; 1606 maxdam = ndam;
1604 maxattacktype = 1 << attacknum; 1607 maxattacktype = 1 << attacknum;
1605 }
1606 } 1608 }
1607 } 1609 }
1608 1610
1609 /* if this is friendly fire then do a set % of damage only 1611 /* 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 1612 * Note - put a check in to make sure this attack is actually
1668 attack_message (maxdam, maxattacktype, op, hitter); 1670 attack_message (maxdam, maxattacktype, op, hitter);
1669 1671
1670 op->stats.hp -= maxdam; 1672 op->stats.hp -= maxdam;
1671 1673
1672 /* Eneq(@csd.uu.se): Check to see if monster runs away. */ 1674 /* Eneq(@csd.uu.se): Check to see if monster runs away. */
1673 if ((op->stats.hp >= 0) && 1675 if (op->stats.hp >= 0
1674 (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) && 1676 && (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER)
1675 op->stats.hp < (signed short) (((float) op->run_away / (float) 100) * (float) op->stats.maxhp)) 1677 && op->stats.hp * 100 < op->stats.maxhp * op->run_away)
1676 { 1678 {
1677 1679
1678 if (QUERY_FLAG (op, FLAG_MONSTER)) 1680 if (QUERY_FLAG (op, FLAG_MONSTER))
1679 SET_FLAG (op, FLAG_RUN_AWAY); 1681 SET_FLAG (op, FLAG_RUN_AWAY);
1680 else 1682 else
1701 if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) 1703 if (QUERY_FLAG (hitter, FLAG_ONE_HIT))
1702 hitter->drop_and_destroy (); 1704 hitter->drop_and_destroy ();
1703 /* Lets handle creatures that are splitting now */ 1705 /* Lets handle creatures that are splitting now */
1704 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) 1706 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING))
1705 { 1707 {
1706 int i;
1707 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); 1708 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY);
1708 int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE); 1709 int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE);
1709 object *owner = op->owner; 1710 object *owner = op->owner;
1710 1711
1711 if (!op->other_arch) 1712 if (!op->other_arch)
1714 return maxdam; 1715 return maxdam;
1715 } 1716 }
1716 1717
1717 op->remove (); 1718 op->remove ();
1718 1719
1719 for (i = 0; i < op->stats.food; i++) 1720 for (int i = 0; i < op->stats.food; i++)
1720 { /* This doesn't handle op->more yet */ 1721 { /* This doesn't handle op->more yet */
1721 object *tmp = arch_to_object (op->other_arch); 1722 object *tmp = op->other_arch->instance ();
1722 int j;
1723 1723
1724 tmp->stats.hp = op->stats.hp; 1724 tmp->stats.hp = op->stats.hp;
1725 1725
1726 if (friendly) 1726 if (friendly)
1727 { 1727 {
1733 } 1733 }
1734 1734
1735 if (unaggressive) 1735 if (unaggressive)
1736 SET_FLAG (tmp, FLAG_UNAGGRESSIVE); 1736 SET_FLAG (tmp, FLAG_UNAGGRESSIVE);
1737 1737
1738 j = find_first_free_spot (tmp, op->map, op->x, op->y); 1738 int j = find_first_free_spot (tmp, op->map, op->x, op->y);
1739 1739
1740 if (j == -1) /* No spot to put this monster */ 1740 if (j == -1) /* No spot to put this monster */
1741 tmp->destroy (); 1741 tmp->destroy ();
1742 else 1742 else
1743 { 1743 {
1760 archetype *at = archetype::find (shstr_poisoning); 1760 archetype *at = archetype::find (shstr_poisoning);
1761 object *tmp = present_arch_in_ob (at, op); 1761 object *tmp = present_arch_in_ob (at, op);
1762 1762
1763 if (tmp == NULL) 1763 if (tmp == NULL)
1764 { 1764 {
1765 if ((tmp = arch_to_object (at)) == NULL) 1765 tmp = insert_ob_in_ob (at->instance (), op);
1766 LOG (llevError, "Failed to clone arch poisoning.\n"); 1766 /* peterm: give poisoning some teeth. It should
1767 * be able to kill things better than it does:
1768 * damage should be dependent something--I choose to
1769 * do this: if it's a monster, the damage from the
1770 * poisoning goes as the level of the monster/2.
1771 * If anything else, goes as damage.
1772 */
1773
1774 if (QUERY_FLAG (hitter, FLAG_ALIVE))
1775 tmp->stats.dam += hitter->level / 2;
1767 else 1776 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; 1777 tmp->stats.dam = dam;
1782 1778
1783 tmp->set_owner (hitter); /* so we get credit for poisoning kills */ 1779 tmp->set_owner (hitter); /* so we get credit for poisoning kills */
1784 if (hitter->skill && hitter->skill != tmp->skill) 1780 if (hitter->skill && hitter->skill != tmp->skill)
1785 {
1786 tmp->skill = hitter->skill; 1781 tmp->skill = hitter->skill;
1787 }
1788 1782
1789 tmp->stats.food += dam; /* more damage, longer poisoning */ 1783 tmp->stats.food += dam; /* more damage, longer poisoning */
1790 1784
1791 if (op->type == PLAYER) 1785 if (op->type == PLAYER)
1792 { 1786 {
1793 /* player looses stats, maximum is -10 of each */ 1787 /* player looses stats, maximum is -10 of each */
1794 tmp->stats.Con = max (-(dam / 4 + 1), -10); 1788 tmp->stats.Con = max (-(dam / 4 + 1), -10);
1795 tmp->stats.Str = max (-(dam / 3 + 2), -10); 1789 tmp->stats.Str = max (-(dam / 3 + 2), -10);
1796 tmp->stats.Dex = max (-(dam / 6 + 1), -10); 1790 tmp->stats.Dex = max (-(dam / 6 + 1), -10);
1797 tmp->stats.Int = max (-(dam / 7 ), -10); 1791 tmp->stats.Int = max (-(dam / 7 ), -10);
1798 SET_FLAG (tmp, FLAG_APPLIED); 1792 SET_FLAG (tmp, FLAG_APPLIED);
1799 op->update_stats (); 1793 op->update_stats ();
1800 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill."); 1794 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill.");
1801 op->play_sound (tmp->sound); 1795 op->play_sound (tmp->sound);
1802 } 1796 }
1803 1797
1804 if (hitter->type == PLAYER) 1798 if (hitter->type == PLAYER)
1805 new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); 1799 new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name);
1806 else if (hitter->owner != NULL && hitter->owner->type == PLAYER) 1800 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); 1801 new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name);
1808 }
1809 1802
1810 tmp->speed_left = 0; 1803 tmp->speed_left = 0;
1811 } 1804 }
1812 else 1805 else
1813 tmp->stats.food++; 1806 tmp->stats.food++;
1822 if (at == NULL) 1815 if (at == NULL)
1823 LOG (llevError, "Can't find slowness archetype.\n"); 1816 LOG (llevError, "Can't find slowness archetype.\n");
1824 1817
1825 if ((tmp = present_arch_in_ob (at, op)) == NULL) 1818 if ((tmp = present_arch_in_ob (at, op)) == NULL)
1826 { 1819 {
1827 tmp = arch_to_object (at); 1820 tmp = at->instance ();
1828 tmp = insert_ob_in_ob (tmp, op); 1821 tmp = insert_ob_in_ob (tmp, op);
1829 new_draw_info (NDI_UNIQUE, 0, op, "The world suddenly moves very fast!"); 1822 new_draw_info (NDI_UNIQUE, 0, op, "The world suddenly moves very fast!");
1830 } 1823 }
1831 else 1824 else
1832 tmp->stats.food++; 1825 tmp->stats.food++;
1919 */ 1912 */
1920 1913
1921 /* Do this as a float - otherwise, rounding might very well reduce this to 0 */ 1914 /* 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; 1915 float effect = dam * 3.f * (100.f - op->resist[ATNR_PARALYZE]) / 100.f;
1923 1916
1924 op->speed_left -= fabs (op->speed) * effect; 1917 op->speed_left -= op->speed * effect;
1925 /* tmp->stats.food+=(signed short) effect/op->speed; */ 1918 /* tmp->stats.food+=(signed short) effect/op->speed; */
1926 1919
1927 /* max number of ticks to be affected for. */ 1920 /* max number of ticks to be affected for. */
1928 float max = (100 - op->resist[ATNR_PARALYZE]) / 2; 1921 float max = (100 - op->resist[ATNR_PARALYZE]) / 2;
1929 1922
1930 if (op->speed_left < -(fabs (op->speed) * max)) 1923 max_it (op->speed_left, -op->speed * max);
1931 op->speed_left = -(fabs (op->speed) * max);
1932 1924
1933/* tmp->stats.food = (signed short) (max / fabs (op->speed)); */ 1925/* tmp->stats.food = (signed short) (max / op->speed); */
1934} 1926}
1935 1927
1936/* Attempts to kill 'op'. hitter is the attack object, dam is 1928/* Attempts to kill 'op'. hitter is the attack object, dam is
1937 * the computed damaged. 1929 * the computed damaged.
1938 */ 1930 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines