warscript 0.0.1-dev.524fae9 → 0.0.1-dev.5354486

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.
Files changed (40) hide show
  1. package/decl/native.d.ts +1 -0
  2. package/engine/ability-type-extended-tooltip.d.ts +8 -0
  3. package/engine/ability-type-extended-tooltip.lua +44 -0
  4. package/engine/behaviour/ability/emulate-impact.d.ts +14 -0
  5. package/engine/behaviour/ability/emulate-impact.lua +74 -1
  6. package/engine/behaviour/ability/instant-impact.d.ts +12 -1
  7. package/engine/behaviour/ability/instant-impact.lua +17 -2
  8. package/engine/behaviour/ability.d.ts +6 -0
  9. package/engine/behaviour/ability.lua +64 -8
  10. package/engine/buff.d.ts +53 -44
  11. package/engine/buff.lua +254 -227
  12. package/engine/internal/object-data/returned-melee-damage-factor.lua +21 -0
  13. package/engine/internal/unit/ability.lua +19 -15
  14. package/engine/internal/unit/bonus.d.ts +3 -0
  15. package/engine/internal/unit/bonus.lua +11 -0
  16. package/engine/internal/unit+ability.lua +10 -0
  17. package/engine/internal/unit.lua +3 -0
  18. package/engine/object-data/entry/ability-type/barrage.d.ts +12 -0
  19. package/engine/object-data/entry/ability-type/barrage.lua +52 -0
  20. package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -3
  21. package/engine/object-data/entry/ability-type/blank-configurable.lua +2 -32
  22. package/engine/object-data/entry/ability-type/blank-passive-with-cooldown.d.ts +23 -0
  23. package/engine/object-data/entry/ability-type/blank-passive-with-cooldown.lua +112 -0
  24. package/engine/object-data/entry/ability-type/channel.d.ts +2 -2
  25. package/engine/object-data/entry/ability-type/channel.lua +3 -3
  26. package/engine/object-data/entry/ability-type/exhume-corpses.d.ts +14 -0
  27. package/engine/object-data/entry/ability-type/exhume-corpses.lua +40 -0
  28. package/engine/object-data/entry/ability-type.d.ts +8 -2
  29. package/engine/object-data/entry/ability-type.lua +42 -3
  30. package/engine/object-data/entry/buff-type/applicable.lua +10 -3
  31. package/engine/object-data/entry/unit-type.d.ts +10 -0
  32. package/engine/object-data/entry/unit-type.lua +34 -20
  33. package/engine/random.lua +1 -1
  34. package/engine/standard/fields/ability.d.ts +2 -2
  35. package/engine/standard/fields/ability.lua +2 -2
  36. package/package.json +2 -2
  37. package/utility/arrays.d.ts +6 -1
  38. package/utility/arrays.lua +5 -0
  39. package/engine/internal/unit/pseudo-passive-abilities.lua +0 -11
  40. /package/engine/internal/{unit/pseudo-passive-abilities.d.ts → object-data/returned-melee-damage-factor.d.ts} +0 -0
@@ -69,6 +69,16 @@ export declare abstract class UnitType<Id extends UnitTypeId = UnitTypeId> exten
69
69
  protected static generateId(): number;
70
70
  protected static getObjectData(map: WarMap): WarObjects;
71
71
  private isPortraitModelPathSet?;
72
+ /** Portrait fields a model setter emptied because no portrait was set yet. */
73
+ private autoEmptiedPortraitFields?;
74
+ private emptyPortraitForModel;
75
+ /**
76
+ * An explicit portrait wins over the automatic empty portraits of the model setters, so
77
+ * it may also be set after the models: the mode-less portrait (one portrait for every
78
+ * mode) returns the automatically emptied per-mode portraits to their defaults, a
79
+ * per-mode portrait replaces only its own mode's.
80
+ */
81
+ private setPortraitModelPathField;
72
82
  get abilityTypeIds(): AbilityTypeId[];
73
83
  set abilityTypeIds(abilityTypeIds: AbilityTypeId[]);
74
84
  get defaultActiveAbilityTypeId(): AbilityTypeId | undefined;
@@ -484,6 +484,32 @@ end
484
484
  function UnitType.getObjectData(self, map)
485
485
  return map.objects.unit
486
486
  end
487
+ function UnitType.prototype.emptyPortraitForModel(self, portraitField)
488
+ if not self.isPortraitModelPathSet and WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
489
+ self:setStringField(portraitField, "")
490
+ if self.autoEmptiedPortraitFields == nil then
491
+ self.autoEmptiedPortraitFields = {}
492
+ end
493
+ self.autoEmptiedPortraitFields[portraitField] = true
494
+ end
495
+ end
496
+ function UnitType.prototype.setPortraitModelPathField(self, portraitField, portraitModelPath)
497
+ local autoEmptiedPortraitFields = self.autoEmptiedPortraitFields
498
+ if autoEmptiedPortraitFields ~= nil then
499
+ if portraitField == "upor" then
500
+ for field in pairs(autoEmptiedPortraitFields) do
501
+ if field ~= portraitField then
502
+ self.object:setField(field, nil)
503
+ end
504
+ end
505
+ self.autoEmptiedPortraitFields = nil
506
+ else
507
+ autoEmptiedPortraitFields[portraitField] = nil
508
+ end
509
+ end
510
+ self:setStringField(portraitField, portraitModelPath)
511
+ self.isPortraitModelPathSet = true
512
+ end
487
513
  function UnitType.prototype.setDeathTypeFlag(self, flag, value)
488
514
  local deathType = self:getNumberField("udea")
489
515
  self:setNumberField("udea", value and deathType | flag or deathType & ~flag)
@@ -1076,9 +1102,7 @@ __TS__SetDescriptor(
1076
1102
  end,
1077
1103
  set = function(self, modelPath)
1078
1104
  self:setStringField("umdl", modelPath)
1079
- if not self.isPortraitModelPathSet and WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
1080
- self:setStringField("upor", "")
1081
- end
1105
+ self:emptyPortraitForModel("upor")
1082
1106
  end
1083
1107
  },
1084
1108
  true
@@ -1092,9 +1116,7 @@ __TS__SetDescriptor(
1092
1116
  end,
1093
1117
  set = function(self, modelPathSD)
1094
1118
  self:setStringField("umdl:sd", modelPathSD)
1095
- if not self.isPortraitModelPathSet and WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
1096
- self:setStringField("upor:sd", "")
1097
- end
1119
+ self:emptyPortraitForModel("upor:sd")
1098
1120
  end
1099
1121
  },
1100
1122
  true
@@ -1108,9 +1130,7 @@ __TS__SetDescriptor(
1108
1130
  end,
1109
1131
  set = function(self, modelPathHD)
1110
1132
  self:setStringField("umdl:hd", modelPathHD)
1111
- if not self.isPortraitModelPathSet and WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
1112
- self:setStringField("upor:hd", "")
1113
- end
1133
+ self:emptyPortraitForModel("upor:hd")
1114
1134
  end
1115
1135
  },
1116
1136
  true
@@ -1124,9 +1144,7 @@ __TS__SetDescriptor(
1124
1144
  end,
1125
1145
  set = function(self, modelPathDE)
1126
1146
  self:setStringField("umdl:de", modelPathDE)
1127
- if not self.isPortraitModelPathSet and WarscriptConfig.AUTOMATICALLY_SET_UNIT_TYPE_PORTRAIT_MODEL_PATH then
1128
- self:setStringField("upor:de", "")
1129
- end
1147
+ self:emptyPortraitForModel("upor:de")
1130
1148
  end
1131
1149
  },
1132
1150
  true
@@ -1139,8 +1157,7 @@ __TS__SetDescriptor(
1139
1157
  return self:getStringField("upor")
1140
1158
  end,
1141
1159
  set = function(self, portraitModelPath)
1142
- self:setStringField("upor", portraitModelPath)
1143
- self.isPortraitModelPathSet = true
1160
+ self:setPortraitModelPathField("upor", portraitModelPath)
1144
1161
  end
1145
1162
  },
1146
1163
  true
@@ -1153,8 +1170,7 @@ __TS__SetDescriptor(
1153
1170
  return self:getStringField("upor:sd")
1154
1171
  end,
1155
1172
  set = function(self, portraitModelPathSD)
1156
- self:setStringField("upor:sd", portraitModelPathSD)
1157
- self.isPortraitModelPathSet = true
1173
+ self:setPortraitModelPathField("upor:sd", portraitModelPathSD)
1158
1174
  end
1159
1175
  },
1160
1176
  true
@@ -1167,8 +1183,7 @@ __TS__SetDescriptor(
1167
1183
  return self:getStringField("upor:hd")
1168
1184
  end,
1169
1185
  set = function(self, portraitModelPathHD)
1170
- self:setStringField("upor:hd", portraitModelPathHD)
1171
- self.isPortraitModelPathSet = true
1186
+ self:setPortraitModelPathField("upor:hd", portraitModelPathHD)
1172
1187
  end
1173
1188
  },
1174
1189
  true
@@ -1181,8 +1196,7 @@ __TS__SetDescriptor(
1181
1196
  return self:getStringField("upor:de")
1182
1197
  end,
1183
1198
  set = function(self, portraitModelPathDE)
1184
- self:setStringField("upor:de", portraitModelPathDE)
1185
- self.isPortraitModelPathSet = true
1199
+ self:setPortraitModelPathField("upor:de", portraitModelPathDE)
1186
1200
  end
1187
1201
  },
1188
1202
  true
package/engine/random.lua CHANGED
@@ -29,7 +29,7 @@ ____exports.random = function(...)
29
29
  ))
30
30
  end
31
31
  ____exports.shuffle = function(array)
32
- for i = #array - 1, 1 do
32
+ for i = #array - 1, 1, -1 do
33
33
  local j = getRandomInt(0, i)
34
34
  local value = array[i + 1]
35
35
  array[i + 1] = array[j + 1]
@@ -7,8 +7,8 @@ export declare const BUTTON_POSITION_ACTIVATED_Y_ABILITY_INTEGER_FIELD: AbilityI
7
7
  export declare const BUTTON_POSITION_RESEARCH_X_ABILITY_INTEGER_FIELD: AbilityIntegerField & symbol;
8
8
  export declare const BUTTON_POSITION_RESEARCH_Y_ABILITY_INTEGER_FIELD: AbilityIntegerField & symbol;
9
9
  export declare const MISSILE_SPEED_ABILITY_INTEGER_FIELD: AbilityIntegerField & symbol;
10
- export declare const TARGET_ATTACHMENTS_ABILITY_INTEGER_FIELD: AbilityIntegerField & symbol;
11
- export declare const CASTER_ATTACHMENTS_ABILITY_INTEGER_FIELD: AbilityIntegerField & symbol;
10
+ export declare const TARGET_EFFECT_COUNT_ABILITY_INTEGER_FIELD: AbilityIntegerField & symbol;
11
+ export declare const CASTER_EFFECT_COUNT_ABILITY_INTEGER_FIELD: AbilityIntegerField & symbol;
12
12
  export declare const PRIORITY_ABILITY_INTEGER_FIELD: AbilityIntegerField & symbol;
13
13
  export declare const LEVELS_ABILITY_INTEGER_FIELD: AbilityIntegerField & symbol;
14
14
  export declare const REQUIRED_LEVEL_ABILITY_INTEGER_FIELD: AbilityIntegerField & symbol;
@@ -18,8 +18,8 @@ ____exports.BUTTON_POSITION_ACTIVATED_Y_ABILITY_INTEGER_FIELD = AbilityIntegerFi
18
18
  ____exports.BUTTON_POSITION_RESEARCH_X_ABILITY_INTEGER_FIELD = AbilityIntegerField:create(fourCC("arpx"))
19
19
  ____exports.BUTTON_POSITION_RESEARCH_Y_ABILITY_INTEGER_FIELD = AbilityIntegerField:create(fourCC("arpy"))
20
20
  ____exports.MISSILE_SPEED_ABILITY_INTEGER_FIELD = AbilityIntegerField:create(fourCC("amsp"))
21
- ____exports.TARGET_ATTACHMENTS_ABILITY_INTEGER_FIELD = AbilityIntegerField:create(fourCC("atac"))
22
- ____exports.CASTER_ATTACHMENTS_ABILITY_INTEGER_FIELD = AbilityIntegerField:create(fourCC("acac"))
21
+ ____exports.TARGET_EFFECT_COUNT_ABILITY_INTEGER_FIELD = AbilityIntegerField:create(fourCC("atac"))
22
+ ____exports.CASTER_EFFECT_COUNT_ABILITY_INTEGER_FIELD = AbilityIntegerField:create(fourCC("acac"))
23
23
  ____exports.PRIORITY_ABILITY_INTEGER_FIELD = AbilityIntegerField:create(fourCC("apri"))
24
24
  ____exports.LEVELS_ABILITY_INTEGER_FIELD = AbilityIntegerField:create(fourCC("alev"))
25
25
  ____exports.REQUIRED_LEVEL_ABILITY_INTEGER_FIELD = AbilityIntegerField:create(fourCC("arlv"))
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "warscript",
4
- "version": "0.0.1-dev.524fae9",
4
+ "version": "0.0.1-dev.5354486",
5
5
  "description": "A typescript library for Warcraft III using Warpack.",
6
6
  "keywords": [
7
7
  "warcraft",
@@ -17,7 +17,7 @@
17
17
  "@warscript/language-extensions": "^0.0.1",
18
18
  "@warscript/tstl-plugin": "^0.0.6",
19
19
  "lua-types": "^2.13.1",
20
- "warpack": "0.0.1-dev.2e316da"
20
+ "warpack": "0.0.1-dev.eb3e92a"
21
21
  },
22
22
  "publishConfig": {
23
23
  "access": "public",
@@ -1,6 +1,11 @@
1
1
  /** @noSelfInFile */
2
- import { TupleOf } from "./types";
2
+ import { NonEmptyArray, ReadonlyNonEmptyArray, TupleOf } from "./types";
3
3
  export declare const emptyArray: <T>() => readonly T[];
4
+ /** Checks for any element with `next` instead of computing the length. */
5
+ export declare const isNonEmptyArray: {
6
+ <T>(array: T[]): array is NonEmptyArray<T>;
7
+ <T>(array: readonly T[]): array is ReadonlyNonEmptyArray<T>;
8
+ };
4
9
  export declare const joinToString: <T>(array: readonly T[], separator: string, transform?: (element: T) => string) => string;
5
10
  export declare const arrayOfNotNull: <T>(...elements: readonly (T | undefined | null)[]) => T[];
6
11
  export declare const array: <T, N extends number>(length: N, initialize: (index: number) => T) => TupleOf<T, N>;
@@ -7,6 +7,7 @@ local ____functions = require("utility.functions")
7
7
  local identity = ____functions.identity
8
8
  local mathMax = math.max
9
9
  local mathMin = math.min
10
+ local next = _G.next
10
11
  local select = _G.select
11
12
  local tableConcat = table.concat
12
13
  local tableSort = table.sort
@@ -14,6 +15,10 @@ local EMPTY_ARRAY = {}
14
15
  ____exports.emptyArray = function()
15
16
  return EMPTY_ARRAY
16
17
  end
18
+ --- Checks for any element with `next` instead of computing the length.
19
+ ____exports.isNonEmptyArray = function(array)
20
+ return (next(array)) ~= nil
21
+ end
17
22
  ____exports.joinToString = function(array, separator, transform)
18
23
  if transform == nil then
19
24
  transform = tostring
@@ -1,11 +0,0 @@
1
- local ____exports = {}
2
- ---
3
- -- @internal For use by internal systems only.
4
- ____exports.compiletimePseudoPassiveAbilityTypeIds = {}
5
- ---
6
- -- @internal For use by internal systems only.
7
- ____exports.pseudoPassiveAbilityTypeIds = postcompile(function() return ____exports.compiletimePseudoPassiveAbilityTypeIds end)
8
- ---
9
- -- @internal For use by internal systems only.
10
- ____exports.pseudoPassiveAbilityOrderTypeStringId = "channel"
11
- return ____exports