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.120 by root, Tue Nov 10 16:29:20 2009 UTC vs.
Revision 1.121 by root, Wed Nov 11 03:52:45 2009 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 51 // destroying objects without material has many bad effects
52 if (mt == MATERIAL_NULL) 52 if (mt == MATERIAL_NULL)
53 return 1; 53 return 1;
54 54
55 roll = rndm (1, 20); 55 int roll = rndm (1, 20);
56 56
57 /* the attacktypes have no meaning for object saves 57 /* the attacktypes have no meaning for object saves
58 * 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
59 * 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
60 * is magic teamed with something else, then strip out the 60 * is magic teamed with something else, then strip out the
61 * magic type, and instead let the fire, cold, or whatever component 61 * magic type, and instead let the fire, cold, or whatever component
62 * destroy the item. Otherwise, you get the case of poisoncloud 62 * destroy the item. Otherwise, you get the case of poisoncloud
63 * destroying objects because it has magic attacktype. 63 * destroying objects because it has magic attacktype.
64 */ 64 */
65 if (type != AT_MAGIC) 65 if (type != AT_MAGIC)
66 type &= ~(AT_CONFUSION | AT_DRAIN | AT_GHOSTHIT | AT_POISON | AT_SLOW | 66 type &= ~(AT_CONFUSION | AT_DRAIN | AT_GHOSTHIT | AT_POISON | AT_SLOW |
67 AT_PARALYZE | AT_TURN_UNDEAD | AT_FEAR | AT_DEPLETE | AT_DEATH | 67 AT_PARALYZE | AT_TURN_UNDEAD | AT_FEAR | AT_DEPLETE | AT_DEATH |
68 AT_COUNTERSPELL | AT_HOLYWORD | AT_BLIND | AT_LIFE_STEALING | AT_MAGIC); 68 AT_COUNTERSPELL | AT_HOLYWORD | AT_BLIND | AT_LIFE_STEALING | AT_MAGIC);
69 69
70
70 if (type == 0) return TRUE; 71 if (type == 0) return TRUE;
71 72
72 if (roll == 20) return TRUE; 73 if (roll == 20) return TRUE;
73 if (roll == 1) return FALSE; 74 if (roll == 1) return FALSE;
74 75
75 for (number = 0; number < NROFATTACKS; number++) 76 for_all_bits_sparse_32 (type, number)
76 { 77 {
77 i = 1 << number;
78
79 if (!(i & type))
80 continue;
81
82 attacks++; 78 attacks++;
79
83 if (op->resist[number] == 100) 80 if (op->resist[number] == 100)
84 saves++; 81 saves++;
85 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)
86 saves++; 83 saves++;
87 else if ((20 - mt->save[number]) / 3 > originator->stats.dam) 84 else if ((20 - mt->save[number]) / 3 > originator->stats.dam)
152 * object with +/- glow_radius and an "other_arch" to change to. 149 * object with +/- glow_radius and an "other_arch" to change to.
153 * (and please note that we cant fail our save and reach this 150 * (and please note that we cant fail our save and reach this
154 * function if the object doesnt contain a material that can burn. 151 * function if the object doesnt contain a material that can burn.
155 * So forget lighting magical swords on fire with this!) -b.t. 152 * So forget lighting magical swords on fire with this!) -b.t.
156 */ 153 */
157 if (type & (AT_FIRE | AT_ELECTRICITY) 154 if (type & (AT_FIRE | AT_ELECTRICITY))
158 && (QUERY_FLAG (op, FLAG_IS_LIGHTABLE)
159 || op->type == LAMP
160 || op->type == TORCH
161 )) 155 {
162 { 156 // seems LAMPs and TORCHes are always IS_LIGHTABLE?
163 switch (op->type) 157 if (op->type == LAMP || op->type == TORCH)
164 { 158 {
165 case LAMP:
166 case TORCH:
167 // turn on a lamp
168 apply_lamp (op, true); 159 apply_lamp (op, true); // turn on a lamp
169 break; 160 return;
170
171 default:
172 // for instance icecubes:
173 if (op->other_arch)
174 {
175 const char *arch = op->other_arch->archname;
176
177 if (op->decrease ())
178 fix_stopped_item (op, m, originator);
179
180 if ((op = archetype::get (arch)))
181 {
182 if (env)
183 env->insert (op);
184 else
185 m->insert (op, x, y, originator);
186 }
187 }
188 } 161 }
162 else if (op->flag [FLAG_IS_LIGHTABLE])
163 {
164 if (op->other_arch)
165 {
166 const char *arch = op->other_arch->archname;
189 167
168 if (op->decrease ())
169 fix_stopped_item (op, m, originator);
170
171 if ((op = archetype::get (arch)))
172 {
173 if (env)
174 env->insert (op);
175 else
176 m->insert (op, x, y, originator);
177 }
178 }
179
190 return; 180 return;
181 }
191 } 182 }
192 183
193 if (type & AT_CANCELLATION) 184 if (type & AT_CANCELLATION)
194 { /* Cancellation. */ 185 { /* Cancellation. */
195 cancellation (op); 186 cancellation (op);
199 } 190 }
200 191
201 if (type & (AT_FIRE | AT_ELECTRICITY)) 192 if (type & (AT_FIRE | AT_ELECTRICITY))
202 if (env) 193 if (env)
203 { 194 {
204 op = archetype::get (shstr_burnout); 195 object *op = archetype::get (shstr_burnout);
205 op->x = env->x, op->y = env->y; 196 op->x = env->x, op->y = env->y;
206 env->insert (op); 197 env->insert (op);
207 } 198 }
208 else 199 else
209 replace_insert_ob_in_map (shstr_burnout, originator); 200 replace_insert_ob_in_map (shstr_burnout, originator);
259 * type is the attacktype of the object. 250 * type is the attacktype of the object.
260 * full_hit is set if monster area does not matter. 251 * full_hit is set if monster area does not matter.
261 * returns 1 if it hits something, 0 otherwise. 252 * returns 1 if it hits something, 0 otherwise.
262 */ 253 */
263int 254int
264hit_map (object *op, int dir, int type, int full_hit) 255hit_map (object *op, int dir, uint32_t type, int full_hit)
265{ 256{
266 maptile *map; 257 maptile *map;
267 sint16 x, y; 258 sint16 x, y;
268 int retflag = 0; /* added this flag.. will return 1 if it hits a monster */ 259 int retflag = 0; /* added this flag.. will return 1 if it hits a monster */
269 260
1460 * modify it. 1451 * modify it.
1461 */ 1452 */
1462/* Oct 95 - altered the following slightly for MULTIPLE_GODS hack 1453/* Oct 95 - altered the following slightly for MULTIPLE_GODS hack
1463 * which needs new attacktype AT_HOLYWORD to work . b.t. */ 1454 * which needs new attacktype AT_HOLYWORD to work . b.t. */
1464int 1455int
1465hit_player (object *op, int dam, object *hitter, int type, int full_hit) 1456hit_player (object *op, int dam, object *hitter, uint32_t type, int full_hit)
1466{ 1457{
1467 int maxdam = 0, ndam = 0, attacktype = 1, magic = (type & AT_MAGIC); 1458 int maxdam = 0, ndam = 0, attacktype = 1, magic = (type & AT_MAGIC);
1468 int maxattacktype, attacknum; 1459 int maxattacktype;
1469 int body_attack = op && op->head; /* Did we hit op's head? */ 1460 int body_attack = op && op->head; /* Did we hit op's head? */
1470 int simple_attack; 1461 int simple_attack;
1471 int rtn_kill = 0; 1462 int rtn_kill = 0;
1472 int friendlyfire; 1463 int friendlyfire;
1473 1464
1584 && god->race.contains (shstr_undead)))) 1575 && god->race.contains (shstr_undead))))
1585 return 0; 1576 return 0;
1586 } 1577 }
1587 1578
1588 maxattacktype = type; /* initialise this to something */ 1579 maxattacktype = type; /* initialise this to something */
1589 for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum) 1580 for_all_bits_sparse_32 (type, attacknum)
1590 { 1581 {
1582 uint32_t attacktype = 1 << attacknum;
1583
1591 /* Magic isn't really a true attack type - it gets combined with other 1584 /* Magic isn't really a true attack type - it gets combined with other
1592 * attack types. As such, skip it over. However, if magic is 1585 * attack types. As such, skip it over. However, if magic is
1593 * the only attacktype in the group, then still attack with it 1586 * the only attacktype in the group, then still attack with it
1594 */ 1587 */
1595 if ((attacktype == AT_MAGIC) && (type & ~AT_MAGIC)) 1588 if ((attacktype == AT_MAGIC) && (type & ~AT_MAGIC))
1598 /* Go through and hit the player with each attacktype, one by one. 1591 /* Go through and hit the player with each attacktype, one by one.
1599 * hit_player_attacktype only figures out the damage, doesn't inflict 1592 * hit_player_attacktype only figures out the damage, doesn't inflict
1600 * it. It will do the appropriate action for attacktypes with 1593 * it. It will do the appropriate action for attacktypes with
1601 * effects (slow, paralization, etc. 1594 * effects (slow, paralization, etc.
1602 */ 1595 */
1603 if (type & attacktype)
1604 {
1605 ndam = hit_player_attacktype (op, hitter, dam, attacknum, magic); 1596 ndam = hit_player_attacktype (op, hitter, dam, attacknum, magic);
1606 /* the >= causes us to prefer messages from special attacks, if 1597 /* the >= causes us to prefer messages from special attacks, if
1607 * the damage is equal. 1598 * the damage is equal.
1608 */ 1599 */
1609 if (ndam >= maxdam) 1600 if (ndam >= maxdam)
1610 { 1601 {
1611 maxdam = ndam; 1602 maxdam = ndam;
1612 maxattacktype = 1 << attacknum; 1603 maxattacktype = 1 << attacknum;
1613 }
1614 } 1604 }
1615 } 1605 }
1616 1606
1617 /* if this is friendly fire then do a set % of damage only 1607 /* if this is friendly fire then do a set % of damage only
1618 * Note - put a check in to make sure this attack is actually 1608 * Note - put a check in to make sure this attack is actually

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines