Skip to content

Commit

Permalink
Implement DecloakToFire
Browse files Browse the repository at this point in the history
  • Loading branch information
ZivDero committed Mar 5, 2025
1 parent f83f531 commit 8d716e6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,4 @@ This page lists all the individual contributions to the project by their author.
- Finalize the feature for animations to spawn additional animations.
- VehicleTypes with Jumpjet locomotion now take damage in flight.
- Fix the map glitching around when scrolling if the map is not large enough to fill the entire screen.

- Implement `DecloakToFire`.
10 changes: 10 additions & 0 deletions docs/New-Features-and-Enhancements.md
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,16 @@ In `RULES.INI`:
TargetZoneScan=InRange ; InRange, Any, or Same. Same - matches original game behaviour and is the default. InRange - considers targets in other movement zones that are within weapon range. Any - ignore zone checks altogether.
```

### DecloakToFire

- Vinifera ports the DecloakToFire key from Red Alert 2.

In `RULES.INI`:
```ini
[SOMETECHNO] ; TechnoType
DecloakToFire=yes ; boolean, does this Techno have to decloak before firing?
```

## Terrain

### Light Sources
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ New:
- Allow disabling the ActLike check on construction yards to allow for faction-specific MCVs (by ZivDero)
- Implement a feature for animations to spawn additional animations (by CCHyper/tomsons26, ZivDero)
- Add `TargetZoneScan` to TechnoTypes (by Rampastring)
- Implement `DecloakToFire` (by ZivDero)


Vanilla fixes:
Expand Down
9 changes: 4 additions & 5 deletions src/extensions/techno/technoext_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ FireErrorType TechnoClassExt::_Can_Fire(TARGET target, WeaponSlotType which)
return FIRE_ILLEGAL;

const auto ext = Extension::Fetch<TechnoClassExtension>(this);
const auto typeext = Extension::Fetch<TechnoTypeClassExtension>(Techno_Type_Class());

/**
* If this unit is a spawner, don't let it fire if it's currently in the process of spawning.
Expand Down Expand Up @@ -692,15 +693,13 @@ FireErrorType TechnoClassExt::_Can_Fire(TARGET target, WeaponSlotType which)
*/
if (weapon && Extension::Fetch<WeaponTypeClassExtension>(weapon)->IsSpawner)
{
const auto techno_ext = Extension::Fetch<TechnoClassExtension>(this);

if (techno_ext->SpawnManager == nullptr)
if (ext->SpawnManager == nullptr)
{
Vinifera_DeveloperMode_Warning_WWMessageBox("[FATAL] You have a weapon that has Spawner=yes but you didn't define Spawns= in the techno.");
Fatal("[FATAL] You have a weapon that has Spawner=yes but you didn't define Spawns= in the techno.");
}

if (techno_ext->SpawnManager->Active_Count() == 0)
if (ext->SpawnManager->Active_Count() == 0)
return FIRE_REARM;
}

Expand Down Expand Up @@ -780,7 +779,7 @@ FireErrorType TechnoClassExt::_Can_Fire(TARGET target, WeaponSlotType which)
/**
* If cloaked, then firing is disabled.
*/
if (Cloak != UNCLOAKED && (Kind_Of() != RTTI_AIRCRAFT || Cloak == CLOAKED))
if (typeext->IsDecloakToFire && Cloak != UNCLOAKED && (Kind_Of() != RTTI_AIRCRAFT || Cloak == CLOAKED))
return FIRE_CLOAKED;

/**
Expand Down
5 changes: 4 additions & 1 deletion src/extensions/technotype/technotypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ TechnoTypeClassExtension::TechnoTypeClassExtension(const TechnoTypeClass *this_p
BuildTimeCost(0),
RequiredHouses(-1),
ForbiddenHouses(-1),
TargetZoneScan(TZST_SAME)
TargetZoneScan(TZST_SAME),
IsDecloakToFire(true)
{
//if (this_ptr) EXT_DEBUG_TRACE("TechnoTypeClassExtension::TechnoTypeClassExtension - Name: %s (0x%08X)\n", Name(), (uintptr_t)(This()));
}
Expand Down Expand Up @@ -239,6 +240,7 @@ void TechnoTypeClassExtension::Compute_CRC(WWCRCEngine &crc) const
crc(SpawnReloadRate);
crc(SpawnsNumber);
crc(TargetZoneScan);
crc(IsDecloakToFire)
}


Expand Down Expand Up @@ -359,6 +361,7 @@ bool TechnoTypeClassExtension::Read_INI(CCINIClass &ini)
ForbiddenHouses = ini.Get_Owners(ini_name, "ForbiddenHouses", ForbiddenHouses);

TargetZoneScan = _Get_TargetZoneScanType(ini, ini_name, "TargetZoneScan", TargetZoneScan);
IsDecloakToFire = ini.Get_Bool(ini_name, "DecloakToFire", IsDecloakToFire);

return true;
}
5 changes: 5 additions & 0 deletions src/extensions/technotype/technotypeext.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,9 @@ class TechnoTypeClassExtension : public ObjectTypeClassExtension
* Defines how the techno treats targets outside of its zone when scanning for targets.
*/
TargetZoneScanType TargetZoneScan;

/**
* Does this object need to decloak before firing?
*/
bool IsDecloakToFire;
};

0 comments on commit 8d716e6

Please sign in to comment.