From 344cf5649fdb8231abf8242c898f929ac0e8ae71 Mon Sep 17 00:00:00 2001 From: Techwizz Date: Sun, 19 Mar 2023 01:56:03 -0600 Subject: [PATCH] AI now has health and can die --- objects/Bullet/Bullet.gd | 2 +- scenes/mainmenu.tscn | 3 +-- scripts/AI.gd | 8 ++++++++ scripts/global.gd | 1 + scripts/maps/islands.gd | 1 - scripts/maps/toyland.gd | 1 - 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/objects/Bullet/Bullet.gd b/objects/Bullet/Bullet.gd index 4ddbdc2..75e16c4 100644 --- a/objects/Bullet/Bullet.gd +++ b/objects/Bullet/Bullet.gd @@ -30,7 +30,7 @@ func _physics_process(delta): self.queue_free() elif body.is_in_group("AI"): print("Bullet hit an AI player") - body.queue_free() + Global.AIHit = true self.queue_free() else: print("Bullet hit something else") diff --git a/scenes/mainmenu.tscn b/scenes/mainmenu.tscn index 03fe598..14be7c7 100644 --- a/scenes/mainmenu.tscn +++ b/scenes/mainmenu.tscn @@ -31,7 +31,6 @@ offset_left = 245.0 offset_top = 577.0 offset_right = 436.0 offset_bottom = 640.0 -tooltip_text = "Coming soon" text = "TUTORIAL" [node name="playButton" type="Button" parent="."] @@ -123,7 +122,7 @@ offset_left = 4.0 offset_top = 622.0 offset_right = 94.0 offset_bottom = 648.0 -text = "Version: PLAYTEST 20230318" +text = "Version: ALPHA" [node name="OurTimeIsNowSolo" type="Sprite2D" parent="."] position = Vector2(123, 104) diff --git a/scripts/AI.gd b/scripts/AI.gd index 8ba1ca5..018dbf0 100644 --- a/scripts/AI.gd +++ b/scripts/AI.gd @@ -3,6 +3,7 @@ extends CharacterBody3D const SPEED = 3.0 const JUMP_VELOCITY = 4.5 +var health = 100 var bullettimer = 50 var bulletshot = false @@ -31,6 +32,13 @@ func _physics_process(delta): if $CollisionShape3D/Neck/Teddy/AnimationPlayer.is_playing() == false and not Global.tutorialComplete: $CollisionShape3D/Neck/Teddy/AnimationPlayer.play("idle") 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(): var animation = $CollisionShape3D/Neck/Teddy/AnimationPlayer.get_current_animation() if animation == "idle": diff --git a/scripts/global.gd b/scripts/global.gd index 73d1353..59e99cd 100644 --- a/scripts/global.gd +++ b/scripts/global.gd @@ -43,6 +43,7 @@ var spawnCoords_z: Array[float] = [] # Used locally in spawn_locations() functio var spawnCoordsInitalized = false # Used locally var volumeModifer = 1 # Modifies volume level var tutorialComplete = false # Used only for tutorial +var AIHit = false # Used so the AI knows to take damage func _process(delta): #if not spawnCoordsInitalized: diff --git a/scripts/maps/islands.gd b/scripts/maps/islands.gd index 5f9fd8d..21d140a 100644 --- a/scripts/maps/islands.gd +++ b/scripts/maps/islands.gd @@ -46,7 +46,6 @@ func _process(delta): else: print("This shouldn't ever be called, toyland.gd") Global.musicUpdated = true - print("hehe") func play_music(music): diff --git a/scripts/maps/toyland.gd b/scripts/maps/toyland.gd index 537cfbf..2a0c913 100644 --- a/scripts/maps/toyland.gd +++ b/scripts/maps/toyland.gd @@ -46,7 +46,6 @@ func _process(delta): else: print("This shouldn't ever be called, toyland.gd") Global.musicUpdated = true - print("hehe") func play_music(music):