minor behavior fixes

This commit is contained in:
incredibleLeitman 2020-01-28 23:22:01 +01:00
parent 7e090ccd7b
commit 12a2821574
2 changed files with 13 additions and 9 deletions

View File

@ -100,6 +100,7 @@ func _process(_delta):
if _audioPlayer.stream != null:
var cur_time = OS.get_ticks_msec()
if cur_time - _lastSound > CMD_DIFF_MS:
#Logger.info("playing last command again")
_audioPlayer.play()
_lastSound = cur_time
_countCmds += 1
@ -152,7 +153,7 @@ func _set_behavior ():
reason = "player outside during worktime"
#elif _playerRef.IsInFactory and daytime < Daytime.WORK_TIME and daytime > Daytime.SLEEP_TIME: # at work after out of WORK_TIME
# EDIT: too early at work is not an angry reason :p
elif _playerRef.IsInFactory and daytime > Daytime.SLEEP_TIME: # at work after out of WORK_TIME
elif _playerRef.IsInFactory and daytime > Daytime.SLEEP_TIME + Daytime.TIGGER_TIME: # at work after out of WORK_TIME
reason = "player in factory out of worktime"
Logger.info("daytime: " + String(daytime) + " SLEEP_TIME: " + String(Daytime.SLEEP_TIME))
elif _countCmds > MAX_CMDS: # after MAX_CMDS repeats of the same command
@ -163,17 +164,19 @@ func _set_behavior ():
Logger.info("catch player! reason: " + reason)
_huntingPlayer = true
_playerRef.IsHunted = true
change_visibility_cone_color(Color.red)
if _followingPlayer == false:
# If the player didn't take enough pills lately, they're suspicious -> following
if Pills.get_round_level() <= _player_follow_pill_level:
Logger.info("The player's pill level is too low - following!")
_followingPlayer = true
change_visibility_cone_color(Color.yellow)
if _huntingPlayer or _followingPlayer:
current_target = _playerRef.transform.origin
if _huntingPlayer:
change_visibility_cone_color(Color.red)
if _followingPlayer:
change_visibility_cone_color(Color.yellow)
else:
change_visibility_cone_color(Color.green)
@ -181,11 +184,8 @@ func _set_behavior ():
var daytime = Daytime.get_time()
if _playerRef.IsHunted:
mood = BEHAVIOR.ANGRY
# do your job
elif _playerRef.is_in_workzone():
mood = BEHAVIOR.DO_JOB
# take your pills
elif Pills.get_level() < Pills.get_max()*0.5:
elif Pills.get_level() < _player_follow_pill_level:
mood = BEHAVIOR.TAKE_PILLS
# go to work
elif daytime < Daytime.WORK_TIME:
@ -193,6 +193,10 @@ func _set_behavior ():
# go home
elif daytime > Daytime.SLEEP_TIME:
mood = BEHAVIOR.GO_HOME
# do your job
elif _playerRef.is_in_workzone():
_countCmds = 0 # hard block -> work is always good :D
mood = BEHAVIOR.DO_JOB
if mood != _curMood:
Logger.info("new mood: " + BEHAVIOR.keys()[mood] + " with cntcmd: " + String(_countCmds))
@ -206,7 +210,6 @@ func _on_body_entered_visibility (body: PhysicsBody):
if body.is_in_group("Player"):
Logger.info("Seeing player!")
_seeingPlayer = true
#_set_behavior()
func _on_body_exited_visibility(body: PhysicsBody):
@ -215,6 +218,7 @@ func _on_body_exited_visibility(body: PhysicsBody):
_seeingPlayer = false
_countCmds = 0
if _huntingPlayer == false and _followingPlayer == false:
change_visibility_cone_color(Color.green)
# dirty quickfix: TODO: refactor
if current_target != _start_pos:
current_target = null

View File

@ -8,7 +8,7 @@ const TIGGER_TIME = _max * 0.2
var _time: float = 0 setget _set_time, get_time
var _prev_time: float = _time
var increase_per_second: float = 25.0
var increase_per_second: float = 5.0
signal respawn
signal go_to_work