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

61 lines
1.2 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
# --- 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
@export var character_name := "template"
# --- Constants ---
const MAX_STATE := 6
const DEBUG := true
# --- Runtime ---
var current_room: int = -1
var move_timer := 0.0
var stunted: bool = false
func move_to(room_id: int):
if current_room != -1:
Global.rooms[current_room].remove_enemy(self)
current_room = room_id
Global.rooms[current_room].add_enemy(self)
func _init():
_ready()
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(character_name, " | AI:", ai_level, " | Roll:", roll)
return roll <= ai_level
func _process(delta: float) -> void:
if try_move(delta):
if(stunted):
stunted = false
return