| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#include <global.h> |
| 29 |
#include <ob_methods.h> |
| 30 |
#include <ob_types.h> |
| 31 |
#include <sounds.h> |
| 32 |
#include <sproto.h> |
| 33 |
|
| 34 |
static method_ret peacemaker_type_process(ob_methods *context, object *op); |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
void init_type_peacemaker(void) { |
| 40 |
register_process(PEACEMAKER, peacemaker_type_process); |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
static method_ret peacemaker_type_process(ob_methods *context, object *op) { |
| 51 |
object *owner; |
| 52 |
|
| 53 |
owner = object_get_owner(op); |
| 54 |
if (owner == NULL) { |
| 55 |
LOG(llevError, "peacemaker_type_process: peacemaker object %s has no owner\n", op->name); |
| 56 |
object_remove(op); |
| 57 |
object_free(op, 1); |
| 58 |
return METHOD_OK; |
| 59 |
} |
| 60 |
|
| 61 |
FOR_MAP_PREPARE(op->map, op->x, op->y, tmp) { |
| 62 |
int atk_lev, def_lev; |
| 63 |
object *victim; |
| 64 |
|
| 65 |
victim = HEAD(tmp); |
| 66 |
if (!QUERY_FLAG(victim, FLAG_MONSTER)) |
| 67 |
continue; |
| 68 |
if (QUERY_FLAG(victim, FLAG_UNAGGRESSIVE)) |
| 69 |
continue; |
| 70 |
if (victim->stats.exp == 0) |
| 71 |
continue; |
| 72 |
|
| 73 |
def_lev = MAX(1, victim->level); |
| 74 |
atk_lev = MAX(1, op->level); |
| 75 |
|
| 76 |
if (rndm(0, atk_lev-1) > def_lev) { |
| 77 |
|
| 78 |
|
| 79 |
change_exp(owner, victim->stats.exp, op->skill, 0); |
| 80 |
victim->stats.exp = 0; |
| 81 |
victim->attack_movement = RANDO2; |
| 82 |
SET_FLAG(victim, FLAG_UNAGGRESSIVE); |
| 83 |
SET_FLAG(victim, FLAG_RUN_AWAY); |
| 84 |
SET_FLAG(victim, FLAG_RANDOM_MOVE); |
| 85 |
CLEAR_FLAG(victim, FLAG_MONSTER); |
| 86 |
if (victim->name) { |
| 87 |
draw_ext_info_format(NDI_UNIQUE, 0, owner, MSG_TYPE_SPELL, MSG_TYPE_SPELL_SUCCESS, |
| 88 |
"%s no longer feels like fighting.", |
| 89 |
victim->name); |
| 90 |
} |
| 91 |
} |
| 92 |
} FOR_MAP_FINISH(); |
| 93 |
return METHOD_OK; |
| 94 |
} |