From 7e2cb8f2b2a49f188380f051cf5fcd72ca94540d Mon Sep 17 00:00:00 2001 From: "Alexander.Iljin" Date: Tue, 14 May 2019 02:00:59 +0700 Subject: [PATCH 1/6] sc2api : Update Convert CloakState For some reason the game sets flag has_cloak and send CloakState as CloakedUnknown. Conversion routine did not take it into account and returned status failure. Now unit cloak state can have value CloakedUnknown and conversion routine returns success. --- include/sc2api/sc2_unit.h | 2 ++ src/sc2api/sc2_proto_to_pods.cc | 1 + 2 files changed, 3 insertions(+) diff --git a/include/sc2api/sc2_unit.h b/include/sc2api/sc2_unit.h index 8c6c31bc..006a8a66 100644 --- a/include/sc2api/sc2_unit.h +++ b/include/sc2api/sc2_unit.h @@ -93,6 +93,8 @@ class Unit { //! Unit cloak state. enum CloakState { + //! Under the fog, so unknown whether it's cloaked or not. + CloakedUnknown = 0, //! Cloaked, invisible to enemies until detected. Cloaked = 1, //! Cloaked enemy, but detected. diff --git a/src/sc2api/sc2_proto_to_pods.cc b/src/sc2api/sc2_proto_to_pods.cc index 8c8f7c9b..2aa9d065 100644 --- a/src/sc2api/sc2_proto_to_pods.cc +++ b/src/sc2api/sc2_proto_to_pods.cc @@ -149,6 +149,7 @@ bool Convert(const SC2APIProtocol::Alliance& alliance_proto, Unit::Alliance& all bool Convert(const SC2APIProtocol::CloakState& cloak_proto, Unit::CloakState& cloak) { switch (cloak_proto) { + case SC2APIProtocol::CloakState::CloakedUnknown: cloak = Unit::CloakedUnknown; return true; case SC2APIProtocol::CloakState::Cloaked: cloak = Unit::Cloaked; return true; case SC2APIProtocol::CloakState::CloakedDetected: cloak = Unit::CloakedDetected; return true; case SC2APIProtocol::CloakState::NotCloaked: cloak = Unit::NotCloaked; return true; From 0a79825bd1c6318debb56082b9142f4940b7d73c Mon Sep 17 00:00:00 2001 From: Peter Cudmore Date: Fri, 12 Jul 2019 16:45:55 +1000 Subject: [PATCH 2/6] Fixed issue #306. Cloak now works properly --- include/sc2api/sc2_unit.h | 4 ++-- src/sc2api/sc2_proto_to_pods.cc | 3 ++- tests/test_unit_command.cc | 5 +---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/sc2api/sc2_unit.h b/include/sc2api/sc2_unit.h index 006a8a66..a99b8f5a 100644 --- a/include/sc2api/sc2_unit.h +++ b/include/sc2api/sc2_unit.h @@ -101,8 +101,8 @@ class Unit { CloakedDetected = 2, //! No cloaking. NotCloaked = 3, - //! Could not determine cloaking state. - Unknown = 4 + //! Cloaked ally, though not sure why this is necessary. + CloakedAllied = 4 }; //! If the unit is shown on screen or not. diff --git a/src/sc2api/sc2_proto_to_pods.cc b/src/sc2api/sc2_proto_to_pods.cc index 2aa9d065..753dedce 100644 --- a/src/sc2api/sc2_proto_to_pods.cc +++ b/src/sc2api/sc2_proto_to_pods.cc @@ -153,6 +153,7 @@ bool Convert(const SC2APIProtocol::CloakState& cloak_proto, Unit::CloakState& cl case SC2APIProtocol::CloakState::Cloaked: cloak = Unit::Cloaked; return true; case SC2APIProtocol::CloakState::CloakedDetected: cloak = Unit::CloakedDetected; return true; case SC2APIProtocol::CloakState::NotCloaked: cloak = Unit::NotCloaked; return true; + case SC2APIProtocol::CloakState::CloakedAllied: cloak = Unit::CloakedAllied; return true; } return false; } @@ -190,7 +191,7 @@ bool Convert(const ObservationRawPtr& observation_raw, UnitPool& unit_pool, uint } } else { - unit->cloak = Unit::Unknown; + unit->cloak = Unit::CloakedUnknown; } unit->detect_range = observation_unit.detect_range(); diff --git a/tests/test_unit_command.cc b/tests/test_unit_command.cc index 75453860..16231947 100644 --- a/tests/test_unit_command.cc +++ b/tests/test_unit_command.cc @@ -39,7 +39,7 @@ namespace sc2 { ReportError("Could not find the test unit."); } - if (test_unit_ && test_unit_->cloak != Unit::CloakState::Cloaked) { + if (test_unit_ && test_unit_->cloak != Unit::CloakState::CloakedAllied) { ReportError("Unit is not cloaked as expected."); } @@ -1255,9 +1255,6 @@ namespace sc2 { if (target_units.front()->is_blip != true) { ReportError("Target unit is not a blip."); } - if (target_units.front()->cloak != Unit::CloakState::Unknown) { - ReportError("Target unit cloak state is incorrect."); - } if (target_units.front()->display_type != Unit::DisplayType::Hidden) { ReportError("Target unit is not hidden."); } From f8a84f4f2d3945d56b5e2192bc1f5b9ee5b8cbf1 Mon Sep 17 00:00:00 2001 From: Peter Cudmore Date: Fri, 12 Jul 2019 17:27:55 +1000 Subject: [PATCH 3/6] Fixed remapped id's --- include/sc2api/sc2_typeenums.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/sc2api/sc2_typeenums.h b/include/sc2api/sc2_typeenums.h index c25bf711..110e950a 100644 --- a/include/sc2api/sc2_typeenums.h +++ b/include/sc2api/sc2_typeenums.h @@ -478,7 +478,8 @@ namespace sc2 { HARVEST_RETURN_MULE = 167, // Target: None. HARVEST_RETURN_PROBE = 299, // Target: None. HARVEST_RETURN_SCV = 296, // Target: None. - HOLDPOSITION = 18, // Target: None. +// HOLDPOSITION = 18, // Target: None. + HOLDPOSITION = 3793, LAND = 3678, // Target: Point. LAND_BARRACKS = 554, // Target: Point. LAND_COMMANDCENTER = 419, // Target: Point. @@ -531,8 +532,10 @@ namespace sc2 { MORPH_WARPGATE = 1518, // Target: None. MORPH_WARPPRISMPHASINGMODE = 1528, // Target: None. MORPH_WARPPRISMTRANSPORTMODE = 1530, // Target: None. - MOVE = 16, // Target: Unit, Point. - PATROL = 17, // Target: Unit, Point. + // MOVE = 16, // Target: Unit, Point. + MOVE = 3794, + // PATROL = 17, // Target: Unit, Point. + PATROL = 3795, RALLY_BUILDING = 195, // Target: Unit, Point. RALLY_COMMANDCENTER = 203, // Target: Unit, Point. RALLY_HATCHERY_UNITS = 211, // Target: Unit, Point. From 0afd7ebddd52dc1dceca8ec8a5bdd6709b7c3c96 Mon Sep 17 00:00:00 2001 From: Peter Cudmore Date: Fri, 12 Jul 2019 17:30:52 +1000 Subject: [PATCH 4/6] Fixed errors in bunker ability id's --- tests/test_unit_command.cc | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/test_unit_command.cc b/tests/test_unit_command.cc index 16231947..9e8648c7 100644 --- a/tests/test_unit_command.cc +++ b/tests/test_unit_command.cc @@ -294,6 +294,9 @@ namespace sc2 { // // TestBuildGateway // + // Since 2018 revamp, new gateways autobuild as warpgates. + // Should test this on base tech level instead of debug tech level. + // Instead we'll just hack around for now. class TestBuildGateway : public TestUnitCommandTargetingPoint { public: @@ -309,18 +312,18 @@ namespace sc2 { void AdditionalTestSetup() override { target_point_ = GetPointOffsetX(origin_pt_); - + agent_->Debug()->DebugCreateUnit(UNIT_TYPEID::PROTOSS_PYLON, origin_pt_, agent_->Observation()->GetPlayerID(), 1); agent_->Debug()->SendDebug(); } void OnTestFinish() override { - VerifyUnitExistsAndComplete(UNIT_TYPEID::PROTOSS_GATEWAY); + VerifyUnitExistsAndComplete(UNIT_TYPEID::PROTOSS_WARPGATE); VerifyUnitIdleAfterOrder(test_unit_type_); - VerifyUnitIdleAfterOrder(UNIT_TYPEID::PROTOSS_GATEWAY); + VerifyUnitIdleAfterOrder(UNIT_TYPEID::PROTOSS_WARPGATE); const ObservationInterface* obs = agent_->Observation(); - if (obs->GetWarpGateCount() != 0) { - ReportError("Gateway is being incorrectly identified as a Warp Gate."); + if (obs->GetWarpGateCount() != 1) { + ReportError("New gateway is not being identified as a Warp Gate."); } KillAllUnits(); } @@ -1555,7 +1558,7 @@ namespace sc2 { TestTransportBunkerLoad() { test_unit_type_ = UNIT_TYPEID::TERRAN_BUNKER; target_unit_type_ = UNIT_TYPEID::TERRAN_MARAUDER; - test_ability_ = ABILITY_ID::LOAD; + test_ability_ = ABILITY_ID::LOAD_BUNKER; instant_cast_ = true; } @@ -1601,7 +1604,7 @@ namespace sc2 { if (test_unit_ && test_unit_->passengers.size() != 1) { ReportError("Unit count in bunker is not 1."); } - if (test_unit_ && test_unit_->cargo_space_max != 6) { + if (test_unit_ && test_unit_->cargo_space_max != 8) { ReportError("Bunker cargo space max is not correct."); } if (test_unit_ && test_unit_->cargo_space_taken != 2) { @@ -1625,7 +1628,7 @@ namespace sc2 { TestTransportBunkerUnloadAll() { test_unit_type_ = UNIT_TYPEID::TERRAN_BUNKER; target_unit_type_ = UNIT_TYPEID::TERRAN_MARAUDER; - test_ability_ = ABILITY_ID::UNLOADALL; + test_ability_ = ABILITY_ID::UNLOADALL_BUNKER; instant_cast_ = true; } @@ -1684,7 +1687,7 @@ namespace sc2 { if (test_unit_ && test_unit_->passengers.size() != 0) { ReportError("Unit count in bunker is not 0."); } - if (test_unit_ && test_unit_->cargo_space_max != 6) { + if (test_unit_ && test_unit_->cargo_space_max != 8) { ReportError("Bunker cargo space max is not correct."); } if (test_unit_ && test_unit_->cargo_space_taken != 0) { From 520fca6e6fe60f4b1b3b727c0304f199898cd140 Mon Sep 17 00:00:00 2001 From: Peter Cudmore Date: Fri, 12 Jul 2019 17:38:39 +1000 Subject: [PATCH 5/6] Fixed issue in bunker tests where too many marauders were created. --- tests/test_unit_command.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_unit_command.cc b/tests/test_unit_command.cc index 9e8648c7..ad0e40f6 100644 --- a/tests/test_unit_command.cc +++ b/tests/test_unit_command.cc @@ -1637,7 +1637,7 @@ namespace sc2 { } void AdditionalTestSetup() override { - agent_->Debug()->DebugCreateUnit(UNIT_TYPEID::TERRAN_MARAUDER, origin_pt_, agent_->Observation()->GetPlayerID(), 3); + agent_->Debug()->DebugCreateUnit(UNIT_TYPEID::TERRAN_MARAUDER, origin_pt_, agent_->Observation()->GetPlayerID(), 2); agent_->Debug()->SendDebug(); } From 8634950537056c121391cc662673a8a3b735882c Mon Sep 17 00:00:00 2001 From: Peter Cudmore Date: Sat, 13 Jul 2019 11:09:06 +1000 Subject: [PATCH 6/6] update comments --- include/sc2api/sc2_unit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sc2api/sc2_unit.h b/include/sc2api/sc2_unit.h index a99b8f5a..c0d4dbf4 100644 --- a/include/sc2api/sc2_unit.h +++ b/include/sc2api/sc2_unit.h @@ -101,7 +101,7 @@ class Unit { CloakedDetected = 2, //! No cloaking. NotCloaked = 3, - //! Cloaked ally, though not sure why this is necessary. + //! Cloaked ally unit. CloakedAllied = 4 };