Skip to content

Commit 3dfad0a

Browse files
committed
Merge remote-tracking branch 'Phobos-Developers/develop' into random-anims
2 parents 0f30f2d + fca5e1f commit 3dfad0a

34 files changed

+463
-209
lines changed

CREDITS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This page lists all the individual contributions to the project by their author.
2121
- Non-ASCII input fix
2222
- Building Placement Preview Adjustment
2323
- Check for Changelog/Documentation/Credits in Pull Requests
24+
- Docs dark theme switcher
2425
- Fix position and layer of info tip and reveal production cameo on selected building
2526
- Fix a glitch related to incorrect target setting for missiles
2627
- Ability to disable shadow for debris & meteor animations
@@ -327,6 +328,8 @@ This page lists all the individual contributions to the project by their author.
327328
- Forbidding parallel AI queues by type
328329
- Jumpjet crash speed fix when crashing onto building
329330
- Disguised units not using the correct palette if target has custom palette bugfix
331+
- Tunnel/Walk/Mech locomotor being stuck when moving too fast bugfix
332+
- Assign Super Weapon cameo to any sidebar tab
330333
- **Apollo** - Translucent SHP drawing patches
331334
- **ststl**
332335
- Customizable ShowTimer priority of superweapons

YRpp

docs/Fixed-or-Improved-Logics.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
167167
- 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.
168168
- Planning paths are now shown for all units under player control or when `[GlobalControls]->DebugPlanningPaths=yes` in singleplayer game modes.
169169
- Fixed `Temporal=true` Warheads potentially crashing game if used to attack `Slaved=true` infantry.
170+
- Fixed some locomotors (Tunnel, Walk, Mech) getting stuck when moving too fast.
171+
- Animations with `MakeInfantry` and `UseNormalLight=false` that are drawn in unit palette will now have cell lighting changes applied on them (by Starkku)
170172

171173
## Fixes / interactions with other extensions
172174

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

475477
[SOMETECHNO] ; TechnoType
476-
SelfHealGainType= ; Self-Heal Gain Type Enumeration (none|infantry|units)
478+
SelfHealGainType= ; Self-Heal Gain Type Enumeration (noheal|infantry|units)
477479
```
478480

479481
### Chrono sparkle animation customization & improvements

docs/New-or-Enhanced-Logics.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ This page describes all the engine features that are either new and introduced b
2525
- `Animation.TemporalAction` determines what happens to the animation when the attached object is under effect of `Temporal=true` Warhead.
2626
- `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.
2727
- `Animation.HideIfAttachedWith` contains list of other AttachEffectTypes that if attached to same techno as the current one, will hide this effect's animation.
28-
- `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.
28+
- `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.
29+
- `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.
2930
- Attached effect can fire off a weapon when expired / removed / object dies by setting `ExpireWeapon`.
3031
- `ExpireWeapon.TriggerOn` determines the exact conditions upon which the weapon is fired, defaults to `expire` which means only if the effect naturally expires.
3132
- `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.
@@ -90,6 +91,7 @@ Animation.TemporalAction=None ; AttachedAnimFlag (None, Hides,
9091
Animation.UseInvokerAsOwner=false ; boolean
9192
Animation.HideIfAttachedWith= ; List of AttachEffectTypes
9293
CumulativeAnimations= ; list of animations
94+
CumulativeAnimations.RestartOnChange=true ; boolean
9395
ExpireWeapon= ; WeaponType
9496
ExpireWeapon.TriggerOn=expire ; List of expire weapon trigger condition enumeration (none|expire|remove|death|all)
9597
ExpireWeapon.CumulativeOnlyOnce=false ; boolean
@@ -877,6 +879,17 @@ Detonate.Damage= ; integer
877879
Detonate.AtFirer=false ; boolean
878880
```
879881

882+
### Customize SuperWeapon TabIndex
883+
884+
- You can now assign a Super Weapon's cameo to any sidebar tab using `TabIndex`.
885+
- Valid values are: 0 (buildings tab), 1 (arsenal tab), 2 (infantry tab), 3 (vehicle tab).
886+
887+
In `rulesmd.ini`:
888+
```ini
889+
[SOMESW] ; Super Weapon
890+
TabIndex=1 ; integer
891+
```
892+
880893
## Technos
881894

882895
### Aircraft spawner customizations

docs/Whats-New.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ You can use the migration utility (can be found on [Phobos supplementaries repo]
2121

2222
#### From post-0.3 devbuilds
2323

24+
- `SelfHealGainType` value `none` has been changed to `noheal` due to `none` being treated as a blank string and not parsed by the game.
2425
- 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.
2526
- 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.
2627
- 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.
@@ -451,6 +452,7 @@ New:
451452
- Nonprovocative Warheads (by Starkku)
452453
- Option to restore `PowerSurplus` setting for AI (by Starkku)
453454
- `FireOnce` infantry sequence reset toggle (by Starkku)
455+
- Assign Super Weapon cameo to any sidebar tab (by NetsuNegi)
454456
455457
Vanilla fixes:
456458
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
@@ -523,6 +525,8 @@ Vanilla fixes:
523525
- Building upgrades now consistently use building's `PowerUpN` animation settings corresponding to the upgrade's `PowersUpToLevel` where possible (by Starkku)
524526
- 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)
525527
- Fixed `Temporal=true` Warheads potentially crashing game if used to attack `Slaved=true` infantry (by Starkku)
528+
- Fixed some locomotors (Tunnel, Walk, Mech) getting stuck when moving too fast (by NetsuNegi)
529+
- Animations with `MakeInfantry` and `UseNormalLight=false` that are drawn in unit palette will now have cell lighting changes applied on them (by Starkku)
526530
527531
Phobos fixes:
528532
- Fixed a few errors of calling for superweapon launch by `LaunchSW` or building infiltration (by Trsdy)
@@ -565,6 +569,7 @@ Phobos fixes:
565569
- 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)
566570
- Fixed Phobos Warhead effects not reliably being applied on damage area as opposed to full weapon-based Warhead detonation (by Starkku)
567571
- Fix `LimboKill` not working reliably (by CrimRecya)
572+
- Fixed `SelfHealGainType=none` not working (changed to `noheal`) (by Starkku)
568573
569574
Fixes / interactions with other extensions:
570575
- `IsSimpleDeployer` units with Hover locomotor and `DeployToLand` no longer get stuck after deploying or play their move sound indefinitely (by Starkku)

src/Ext/Anim/Body.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "Body.h"
22

3+
#include <GameOptionsClass.h>
4+
35
#include <Ext/AnimType/Body.h>
46
#include <Ext/House/Body.h>
57
#include <Ext/WarheadType/Body.h>
@@ -130,6 +132,54 @@ void AnimExt::VeinAttackAI(AnimClass* pAnim)
130132
}
131133
}
132134

135+
// Changes type of anim in similar fashion to Next.
136+
void AnimExt::ChangeAnimType(AnimClass* pAnim, AnimTypeClass* pNewType, bool resetLoops, bool restart)
137+
{
138+
double percentThrough = pAnim->Animation.Value / static_cast<double>(pAnim->Type->End);
139+
140+
if (pNewType->End == -1)
141+
{
142+
pNewType->End = pNewType->GetImage()->Frames;
143+
144+
if (pNewType->Shadow)
145+
pNewType->End /= 2;
146+
}
147+
148+
if (pNewType->LoopEnd == -1)
149+
{
150+
pNewType->LoopEnd = pNewType->End;
151+
}
152+
153+
pAnim->Type = pNewType;
154+
155+
if (resetLoops)
156+
pAnim->RemainingIterations = static_cast<byte>(pNewType->LoopCount);
157+
158+
pAnim->Accum = 0;
159+
pAnim->UnableToContinue = false;
160+
pAnim->Reverse = pNewType->Reverse;
161+
162+
int rate = pNewType->Rate;
163+
164+
if (pNewType->RandomRate.Min || pNewType->RandomRate.Max)
165+
rate = ScenarioClass::Instance->Random.RandomRanged(pNewType->RandomRate.Min, pNewType->RandomRate.Max);
166+
167+
if (pNewType->Normalized)
168+
rate = GameOptionsClass::Instance->GetAnimSpeed(rate);
169+
170+
pAnim->Animation.Start(rate, pNewType->Reverse ? -1 : 1);
171+
172+
if (restart)
173+
{
174+
pAnim->Animation.Value = pNewType->Reverse ? pNewType->End : pNewType->Start;
175+
pAnim->Start();
176+
}
177+
else
178+
{
179+
pAnim->Animation.Value = static_cast<int>(pNewType->End * percentThrough);
180+
}
181+
}
182+
133183
void AnimExt::HandleDebrisImpact(AnimTypeClass* pExpireAnim, AnimTypeClass* pWakeAnim, Iterator<AnimTypeClass*> splashAnims, HouseClass* pOwner, WarheadTypeClass* pWarhead, int nDamage,
134184
CellClass* pCell, CoordStruct nLocation, bool heightFlag, bool isMeteor, bool warheadDetonate, bool explodeOnWater, bool splashAnimsPickRandom)
135185
{

src/Ext/Anim/Body.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ class AnimExt
7272

7373
static bool SetAnimOwnerHouseKind(AnimClass* pAnim, HouseClass* pInvoker, HouseClass* pVictim, bool defaultToVictimOwner = true, bool defaultToInvokerOwner = false);
7474
static HouseClass* GetOwnerHouse(AnimClass* pAnim, HouseClass* pDefaultOwner = nullptr);
75-
7675
static void VeinAttackAI(AnimClass* pAnim);
77-
76+
static void ChangeAnimType(AnimClass* pAnim, AnimTypeClass* pNewType, bool resetLoops, bool restart);
7877
static void HandleDebrisImpact(AnimTypeClass* pExpireAnim, AnimTypeClass* pWakeAnim, Iterator<AnimTypeClass*> splashAnims, HouseClass* pOwner, WarheadTypeClass* pWarhead, int nDamage,
7978
CellClass* pCell, CoordStruct nLocation, bool heightFlag, bool isMeteor, bool warheadDetonate, bool explodeOnWater, bool splashAnimsPickRandom);
8079

src/Ext/Anim/Hooks.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,23 @@ DEFINE_HOOK(0x423365, AnimClass_DrawIt_ExtraShadow, 0x8)
312312
return SkipExtraShadow;
313313
}
314314

315+
// Apply cell lighting on UseNormalLight=no MakeInfantry anims.
316+
DEFINE_HOOK(0x4232BF, AnimClass_DrawIt_MakeInfantry, 0x6)
317+
{
318+
enum { SkipGameCode = 0x4232C5 };
319+
320+
GET(AnimClass*, pThis, ESI);
321+
322+
if (pThis->Type->MakeInfantry != -1)
323+
{
324+
auto const pCell = pThis->GetCell();
325+
R->EAX(pCell->Intensity_Normal);
326+
return SkipGameCode;
327+
}
328+
329+
return 0;
330+
}
331+
315332
#pragma region AltPalette
316333

317334
// Fix AltPalette anims not using owner color scheme.

src/Ext/Bullet/Body.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ DEFINE_HOOK(0x4665E9, BulletClass_DTOR, 0xA)
214214
GET(BulletClass*, pItem, ESI);
215215

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

219219
BulletExt::ExtMap.Remove(pItem);
220220
return 0;

src/Ext/Bullet/Trajectories/BombardTrajectory.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@ PhobosTrajectory* BombardTrajectoryType::CreateInstance() const
77
return new BombardTrajectory(this);
88
}
99

10+
template<typename T>
11+
void BombardTrajectoryType::Serialize(T& Stm)
12+
{
13+
Stm.Process(this->Height);
14+
}
15+
1016
bool BombardTrajectoryType::Load(PhobosStreamReader& Stm, bool RegisterForChange)
1117
{
1218
this->PhobosTrajectoryType::Load(Stm, false);
13-
Stm.Process(this->Height, false);
19+
this->Serialize(Stm);
1420
return true;
1521
}
1622

1723
bool BombardTrajectoryType::Save(PhobosStreamWriter& Stm) const
1824
{
1925
this->PhobosTrajectoryType::Save(Stm);
20-
Stm.Process(this->Height);
26+
const_cast<BombardTrajectoryType*>(this)->Serialize(Stm);
2127
return true;
2228
}
2329

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

29-
bool BombardTrajectory::Load(PhobosStreamReader& Stm, bool RegisterForChange)
35+
template<typename T>
36+
void BombardTrajectory::Serialize(T& Stm)
3037
{
31-
this->PhobosTrajectory::Load(Stm, false);
32-
3338
Stm
3439
.Process(this->IsFalling)
3540
.Process(this->Height)
3641
;
42+
}
43+
44+
bool BombardTrajectory::Load(PhobosStreamReader& Stm, bool RegisterForChange)
45+
{
46+
this->PhobosTrajectory::Load(Stm, false);
47+
48+
this->Serialize(Stm);
3749

3850
return true;
3951
}
@@ -42,10 +54,7 @@ bool BombardTrajectory::Save(PhobosStreamWriter& Stm) const
4254
{
4355
this->PhobosTrajectory::Save(Stm);
4456

45-
Stm
46-
.Process(this->IsFalling)
47-
.Process(this->Height)
48-
;
57+
const_cast<BombardTrajectory*>(this)->Serialize(Stm);
4958

5059
return true;
5160
}

src/Ext/Bullet/Trajectories/BombardTrajectory.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ class BombardTrajectoryType final : public PhobosTrajectoryType
1616
virtual void Read(CCINIClass* const pINI, const char* pSection) override;
1717

1818
double Height;
19+
20+
private:
21+
template <typename T>
22+
void Serialize(T& Stm);
1923
};
2024

2125
class BombardTrajectory final : public PhobosTrajectory
2226
{
2327
public:
24-
BombardTrajectory() : PhobosTrajectory(TrajectoryFlag::Bombard)
25-
, IsFalling { false }
26-
, Height { 0.0 }
27-
{}
28+
BombardTrajectory(noinit_t) :PhobosTrajectory { noinit_t{} } { }
2829

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

4445
bool IsFalling;
4546
double Height;
47+
48+
private:
49+
template <typename T>
50+
void Serialize(T& Stm);
4651
};

src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ PhobosTrajectory* PhobosTrajectory::LoadFromStream(PhobosStreamReader& Stm)
132132
switch (flag)
133133
{
134134
case TrajectoryFlag::Straight:
135-
pTraj = DLLCreate<StraightTrajectory>();
135+
pTraj = new StraightTrajectory(noinit_t {});
136136
break;
137137
case TrajectoryFlag::Bombard:
138-
pTraj = DLLCreate<BombardTrajectory>();
138+
pTraj = new BombardTrajectory(noinit_t {});
139139
break;
140140
default:
141141
return nullptr;

0 commit comments

Comments
 (0)