… | |
… | |
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 | |
… | |
… | |
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) |
… | |
… | |
825 | |
824 | |
826 | /* Move the arrow. */ |
825 | /* Move the arrow. */ |
827 | op->move_to (pos); |
826 | op->move_to (pos); |
828 | } |
827 | } |
829 | |
828 | |
830 | 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; |
832 | int i, j; |
834 | |
833 | |
835 | if (!op->other_arch) |
834 | if (!op->other_arch) |
… | |
… | |
942 | /* This object will teleport someone to a different map |
941 | /* This object will teleport someone to a different map |
943 | and will also apply changes to the player from its inventory. |
942 | and will also apply changes to the player from its inventory. |
944 | This was invented for giving classes, but there's no reason it |
943 | This was invented for giving classes, but there's no reason it |
945 | can't be generalized. |
944 | can't be generalized. |
946 | */ |
945 | */ |
947 | void |
946 | static void |
948 | move_player_changer (object *op) |
947 | move_player_changer (object *op) |
949 | { |
948 | { |
950 | object *player; |
|
|
951 | object *walk; |
|
|
952 | |
|
|
953 | if (!op->above || !EXIT_PATH (op)) |
949 | if (!op->above || !EXIT_PATH (op)) |
954 | return; |
950 | return; |
955 | |
951 | |
956 | /* This isn't all that great - means that the player_mover |
952 | /* This isn't all that great - means that the player_mover |
957 | * needs to be on top. |
953 | * needs to be on top. |
958 | */ |
954 | */ |
959 | if (op->above->type == PLAYER) |
955 | if (op->above->type == PLAYER) |
960 | { |
956 | { |
|
|
957 | object *player = op->above; |
|
|
958 | |
961 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (player))) |
959 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (player))) |
962 | return; |
960 | return; |
963 | |
961 | |
964 | player = op->above; |
|
|
965 | |
|
|
966 | for (walk = op->inv; walk; walk = walk->below) |
962 | for (object *walk = op->inv; walk; walk = walk->below) |
967 | apply_changes_to_player (player, walk); |
963 | apply_changes_to_player (player, walk); |
968 | |
964 | |
969 | player->update_stats (); |
965 | player->update_stats (); |
970 | |
966 | |
971 | esrv_send_inventory (op->above, op->above); |
967 | esrv_send_inventory (op->above, op->above); |
… | |
… | |
1018 | * moves them in the op->stats.sp direction. speed is how often it'll move. |
1014 | * 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, |
1015 | * 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, |
1016 | * 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 |
1017 | * it'll paralyze the victim for hp*his speed/op->speed |
1022 | */ |
1018 | */ |
1023 | void |
1019 | static void |
1024 | move_player_mover (object *op) |
1020 | move_player_mover (object *op) |
1025 | { |
1021 | { |
1026 | int dir = op->stats.sp; |
1022 | int dir = op->stats.sp; |
1027 | sint16 nx, ny; |
1023 | sint16 nx, ny; |
1028 | maptile *m; |
1024 | maptile *m; |
… | |
… | |
1072 | /* only level >=1 movers move people */ |
1068 | /* only level >=1 movers move people */ |
1073 | if (op->level) |
1069 | if (op->level) |
1074 | { |
1070 | { |
1075 | /* Following is a bit of hack. We need to make sure it |
1071 | /* Following is a bit of hack. We need to make sure it |
1076 | * is cleared, otherwise the player will get stuck in |
1072 | * is cleared, otherwise the player will get stuck in |
1077 | * place. This can happen if the player used a spell to |
1073 | * place. This can happen if the player used a spell to |
1078 | * get to this space. |
1074 | * get to this space. |
1079 | */ |
1075 | */ |
1080 | victim->contr->fire_on = 0; |
1076 | victim->contr->fire_on = 0; |
1081 | victim->speed_left = 1.f; |
1077 | victim->speed_left = 1.f; |
1082 | move_player (victim, dir); |
1078 | move_player (victim, dir); |
… | |
… | |
1090 | if (!op->stats.maxsp && op->attacktype) |
1086 | if (!op->stats.maxsp && op->attacktype) |
1091 | op->stats.maxsp = 2; |
1087 | op->stats.maxsp = 2; |
1092 | |
1088 | |
1093 | if (op->attacktype) |
1089 | if (op->attacktype) |
1094 | { /* flag to paralyze the player */ |
1090 | { /* flag to paralyze the player */ |
1095 | victim->speed_left = max (-5.f, -FABS (op->stats.maxsp * victim->speed / op->speed)); |
1091 | victim->speed_left = max (-5.f, -fabs (op->stats.maxsp * victim->speed / op->speed)); |
1096 | } |
1092 | } |
1097 | } |
1093 | } |
1098 | } |
1094 | } |
1099 | } |
1095 | } |
1100 | |
1096 | |
… | |
… | |
1254 | } |
1250 | } |
1255 | } |
1251 | } |
1256 | |
1252 | |
1257 | // mapscript objects activate themselves (only) then their timer fires |
1253 | // mapscript objects activate themselves (only) then their timer fires |
1258 | // TODO: maybe they should simply trigger the link like any other object? |
1254 | // TODO: maybe they should simply trigger the link like any other object? |
1259 | void |
1255 | static void |
1260 | move_mapscript (object *op) |
1256 | move_mapscript (object *op) |
1261 | { |
1257 | { |
1262 | op->set_speed (0); |
1258 | op->set_speed (0); |
1263 | cfperl_mapscript_activate (op, true, op, 0); |
1259 | cfperl_mapscript_activate (op, true, op, 0); |
1264 | } |
1260 | } |
1265 | |
1261 | |
|
|
1262 | static void |
1266 | void move_lamp (object *op) |
1263 | move_lamp (object *op) |
1267 | { |
1264 | { |
1268 | // if the lamp/torch is off, we should disable it. |
1265 | // if the lamp/torch is off, we should disable it. |
1269 | if (!op->glow_radius) |
1266 | if (!op->glow_radius) |
1270 | { |
1267 | { |
1271 | op->set_speed (0); |
1268 | op->set_speed (0); |