… | |
… | |
35 | * set to sane values. |
35 | * set to sane values. |
36 | */ |
36 | */ |
37 | object * |
37 | object * |
38 | check_enemy (object *npc, rv_vector * rv) |
38 | check_enemy (object *npc, rv_vector * rv) |
39 | { |
39 | { |
40 | |
|
|
41 | /* if this is pet, let him attack the same enemy as his owner |
40 | /* if this is pet, let him attack the same enemy as his owner |
42 | * TODO: when there is no ower enemy, try to find a target, |
41 | * TODO: when there is no ower enemy, try to find a target, |
43 | * which CAN attack the owner. */ |
42 | * which CAN attack the owner. */ |
44 | if ((npc->attack_movement & HI4) == PETMOVE) |
43 | if ((npc->attack_movement & HI4) == PETMOVE) |
45 | { |
44 | { |
… | |
… | |
324 | op->last_heal += (int) ((float) (8 * op->stats.Con) / FABS (op->speed)); |
323 | op->last_heal += (int) ((float) (8 * op->stats.Con) / FABS (op->speed)); |
325 | op->stats.hp = MIN ((sint32) op->stats.hp + op->last_heal / 32, op->stats.maxhp); /* causes Con/4 hp/tick */ |
324 | op->stats.hp = MIN ((sint32) op->stats.hp + op->last_heal / 32, op->stats.maxhp); /* causes Con/4 hp/tick */ |
326 | op->last_heal %= 32; |
325 | op->last_heal %= 32; |
327 | |
326 | |
328 | /* So if the monster has gained enough HP that they are no longer afraid */ |
327 | /* So if the monster has gained enough HP that they are no longer afraid */ |
329 | if (QUERY_FLAG (op, FLAG_RUN_AWAY) && op->stats.hp >= (signed short) (((float) op->run_away / (float) 100) * (float) op->stats.maxhp)) |
328 | if (QUERY_FLAG (op, FLAG_RUN_AWAY) && op->stats.hp >= (signed short)(((float)op->run_away / 100.f) * (float)op->stats.maxhp)) |
330 | CLEAR_FLAG (op, FLAG_RUN_AWAY); |
329 | CLEAR_FLAG (op, FLAG_RUN_AWAY); |
331 | |
330 | |
332 | if (op->stats.hp > op->stats.maxhp) |
331 | if (op->stats.hp > op->stats.maxhp) |
333 | op->stats.hp = op->stats.maxhp; |
332 | op->stats.hp = op->stats.maxhp; |
334 | } |
333 | } |
335 | |
334 | |
336 | /* generate sp, if applicable */ |
335 | /* generate sp, if applicable */ |
337 | if (op->stats.Pow > 0 && op->stats.sp < op->stats.maxsp) |
336 | if (op->stats.Pow > 0 && op->stats.sp < op->stats.maxsp) |
338 | { |
337 | { |
339 | /* last_sp is in funny units. Dividing by speed puts |
338 | /* last_sp is in funny units. Dividing by speed puts |
340 | * the regeneration rate on a basis of time instead of |
339 | * the regeneration rate on a basis of time instead of |
341 | * #moves the monster makes. The scaling by 8 is |
340 | * #moves the monster makes. The scaling by 8 is |
342 | * to capture 8th's of a sp fraction regens |
341 | * to capture 8th's of a sp fraction regens |
343 | * |
342 | * |
344 | * Cast to sint32 before comparing to maxhp since otherwise an (sint16) |
343 | * Cast to sint32 before comparing to maxhp since otherwise an (sint16) |
345 | * overflow might produce monsters with negative sp. |
344 | * overflow might produce monsters with negative sp. |
346 | */ |
345 | */ |
347 | |
346 | |
348 | op->last_sp += (int) ((float) (8 * op->stats.Pow) / FABS (op->speed)); |
347 | op->last_sp += (int) ((float) (8 * op->stats.Pow) / fabsf (op->speed)); |
349 | op->stats.sp = MIN (op->stats.sp + op->last_sp / 128, op->stats.maxsp); /* causes Pow/16 sp/tick */ |
348 | op->stats.sp = min (op->stats.sp + op->last_sp / 128, op->stats.maxsp); /* causes Pow/16 sp/tick */ |
350 | op->last_sp %= 128; |
349 | op->last_sp %= 128; |
351 | } |
350 | } |
352 | |
351 | |
353 | /* this should probably get modified by many more values. |
352 | /* this should probably get modified by many more values. |
354 | * (eg, creatures resistance to fear, level, etc. ) |
353 | * (eg, creatures resistance to fear, level, etc. ) |
… | |
… | |
504 | if (QUERY_FLAG (op, FLAG_READY_BOW) && !(rndm (2))) |
503 | if (QUERY_FLAG (op, FLAG_READY_BOW) && !(rndm (2))) |
505 | if (monster_use_bow (op, part, enemy, dir)) |
504 | if (monster_use_bow (op, part, enemy, dir)) |
506 | return 0; |
505 | return 0; |
507 | } /* for processing of all parts */ |
506 | } /* for processing of all parts */ |
508 | } /* If not scared */ |
507 | } /* If not scared */ |
509 | |
|
|
510 | |
508 | |
511 | part = rv.part; |
509 | part = rv.part; |
512 | dir = rv.direction; |
510 | dir = rv.direction; |
513 | |
511 | |
514 | if (QUERY_FLAG (op, FLAG_SCARED) || QUERY_FLAG (op, FLAG_RUN_AWAY)) |
512 | if (QUERY_FLAG (op, FLAG_SCARED) || QUERY_FLAG (op, FLAG_RUN_AWAY)) |