| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include "global.h" |
| 20 |
|
| 21 |
#include <string.h> |
| 22 |
|
| 23 |
#include "ob_methods.h" |
| 24 |
#include "ob_types.h" |
| 25 |
#include "sounds.h" |
| 26 |
#include "sproto.h" |
| 27 |
|
| 28 |
static method_ret duplicator_type_trigger(ob_methods *context, object *op, object *cause, int state); |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
void init_type_duplicator(void) { |
| 34 |
register_trigger(DUPLICATOR, duplicator_type_trigger); |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
static void move_duplicator(object *op) { |
| 49 |
object *tmp; |
| 50 |
|
| 51 |
if (!op->other_arch) { |
| 52 |
LOG(llevInfo, "Duplicator with no other_arch! %d %d %s\n", op->x, op->y, op->map ? op->map->path : "nullmap"); |
| 53 |
return; |
| 54 |
} |
| 55 |
|
| 56 |
if (op->above == NULL) |
| 57 |
return; |
| 58 |
int count = op->nrof; |
| 59 |
for (tmp = op->above; tmp != NULL; tmp = tmp->above) { |
| 60 |
if (strcmp(op->other_arch->name, tmp->arch->name) == 0) { |
| 61 |
if (op->level <= 0) { |
| 62 |
object_remove(tmp); |
| 63 |
object_free_drop_inventory(tmp); |
| 64 |
tmp = op; |
| 65 |
} else { |
| 66 |
uint64_t new_nrof = (uint64_t)tmp->nrof*op->level; |
| 67 |
|
| 68 |
if (new_nrof >= 1UL<<31) |
| 69 |
new_nrof = 1UL<<31; |
| 70 |
tmp->nrof = new_nrof; |
| 71 |
} |
| 72 |
if ( count <= 1 ) break; |
| 73 |
--count; |
| 74 |
} |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
static method_ret duplicator_type_trigger(ob_methods *context, object *op, object *cause, int state) { |
| 87 |
move_duplicator(op); |
| 88 |
return METHOD_OK; |
| 89 |
} |