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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Credits
- **secsome (SEC-SOME)** - debug info dump hotkey, refactoring & porting of Ares helper code, introducing more Ares-derived stuff, disguise removal warhead, Mind Control removal warhead, Mind Control enhancement, shields, AnimList.PickRandom, MoveToCell fix, unlimited waypoints, Build At trigger action buildup anim fix, Undeploy building into a unit plays `EVA_NewRallyPointEstablished` fix, custom ore gathering anim, TemporaryClass related crash, Retry dialog on mission failure, Default disguise for individual InfantryTypes, PowerPlant Enhancer, SaveGame Trigger Action, QuickSave command, Numeric variables, Custom gravity for projectiles, Retint map actions bugfix, Sharpnel enhancement
- **Otamaa (Fahroni, BoredEXE)** - help with CellSpread, ported and fixed custom RadType code, togglable ElectricBolt bolts, customizable Chrono Locomotor properties per TechnoClass, DebrisMaximums fixes, Anim-to-Unit, NotHuman anim sequences improvements, Customizable OpenTopped Properties, hooks for ScriptType Actions 92 & 93, ore stage threshold for `HideIfNoOre`, occupied building `MuzzleFlashX` bugfix,`EnemyUIName=` for other TechnoTypes, TerrainType `DestroyAnim` & `DestroySound`
- **E1 Elite** - TileSet 255 and above bridge repair fix
- **FS-21** - Dump Object Info enhancements, Powered.KillSpawns, Spawner.LimitRange, ScriptType Actions 71 to 113, MC deployer fixes, help with docs, Automatic Passenger Deletion, Fire SW At Location Trigger Action, Fire SW At Waypoint Trigger Action, Kill Object Automatically, Customize resource storage, Override Uncloaked Underwater attack behavior, AI Aircraft docks fix
- **FS-21** - Dump Object Info enhancements, Powered.KillSpawns, Spawner.LimitRange, ScriptType Actions 71 to 113, MC deployer fixes, help with docs, Automatic Passenger Deletion, Fire SW At Location Trigger Action, Fire SW At Waypoint Trigger Action, Kill Object Automatically, Customize resource storage, Override Uncloaked Underwater attack behavior, AI Aircraft docks fix, Shared Ammo
- **AutoGavy** - interceptor logic, warhead critical damage system, Customize resource storage
- **ChrisLv_CN** - interceptor logic, LaserTrails, laser fixes, general assistance (work relicensed under [following permission](images/ChrisLv-relicense.png))
- **Xkein** - general assistance, YRpp edits
Expand Down
18 changes: 18 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,24 @@ OpenTopped.DamageMultiplier=1.3 ; float
OpenTopped.WarpDistance=8 ; integer
```

### Shared Ammo

- Transports with `OpenTopped=yes` and `Ammo.Shared=yes` will transfer ammo to passengers that have `Ammo.Shared=yes`.
In addition, a transport can filter who will receive ammo if passengers have the same value in `Ammo.Shared.Group=<integer>` of the transport, ignoring other passengers with different groups values.
- Transports with `Ammo.Shared.Group=-1` will transfer ammo to any passenger with `Ammo.Shared=yes` ignoring the group.
- Transports must have ammo and should be able to reload ammo.

In `rulesmd.ini`:
```ini
[SOMETECHNO1] ; TechnoType, transport with OpenTopped=yes
Ammo.Shared=no ; boolean
Ammo.Shared.Group=-1 ; integer

[SOMETECHNO2] ; TechnoType, passenger
Ammo.Shared=no ; boolean
Ammo.Shared.Group=-1 ; integer
```

## Technos

### Mind Control enhancement
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ New:
- Trigger Action 506 for Firing at waypoint (by FS-21)
- New ways for self-killing objects under certaing cases (by FS-21)
- `ForceWeapon.Naval.Decloacked` for overriding uncloaked underwater attack behavior (by FS-21)
- Shared Ammo for transports to passengers (by FS-21)

Vanilla fixes:
- Fixed laser drawing code to allow for thicker lasers in house color draw mode (by Kerbiter, ChrisLv_CN)
Expand Down
41 changes: 41 additions & 0 deletions src/Ext/Techno/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,47 @@ void TechnoExt::CheckDeathConditions(TechnoClass* pThis)
}
}

void TechnoExt::UpdateSharedAmmo(TechnoClass* pThis)
{
if (!pThis)
return;

if (const auto pType = pThis->GetTechnoType())
{
if (pType->OpenTopped && pThis->Passengers.NumPassengers > 0)
{
if (const auto pExt = TechnoTypeExt::ExtMap.Find(pType))
{
if (pExt->Ammo_Shared && pType->Ammo > 0)
{
auto passenger = pThis->Passengers.FirstPassenger;
TechnoTypeClass* passengerType;

do
{
passengerType = passenger->GetTechnoType();
auto pPassengerExt = TechnoTypeExt::ExtMap.Find(passengerType);

if (pPassengerExt && pPassengerExt->Ammo_Shared)
{
if (pExt->Ammo_Shared_Group < 0 || pExt->Ammo_Shared_Group == pPassengerExt->Ammo_Shared_Group)
{
if (pThis->Ammo > 0 && (passenger->Ammo < passengerType->Ammo))
{
pThis->Ammo--;
passenger->Ammo++;
}
}
}

passenger = static_cast<FootClass*>(passenger->NextObject);
} while (passenger);
}
}
}
}
}

// =============================
// load / save

Expand Down
1 change: 1 addition & 0 deletions src/Ext/Techno/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class TechnoExt
static void CheckDeathConditions(TechnoClass* pThis);
static void ObjectKilledBy(TechnoClass* pThis, TechnoClass* pKiller);
static void EatPassengers(TechnoClass* pThis);
static void UpdateSharedAmmo(TechnoClass* pThis);

static bool CanFireNoAmmoWeapon(TechnoClass* pThis, int weaponIndex);
};
10 changes: 10 additions & 0 deletions src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,13 @@ DEFINE_HOOK(0x6F3428, TechnoClass_GetWeapon_ForceWeapon, 0x6)

return 0;
}

// Update ammo rounds
DEFINE_HOOK(0x6FB086, TechnoClass_Reload_ReloadAmount, 0x8)
{
GET(TechnoClass* const, pThis, ECX);

TechnoExt::UpdateSharedAmmo(pThis);

return 0;
}
4 changes: 4 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->EnemyUIName.Read(exINI, pSection, "EnemyUIName");

this->ForceWeapon_Naval_Decloaked.Read(exINI, pSection, "ForceWeapon.Naval.Decloaked");
this->Ammo_Shared.Read(exINI, pSection, "Ammo.Shared");
this->Ammo_Shared_Group.Read(exINI, pSection, "Ammo.Shared.Group");
}

template <typename T>
Expand Down Expand Up @@ -301,6 +303,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->DeployingAnim_UseUnitDrawer)
.Process(this->EnemyUIName)
.Process(this->ForceWeapon_Naval_Decloaked)
.Process(this->Ammo_Shared)
.Process(this->Ammo_Shared_Group)
;
}
void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)
Expand Down
5 changes: 5 additions & 0 deletions src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class TechnoTypeExt

Valueable<int> ForceWeapon_Naval_Decloaked;

Valueable<bool> Ammo_Shared;
Valueable<int> Ammo_Shared_Group;

struct LaserTrailDataEntry
{
ValueableIdx<LaserTrailTypeClass> idxType;
Expand Down Expand Up @@ -187,6 +190,8 @@ class TechnoTypeExt
, Death_NoAmmo { false }
, Death_Countdown { 0 }
, ForceWeapon_Naval_Decloaked { -1 }
, Ammo_Shared { false }
, Ammo_Shared_Group { -1 }
{ }

virtual ~ExtData() = default;
Expand Down