… | |
… | |
50 | } |
50 | } |
51 | } |
51 | } |
52 | |
52 | |
53 | if (op->other_arch) |
53 | if (op->other_arch) |
54 | { |
54 | { |
55 | object *tmp = arch_to_object (op->other_arch); |
55 | object *tmp = op->other_arch->instance (); |
56 | tmp->x = op->x; |
56 | tmp->x = op->x; |
57 | tmp->y = op->y; |
57 | tmp->y = op->y; |
58 | tmp->map = op->map; |
58 | tmp->map = op->map; |
59 | tmp->level = op->level; |
59 | tmp->level = op->level; |
60 | insert_ob_in_map (tmp, op->map, op, 0); |
60 | insert_ob_in_map (tmp, op->map, op, 0); |
… | |
… | |
79 | } |
79 | } |
80 | } |
80 | } |
81 | |
81 | |
82 | if (op->other_arch) |
82 | if (op->other_arch) |
83 | { |
83 | { |
84 | tmp = arch_to_object (op->other_arch); |
84 | tmp = op->other_arch->instance (); |
85 | tmp->x = op->x; |
85 | tmp->x = op->x; |
86 | tmp->y = op->y; |
86 | tmp->y = op->y; |
87 | tmp->map = op->map; |
87 | tmp->map = op->map; |
88 | tmp->level = op->level; |
88 | tmp->level = op->level; |
89 | insert_ob_in_map (tmp, op->map, op, 0); |
89 | insert_ob_in_map (tmp, op->map, op, 0); |
… | |
… | |
135 | // ...or use other_arch |
135 | // ...or use other_arch |
136 | dir = find_free_spot (gen->other_arch, gen->map, gen->x, gen->y, 1, SIZEOFFREE1 + 1); |
136 | dir = find_free_spot (gen->other_arch, gen->map, gen->x, gen->y, 1, SIZEOFFREE1 + 1); |
137 | if (dir < 0) |
137 | if (dir < 0) |
138 | return; |
138 | return; |
139 | |
139 | |
140 | op = arch_to_object (gen->other_arch); |
140 | op = gen->other_arch->instance (); |
141 | } |
141 | } |
142 | else |
142 | else |
143 | return; |
143 | return; |
144 | |
144 | |
145 | op->expand_tail (); |
145 | op->expand_tail (); |
… | |
… | |
827 | } |
827 | } |
828 | |
828 | |
829 | static void |
829 | static void |
830 | change_object (object *op) |
830 | change_object (object *op) |
831 | { /* Doesn`t handle linked objs yet */ |
831 | { /* Doesn`t handle linked objs yet */ |
832 | int i, j; |
|
|
833 | |
|
|
834 | if (!op->other_arch) |
832 | if (!op->other_arch) |
835 | { |
833 | { |
836 | LOG (llevError, "Change object (%s) without other_arch error.\n", op->debug_desc ()); |
834 | LOG (llevError, "Change object (%s) without other_arch error.\n", op->debug_desc ()); |
837 | return; |
835 | return; |
838 | } |
836 | } |
… | |
… | |
847 | } |
845 | } |
848 | |
846 | |
849 | object *env = op->env; |
847 | object *env = op->env; |
850 | |
848 | |
851 | op->remove (); |
849 | op->remove (); |
852 | for (i = 0; i < op->stats.food; i++) |
850 | for (int i = 0; i < op->stats.food; i++) |
853 | { |
851 | { |
854 | object *tmp = arch_to_object (op->other_arch); |
852 | object *tmp = op->other_arch->instance (); |
855 | |
853 | |
856 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
854 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
857 | |
855 | |
858 | if (env) |
856 | if (env) |
859 | env->insert (tmp); |
857 | env->insert (tmp); |
860 | else |
858 | else |
861 | { |
859 | { |
862 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
860 | int j = find_first_free_spot (tmp, op->map, op->x, op->y); |
|
|
861 | |
863 | if (j < 0) /* No free spot */ |
862 | if (j < 0) /* No free spot */ |
864 | tmp->destroy (); |
863 | tmp->destroy (); |
865 | else |
864 | else |
866 | { |
865 | { |
867 | mapxy pos (op); pos.move (j); |
866 | mapxy pos (op); pos.move (j); |
… | |
… | |
1079 | } |
1078 | } |
1080 | else |
1079 | else |
1081 | return; |
1080 | return; |
1082 | } |
1081 | } |
1083 | else |
1082 | else |
1084 | move_object (victim, dir); |
1083 | victim->move (dir); |
1085 | |
1084 | |
1086 | if (!op->stats.maxsp && op->attacktype) |
1085 | if (!op->stats.maxsp && op->attacktype) |
1087 | op->stats.maxsp = 2; |
1086 | op->stats.maxsp = 2; |
1088 | |
1087 | |
1089 | if (op->attacktype) |
1088 | if (op->attacktype) |