Skip to content

Commit 0fd1f49

Browse files
authored
[Minor] Speed=0 extension (#1808)
When `Speed=0` or the TechnoTypes cell cannot move due to `MovementRestrictedTo`, vehicles cannot attack targets beyond the weapon's range. `Area Guard` and `Hunt` missions will also become ineffective. - `Speed=0`或`MovementRestrictedTo`导致单元格无法移动时载具无法攻击超出武器射程的目标。`区域守卫(AreaGuard)`和`猎杀(Hunt)`任务也会失效。 - When the vehicle loses its target, you can customize whether to align the turret direction with the vehicle body. - When `Speed=0` or TechnoTypes cells cannot move due to `MovementRestrictedTo`, the default value is no; in other cases, it is yes. - 当载具失去目标时可以自定义炮塔朝向和本体对齐。 - `Speed=0`或者`MovementRestrictedTo`导致单元格无法移动时默认值为no,其他情况为yes。 In `rulesmd.ini`: ```ini [SOMEVEHICLE] ; VehicleType TurretResponse= ; boolean ``` --------- Co-authored-by: Fly-Star <[email protected]>
1 parent 73c2208 commit 0fd1f49

File tree

12 files changed

+177
-44
lines changed

12 files changed

+177
-44
lines changed

CREDITS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ This page lists all the individual contributions to the project by their author.
386386
- Fix an unusual use of DeployFireWeapon for InfantryType
387387
- Fix the fact that when the selected unit is in a rearmed state, it can unconditionally use attack mouse on the target
388388
- Units can customize the attack voice that plays when using more weapons
389+
- When `Speed=0` or the TechnoTypes cell cannot move due to `MovementRestrictedTo`, vehicles cannot attack targets beyond the weapon's range. `Area Guard` and `Hunt` missions will also become ineffective
390+
- When the vehicle loses its target, you can customize whether to align the turret direction with the vehicle body
389391
- **NetsuNegi**:
390392
- Forbidding parallel AI queues by type
391393
- Jumpjet crash speed fix when crashing onto building

YRpp

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
253253
- Fixed the bug that Locomotor warhead won't stop working when firer (except for vehicle) stop firing.
254254
- Fixed the bug that hover vehicle will sink if destroyed on bridge.
255255
- Fixed the fact that when the selected unit is in a rearmed state, it can unconditionally use attack mouse on the target.
256+
- When `Speed=0` or the TechnoTypes cell cannot move due to `MovementRestrictedTo`, vehicles cannot attack targets beyond the weapon's range. `Area Guard` and `Hunt` missions will also become ineffective.
256257

257258
## Fixes / interactions with other extensions
258259

docs/New-or-Enhanced-Logics.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,6 +2075,17 @@ FireUp= ; integer
20752075
FireUp.ResetInRetarget=true ; boolean
20762076
```
20772077

2078+
### Turret Response
2079+
2080+
- When the vehicle loses its target, you can customize whether to align the turret direction with the vehicle body.
2081+
- When `Speed=0` or TechnoTypes cells cannot move due to `MovementRestrictedTo`, the default value is no; in other cases, it is yes.
2082+
2083+
In `rulesmd.ini`:
2084+
```ini
2085+
[SOMEVEHICLE] ; VehicleType
2086+
TurretResponse= ; boolean
2087+
```
2088+
20782089
## Warheads
20792090

20802091
```{hint}

docs/Whats-New.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ New:
428428
- [Units can customize the attack voice that plays when using more weapons](New-or-Enhanced-Logics.md#multi-voiceattack) (by FlyStar)
429429
- Customize squid grapple animation (by NetsuNegi)
430430
- [Auto deploy for GI-like infantry](Fixed-or-Improved-Logics.md#auto-deploy-for-gi-like-infantry) (by TaranDahl)
431+
- When the vehicle loses its target, you can customize whether to align the turret direction with the vehicle body (by FlyStar)
431432
432433
Vanilla fixes:
433434
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
@@ -444,6 +445,7 @@ Vanilla fixes:
444445
445446
Phobos fixes:
446447
- Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi)
448+
- When `Speed=0` or the TechnoTypes cell cannot move due to `MovementRestrictedTo`, vehicles cannot attack targets beyond the weapon's range. `Area Guard` and `Hunt` missions will also become ineffective (by FlyStar)
447449
448450
Fixes / interactions with other extensions:
449451
- Allowed `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades (by Ollerus)

src/Ext/Aircraft/Hooks.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -824,32 +824,3 @@ DEFINE_HOOK(0x4157EB, AircraftClass_Mission_SpyPlaneOverfly_MaxCount, 0x6)
824824

825825
return 0;
826826
}
827-
828-
DEFINE_HOOK(0x708FC0, TechnoClass_ResponseMove_Pickup, 0x5)
829-
{
830-
enum { SkipResponse = 0x709015 };
831-
832-
GET(TechnoClass*, pThis, ECX);
833-
834-
if (auto const pAircraft = abstract_cast<AircraftClass*>(pThis))
835-
{
836-
auto const pType = pAircraft->Type;
837-
838-
if (pType->Carryall
839-
&& pAircraft->HasAnyLink()
840-
&& generic_cast<FootClass*>(pAircraft->Destination))
841-
{
842-
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pType);
843-
844-
if (pTypeExt->VoicePickup.isset())
845-
{
846-
pThis->QueueVoice(pTypeExt->VoicePickup.Get());
847-
848-
R->EAX(1);
849-
return SkipResponse;
850-
}
851-
}
852-
}
853-
854-
return 0;
855-
}

src/Ext/Techno/Body.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,35 @@ bool TechnoExt::IsHealthInThreshold(TechnoClass* pObject, double min, double max
731731
return hp <= max && hp >= min;
732732
}
733733

734+
bool TechnoExt::CannotMove(UnitClass* pThis)
735+
{
736+
const auto pType = pThis->Type;
737+
738+
if (pType->Speed == 0)
739+
return true;
740+
741+
if (!pThis->IsInAir())
742+
{
743+
LandType landType = pThis->GetCell()->LandType;
744+
const LandType movementRestrictedTo = pType->MovementRestrictedTo;
745+
746+
if (pThis->OnBridge
747+
&& (landType == LandType::Water || landType == LandType::Beach))
748+
{
749+
landType = LandType::Road;
750+
}
751+
752+
if (movementRestrictedTo != LandType::None &&
753+
movementRestrictedTo != landType &&
754+
landType != LandType::Tunnel)
755+
{
756+
return true;
757+
}
758+
}
759+
760+
return false;
761+
}
762+
734763
// =============================
735764
// load / save
736765

src/Ext/Techno/Body.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ class TechnoExt
265265
static bool IsHealthInThreshold(TechnoClass* pObject, double min, double max);
266266
static UnitTypeClass* GetUnitTypeExtra(UnitClass* pUnit);
267267
static AircraftTypeClass* GetAircraftTypeExtra(AircraftClass* pAircraft);
268+
static bool CannotMove(UnitClass* pThis);
268269

269270
// WeaponHelpers.cpp
270271
static int PickWeaponIndex(TechnoClass* pThis, TechnoClass* pTargetTechno, AbstractClass* pTarget, int weaponIndexOne, int weaponIndexTwo, bool allowFallback = true, bool allowAAFallback = true);

src/Ext/Techno/Hooks.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,3 +1202,41 @@ DEFINE_HOOK(0x4DF3A6, FootClass_UpdateAttackMove_Follow, 0x6)
12021202
}
12031203

12041204
#pragma endregion
1205+
1206+
DEFINE_HOOK(0x708FC0, TechnoClass_ResponseMove_Pickup, 0x5)
1207+
{
1208+
enum { SkipResponse = 0x709015 };
1209+
1210+
GET(TechnoClass*, pThis, ECX);
1211+
1212+
const AbstractType rtti = pThis->WhatAmI();
1213+
1214+
if (rtti == AbstractType::Aircraft)
1215+
{
1216+
auto const pAircraft = static_cast<AircraftClass*>(pThis);
1217+
auto const pType = pAircraft->Type;
1218+
1219+
if (pType->Carryall && pAircraft->HasAnyLink()
1220+
&& generic_cast<FootClass*>(pAircraft->Destination))
1221+
{
1222+
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pType);
1223+
1224+
if (pTypeExt->VoicePickup.isset())
1225+
{
1226+
pThis->QueueVoice(pTypeExt->VoicePickup.Get());
1227+
1228+
R->EAX(1);
1229+
return SkipResponse;
1230+
}
1231+
}
1232+
}
1233+
else if (rtti == AbstractType::Unit)
1234+
{
1235+
auto const pUnit = static_cast<UnitClass*>(pThis);
1236+
1237+
if (TechnoExt::TechnoExt::CannotMove(pUnit))
1238+
return SkipResponse;
1239+
}
1240+
1241+
return 0;
1242+
}

src/Ext/TechnoType/Body.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
956956
this->AttackMove_PursuitTarget.Read(exINI, pSection, "AttackMove.PursuitTarget");
957957

958958
this->InfantryAutoDeploy.Read(exINI, pSection, "InfantryAutoDeploy");
959-
959+
960960
// Ares 0.2
961961
this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius");
962962

@@ -1190,14 +1190,14 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
11901190
if (GeneralUtils::IsValidString(pThis->PaletteFile) && !pThis->Palette)
11911191
Debug::Log("[Developer warning] [%s] has Palette=%s set but no palette file was loaded (missing file or wrong filename). Missing palettes cause issues with lighting recalculations.\n", pArtSection, pThis->PaletteFile);
11921192

1193-
this->LoadFromINIByWhatAmI(exArtINI, pArtSection);
1193+
this->LoadFromINIByWhatAmI(exINI, pSection, exArtINI, pArtSection);
11941194

11951195
// VoiceIFVRepair from Ares 0.2
11961196
this->VoiceIFVRepair.Read(exINI, pSection, "VoiceIFVRepair");
11971197
this->ParseVoiceWeaponAttacks(exINI, pSection, this->VoiceWeaponAttacks, this->VoiceEliteWeaponAttacks);
11981198
}
11991199

1200-
void TechnoTypeExt::ExtData::LoadFromINIByWhatAmI(INI_EX& exArtINI, const char* pArtSection)
1200+
void TechnoTypeExt::ExtData::LoadFromINIByWhatAmI(INI_EX& exINI, const char* pSection, INI_EX& exArtINI, const char* pArtSection)
12011201
{
12021202
AbstractType abs = this->OwnerObject()->WhatAmI();
12031203

@@ -1207,6 +1207,7 @@ void TechnoTypeExt::ExtData::LoadFromINIByWhatAmI(INI_EX& exArtINI, const char*
12071207
{
12081208
this->FireUp.Read(exArtINI, pArtSection, "FireUp");
12091209
this->FireUp_ResetInRetarget.Read(exArtINI, pArtSection, "FireUp.ResetInRetarget");
1210+
this->TurretResponse.Read(exINI, pSection, "TurretResponse");
12101211
//this->SecondaryFire.Read(exArtINI, pArtSection, "SecondaryFire");
12111212
break;
12121213
}
@@ -1591,6 +1592,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
15911592
.Process(this->VoiceEliteWeaponAttacks)
15921593

15931594
.Process(this->InfantryAutoDeploy)
1595+
1596+
.Process(this->TurretResponse)
15941597
;
15951598
}
15961599
void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)

0 commit comments

Comments
 (0)