/* Kitsune's Curse Copyright (C) 2020-2023 Juan J. Martinez This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "splib.h" #include "main.h" #include "maps.h" // generated #include "ninja.h" #include "entities.h" #include "et_ninja.h" #include "et_player.h" #include "et_effect.h" void draw_ninja() { if (*it_extra) return; put_sprite4(ninja[player_frames[*it_frame]], *it_x, *it_y, 3, *it_param); erase_sprite(*it_ox, *it_oy, 3); } uint8_t try_magic() { uint8_t target = *it_x; if (*it_x == TW * TMW - 8 - 2 || *it_x == 2) return 0; for (it_k = 0; it_k < 6; it_k++) { if (*it_param) target += 8; else target -= 8; if (is_map_blocked(target, *it_y + 8) || is_map_deadly(target, *it_y + 24) || target < 4 || target > TW * TMW - 8 - 4) break; if (is_map_blocked(target, *it_y + 24)) { erase_sprite(*it_ox, *it_oy, 3); new_explo_et(); *it_x = (target / TW) * TW; *it_extra = COOL_DOWN + 2; return 1; } } return 0; } void update_ninja() { if ((*it_delay)++ == 2) { *it_delay = 0; if (++(*it_frame) > WALK_CYCLE) *it_frame = WALK; } if (*it_extra) { --(*it_extra); if (*it_extra == 0) new_explo_et(); return; } if (*it_param) { if (is_map_blocked(*it_x + 8, *it_y + 8) || *it_x == TW * TMW - 8 - 2 || !is_map_blocked(*it_x + 8, *it_y + 24) || is_map_deadly(*it_x + 8, *it_y + 24)) { if (try_magic()) return; goto ninja_change_dir; } else *it_x += 1; } else { if (is_map_blocked(*it_x - 1, *it_y + 8) || *it_x == 2 || !is_map_blocked(*it_x - 1, *it_y + 24) || is_map_deadly(*it_x - 1, *it_y + 24)) { if (try_magic()) return; goto ninja_change_dir; } else *it_x -= 1; } if (*it_extra == 0 && check_for_player(24)) { player_hit(1); ninja_change_dir: *it_param ^= 128; *it_delay = 0; *it_frame = WALK; } }