Skip to content

Commit 1efa1d4

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into multiweapon
# Conflicts: # docs/Whats-New.md
2 parents f18ba2e + e195a83 commit 1efa1d4

File tree

16 files changed

+508
-12
lines changed

16 files changed

+508
-12
lines changed

CREDITS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ This page lists all the individual contributions to the project by their author.
7070
- Ability for deployed infantry to use both weapons
7171
- Observer PCX loading screen
7272
- Original `Arcing` elevation inaccuracy fix
73+
- Display banner improvement
7374
- Official CN docs for Build#29 and previous versions
7475
- **secsome (SEC-SOME)**:
7576
- Debug info dump hotkey
@@ -288,6 +289,7 @@ This page lists all the individual contributions to the project by their author.
288289
- `601 House owns TechnoType` and `602 House doesn't own TechnoType` trigger events
289290
- Voxel light source position customization
290291
- Extending `Power` to all TechnoTypes
292+
- Display banner by triggers
291293
- Help with docs
292294
- **ChrisLv_CN** (work relicensed under [following permission](https://github.com/Phobos-developers/Phobos/blob/develop/images/ChrisLv-relicense.png)):
293295
- General assistance
@@ -414,6 +416,7 @@ This page lists all the individual contributions to the project by their author.
414416
- Fix the bug that `DamageSelf` and `AllowDamageOnSelf` are ineffective on airforce
415417
- Customize limit when engineer repair a building
416418
- Fix the bug that damaged particle dont disappear after building has repaired by engineer
419+
- Display banner improvement
417420
- **Apollo** - Translucent SHP drawing patches
418421
- **ststl**:
419422
- Customizable `ShowTimer` priority of superweapons
@@ -422,6 +425,7 @@ This page lists all the individual contributions to the project by their author.
422425
- Unlimited `AlternateFLH` entries
423426
- Build limit group
424427
- Customizing whether passengers are kicked out when an aircraft fires
428+
- Display banner by triggers
425429
- New SuperWeapon Type template
426430
- Fix the issue where some units crashed after the deployment transformation
427431
- **TwinkleStar**:
@@ -509,6 +513,7 @@ This page lists all the individual contributions to the project by their author.
509513
- Allow player's self-healing effects to be benefited by allied or `PlayerControl=true` houses
510514
- Power plant damage factor
511515
- Allow faking digital display for `InfoType=Health` at disguise
516+
- Display banner improvement and doc
512517
- **NaotoYuuki** - Vertical & meteor trajectory projectile prototypes
513518
- **handama** - AI script action to `16005 Jump Back To Previous Script`
514519
- **TaranDahl (航味麻酱)**:

Phobos.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@
9090
<ClCompile Include="src\Misc\Hooks.VeinholeMonster.cpp" />
9191
<ClCompile Include="src\Misc\PhobosToolTip.cpp" />
9292
<ClCompile Include="src\Misc\TextInput.cpp" />
93+
<ClCompile Include="src\New\Entity\BannerClass.cpp" />
9394
<ClCompile Include="src\New\Entity\ShieldClass.cpp" />
9495
<ClCompile Include="src\Misc\RetryDialog.cpp" />
96+
<ClCompile Include="src\New\Type\BannerTypeClass.cpp" />
9597
<ClCompile Include="src\New\Type\Affiliated\DroppodTypeClass.cpp" />
9698
<ClCompile Include="src\New\Type\DigitalDisplayTypeClass.cpp" />
9799
<ClCompile Include="src\New\Type\InsigniaTypeClass.cpp" />
@@ -247,6 +249,8 @@
247249
<ClInclude Include="src\Misc\FlyingStrings.h" />
248250
<ClInclude Include="src\Misc\PhobosToolTip.h" />
249251
<ClInclude Include="src\Misc\SyncLogging.h" />
252+
<ClInclude Include="src\New\Entity\BannerClass.h" />
253+
<ClInclude Include="src\New\Type\BannerTypeClass.h" />
250254
<ClInclude Include="src\New\Type\Affiliated\TypeConvertGroup.h" />
251255
<ClInclude Include="src\New\Type\Affiliated\DroppodTypeClass.h" />
252256
<ClInclude Include="src\New\Type\DigitalDisplayTypeClass.h" />

docs/AI-Scripting-and-Mapping.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,47 @@ ID=ActionCount,[Action1],608,0,0,[HouseIndex],0,0,0,A,[ActionX]
666666
...
667667
```
668668

669+
###`800-802` Display Banner
670+
671+
- Display a 'banner' at a fixed location that is relative to the screen.
672+
- Action `800` will create a new banner or replace the banner with the same Banner ID if it exists. Using a local variable's value when displaying a text banner.
673+
- Action `801` will create a new banner or replace the banner with the same Banner ID if it exists. Using a global variable's value when displaying a text banner.
674+
- Action `802` will delete the banner corresponding to the set Banner ID.
675+
- To make use of this, you need to set the properties of a `BannerType` in your ini file. The banner can either be a `PCX` file, a Shape (`SHP`) file or a `CSF` text. If multiple are set the first one in the above listed order takes effect.
676+
- `SHP.Palette` controls the palette that'll be used when drawing a banner for Shape file.
677+
- `CSF.Color` controls the color of the text that'll be used when drawing a text banner.
678+
- `CSF.Background` controls whether a black background will be displayed below the text banner.
679+
- `CSF.VariableFormat` controls the way to print a variable together with the text banner.
680+
- `none` will make the text banner not display the variable.
681+
- `variable` will make the text banner display the variable alone and will ignore the text in `CSF`.
682+
- `prefix`/`prefixed` will make the text banner display the variable before any other text.
683+
- `surfix`/`surfixed` will make the text banner display the variable after any other text.
684+
685+
In `rulesmd.ini`:
686+
```ini
687+
[BannerTypes]
688+
0=SOMEBANNER
689+
690+
[SOMEBANNER] ; BannerType
691+
PCX= ; filename - excluding the .pcx extension
692+
SHP= ; filename - excluding the .shp extension
693+
SHP.Palette=palette.pal ; filename - excluding the .pal extension
694+
CSF= ; CSF entry key
695+
CSF.Color= ; integer - R,G,B, defaults to MessageTextColor of the owner Side
696+
CSF.Background=false ; boolean
697+
CSF.VariableFormat=none ; List of Variable Format Enumeration (none|variable|prefix/prefixed|surfix/surfixed)
698+
```
699+
700+
In `mycampaign.map`:
701+
```ini
702+
[Actions]
703+
...
704+
ID=ActionCount,[Action1],800,4,[SOMEBANNER],[Unique ID],[Horizontal position],[Vertical position],[VariableIndex],A,[ActionX]
705+
ID=ActionCount,[Action1],801,4,[SOMEBANNER],[Unique ID],[Horizontal position],[Vertical position],[VariableIndex],A,[ActionX]
706+
ID=ActionCount,[Action1],802,0,[Unique ID],0,0,0,0,A,[ActionX]
707+
...
708+
```
709+
669710
## Trigger events
670711

671712
### `500-511` Variable comparation

docs/Whats-New.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ HideLightFlashEffects=false ; boolean
117117
68=House,1,2
118118
69=Non-inert,10
119119
70=AITargetTypes index,0
120+
101=BannerType,0
121+
102=Horizontal position,0
122+
103=Vertical position,0
123+
104=Banner ID,0
120124
121125
[EventsRA2]
122126
500=Local variable is greater than,48,6,0,0,[LONG DESC],0,1,500,1
@@ -175,6 +179,9 @@ HideLightFlashEffects=false ; boolean
175179
606=Edit hate-value (Phobos),0,2,55,6,0,0,0,0,0, Edit the hate-value that trigger houses to other houses. -1 works for all houses.,0,1,606
176180
607=Clear hate-value (Phobos),0,2,0,0,0,0,0,0,0, Clear the hate-value that trigger houses to other houses. -1 works for all houses.,0,1,607
177181
608=Set force enemy (Phobos),0,0,2,0,0,0,0,0,0, Force an enemy, it will not change with the change of hate-value. -1 will remove the forced enemy, -2 will never have any enemies.,0,1,608
182+
800=Display banner and local variable (Phobos),4,101,104,102,103,3,0,0,0,Draw banner on screen and replace banner with same ID,0,1,800
183+
001=Display banner and global variable (Phobos),4,101,104,102,103,35,0,0,0,Draw banner on screen and replace banner with same ID,0,1,801
184+
802=Delete banner (Phobos),0,104,0,0,0,0,0,0,0,Delete banner with ID,0,1,802
178185
179186
; FOLLOWING ENTRIES REQUIRE FA2SP.DLL (by secsome)
180187
[ScriptTypeLists]
@@ -396,6 +403,7 @@ New:
396403
- [Warhead activation target health thresholds](Fixed-or-Improved-Logics.md#customizable-warhead-trigger-conditions) (by FS-21 & Kerbiter)
397404
- [Customize limit and sound when engineer repair a building](New-or-Enhanced-Logics.md#engineer-repair-customization) (by NetsuNegi)
398405
- [Customizable debris trailer anim spawn delay](Fixed-or-Improved-Logics.md#customizable-debris-trailer-anim-spawn-delay) (by CrimRecya)
406+
- [Display banner](AI-Scripting-and-Mapping.md#display-banner) (by Morton & ststl)
399407
- Support for more optional weapons (by FlyStar)
400408
401409
Vanilla fixes:

src/Ext/Rules/Body.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <New/Type/LaserTrailTypeClass.h>
1010
#include <New/Type/DigitalDisplayTypeClass.h>
1111
#include <New/Type/AttachEffectTypeClass.h>
12+
#include <New/Type/BannerTypeClass.h>
1213
#include <New/Type/InsigniaTypeClass.h>
1314
#include <New/Type/SelectBoxTypeClass.h>
1415
#include <Utilities/Patch.h>
@@ -38,6 +39,7 @@ void RulesExt::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
3839
ShieldTypeClass::LoadFromINIList(pINI);
3940
LaserTrailTypeClass::LoadFromINIList(&CCINIClass::INI_Art);
4041
AttachEffectTypeClass::LoadFromINIList(pINI);
42+
BannerTypeClass::LoadFromINIList(pINI);
4143
InsigniaTypeClass::LoadFromINIList(pINI);
4244

4345
Data->LoadBeforeTypeData(pThis, pINI);

src/Ext/TAction/Body.cpp

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#include "Body.h"
22

3-
#include <SessionClass.h>
43
#include <MessageListClass.h>
5-
#include <HouseClass.h>
6-
#include <CRT.h>
7-
#include <SuperWeaponTypeClass.h>
8-
#include <SuperClass.h>
9-
#include <Ext/SWType/Body.h>
10-
#include <Utilities/SavegameDef.h>
114

125
#include <Ext/Scenario/Body.h>
6+
#include <Ext/SWType/Body.h>
7+
8+
#include <New/Entity/BannerClass.h>
9+
10+
#include <New/Type/BannerTypeClass.h>
11+
12+
#include <Utilities/SavegameDef.h>
1313
#include <Ext/House/Body.h>
1414

1515
//Static init
@@ -78,6 +78,13 @@ bool TActionExt::Execute(TActionClass* pThis, HouseClass* pHouse, ObjectClass* p
7878
case PhobosTriggerAction::SetForceEnemy:
7979
return TActionExt::SetForceEnemy(pThis, pHouse, pObject, pTrigger, location);
8080

81+
case PhobosTriggerAction::CreateBannerGlobal:
82+
return TActionExt::CreateBannerGlobal(pThis, pHouse, pObject, pTrigger, location);
83+
case PhobosTriggerAction::CreateBannerLocal:
84+
return TActionExt::CreateBannerLocal(pThis, pHouse, pObject, pTrigger, location);
85+
case PhobosTriggerAction::DeleteBanner:
86+
return TActionExt::DeleteBanner(pThis, pHouse, pObject, pTrigger, location);
87+
8188
default:
8289
bHandled = false;
8390
return true;
@@ -364,7 +371,7 @@ bool TActionExt::RunSuperWeaponAt(TActionClass* pThis, int X, int Y)
364371
if (pExecuteHouse)
365372
{
366373
auto const pSuper = pExecuteHouse->Supers.Items[swIdx];
367-
374+
368375
CDTimerClass old_timer = pSuper->RechargeTimer;
369376
pSuper->SetReadiness(true);
370377
pSuper->Launch(targetLocation, false);
@@ -512,6 +519,64 @@ bool TActionExt::SetForceEnemy(TActionClass* pThis, HouseClass* pHouse, ObjectCl
512519
return true;
513520
}
514521

522+
static void CreateOrReplaceBanner(TActionClass* pTAction, bool isGlobal)
523+
{
524+
const auto pBannerType = BannerTypeClass::Find(pTAction->Text);
525+
526+
if (!pBannerType)
527+
return;
528+
529+
auto& banners = BannerClass::Array;
530+
531+
const auto it = std::find_if(banners.begin(), banners.end(),
532+
[pTAction](const std::unique_ptr<BannerClass>& pBanner)
533+
{
534+
return pBanner->ID == pTAction->Param3;
535+
});
536+
537+
if (it != banners.end())
538+
{
539+
auto& pBanner = *it;
540+
pBanner->Type = pBannerType;
541+
pBanner->Position = { static_cast<int>(pTAction->Param4 / 100.0 * DSurface::ViewBounds.Width), static_cast<int>(pTAction->Param5 / 100.0 * DSurface::ViewBounds.Height) };
542+
pBanner->Variable = pTAction->Param6;
543+
pBanner->IsGlobalVariable = isGlobal;
544+
}
545+
else
546+
{
547+
banners.emplace_back(
548+
std::make_unique<BannerClass>(pBannerType, pTAction->Param3, Point2D { pTAction->Param4, pTAction->Param5 }, pTAction->Param6, isGlobal)
549+
);
550+
}
551+
}
552+
553+
bool TActionExt::CreateBannerGlobal(TActionClass* pThis, HouseClass* pHouse, ObjectClass* pObject, TriggerClass* pTrigger, CellStruct const& location)
554+
{
555+
CreateOrReplaceBanner(pThis, true);
556+
return true;
557+
}
558+
559+
bool TActionExt::CreateBannerLocal(TActionClass* pThis, HouseClass* pHouse, ObjectClass* pObject, TriggerClass* pTrigger, CellStruct const& location)
560+
{
561+
CreateOrReplaceBanner(pThis, false);
562+
return true;
563+
}
564+
565+
bool TActionExt::DeleteBanner(TActionClass* pThis, HouseClass* pHouse, ObjectClass* pObject, TriggerClass* pTrigger, CellStruct const& location)
566+
{
567+
const auto it = std::find_if(BannerClass::Array.cbegin(), BannerClass::Array.cend(),
568+
[pThis](const std::unique_ptr<BannerClass>& pBanner)
569+
{
570+
return pBanner->ID == pThis->Value;
571+
});
572+
573+
if (it != BannerClass::Array.cend())
574+
BannerClass::Array.erase(it);
575+
576+
return true;
577+
}
578+
579+
515580
// =============================
516581
// container
517582

src/Ext/TAction/Body.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ enum class PhobosTriggerAction : unsigned int
2323
EditAngerNode = 606,
2424
ClearAngerNode = 607,
2525
SetForceEnemy = 608,
26+
27+
CreateBannerGlobal = 800, // any banner w/ global variable
28+
CreateBannerLocal = 801, // any banner w/ local variable
29+
DeleteBanner = 802,
2630
};
2731

2832
class TActionExt
@@ -72,6 +76,10 @@ class TActionExt
7276
ACTION_FUNC(ClearAngerNode);
7377
ACTION_FUNC(SetForceEnemy);
7478

79+
ACTION_FUNC(CreateBannerGlobal);
80+
ACTION_FUNC(CreateBannerLocal);
81+
ACTION_FUNC(DeleteBanner);
82+
7583
static bool RunSuperWeaponAt(TActionClass* pThis, int X, int Y);
7684

7785
#undef ACTION_FUNC

src/Ext/Techno/Body.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
#include <AircraftClass.h>
44
#include <HouseClass.h>
55
#include <ScenarioClass.h>
6-
#include <OverlayTypeClass.h>
76

87
#include <Ext/Anim/Body.h>
9-
#include <Ext/BulletType/Body.h>
108
#include <Ext/House/Body.h>
119
#include <Ext/Scenario/Body.h>
1210
#include <Ext/WeaponType/Body.h>

src/Misc/Hooks.UI.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
#include <Ext/Scenario/Body.h>
1212
#include <Ext/TechnoType/Body.h>
1313
#include <Ext/SWType/Body.h>
14+
1415
#include <Misc/FlyingStrings.h>
16+
17+
#include <New/Entity/BannerClass.h>
18+
#include <New/Type/BannerTypeClass.h>
19+
1520
#include <Utilities/Debug.h>
1621

1722
DEFINE_HOOK(0x777C41, UI_ApplyAppIcon, 0x9)
@@ -240,6 +245,14 @@ DEFINE_HOOK(0x456776, BuildingClass_DrawRadialIndicator_Visibility, 0x6)
240245
return DoNotDraw;
241246
}
242247

248+
DEFINE_HOOK(0x6D4B25, TacticalClass_Render_Banner, 0x5)
249+
{
250+
for (const auto& pBanner : BannerClass::Array)
251+
pBanner->Render();
252+
253+
return 0;
254+
}
255+
243256
#pragma region ShowBriefing
244257

245258
namespace BriefingTemp

0 commit comments

Comments
 (0)