44 lines
1.5 KiB
GDScript
44 lines
1.5 KiB
GDScript
## freeftf
|
|
## Copyright (C) 2024 Patrick_Pluto
|
|
##
|
|
## This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
##
|
|
## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
##
|
|
## You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
extends StaticBody3D
|
|
|
|
var trapped_body
|
|
var occupied = false
|
|
var living = true
|
|
|
|
func _process(_delta):
|
|
if occupied and trapped_body.hp == 0 and living:
|
|
Game.died()
|
|
living = false
|
|
$dead.show()
|
|
$Sprite3D.hide()
|
|
elif occupied:
|
|
trapped_body.position = global_position
|
|
$Sprite3D.show()
|
|
|
|
func _on_area_3d_body_entered(body):
|
|
if body is CharacterBody3D:
|
|
if body.beast and body.got_person and !occupied:
|
|
trapped_body = body.caught_body
|
|
occupied = true
|
|
living = true
|
|
body.lost_one()
|
|
trapped_body.frozen()
|
|
Game.freeze()
|
|
elif !body.beast and occupied and living and body != trapped_body:
|
|
trapped_body.unfreeze()
|
|
Game.unfreeze()
|
|
occupied = false
|
|
trapped_body.position = $spawn.global_position
|
|
trapped_body = null
|
|
|
|
func _on_timer_timeout():
|
|
if occupied and living:
|
|
trapped_body.hp -= 2
|