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
5 changes: 5 additions & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
<ClCompile Include="src\Ext\WarheadType\Detonate.cpp" />
<ClCompile Include="src\Ext\Techno\Hooks.Shield.cpp" />
<ClCompile Include="src\Ext\Techno\Hooks.Grinding.cpp" />
<ClCompile Include="src\Ext\VoxelAnimType\Body.cpp" />
<ClCompile Include="src\Ext\VoxelAnim\Body.cpp" />
<ClCompile Include="src\Ext\VoxelAnim\Hooks.cpp" />
<ClCompile Include="src\Ext\WeaponType\Body.cpp" />
<ClCompile Include="src\Ext\WeaponType\Hook.EBolt.cpp" />
<ClCompile Include="src\Ext\WeaponType\Hooks.cpp" />
Expand Down Expand Up @@ -141,6 +144,8 @@
<ClInclude Include="src\Ext\TechnoType\Body.h" />
<ClInclude Include="src\Ext\Techno\Body.h" />
<ClInclude Include="src\Ext\TerrainType\Body.h" />
<ClInclude Include="src\Ext\VoxelAnimType\Body.h" />
<ClInclude Include="src\Ext\VoxelAnim\Body.h" />
<ClInclude Include="src\Ext\WeaponType\Body.h" />
<ClInclude Include="src\Utilities\Savegame.h" />
<ClInclude Include="src\Utilities\SavegameDef.h" />
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Credits
- **wiktorderelf** - overhauled Unicode font
- **Uranusian (Thrifinesma)** - Mind Control enhancement, custom warhead splash list, harvesters counter, promoted spawns, shields, death after dead fix, customizeable missing cameo, cameo sorting priority, placement mode responding of tab hotkeys fix, producing progress, custom ore gathering anim, NoManualMove, weapon target house filtering, DeathWeapon fix, re-enable obsolete `JumpjetControls`, AITrigger Building Upgrades recognition, Wall-Gate links, deployed infantry using both weapons, overhauled Unicode font, docs maintenance, CN docs translation
- **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`
- **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`, Laser trails for VoxelAnims
- **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, Shared Ammo
- **AutoGavy** - interceptor logic, Warhead critical hit logic, Customize resource storage
Expand Down
10 changes: 8 additions & 2 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ Shield.InheritStateOnReplace=false ; boolean
![Laser Trails](_static/images/lasertrails.gif)
*Laser trails used in [Rise of the East](https://www.moddb.com/mods/riseoftheeast)*

- Technos and projectiles can now have colorful trails of different transparency, thickness and color, which are drawn via laser drawing code.
- Technos and projectiles can have multiple laser trails. For technos each trail can have custom laser trail type and FLH offset relative to turret and body.
- Technos, Projectiles, and VoxelAnims can now have colorful trails of different transparency, thickness and color, which are drawn via laser drawing code.
- Technos, Projectiles, and VoxelAnims can have multiple laser trails. For technos each trail can have custom laser trail type and FLH offset relative to turret and body.

```{warning}
Laser trails are very resource intensive! Due to the game not utilizing GPU having a lot of trails can quickly drop the FPS on even good machines. To reduce that effect:
Expand Down Expand Up @@ -146,6 +146,12 @@ LaserTrailN.IsOnTurret=no ; boolean, whether the trail origin is turret
; where N = 0, 1, 2, ...
```

in `rulesmd.ini`:
```ini
[SOMEVOXELANIM] ; VoxelAnim
LaserTrail.Types=SOMETRAIL ; list of LaserTrailTypes
```

### Custom Radiation Types

![image](_static/images/radtype-01.png)
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ New:
- `ForceWeapon.Naval.Decloacked` for overriding uncloaked underwater attack behavior (by FS-21)
- Shared Ammo for transports to passengers (by FS-21)
- Additional critical hit logic customizations (by Starkku)
- Laser trails for VoxelAnims (by Otamaa)

Vanilla fixes:
- Fixed laser drawing code to allow for thicker lasers in house color draw mode (by Kerbiter, ChrisLv_CN)
Expand Down
114 changes: 114 additions & 0 deletions src/Ext/VoxelAnim/Body.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#include "Body.h"
#include <Ext/VoxelAnimType/Body.h>
#include <New/Entity/LaserTrailClass.h>

template<> const DWORD Extension<VoxelAnimClass>::Canary = 0xAAAAAACC;
VoxelAnimExt::ExtContainer VoxelAnimExt::ExtMap;

void VoxelAnimExt::InitializeLaserTrails(VoxelAnimClass* pThis)
{
auto pThisExt = VoxelAnimExt::ExtMap.Find(pThis);
auto pTypeExt = VoxelAnimTypeExt::ExtMap.Find(pThis->Type);

if (pThisExt->LaserTrails.size())
return;

for (auto const& idxTrail : pTypeExt->LaserTrail_Types)
{
if (auto const pLaserType = LaserTrailTypeClass::Array[idxTrail].get())
{
pThisExt->LaserTrails.push_back(std::make_unique<LaserTrailClass>
(pLaserType, pThis->OwnerHouse));
}
}
}

void VoxelAnimExt::ExtData::Initialize() {}

// =============================
// load / save
template <typename T>
void VoxelAnimExt::ExtData::Serialize(T& Stm)
{
Stm
.Process(LaserTrails)
;
}

void VoxelAnimExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)
{
Extension<VoxelAnimClass>::LoadFromStream(Stm);
this->Serialize(Stm);
}

void VoxelAnimExt::ExtData::SaveToStream(PhobosStreamWriter& Stm)
{
Extension<VoxelAnimClass>::SaveToStream(Stm);
this->Serialize(Stm);
}

void VoxelAnimExt::ExtContainer::InvalidatePointer(void* ptr, bool bRemoved) {}

bool VoxelAnimExt::LoadGlobals(PhobosStreamReader& Stm)
{
return Stm
.Success();
}

bool VoxelAnimExt::SaveGlobals(PhobosStreamWriter& Stm)
{
return Stm
.Success();
}

// =============================
// container

VoxelAnimExt::ExtContainer::ExtContainer() : Container("VoxelAnimClass") {}
VoxelAnimExt::ExtContainer::~ExtContainer() = default;

// =============================
// container hooks

//DEFINE_HOOK(0x749951, VoxelAnimClass_CTOR, 0xC)
DEFINE_HOOK(0x74942E, VoxelAnimClass_CTOR, 0xC)
{
GET(VoxelAnimClass*, pItem, ESI);

VoxelAnimExt::ExtMap.FindOrAllocate(pItem);
VoxelAnimExt::InitializeLaserTrails(pItem);

return 0;
}

DEFINE_HOOK(0x7499F1, VoxelAnimClass_DTOR, 0x5)
{
GET(VoxelAnimClass*, pItem, ECX);

VoxelAnimExt::ExtMap.Remove(pItem);

return 0;
}

DEFINE_HOOK_AGAIN(0x74A970, VoxelAnimClass_SaveLoad_Prefix, 0x5)
DEFINE_HOOK(0x74AA10, VoxelAnimClass_SaveLoad_Prefix, 0x8)
{
GET_STACK(VoxelAnimClass*, pItem, 0x4);
GET_STACK(IStream*, pStm, 0x8);

VoxelAnimExt::ExtMap.PrepareStream(pItem, pStm);

return 0;
}

DEFINE_HOOK(0x74A9FB, VoxelAnimClass_Load_Suffix, 0x5)
{
VoxelAnimExt::ExtMap.LoadStatic();
return 0;
}

DEFINE_HOOK(0x74AA24, VoxelAnimClass_Save_Suffix, 0x5)
{
VoxelAnimExt::ExtMap.SaveStatic();
return 0;
}
54 changes: 54 additions & 0 deletions src/Ext/VoxelAnim/Body.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#pragma once

#include <VoxelAnimClass.h>

#include <Utilities/Container.h>
#include <Utilities/Constructs.h>
#include <Utilities/Template.h>
#include <Utilities/TemplateDef.h>
#include <Utilities/Debug.h>

#include <Helpers/Macro.h>

#include <New/Entity/LaserTrailClass.h>

class VoxelAnimExt
{
public:
using base_type = VoxelAnimClass;

class ExtData final : public Extension<VoxelAnimClass>
{
public:

ValueableVector<std::unique_ptr<LaserTrailClass>> LaserTrails;

ExtData(VoxelAnimClass* OwnerObject) : Extension<VoxelAnimClass>(OwnerObject)
, LaserTrails()
{ }

virtual ~ExtData() = default;
virtual size_t Size() const { return sizeof(*this); };
virtual void InvalidatePointer(void *ptr, bool bRemoved) override {}
virtual void LoadFromStream(PhobosStreamReader& Stm)override;
virtual void SaveToStream(PhobosStreamWriter& Stm)override;
virtual void Initialize() override;

private:
template <typename T>
void Serialize(T& Stm);
};

class ExtContainer final : public Container<VoxelAnimExt>
{
public:
ExtContainer();
~ExtContainer();
virtual void InvalidatePointer(void* ptr, bool bRemoved) override;
};

static ExtContainer ExtMap;
static void InitializeLaserTrails(VoxelAnimClass* pThis);
static bool LoadGlobals(PhobosStreamReader& Stm);
static bool SaveGlobals(PhobosStreamWriter& Stm);
};
29 changes: 29 additions & 0 deletions src/Ext/VoxelAnim/Hooks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "Body.h"

#include <Ext/VoxelAnimType/Body.h>

DEFINE_HOOK(0x74A70E, VoxelAnimClass_AI_Additional, 0xC)
{
GET(VoxelAnimClass* const, pThis, EBX);

//auto pTypeExt = VoxelAnimTypeExt::ExtMap.Find(pThis->Type);
auto pThisExt = VoxelAnimExt::ExtMap.Find(pThis);

if (!pThisExt->LaserTrails.empty())
{
CoordStruct location = pThis->GetCoords();
CoordStruct drawnCoords = location;

for (auto const& trail : pThisExt->LaserTrails)
{
if (!trail->LastLocation.isset())
trail->LastLocation = location;

trail->Visible = pThis->IsVisible;
trail->Update(drawnCoords);

}
}

return 0;
}
111 changes: 111 additions & 0 deletions src/Ext/VoxelAnimType/Body.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include "Body.h"


template<> const DWORD Extension<VoxelAnimTypeClass>::Canary = 0xAAAEEEEE;
VoxelAnimTypeExt::ExtContainer VoxelAnimTypeExt::ExtMap;
void VoxelAnimTypeExt::ExtData::Initialize() {}

void VoxelAnimTypeExt::ExtData::LoadFromINIFile(CCINIClass* pINI)
{
const char* pID = this->OwnerObject()->ID;
INI_EX exINI(pINI);

this->LaserTrail_Types.Read(exINI, pID, "LaserTrail.Types");
}

// =============================
// load / save
template <typename T>
void VoxelAnimTypeExt::ExtData::Serialize(T& Stm)
{
Stm
.Process(LaserTrail_Types)
;
}

void VoxelAnimTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)
{
Extension<VoxelAnimTypeClass>::LoadFromStream(Stm);
this->Serialize(Stm);
}

void VoxelAnimTypeExt::ExtData::SaveToStream(PhobosStreamWriter& Stm)
{
Extension<VoxelAnimTypeClass>::SaveToStream(Stm);
this->Serialize(Stm);
}

void VoxelAnimTypeExt::ExtContainer::InvalidatePointer(void* ptr, bool bRemoved) {}

bool VoxelAnimTypeExt::LoadGlobals(PhobosStreamReader& Stm)
{
return Stm
.Success();
}

bool VoxelAnimTypeExt::SaveGlobals(PhobosStreamWriter& Stm)
{
return Stm
.Success();
}

// =============================
// container

VoxelAnimTypeExt::ExtContainer::ExtContainer() : Container("VoxelVoxelAnimTypeClass") {}
VoxelAnimTypeExt::ExtContainer::~ExtContainer() = default;

// =============================
// container hooks

DEFINE_HOOK(0x74AEB0, VoxelAnimTypeClass_CTOR, 0xB)
{
GET(VoxelAnimTypeClass*, pItem, ESI);

VoxelAnimTypeExt::ExtMap.FindOrAllocate(pItem);
return 0;
}

DEFINE_HOOK(0x74BA31, VoxelAnimTypeClass_DTOR, 0x5)
{
GET(VoxelAnimTypeClass*, pItem, ECX);

VoxelAnimTypeExt::ExtMap.Remove(pItem);
return 0;
}

DEFINE_HOOK_AGAIN(0x74B810, VoxelAnimTypeClass_SaveLoad_Prefix, 0x5)
DEFINE_HOOK(0x74B8D0, VoxelAnimTypeClass_SaveLoad_Prefix, 0x8)
{
GET_STACK(VoxelAnimTypeClass*, pItem, 0x4);
GET_STACK(IStream*, pStm, 0x8);

VoxelAnimTypeExt::ExtMap.PrepareStream(pItem, pStm);

return 0;
}

DEFINE_HOOK(0x74B8C2, VoxelAnimTypeClass_Load_Suffix, 0x5)
{
VoxelAnimTypeExt::ExtMap.LoadStatic();
return 0;
}

DEFINE_HOOK(0x74B8EA, VoxelAnimTypeClass_Save_Suffix, 0x5)
{
VoxelAnimTypeExt::ExtMap.SaveStatic();
return 0;
}

DEFINE_HOOK_AGAIN(0x74B607, VoxelAnimTypeClass_LoadFromINI, 0x5)
DEFINE_HOOK_AGAIN(0x74B561, VoxelAnimTypeClass_LoadFromINI, 0x5)
DEFINE_HOOK_AGAIN(0x74B54A, VoxelAnimTypeClass_LoadFromINI, 0x5)
DEFINE_HOOK_AGAIN(0x74B51B, VoxelAnimTypeClass_LoadFromINI, 0x5)
DEFINE_HOOK(0x74B4F0, VoxelAnimTypeClass_LoadFromINI, 0x5)
{
GET(VoxelAnimTypeClass*, pItem, ESI);
GET_STACK(CCINIClass*, pINI, 0x4);

VoxelAnimTypeExt::ExtMap.LoadFromINI(pItem, pINI);
return 0;
}
Loading