Skip to content

Commit

Permalink
Merge branch 'develop' into origin/branch/exclusive-sw-sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
NetsuNegi authored Jan 9, 2025
2 parents cb54e0e + 4071134 commit 8c27445
Show file tree
Hide file tree
Showing 11 changed files with 332 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ This page lists all the individual contributions to the project by their author.
- Ares' Abductor weapon fix
- Suppress Ares' swizzle warning when parsing tags and taskforces
- Better fix for Ares academy not working on the initial payloads of vehicles built from a war factory
- Fix Ares' InitialPayload for teams spawned by trigger actions
- Misc code refactor & maintenance, CN doc fixes, bugfixes
- **FlyStar**
- Campaign load screen PCX support
Expand Down Expand Up @@ -374,6 +375,8 @@ This page lists all the individual contributions to the project by their author.
- **CrimRecya**
- Fix `LimboKill` not working reliably
- Exclusive SuperWeapon Sidebar
- Allow using waypoints, area guard and attack move with aircraft
- Fix `Stop` command not working so well in some cases
- **Ollerus**
- Build limit group enhancement
- Customizable rocker amplitude
Expand Down Expand Up @@ -409,6 +412,7 @@ This page lists all the individual contributions to the project by their author.
- **thomassneddon** - general assistance, knowledge about voxel lighting model
- **Xkein** - general assistance, YRpp edits
- **mevitar** - honorary shield tester *triple* award
- **Phobos CN Tester Group (Reedom, Mantis, Swim Wing, Takitoru, Examon, AKB, Pusheen, ZQ, Claptrap, BunkerGeneral, Big J, Skywalker, ChickEmperor, Shifty, Mikain, Tobiichi Origami, Feiron, W_S502, Ailink, AbrahamMikhail, Tide, Fnfalsc, Yumeri_Rei, Nacho, Zhuzi, Ika_Aru)** - extensive and thorough testing
- **Damfoos** - extensive and thorough testing
- **Dmitry Volkov** - extensive and thorough testing
- **Rise of the East community** - extensive playtesting of in-dev features
Expand Down
2 changes: 1 addition & 1 deletion YRpp
15 changes: 15 additions & 0 deletions docs/Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,21 @@ git config --global branch.autoSetupRebase always
git config --global diff.colorMoved zebra
```

### Working with YRpp via submodules

Often when working on Phobos and/or researching the YR engine you'll need to implement corrections for YRpp. Generally the corrections need to be submitted to [YRpp repository](https://github.com/Phobos-developers/YRpp) and can be done separately from the actual features in Phobos, but frequently the improvements are to be submitted as a part of Phobos contribution process. To submit improvements to YRpp you have to create a branch in YRpp, then you can push it and submit a pull request to YRpp repository.

When you clone Phobos recursively - you also clone YRpp as a submodule. Basically submodules are just nested repositories. You can open it like any other repository, so the changes can be synchronized to Phobos and you don't need to rename stuff by hand.

The suggested workflow is as follows:
1. In your IDE of choice rename fields and functions using symbol renaming feature (`Rename...` feature in Visual Studio (regular or Code), `[F2]` by default), then you will have two "levels" of changes displayed in your Git client:
- for Phobos repository - changes in the Phobos code (as regular changes) and changes to YRpp (as one submodule change)
- for YRpp repository - changes to the field names and function names in YRpp as regular changes.
2. Create a branch in YRpp repository (create a fork of it if you didn't yet), commit and push the changes and submit it as a pull request. After pushing it you have two options in Phobos repository:
- wait until it's accepted, then checkout YRpp at the newest commit, then commit and push - this will save you having to commit and push multiple times, but you won't be able to get a nightly build for people to test;
- don't wait for YRpp changes to be merged, commit and push right after you pushed the YRpp changes to your YRpp branch - you will have an up-to-date build on Phobos pull request this way. Note that you must do this only after you committed to and pushed your YRpp branch, otherwise the build system won't know what are the changes as they are not exposed to the world, only available to you locally.
3. After the YRpp pull request gets accepted you will need to switch to the latest commit that was merged (you do that in the submodule), verify that it compiles like normal, and then commit and push it to your Phobos branch that you made for your pull request.

## Ways to help

Engine modding is a complicated process which is pretty hard to pull off, but there are also easier parts which don't require mastering the art of reverse-engineering or becoming a dank magician in C++.
Expand Down
23 changes: 22 additions & 1 deletion docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- `<Player @ X>` can now be used as owner for pre-placed objects on skirmish and multiplayer maps.
- Follower vehicle index for preplaced vehicles in maps is now explicitly constrained to `[Units]` list in map files and is no longer thrown off by vehicles that could not be created or created vehicles having other vehicles as initial passengers.
- Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix
- Stop command (`[S]` by default) behavior is now more correct:
- Jumpjets no longer fall into a state of standing by idly.
- Technos are no longer unable to stop the attack move mission.
- Technos are no longer unable to stop the area guard mission.
- Aircraft no longer find airport twice and overlap.
- Aircraft no longer briefly pause in the air before returning.
- Aircraft with `AirportBound=no` continue moving forward.
- Unit `Speed` setting now accepts floating-point values. Internally parsed values are clamped down to maximum of 100, multiplied by 256 and divided by 100, the result (which at this point is converted to an integer) then clamped down to maximum of 255 giving effective internal speed value range of 0 to 255, e.g leptons traveled per game frame.
- Subterranean movement now benefits from speed multipliers from all sources such as veterancy, AttachEffect etc.

Expand All @@ -192,7 +199,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- Fixed Ares' Abductor weapon leaves permanent placement stats when abducting moving vehicles.
- Suppressed Ares' swizzle warning when parsing `Tags` and `TaskForces` (typically begin with `[Developer fatal]Pointer 00000000 declared change to both`).
- Fixed Academy *(Ares feature)* not working on the initial payloads *(Ares feature)* of vehicles built from a war factory.

- Fixed Ares' InitialPayload not being created for vehicles spawned by trigger actions.
## Aircraft

### Carryall pickup voice
Expand Down Expand Up @@ -228,6 +235,20 @@ In `rulesmd.ini`:
LandingDir= ; Direction type (integers from 0-255). Accepts negative values as a special case.
```

### Extended Aircraft Missions

- Aircraft will now be able to use waypoints.
- When a `guard` command (`[G]` by default) is issued, the aircraft will search for targets around the current location and return immediately when target is not found, target is destroyed or ammos are depleted.
- If the target is destroyed but ammos are not depleted yet, it will also return because the aircraft's command is one-time.
- When an `attack move` command (`[Ctrl]+[Shift]`) is issued, the aircraft will move towards the destination and search for nearby targets on the route for attack. Once ammo is depleted or the destination is reached, it will return.
- If the automatically selected target is destroyed but ammo is not depleted yet during the process, the aircraft will continue flying to the destination.

In `rulesmd.ini`:
```ini
[General]
ExtendedAircraftMissions=false ; boolean
```

## Animations

### Animation weapon and damage settings
Expand Down
3 changes: 3 additions & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ New:
- Option for Warhead to remove all shield types at once (by Starkku)
- Allow customizing voxel light source position (by Kerbiter, Morton, based on knowledge of thomassnedon)
- Option to fix voxel light source being offset and incorrectly tilting on slopes (by Kerbiter)
- Allow using waypoints, area guard and attack move with aircraft (by CrimRecya)
- AI superweapon delay timer customization (by Starkku)
- Disabling `MultipleFactory` bonus from specific BuildingType (by Starkku)
- Customizable ChronoSphere teleport delays for units (by Starkku)
Expand Down Expand Up @@ -553,6 +554,7 @@ Vanilla fixes:
- Fixed objects with ally target and `AttackFriendlies=true` having their target reset every frame, particularly AI-owned buildings (by Starkku)
- Follower vehicle index for preplaced vehicles in maps is now explicitly constrained to `[Units]` list in map files and is no longer thrown off by vehicles that could not be created or created vehicles having other vehicles as initial passengers (by Starkku)
- Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix (by tyuah8)
- Fix `Stop` command not working so well in some cases (by CrimRecya)
- Subterranean movement now benefits from speed multipliers from all sources such as veterancy, AttachEffect etc. (by Starkku)
Phobos fixes:
Expand Down Expand Up @@ -612,6 +614,7 @@ Fixes / interactions with other extensions:
- Fixed Ares' Abductor weapon leaves permanent placement stats when abducting moving vehicles (by Trsdy)
- Suppressed Ares' swizzle warning when parsing `Tags` and `TaskForces` (by Trsdy)
- Fixed Academy *(Ares feature)* not working on the initial payloads *(Ares feature)* of vehicles built from a war factory (by Trsdy, supersedes Aephiex impl.)
- Fixed Ares' InitialPayload not being created for vehicles spawned by trigger actions (by Trsdy)
</details>
### 0.3.0.1
Expand Down
173 changes: 173 additions & 0 deletions src/Ext/Aircraft/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,179 @@ DEFINE_HOOK(0x415EEE, AircraftClass_Fire_KickOutPassengers, 0x6)
return SkipKickOutPassengers;
}

// Aircraft mission hard code are all disposable that no ammo, target died or arrived destination all will call the aircraft return airbase
#pragma region ExtendedAircraftMissions

// Waypoint: enable and smooth moving action
bool __fastcall AircraftTypeClass_CanUseWaypoint(AircraftTypeClass* pThis)
{
return RulesExt::Global()->ExtendedAircraftMissions.Get();
}
DEFINE_JUMP(VTABLE, 0x7E2908, GET_OFFSET(AircraftTypeClass_CanUseWaypoint))

// KickOut: skip useless tether
DEFINE_JUMP(LJMP, 0x444021, 0x44402E)

// Move: smooth the planning paths and returning route
DEFINE_HOOK_AGAIN(0x4168C7, AircraftClass_Mission_Move_SmoothMoving, 0x5)
DEFINE_HOOK(0x416A0A, AircraftClass_Mission_Move_SmoothMoving, 0x5)
{
enum { EnterIdleAndReturn = 0x416AC0, ContinueMoving1 = 0x416908, ContinueMoving2 = 0x416A47 };

GET(AircraftClass* const, pThis, ESI);
GET(CoordStruct* const, pCoords, EAX);

if (!RulesExt::Global()->ExtendedAircraftMissions)
return 0;

const auto pType = pThis->Type;

if (!pType->AirportBound || pThis->Team || pThis->Airstrike || pThis->Spawned)
return 0;

const int distance = Game::F2I(Point2D { pCoords->X, pCoords->Y }.DistanceFrom(Point2D { pThis->Location.X, pThis->Location.Y }));

// When the horizontal distance between the aircraft and its destination is greater than half of its deceleration distance
// or its turning radius, continue to move forward, otherwise return to airbase or execute the next planning path
if (distance > std::max((pType->SlowdownDistance >> 1), (2048 / pType->ROT)))
return (R->Origin() == 0x4168C7 ? ContinueMoving1 : ContinueMoving2);

pThis->EnterIdleMode(false, true);

return EnterIdleAndReturn;
}

// AreaGuard: return when no ammo or first target died
DEFINE_HOOK_AGAIN(0x41A982, AircraftClass_Mission_AreaGuard, 0x6)
DEFINE_HOOK(0x41A96C, AircraftClass_Mission_AreaGuard, 0x6)
{
enum { SkipGameCode = 0x41A97A };

GET(AircraftClass* const, pThis, ESI);

if (RulesExt::Global()->ExtendedAircraftMissions && !pThis->Team && pThis->Ammo && pThis->IsArmed())
{
auto coords = pThis->GetCoords();

if (pThis->TargetAndEstimateDamage(coords, ThreatType::Area))
{
pThis->QueueMission(Mission::Attack, false);
return SkipGameCode;
}
}

return 0;
}

// AttackMove: return when no ammo or arrived destination
bool __fastcall AircraftTypeClass_CanAttackMove(AircraftTypeClass* pThis)
{
return RulesExt::Global()->ExtendedAircraftMissions.Get();
}
DEFINE_JUMP(VTABLE, 0x7E290C, GET_OFFSET(AircraftTypeClass_CanAttackMove))

DEFINE_HOOK(0x6FA68B, TechnoClass_Update_AttackMovePaused, 0xA) // To make aircrafts not search for targets while resting at the airport, this is designed to adapt to loop waypoint
{
enum { SkipGameCode = 0x6FA6F5 };

GET(TechnoClass* const, pThis, ESI);

const bool skip = RulesExt::Global()->ExtendedAircraftMissions
&& pThis->WhatAmI() == AbstractType::Aircraft
&& (!pThis->Ammo || !pThis->IsInAir());

return skip ? SkipGameCode : 0;
}

DEFINE_HOOK(0x4DF3BA, FootClass_UpdateAttackMove_AircraftHoldAttackMoveTarget1, 0x6) // When it have MegaDestination
{
enum { LoseTarget = 0x4DF3D3, HoldTarget = 0x4DF4AB };

GET(FootClass* const, pThis, ESI);

// The aircraft is constantly moving, which may cause its target to constantly enter and leave its range, so it is fixed to hold the target.
if (RulesExt::Global()->ExtendedAircraftMissions && pThis->WhatAmI() == AbstractType::Aircraft)
return HoldTarget;

return pThis->InAuxiliarySearchRange(pThis->Target) ? HoldTarget : LoseTarget;
}

DEFINE_HOOK(0x4DF42A, FootClass_UpdateAttackMove_AircraftHoldAttackMoveTarget2, 0x6) // When it have MegaTarget
{
enum { ContinueCheck = 0x4DF462, HoldTarget = 0x4DF4AB };

GET(FootClass* const, pThis, ESI);

// Although if the target selected by CS is an object rather than cell.
return (RulesExt::Global()->ExtendedAircraftMissions && pThis->WhatAmI() == AbstractType::Aircraft) ? HoldTarget : ContinueCheck;
}

DEFINE_HOOK(0x418CD1, AircraftClass_Mission_Attack_ContinueFlyToDestination, 0x6)
{
enum { Continue = 0x418C43, Return = 0x418CE8 };

GET(AircraftClass* const, pThis, ESI);

if (!pThis->Target)
{
if (!RulesExt::Global()->ExtendedAircraftMissions || !pThis->MegaMissionIsAttackMove() || !pThis->MegaDestination)
return Continue;

pThis->SetDestination(pThis->MegaDestination, false);
pThis->QueueMission(Mission::Move, true);
pThis->HaveAttackMoveTarget = false;
}
else
{
pThis->MissionStatus = 1;
}

R->EAX(1);
return Return;
}

// Idle: clear the target if no ammo
DEFINE_HOOK(0x414D4D, AircraftClass_Update_ClearTargetIfNoAmmo, 0x6)
{
enum { ClearTarget = 0x414D3F };

GET(AircraftClass* const, pThis, ESI);

if (RulesExt::Global()->ExtendedAircraftMissions && !pThis->Ammo && !pThis->Airstrike && !pThis->Spawned)
{
if (!SessionClass::IsCampaign()) // To avoid AI's aircrafts team repeatedly attempting to attack the target when no ammo
{
if (const auto pTeam = pThis->Team)
pTeam->LiberateMember(pThis);
}

return ClearTarget;
}

return 0;
}

// Stop: clear the mega mission and return to airbase immediately
// (StopEventFix's DEFINE_HOOK(0x4C75DA, EventClass_RespondToEvent_Stop, 0x6) in Hooks.BugFixes.cpp)

// GreatestThreat: for all the mission that should let the aircraft auto select a target
AbstractClass* __fastcall AircraftClass_GreatestThreat(AircraftClass* pThis, void* _, ThreatType threatType, CoordStruct* pSelectCoords, bool onlyTargetHouseEnemy)
{
if (RulesExt::Global()->ExtendedAircraftMissions)
{
if (const auto pPrimaryWeapon = pThis->GetWeapon(0)->WeaponType)
threatType |= pPrimaryWeapon->AllowedThreats();

if (const auto pSecondaryWeapon = pThis->GetWeapon(1)->WeaponType)
threatType |= pSecondaryWeapon->AllowedThreats();
}

return pThis->FootClass::GreatestThreat(threatType, pSelectCoords, onlyTargetHouseEnemy);
}
DEFINE_JUMP(VTABLE, 0x7E2668, GET_OFFSET(AircraftClass_GreatestThreat))

#pragma endregion

static __forceinline bool CheckSpyPlaneCameraCount(AircraftClass* pThis)
{
auto const pExt = TechnoExt::ExtMap.Find(pThis);
Expand Down
3 changes: 3 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->HeightShadowScaling = false;
this->HeightShadowScaling_MinScale.Read(exINI, GameStrings::AudioVisual, "HeightShadowScaling.MinScale");

this->ExtendedAircraftMissions.Read(exINI, GameStrings::General, "ExtendedAircraftMissions");

this->AllowParallelAIQueues.Read(exINI, "GlobalControls", "AllowParallelAIQueues");
this->ForbidParallelAIQueues_Aircraft.Read(exINI, "GlobalControls", "ForbidParallelAIQueues.Aircraft");
this->ForbidParallelAIQueues_Building.Read(exINI, "GlobalControls", "ForbidParallelAIQueues.Building");
Expand Down Expand Up @@ -330,6 +332,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->AirShadowBaseScale_log)
.Process(this->HeightShadowScaling)
.Process(this->HeightShadowScaling_MinScale)
.Process(this->ExtendedAircraftMissions)
.Process(this->AllowParallelAIQueues)
.Process(this->ForbidParallelAIQueues_Aircraft)
.Process(this->ForbidParallelAIQueues_Building)
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class RulesExt
Valueable<double> HeightShadowScaling_MinScale;
double AirShadowBaseScale_log;

Valueable<bool> ExtendedAircraftMissions;

Valueable<bool> AllowParallelAIQueues;
Valueable<bool> ForbidParallelAIQueues_Aircraft;
Valueable<bool> ForbidParallelAIQueues_Building;
Expand Down Expand Up @@ -223,6 +225,8 @@ class RulesExt
, HeightShadowScaling_MinScale { 0.0 }
, AirShadowBaseScale_log { 0.693376137 }

, ExtendedAircraftMissions { false }

, AllowParallelAIQueues { true }
, ForbidParallelAIQueues_Aircraft { false }
, ForbidParallelAIQueues_Building { false }
Expand Down
26 changes: 23 additions & 3 deletions src/Ext/Team/Hooks.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
#include "Body.h"

#include <Utilities/AresHelper.h>

// Bugfix: TAction 7,80,107.
DEFINE_HOOK(0x65DF81, TeamTypeClass_CreateMembers_LoadOntoTransport, 0x7)
DEFINE_HOOK(0x65DF67, TeamTypeClass_CreateMembers_LoadOntoTransport, 0x6)
{
if(!AresHelper::CanUseAres) // If you're not using Ares you don't deserve a fix
return 0;

GET(FootClass* const, pPayload, EAX);
GET(FootClass* const, pTransport, ESI);
GET(TeamClass* const, pTeam, EBP);
GET(TeamTypeClass const*, pThis, EBX);

auto unmarkPayloadCreated = [](FootClass* member){reinterpret_cast<char*>(member->align_154)[0x9E] = false;};

if (!pTransport)
{
for (auto pNext = pPayload;
pNext && pNext != pTransport && pNext->Team == pTeam;
pNext = abstract_cast<FootClass*>(pNext->NextObject))
unmarkPayloadCreated(pNext);

return 0x65DFE8;
}

unmarkPayloadCreated(pTransport);

if (!pPayload || !pThis->Full)
return 0x65E004;

const bool isTransportOpenTopped = pTransport->GetTechnoType()->OpenTopped;
FootClass* pGunner = nullptr;
Expand All @@ -29,6 +50,5 @@ DEFINE_HOOK(0x65DF81, TeamTypeClass_CreateMembers_LoadOntoTransport, 0x7)
if (pTransport->GetTechnoType()->Gunner && pGunner)
pTransport->ReceiveGunner(pGunner);

// Ares' CreateInitialPayload doesn't work here
return 0x65DF8D;
}
4 changes: 3 additions & 1 deletion src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ DEFINE_HOOK(0x6F9FA9, TechnoClass_AI_PromoteAnim, 0x6)
promAnim = GameCreate<AnimClass>(RulesExt::Global()->Promote_VeteranAnimation, pThis->GetCenterCoords());
else if (RulesExt::Global()->Promote_EliteAnimation)
promAnim = GameCreate<AnimClass>(RulesExt::Global()->Promote_EliteAnimation, pThis->GetCenterCoords());
promAnim->SetOwnerObject(pThis);

if(promAnim)
promAnim->SetOwnerObject(pThis);
}

return aresProcess();
Expand Down
Loading

0 comments on commit 8c27445

Please sign in to comment.