… | |
… | |
502 | move_apply (op, tmp, tmp); |
502 | move_apply (op, tmp, tmp); |
503 | } |
503 | } |
504 | } |
504 | } |
505 | |
505 | |
506 | SET_ANIMATION (op, op->stats.wc); |
506 | SET_ANIMATION (op, op->stats.wc); |
507 | update_object (op, UP_OBJ_FACE); |
507 | update_object (op, UP_OBJ_CHANGE); |
508 | return; |
508 | return; |
509 | } |
509 | } |
510 | |
510 | |
511 | /* We're closing */ |
511 | /* We're closing */ |
512 | op->move_on = 0; |
512 | op->move_on = 0; |
513 | |
513 | |
514 | op->stats.wc++; |
514 | op->stats.wc++; |
515 | if ((int) op->stats.wc >= NUM_ANIMATIONS (op)) |
515 | if (op->stats.wc >= NUM_ANIMATIONS (op)) |
516 | op->stats.wc = NUM_ANIMATIONS (op) - 1; |
516 | op->stats.wc = NUM_ANIMATIONS (op) - 1; |
517 | |
517 | |
518 | SET_ANIMATION (op, op->stats.wc); |
518 | SET_ANIMATION (op, op->stats.wc); |
519 | update_object (op, UP_OBJ_FACE); |
519 | update_object (op, UP_OBJ_CHANGE); |
520 | if ((unsigned char) op->stats.wc == (NUM_ANIMATIONS (op) - 1)) |
520 | if (op->stats.wc == (NUM_ANIMATIONS (op) - 1)) |
521 | op->set_speed (0); /* closed, let's stop */ |
521 | op->set_speed (0); /* closed, let's stop */ |
522 | } |
522 | } |
523 | |
523 | |
524 | |
524 | |
525 | /* stop_item() returns a pointer to the stopped object. The stopped object |
525 | /* stop_item() returns a pointer to the stopped object. The stopped object |
… | |
… | |
1004 | } |
1004 | } |
1005 | |
1005 | |
1006 | cast_spell (op, op, op->stats.sp ? op->stats.sp : rndm (1, 8), spell, NULL); |
1006 | cast_spell (op, op, op->stats.sp ? op->stats.sp : rndm (1, 8), spell, NULL); |
1007 | } |
1007 | } |
1008 | |
1008 | |
1009 | /* move_player_mover: this function takes a "player mover" as an |
1009 | /* move_player_mover: this function takes a "player mover" as an |
1010 | * argument, and performs the function of a player mover, which is: |
1010 | * argument, and performs the function of a player mover, which is: |
1011 | * |
1011 | * |
1012 | * a player mover finds any players that are sitting on it. It |
1012 | * a player mover finds any players that are sitting on it. It |
1013 | * 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. |
1014 | * 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, |
… | |
… | |
1016 | * it'll paralyze the victim for hp*his speed/op->speed |
1016 | * it'll paralyze the victim for hp*his speed/op->speed |
1017 | */ |
1017 | */ |
1018 | static void |
1018 | static void |
1019 | move_player_mover (object *op) |
1019 | move_player_mover (object *op) |
1020 | { |
1020 | { |
1021 | int dir = op->stats.sp; |
1021 | int dir = 0; |
1022 | sint16 nx, ny; |
|
|
1023 | maptile *m; |
|
|
1024 | |
|
|
1025 | /* Determine direction now for random movers so we do the right thing */ |
|
|
1026 | if (!dir) |
|
|
1027 | dir = rndm (1, 8); |
|
|
1028 | |
1022 | |
1029 | for (object *victim = op->ms ().bot; victim; victim = victim->above) |
1023 | for (object *victim = op->ms ().bot; victim; victim = victim->above) |
1030 | { |
1024 | { |
1031 | if (victim->flag [FLAG_ALIVE] && !victim->flag [FLAG_WIZPASS] && |
1025 | if (victim->flag [FLAG_ALIVE] |
|
|
1026 | && !victim->flag [FLAG_WIZPASS] |
1032 | (victim->move_type & op->move_type || !victim->move_type)) |
1027 | && (victim->move_type & op->move_type || !victim->move_type)) |
|
|
1028 | { |
|
|
1029 | if (op->flag [FLAG_LIFESAVE] && op->stats.hp-- < 0) |
1033 | { |
1030 | { |
|
|
1031 | op->destroy (); |
|
|
1032 | return; |
|
|
1033 | } |
|
|
1034 | |
|
|
1035 | /* Determine direction only once so we do the right thing */ |
|
|
1036 | // why is it the right thing, though? |
|
|
1037 | if (!dir) |
|
|
1038 | dir = op->stats.sp ? op->stats.sp : rndm (1, 8); |
|
|
1039 | |
|
|
1040 | sint16 nx = op->x + freearr_x[dir]; |
|
|
1041 | sint16 ny = op->y + freearr_y[dir]; |
|
|
1042 | maptile *m = op->map; |
|
|
1043 | if (get_map_flags (m, &m, nx, ny, &nx, &ny) & P_OUT_OF_MAP) |
|
|
1044 | { |
|
|
1045 | LOG (llevError, "move_player_mover: Trying to push player off the map! map=%s (%d, %d)\n", &m->path, op->x, op->y); |
|
|
1046 | return; |
|
|
1047 | } |
1034 | |
1048 | |
1035 | if (victim->head) |
1049 | if (victim->head) |
1036 | victim = victim->head; |
1050 | victim = victim->head; |
1037 | |
|
|
1038 | if (op->flag [FLAG_LIFESAVE] && op->stats.hp-- < 0) |
|
|
1039 | { |
|
|
1040 | op->remove (); |
|
|
1041 | return; |
|
|
1042 | } |
|
|
1043 | |
|
|
1044 | nx = op->x + freearr_x[dir]; |
|
|
1045 | ny = op->y + freearr_y[dir]; |
|
|
1046 | m = op->map; |
|
|
1047 | if (get_map_flags (m, &m, nx, ny, &nx, &ny) & P_OUT_OF_MAP) |
|
|
1048 | { |
|
|
1049 | LOG (llevError, "move_player_mover: Trying to push player off the map! map=%s (%d, %d)\n", &m->path, op->x, op->y); |
|
|
1050 | return; |
|
|
1051 | } |
|
|
1052 | |
1051 | |
1053 | if (should_director_abort (op, victim)) |
1052 | if (should_director_abort (op, victim)) |
1054 | return; |
1053 | return; |
1055 | |
1054 | |
1056 | for (object *nextmover = m->at (nx, ny).bot; nextmover; nextmover = nextmover->above) |
1055 | for (object *nextmover = m->at (nx, ny).bot; nextmover; nextmover = nextmover->above) |