Skip to content
Merged
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
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ This page lists all the individual contributions to the project by their author.
- Enter the grinder voice
- Customize the country displayed in `Sight`
- The parachute animation supports `ShouldUseCellDrawer=no` to remove the hard-coded requirement to use the owner's color palette, while inheriting the animation owner's current country
- New `NoAmmoWeapons` tag supporting multiple weapon types
- **NetsuNegi**:
- Forbidding parallel AI queues by type
- Jumpjet crash speed fix when crashing onto building
Expand Down
26 changes: 26 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2419,6 +2419,32 @@ MultiWeapon.IsSecondary= ; List of integers
MultiWeapon.SelectCount=2 ; integer
```

### Multi VoiceAttack

- Units can customize the attack voice that plays when using more weapons.
- If you need to assign an attack-voice to `Weapon1`, simply set `VoiceWeapon1Attack`. The same applies to other weapons.
- `VoiceEliteWeaponNAttack` can also be used to specify attack voices for `EliteWeaponN`. The default is `VoiceWeaponNAttack`.

In `rulesmd.ini`:
```ini
[SOMETECHNO] ; TechnoType
VoiceWeaponNAttack= ; Sound entry
VoiceEliteWeaponNAttack= ; Sound entry
```

### No Ammo Weapons

- You can now use multiple weapons with `NoAmmoWeapons` while `NoAmmoAmount` is active.
- `NoAmmoWeapons` selects an appropriate weapon based on the weapon's `CanTarget` and other tags, as well as the projectile's `Verses`.
- If no suitable weapon is found, it continues to use `NoAmmoWeapon`.

In `rulesmd.ini`:
```ini
[SOMETECHNO] ; TechnoType
NoAmmoWeapons= ; List of integers
NoAmmoWeapons.IgnoreNeverUse=yes ; boolean
```

### No Manual Move

- You can now specify whether a TechnoType is unable to receive move command.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -2049,6 +2049,7 @@ HideShakeEffects=false ; boolean
- [AttachEffect `CumulativeAnimations` count increment customization](New-or-Enhanced-Logics.md#attached-effects) (by Starkku)
- [More convenient vanilla action script target specification](AI-Scripting-and-Mapping.md#more-convenient-vanilla-action-script-target-specification) (by NetsuNegi)
- Global default value for `ShouldUseCellDrawer` (by Noble_Fish)
- [New `NoAmmoWeapons` tag supporting multiple weapon types](New-or-Enhanced-Logics.md#no-ammo-weapons) (by FlyStar)

#### Vanilla fixes:
- Fixed the bug where a building with `Factory=BuildingType` owned by the AI did not play `ProductionAnim` when placing a produced building (by Noble_Fish)
Expand Down
2 changes: 1 addition & 1 deletion src/Ext/Techno/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class TechnoExt : public RadioExt, public Detach::Listener<AirstrikeClass>
static void ApplyKillWeapon(TechnoClass* pThis, TechnoClass* pSource, WarheadTypeClass* pWH, HouseClass* pSourceHouse);
static void ApplyRevengeWeapon(TechnoClass* pThis, TechnoClass* pSource, WarheadTypeClass* pWH);
static bool TryToCreateCrate(CoordStruct location, Powerup selectedPowerup = Powerup::Money, int maxCellRange = 10);
static bool MultiWeaponCanFire(TechnoClass* const pThis, AbstractClass* const pTarget, WeaponTypeClass* const pWeaponType);
static bool MultiWeaponCanFire(TechnoClass* const pThis, AbstractClass* const pTarget, WeaponTypeClass* const pWeaponType, const bool ignoreNeverUse = false);
static bool HasWeaponsDisabled(TechnoClass* pThis);
static FireError GetFireErrorIgnoreDisableWeapons(TechnoClass* pThis, AbstractClass* pTarget, int weaponIndex, bool ignoreRange);
};
Expand Down
40 changes: 40 additions & 0 deletions src/Ext/Techno/Hooks.Firing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,46 @@ DEFINE_HOOK(0x6F33CD, TechnoClass_WhatWeaponShouldIUse_ForceFire, 0x6)
return 0;
}

// Disable Ares NoAmmoWeapon hook.
DEFINE_PATCH(0x6F3410, 0x8A, 0x4F, 0x14);
DEFINE_PATCH(0x6F3413, 0x8B, 0x16);

DEFINE_HOOK(0x6F3415, TechnoClass_WhatWeaponShouldIUse_NoAmmoWeapon, 0x5)
{
enum { UseWeaponIndex = 0x6F3406 };

GET(TechnoClass* const, pThis, ESI);
GET(AbstractClass* const, pTarget, EDI);

auto const pTypeExt = TechnoExt::Fetch(pThis)->TypeExtData;
auto const pType = pTypeExt->OwnerObject();

if (pType->Ammo >= 0 && pThis->Ammo <= pTypeExt->NoAmmoAmount)
{
const auto& noAmmoWeapons = pTypeExt->NoAmmoWeapons;
const bool ignoreNeverUse = pTypeExt->NoAmmoWeapons_IgnoreNeverUse;

for (int weaponIndex : noAmmoWeapons)
{
if (TechnoExt::MultiWeaponCanFire(pThis, pTarget, pThis->GetWeapon(weaponIndex)->WeaponType), ignoreNeverUse)
{
R->EAX(weaponIndex);
return UseWeaponIndex;
}
}

const int noAmmoWeapon = pTypeExt->NoAmmoWeapon;

if (noAmmoWeapon >= 0)
{
R->EAX(noAmmoWeapon);
return UseWeaponIndex;
}
}

return 0;
}

DEFINE_HOOK(0x6F3428, TechnoClass_WhatWeaponShouldIUse_ForceWeapon, 0x6)
{
enum { UseWeaponIndex = 0x6F37AF };
Expand Down
5 changes: 3 additions & 2 deletions src/Ext/Techno/WeaponHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,10 @@ int TechnoExt::ApplyForceWeaponInRange(AbstractClass* pTarget)
return forceWeaponIndex;
}

bool TechnoExt::MultiWeaponCanFire(TechnoClass* const pThis, AbstractClass* const pTarget, WeaponTypeClass* const pWeaponType)
bool TechnoExt::MultiWeaponCanFire(TechnoClass* const pThis, AbstractClass* const pTarget, WeaponTypeClass* const pWeaponType, const bool ignoreNeverUse)
{
if (!pWeaponType || pWeaponType->NeverUse
if (!pWeaponType
|| (!ignoreNeverUse && pWeaponType->NeverUse)
|| (pThis->InOpenToppedTransport && !pWeaponType->FireInTransport))
{
return false;
Expand Down
6 changes: 6 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,9 @@ void TechnoTypeExt::LoadFromINIFile(CCINIClass* const pINI)
this->DefaultToGuardArea_Modes.Read(exINI, pSection, "DefaultToGuardArea.Modes");
this->DefaultToGuardArea_AIModes.Read(exINI, pSection, "DefaultToGuardArea.AIModes");

this->NoAmmoWeapons.Read(exINI, pSection, "NoAmmoWeapons");
this->NoAmmoWeapons_IgnoreNeverUse.Read(exINI, pSection, "NoAmmoWeapons.IgnoreNeverUse");

// Ares 0.2
this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius");

Expand Down Expand Up @@ -1870,6 +1873,9 @@ void TechnoTypeExt::Serialize(T& Stm)
.Process(this->DefaultToGuardArea_Modes)
.Process(this->DefaultToGuardArea_AIModes)

.Process(this->NoAmmoWeapons)
.Process(this->NoAmmoWeapons_IgnoreNeverUse)

// Ares 0.2
.Process(this->RadarJamRadius)

Expand Down
6 changes: 6 additions & 0 deletions src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ class TechnoTypeExt : public ObjectTypeExt

ValueableVector<int> DefaultToGuardArea_Modes;
ValueableVector<int> DefaultToGuardArea_AIModes;

ValueableVector<int> NoAmmoWeapons;
Valueable<bool> NoAmmoWeapons_IgnoreNeverUse;

// Ares 0.2
Valueable<int> RadarJamRadius;
Expand Down Expand Up @@ -884,6 +887,9 @@ class TechnoTypeExt : public ObjectTypeExt
, DefaultToGuardArea_Modes {}
, DefaultToGuardArea_AIModes {}

, NoAmmoWeapons {}
, NoAmmoWeapons_IgnoreNeverUse { true }

// Ares 0.2
, RadarJamRadius { 0 }

Expand Down
Loading