1 | |
1 | |
2 | /* |
2 | /* |
3 | * static char *rcsid_attack_c = |
3 | * static char *rcsid_attack_c = |
4 | * "$Id: attack.C,v 1.10 2006/09/11 11:46:52 root Exp $"; |
4 | * "$Id: attack.C,v 1.15 2006/09/14 20:46:10 root Exp $"; |
5 | */ |
5 | */ |
6 | |
6 | |
7 | /* |
7 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
9 | |
9 | |
… | |
… | |
177 | if (type & (AT_FIRE | AT_ELECTRICITY) && op->other_arch && QUERY_FLAG (op, FLAG_IS_LIGHTABLE)) |
177 | if (type & (AT_FIRE | AT_ELECTRICITY) && op->other_arch && QUERY_FLAG (op, FLAG_IS_LIGHTABLE)) |
178 | { |
178 | { |
179 | const char *arch = op->other_arch->name; |
179 | const char *arch = op->other_arch->name; |
180 | |
180 | |
181 | op = decrease_ob_nr (op, 1); |
181 | op = decrease_ob_nr (op, 1); |
|
|
182 | |
182 | if (op) |
183 | if (op) |
183 | fix_stopped_item (op, m, originator); |
184 | fix_stopped_item (op, m, originator); |
|
|
185 | |
184 | if ((op = get_archetype (arch)) != NULL) |
186 | if ((op = get_archetype (arch)) != NULL) |
185 | { |
187 | { |
186 | if (env) |
188 | if (env) |
187 | { |
189 | { |
188 | op->x = env->x, op->y = env->y; |
190 | op->x = env->x, op->y = env->y; |
… | |
… | |
194 | { |
196 | { |
195 | op->x = x, op->y = y; |
197 | op->x = x, op->y = y; |
196 | insert_ob_in_map (op, m, originator, 0); |
198 | insert_ob_in_map (op, m, originator, 0); |
197 | } |
199 | } |
198 | } |
200 | } |
|
|
201 | |
199 | return; |
202 | return; |
200 | } |
203 | } |
|
|
204 | |
201 | if (type & AT_CANCELLATION) |
205 | if (type & AT_CANCELLATION) |
202 | { /* Cancellation. */ |
206 | { /* Cancellation. */ |
203 | cancellation (op); |
207 | cancellation (op); |
204 | fix_stopped_item (op, m, originator); |
208 | fix_stopped_item (op, m, originator); |
205 | return; |
209 | return; |
206 | } |
210 | } |
|
|
211 | |
207 | if (op->nrof > 1) |
212 | if (op->nrof > 1) |
208 | { |
213 | { |
209 | op = decrease_ob_nr (op, rndm (0, op->nrof - 1)); |
214 | op = decrease_ob_nr (op, rndm (0, op->nrof - 1)); |
|
|
215 | |
210 | if (op) |
216 | if (op) |
211 | fix_stopped_item (op, m, originator); |
217 | fix_stopped_item (op, m, originator); |
212 | } |
218 | } |
213 | else |
219 | else |
214 | { |
220 | { |
215 | if (op->env) |
221 | if (op->env) |
216 | { |
222 | { |
217 | object *tmp = is_player_inv (op->env); |
223 | object *tmp = is_player_inv (op->env); |
218 | |
224 | |
219 | if (tmp) |
225 | if (tmp) |
220 | { |
|
|
221 | esrv_del_item (tmp->contr, op->count); |
226 | esrv_del_item (tmp->contr, op->count); |
222 | } |
|
|
223 | } |
227 | } |
|
|
228 | |
224 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
229 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
225 | remove_ob (op); |
230 | remove_ob (op); |
|
|
231 | |
226 | free_object (op); |
232 | free_object (op); |
227 | } |
233 | } |
|
|
234 | |
228 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
235 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
229 | { |
|
|
230 | if (env) |
236 | if (env) |
231 | { |
237 | { |
232 | op = get_archetype ("burnout"); |
238 | op = get_archetype ("burnout"); |
233 | op->x = env->x, op->y = env->y; |
239 | op->x = env->x, op->y = env->y; |
234 | insert_ob_in_ob (op, env); |
240 | insert_ob_in_ob (op, env); |
235 | } |
241 | } |
236 | else |
242 | else |
237 | { |
|
|
238 | replace_insert_ob_in_map ("burnout", originator); |
243 | replace_insert_ob_in_map ("burnout", originator); |
239 | } |
244 | |
240 | } |
|
|
241 | return; |
245 | return; |
242 | } |
246 | } |
|
|
247 | |
243 | /* The value of 50 is arbitrary. */ |
248 | /* The value of 50 is arbitrary. */ |
244 | if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && (RANDOM () & 2)) |
249 | if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && (RANDOM () & 2)) |
245 | { |
250 | { |
246 | object *tmp; |
251 | object *tmp; |
247 | archetype *at = find_archetype ("icecube"); |
252 | archetype *at = find_archetype ("icecube"); |
248 | |
253 | |
249 | if (at == NULL) |
254 | if (at == NULL) |
250 | return; |
255 | return; |
|
|
256 | |
251 | op = stop_item (op); |
257 | op = stop_item (op); |
252 | if (op == NULL) |
258 | if (op == NULL) |
253 | return; |
259 | return; |
|
|
260 | |
254 | if ((tmp = present_arch (at, op->map, op->x, op->y)) == NULL) |
261 | if ((tmp = present_arch (at, op->map, op->x, op->y)) == NULL) |
255 | { |
262 | { |
256 | tmp = arch_to_object (at); |
263 | tmp = arch_to_object (at); |
257 | tmp->x = op->x, tmp->y = op->y; |
264 | tmp->x = op->x, tmp->y = op->y; |
258 | /* This was in the old (pre new movement code) - |
265 | /* This was in the old (pre new movement code) - |
… | |
… | |
261 | */ |
268 | */ |
262 | tmp->move_slow_penalty = 0; |
269 | tmp->move_slow_penalty = 0; |
263 | tmp->move_slow = 0; |
270 | tmp->move_slow = 0; |
264 | insert_ob_in_map (tmp, op->map, originator, 0); |
271 | insert_ob_in_map (tmp, op->map, originator, 0); |
265 | } |
272 | } |
|
|
273 | |
266 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
274 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
267 | remove_ob (op); |
275 | remove_ob (op); |
|
|
276 | |
268 | (void) insert_ob_in_ob (op, tmp); |
277 | insert_ob_in_ob (op, tmp); |
269 | return; |
278 | return; |
270 | } |
279 | } |
271 | } |
280 | } |
272 | |
281 | |
273 | /* Object op is hitting the map. |
282 | /* Object op is hitting the map. |
… | |
… | |
316 | |
325 | |
317 | int mflags = get_map_flags (map, &map, x, y, &x, &y); |
326 | int mflags = get_map_flags (map, &map, x, y, &x, &y); |
318 | |
327 | |
319 | // elmex: a safe map tile can't be hit! |
328 | // elmex: a safe map tile can't be hit! |
320 | // this should prevent most harmful effects on items and players there. |
329 | // this should prevent most harmful effects on items and players there. |
321 | if ((mflags & P_OUT_OF_MAP) || (mflags & P_SAFE)) |
330 | if (mflags & (P_OUT_OF_MAP | P_SAFE)) |
322 | return 0; |
331 | return 0; |
323 | |
332 | |
324 | /* peterm: a few special cases for special attacktypes --counterspell |
333 | /* peterm: a few special cases for special attacktypes --counterspell |
325 | * must be out here because it strikes things which are not alive |
334 | * must be out here because it strikes things which are not alive |
326 | */ |
335 | */ |
… | |
… | |
331 | |
340 | |
332 | /* If the only attacktype is counterspell or magic, don't need |
341 | /* If the only attacktype is counterspell or magic, don't need |
333 | * to do any further processing. |
342 | * to do any further processing. |
334 | */ |
343 | */ |
335 | if (!(type & ~(AT_COUNTERSPELL | AT_MAGIC))) |
344 | if (!(type & ~(AT_COUNTERSPELL | AT_MAGIC))) |
336 | { |
|
|
337 | return 0; |
345 | return 0; |
338 | } |
346 | |
339 | type &= ~AT_COUNTERSPELL; |
347 | type &= ~AT_COUNTERSPELL; |
340 | } |
348 | } |
341 | |
349 | |
342 | if (type & AT_CHAOS) |
350 | if (type & AT_CHAOS) |
343 | { |
351 | { |
… | |
… | |
364 | * below was spamming the logs for absolutely no reason. |
372 | * below was spamming the logs for absolutely no reason. |
365 | */ |
373 | */ |
366 | /* LOG (llevDebug, "hit_map(): next object destroyed\n"); */ |
374 | /* LOG (llevDebug, "hit_map(): next object destroyed\n"); */ |
367 | break; |
375 | break; |
368 | } |
376 | } |
|
|
377 | |
369 | tmp = next; |
378 | tmp = next; |
370 | next = tmp->above; |
379 | next = tmp->above; |
|
|
380 | |
371 | if (next) |
381 | if (next) |
372 | next_tag = next->count; |
382 | next_tag = next->count; |
373 | |
383 | |
374 | if (QUERY_FLAG (tmp, FLAG_FREED)) |
384 | if (QUERY_FLAG (tmp, FLAG_FREED)) |
375 | { |
385 | { |
… | |
… | |
389 | hit_player (tmp, op->stats.dam, op, type, full_hit); |
399 | hit_player (tmp, op->stats.dam, op, type, full_hit); |
390 | retflag |= 1; |
400 | retflag |= 1; |
391 | if (was_destroyed (op, op_tag)) |
401 | if (was_destroyed (op, op_tag)) |
392 | break; |
402 | break; |
393 | } |
403 | } |
|
|
404 | |
394 | /* Here we are potentially destroying an object. If the object has |
405 | /* Here we are potentially destroying an object. If the object has |
395 | * NO_PASS set, it is also immune - you can't destroy walls. Note |
406 | * NO_PASS set, it is also immune - you can't destroy walls. Note |
396 | * that weak walls have is_alive set, which prevent objects from |
407 | * that weak walls have is_alive set, which prevent objects from |
397 | * passing over/through them. We don't care what type of movement |
408 | * passing over/through them. We don't care what type of movement |
398 | * the wall blocks - if it blocks any type of movement, can't be |
409 | * the wall blocks - if it blocks any type of movement, can't be |
… | |
… | |
403 | save_throw_object (tmp, type, op); |
414 | save_throw_object (tmp, type, op); |
404 | if (was_destroyed (op, op_tag)) |
415 | if (was_destroyed (op, op_tag)) |
405 | break; |
416 | break; |
406 | } |
417 | } |
407 | } |
418 | } |
|
|
419 | |
408 | return 0; |
420 | return 0; |
409 | } |
421 | } |
410 | |
422 | |
411 | void |
423 | void |
412 | attack_message (int dam, int type, object *op, object *hitter) |
424 | attack_message (int dam, int type, object *op, object *hitter) |
… | |
… | |
1328 | break; |
1340 | break; |
1329 | case ATNR_TURN_UNDEAD: |
1341 | case ATNR_TURN_UNDEAD: |
1330 | { |
1342 | { |
1331 | if (QUERY_FLAG (op, FLAG_UNDEAD)) |
1343 | if (QUERY_FLAG (op, FLAG_UNDEAD)) |
1332 | { |
1344 | { |
1333 | object *owner = get_owner (hitter) == NULL ? hitter : get_owner (hitter); |
1345 | object *owner = hitter->owner ? (object *)hitter->owner : hitter; |
1334 | object *god = find_god (determine_god (owner)); |
1346 | object *god = find_god (determine_god (owner)); |
1335 | int div = 1; |
1347 | int div = 1; |
1336 | |
1348 | |
1337 | /* if undead are not an enemy of your god, you turn them |
1349 | /* if undead are not an enemy of your god, you turn them |
1338 | * at half strength */ |
1350 | * at half strength */ |
… | |
… | |
1364 | break; |
1376 | break; |
1365 | case ATNR_HOLYWORD: |
1377 | case ATNR_HOLYWORD: |
1366 | { |
1378 | { |
1367 | /* This has already been handled by hit_player, |
1379 | /* This has already been handled by hit_player, |
1368 | * no need to check twice -- DAMN */ |
1380 | * no need to check twice -- DAMN */ |
1369 | |
1381 | object *owner = hitter->owner ? (object *)hitter->owner : hitter; |
1370 | object *owner = get_owner (hitter) == NULL ? hitter : get_owner (hitter); |
|
|
1371 | |
1382 | |
1372 | /* As with turn undead above, give a bonus on the saving throw */ |
1383 | /* As with turn undead above, give a bonus on the saving throw */ |
1373 | if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis]) |
1384 | if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis]) |
1374 | scare_creature (op, owner); |
1385 | scare_creature (op, owner); |
1375 | } |
1386 | } |
… | |
… | |
1684 | { |
1695 | { |
1685 | play_sound_player_only (owner1->contr, SOUND_PET_IS_KILLED, 0, 0); |
1696 | play_sound_player_only (owner1->contr, SOUND_PET_IS_KILLED, 0, 0); |
1686 | /* Maybe we should include the owner that killed this, maybe not */ |
1697 | /* Maybe we should include the owner that killed this, maybe not */ |
1687 | new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, is killed by %s.", &op->name, &hitter->name); |
1698 | new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, is killed by %s.", &op->name, &hitter->name); |
1688 | } |
1699 | } |
|
|
1700 | |
1689 | remove_friendly_object (op); |
1701 | remove_friendly_object (op); |
1690 | } |
1702 | } |
|
|
1703 | |
1691 | remove_ob (op); |
1704 | remove_ob (op); |
1692 | free_object (op); |
1705 | free_object (op); |
1693 | } |
1706 | } |
1694 | /* Player has been killed! */ |
1707 | /* Player has been killed! */ |
1695 | else |
1708 | else |
… | |
… | |
1697 | if (owner->type == PLAYER) |
1710 | if (owner->type == PLAYER) |
1698 | { |
1711 | { |
1699 | snprintf (op->contr->killer, BIG_NAME, "%s the %s", &owner->name, owner->contr->title); |
1712 | snprintf (op->contr->killer, BIG_NAME, "%s the %s", &owner->name, owner->contr->title); |
1700 | } |
1713 | } |
1701 | else |
1714 | else |
1702 | { |
|
|
1703 | strncpy (op->contr->killer, hitter->name, BIG_NAME); |
1715 | assign (op->contr->killer, hitter->name); |
1704 | op->contr->killer[BIG_NAME - 1] = '\0'; |
|
|
1705 | } |
|
|
1706 | } |
1716 | } |
|
|
1717 | |
1707 | /* This was return -1 - that doesn't seem correct - if we return -1, process |
1718 | /* This was return -1 - that doesn't seem correct - if we return -1, process |
1708 | * continues in the calling function. |
1719 | * continues in the calling function. |
1709 | */ |
1720 | */ |
1710 | return maxdam; |
1721 | return maxdam; |
1711 | } |
1722 | } |