Skip to content

Commit

Permalink
Merge remote-tracking branch 'Phobos-Developers/develop' into random-…
Browse files Browse the repository at this point in the history
…anims
  • Loading branch information
MortonPL committed Sep 24, 2024
2 parents 0f30f2d + fca5e1f commit 3dfad0a
Show file tree
Hide file tree
Showing 34 changed files with 463 additions and 209 deletions.
3 changes: 3 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This page lists all the individual contributions to the project by their author.
- Non-ASCII input fix
- Building Placement Preview Adjustment
- Check for Changelog/Documentation/Credits in Pull Requests
- Docs dark theme switcher
- Fix position and layer of info tip and reveal production cameo on selected building
- Fix a glitch related to incorrect target setting for missiles
- Ability to disable shadow for debris & meteor animations
Expand Down Expand Up @@ -327,6 +328,8 @@ This page lists all the individual contributions to the project by their author.
- Forbidding parallel AI queues by type
- Jumpjet crash speed fix when crashing onto building
- Disguised units not using the correct palette if target has custom palette bugfix
- Tunnel/Walk/Mech locomotor being stuck when moving too fast bugfix
- Assign Super Weapon cameo to any sidebar tab
- **Apollo** - Translucent SHP drawing patches
- **ststl**
- Customizable ShowTimer priority of superweapons
Expand Down
2 changes: 1 addition & 1 deletion YRpp
Submodule YRpp updated 2 files
+8 −0 AnimClass.h
+34 −34 ControlClass.h
4 changes: 3 additions & 1 deletion docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- The otherwise unused setting `[AI]` -> `PowerSurplus` (defaults to 50) which determines how much surplus power AI players will strive to have can be restored by setting `[AI]` -> `EnablePowerSurplus` to true.
- Planning paths are now shown for all units under player control or when `[GlobalControls]->DebugPlanningPaths=yes` in singleplayer game modes.
- Fixed `Temporal=true` Warheads potentially crashing game if used to attack `Slaved=true` infantry.
- Fixed some locomotors (Tunnel, Walk, Mech) getting stuck when moving too fast.
- Animations with `MakeInfantry` and `UseNormalLight=false` that are drawn in unit palette will now have cell lighting changes applied on them (by Starkku)

## Fixes / interactions with other extensions

Expand Down Expand Up @@ -473,7 +475,7 @@ Pips.SelfHeal.Units.Offset=33,-32 ; X,Y, pixels relative to default
Pips.SelfHeal.Buildings.Offset=15,10 ; X,Y, pixels relative to default

[SOMETECHNO] ; TechnoType
SelfHealGainType= ; Self-Heal Gain Type Enumeration (none|infantry|units)
SelfHealGainType= ; Self-Heal Gain Type Enumeration (noheal|infantry|units)
```

### Chrono sparkle animation customization & improvements
Expand Down
15 changes: 14 additions & 1 deletion docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ This page describes all the engine features that are either new and introduced b
- `Animation.TemporalAction` determines what happens to the animation when the attached object is under effect of `Temporal=true` Warhead.
- `Animation.UseInvokerAsOwner` can be used to set the house and TechnoType that created the effect (e.g firer of the weapon that applied it) as the animation's owner & invoker instead of the object the effect is attached to.
- `Animation.HideIfAttachedWith` contains list of other AttachEffectTypes that if attached to same techno as the current one, will hide this effect's animation.
- `CumulativeAnimations` can be used to declare a list of animations used for `Cumulative=true` types instead of `Animation`. An animation is picked from the list in order matching the number of active instances of the type on the object, with last listed animation used if number is higher than the number of listed animations. This animation is only displayed once, on the first active instance of the effect found attached and is updated and restarted if the number of active instances changed.
- `CumulativeAnimations` can be used to declare a list of animations used for `Cumulative=true` types instead of `Animation`. An animation is picked from the list in order matching the number of active instances of the type on the object, with last listed animation used if number is higher than the number of listed animations. This animation is only displayed once and is transferred from the effect to another of same type (specifically one with longest remaining duration), if such exists, upon expiration or removal. Note that because `Cumulative.MaxCount` limits the number of effects of same type that can be applied this can cause animations to 'flicker' here as effects expire before new ones can be applied in some circumstances.
- `CumulativeAnimations.RestartOnChange` determines if the animation playback is restarted when the type of animation changes, if not then playback resumes at frame at same position relative to the animation's length.
- Attached effect can fire off a weapon when expired / removed / object dies by setting `ExpireWeapon`.
- `ExpireWeapon.TriggerOn` determines the exact conditions upon which the weapon is fired, defaults to `expire` which means only if the effect naturally expires.
- `ExpireWeapon.CumulativeOnlyOnce`, if set to true, makes it so that `Cumulative=true` attached effects only detonate the weapon once period, instead of once per active instance. On `remove` and `expire` condition this means it will only detonate after last instance has expired or been removed.
Expand Down Expand Up @@ -90,6 +91,7 @@ Animation.TemporalAction=None ; AttachedAnimFlag (None, Hides,
Animation.UseInvokerAsOwner=false ; boolean
Animation.HideIfAttachedWith= ; List of AttachEffectTypes
CumulativeAnimations= ; list of animations
CumulativeAnimations.RestartOnChange=true ; boolean
ExpireWeapon= ; WeaponType
ExpireWeapon.TriggerOn=expire ; List of expire weapon trigger condition enumeration (none|expire|remove|death|all)
ExpireWeapon.CumulativeOnlyOnce=false ; boolean
Expand Down Expand Up @@ -877,6 +879,17 @@ Detonate.Damage= ; integer
Detonate.AtFirer=false ; boolean
```

### Customize SuperWeapon TabIndex

- You can now assign a Super Weapon's cameo to any sidebar tab using `TabIndex`.
- Valid values are: 0 (buildings tab), 1 (arsenal tab), 2 (infantry tab), 3 (vehicle tab).

In `rulesmd.ini`:
```ini
[SOMESW] ; Super Weapon
TabIndex=1 ; integer
```

## Technos

### Aircraft spawner customizations
Expand Down
5 changes: 5 additions & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ You can use the migration utility (can be found on [Phobos supplementaries repo]

#### From post-0.3 devbuilds

- `SelfHealGainType` value `none` has been changed to `noheal` due to `none` being treated as a blank string and not parsed by the game.
- Affected target enum (`CanTarget`, `Crit.Affects` et al) now considers buildings considered vehicles (`ConsideredVehicle=true` or not set in conjunction with `UndeploysInto` & 1x1 foundation) as units instead of buildings.
- If `CreateUnit.AlwaysSpawnOnGround` is set to false, jumpjet vehicles created will now automatically take off instead of staying on ground. Set to true to force spawn on ground.
- Digital display `Offset` and `Offset.ShieldDelta` Y-axis coordinates now work in inverted fashion (negative goes up, positive goes down) to be consistent with how pixel offsets work elsewhere in the game.
Expand Down Expand Up @@ -451,6 +452,7 @@ New:
- Nonprovocative Warheads (by Starkku)
- Option to restore `PowerSurplus` setting for AI (by Starkku)
- `FireOnce` infantry sequence reset toggle (by Starkku)
- Assign Super Weapon cameo to any sidebar tab (by NetsuNegi)
Vanilla fixes:
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
Expand Down Expand Up @@ -523,6 +525,8 @@ Vanilla fixes:
- Building upgrades now consistently use building's `PowerUpN` animation settings corresponding to the upgrade's `PowersUpToLevel` where possible (by Starkku)
- Subterranean units are no longer allowed to perform deploy functions like firing weapons or `IsSimpleDeployer` while burrowed or burrowing, they will instead emerge first like they do for transport unloading (by Starkku)
- Fixed `Temporal=true` Warheads potentially crashing game if used to attack `Slaved=true` infantry (by Starkku)
- Fixed some locomotors (Tunnel, Walk, Mech) getting stuck when moving too fast (by NetsuNegi)
- Animations with `MakeInfantry` and `UseNormalLight=false` that are drawn in unit palette will now have cell lighting changes applied on them (by Starkku)
Phobos fixes:
- Fixed a few errors of calling for superweapon launch by `LaunchSW` or building infiltration (by Trsdy)
Expand Down Expand Up @@ -565,6 +569,7 @@ Phobos fixes:
- Buildings considered vehicles (`ConsideredVehicle=true` or not set in conjunction with `UndeploysInto` & 1x1 foundation) are now considered units by affected target enum checks (by Starkku)
- Fixed Phobos Warhead effects not reliably being applied on damage area as opposed to full weapon-based Warhead detonation (by Starkku)
- Fix `LimboKill` not working reliably (by CrimRecya)
- Fixed `SelfHealGainType=none` not working (changed to `noheal`) (by Starkku)
Fixes / interactions with other extensions:
- `IsSimpleDeployer` units with Hover locomotor and `DeployToLand` no longer get stuck after deploying or play their move sound indefinitely (by Starkku)
Expand Down
50 changes: 50 additions & 0 deletions src/Ext/Anim/Body.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "Body.h"

#include <GameOptionsClass.h>

#include <Ext/AnimType/Body.h>
#include <Ext/House/Body.h>
#include <Ext/WarheadType/Body.h>
Expand Down Expand Up @@ -130,6 +132,54 @@ void AnimExt::VeinAttackAI(AnimClass* pAnim)
}
}

// Changes type of anim in similar fashion to Next.
void AnimExt::ChangeAnimType(AnimClass* pAnim, AnimTypeClass* pNewType, bool resetLoops, bool restart)
{
double percentThrough = pAnim->Animation.Value / static_cast<double>(pAnim->Type->End);

if (pNewType->End == -1)
{
pNewType->End = pNewType->GetImage()->Frames;

if (pNewType->Shadow)
pNewType->End /= 2;
}

if (pNewType->LoopEnd == -1)
{
pNewType->LoopEnd = pNewType->End;
}

pAnim->Type = pNewType;

if (resetLoops)
pAnim->RemainingIterations = static_cast<byte>(pNewType->LoopCount);

pAnim->Accum = 0;
pAnim->UnableToContinue = false;
pAnim->Reverse = pNewType->Reverse;

int rate = pNewType->Rate;

if (pNewType->RandomRate.Min || pNewType->RandomRate.Max)
rate = ScenarioClass::Instance->Random.RandomRanged(pNewType->RandomRate.Min, pNewType->RandomRate.Max);

if (pNewType->Normalized)
rate = GameOptionsClass::Instance->GetAnimSpeed(rate);

pAnim->Animation.Start(rate, pNewType->Reverse ? -1 : 1);

if (restart)
{
pAnim->Animation.Value = pNewType->Reverse ? pNewType->End : pNewType->Start;
pAnim->Start();
}
else
{
pAnim->Animation.Value = static_cast<int>(pNewType->End * percentThrough);
}
}

void AnimExt::HandleDebrisImpact(AnimTypeClass* pExpireAnim, AnimTypeClass* pWakeAnim, Iterator<AnimTypeClass*> splashAnims, HouseClass* pOwner, WarheadTypeClass* pWarhead, int nDamage,
CellClass* pCell, CoordStruct nLocation, bool heightFlag, bool isMeteor, bool warheadDetonate, bool explodeOnWater, bool splashAnimsPickRandom)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Ext/Anim/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ class AnimExt

static bool SetAnimOwnerHouseKind(AnimClass* pAnim, HouseClass* pInvoker, HouseClass* pVictim, bool defaultToVictimOwner = true, bool defaultToInvokerOwner = false);
static HouseClass* GetOwnerHouse(AnimClass* pAnim, HouseClass* pDefaultOwner = nullptr);

static void VeinAttackAI(AnimClass* pAnim);

static void ChangeAnimType(AnimClass* pAnim, AnimTypeClass* pNewType, bool resetLoops, bool restart);
static void HandleDebrisImpact(AnimTypeClass* pExpireAnim, AnimTypeClass* pWakeAnim, Iterator<AnimTypeClass*> splashAnims, HouseClass* pOwner, WarheadTypeClass* pWarhead, int nDamage,
CellClass* pCell, CoordStruct nLocation, bool heightFlag, bool isMeteor, bool warheadDetonate, bool explodeOnWater, bool splashAnimsPickRandom);

Expand Down
17 changes: 17 additions & 0 deletions src/Ext/Anim/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,23 @@ DEFINE_HOOK(0x423365, AnimClass_DrawIt_ExtraShadow, 0x8)
return SkipExtraShadow;
}

// Apply cell lighting on UseNormalLight=no MakeInfantry anims.
DEFINE_HOOK(0x4232BF, AnimClass_DrawIt_MakeInfantry, 0x6)
{
enum { SkipGameCode = 0x4232C5 };

GET(AnimClass*, pThis, ESI);

if (pThis->Type->MakeInfantry != -1)
{
auto const pCell = pThis->GetCell();
R->EAX(pCell->Intensity_Normal);
return SkipGameCode;
}

return 0;
}

#pragma region AltPalette

// Fix AltPalette anims not using owner color scheme.
Expand Down
2 changes: 1 addition & 1 deletion src/Ext/Bullet/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ DEFINE_HOOK(0x4665E9, BulletClass_DTOR, 0xA)
GET(BulletClass*, pItem, ESI);

if (auto pTraj = BulletExt::ExtMap.Find(pItem)->Trajectory)
DLLDelete(pTraj);
delete pTraj;

BulletExt::ExtMap.Remove(pItem);
return 0;
Expand Down
27 changes: 18 additions & 9 deletions src/Ext/Bullet/Trajectories/BombardTrajectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ PhobosTrajectory* BombardTrajectoryType::CreateInstance() const
return new BombardTrajectory(this);
}

template<typename T>
void BombardTrajectoryType::Serialize(T& Stm)
{
Stm.Process(this->Height);
}

bool BombardTrajectoryType::Load(PhobosStreamReader& Stm, bool RegisterForChange)
{
this->PhobosTrajectoryType::Load(Stm, false);
Stm.Process(this->Height, false);
this->Serialize(Stm);
return true;
}

bool BombardTrajectoryType::Save(PhobosStreamWriter& Stm) const
{
this->PhobosTrajectoryType::Save(Stm);
Stm.Process(this->Height);
const_cast<BombardTrajectoryType*>(this)->Serialize(Stm);
return true;
}

Expand All @@ -26,14 +32,20 @@ void BombardTrajectoryType::Read(CCINIClass* const pINI, const char* pSection)
this->Height = pINI->ReadDouble(pSection, "Trajectory.Bombard.Height", 0.0);
}

bool BombardTrajectory::Load(PhobosStreamReader& Stm, bool RegisterForChange)
template<typename T>
void BombardTrajectory::Serialize(T& Stm)
{
this->PhobosTrajectory::Load(Stm, false);

Stm
.Process(this->IsFalling)
.Process(this->Height)
;
}

bool BombardTrajectory::Load(PhobosStreamReader& Stm, bool RegisterForChange)
{
this->PhobosTrajectory::Load(Stm, false);

this->Serialize(Stm);

return true;
}
Expand All @@ -42,10 +54,7 @@ bool BombardTrajectory::Save(PhobosStreamWriter& Stm) const
{
this->PhobosTrajectory::Save(Stm);

Stm
.Process(this->IsFalling)
.Process(this->Height)
;
const_cast<BombardTrajectory*>(this)->Serialize(Stm);

return true;
}
Expand Down
13 changes: 9 additions & 4 deletions src/Ext/Bullet/Trajectories/BombardTrajectory.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ class BombardTrajectoryType final : public PhobosTrajectoryType
virtual void Read(CCINIClass* const pINI, const char* pSection) override;

double Height;

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

class BombardTrajectory final : public PhobosTrajectory
{
public:
BombardTrajectory() : PhobosTrajectory(TrajectoryFlag::Bombard)
, IsFalling { false }
, Height { 0.0 }
{}
BombardTrajectory(noinit_t) :PhobosTrajectory { noinit_t{} } { }

BombardTrajectory(PhobosTrajectoryType const* pType) : PhobosTrajectory(TrajectoryFlag::Bombard)
, IsFalling { false }
Expand All @@ -43,4 +44,8 @@ class BombardTrajectory final : public PhobosTrajectory

bool IsFalling;
double Height;

private:
template <typename T>
void Serialize(T& Stm);
};
4 changes: 2 additions & 2 deletions src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ PhobosTrajectory* PhobosTrajectory::LoadFromStream(PhobosStreamReader& Stm)
switch (flag)
{
case TrajectoryFlag::Straight:
pTraj = DLLCreate<StraightTrajectory>();
pTraj = new StraightTrajectory(noinit_t {});
break;
case TrajectoryFlag::Bombard:
pTraj = DLLCreate<BombardTrajectory>();
pTraj = new BombardTrajectory(noinit_t {});
break;
default:
return nullptr;
Expand Down
Loading

0 comments on commit 3dfad0a

Please sign in to comment.