Procházet zdrojové kódy

:sparkles: some rebalancing. infinite games should now be impossible

Felix Bytow před 10 měsíci
rodič
revize
5abf1fa46f
4 změnil soubory, kde provedl 50 přidání a 17 odebrání
  1. 16 6
      assets/scenes/bot.gd
  2. 1 1
      assets/scenes/bot.tscn
  3. 4 3
      assets/scenes/demon.gd
  4. 29 7
      screens/game.gd

+ 16 - 6
assets/scenes/bot.gd

@@ -9,6 +9,8 @@ const SKINS: Array[String] = ["blue", "green", "red", "yellow"]
 
 @export var speed: float = 64.0
 
+var health: int = 1
+
 func _ready() -> void:
 	base = get_tree().get_first_node_in_group("base")
 	if base != null:
@@ -26,13 +28,21 @@ func _physics_process(delta: float) -> void:
 	if base != null:
 		global_position = global_position.move_toward(get_base_center(), speed * delta)
 
-func die():
+func take_damage() -> void:
+	health -= 1
+	if health <= 0:
+		die()
+	else:
+		sprite.modulate = Color(0.0, 0.0, 0.0)
+		await get_tree().create_timer(0.05).timeout
+		sprite.modulate = Color(1.0, 1.0, 1.0)
+
+func _on_area_entered(area: Area2D) -> void:
+	if area.is_in_group("base"):
+		die()
+
+func die() -> void:
 	var explosion = explosion_scene.instantiate()
 	add_sibling(explosion)
 	explosion.global_position = global_position
 	queue_free()
-
-func _on_area_entered(area: Area2D):
-	if area.is_in_group("base"):
-		die()
-		

+ 1 - 1
assets/scenes/bot.tscn

@@ -69,7 +69,7 @@ script = ExtResource("1_juoa1")
 rotation = 1.5708
 scale = Vector2(0.18, 0.18)
 sprite_frames = SubResource("SpriteFrames_b0o1s")
-animation = &"red"
+animation = &"blue"
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
 position = Vector2(7, 0)

+ 4 - 3
assets/scenes/demon.gd

@@ -103,15 +103,16 @@ func shoot_at(foe: Area2D) -> void:
 		#print(speed_percent)
 		var base = Game.base_accuracy
 		var rest = (1.0 - base) / 2.0
-		var hit_chance: float = Game.base_accuracy + distance_percent * rest + speed_percent * rest
+		var hit_chance: float = base + distance_percent * rest + speed_percent * rest
+		print("%s: Base %.2f Speed %.2f Distance %.2f"% [name, base, speed_percent * rest, distance_percent * rest])
 		print("%s: Shooting at %s with %.2f hit chance" % [name, foe.name, hit_chance])
 		
 		var hit: float = randf()
 		if hit > hit_chance:
 			print("%s: missed shot (%.2f > %.2f)" % [name, hit, hit_chance])
 		else:
-			if foe.has_method("die"):
-				foe.die()
+			if foe.has_method("take_damage"):
+				await foe.take_damage()
 			else:
 				foe.queue_free()
 		

+ 29 - 7
screens/game.gd

@@ -80,6 +80,7 @@ func _ready() -> void:
 	Game.reload_time = RELOAD_TIME # seconds
 	Game.max_ammo = 1 # shots
 	Game.base_accuracy = 0.33 # percent
+	GlobalInput.dragging_disabled = false
 	waves_completed = 0
 	phase = Phase.PHASE_SETUP
 	overlay.visible = true
@@ -126,6 +127,7 @@ func spawn_bot(spawn: Marker2D, index: int) -> void:
 	bot.name = "Bot #%d" % (index + 1)
 	bot.speed += waves_completed
 	bot.visible = false
+	bot.health += waves_completed / 30
 	spawn.add_child(bot)
 	bot.position = Vector2.ZERO
 
@@ -201,10 +203,32 @@ func start_combat() -> void:
 
 const LOOT_SURVIVOR: String = "+1 SURVIVOR"
 const LOOT_HEALTH: String = "+3 HEALTH"
+const LOOT_FULL_HEALTH: String = "FULL HEALTH"
 const LOOT_AMMO: String = "BIGGER MAGAZINES"
 const LOOT_RELOAD_TIME: String = "FASTER RELOADING"
 const LOOT_ACCURACY: String = "HIGHER ACCURACY"
-const LOOTS: Array[String] = [LOOT_SURVIVOR, LOOT_HEALTH, LOOT_AMMO, LOOT_RELOAD_TIME, LOOT_ACCURACY]
+
+func determine_loot_options() -> Array[String]:
+	var loots: Array[String] = []
+	if get_survivors().size() < 6: # this is, so the player has a reason to move survivors even later
+		loots.push_back(LOOT_SURVIVOR)
+	if Game.base_accuracy < 0.67:
+		loots.push_back(LOOT_ACCURACY)
+	if Game.reload_time > 1.5:
+		loots.push_back(LOOT_RELOAD_TIME)
+	if Game.max_ammo < 9:
+		loots.push_back(LOOT_AMMO)
+	var health = health_bar.health
+	if health < HealthBar.MAX_HEALTH:
+		if health == 1:
+			loots.push_back(LOOT_FULL_HEALTH)
+		else:
+			loots.push_back(LOOT_HEALTH)
+	loots.shuffle()
+	if loots.size() < 3:
+		for n in (3-loots.size()):
+			loots.push_back("NOTHING")
+	return loots
 
 func end_combat() -> void:
 	phase = Phase.PHASE_LOOT
@@ -212,11 +236,7 @@ func end_combat() -> void:
 	await get_tree().create_timer(1.5).timeout
 	var vs: Victory = victory_scene.instantiate()
 	ui_root.add_child(vs)
-	var loots: Array[String] = []
-	loots.assign(LOOTS)
-	if get_survivors().size() >= 6: # this is, so the player has a reason to move survivors even later
-		loots.erase(LOOT_SURVIVOR)
-	loots.shuffle()
+	var loots: Array[String] = determine_loot_options()
 	vs.set_loot_options(loots[0], loots[1], loots[2])
 	await vs.loot_selected
 	var loot: String = loots[vs.selection]
@@ -231,12 +251,14 @@ func end_combat() -> void:
 				self.player_spawn.add_survivor()
 			LOOT_HEALTH:
 				self.health_bar.health += 3
+			LOOT_FULL_HEALTH:
+				self.health_bar.health = HealthBar.MAX_HEALTH
 			LOOT_RELOAD_TIME:
 				Game.reload_time *= 0.9
 			LOOT_AMMO:
 				Game.max_ammo += 1
 			LOOT_ACCURACY:
-				Game.base_accuracy += 0.1
+				Game.base_accuracy += 0.01
 		self.reset_survivors()
 		self.start_setup()
 	)