Files
Five-Nights-At-Akers/Scripts/Characters/cCharacter.gd
2026-03-24 12:56:35 -07:00

78 lines
1.5 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
class_name cCharacter
extends Node
const Map = preload("res://Scripts/Levels/lsOffice.gd")
# --- Parameters ---
@export_range(0, 20) var ai_level := 10
@export var min_interval := 8
@export var max_interval := 12
@export var reset_after_climax := true
# --- Constants ---
const MAX_STATE := 6
const DEBUG := true
# --- Runtime ---
var state: int = 0
var current_location: int = Global.LocationID.POWER_STATION
var move_timer := 0.0
var stunted: bool = false
func get_room_presence(room_id):
if current_location != room_id:
return -1
return state
func _ready() -> void:
randomize()
_set_next_interval()
# Pick the next random movement interval (35 sec)
func _set_next_interval() -> void:
move_timer = randf_range(min_interval, max_interval)
# Rolls to see if the character may move
func try_move(delta: float) -> bool:
move_timer -= delta
if move_timer > 0.0:
return false
# Interval completed → immediately pick the next one
_set_next_interval()
# Roll 120 like OG FNAF
var roll := randi_range(1, 20)
if DEBUG:
print(name, " | AI:", ai_level, " | Roll:", roll)
return roll <= ai_level
func advance_state() -> void:
if state >= MAX_STATE:
if reset_after_climax:
state = 0
else:
state += 1
func _process(delta: float) -> void:
if try_move(delta):
if(stunted):
stunted = false
return
advance_state()
if (randi_range(1, 20) > 10):
stunted = true
match state:
0: pass # dormant
1: pass
2: pass
3: pass
4: pass
5: pass
6: pass