AI now has health and can die

This commit is contained in:
Paul Black 2023-03-19 01:56:03 -06:00
parent 880a0304c3
commit 344cf5649f
6 changed files with 11 additions and 5 deletions

View file

@ -30,7 +30,7 @@ func _physics_process(delta):
self.queue_free() self.queue_free()
elif body.is_in_group("AI"): elif body.is_in_group("AI"):
print("Bullet hit an AI player") print("Bullet hit an AI player")
body.queue_free() Global.AIHit = true
self.queue_free() self.queue_free()
else: else:
print("Bullet hit something else") print("Bullet hit something else")

View file

@ -31,7 +31,6 @@ offset_left = 245.0
offset_top = 577.0 offset_top = 577.0
offset_right = 436.0 offset_right = 436.0
offset_bottom = 640.0 offset_bottom = 640.0
tooltip_text = "Coming soon"
text = "TUTORIAL" text = "TUTORIAL"
[node name="playButton" type="Button" parent="."] [node name="playButton" type="Button" parent="."]
@ -123,7 +122,7 @@ offset_left = 4.0
offset_top = 622.0 offset_top = 622.0
offset_right = 94.0 offset_right = 94.0
offset_bottom = 648.0 offset_bottom = 648.0
text = "Version: PLAYTEST 20230318" text = "Version: ALPHA"
[node name="OurTimeIsNowSolo" type="Sprite2D" parent="."] [node name="OurTimeIsNowSolo" type="Sprite2D" parent="."]
position = Vector2(123, 104) position = Vector2(123, 104)

View file

@ -3,6 +3,7 @@ extends CharacterBody3D
const SPEED = 3.0 const SPEED = 3.0
const JUMP_VELOCITY = 4.5 const JUMP_VELOCITY = 4.5
var health = 100
var bullettimer = 50 var bullettimer = 50
var bulletshot = false var bulletshot = false
@ -31,6 +32,13 @@ func _physics_process(delta):
if $CollisionShape3D/Neck/Teddy/AnimationPlayer.is_playing() == false and not Global.tutorialComplete: if $CollisionShape3D/Neck/Teddy/AnimationPlayer.is_playing() == false and not Global.tutorialComplete:
$CollisionShape3D/Neck/Teddy/AnimationPlayer.play("idle") $CollisionShape3D/Neck/Teddy/AnimationPlayer.play("idle")
if player and Global.playerAlive and Global.tutorialComplete: if player and Global.playerAlive and Global.tutorialComplete:
if Global.AIHit == true:
Global.AIHit = false
var damage = RandomNumberGenerator.new().randi_range(7, 16)
health -= damage
print(health)
if health <= 0:
self.queue_free()
if $CollisionShape3D/Neck/Teddy/AnimationPlayer.is_playing(): if $CollisionShape3D/Neck/Teddy/AnimationPlayer.is_playing():
var animation = $CollisionShape3D/Neck/Teddy/AnimationPlayer.get_current_animation() var animation = $CollisionShape3D/Neck/Teddy/AnimationPlayer.get_current_animation()
if animation == "idle": if animation == "idle":

View file

@ -43,6 +43,7 @@ var spawnCoords_z: Array[float] = [] # Used locally in spawn_locations() functio
var spawnCoordsInitalized = false # Used locally var spawnCoordsInitalized = false # Used locally
var volumeModifer = 1 # Modifies volume level var volumeModifer = 1 # Modifies volume level
var tutorialComplete = false # Used only for tutorial var tutorialComplete = false # Used only for tutorial
var AIHit = false # Used so the AI knows to take damage
func _process(delta): func _process(delta):
#if not spawnCoordsInitalized: #if not spawnCoordsInitalized:

View file

@ -46,7 +46,6 @@ func _process(delta):
else: else:
print("This shouldn't ever be called, toyland.gd") print("This shouldn't ever be called, toyland.gd")
Global.musicUpdated = true Global.musicUpdated = true
print("hehe")
func play_music(music): func play_music(music):

View file

@ -46,7 +46,6 @@ func _process(delta):
else: else:
print("This shouldn't ever be called, toyland.gd") print("This shouldn't ever be called, toyland.gd")
Global.musicUpdated = true Global.musicUpdated = true
print("hehe")
func play_music(music): func play_music(music):