feat: spawn enemies from reusable definitions
This commit is contained in:
@@ -1,9 +1,20 @@
|
||||
class_name EnemyDefinition
|
||||
extends Resource
|
||||
|
||||
const BEHAVIOR_PROFILE_RAID_ASSAULT := &"raid_assault"
|
||||
const BEHAVIOR_PROFILE_WOLF_HUNT := &"wolf_hunt"
|
||||
const VALID_BEHAVIOR_PROFILE_IDS := [
|
||||
BEHAVIOR_PROFILE_RAID_ASSAULT,
|
||||
BEHAVIOR_PROFILE_WOLF_HUNT,
|
||||
]
|
||||
|
||||
@export var enemy_id: StringName
|
||||
@export var display_name: String
|
||||
@export var kind: StringName = SimulationIds.COMBATANT_KIND_RAIDER
|
||||
@export var behavior_profile_id: StringName = BEHAVIOR_PROFILE_RAID_ASSAULT
|
||||
@export var combatant_id_prefix := "enemy"
|
||||
@export var faction_id: StringName = SimulationIds.FACTION_TRIBE
|
||||
@export var hostile := true
|
||||
@export var weapon_id: StringName = SimulationIds.ITEM_SWORD
|
||||
@export var health := 60.0
|
||||
@export var move_speed := 3.5
|
||||
@@ -18,6 +29,18 @@ func validate() -> Array[String]:
|
||||
errors.append("enemy_id is empty")
|
||||
if display_name.is_empty():
|
||||
errors.append("display_name is empty for '%s'" % enemy_id)
|
||||
if behavior_profile_id not in VALID_BEHAVIOR_PROFILE_IDS:
|
||||
errors.append(
|
||||
"behavior_profile_id '%s' is invalid for '%s'" % [behavior_profile_id, enemy_id]
|
||||
)
|
||||
if combatant_id_prefix.is_empty():
|
||||
errors.append("combatant_id_prefix is empty for '%s'" % enemy_id)
|
||||
elif not combatant_id_prefix.is_valid_identifier():
|
||||
errors.append(
|
||||
"combatant_id_prefix '%s' is invalid for '%s'" % [combatant_id_prefix, enemy_id]
|
||||
)
|
||||
if faction_id.is_empty():
|
||||
errors.append("faction_id is empty for '%s'" % enemy_id)
|
||||
if (
|
||||
kind
|
||||
not in [
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
[gd_resource type="Resource" script_class="EnemyDefinition" load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://simulation/definitions/EnemyDefinition.gd" id="1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
enemy_id = &"enemy_boar"
|
||||
display_name = "Wild Boar"
|
||||
kind = &"wolf"
|
||||
behavior_profile_id = &"wolf_hunt"
|
||||
combatant_id_prefix = "boar"
|
||||
faction_id = &"faction_tribe"
|
||||
hostile = true
|
||||
weapon_id = &"item_claw"
|
||||
health = 55.0
|
||||
move_speed = 3.6
|
||||
body_color = Color(0.28, 0.16, 0.08, 1)
|
||||
accent_color = Color(0.78, 0.68, 0.5, 1)
|
||||
visual_scale = Vector3(1.05, 0.9, 1.15)
|
||||
@@ -7,6 +7,10 @@ script = ExtResource("1")
|
||||
enemy_id = &"enemy_raider"
|
||||
display_name = "Raider"
|
||||
kind = &"raider"
|
||||
behavior_profile_id = &"raid_assault"
|
||||
combatant_id_prefix = "raider"
|
||||
faction_id = &"faction_tribe"
|
||||
hostile = true
|
||||
weapon_id = &"item_sword"
|
||||
health = 60.0
|
||||
move_speed = 3.5
|
||||
|
||||
@@ -7,6 +7,10 @@ script = ExtResource("1")
|
||||
enemy_id = &"enemy_wolf"
|
||||
display_name = "Wolf"
|
||||
kind = &"wolf"
|
||||
behavior_profile_id = &"wolf_hunt"
|
||||
combatant_id_prefix = "wolf"
|
||||
faction_id = &"faction_tribe"
|
||||
hostile = true
|
||||
weapon_id = &"item_claw"
|
||||
health = 40.0
|
||||
move_speed = 4.2
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_resource type="Resource" script_class="SimulationContentPack" load_steps=27 format=3]
|
||||
[gd_resource type="Resource" script_class="SimulationContentPack" load_steps=28 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://simulation/definitions/SimulationContentPack.gd" id="1_pack"]
|
||||
[ext_resource type="Resource" path="res://simulation/definitions/actions/defend.tres" id="2_defend"]
|
||||
@@ -25,6 +25,7 @@
|
||||
[ext_resource type="Resource" path="res://simulation/definitions/items/wood.tres" id="23_wood"]
|
||||
[ext_resource type="Resource" path="res://simulation/definitions/enemies/raider.tres" id="24_raider"]
|
||||
[ext_resource type="Resource" path="res://simulation/definitions/enemies/wolf.tres" id="25_wolf"]
|
||||
[ext_resource type="Resource" path="res://simulation/definitions/enemies/boar.tres" id="26_boar"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_pack")
|
||||
@@ -33,4 +34,4 @@ display_name = "The Steward Core"
|
||||
actions = [ExtResource("2_defend"), ExtResource("3_deposit_food"), ExtResource("4_deposit_wood"), ExtResource("5_eat"), ExtResource("6_feed_animal"), ExtResource("7_gather_food"), ExtResource("8_gather_wood"), ExtResource("9_patrol"), ExtResource("10_rest"), ExtResource("11_sleep"), ExtResource("12_study"), ExtResource("13_wander"), ExtResource("14_withdraw_food")]
|
||||
professions = [ExtResource("15_farmer"), ExtResource("16_guard"), ExtResource("17_scholar"), ExtResource("18_wanderer"), ExtResource("19_woodcutter")]
|
||||
items = [ExtResource("20_claw"), ExtResource("21_food"), ExtResource("22_sword"), ExtResource("23_wood")]
|
||||
enemies = [ExtResource("24_raider"), ExtResource("25_wolf")]
|
||||
enemies = [ExtResource("24_raider"), ExtResource("25_wolf"), ExtResource("26_boar")]
|
||||
|
||||
Reference in New Issue
Block a user