Skip to content

Commit

Permalink
Merge pull request #32 from dysonreturns/feature/newcomer-improvements
Browse files Browse the repository at this point in the history
Feature/newcomer improvements
  • Loading branch information
dysonreturns committed Apr 9, 2024
2 parents d16a1c2 + e7e5618 commit 0f7a509
Show file tree
Hide file tree
Showing 16 changed files with 427 additions and 72 deletions.
12 changes: 6 additions & 6 deletions bin/generate_meta_data
Original file line number Diff line number Diff line change
Expand Up @@ -632,27 +632,27 @@ code_ability = <<~CODEGEN
# },
# }
# }
def upgrade_research_abilities_data = #{upgrade_research_abilities_friendly.pretty_inspect.gsub('"', "")}
def upgrade_research_abilities_data = #{upgrade_research_abilities_friendly.pretty_inspect.gsub('"', "")}.freeze
# unit_created_from_data = {
# UnitTypeId.ADEPT: [UnitTypeId.GATEWAY, UnitTypeId.WARPGATE],
# UnitTypeId.ARMORY: [UnitTypeId.SCV],
# UnitTypeId.ASSIMILATOR: [UnitTypeId.PROBE],
# }
def unit_created_from_data = #{unit_created_from_friendly.pretty_inspect.gsub('"', "")}
def unit_created_from_data = #{unit_created_from_friendly.pretty_inspect.gsub('"', "")}.freeze
# unit_created_from_data = {
# UpgradeId.ADEPTPIERCINGATTACK: UnitTypeId.TWILIGHTCOUNCIL,
# UpgradeId.ANABOLICSYNTHESIS: UnitTypeId.ULTRALISKCAVERN,
# UpgradeId.BANSHEECLOAK: UnitTypeId.STARPORTTECHLAB,
# }
def upgrade_researched_from_data = #{upgrade_researched_from_friendly.pretty_inspect.gsub('"', "")}
def upgrade_researched_from_data = #{upgrade_researched_from_friendly.pretty_inspect.gsub('"', "")}.freeze
def unit_abilities_data = #{unit_abilities_friendly.pretty_inspect.gsub('"', "")}
def unit_abilities_data = #{unit_abilities_friendly.pretty_inspect.gsub('"', "")}.freeze
def unit_alias_data = #{unit_alias_friendly.pretty_inspect.gsub('"', "")}
def unit_alias_data = #{unit_alias_friendly.pretty_inspect.gsub('"', "")}.freeze
def unit_tech_alias_data = #{unit_tech_alias_friendly.pretty_inspect.gsub('"', "")}
def unit_tech_alias_data = #{unit_tech_alias_friendly.pretty_inspect.gsub('"', "")}.freeze
end
end
Expand Down
2 changes: 1 addition & 1 deletion data/data.json

Large diffs are not rendered by default.

59 changes: 31 additions & 28 deletions data/data_readable.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
"allow_autocast": false,
"allow_minimap": false,
"buff": [],
"cast_range": 9.0,
"cast_range": 10.0,
"cooldown": 0,
"effect": [],
"energy_cost": 0,
Expand Down Expand Up @@ -11239,7 +11239,7 @@
"Mechanical",
"Structure"
],
"gas": 100,
"gas": 50,
"id": 29,
"is_addon": false,
"is_flying": false,
Expand Down Expand Up @@ -12239,7 +12239,7 @@
"cooldown": 1.5,
"damage_per_hit": 5.0,
"damage_splash": 0,
"range": 0.10009765625,
"range": 0.199951171875,
"target_type": "Ground"
}
]
Expand Down Expand Up @@ -13188,7 +13188,7 @@
"power_radius": 6.5,
"race": "Protoss",
"radius": 1.125,
"sight": 9.0,
"sight": 10.0,
"size": 0,
"speed_creep_mul": 1.0,
"supply": -8.0,
Expand Down Expand Up @@ -14293,7 +14293,6 @@
"accepts_addon": false,
"armor": 1.0,
"attributes": [
"Light",
"Mechanical",
"Psionic"
],
Expand Down Expand Up @@ -14615,7 +14614,7 @@
"is_townhall": false,
"is_worker": false,
"max_health": 40.0,
"max_shield": 20.0,
"max_shield": 30.0,
"minerals": 25,
"name": "Observer",
"needs_creep": false,
Expand All @@ -14629,7 +14628,7 @@
"speed_creep_mul": 1.0,
"supply": 1.0,
"tech_alias": [],
"time": 480.0,
"time": 400.0,
"unit_alias": 0,
"weapons": []
},
Expand Down Expand Up @@ -14872,7 +14871,7 @@
"cooldown": 1.5,
"damage_per_hit": 5.0,
"damage_splash": 0,
"range": 0.10009765625,
"range": 0.199951171875,
"target_type": "Ground"
}
]
Expand Down Expand Up @@ -15006,7 +15005,14 @@
"weapons": []
},
{
"abilities": [],
"abilities": [
{
"ability": 1733
},
{
"ability": 1
}
],
"accepts_addon": false,
"armor": 0.0,
"attributes": [
Expand Down Expand Up @@ -16127,7 +16133,7 @@
"cooldown": 1.5,
"damage_per_hit": 5.0,
"damage_splash": 0,
"range": 0.10009765625,
"range": 0.199951171875,
"target_type": "Ground"
}
]
Expand Down Expand Up @@ -17301,7 +17307,7 @@
"normal_mode": 111,
"race": "Zerg",
"radius": 0.625,
"sight": 10.0,
"sight": 8.0,
"size": 0,
"speed": 2.0,
"speed_creep_mul": 1.0,
Expand Down Expand Up @@ -20011,7 +20017,7 @@
"is_structure": false,
"is_townhall": false,
"is_worker": false,
"max_health": 110.0,
"max_health": 130.0,
"minerals": 125,
"name": "Cyclone",
"needs_creep": false,
Expand All @@ -20036,7 +20042,7 @@
"damage": 3.0
}
],
"cooldown": 0.673828125,
"cooldown": 0.81201171875,
"damage_per_hit": 11.0,
"damage_splash": 0,
"range": 6.0,
Expand Down Expand Up @@ -21422,13 +21428,13 @@
"radius": 1.0,
"sight": 11.0,
"size": 0,
"speed": 0.78515625,
"speed": 0.9140625,
"speed_creep_mul": 1.0,
"supply": -8.0,
"tech_alias": [
106
],
"time": 266.6796875,
"time": 336.015625,
"unit_alias": 0,
"weapons": []
},
Expand Down Expand Up @@ -21458,7 +21464,7 @@
"power_radius": 6.5,
"race": "Protoss",
"radius": 1.125,
"sight": 9.0,
"sight": 10.0,
"size": 0,
"speed_creep_mul": 1.0,
"supply": -8.0,
Expand Down Expand Up @@ -21519,9 +21525,6 @@
},
{
"abilities": [
{
"ability": 4
},
{
"ability": 4111
},
Expand Down Expand Up @@ -21587,7 +21590,7 @@
"is_townhall": false,
"is_worker": false,
"max_health": 40.0,
"max_shield": 20.0,
"max_shield": 30.0,
"minerals": 25,
"name": "ObserverSiegeMode",
"needs_creep": false,
Expand Down Expand Up @@ -21900,17 +21903,17 @@
},
{
"cost": {
"gas": 175,
"minerals": 175,
"gas": 150,
"minerals": 150,
"time": 3040.0
},
"id": 8,
"name": "TerranInfantryWeaponsLevel2"
},
{
"cost": {
"gas": 250,
"minerals": 250,
"gas": 200,
"minerals": 200,
"time": 3520.0
},
"id": 9,
Expand All @@ -21936,17 +21939,17 @@
},
{
"cost": {
"gas": 175,
"minerals": 175,
"gas": 150,
"minerals": 150,
"time": 3040.0
},
"id": 12,
"name": "TerranInfantryArmorsLevel2"
},
{
"cost": {
"gas": 250,
"minerals": 250,
"gas": 200,
"minerals": 200,
"time": 3520.0
},
"id": 13,
Expand Down
2 changes: 1 addition & 1 deletion lib/sc2ai/api/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Data
# @return [Hash<Integer, Api::UnitTypeData>] UnitId => UnitTypeData
attr_accessor :units
# @!attribute upgrades
# @return [Hash<Integer, Api::UnitTypeData>] UnitTypeId => UnitTypeData
# @return [Hash<Integer, Api::UpgradeData>] UpgradeId => UpgradeData
attr_accessor :upgrades
# @!attribute buffs
# Not particularly useful data. Just use BuffId directly
Expand Down
22 changes: 22 additions & 0 deletions lib/sc2ai/api/tech_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ def unit_created_from(unit_type_id:)
def upgrade_researched_from(upgrade_id:)
upgrade_researched_from_data[upgrade_id]
end

# Returns the ability which researches this upgrade
# @return [Integer] ability_id
def upgrade_research_ability_id(upgrade_id:)
source_unit_type_id = upgrade_researched_from(upgrade_id:)
upgrade_research_abilities_data[source_unit_type_id][upgrade_id][:ability]
end

# Returns a full list of structure unit id's which perform upgrades
# This is a useful list when checking if any updates are in progress,
# because we scan these structure types for orders
# @return [Array<Integer>] unit type ids
def upgrade_structure_unit_type_ids
@upgrade_structure_unit_type_ids ||= upgrade_research_abilities_data.keys
end

# Returns hash of upgrade info for a specific structure where the upgrade id is the key
# @param source_unit_type_id [Integer] source structure unit type id
# @return [Hash<Integer, Hash>] ability_id
def upgrade_ability_data(source_unit_type_id)
upgrade_research_abilities_data[source_unit_type_id]
end
end
end
end
29 changes: 20 additions & 9 deletions lib/sc2ai/api/tech_tree_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ def unit_type_creation_abilities_data = {Api::UnitTypeId::COMMANDCENTER =>
Api::UnitTypeId::QUEEN =>
{ability: Api::AbilityId::TRAINQUEEN_QUEEN,
required_building: Api::UnitTypeId::SPAWNINGPOOL}},
Api::UnitTypeId::CREEPTUMOR =>
{Api::UnitTypeId::CREEPTUMOR =>
{ability: Api::AbilityId::BUILD_CREEPTUMOR_TUMOR,
requires_placement_position: true}},
Api::UnitTypeId::SPIRE =>
{Api::UnitTypeId::GREATERSPIRE =>
{ability: Api::AbilityId::UPGRADETOGREATERSPIRE_GREATERSPIRE,
Expand Down Expand Up @@ -759,6 +763,7 @@ def upgrade_research_abilities_data = {Api::UnitTypeId::ENGINEERINGBAY =>
Api::UpgradeId::LURKERRANGE =>
{ability: Api::AbilityId::LURKERDENRESEARCH_RESEARCHLURKERRANGE,
required_building: Api::UnitTypeId::HIVE}}}
.freeze

# unit_created_from_data = {
# UnitTypeId.ADEPT: [UnitTypeId.GATEWAY, UnitTypeId.WARPGATE],
Expand Down Expand Up @@ -845,6 +850,11 @@ def unit_created_from_data = {Api::UnitTypeId::SCV =>
[Api::UnitTypeId::HATCHERY,
Api::UnitTypeId::LAIR,
Api::UnitTypeId::HIVE],
Api::UnitTypeId::CREEPTUMOR =>
[Api::UnitTypeId::CREEPTUMOR,
Api::UnitTypeId::QUEEN,
Api::UnitTypeId::CREEPTUMORBURROWED,
Api::UnitTypeId::CREEPTUMORQUEEN],
Api::UnitTypeId::GREATERSPIRE => [Api::UnitTypeId::SPIRE],
Api::UnitTypeId::NYDUSCANAL => [Api::UnitTypeId::NYDUSNETWORK],
Api::UnitTypeId::HIVE => [Api::UnitTypeId::LAIR],
Expand All @@ -869,10 +879,6 @@ def unit_created_from_data = {Api::UnitTypeId::SCV =>
Api::UnitTypeId::RAVAGER => [Api::UnitTypeId::ROACH],
Api::UnitTypeId::BROODLORD => [Api::UnitTypeId::CORRUPTOR],
Api::UnitTypeId::CREEPTUMORQUEEN => [Api::UnitTypeId::QUEEN],
Api::UnitTypeId::CREEPTUMOR =>
[Api::UnitTypeId::QUEEN,
Api::UnitTypeId::CREEPTUMORBURROWED,
Api::UnitTypeId::CREEPTUMORQUEEN],
Api::UnitTypeId::CHANGELING =>
[Api::UnitTypeId::OVERSEER, Api::UnitTypeId::OVERSEERSIEGEMODE],
Api::UnitTypeId::DRONE => [Api::UnitTypeId::LARVA],
Expand All @@ -889,8 +895,9 @@ def unit_created_from_data = {Api::UnitTypeId::SCV =>
Api::UnitTypeId::LOCUSTMPFLYING =>
[Api::UnitTypeId::SWARMHOSTBURROWEDMP, Api::UnitTypeId::SWARMHOSTMP],
Api::UnitTypeId::ORACLESTASISTRAP => [Api::UnitTypeId::ORACLE]}
.freeze

# upgrade_researched_from_data = {
# unit_created_from_data = {
# UpgradeId.ADEPTPIERCINGATTACK: UnitTypeId.TWILIGHTCOUNCIL,
# UpgradeId.ANABOLICSYNTHESIS: UnitTypeId.ULTRALISKCAVERN,
# UpgradeId.BANSHEECLOAK: UnitTypeId.STARPORTTECHLAB,
Expand Down Expand Up @@ -993,6 +1000,7 @@ def upgrade_researched_from_data = {Api::UpgradeId::HISECAUTOTRACKING => Api::Un
Api::UpgradeId::TUNNELINGCLAWS => Api::UnitTypeId::ROACHWARREN,
Api::UpgradeId::DIGGINGCLAWS => Api::UnitTypeId::LURKERDENMP,
Api::UpgradeId::LURKERRANGE => Api::UnitTypeId::LURKERDENMP}
.freeze

def unit_abilities_data = {Api::UnitTypeId::COLOSSUS =>
[Api::AbilityId::STOP_STOP,
Expand Down Expand Up @@ -1038,7 +1046,7 @@ def unit_abilities_data = {Api::UnitTypeId::COLOSSUS =>
Api::AbilityId::ATTACK_ATTACK,
Api::AbilityId::EFFECT_MASSRECALL_STRATEGICRECALL,
Api::AbilityId::EFFECT_TIMEWARP,
Api::AbilityId._250MMSTRIKECANNONS_CANCEL,
Api::AbilityId._250MMSTRIKECANNONS_250MMSTRIKECANNONS,
Api::AbilityId::SMART],
Api::UnitTypeId::POINTDEFENSEDRONE => [],
Api::UnitTypeId::CHANGELING =>
Expand Down Expand Up @@ -1578,7 +1586,8 @@ def unit_abilities_data = {Api::UnitTypeId::COLOSSUS =>
Api::AbilityId::SMART,
Api::AbilityId::UPGRADETOLAIR_LAIR,
Api::AbilityId::TRAINQUEEN_QUEEN],
Api::UnitTypeId::CREEPTUMOR => [],
Api::UnitTypeId::CREEPTUMOR =>
[Api::AbilityId::BUILD_CREEPTUMOR_TUMOR, Api::AbilityId::SMART],
Api::UnitTypeId::EXTRACTOR => [],
Api::UnitTypeId::SPAWNINGPOOL =>
[Api::AbilityId::RESEARCH_ZERGLINGMETABOLICBOOST,
Expand Down Expand Up @@ -2242,8 +2251,7 @@ def unit_abilities_data = {Api::UnitTypeId::COLOSSUS =>
Api::AbilityId::ATTACK_ATTACK,
Api::AbilityId::SMART],
Api::UnitTypeId::SHIELDBATTERY =>
[Api::AbilityId::STOP_STOP,
Api::AbilityId::SHIELDBATTERYRECHARGEEX5_SHIELDBATTERYRECHARGE,
[Api::AbilityId::SHIELDBATTERYRECHARGEEX5_SHIELDBATTERYRECHARGE,
Api::AbilityId::SMART],
Api::UnitTypeId::OBSERVERSIEGEMODE =>
[Api::AbilityId::STOP_STOP, Api::AbilityId::MORPH_OBSERVERMODE],
Expand All @@ -2261,6 +2269,7 @@ def unit_abilities_data = {Api::UnitTypeId::COLOSSUS =>
Api::UnitTypeId::REFINERYRICH => [],
Api::UnitTypeId::ASSIMILATORRICH => [],
Api::UnitTypeId::EXTRACTORRICH => []}
.freeze

def unit_alias_data = {Api::UnitTypeId::CHANGELINGZEALOT => Api::UnitTypeId::CHANGELING,
Api::UnitTypeId::CHANGELINGMARINESHIELD => Api::UnitTypeId::CHANGELING,
Expand Down Expand Up @@ -2302,6 +2311,7 @@ def unit_alias_data = {Api::UnitTypeId::CHANGELINGZEALOT => Api::UnitTypeId::CHA
Api::UnitTypeId::PYLONOVERCHARGED => Api::UnitTypeId::PYLON,
Api::UnitTypeId::OBSERVERSIEGEMODE => Api::UnitTypeId::OBSERVER,
Api::UnitTypeId::OVERSEERSIEGEMODE => Api::UnitTypeId::OVERSEER}
.freeze

def unit_tech_alias_data = {Api::UnitTypeId::SIEGETANKSIEGED => [Api::UnitTypeId::SIEGETANK],
Api::UnitTypeId::VIKINGASSAULT => [Api::UnitTypeId::VIKING],
Expand Down Expand Up @@ -2337,6 +2347,7 @@ def unit_tech_alias_data = {Api::UnitTypeId::SIEGETANKSIEGED => [Api::UnitTypeId
Api::UnitTypeId::PYLONOVERCHARGED =>
[Api::UnitTypeId::PYLON, Api::UnitTypeId::PYLON],
Api::UnitTypeId::OVERSEERSIEGEMODE => [Api::UnitTypeId::OVERLORD]}
.freeze
end
end
end

0 comments on commit 0f7a509

Please sign in to comment.