00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00028 #include <global.h>
00029 #include <ob_methods.h>
00030 #include <ob_types.h>
00031 #include <sounds.h>
00032 #include <sproto.h>
00033
00034 static method_ret duplicator_type_trigger(ob_methods *context, object *op, object *cause, int state);
00035
00039 void init_type_duplicator(void) {
00040 register_trigger(DUPLICATOR, duplicator_type_trigger);
00041 }
00042
00054 void move_duplicator(object *op) {
00055 object *tmp;
00056
00057 if (!op->other_arch) {
00058 LOG(llevInfo, "Duplicator with no other_arch! %d %d %s\n", op->x, op->y, op->map ? op->map->path : "nullmap");
00059 return;
00060 }
00061
00062 if (op->above == NULL)
00063 return;
00064 for (tmp = op->above; tmp != NULL; tmp = tmp->above) {
00065 if (strcmp(op->other_arch->name, tmp->arch->name) == 0) {
00066 if (op->level <= 0) {
00067 remove_ob(tmp);
00068 free_object(tmp);
00069 } else {
00070 uint64 new_nrof = (uint64)tmp->nrof*op->level;
00071
00072 if (new_nrof >= 1UL<<31)
00073 new_nrof = 1UL<<31;
00074 tmp->nrof = new_nrof;
00075 }
00076 break;
00077 }
00078 }
00079 }
00080
00089 static method_ret duplicator_type_trigger(ob_methods *context, object *op, object *cause, int state) {
00090 move_duplicator(op);
00091 return METHOD_OK;
00092 }