Merge branch 'master' of https://gitlab.hexaquo.at/mga/retrace
This commit is contained in:
commit
2d167726b3
@ -1,7 +1,6 @@
|
|||||||
extends NPC
|
extends NPC
|
||||||
|
|
||||||
|
|
||||||
#export(NodePath) var _visibility_path: NodePath
|
|
||||||
export(int) var _player_follow_pill_level = 3
|
export(int) var _player_follow_pill_level = 3
|
||||||
|
|
||||||
onready var visibility_cone_mesh = get_node("Visibility/VisibilityCone")
|
onready var visibility_cone_mesh = get_node("Visibility/VisibilityCone")
|
||||||
@ -33,12 +32,19 @@ var _interactArea: Area
|
|||||||
var _audioPlayer: AudioStreamPlayer3D
|
var _audioPlayer: AudioStreamPlayer3D
|
||||||
var _playerRef
|
var _playerRef
|
||||||
|
|
||||||
|
onready var _start_pos = transform.origin
|
||||||
|
onready var _start_rot: Vector3 = rotation_degrees
|
||||||
|
|
||||||
var _followingPlayer = false # true if Meldewesen finds player "suspicios" and follows
|
var _followingPlayer = false # true if Meldewesen finds player "suspicios" and follows
|
||||||
var _huntingPlayer = false # active if the Meldewesen wants to "catch" the player
|
var _huntingPlayer = false # active if the Meldewesen wants to "catch" the player
|
||||||
var _seeingPlayer = false # as long as player is in visible range
|
var _seeingPlayer = false # as long as player is in visible range
|
||||||
var _lastSound = 0 # timestamp of last played message
|
var _lastSound = 0 # timestamp of last played message
|
||||||
var _countCmds = 0 # count of spoken commands -> after MAX_CMDS Meldewesen gets pissy
|
var _countCmds = 0 # count of spoken commands -> after MAX_CMDS Meldewesen gets pissy
|
||||||
|
|
||||||
|
|
||||||
|
# test only
|
||||||
|
var _prev_target = null
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
#Logger.set_logger_level(Logger.LOG_LEVEL_FINE)
|
#Logger.set_logger_level(Logger.LOG_LEVEL_FINE)
|
||||||
|
|
||||||
@ -68,18 +74,27 @@ func _ready():
|
|||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
# movement
|
# movement
|
||||||
if current_target:
|
if current_target:
|
||||||
|
if _prev_target != current_target:
|
||||||
|
Logger.info("current target: " + String(current_target))
|
||||||
|
_prev_target = current_target
|
||||||
|
|
||||||
# continue following player after illegal action or low pill level
|
# continue following player after illegal action or low pill level
|
||||||
if _huntingPlayer or (_followingPlayer and Pills.get_round_level() <= _player_follow_pill_level):
|
if _huntingPlayer or (_followingPlayer and Pills.get_round_level() <= _player_follow_pill_level):
|
||||||
current_target = _playerRef.transform.origin
|
current_target = _playerRef.transform.origin
|
||||||
# stop following player if pill level is high enough and player is not in an illegal area
|
# stop following player if pill level is high enough and player is not in an illegal area
|
||||||
else:
|
else:
|
||||||
Logger.info("player pill level ok and no illegal actions detected!")
|
if _followingPlayer:
|
||||||
_followingPlayer = false
|
Logger.info("player pill level ok and no illegal actions detected!")
|
||||||
current_target = null
|
_followingPlayer = false
|
||||||
|
current_target = _start_pos
|
||||||
|
elif current_target == _start_pos and transform.origin.distance_to(current_target) < 0.1:
|
||||||
|
Logger.info("the watch begins")
|
||||||
|
current_target = null
|
||||||
|
current_look_target = null
|
||||||
|
rotation_degrees = _start_rot
|
||||||
|
|
||||||
if _seeingPlayer:
|
if _seeingPlayer:
|
||||||
# logic
|
_set_behavior() # logic
|
||||||
_set_behavior()
|
|
||||||
|
|
||||||
# audio
|
# audio
|
||||||
if _audioPlayer.stream != null:
|
if _audioPlayer.stream != null:
|
||||||
@ -97,8 +112,9 @@ func _on_area_entered (area: Area):
|
|||||||
|
|
||||||
|
|
||||||
func change_visibility_cone_color(new_color: Color):
|
func change_visibility_cone_color(new_color: Color):
|
||||||
visibility_cone_mesh.get_surface_material(0).albedo_color = new_color
|
if visibility_cone_mesh.get_surface_material(0).albedo_color != new_color:
|
||||||
visibility_cone_mesh.get_surface_material(0).albedo_color.a = VISIBILITY_CONE_ALPHA
|
visibility_cone_mesh.get_surface_material(0).albedo_color = new_color
|
||||||
|
visibility_cone_mesh.get_surface_material(0).albedo_color.a = VISIBILITY_CONE_ALPHA
|
||||||
|
|
||||||
|
|
||||||
func _load_sound ():
|
func _load_sound ():
|
||||||
@ -189,8 +205,7 @@ func _on_body_entered_visibility (body: PhysicsBody):
|
|||||||
if body.is_in_group("Player"):
|
if body.is_in_group("Player"):
|
||||||
Logger.info("Seeing player!")
|
Logger.info("Seeing player!")
|
||||||
_seeingPlayer = true
|
_seeingPlayer = true
|
||||||
|
#_set_behavior()
|
||||||
_set_behavior()
|
|
||||||
|
|
||||||
|
|
||||||
func _on_body_exited_visibility(body: PhysicsBody):
|
func _on_body_exited_visibility(body: PhysicsBody):
|
||||||
@ -199,4 +214,6 @@ func _on_body_exited_visibility(body: PhysicsBody):
|
|||||||
_seeingPlayer = false
|
_seeingPlayer = false
|
||||||
_countCmds = 0
|
_countCmds = 0
|
||||||
if _huntingPlayer == false and _followingPlayer == false:
|
if _huntingPlayer == false and _followingPlayer == false:
|
||||||
current_target = null
|
# dirty quickfix: TODO: refactor
|
||||||
|
if current_target != _start_pos:
|
||||||
|
current_target = null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user