… | |
… | |
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); |
90 | } |
90 | } |
91 | |
91 | |
92 | op->drop_and_destroy (); |
92 | op->drop_and_destroy (); |
93 | } |
93 | } |
94 | |
94 | |
95 | void |
95 | static void |
96 | generate_monster (object *gen) |
96 | generate_monster (object *gen) |
97 | { |
97 | { |
98 | if (!gen->map) |
98 | if (!gen->map) |
99 | return; |
99 | return; |
100 | |
100 | |
… | |
… | |
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 (); |
… | |
… | |
158 | } |
158 | } |
159 | |
159 | |
160 | op->destroy (); |
160 | op->destroy (); |
161 | } |
161 | } |
162 | |
162 | |
163 | void |
163 | static void |
164 | remove_force (object *op) |
164 | remove_force (object *op) |
165 | { |
165 | { |
166 | if (--op->duration > 0) |
166 | if (--op->duration > 0) |
167 | return; |
167 | return; |
168 | |
168 | |
… | |
… | |
180 | } |
180 | } |
181 | |
181 | |
182 | op->destroy (); |
182 | op->destroy (); |
183 | } |
183 | } |
184 | |
184 | |
185 | void |
185 | static void |
186 | remove_blindness (object *op) |
186 | remove_blindness (object *op) |
187 | { |
187 | { |
188 | if (--op->stats.food > 0) |
188 | if (--op->stats.food > 0) |
189 | return; |
189 | return; |
190 | |
190 | |
… | |
… | |
197 | } |
197 | } |
198 | |
198 | |
199 | op->destroy (); |
199 | op->destroy (); |
200 | } |
200 | } |
201 | |
201 | |
202 | void |
202 | static void |
203 | poison_more (object *op) |
203 | poison_more (object *op) |
204 | { |
204 | { |
205 | if (op->env == NULL || !QUERY_FLAG (op->env, FLAG_ALIVE) || op->env->stats.hp < 0) |
205 | if (op->env == NULL || !QUERY_FLAG (op->env, FLAG_ALIVE) || op->env->stats.hp < 0) |
206 | { |
206 | { |
207 | op->destroy (); |
207 | op->destroy (); |
… | |
… | |
232 | |
232 | |
233 | hit_player (op->env, op->stats.dam, op, AT_INTERNAL, 1); |
233 | hit_player (op->env, op->stats.dam, op, AT_INTERNAL, 1); |
234 | } |
234 | } |
235 | |
235 | |
236 | |
236 | |
237 | void |
237 | static void |
238 | move_gate (object *op) |
238 | move_gate (object *op) |
239 | { /* 1 = going down, 0 = going up */ |
239 | { /* 1 = going down, 0 = going up */ |
240 | object *tmp; |
240 | object *tmp; |
241 | |
241 | |
242 | if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op)) |
242 | if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op)) |
… | |
… | |
249 | if (op->value) |
249 | if (op->value) |
250 | { |
250 | { |
251 | if (--op->stats.wc <= 0) |
251 | if (--op->stats.wc <= 0) |
252 | { /* Reached bottom, let's stop */ |
252 | { /* Reached bottom, let's stop */ |
253 | op->stats.wc = 0; |
253 | op->stats.wc = 0; |
254 | if (op->arch->speed) |
254 | if (op->arch->has_active_speed ()) |
255 | op->value = 0; |
255 | op->value = 0; |
256 | else |
256 | else |
257 | op->set_speed (0); |
257 | op->set_speed (0); |
258 | } |
258 | } |
259 | |
259 | |
… | |
… | |
285 | if (!QUERY_FLAG (tmp, FLAG_NO_PICK) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || QUERY_FLAG (tmp, FLAG_ALIVE)) |
285 | if (!QUERY_FLAG (tmp, FLAG_NO_PICK) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || QUERY_FLAG (tmp, FLAG_ALIVE)) |
286 | break; |
286 | break; |
287 | |
287 | |
288 | if (!tmp) |
288 | if (!tmp) |
289 | { |
289 | { |
290 | if (op->arch->speed) |
290 | if (op->arch->has_active_speed ()) |
291 | op->value = 1; |
291 | op->value = 1; |
292 | else |
292 | else |
293 | op->set_speed (0); |
293 | op->set_speed (0); |
294 | |
294 | |
295 | return; |
295 | return; |
… | |
… | |
376 | |
376 | |
377 | /* hp : how long door is open/closed |
377 | /* hp : how long door is open/closed |
378 | * maxhp : initial value for hp |
378 | * maxhp : initial value for hp |
379 | * sp : 1 = open, 0 = close |
379 | * sp : 1 = open, 0 = close |
380 | */ |
380 | */ |
381 | void |
381 | static void |
382 | move_timed_gate (object *op) |
382 | move_timed_gate (object *op) |
383 | { |
383 | { |
384 | int v = op->value; |
384 | int v = op->value; |
385 | |
385 | |
386 | if (op->stats.sp) |
386 | if (op->stats.sp) |
… | |
… | |
405 | * speed: frequency of 'glances' |
405 | * speed: frequency of 'glances' |
406 | * connected: connected value of detector |
406 | * connected: connected value of detector |
407 | * sp: 1 if detection sets buttons |
407 | * sp: 1 if detection sets buttons |
408 | * -1 if detection unsets buttons |
408 | * -1 if detection unsets buttons |
409 | */ |
409 | */ |
410 | |
410 | static void |
411 | void |
|
|
412 | move_detector (object *op) |
411 | move_detector (object *op) |
413 | { |
412 | { |
414 | object *tmp; |
413 | object *tmp; |
415 | int last = op->value; |
414 | int last = op->value; |
416 | int detected; |
415 | int detected; |
… | |
… | |
483 | SET_ANIMATION (op, op->stats.wc); |
482 | SET_ANIMATION (op, op->stats.wc); |
484 | update_object (op, UP_OBJ_FACE); |
483 | update_object (op, UP_OBJ_FACE); |
485 | } |
484 | } |
486 | } |
485 | } |
487 | |
486 | |
488 | void |
487 | static void |
489 | move_hole (object *op) |
488 | move_hole (object *op) |
490 | { /* 1 = opening, 0 = closing */ |
489 | { /* 1 = opening, 0 = closing */ |
491 | if (op->value) |
490 | if (op->value) |
492 | { /* We're opening */ |
491 | { /* We're opening */ |
493 | if (--op->stats.wc <= 0) |
492 | if (--op->stats.wc <= 0) |
… | |
… | |
828 | } |
827 | } |
829 | |
828 | |
830 | static void |
829 | static void |
831 | change_object (object *op) |
830 | change_object (object *op) |
832 | { /* Doesn`t handle linked objs yet */ |
831 | { /* Doesn`t handle linked objs yet */ |
833 | int i, j; |
|
|
834 | |
|
|
835 | if (!op->other_arch) |
832 | if (!op->other_arch) |
836 | { |
833 | { |
837 | 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 ()); |
838 | return; |
835 | return; |
839 | } |
836 | } |
… | |
… | |
848 | } |
845 | } |
849 | |
846 | |
850 | object *env = op->env; |
847 | object *env = op->env; |
851 | |
848 | |
852 | op->remove (); |
849 | op->remove (); |
853 | for (i = 0; i < op->stats.food; i++) |
850 | for (int i = 0; i < op->stats.food; i++) |
854 | { |
851 | { |
855 | object *tmp = arch_to_object (op->other_arch); |
852 | object *tmp = op->other_arch->instance (); |
856 | |
853 | |
857 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
854 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
858 | |
855 | |
859 | if (env) |
856 | if (env) |
860 | env->insert (tmp); |
857 | env->insert (tmp); |
861 | else |
858 | else |
862 | { |
859 | { |
863 | 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 | |
864 | if (j < 0) /* No free spot */ |
862 | if (j < 0) /* No free spot */ |
865 | tmp->destroy (); |
863 | tmp->destroy (); |
866 | else |
864 | else |
867 | { |
865 | { |
868 | mapxy pos (op); pos.move (j); |
866 | mapxy pos (op); pos.move (j); |
… | |
… | |
942 | /* This object will teleport someone to a different map |
940 | /* This object will teleport someone to a different map |
943 | and will also apply changes to the player from its inventory. |
941 | and will also apply changes to the player from its inventory. |
944 | This was invented for giving classes, but there's no reason it |
942 | This was invented for giving classes, but there's no reason it |
945 | can't be generalized. |
943 | can't be generalized. |
946 | */ |
944 | */ |
947 | void |
945 | static void |
948 | move_player_changer (object *op) |
946 | move_player_changer (object *op) |
949 | { |
947 | { |
950 | object *player; |
|
|
951 | object *walk; |
|
|
952 | |
|
|
953 | if (!op->above || !EXIT_PATH (op)) |
948 | if (!op->above || !EXIT_PATH (op)) |
954 | return; |
949 | return; |
955 | |
950 | |
956 | /* This isn't all that great - means that the player_mover |
951 | /* This isn't all that great - means that the player_mover |
957 | * needs to be on top. |
952 | * needs to be on top. |
958 | */ |
953 | */ |
959 | if (op->above->type == PLAYER) |
954 | if (op->above->type == PLAYER) |
960 | { |
955 | { |
|
|
956 | object *player = op->above; |
|
|
957 | |
961 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (player))) |
958 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (player))) |
962 | return; |
959 | return; |
963 | |
960 | |
964 | player = op->above; |
|
|
965 | |
|
|
966 | for (walk = op->inv; walk; walk = walk->below) |
961 | for (object *walk = op->inv; walk; walk = walk->below) |
967 | apply_changes_to_player (player, walk); |
962 | apply_changes_to_player (player, walk); |
968 | |
963 | |
969 | player->update_stats (); |
964 | player->update_stats (); |
970 | |
965 | |
971 | esrv_send_inventory (op->above, op->above); |
966 | esrv_send_inventory (op->above, op->above); |
… | |
… | |
1018 | * moves them in the op->stats.sp direction. speed is how often it'll move. |
1013 | * moves them in the op->stats.sp direction. speed is how often it'll move. |
1019 | * If attacktype is nonzero it will paralyze the player. If lifesave is set, |
1014 | * If attacktype is nonzero it will paralyze the player. If lifesave is set, |
1020 | * it'll dissapear after hp+1 moves. If hp is set and attacktype is set, |
1015 | * it'll dissapear after hp+1 moves. If hp is set and attacktype is set, |
1021 | * it'll paralyze the victim for hp*his speed/op->speed |
1016 | * it'll paralyze the victim for hp*his speed/op->speed |
1022 | */ |
1017 | */ |
1023 | void |
1018 | static void |
1024 | move_player_mover (object *op) |
1019 | move_player_mover (object *op) |
1025 | { |
1020 | { |
1026 | int dir = op->stats.sp; |
1021 | int dir = op->stats.sp; |
1027 | sint16 nx, ny; |
1022 | sint16 nx, ny; |
1028 | maptile *m; |
1023 | maptile *m; |
… | |
… | |
1083 | } |
1078 | } |
1084 | else |
1079 | else |
1085 | return; |
1080 | return; |
1086 | } |
1081 | } |
1087 | else |
1082 | else |
1088 | move_object (victim, dir); |
1083 | victim->move (dir); |
1089 | |
1084 | |
1090 | if (!op->stats.maxsp && op->attacktype) |
1085 | if (!op->stats.maxsp && op->attacktype) |
1091 | op->stats.maxsp = 2; |
1086 | op->stats.maxsp = 2; |
1092 | |
1087 | |
1093 | if (op->attacktype) |
1088 | if (op->attacktype) |
1094 | { /* flag to paralyze the player */ |
1089 | { /* flag to paralyze the player */ |
1095 | victim->speed_left = max (-5.f, -FABS (op->stats.maxsp * victim->speed / op->speed)); |
1090 | victim->speed_left = max (-5.f, -op->stats.maxsp * victim->speed / op->speed); |
1096 | } |
1091 | } |
1097 | } |
1092 | } |
1098 | } |
1093 | } |
1099 | } |
1094 | } |
1100 | |
1095 | |
… | |
… | |
1254 | } |
1249 | } |
1255 | } |
1250 | } |
1256 | |
1251 | |
1257 | // mapscript objects activate themselves (only) then their timer fires |
1252 | // mapscript objects activate themselves (only) then their timer fires |
1258 | // TODO: maybe they should simply trigger the link like any other object? |
1253 | // TODO: maybe they should simply trigger the link like any other object? |
1259 | void |
1254 | static void |
1260 | move_mapscript (object *op) |
1255 | move_mapscript (object *op) |
1261 | { |
1256 | { |
1262 | op->set_speed (0); |
1257 | op->set_speed (0); |
1263 | cfperl_mapscript_activate (op, true, op, 0); |
1258 | cfperl_mapscript_activate (op, true, op, 0); |
1264 | } |
1259 | } |
1265 | |
1260 | |
|
|
1261 | static void |
1266 | void move_lamp (object *op) |
1262 | move_lamp (object *op) |
1267 | { |
1263 | { |
1268 | // if the lamp/torch is off, we should disable it. |
1264 | // if the lamp/torch is off, we should disable it. |
1269 | if (!op->glow_radius) |
1265 | if (!op->glow_radius) |
1270 | { |
1266 | { |
1271 | op->set_speed (0); |
1267 | op->set_speed (0); |