Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -921,4 +921,6 @@ This page lists all the individual contributions to the project by their author.
- **Chang_zhi**:
- Interop export interface for accessing scenario local/global variables
- Add `ClampToScreen` tag for `BannerType` to control whether banner position is clamped to the visible area
- **obsidianus** - Automatic conversion based on health
- **obsidianus**:
- Automatic conversion based on health
- Unit image changes in various theater types
20 changes: 20 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2573,6 +2573,26 @@ WaterImage.ConditionRed= ; VehicleType entry
Note that the VehicleTypes had to be defined under [VehicleTypes] and use same image type (SHP/VXL) for vanilla/damaged states.
```

### Unit image changes in various theater types

- Units on maps of different theater types can now change their models to the corresponding theater-specific models.
- The INI tags are shown below.

In `rulesmd.ini`:
```ini
[SOMEVEHICLE] ; VehicleType
Image.Temperate= ; VehicleType entry
Image.Snow= ; VehicleType entry
Image.Urban= ; VehicleType entry
Image.Desert= ; VehicleType entry
Image.NewUrban= ; VehicleType entry
Image.Lunar= ; VehicleType entry
```

```{warning}
Note that the VehicleTypes had to be defined under [VehicleTypes] and use same image type (SHP/VXL) for vanilla/damaged states.
```

### Default mirage disguise for individual VehicleTypes

- Vehicle can now have its `DefaultMirageDisguises` overridden per-type.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ HideShakeEffects=false ; boolean
- [DeployFire supports buildings](New-or-Enhanced-Logics.md#deployfire-supports) (By FlyStar)
- `OmniFire` supports buildings with `Turret=yes` (by FlyStar)
- [Automatic conversion based on heallth](New-or-Enhanced-Logics.md#automatic-conversion-based-on-heallth) (by obsidianus)
- [Unit image changes in various theater types](New-or-Enhanced-Logics.md#unit-image-changes-in-various-theater-types) (by obsidianus)

#### Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
29 changes: 25 additions & 4 deletions src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,10 +796,19 @@ DEFINE_HOOK(0x73B4DA, UnitClass_DrawVXL_WaterType_Extra, 0x6)

const auto pTypeExt = UnitTypeExt::Fetch(pThis->Type);

if (pTypeExt->NeedDamagedImage && pThis->IsClearlyVisibleTo(HouseClass::CurrentPlayer) && !pThis->Deployed)
if (pThis->IsClearlyVisibleTo(HouseClass::CurrentPlayer) && !pThis->Deployed)
{
if (const auto pCustomType = UnitExt::GetUnitTypeExtra(pThis, pTypeExt))
if (const auto pCustomType = UnitExt::GetUnitType(pThis, pTypeExt))
{
R->EBX<ObjectTypeClass*>(pCustomType);
}
if (pTypeExt->NeedDamagedImage)
{
if (const auto pCustomType = UnitExt::GetUnitTypeExtra(pThis, pTypeExt))
{
R->EBX<ObjectTypeClass*>(pCustomType);
}
}
}

return 0;
Expand All @@ -814,12 +823,24 @@ DEFINE_HOOK(0x73C602, UnitClass_DrawSHP_WaterType_Extra, 0x6)
const auto pType = pThis->Type;
const auto pTypeExt = UnitTypeExt::Fetch(pType);

if (pTypeExt->NeedDamagedImage && pThis->IsClearlyVisibleTo(HouseClass::CurrentPlayer) && !pThis->Deployed)
if (pThis->IsClearlyVisibleTo(HouseClass::CurrentPlayer) && !pThis->Deployed)
{
if (const auto pCustomType = UnitExt::GetUnitTypeExtra(pThis, pTypeExt))
if (const auto pCustomType = UnitExt::GetUnitType(pThis, pTypeExt))
{
if (const auto Image = pCustomType->GetImage())
{
R->EAX<SHPStruct*>(Image);
}
}
if (pTypeExt->NeedDamagedImage)
{
if (const auto pCustomType = UnitExt::GetUnitTypeExtra(pThis, pTypeExt))
{
if (const auto Image = pCustomType->GetImage())
{
R->EAX<SHPStruct*>(Image);
}
}
}
}

Expand Down
46 changes: 46 additions & 0 deletions src/Ext/Unit/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,52 @@ bool UnitExt::CanDeployIntoBuilding(UnitClass* pThis, bool noDeploysIntoDefaultV
return canDeploy;
}

UnitTypeClass* UnitExt::GetUnitType(UnitClass* pUnit, UnitTypeExt* pData)
{
switch (ScenarioClass::Instance->Theater)
{
case TheaterType::Temperate:
if (const auto image = pData->Image_Temperate)
{
return image;
}
break;
case TheaterType::Snow:
if (const auto image = pData->Image_Snow)
{
return image;
}
break;
case TheaterType::Urban:
if (const auto image = pData->Image_Urban)
{
return image;
}
break;
case TheaterType::Desert:
if (const auto image = pData->Image_Desert)
{
return image;
}
break;
case TheaterType::NewUrban:
if (const auto image = pData->Image_NewUrban)
{
return image;
}
break;
case TheaterType::Lunar:
if (const auto image = pData->Image_Lunar)
{
return image;
}
break;
default:
break;
}
return nullptr;
}

UnitTypeClass* UnitExt::GetUnitTypeExtra(UnitClass* pUnit, UnitTypeExt* pData)
{
if (pUnit->IsGreenHP())
Expand Down
1 change: 1 addition & 0 deletions src/Ext/Unit/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class UnitExt final : public FootExt
static bool SimpleDeployerAllowedToDeploy(UnitClass* pThis, bool defaultValue, bool alwaysCheckLandTypes);
static bool CanDeployIntoBuilding(UnitClass* pThis, bool noDeploysIntoDefaultValue = false);
static UnitTypeClass* GetUnitTypeExtra(UnitClass* pUnit, UnitTypeExt* pData);
static UnitTypeClass* GetUnitType(UnitClass* pUnit, UnitTypeExt* pData);

UnitClass* OwnerObject() const
{
Expand Down
13 changes: 13 additions & 0 deletions src/Ext/UnitType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ void UnitTypeExt::LoadFromINIFile(CCINIClass* const pINI)
this->Deploy_NoTiberium.Read(exINI, pSection, "Deploy.NoTiberium");
this->HoverDrownable.Read(exINI, pSection, "HoverDrownable");

this->Image_Temperate.Read(exINI, pSection, "Image.Temperate");
this->Image_Snow.Read(exINI, pSection, "Image.Snow");
this->Image_Urban.Read(exINI, pSection, "Image.Urban");
this->Image_Desert.Read(exINI, pSection, "Image.Desert");
this->Image_NewUrban.Read(exINI, pSection, "Image.NewUrban");
this->Image_Lunar.Read(exINI, pSection, "Image.Lunar");

const auto pArtINI = &CCINIClass::INI_Art;
INI_EX exArtINI(pArtINI);
auto pArtSection = pThis->ImageFile;
Expand Down Expand Up @@ -192,6 +199,12 @@ void UnitTypeExt::Serialize(T& Stm)
.Process(this->Deploy_NoPassenger)
.Process(this->Deploy_NoTiberium)
.Process(this->HoverDrownable)
.Process(this->Image_Temperate)
.Process(this->Image_Snow)
.Process(this->Image_Urban)
.Process(this->Image_Desert)
.Process(this->Image_NewUrban)
.Process(this->Image_Lunar)
.Process(this->TurretShape)
.Process(this->BarrelOverTurret)
.Process(this->BarrelOffset)
Expand Down
13 changes: 13 additions & 0 deletions src/Ext/UnitType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ class UnitTypeExt final : public TechnoTypeExt
std::vector<CoordStruct> ExtraTurretOffsets;
Valueable<int> BurstPerTurret;

Nullable<UnitTypeClass*> Image_Temperate;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Nullable<UnitTypeClass*> Image_Temperate;
Valueable<UnitTypeClass*> Image_Temperate;

Nullable<UnitTypeClass*> Image_Snow;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Nullable<UnitTypeClass*> Image_Snow;
Valueable<UnitTypeClass*> Image_Snow;

Nullable<UnitTypeClass*> Image_Urban;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Nullable<UnitTypeClass*> Image_Urban;
Valueable<UnitTypeClass*> Image_Urban;

Nullable<UnitTypeClass*> Image_Desert;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Nullable<UnitTypeClass*> Image_Desert;
Valueable<UnitTypeClass*> Image_Desert;

Nullable<UnitTypeClass*> Image_NewUrban;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Nullable<UnitTypeClass*> Image_NewUrban;
Valueable<UnitTypeClass*> Image_NewUrban;

Nullable<UnitTypeClass*> Image_Lunar;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Nullable<UnitTypeClass*> Image_Lunar;
Valueable<UnitTypeClass*> Image_Lunar;


explicit UnitTypeExt(UnitTypeClass* const OwnerObject) : TechnoTypeExt(OwnerObject)
, SinkSpeed {}
, Sinkable {}
Expand Down Expand Up @@ -143,6 +150,12 @@ class UnitTypeExt final : public TechnoTypeExt
, ExtraTurretCount { 0 }
, ExtraTurretOffsets { }
, BurstPerTurret { 0 }
, Image_Temperate {}
, Image_Snow {}
, Image_Urban {}
, Image_Desert {}
, Image_NewUrban {}
, Image_Lunar {}
{ }

UnitTypeClass* OwnerObject() const
Expand Down
Loading