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.58 by root, Sun Apr 29 03:44:36 2007 UTC vs.
Revision 1.59 by root, Sun Apr 29 18:11:21 2007 UTC

267 * op is going in direction 'dir' 267 * op is going in direction 'dir'
268 * type is the attacktype of the object. 268 * type is the attacktype of the object.
269 * full_hit is set if monster area does not matter. 269 * full_hit is set if monster area does not matter.
270 * returns 1 if it hits something, 0 otherwise. 270 * returns 1 if it hits something, 0 otherwise.
271 */ 271 */
272
273int 272int
274hit_map (object *op, int dir, int type, int full_hit) 273hit_map (object *op, int dir, int type, int full_hit)
275{ 274{
276 maptile *map; 275 maptile *map;
277 sint16 x, y; 276 sint16 x, y;
310 mapspace &ms = map->at (x, y); 309 mapspace &ms = map->at (x, y);
311 310
312 if (ms.flags () & P_SAFE) 311 if (ms.flags () & P_SAFE)
313 return 0; 312 return 0;
314 313
315 /* peterm: a few special cases for special attacktypes --counterspell 314 /* peterm: a few special cases for special attacktypes --counterspell
316 * must be out here because it strikes things which are not alive 315 * must be out here because it strikes things which are not alive
317 */ 316 */
318 if (type & (AT_COUNTERSPELL | AT_CHAOS)) 317 if (type & (AT_COUNTERSPELL | AT_CHAOS))
319 { 318 {
320 if (type & AT_COUNTERSPELL) 319 if (type & AT_COUNTERSPELL)
774 { 773 {
775 int hitdam = base_dam; 774 int hitdam = base_dam;
776 775
777 if (settings.casting_time == TRUE) 776 if (settings.casting_time == TRUE)
778 { 777 {
779 if ((hitter->type == PLAYER) && (hitter->casting_time > -1)) 778 if (hitter->type == PLAYER && hitter->casting_time > -1)
780 { 779 {
781 hitter->casting_time = -1; 780 hitter->casting_time = -1;
782 new_draw_info (NDI_UNIQUE, 0, hitter, "You attacked and lost your spell!"); 781 new_draw_info (NDI_UNIQUE, 0, hitter, "You attacked and lost your spell!");
783 } 782 }
784 783
785 if ((op->casting_time > -1) && (hitdam > 0)) 784 if (op->casting_time > -1 && hitdam > 0)
786 { 785 {
787 op->casting_time = -1; 786 op->casting_time = -1;
788 if (op->type == PLAYER) 787 if (op->type == PLAYER)
789 { 788 {
790 new_draw_info (NDI_UNIQUE, 0, op, "You were hit and lost your spell!"); 789 new_draw_info (NDI_UNIQUE, 0, op, "You were hit and lost your spell!");
808 807
809 /* if you were hidden and hit by a creature, you are discovered */ 808 /* if you were hidden and hit by a creature, you are discovered */
810 if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE)) 809 if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE))
811 { 810 {
812 make_visible (op); 811 make_visible (op);
812
813 if (op->type == PLAYER) 813 if (op->type == PLAYER)
814 new_draw_info (NDI_UNIQUE, 0, op, "You were hit by a wild attack. " "You are no longer hidden!"); 814 new_draw_info (NDI_UNIQUE, 0, op, "You were hit by a wild attack. " "You are no longer hidden!");
815 } 815 }
816 816
817 /* thrown items (hitter) will have various effects 817 /* thrown items (hitter) will have various effects
891 * debate - 5000 is 5 kg, so arrows, knives, and other light weapons 891 * debate - 5000 is 5 kg, so arrows, knives, and other light weapons
892 * stick around. 892 * stick around.
893 */ 893 */
894 if (op->weight <= 5000 && tmp->stats.hp >= 0) 894 if (op->weight <= 5000 && tmp->stats.hp >= 0)
895 { 895 {
896 if (tmp->head != NULL)
897 tmp = tmp->head; 896 tmp = tmp->head_ ();
898 897
899 op->remove (); 898 op->remove ();
900 op = insert_ob_in_ob (op, tmp); 899 op = insert_ob_in_ob (op, tmp);
901 900
902 if (tmp->type == PLAYER) 901 if (tmp->type == PLAYER)
1067 SET_FLAG (target, FLAG_SCARED); 1066 SET_FLAG (target, FLAG_SCARED);
1068 if (!target->enemy) 1067 if (!target->enemy)
1069 target->enemy = owner; 1068 target->enemy = owner;
1070} 1069}
1071 1070
1072
1073/* This returns the amount of damage hitter does to op with the 1071/* This returns the amount of damage hitter does to op with the
1074 * appropriate attacktype. Only 1 attacktype should be set at a time. 1072 * appropriate attacktype. Only 1 attacktype should be set at a time.
1075 * This doesn't damage the player, but returns how much it should 1073 * This doesn't damage the player, but returns how much it should
1076 * take. However, it will do other effects (paralyzation, slow, etc.) 1074 * take. However, it will do other effects (paralyzation, slow, etc.)
1077 * Note - changed for PR code - we now pass the attack number and not 1075 * Note - changed for PR code - we now pass the attack number and not
1099 if (attacknum == ATNR_INTERNAL) 1097 if (attacknum == ATNR_INTERNAL)
1100 return dam; 1098 return dam;
1101 1099
1102 if (hitter->slaying) 1100 if (hitter->slaying)
1103 { 1101 {
1104 if (((op->race != NULL) && strstr (hitter->slaying, op->race)) || 1102 if ((op->race && strstr (hitter->slaying, op->race))
1105 (op->arch && (op->arch->name != NULL) && strstr (op->arch->name, hitter->slaying))) 1103 || (op->arch && op->arch->name && strstr (op->arch->name, hitter->slaying)))
1106 { 1104 {
1107 doesnt_slay = 0; 1105 doesnt_slay = 0;
1108 dam *= 3; 1106 dam *= 3;
1109 } 1107 }
1110 } 1108 }
1124 /* Special hack. By default, if immune to something, you 1122 /* Special hack. By default, if immune to something, you
1125 * shouldn't need to worry. However, acid is an exception, since 1123 * shouldn't need to worry. However, acid is an exception, since
1126 * it can still damage your items. Only include attacktypes if 1124 * it can still damage your items. Only include attacktypes if
1127 * special processing is needed */ 1125 * special processing is needed */
1128 1126
1129 if ((op->resist[attacknum] >= 100) && doesnt_slay && (attacknum != ATNR_ACID)) 1127 if (op->resist[attacknum] >= 100
1128 && doesnt_slay
1129 && attacknum != ATNR_ACID)
1130 return 0; 1130 return 0;
1131 1131
1132 /* Keep this in order - makes things easier to find */ 1132 /* Keep this in order - makes things easier to find */
1133 1133
1134 switch (attacknum) 1134 switch (attacknum)
1184 else if (attacknum == ATNR_DEPLETE) 1184 else if (attacknum == ATNR_DEPLETE)
1185 op->drain_stat (); 1185 op->drain_stat ();
1186 else if (attacknum == ATNR_BLIND && !QUERY_FLAG (op, FLAG_UNDEAD) && !QUERY_FLAG (op, FLAG_GENERATOR)) 1186 else if (attacknum == ATNR_BLIND && !QUERY_FLAG (op, FLAG_UNDEAD) && !QUERY_FLAG (op, FLAG_GENERATOR))
1187 blind_player (op, hitter, dam); 1187 blind_player (op, hitter, dam);
1188 } 1188 }
1189
1189 dam = 0; /* These are all effects and don't do real damage */ 1190 dam = 0; /* These are all effects and don't do real damage */
1190 } 1191 }
1191 break; 1192 break;
1192 1193
1193 case ATNR_ACID: 1194 case ATNR_ACID:
1282 if (op->type != PLAYER || owner->type != PLAYER) 1283 if (op->type != PLAYER || owner->type != PLAYER)
1283 change_exp (owner, op->stats.exp / (rate * 2), 1284 change_exp (owner, op->stats.exp / (rate * 2),
1284 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, SK_EXP_TOTAL); 1285 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, SK_EXP_TOTAL);
1285 } 1286 }
1286 else if (op->type != PLAYER || hitter->type != PLAYER) 1287 else if (op->type != PLAYER || hitter->type != PLAYER)
1287 {
1288 change_exp (hitter, op->stats.exp / (rate * 2), 1288 change_exp (hitter, op->stats.exp / (rate * 2),
1289 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0); 1289 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0);
1290 } 1290
1291 change_exp (op, -op->stats.exp / rate, NULL, 0); 1291 change_exp (op, -op->stats.exp / rate, NULL, 0);
1292 } 1292 }
1293 1293
1294 dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure 1294 dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure
1295 * drain attack, you won't know that you are actually sucking out EXP, 1295 * drain attack, you won't know that you are actually sucking out EXP,
1309 1309
1310 /* if undead are not an enemy of your god, you turn them 1310 /* if undead are not an enemy of your god, you turn them
1311 * at half strength */ 1311 * at half strength */
1312 if (!god || !god->slaying || strstr (god->slaying, undead_name) == NULL) 1312 if (!god || !god->slaying || strstr (god->slaying, undead_name) == NULL)
1313 div = 2; 1313 div = 2;
1314
1314 /* Give a bonus if you resist turn undead */ 1315 /* Give a bonus if you resist turn undead */
1315 if (op->level * div < (turn_bonus[owner->stats.Wis] + owner->level + (op->resist[ATNR_TURN_UNDEAD] / 100))) 1316 if (op->level * div < (turn_bonus[owner->stats.Wis] + owner->level + (op->resist[ATNR_TURN_UNDEAD] / 100)))
1316 scare_creature (op, owner); 1317 scare_creature (op, owner);
1317 } 1318 }
1318 else 1319 else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines