@bf6mods/sdk 1.0.2 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1467 -1445
- package/dist/index.js +415 -1
- package/dist/index.js.map +1 -1
- package/dist/std/chunk-Bp6m_JJh.js +13 -0
- package/dist/std/index.d.ts +38 -0
- package/dist/std/index.js +247 -0
- package/dist/std/index.js.map +1 -0
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -1,2 +1,416 @@
|
|
|
1
|
-
var M=(t=>(t[t.Crawl=0]="Crawl",t[t.Downed=1]="Downed",t[t.InstantDeath=2]="InstantDeath",t))(M||{}),x=(t=>(t[t.NoBots=0]="NoBots",t[t.Backfill=1]="Backfill",t[t.Static=2]="Static",t))(x||{}),S=(r=>(r[r.All=0]="All",r[r.SquadmatesOnLeader_LeaderNone=1]="SquadmatesOnLeader_LeaderNone",r[r.SquadmatesOnLeader_LeaderAll=2]="SquadmatesOnLeader_LeaderAll",r[r.Disabled=2]="Disabled",r))(S||{}),w=(l=>(l[l.NotSet=0]="NotSet",l[l.DefaultFAA=1]="DefaultFAA",l[l.Off=2]="Off",l[l.CustomTwoTeams=3]="CustomTwoTeams",l[l.CustomFFA=4]="CustomFFA",l))(w||{}),V=(n=>(n[n.PingTargets=0]="PingTargets",n[n.Disabled=1]="Disabled",n))(V||{}),W=(o=>(o[o.Custom=2]="Custom",o))(W||{}),D=(t=>(t[t.Pax=-1865993703]="Pax",t[t.MapDefault=0]="MapDefault",t[t.NATO=607944106]="NATO",t))(D||{}),F=(t=>(t[t.SpatialData=1]="SpatialData",t[t.TypeScript=2]="TypeScript",t[t.Strings=4]="Strings",t))(F||{});function J(e,o){return e+o}function X(...e){for(let o=0;o<e.length;o++)if(!e[o])return!1;return!0}function Z(...e){for(let o=0;o<e.length;o++){let n=e[o];if(!n())return!1}return!0}function E(e){return mod.GetObjId(e)}function H(e){return mod.GetObjId(e)}function _(e){let o=[],n=mod.CountOf(e);for(let t=0;t<n;t++){let r=mod.ValueInArray(e,t);o.push(r)}return o}function Q(e,o){let n=_(e),t=mod.EmptyArray(),r=n.length;for(let l=0;l<r;l++){let i=n[l];o(i)&&mod.AppendToArray(t,i)}return t}function Y(e,o,n=null){let t=_(e),r=t.length;for(let l=0;l<r;l++){let i=t[l];if(o(i,n))return l}return-1}function $(e,o,n){return e?o():n()}function ee(e,o,n=null){let t=_(e),r=t.length;for(let l=0;l<r;l++){let i=t[l];if(!o(i,n))return!1}return!0}function oe(e,o,n=null){let t=_(e),r=t.length;for(let l=0;l<r;l++){let i=t[l];if(o(i,n))return!0}return!1}function te(e,o){let n=e.slice();n.sort(o);let t=[];for(let r of n)t.push(r);return t}function ne(e,o){if(e==null||o==null)debugger;return mod.Equals(e,o)}async function re(e,o){let n=10,t=e/n;for(let r=0;r<n&&o();r++)await mod.Wait(t)}var U=class{constructor(){this.lastState=!1}update(o){return o?this.lastState?!1:(this.lastState=!0,!0):(this.lastState=!1,!1)}},T=class{constructor(){this.conditionStates=[]}getConditionState(o){for(;o>=this.conditionStates.length;)this.conditionStates.push(new U);return this.conditionStates[o]}},A=[],h=[],O=[],G=[],R=[],v=new T;function f(e,o,n){for(;e>=o.length;)o.push(new T);return o[e].getConditionState(n)}function le(e,o){let n=E(e);for(;n>=A.length;)A.push(new T);return A[n].getConditionState(o)}function ae(e,o){let n=H(e);for(;n>=h.length;)h.push(new T);return h[n].getConditionState(o)}function ie(e,o){let n=mod.GetObjId(e);return f(n,O,o)}function de(e,o){let n=mod.GetObjId(e);return f(n,G,o)}function me(e,o){let n=mod.GetObjId(e);return f(n,R,o)}function be(e){return v.getConditionState(e)}function C(e){let o=mod.AllPlayers(),n=mod.CountOf(o),t=[];for(let r=0;r<n;r++){let l=mod.ValueInArray(o,r);mod.GetTeam(l)==e&&t.push(l)}return t}function a(e){return Array.isArray(e)?mod.CreateVector(e[0],e[1],e.length==2?0:e[2]):e}function y(e){return typeof e=="string"?mod.Message(e):e}function c(e){e.hasOwnProperty("name")||(e.name=""),e.hasOwnProperty("position")||(e.position=mod.CreateVector(0,0,0)),e.hasOwnProperty("size")||(e.size=mod.CreateVector(100,100,0)),e.hasOwnProperty("anchor")||(e.anchor=mod.UIAnchor.TopLeft),e.hasOwnProperty("parent")||(e.parent=mod.GetUIRoot()),e.hasOwnProperty("visible")||(e.visible=!0),e.hasOwnProperty("padding")||(e.padding=e.type=="Container"?0:8),e.hasOwnProperty("bgColor")||(e.bgColor=mod.CreateVector(.25,.25,.25)),e.hasOwnProperty("bgAlpha")||(e.bgAlpha=.5),e.hasOwnProperty("bgFill")||(e.bgFill=mod.UIBgFill.Solid)}function g(e,o){let n=mod.FindUIWidgetWithName(e);return mod.SetUIWidgetName(n,o.name),n}var d="----uniquename----";function B(e){c(e);let o=e.teamId??e.playerId;o?mod.AddUIContainer(d,a(e.position),a(e.size),e.anchor,e.parent,e.visible,e.padding,a(e.bgColor),e.bgAlpha,e.bgFill,o):mod.AddUIContainer(d,a(e.position),a(e.size),e.anchor,e.parent,e.visible,e.padding,a(e.bgColor),e.bgAlpha,e.bgFill);let n=g(d,e);return e.children&&e.children.forEach(t=>{t.parent=n,I(t)}),n}function N(e){e.hasOwnProperty("textLabel")||(e.textLabel=""),e.hasOwnProperty("textSize")||(e.textSize=0),e.hasOwnProperty("textColor")||(e.textColor=mod.CreateVector(1,1,1)),e.hasOwnProperty("textAlpha")||(e.textAlpha=1),e.hasOwnProperty("textAnchor")||(e.textAnchor=mod.UIAnchor.CenterLeft)}function L(e){c(e),N(e);let o=e.teamId??e.playerId;return o?mod.AddUIText(d,a(e.position),a(e.size),e.anchor,e.parent,e.visible,e.padding,a(e.bgColor),e.bgAlpha,e.bgFill,y(e.textLabel),e.textSize,a(e.textColor),e.textAlpha,e.textAnchor,o):mod.AddUIText(d,a(e.position),a(e.size),e.anchor,e.parent,e.visible,e.padding,a(e.bgColor),e.bgAlpha,e.bgFill,y(e.textLabel),e.textSize,a(e.textColor),e.textAlpha,e.textAnchor),g(d,e)}function k(e){e.hasOwnProperty("imageType")||(e.imageType=mod.UIImageType.None),e.hasOwnProperty("imageColor")||(e.imageColor=mod.CreateVector(1,1,1)),e.hasOwnProperty("imageAlpha")||(e.imageAlpha=1)}function z(e){c(e),k(e);let o=e.teamId??e.playerId;return o?mod.AddUIImage(d,a(e.position),a(e.size),e.anchor,e.parent,e.visible,e.padding,a(e.bgColor),e.bgAlpha,e.bgFill,e.imageType,a(e.imageColor),e.imageAlpha,o):mod.AddUIImage(d,a(e.position),a(e.size),e.anchor,e.parent,e.visible,e.padding,a(e.bgColor),e.bgAlpha,e.bgFill,e.imageType,a(e.imageColor),e.imageAlpha),g(d,e)}function K(e){e.hasOwnProperty("buttonEnabled")||(e.buttonEnabled=!0),e.hasOwnProperty("buttonColorBase")||(e.buttonColorBase=mod.CreateVector(.7,.7,.7)),e.hasOwnProperty("buttonAlphaBase")||(e.buttonAlphaBase=1),e.hasOwnProperty("buttonColorDisabled")||(e.buttonColorDisabled=mod.CreateVector(.2,.2,.2)),e.hasOwnProperty("buttonAlphaDisabled")||(e.buttonAlphaDisabled=.5),e.hasOwnProperty("buttonColorPressed")||(e.buttonColorPressed=mod.CreateVector(.25,.25,.25)),e.hasOwnProperty("buttonAlphaPressed")||(e.buttonAlphaPressed=1),e.hasOwnProperty("buttonColorHover")||(e.buttonColorHover=mod.CreateVector(1,1,1)),e.hasOwnProperty("buttonAlphaHover")||(e.buttonAlphaHover=1),e.hasOwnProperty("buttonColorFocused")||(e.buttonColorFocused=mod.CreateVector(1,1,1)),e.hasOwnProperty("buttonAlphaFocused")||(e.buttonAlphaFocused=1)}function j(e){c(e),K(e);let o=e.teamId??e.playerId;return o?mod.AddUIButton(d,a(e.position),a(e.size),e.anchor,e.parent,e.visible,e.padding,a(e.bgColor),e.bgAlpha,e.bgFill,e.buttonEnabled,a(e.buttonColorBase),e.buttonAlphaBase,a(e.buttonColorDisabled),e.buttonAlphaDisabled,a(e.buttonColorPressed),e.buttonAlphaPressed,a(e.buttonColorHover),e.buttonAlphaHover,a(e.buttonColorFocused),e.buttonAlphaFocused,o):mod.AddUIButton(d,a(e.position),a(e.size),e.anchor,e.parent,e.visible,e.padding,a(e.bgColor),e.bgAlpha,e.bgFill,e.buttonEnabled,a(e.buttonColorBase),e.buttonAlphaBase,a(e.buttonColorDisabled),e.buttonAlphaDisabled,a(e.buttonColorPressed),e.buttonAlphaPressed,a(e.buttonColorHover),e.buttonAlphaHover,a(e.buttonColorFocused),e.buttonAlphaFocused),g(d,e)}function I(e){if(e!=null){if(e.type=="Container")return B(e);if(e.type=="Text")return L(e);if(e.type=="Image")return z(e);if(e.type=="Button")return j(e)}}function Pe(...e){let o;for(let n=0;n<e.length;n++)o=I(e[n]);return o}function ue(e,o,n,t){let r=async(m,P,b,u)=>{mod.AddUIText(m,mod.CreateVector(50,250+u*45,0),mod.CreateVector(250,60,0),mod.UIAnchor.TopRight,mod.GetUIRoot(),!0,8,mod.CreateVector(1,1,1),1,mod.UIBgFill.Blur,P,30,mod.CreateVector(1,1,1),1,mod.UIAnchor.Center,b),n>0&&(await mod.Wait(n),mod.DeleteUIWidget(mod.FindUIWidgetWithName(m)))},l=async(m,P,b,u)=>{mod.AddUIText(m,mod.CreateVector(85,270+u*43,0),mod.CreateVector(125,40,0),mod.UIAnchor.TopRight,mod.GetUIRoot(),!0,8,mod.CreateVector(1,1,1),1,mod.UIBgFill.Blur,P,20,mod.CreateVector(1,1,1),1,mod.UIAnchor.Center,b),n>0&&(await mod.Wait(n),mod.DeleteUIWidget(mod.FindUIWidgetWithName(m)))},i=o<1?r:l;if(t)if(mod.IsType(t,mod.Types.Player)){let m=o+String(t);i(m,e,t,o)}else mod.IsType(t,mod.Types.Team)&&C(t).forEach(P=>{let b=o+String(P);i(b,e,P,o)});else{let m=mod.AllPlayers(),P=mod.CountOf(m);for(let b=0;b<P;b++){let u=mod.ValueInArray(m,b),p=o+String(u);i(p,e,u,o)}}}function Te(e,o){let n=async(t,r)=>{let l="GameModeMessage";r?mod.AddUIText(l,mod.CreateVector(0,0,0),mod.CreateVector(2500,80,0),mod.UIAnchor.TopCenter,mod.GetUIRoot(),!0,8,mod.CreateVector(1,1,1),1,mod.UIBgFill.Blur,t,30,mod.CreateVector(1,1,1),1,mod.UIAnchor.Center,r):mod.AddUIText(l,mod.CreateVector(0,0,0),mod.CreateVector(2500,80,0),mod.UIAnchor.TopCenter,mod.GetUIRoot(),!0,8,mod.CreateVector(1,1,1),1,mod.UIBgFill.Blur,t,30,mod.CreateVector(1,1,1),1,mod.UIAnchor.Center),await mod.Wait(6),mod.DeleteUIWidget(mod.FindUIWidgetWithName(l))};o?n(e,o):n(e)}function se(e,o){o?mod.DisplayHighlightedWorldLogMessage(e,o):mod.DisplayHighlightedWorldLogMessage(e)}function _e(e,o){o?mod.DisplayNotificationMessage(e,o):mod.DisplayNotificationMessage(e)}function ce(e){try{s(mod.CustomNotificationSlots.HeaderText,e)}catch{}try{s(mod.CustomNotificationSlots.MessageText1,e)}catch{}try{s(mod.CustomNotificationSlots.MessageText2,e)}catch{}try{s(mod.CustomNotificationSlots.MessageText3,e)}catch{}try{s(mod.CustomNotificationSlots.MessageText4,e)}catch{}}function s(e,o){try{if(o){if(mod.IsType(o,mod.Types.Player))mod.DeleteUIWidget(mod.FindUIWidgetWithName(e+String(o)));else if(mod.IsType(o,mod.Types.Team)){let n=C(o);for(let t=0;t<n.length;t++){let r=n[t];mod.DeleteUIWidget(mod.FindUIWidgetWithName(e+String(r)))}}}else{let n=mod.AllPlayers(),t=mod.CountOf(n);for(let r=0;r<t;r++){let l=mod.ValueInArray(n,r);mod.DeleteUIWidget(mod.FindUIWidgetWithName(e+String(l)))}}}catch{console.error("Could not clear custom message for specified target(s)")}}export{x as AiSpawnType,X as And,Z as AndFn,F as AttachmentType,ce as ClearAllCustomNotificationMessages,s as ClearCustomNotificationMessage,J as Concat,U as ConditionState,_ as ConvertArray,ue as DisplayCustomNotificationMessage,ne as Equals,D as FactionID,Q as FilteredArray,$ as IfThenElse,Y as IndexOfFirstTrue,ee as IsTrueForAll,oe as IsTrueForAny,M as ManDownExperienceType,W as ModBuilderGameMode,Pe as ParseUI,V as PingBehavior,w as ScoreboardType,Te as ShowEventGameModeMessage,se as ShowHighlightedGameModeMessage,_e as ShowNotificationMessage,te as SortedArray,S as SquadSpawnType,re as WaitUntil,ie as getCapturePointCondition,be as getGlobalCondition,de as getMCOMCondition,le as getPlayerCondition,E as getPlayerId,C as getPlayersInTeam,ae as getTeamCondition,H as getTeamId,me as getVehicleCondition};
|
|
1
|
+
//#region src/config/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* Determines the Man-Down behavior when a soldier is downed.
|
|
4
|
+
*/
|
|
5
|
+
let ManDownExperienceType = /* @__PURE__ */ function(ManDownExperienceType$1) {
|
|
6
|
+
ManDownExperienceType$1[ManDownExperienceType$1["Crawl"] = 0] = "Crawl";
|
|
7
|
+
ManDownExperienceType$1[ManDownExperienceType$1["Downed"] = 1] = "Downed";
|
|
8
|
+
ManDownExperienceType$1[ManDownExperienceType$1["InstantDeath"] = 2] = "InstantDeath";
|
|
9
|
+
return ManDownExperienceType$1;
|
|
10
|
+
}({});
|
|
11
|
+
/**
|
|
12
|
+
* Controls which type of AI to spawn. PvP AI will automatically spawn and can be replaced by human players. PvE AI is a fixed number that cannot be replaced, for Solo or Co-op experiences.
|
|
13
|
+
*/
|
|
14
|
+
let AiSpawnType = /* @__PURE__ */ function(AiSpawnType$1) {
|
|
15
|
+
AiSpawnType$1[AiSpawnType$1["NoBots"] = 0] = "NoBots";
|
|
16
|
+
AiSpawnType$1[AiSpawnType$1["Backfill"] = 2] = "Backfill";
|
|
17
|
+
AiSpawnType$1[AiSpawnType$1["Static"] = 1] = "Static";
|
|
18
|
+
return AiSpawnType$1;
|
|
19
|
+
}({});
|
|
20
|
+
/**
|
|
21
|
+
* Controls the rules for Squad Spawning, for squad members and squad leaders.
|
|
22
|
+
*/
|
|
23
|
+
let SquadSpawnType = /* @__PURE__ */ function(SquadSpawnType$1) {
|
|
24
|
+
SquadSpawnType$1[SquadSpawnType$1["All"] = 0] = "All";
|
|
25
|
+
SquadSpawnType$1[SquadSpawnType$1["SquadmatesOnLeader_LeaderNone"] = 1] = "SquadmatesOnLeader_LeaderNone";
|
|
26
|
+
SquadSpawnType$1[SquadSpawnType$1["SquadmatesOnLeader_LeaderAll"] = 2] = "SquadmatesOnLeader_LeaderAll";
|
|
27
|
+
SquadSpawnType$1[SquadSpawnType$1["Disabled"] = 2] = "Disabled";
|
|
28
|
+
return SquadSpawnType$1;
|
|
29
|
+
}({});
|
|
30
|
+
/**
|
|
31
|
+
* Controls what type of scoreboard layout to use.
|
|
32
|
+
*/
|
|
33
|
+
let ScoreboardType = /* @__PURE__ */ function(ScoreboardType$1) {
|
|
34
|
+
ScoreboardType$1[ScoreboardType$1["NotSet"] = 0] = "NotSet";
|
|
35
|
+
ScoreboardType$1[ScoreboardType$1["DefaultFAA"] = 1] = "DefaultFAA";
|
|
36
|
+
ScoreboardType$1[ScoreboardType$1["Off"] = 2] = "Off";
|
|
37
|
+
ScoreboardType$1[ScoreboardType$1["CustomTwoTeams"] = 3] = "CustomTwoTeams";
|
|
38
|
+
ScoreboardType$1[ScoreboardType$1["CustomFFA"] = 4] = "CustomFFA";
|
|
39
|
+
return ScoreboardType$1;
|
|
40
|
+
}({});
|
|
41
|
+
/**
|
|
42
|
+
* Determines the behavior of the Ping command.
|
|
43
|
+
*/
|
|
44
|
+
let PingBehavior = /* @__PURE__ */ function(PingBehavior$1) {
|
|
45
|
+
PingBehavior$1[PingBehavior$1["PingTargets"] = 0] = "PingTargets";
|
|
46
|
+
PingBehavior$1[PingBehavior$1["Disabled"] = 1] = "Disabled";
|
|
47
|
+
return PingBehavior$1;
|
|
48
|
+
}({});
|
|
49
|
+
let ModBuilderGameMode = /* @__PURE__ */ function(ModBuilderGameMode$1) {
|
|
50
|
+
ModBuilderGameMode$1[ModBuilderGameMode$1["Custom"] = 2] = "Custom";
|
|
51
|
+
return ModBuilderGameMode$1;
|
|
52
|
+
}({});
|
|
53
|
+
/**
|
|
54
|
+
* Sets the faction for each team.
|
|
55
|
+
*/
|
|
56
|
+
let FactionID = /* @__PURE__ */ function(FactionID$1) {
|
|
57
|
+
FactionID$1[FactionID$1["Pax"] = -1865993703] = "Pax";
|
|
58
|
+
FactionID$1[FactionID$1["MapDefault"] = 0] = "MapDefault";
|
|
59
|
+
FactionID$1[FactionID$1["NATO"] = 607944106] = "NATO";
|
|
60
|
+
return FactionID$1;
|
|
61
|
+
}({});
|
|
62
|
+
let AttachmentType = /* @__PURE__ */ function(AttachmentType$1) {
|
|
63
|
+
AttachmentType$1[AttachmentType$1["SpatialData"] = 1] = "SpatialData";
|
|
64
|
+
AttachmentType$1[AttachmentType$1["TypeScript"] = 2] = "TypeScript";
|
|
65
|
+
AttachmentType$1[AttachmentType$1["Strings"] = 4] = "Strings";
|
|
66
|
+
return AttachmentType$1;
|
|
67
|
+
}({});
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/modlib/index.ts
|
|
71
|
+
function Concat(s1, s2) {
|
|
72
|
+
return s1 + s2;
|
|
73
|
+
}
|
|
74
|
+
function And(...rest) {
|
|
75
|
+
for (let i = 0; i < rest.length; i++) if (!rest[i]) return false;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
function AndFn(...rest) {
|
|
79
|
+
for (let i = 0; i < rest.length; i++) {
|
|
80
|
+
const condFn = rest[i];
|
|
81
|
+
if (!condFn()) return false;
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
function getPlayerId(player) {
|
|
86
|
+
return mod.GetObjId(player);
|
|
87
|
+
}
|
|
88
|
+
function getTeamId(team) {
|
|
89
|
+
return mod.GetObjId(team);
|
|
90
|
+
}
|
|
91
|
+
function ConvertArray(array) {
|
|
92
|
+
let v = [];
|
|
93
|
+
let n = mod.CountOf(array);
|
|
94
|
+
for (let i = 0; i < n; i++) {
|
|
95
|
+
let currentElement = mod.ValueInArray(array, i);
|
|
96
|
+
v.push(currentElement);
|
|
97
|
+
}
|
|
98
|
+
return v;
|
|
99
|
+
}
|
|
100
|
+
function FilteredArray(array, cond) {
|
|
101
|
+
const arr = ConvertArray(array);
|
|
102
|
+
let v = mod.EmptyArray();
|
|
103
|
+
let n = arr.length;
|
|
104
|
+
for (let i = 0; i < n; i++) {
|
|
105
|
+
let currentElement = arr[i];
|
|
106
|
+
if (cond(currentElement)) mod.AppendToArray(v, currentElement);
|
|
107
|
+
}
|
|
108
|
+
return v;
|
|
109
|
+
}
|
|
110
|
+
function IndexOfFirstTrue(array, cond, arg = null) {
|
|
111
|
+
const arr = ConvertArray(array);
|
|
112
|
+
let n = arr.length;
|
|
113
|
+
for (let i = 0; i < n; i++) {
|
|
114
|
+
let currentArrayElement = arr[i];
|
|
115
|
+
if (cond(currentArrayElement, arg)) return i;
|
|
116
|
+
}
|
|
117
|
+
return -1;
|
|
118
|
+
}
|
|
119
|
+
function IfThenElse(condition, ifTrue, ifFalse) {
|
|
120
|
+
if (condition) return ifTrue();
|
|
121
|
+
else return ifFalse();
|
|
122
|
+
}
|
|
123
|
+
function IsTrueForAll(array, condition, arg = null) {
|
|
124
|
+
const arr = ConvertArray(array);
|
|
125
|
+
let n = arr.length;
|
|
126
|
+
for (let i = 0; i < n; i++) {
|
|
127
|
+
let currentArrayElement = arr[i];
|
|
128
|
+
if (!condition(currentArrayElement, arg)) return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
function IsTrueForAny(array, condition, arg = null) {
|
|
133
|
+
const arr = ConvertArray(array);
|
|
134
|
+
let n = arr.length;
|
|
135
|
+
for (let i = 0; i < n; i++) {
|
|
136
|
+
let currentArrayElement = arr[i];
|
|
137
|
+
if (condition(currentArrayElement, arg)) return true;
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
function SortedArray(array, compare) {
|
|
142
|
+
let v1 = array.slice();
|
|
143
|
+
v1.sort(compare);
|
|
144
|
+
let v2 = [];
|
|
145
|
+
for (let e of v1) v2.push(e);
|
|
146
|
+
return v2;
|
|
147
|
+
}
|
|
148
|
+
function Equals(a, b) {
|
|
149
|
+
if (a == null || b == null) debugger;
|
|
150
|
+
return mod.Equals(a, b);
|
|
151
|
+
}
|
|
152
|
+
async function WaitUntil(delay, cond) {
|
|
153
|
+
let deltaCount = 10;
|
|
154
|
+
let deltaWait = delay / deltaCount;
|
|
155
|
+
for (let t = 0; t < deltaCount; t++) {
|
|
156
|
+
if (!cond()) break;
|
|
157
|
+
await mod.Wait(deltaWait);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
var ConditionState = class {
|
|
161
|
+
constructor() {
|
|
162
|
+
this.lastState = false;
|
|
163
|
+
}
|
|
164
|
+
update(newState) {
|
|
165
|
+
if (!newState) {
|
|
166
|
+
this.lastState = false;
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
if (this.lastState) return false;
|
|
170
|
+
this.lastState = true;
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
var Conditions = class {
|
|
175
|
+
constructor() {
|
|
176
|
+
this.conditionStates = [];
|
|
177
|
+
}
|
|
178
|
+
getConditionState(n) {
|
|
179
|
+
while (n >= this.conditionStates.length) this.conditionStates.push(new ConditionState());
|
|
180
|
+
return this.conditionStates[n];
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
let playerConditions = [];
|
|
184
|
+
let teamConditions = [];
|
|
185
|
+
let capturePointConditions = [];
|
|
186
|
+
let mcomConditions = [];
|
|
187
|
+
let vehicleConditions = [];
|
|
188
|
+
let globalConditions = new Conditions();
|
|
189
|
+
function getObjectCondition(id, objectConditions, n) {
|
|
190
|
+
while (id >= objectConditions.length) objectConditions.push(new Conditions());
|
|
191
|
+
return objectConditions[id].getConditionState(n);
|
|
192
|
+
}
|
|
193
|
+
function getPlayerCondition(obj, n) {
|
|
194
|
+
let id = getPlayerId(obj);
|
|
195
|
+
while (id >= playerConditions.length) playerConditions.push(new Conditions());
|
|
196
|
+
return playerConditions[id].getConditionState(n);
|
|
197
|
+
}
|
|
198
|
+
function getTeamCondition(team, n) {
|
|
199
|
+
let id = getTeamId(team);
|
|
200
|
+
while (id >= teamConditions.length) teamConditions.push(new Conditions());
|
|
201
|
+
return teamConditions[id].getConditionState(n);
|
|
202
|
+
}
|
|
203
|
+
function getCapturePointCondition(obj, n) {
|
|
204
|
+
return getObjectCondition(mod.GetObjId(obj), capturePointConditions, n);
|
|
205
|
+
}
|
|
206
|
+
function getMCOMCondition(obj, n) {
|
|
207
|
+
return getObjectCondition(mod.GetObjId(obj), mcomConditions, n);
|
|
208
|
+
}
|
|
209
|
+
function getVehicleCondition(obj, n) {
|
|
210
|
+
return getObjectCondition(mod.GetObjId(obj), vehicleConditions, n);
|
|
211
|
+
}
|
|
212
|
+
function getGlobalCondition(n) {
|
|
213
|
+
return globalConditions.getConditionState(n);
|
|
214
|
+
}
|
|
215
|
+
function getPlayersInTeam(team) {
|
|
216
|
+
const allPlayers = mod.AllPlayers();
|
|
217
|
+
const n = mod.CountOf(allPlayers);
|
|
218
|
+
let teamMembers = [];
|
|
219
|
+
for (let i = 0; i < n; i++) {
|
|
220
|
+
let player = mod.ValueInArray(allPlayers, i);
|
|
221
|
+
if (mod.GetTeam(player) == team) teamMembers.push(player);
|
|
222
|
+
}
|
|
223
|
+
return teamMembers;
|
|
224
|
+
}
|
|
225
|
+
function __asModVector(param) {
|
|
226
|
+
if (Array.isArray(param)) return mod.CreateVector(param[0], param[1], param.length == 2 ? 0 : param[2]);
|
|
227
|
+
else return param;
|
|
228
|
+
}
|
|
229
|
+
function __asModMessage(param) {
|
|
230
|
+
if (typeof param === "string") return mod.Message(param);
|
|
231
|
+
return param;
|
|
232
|
+
}
|
|
233
|
+
function __fillInDefaultArgs(params) {
|
|
234
|
+
if (!params.hasOwnProperty("name")) params.name = "";
|
|
235
|
+
if (!params.hasOwnProperty("position")) params.position = mod.CreateVector(0, 0, 0);
|
|
236
|
+
if (!params.hasOwnProperty("size")) params.size = mod.CreateVector(100, 100, 0);
|
|
237
|
+
if (!params.hasOwnProperty("anchor")) params.anchor = mod.UIAnchor.TopLeft;
|
|
238
|
+
if (!params.hasOwnProperty("parent")) params.parent = mod.GetUIRoot();
|
|
239
|
+
if (!params.hasOwnProperty("visible")) params.visible = true;
|
|
240
|
+
if (!params.hasOwnProperty("padding")) params.padding = params.type == "Container" ? 0 : 8;
|
|
241
|
+
if (!params.hasOwnProperty("bgColor")) params.bgColor = mod.CreateVector(.25, .25, .25);
|
|
242
|
+
if (!params.hasOwnProperty("bgAlpha")) params.bgAlpha = .5;
|
|
243
|
+
if (!params.hasOwnProperty("bgFill")) params.bgFill = mod.UIBgFill.Solid;
|
|
244
|
+
}
|
|
245
|
+
function __setNameAndGetWidget(uniqueName, params) {
|
|
246
|
+
let widget = mod.FindUIWidgetWithName(uniqueName);
|
|
247
|
+
mod.SetUIWidgetName(widget, params.name);
|
|
248
|
+
return widget;
|
|
249
|
+
}
|
|
250
|
+
const __cUniqueName = "----uniquename----";
|
|
251
|
+
function __addUIContainer(params) {
|
|
252
|
+
__fillInDefaultArgs(params);
|
|
253
|
+
let restrict = params.teamId ?? params.playerId;
|
|
254
|
+
if (restrict) mod.AddUIContainer(__cUniqueName, __asModVector(params.position), __asModVector(params.size), params.anchor, params.parent, params.visible, params.padding, __asModVector(params.bgColor), params.bgAlpha, params.bgFill, restrict);
|
|
255
|
+
else mod.AddUIContainer(__cUniqueName, __asModVector(params.position), __asModVector(params.size), params.anchor, params.parent, params.visible, params.padding, __asModVector(params.bgColor), params.bgAlpha, params.bgFill);
|
|
256
|
+
let widget = __setNameAndGetWidget(__cUniqueName, params);
|
|
257
|
+
if (params.children) params.children.forEach((childParams) => {
|
|
258
|
+
childParams.parent = widget;
|
|
259
|
+
__addUIWidget(childParams);
|
|
260
|
+
});
|
|
261
|
+
return widget;
|
|
262
|
+
}
|
|
263
|
+
function __fillInDefaultTextArgs(params) {
|
|
264
|
+
if (!params.hasOwnProperty("textLabel")) params.textLabel = "";
|
|
265
|
+
if (!params.hasOwnProperty("textSize")) params.textSize = 0;
|
|
266
|
+
if (!params.hasOwnProperty("textColor")) params.textColor = mod.CreateVector(1, 1, 1);
|
|
267
|
+
if (!params.hasOwnProperty("textAlpha")) params.textAlpha = 1;
|
|
268
|
+
if (!params.hasOwnProperty("textAnchor")) params.textAnchor = mod.UIAnchor.CenterLeft;
|
|
269
|
+
}
|
|
270
|
+
function __addUIText(params) {
|
|
271
|
+
__fillInDefaultArgs(params);
|
|
272
|
+
__fillInDefaultTextArgs(params);
|
|
273
|
+
let restrict = params.teamId ?? params.playerId;
|
|
274
|
+
if (restrict) mod.AddUIText(__cUniqueName, __asModVector(params.position), __asModVector(params.size), params.anchor, params.parent, params.visible, params.padding, __asModVector(params.bgColor), params.bgAlpha, params.bgFill, __asModMessage(params.textLabel), params.textSize, __asModVector(params.textColor), params.textAlpha, params.textAnchor, restrict);
|
|
275
|
+
else mod.AddUIText(__cUniqueName, __asModVector(params.position), __asModVector(params.size), params.anchor, params.parent, params.visible, params.padding, __asModVector(params.bgColor), params.bgAlpha, params.bgFill, __asModMessage(params.textLabel), params.textSize, __asModVector(params.textColor), params.textAlpha, params.textAnchor);
|
|
276
|
+
return __setNameAndGetWidget(__cUniqueName, params);
|
|
277
|
+
}
|
|
278
|
+
function __fillInDefaultImageArgs(params) {
|
|
279
|
+
if (!params.hasOwnProperty("imageType")) params.imageType = mod.UIImageType.None;
|
|
280
|
+
if (!params.hasOwnProperty("imageColor")) params.imageColor = mod.CreateVector(1, 1, 1);
|
|
281
|
+
if (!params.hasOwnProperty("imageAlpha")) params.imageAlpha = 1;
|
|
282
|
+
}
|
|
283
|
+
function __addUIImage(params) {
|
|
284
|
+
__fillInDefaultArgs(params);
|
|
285
|
+
__fillInDefaultImageArgs(params);
|
|
286
|
+
let restrict = params.teamId ?? params.playerId;
|
|
287
|
+
if (restrict) mod.AddUIImage(__cUniqueName, __asModVector(params.position), __asModVector(params.size), params.anchor, params.parent, params.visible, params.padding, __asModVector(params.bgColor), params.bgAlpha, params.bgFill, params.imageType, __asModVector(params.imageColor), params.imageAlpha, restrict);
|
|
288
|
+
else mod.AddUIImage(__cUniqueName, __asModVector(params.position), __asModVector(params.size), params.anchor, params.parent, params.visible, params.padding, __asModVector(params.bgColor), params.bgAlpha, params.bgFill, params.imageType, __asModVector(params.imageColor), params.imageAlpha);
|
|
289
|
+
return __setNameAndGetWidget(__cUniqueName, params);
|
|
290
|
+
}
|
|
291
|
+
function __fillInDefaultButtonArgs(params) {
|
|
292
|
+
if (!params.hasOwnProperty("buttonEnabled")) params.buttonEnabled = true;
|
|
293
|
+
if (!params.hasOwnProperty("buttonColorBase")) params.buttonColorBase = mod.CreateVector(.7, .7, .7);
|
|
294
|
+
if (!params.hasOwnProperty("buttonAlphaBase")) params.buttonAlphaBase = 1;
|
|
295
|
+
if (!params.hasOwnProperty("buttonColorDisabled")) params.buttonColorDisabled = mod.CreateVector(.2, .2, .2);
|
|
296
|
+
if (!params.hasOwnProperty("buttonAlphaDisabled")) params.buttonAlphaDisabled = .5;
|
|
297
|
+
if (!params.hasOwnProperty("buttonColorPressed")) params.buttonColorPressed = mod.CreateVector(.25, .25, .25);
|
|
298
|
+
if (!params.hasOwnProperty("buttonAlphaPressed")) params.buttonAlphaPressed = 1;
|
|
299
|
+
if (!params.hasOwnProperty("buttonColorHover")) params.buttonColorHover = mod.CreateVector(1, 1, 1);
|
|
300
|
+
if (!params.hasOwnProperty("buttonAlphaHover")) params.buttonAlphaHover = 1;
|
|
301
|
+
if (!params.hasOwnProperty("buttonColorFocused")) params.buttonColorFocused = mod.CreateVector(1, 1, 1);
|
|
302
|
+
if (!params.hasOwnProperty("buttonAlphaFocused")) params.buttonAlphaFocused = 1;
|
|
303
|
+
}
|
|
304
|
+
function __addUIButton(params) {
|
|
305
|
+
__fillInDefaultArgs(params);
|
|
306
|
+
__fillInDefaultButtonArgs(params);
|
|
307
|
+
let restrict = params.teamId ?? params.playerId;
|
|
308
|
+
if (restrict) mod.AddUIButton(__cUniqueName, __asModVector(params.position), __asModVector(params.size), params.anchor, params.parent, params.visible, params.padding, __asModVector(params.bgColor), params.bgAlpha, params.bgFill, params.buttonEnabled, __asModVector(params.buttonColorBase), params.buttonAlphaBase, __asModVector(params.buttonColorDisabled), params.buttonAlphaDisabled, __asModVector(params.buttonColorPressed), params.buttonAlphaPressed, __asModVector(params.buttonColorHover), params.buttonAlphaHover, __asModVector(params.buttonColorFocused), params.buttonAlphaFocused, restrict);
|
|
309
|
+
else mod.AddUIButton(__cUniqueName, __asModVector(params.position), __asModVector(params.size), params.anchor, params.parent, params.visible, params.padding, __asModVector(params.bgColor), params.bgAlpha, params.bgFill, params.buttonEnabled, __asModVector(params.buttonColorBase), params.buttonAlphaBase, __asModVector(params.buttonColorDisabled), params.buttonAlphaDisabled, __asModVector(params.buttonColorPressed), params.buttonAlphaPressed, __asModVector(params.buttonColorHover), params.buttonAlphaHover, __asModVector(params.buttonColorFocused), params.buttonAlphaFocused);
|
|
310
|
+
return __setNameAndGetWidget(__cUniqueName, params);
|
|
311
|
+
}
|
|
312
|
+
function __addUIWidget(params) {
|
|
313
|
+
if (params == null) return void 0;
|
|
314
|
+
if (params.type == "Container") return __addUIContainer(params);
|
|
315
|
+
else if (params.type == "Text") return __addUIText(params);
|
|
316
|
+
else if (params.type == "Image") return __addUIImage(params);
|
|
317
|
+
else if (params.type == "Button") return __addUIButton(params);
|
|
318
|
+
}
|
|
319
|
+
function ParseUI(...params) {
|
|
320
|
+
let widget;
|
|
321
|
+
for (let a = 0; a < params.length; a++) widget = __addUIWidget(params[a]);
|
|
322
|
+
return widget;
|
|
323
|
+
}
|
|
324
|
+
function DisplayCustomNotificationMessage(msg, custom, duration, target) {
|
|
325
|
+
const CreateHeader = async (widgetId, msg$1, targetPlayer, slot) => {
|
|
326
|
+
mod.AddUIText(widgetId, mod.CreateVector(50, 250 + slot * 45, 0), mod.CreateVector(250, 60, 0), mod.UIAnchor.TopRight, mod.GetUIRoot(), true, 8, mod.CreateVector(1, 1, 1), 1, mod.UIBgFill.Blur, msg$1, 30, mod.CreateVector(1, 1, 1), 1, mod.UIAnchor.Center, targetPlayer);
|
|
327
|
+
if (duration > 0) {
|
|
328
|
+
await mod.Wait(duration);
|
|
329
|
+
mod.DeleteUIWidget(mod.FindUIWidgetWithName(widgetId));
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
const CreateSubText = async (widgetId, msg$1, targetPlayer, slot) => {
|
|
333
|
+
mod.AddUIText(widgetId, mod.CreateVector(85, 270 + slot * 43, 0), mod.CreateVector(125, 40, 0), mod.UIAnchor.TopRight, mod.GetUIRoot(), true, 8, mod.CreateVector(1, 1, 1), 1, mod.UIBgFill.Blur, msg$1, 20, mod.CreateVector(1, 1, 1), 1, mod.UIAnchor.Center, targetPlayer);
|
|
334
|
+
if (duration > 0) {
|
|
335
|
+
await mod.Wait(duration);
|
|
336
|
+
mod.DeleteUIWidget(mod.FindUIWidgetWithName(widgetId));
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
const createNotificationFunction = custom < 1 ? CreateHeader : CreateSubText;
|
|
340
|
+
if (target) {
|
|
341
|
+
if (mod.IsType(target, mod.Types.Player)) createNotificationFunction(custom + String(target), msg, target, custom);
|
|
342
|
+
else if (mod.IsType(target, mod.Types.Team)) getPlayersInTeam(target).forEach((player) => {
|
|
343
|
+
createNotificationFunction(custom + String(player), msg, player, custom);
|
|
344
|
+
});
|
|
345
|
+
} else {
|
|
346
|
+
const allPlayers = mod.AllPlayers();
|
|
347
|
+
const n = mod.CountOf(allPlayers);
|
|
348
|
+
for (let i = 0; i < n; i++) {
|
|
349
|
+
let player = mod.ValueInArray(allPlayers, i);
|
|
350
|
+
createNotificationFunction(custom + String(player), msg, player, custom);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function ShowEventGameModeMessage(event, target) {
|
|
355
|
+
const MakeShiftDisplayGameModeMessage = async (message, target$1) => {
|
|
356
|
+
const widgetId = "GameModeMessage";
|
|
357
|
+
if (target$1) mod.AddUIText(widgetId, mod.CreateVector(0, 0, 0), mod.CreateVector(2500, 80, 0), mod.UIAnchor.TopCenter, mod.GetUIRoot(), true, 8, mod.CreateVector(1, 1, 1), 1, mod.UIBgFill.Blur, message, 30, mod.CreateVector(1, 1, 1), 1, mod.UIAnchor.Center, target$1);
|
|
358
|
+
else mod.AddUIText(widgetId, mod.CreateVector(0, 0, 0), mod.CreateVector(2500, 80, 0), mod.UIAnchor.TopCenter, mod.GetUIRoot(), true, 8, mod.CreateVector(1, 1, 1), 1, mod.UIBgFill.Blur, message, 30, mod.CreateVector(1, 1, 1), 1, mod.UIAnchor.Center);
|
|
359
|
+
await mod.Wait(6);
|
|
360
|
+
mod.DeleteUIWidget(mod.FindUIWidgetWithName(widgetId));
|
|
361
|
+
};
|
|
362
|
+
if (target) MakeShiftDisplayGameModeMessage(event, target);
|
|
363
|
+
else MakeShiftDisplayGameModeMessage(event);
|
|
364
|
+
}
|
|
365
|
+
function ShowHighlightedGameModeMessage(event, target) {
|
|
366
|
+
if (target) mod.DisplayHighlightedWorldLogMessage(event, target);
|
|
367
|
+
else mod.DisplayHighlightedWorldLogMessage(event);
|
|
368
|
+
}
|
|
369
|
+
function ShowNotificationMessage(msg, target) {
|
|
370
|
+
if (target) mod.DisplayNotificationMessage(msg, target);
|
|
371
|
+
else mod.DisplayNotificationMessage(msg);
|
|
372
|
+
}
|
|
373
|
+
function ClearAllCustomNotificationMessages(target) {
|
|
374
|
+
try {
|
|
375
|
+
ClearCustomNotificationMessage(mod.CustomNotificationSlots.HeaderText, target);
|
|
376
|
+
} catch {}
|
|
377
|
+
try {
|
|
378
|
+
ClearCustomNotificationMessage(mod.CustomNotificationSlots.MessageText1, target);
|
|
379
|
+
} catch {}
|
|
380
|
+
try {
|
|
381
|
+
ClearCustomNotificationMessage(mod.CustomNotificationSlots.MessageText2, target);
|
|
382
|
+
} catch {}
|
|
383
|
+
try {
|
|
384
|
+
ClearCustomNotificationMessage(mod.CustomNotificationSlots.MessageText3, target);
|
|
385
|
+
} catch {}
|
|
386
|
+
try {
|
|
387
|
+
ClearCustomNotificationMessage(mod.CustomNotificationSlots.MessageText4, target);
|
|
388
|
+
} catch {}
|
|
389
|
+
}
|
|
390
|
+
function ClearCustomNotificationMessage(custom, target) {
|
|
391
|
+
try {
|
|
392
|
+
if (target) {
|
|
393
|
+
if (mod.IsType(target, mod.Types.Player)) mod.DeleteUIWidget(mod.FindUIWidgetWithName(custom + String(target)));
|
|
394
|
+
else if (mod.IsType(target, mod.Types.Team)) {
|
|
395
|
+
const teamMembers = getPlayersInTeam(target);
|
|
396
|
+
for (let i = 0; i < teamMembers.length; i++) {
|
|
397
|
+
let player = teamMembers[i];
|
|
398
|
+
mod.DeleteUIWidget(mod.FindUIWidgetWithName(custom + String(player)));
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
} else {
|
|
402
|
+
const allPlayers = mod.AllPlayers();
|
|
403
|
+
const n = mod.CountOf(allPlayers);
|
|
404
|
+
for (let i = 0; i < n; i++) {
|
|
405
|
+
let player = mod.ValueInArray(allPlayers, i);
|
|
406
|
+
mod.DeleteUIWidget(mod.FindUIWidgetWithName(custom + String(player)));
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
} catch {
|
|
410
|
+
console.error("Could not clear custom message for specified target(s)");
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
//#endregion
|
|
415
|
+
export { AiSpawnType, And, AndFn, AttachmentType, ClearAllCustomNotificationMessages, ClearCustomNotificationMessage, Concat, ConditionState, ConvertArray, DisplayCustomNotificationMessage, Equals, FactionID, FilteredArray, IfThenElse, IndexOfFirstTrue, IsTrueForAll, IsTrueForAny, ManDownExperienceType, ModBuilderGameMode, ParseUI, PingBehavior, ScoreboardType, ShowEventGameModeMessage, ShowHighlightedGameModeMessage, ShowNotificationMessage, SortedArray, SquadSpawnType, WaitUntil, getCapturePointCondition, getGlobalCondition, getMCOMCondition, getPlayerCondition, getPlayerId, getPlayersInTeam, getTeamCondition, getTeamId, getVehicleCondition };
|
|
2
416
|
//# sourceMappingURL=index.js.map
|