Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Burst projectile retargeting #1073

Open
wants to merge 41 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
dc865b2
First commit
FS-21 Jun 1, 2023
1506095
Merge branch 'develop' into feature/burst-retarget
FS-21 Jun 1, 2023
60cbebf
Added docs
FS-21 Jun 1, 2023
82dbb40
Removed comments
FS-21 Jun 1, 2023
9d7b854
Tweak
FS-21 Jun 4, 2023
ba2e450
v2.0 and tag rename
FS-21 Sep 4, 2023
a364fe9
Small changes
FS-21 Sep 4, 2023
ef93c81
Merge branch 'develop' into feature/burst-retarget
FS-21 Sep 22, 2023
1ea2d23
Point to latest YRpp
FS-21 Sep 22, 2023
2fd3455
Merge branch 'develop' into feature/burst-retarget
FS-21 Sep 25, 2023
ab1cb83
Fixes
FS-21 Oct 3, 2023
24b2cc1
tweak
FS-21 Oct 6, 2023
6f85473
tweak
FS-21 Oct 6, 2023
68296f9
Fix crash
FS-21 Oct 6, 2023
da32f58
tweak
FS-21 Oct 7, 2023
ea7d0e3
Merge branch 'develop' into feature/burst-retarget
FS-21 Nov 9, 2023
f32981b
Moved IsUnitAvailable() in TechnoExt
FS-21 Nov 11, 2023
d9e8c2a
tweaks
FS-21 Nov 11, 2023
12ffb72
Changed name of GetRandomTarget()
FS-21 Nov 11, 2023
54f327e
Tweaks based on feedback
FS-21 Nov 16, 2023
f83e32f
Merge remote-tracking branch 'origin/develop' into feature/burst-reta…
FS-21 Mar 10, 2024
24e0606
Merge remote-tracking branch 'origin/develop' into feature/burst-reta…
FS-21 Mar 10, 2024
9336b6c
fixed weird merge
FS-21 Mar 11, 2024
d84a418
Merge branch 'develop' into feature/burst-retarget
FS-21 Mar 12, 2024
1692452
Fix crashes
FS-21 Mar 23, 2024
d4d841c
Merge branch 'develop' into feature/burst-retarget
FS-21 Apr 27, 2024
e4a625b
Fix crashes
FS-21 Apr 29, 2024
a6ea99a
Merge branch 'develop' into feature/burst-retarget
FS-21 Aug 30, 2024
bb09eb0
Fix crash
FS-21 Aug 30, 2024
5677163
Merge branch 'develop' into feature/burst-retarget
FS-21 Aug 30, 2024
6d1ff8a
Merge branch 'develop' into feature/burst-retarget
FS-21 Oct 27, 2024
9f560b9
Merge branch 'develop' into feature/burst-retarget
FS-21 Oct 28, 2024
fac6454
Moved code into new files
FS-21 Oct 29, 2024
d32236f
Moving more code
FS-21 Oct 29, 2024
5ba91ae
Code rewrite
FS-21 Nov 1, 2024
f56ad67
Merge branch 'develop' into feature/burst-retarget
FS-21 Nov 1, 2024
c18b3c2
small fix
FS-21 Nov 1, 2024
8b60ea7
small doc fix
FS-21 Nov 1, 2024
32fc883
Small changes
FS-21 Feb 18, 2025
edb5977
tweak
FS-21 Feb 19, 2025
93e7fdd
tweak
FS-21 Feb 20, 2025
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 @@ -134,6 +134,7 @@ This page lists all the individual contributions to the project by their author.
- Customizable FLH when infantry is prone or deployed
- Initial strength for cloned infantry
- Map Events 604 & 605 for checking if a specific Techno enters in a cell
- `RandomTarget` for random projectile retargeting
- **Starkku**:
- Misc. minor bugfixes & improvements
- AI script actions:
Expand Down
4 changes: 4 additions & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\Ext\Techno\Body.RandomTarget.cpp" />
<ClCompile Include="src\Ext\Techno\Hooks.RandomTarget.cpp" />
<ClCompile Include="src\New\Entity\AttachEffectClass.cpp" />
<ClCompile Include="src\New\Type\AttachEffectTypeClass.cpp" />
<ClCompile Include="src\Commands\Commands.cpp" />
Expand Down Expand Up @@ -93,6 +95,7 @@
<ClCompile Include="src\Ext\Bullet\Body.cpp" />
<ClCompile Include="src\Ext\Bullet\Hooks.cpp" />
<ClCompile Include="src\Ext\Bullet\Hooks.Obstacles.cpp" />
<ClCompile Include="src\Ext\Event\Body.cpp" />
<ClCompile Include="src\Ext\House\Body.cpp" />
<ClCompile Include="src\Ext\House\Hooks.cpp" />
<ClCompile Include="src\Ext\House\Hooks.AINavalProduction.cpp" />
Expand Down Expand Up @@ -200,6 +203,7 @@
<ClInclude Include="src\Ext\Bullet\Trajectories\BombardTrajectory.h" />
<ClInclude Include="src\Ext\Bullet\Trajectories\PhobosTrajectory.h" />
<ClInclude Include="src\Ext\Bullet\Trajectories\StraightTrajectory.h" />
<ClInclude Include="src\Ext\Event\Body.h" />
<ClInclude Include="src\Ext\OverlayType\Body.h" />
<ClInclude Include="src\Ext\ParticleType\Body.h" />
<ClInclude Include="src\Ext\Sidebar\Body.h" />
Expand Down
16 changes: 16 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,22 @@ ExtraWarheads.DetonationChances= ; list of floating-point values (percentage or
ExtraWarheads.FullDetonation= ; list of booleans
```

### Projectile's random target
- The firer will pick targets randomly.
- Works with missiles (no splits, airbusts, etc), cannons, lasers & spawners.
- A valid techno is required for trigger the logic.
- `OmniFire=yes` will make selectable any targets around the firer, limited by the weapon range.
- `OmniFire=no` will force the firer to pick targets in an area composed by the firer's weapon range around the original target intersected with the firer's weapon range around the firer.
- `RandomTarget.Spawners.MultipleTargets=true` gives each spawner it's own target.
- This logic should be used only in one weapon of the object.

In `rulesmd.ini`:
```ini
[SOMEWEAPON] ; WeaponType
RandomTarget=0.0 ; double or percentage
RandomTarget.Spawners.MultipleTargets=false ; boolean
```

### Feedback weapon

![image](_static/images/feedbackweapon.gif)
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ New:
- Customizable straight trajectory detonation & snap distance and pass-through option (by Starkku)
- Airstrike & spy plane fixed spawn distance & height (by Starkku)
- Allow enabling application of `Verses` and `PercentAtMax` for negative damage (by Starkku)
- `RandomTarget` for assigning a new target in each projectile (by FS-21)
- In addition to `PlacementGrid.Translucency`, allow to set the transparency of the grid when PlacementPreview is enabled, using the `PlacementGrid.TranslucencyWithPreview` tag (by Belonit).
- Show briefing screen on singleplayer mission start (by Starkku)
- Allow setting mission par times and related messages in `missionmd.ini` (by Starkku)
Expand Down
12 changes: 6 additions & 6 deletions src/Ext/Event/Body.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
#include "Body.h"

#include <Ext/Techno/Body.h>

#include <Helpers/Macro.h>
#include <EventClass.h>

Expand All @@ -13,8 +14,8 @@ void EventExt::RespondEvent()
{
switch (this->Type)
{
case EventTypeExt::Sample:
// Place the handler here
case EventTypeExt::SyncStopRandomTargetTarNav:
TechnoExt::HandleStopRandomTargetTarNav(this);
break;
}
}
Expand All @@ -23,8 +24,8 @@ size_t EventExt::GetDataSize(EventTypeExt type)
{
switch (type)
{
case EventTypeExt::Sample:
return sizeof(EventExt::Sample);
case EventTypeExt::SyncStopRandomTargetTarNav:
return sizeof(EventExt::SyncStopRandomTargetTarNav);
}

return 0;
Expand Down Expand Up @@ -98,4 +99,3 @@ DEFINE_HOOK(0x64C30E, sub_64BDD0_GetEventSize2, 0x6)

return 0;
}
*/
16 changes: 8 additions & 8 deletions src/Ext/Event/Body.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#pragma once
/*
#include <cstddef>
#include <stdint.h>
#include <TechnoClass.h>
#include <FootClass.h>

enum class EventTypeExt : uint8_t
{
// Vanilla game used Events from 0x00 to 0x2F
// CnCNet reserved Events from 0x30 to 0x3F
// Ares used Events 0x60 and 0x61

Sample = 0x40, // Sample event, remove it when Phobos needs its own events
SyncStopRandomTargetTarNav = 0x49,

FIRST = Sample,
LAST = Sample
FIRST = SyncStopRandomTargetTarNav,
LAST = SyncStopRandomTargetTarNav
};

#pragma pack(push, 1)
Expand All @@ -27,10 +28,10 @@ class EventExt
{
char DataBuffer[104];

struct Sample
struct SyncStopRandomTargetTarNav
{
char DataBuffer[104];
} Sample;
int TechnoUniqueID;
} SyncStopRandomTargetTarNav;
};

bool AddEvent();
Expand All @@ -43,4 +44,3 @@ class EventExt
static_assert(sizeof(EventExt) == 111);
static_assert(offsetof(EventExt, DataBuffer) == 7);
#pragma pack(pop)
*/
8 changes: 4 additions & 4 deletions src/Ext/Script/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void ScriptExt::Mission_Gather_NearTheLeader(TeamClass* pTeam, int countdown = -
// Find the Leader
pLeaderUnit = pExt->TeamLeader;

if (!IsUnitAvailable(pLeaderUnit, true))
if (!ScriptExt::IsUnitAvailable(pLeaderUnit, true))
{
pLeaderUnit = FindTheTeamLeader(pTeam);
pExt->TeamLeader = pLeaderUnit;
Expand Down Expand Up @@ -454,7 +454,7 @@ void ScriptExt::Mission_Gather_NearTheLeader(TeamClass* pTeam, int countdown = -
// Check if units are around the leader
for (auto pUnit = pTeam->FirstUnit; pUnit; pUnit = pUnit->NextTeamMember)
{
if (!IsUnitAvailable(pUnit, true))
if (!ScriptExt::IsUnitAvailable(pUnit, true))
{
auto pTypeUnit = pUnit->GetTechnoType();

Expand Down Expand Up @@ -753,7 +753,7 @@ bool ScriptExt::MoveMissionEndStatus(TeamClass* pTeam, TechnoClass* pFocus, Foot
// Team already have a focused target
for (auto pUnit = pTeam->FirstUnit; pUnit; pUnit = pUnit->NextTeamMember)
{
if (IsUnitAvailable(pUnit, true)
if (ScriptExt::IsUnitAvailable(pUnit, true)
&& !pUnit->TemporalTargetingMe
&& !pUnit->BeingWarpedOut)
{
Expand Down Expand Up @@ -1085,7 +1085,7 @@ FootClass* ScriptExt::FindTheTeamLeader(TeamClass* pTeam)
// Find the Leader or promote a new one
for (auto pUnit = pTeam->FirstUnit; pUnit; pUnit = pUnit->NextTeamMember)
{
if (!IsUnitAvailable(pUnit, true) || !(pUnit->IsInitiated || pUnit->WhatAmI() == AbstractType::Aircraft))
if (!ScriptExt::IsUnitAvailable(pUnit, true) || !(pUnit->IsInitiated || pUnit->WhatAmI() == AbstractType::Aircraft))
continue;

// The team Leader will be used for selecting targets, if there are living Team Members then always exists 1 Leader.
Expand Down
14 changes: 7 additions & 7 deletions src/Ext/Script/Mission.Attack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void ScriptExt::Mission_Attack(TeamClass* pTeam, bool repeatAction = true, int c

pFocus = abstract_cast<TechnoClass*>(pTeam->Focus);

if (!IsUnitAvailable(pFocus, true))
if (!ScriptExt::IsUnitAvailable(pFocus, true))
{
pTeam->Focus = nullptr;
pFocus = nullptr;
Expand Down Expand Up @@ -115,7 +115,7 @@ void ScriptExt::Mission_Attack(TeamClass* pTeam, bool repeatAction = true, int c

for (auto pFoot = pTeam->FirstUnit; pFoot; pFoot = pFoot->NextTeamMember)
{
if (IsUnitAvailable(pFoot, true))
if (ScriptExt::IsUnitAvailable(pFoot, true))
{
auto const pTechnoType = pFoot->GetTechnoType();

Expand Down Expand Up @@ -143,7 +143,7 @@ void ScriptExt::Mission_Attack(TeamClass* pTeam, bool repeatAction = true, int c
// Find the Leader
pLeaderUnit = pTeamData->TeamLeader;

if (!IsUnitAvailable(pLeaderUnit, true))
if (!ScriptExt::IsUnitAvailable(pLeaderUnit, true))
{
pLeaderUnit = FindTheTeamLeader(pTeam);
pTeamData->TeamLeader = pLeaderUnit;
Expand Down Expand Up @@ -299,7 +299,7 @@ void ScriptExt::Mission_Attack(TeamClass* pTeam, bool repeatAction = true, int c
bool isAirOK = pFocus->IsInAir() && leaderWeaponsHaveAA;
bool isGroundOK = !pFocus->IsInAir() && leaderWeaponsHaveAG;

if (IsUnitAvailable(pFocus, true)
if (ScriptExt::IsUnitAvailable(pFocus, true)
&& !pFocus->GetTechnoType()->Immune
&& (isAirOK || isGroundOK)
&& (!pLeaderUnit->Owner->IsAlliedWith(pFocus) || IsUnitMindControlledFriendly(pLeaderUnit->Owner, pFocus)))
Expand All @@ -310,7 +310,7 @@ void ScriptExt::Mission_Attack(TeamClass* pTeam, bool repeatAction = true, int c
{
auto const pTechnoType = pFoot->GetTechnoType();

if (IsUnitAvailable(pFoot, true))
if (ScriptExt::IsUnitAvailable(pFoot, true))
{
// Aircraft case 1
if ((pFoot->WhatAmI() == AbstractType::Aircraft
Expand Down Expand Up @@ -486,7 +486,7 @@ TechnoClass* ScriptExt::GreatestThreat(TechnoClass* pTechno, int method, int cal
continue;

if (object != pTechno
&& IsUnitAvailable(object, true)
&& ScriptExt::IsUnitAvailable(object, true)
&& !objectType->Immune
&& !object->TemporalTargetingMe
&& !object->BeingWarpedOut
Expand Down Expand Up @@ -1168,7 +1168,7 @@ void ScriptExt::Mission_Attack_List1Random(TeamClass* pTeam, bool repeatAction,
auto const pFirstUnit = pTeam->FirstUnit;

if (pTechnoType == objectFromList
&& IsUnitAvailable(pTechno, true)
&& ScriptExt::IsUnitAvailable(pTechno, true)
&& (!pFirstUnit->Owner->IsAlliedWith(pTechno) || IsUnitMindControlledFriendly(pFirstUnit->Owner, pTechno)))
{
validIndexes.push_back(j);
Expand Down
8 changes: 4 additions & 4 deletions src/Ext/Script/Mission.Move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void ScriptExt::Mission_Move(TeamClass* pTeam, int calcThreatMode = 0, bool pick
// Find the Leader
pLeaderUnit = pTeamData->TeamLeader;

if (!IsUnitAvailable(pLeaderUnit, true))
if (!ScriptExt::IsUnitAvailable(pLeaderUnit, true))
{
pLeaderUnit = FindTheTeamLeader(pTeam);
pTeamData->TeamLeader = pLeaderUnit;
Expand Down Expand Up @@ -125,7 +125,7 @@ void ScriptExt::Mission_Move(TeamClass* pTeam, int calcThreatMode = 0, bool pick

auto const pTechnoType = pFoot->GetTechnoType();

if (IsUnitAvailable(pFoot, true))
if (ScriptExt::IsUnitAvailable(pFoot, true))
{
if (pTechnoType->Underwater && pTechnoType->LandTargeting == LandTargetingType::Land_Not_OK && selectedTarget->GetCell()->LandType != LandType::Water) // Land not OK for the Naval unit
{
Expand Down Expand Up @@ -264,7 +264,7 @@ TechnoClass* ScriptExt::FindBestObject(TechnoClass* pTechno, int method, int cal
}

if (object != pTechno
&& IsUnitAvailable(object, true)
&& ScriptExt::IsUnitAvailable(object, true)
&& ((pickAllies && pTechno->Owner->IsAlliedWith(object))
|| (!pickAllies && !pTechno->Owner->IsAlliedWith(object))))
{
Expand Down Expand Up @@ -407,7 +407,7 @@ void ScriptExt::Mission_Move_List1Random(TeamClass* pTeam, int calcThreatMode, b
auto objectFromList = objectsList[j];

if (pTechnoType == objectFromList
&& IsUnitAvailable(pTechno, true)
&& ScriptExt::IsUnitAvailable(pTechno, true)
&& ((pickAllies
&& pTeam->FirstUnit->Owner->IsAlliedWith(pTechno))
|| (!pickAllies
Expand Down
Loading