Files
draugnorak/src/player.nvgt
T

93 lines
3.0 KiB
Plaintext

// Player state
int x = 0;
int y = 0;
int facing = 1; // 0: left, 1: right
bool jumping = false;
bool climbing = false;
bool falling = false;
int climb_target_y = 0; // Target height when climbing
int fall_start_y = 0; // Height where fall started
int fall_sound_handle = -1; // Handle for looping fall sound
timer fall_timer; // For fall sound pitch
timer climb_timer; // For climb speed
// Rope climbing state
bool rope_climbing = false;
bool rope_climb_up = true;
int rope_climb_target_x = 0;
int rope_climb_target_y = 0;
int rope_climb_start_y = 0;
int rope_climb_sound_handle = -1;
timer rope_climb_timer;
int pending_rope_climb_x = -1;
int pending_rope_climb_elevation = 0;
// Health System
int player_health = 10;
int base_max_health = 10;
int max_health = 10;
timer fire_damage_timer;
timer healing_timer;
// Sling state
bool sling_charging = false;
timer sling_charge_timer;
int sling_sound_handle = -1;
int last_sling_stage = -1; // Track which stage we're in to avoid duplicate sounds
// Fishing state
bool is_casting = false; // Holding control, cast_strength playing
bool line_in_water = false; // Cast successful, waiting for fish
bool fish_on_line = false; // Fish caught, reeling phase
bool is_reeling = false; // Holding control during reel
int cast_position = -1; // Current position of cast cursor
int reel_position = -1; // Position of fish during reel
int cast_origin_x = -1; // Player position when casting started
int cast_direction = 0; // 1 = moving toward stream, -1 = moving back
int reel_direction = 0; // 1 = moving toward player, -1 = moving past
int reel_start_direction = 0; // Initial reel direction toward player
int target_stream_start = -1; // Start of target stream for casting
int target_stream_end = -1; // End of target stream for casting
timer fishing_timer; // Tracks time line has been in water
timer cast_move_timer; // Controls discrete position movement (150ms per tile)
int catch_chance = 0; // Current catch percentage (starts 0, +15% per minute, max 85%)
int cast_sound_handle = -1; // Handle for cast_strength.ogg
string hooked_fish_type = ""; // Type of fish on the line
// Favor system
double favor = 0.0;
int incense_hours_remaining = 0;
bool incense_burning = false;
bool blessing_speed_active = false;
timer blessing_speed_timer;
// Timers
timer walktimer;
timer jumptimer;
timer search_timer;
timer search_delay_timer;
timer attack_timer;
// Search state
bool searching = false;
// Adventure state
int last_adventure_day = -1;
// Pause state
bool game_paused = false;
// Restart all game timers when resuming from pause
// Prevents time from accumulating while paused
void restart_all_timers() {
// Player timers
fire_damage_timer.restart();
healing_timer.restart();
sling_charge_timer.restart();
// Fire fuel timers
for (uint i = 0; i < world_fires.length(); i++) {
world_fires[i].fuel_timer.restart();
}
}