warscript 0.0.1-dev.1d3eae2 → 0.0.1-dev.1da5f63

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.
@@ -0,0 +1,17 @@
1
+ /** @noSelfInFile */
2
+ declare module "../unit" {
3
+ interface Unit {
4
+ strengthBase: number;
5
+ }
6
+ }
7
+ declare module "../unit" {
8
+ interface Unit {
9
+ agilityBase: number;
10
+ }
11
+ }
12
+ declare module "../unit" {
13
+ interface Unit {
14
+ intelligenceBase: number;
15
+ }
16
+ }
17
+ export {};
@@ -0,0 +1,46 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
3
+ local ____exports = {}
4
+ local ____unit = require("engine.internal.unit")
5
+ local Unit = ____unit.Unit
6
+ local ____unit = require("engine.standard.fields.unit")
7
+ local AGILITY_UNIT_FIELD = ____unit.AGILITY_UNIT_FIELD
8
+ local INTELLIGENCE_UNIT_FIELD = ____unit.INTELLIGENCE_UNIT_FIELD
9
+ local STRENGTH_UNIT_FIELD = ____unit.STRENGTH_UNIT_FIELD
10
+ __TS__ObjectDefineProperty(
11
+ Unit.prototype,
12
+ "strengthBase",
13
+ {
14
+ get = function(self)
15
+ return STRENGTH_UNIT_FIELD:getValue(self)
16
+ end,
17
+ set = function(self, value)
18
+ STRENGTH_UNIT_FIELD:setValue(self, value)
19
+ end
20
+ }
21
+ )
22
+ __TS__ObjectDefineProperty(
23
+ Unit.prototype,
24
+ "agilityBase",
25
+ {
26
+ get = function(self)
27
+ return AGILITY_UNIT_FIELD:getValue(self)
28
+ end,
29
+ set = function(self, value)
30
+ AGILITY_UNIT_FIELD:setValue(self, value)
31
+ end
32
+ }
33
+ )
34
+ __TS__ObjectDefineProperty(
35
+ Unit.prototype,
36
+ "intelligenceBase",
37
+ {
38
+ get = function(self)
39
+ return INTELLIGENCE_UNIT_FIELD:getValue(self)
40
+ end,
41
+ set = function(self, value)
42
+ INTELLIGENCE_UNIT_FIELD:setValue(self, value)
43
+ end
44
+ }
45
+ )
46
+ return ____exports
@@ -4,16 +4,16 @@ local ____exports = {}
4
4
  local ____unit = require("engine.internal.unit")
5
5
  local Unit = ____unit.Unit
6
6
  local ____unit = require("engine.standard.fields.unit")
7
- local FLY_HEIGHT_UNIT_FLOAT_FIELD = ____unit.FLY_HEIGHT_UNIT_FLOAT_FIELD
7
+ local FLY_HEIGHT_UNIT_FIELD = ____unit.FLY_HEIGHT_UNIT_FIELD
8
8
  __TS__ObjectDefineProperty(
9
9
  Unit.prototype,
10
10
  "flyHeight",
11
11
  {
12
12
  get = function(self)
13
- return FLY_HEIGHT_UNIT_FLOAT_FIELD:getValue(self)
13
+ return FLY_HEIGHT_UNIT_FIELD:getValue(self)
14
14
  end,
15
15
  set = function(self, value)
16
- FLY_HEIGHT_UNIT_FLOAT_FIELD:setValue(self, value)
16
+ FLY_HEIGHT_UNIT_FIELD:setValue(self, value)
17
17
  end
18
18
  }
19
19
  )
@@ -4,16 +4,16 @@ local ____exports = {}
4
4
  local ____unit = require("engine.internal.unit")
5
5
  local Unit = ____unit.Unit
6
6
  local ____unit = require("engine.standard.fields.unit")
7
- local SCALING_VALUE_UNIT_FLOAT_FIELD = ____unit.SCALING_VALUE_UNIT_FLOAT_FIELD
7
+ local SCALING_VALUE_UNIT_FIELD = ____unit.SCALING_VALUE_UNIT_FIELD
8
8
  __TS__ObjectDefineProperty(
9
9
  Unit.prototype,
10
10
  "scale",
11
11
  {
12
12
  get = function(self)
13
- return SCALING_VALUE_UNIT_FLOAT_FIELD:getValue(self)
13
+ return SCALING_VALUE_UNIT_FIELD:getValue(self)
14
14
  end,
15
15
  set = function(self, value)
16
- SCALING_VALUE_UNIT_FLOAT_FIELD:setValue(self, value)
16
+ SCALING_VALUE_UNIT_FIELD:setValue(self, value)
17
17
  end
18
18
  }
19
19
  )
@@ -177,16 +177,10 @@ export declare class Unit extends Handle<junit> {
177
177
  set xp(v: number);
178
178
  get primaryAttribute(): UnitAttribute;
179
179
  set primaryAttribute(primaryAttribute: UnitAttribute);
180
- get strengthBase(): number;
181
- set strengthBase(strengthBase: number);
182
180
  get strengthBonus(): number;
183
181
  get strength(): number;
184
- get agilityBase(): number;
185
- set agilityBase(agilityBase: number);
186
182
  get agilityBonus(): number;
187
183
  get agility(): number;
188
- get intelligenceBase(): number;
189
- set intelligenceBase(intelligenceBase: number);
190
184
  get intelligenceBonus(): number;
191
185
  get intelligence(): number;
192
186
  get name(): string;
@@ -318,6 +312,7 @@ export declare class Unit extends Handle<junit> {
318
312
  static getInCollisionRange(x: number, y: number, range: number, predicate?: (unit: Unit) => boolean): Unit[];
319
313
  static getInSector(pos: Vec2, range: number, offsetAngle: number, centralAngle: number): Unit[];
320
314
  static getSelectionOf(player: Player, target?: Unit[]): Unit[];
315
+ static readonly levelChangedEvent: UnitTriggerEvent<[]>;
321
316
  static readonly deathEvent: UnitTriggerEvent<[Unit]>;
322
317
  static readonly onDecay: UnitTriggerEvent<[]>;
323
318
  static readonly onResurrect: InitializingEvent<[Unit], void>;
@@ -73,16 +73,12 @@ local getUnitRealField = BlzGetUnitRealField
73
73
  local getHeroStr = GetHeroStr
74
74
  local getHeroAgi = GetHeroAgi
75
75
  local getHeroInt = GetHeroInt
76
- local setHeroStr = SetHeroStr
77
- local setHeroAgi = SetHeroAgi
78
- local setHeroInt = SetHeroInt
79
76
  local getUnitBooleanField = BlzGetUnitBooleanField
80
77
  local getUnitStringField = BlzGetUnitStringField
81
78
  local setUnitIntegerField = BlzSetUnitIntegerField
82
79
  local setUnitRealField = BlzSetUnitRealField
83
80
  local setUnitBooleanField = BlzSetUnitBooleanField
84
81
  local setUnitStringField = BlzSetUnitStringField
85
- local setUnitScale = SetUnitScale
86
82
  local setUnitPosition = SetUnitPosition
87
83
  local setUnitTimeScale = SetUnitTimeScale
88
84
  local getHandleId = GetHandleId
@@ -1392,19 +1388,6 @@ __TS__SetDescriptor(
1392
1388
  },
1393
1389
  true
1394
1390
  )
1395
- __TS__SetDescriptor(
1396
- Unit.prototype,
1397
- "strengthBase",
1398
- {
1399
- get = function(self)
1400
- return getHeroStr(self.handle, false)
1401
- end,
1402
- set = function(self, strengthBase)
1403
- setHeroStr(self.handle, strengthBase, true)
1404
- end
1405
- },
1406
- true
1407
- )
1408
1391
  __TS__SetDescriptor(
1409
1392
  Unit.prototype,
1410
1393
  "strengthBonus",
@@ -1422,19 +1405,6 @@ __TS__SetDescriptor(
1422
1405
  end},
1423
1406
  true
1424
1407
  )
1425
- __TS__SetDescriptor(
1426
- Unit.prototype,
1427
- "agilityBase",
1428
- {
1429
- get = function(self)
1430
- return getHeroAgi(self.handle, false)
1431
- end,
1432
- set = function(self, agilityBase)
1433
- setHeroAgi(self.handle, agilityBase, true)
1434
- end
1435
- },
1436
- true
1437
- )
1438
1408
  __TS__SetDescriptor(
1439
1409
  Unit.prototype,
1440
1410
  "agilityBonus",
@@ -1452,19 +1422,6 @@ __TS__SetDescriptor(
1452
1422
  end},
1453
1423
  true
1454
1424
  )
1455
- __TS__SetDescriptor(
1456
- Unit.prototype,
1457
- "intelligenceBase",
1458
- {
1459
- get = function(self)
1460
- return getHeroInt(self.handle, false)
1461
- end,
1462
- set = function(self, intelligenceBase)
1463
- setHeroInt(self.handle, intelligenceBase, true)
1464
- end
1465
- },
1466
- true
1467
- )
1468
1425
  __TS__SetDescriptor(
1469
1426
  Unit.prototype,
1470
1427
  "intelligenceBonus",
@@ -2172,6 +2129,11 @@ __TS__SetDescriptor(
2172
2129
  end},
2173
2130
  true
2174
2131
  )
2132
+ Unit.levelChangedEvent = __TS__New(
2133
+ ____exports.UnitTriggerEvent,
2134
+ EVENT_PLAYER_HERO_LEVEL,
2135
+ function() return ____exports.Unit:of(getTriggerUnit()) end
2136
+ )
2175
2137
  Unit.deathEvent = __TS__New(
2176
2138
  ____exports.UnitTriggerEvent,
2177
2139
  EVENT_PLAYER_UNIT_DEATH,
@@ -46,6 +46,7 @@ export declare abstract class ObjectField<ObjectDataEntryType extends ObjectData
46
46
  private modifiersByInstance?;
47
47
  getValue(entry: ObjectDataEntryType | InstanceType, includeModifiers?: boolean): ValueType;
48
48
  setValue(entry: ObjectDataEntryType | InstanceType, value: ValueType): boolean;
49
+ updateActualValue(instance: InstanceType): void;
49
50
  applyModifier(instance: InstanceType, modifier: ObjectFieldModifier<InstanceType, ValueType>): void;
50
51
  removeModifier(instance: InstanceType, modifier: ObjectFieldModifier<InstanceType, ValueType>): boolean;
51
52
  removeValue(entry: ObjectDataEntryType): boolean;
@@ -89,6 +90,7 @@ export declare abstract class ObjectLevelField<ObjectDataEntryType extends Objec
89
90
  protected abstract getLevelCount(entry: ObjectDataEntryType | InstanceType): number;
90
91
  getValue<LevelType extends [number] | []>(entry: ObjectDataEntryType | InstanceType, ...[level]: LevelType): LevelType extends [number] ? ValueType : ValueType[];
91
92
  setValue(entry: ObjectDataEntryType | InstanceType, ...[levelOrValue, value]: [value: ObjectDataEntryLevelFieldValueSupplier<InputValueType, ValueType>] | [level: number, value: InputValueType]): boolean;
93
+ updateActualValue(instance: InstanceType, level?: number): void;
92
94
  applyModifier(instance: InstanceType, modifier: ObjectLevelFieldModifier<InstanceType, ValueType>): void;
93
95
  removeModifier(instance: InstanceType, modifier: ObjectLevelFieldModifier<InstanceType, ValueType>): boolean;
94
96
  trySetValue(entry: ObjectDataEntryType | InstanceType, levelOrValue: number | unknown, value?: unknown): boolean;
@@ -139,7 +139,7 @@ function ObjectField.prototype.setValue(self, entry, value)
139
139
  return true
140
140
  end
141
141
  originalValueByInstance[entry] = value
142
- value = self:calculateActualValue(entry)
142
+ value = (self:calculateActualValue(entry))
143
143
  end
144
144
  end
145
145
  local previousValue = self:setActualValue(entry, value)
@@ -163,6 +163,12 @@ function ObjectField.prototype.setValue(self, entry, value)
163
163
  end
164
164
  return true
165
165
  end
166
+ function ObjectField.prototype.updateActualValue(self, instance)
167
+ local actualValue, hasModifiers = self:calculateActualValue(instance)
168
+ if hasModifiers then
169
+ self:setActualValue(instance, actualValue)
170
+ end
171
+ end
166
172
  function ObjectField.prototype.applyModifier(self, instance, modifier)
167
173
  local modifiersByInstance = self.modifiersByInstance
168
174
  if modifiersByInstance == nil then
@@ -182,10 +188,7 @@ function ObjectField.prototype.applyModifier(self, instance, modifier)
182
188
  ____originalValueByInstance_instance_3 = self:getActualValue(instance)
183
189
  end
184
190
  ____originalValueByInstance_4[____instance_5] = ____originalValueByInstance_instance_3
185
- self:setActualValue(
186
- instance,
187
- self:calculateActualValue(instance)
188
- )
191
+ self:setActualValue(instance, (self:calculateActualValue(instance)))
189
192
  end
190
193
  end
191
194
  function ObjectField.prototype.removeModifier(self, instance, modifier)
@@ -193,10 +196,7 @@ function ObjectField.prototype.removeModifier(self, instance, modifier)
193
196
  if modifiersByInstance ~= nil then
194
197
  local modifiers = modifiersByInstance[instance]
195
198
  if modifiers ~= nil and modifiers:remove(modifier) then
196
- self:setActualValue(
197
- instance,
198
- self:calculateActualValue(instance)
199
- )
199
+ self:setActualValue(instance, (self:calculateActualValue(instance)))
200
200
  return true
201
201
  end
202
202
  end
@@ -283,10 +283,11 @@ function ObjectField.prototype.calculateActualValue(self, instance)
283
283
  for modifier in pairs(modifiers) do
284
284
  value = modifier(instance, value, originalValue)
285
285
  end
286
+ return value, true
286
287
  end
287
- return value
288
+ return value, false
288
289
  end
289
- return self.defaultValue
290
+ return self.defaultValue, false
290
291
  end
291
292
  function ObjectField.prototype.invokeValueChangeEvent(self, ...)
292
293
  self:invokeValueChangeEventRecursive(
@@ -512,6 +513,27 @@ function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
512
513
  end
513
514
  return true
514
515
  end
516
+ function ObjectLevelField.prototype.updateActualValue(self, instance, level)
517
+ local modifiersByInstance = self.modifiersByInstance
518
+ if modifiersByInstance == nil then
519
+ return
520
+ end
521
+ local modifiers = modifiersByInstance[instance]
522
+ if modifiers == nil or modifiers.size == 0 then
523
+ return
524
+ end
525
+ if level == nil then
526
+ for i = 0, self:getLevelCount(instance) - 1 do
527
+ self:updateActualValue(instance, i)
528
+ end
529
+ return
530
+ end
531
+ self:setActualValue(
532
+ instance,
533
+ level,
534
+ self:calculateActualValue(instance, level)
535
+ )
536
+ end
515
537
  function ObjectLevelField.prototype.applyModifier(self, instance, modifier)
516
538
  local modifiersByInstance = self.modifiersByInstance
517
539
  if modifiersByInstance == nil then
@@ -1,9 +1,12 @@
1
1
  /** @noSelfInFile */
2
- import { UnitClassificationsField, UnitFloatField, UnitFlyHeightField, UnitHealthRegenerationTypeField, UnitPropulsionWindowField, UnitScalingValueField } from "../../object-field/unit";
3
- export declare const PROPULSION_WINDOW_UNIT_FLOAT_FIELD: UnitPropulsionWindowField & symbol;
4
- export declare const UNIT_CLASSIFICATIONS_FIELD: UnitClassificationsField & symbol;
5
- export declare const FLY_HEIGHT_UNIT_FLOAT_FIELD: UnitFlyHeightField & symbol;
6
- export declare const SCALING_VALUE_UNIT_FLOAT_FIELD: UnitScalingValueField & symbol;
7
- export declare const HEALTH_REGENERATION_RATE_UNIT_FLOAT_FIELD: UnitFloatField & symbol;
8
- export declare const MANA_REGENERATION_RATE_UNIT_FLOAT_FIELD: UnitFloatField & symbol;
9
- export declare const UNIT_HEALTH_REGENERATION_TYPE_FIELD: UnitHealthRegenerationTypeField & symbol;
2
+ import { UnitClassificationsField, UnitFloatField, UnitFlyHeightField, UnitHealthRegenerationTypeField, UnitIntegerField, UnitPropulsionWindowField, UnitScalingValueField } from "../../object-field/unit";
3
+ export declare const PROPULSION_WINDOW_UNIT_FIELD: UnitPropulsionWindowField & symbol;
4
+ export declare const CLASSIFICATIONS_UNIT_FIELD: UnitClassificationsField & symbol;
5
+ export declare const FLY_HEIGHT_UNIT_FIELD: UnitFlyHeightField & symbol;
6
+ export declare const SCALING_VALUE_UNIT_FIELD: UnitScalingValueField & symbol;
7
+ export declare const HEALTH_REGENERATION_RATE_UNIT_FIELD: UnitFloatField & symbol;
8
+ export declare const MANA_REGENERATION_RATE_UNIT_FIELD: UnitFloatField & symbol;
9
+ export declare const HEALTH_REGENERATION_TYPE_UNIT_FIELD: UnitHealthRegenerationTypeField & symbol;
10
+ export declare const STRENGTH_UNIT_FIELD: UnitIntegerField<number> & symbol;
11
+ export declare const AGILITY_UNIT_FIELD: UnitIntegerField<number> & symbol;
12
+ export declare const INTELLIGENCE_UNIT_FIELD: UnitIntegerField<number> & symbol;
@@ -4,13 +4,17 @@ local UnitClassificationsField = ____unit.UnitClassificationsField
4
4
  local UnitFloatField = ____unit.UnitFloatField
5
5
  local UnitFlyHeightField = ____unit.UnitFlyHeightField
6
6
  local UnitHealthRegenerationTypeField = ____unit.UnitHealthRegenerationTypeField
7
+ local UnitIntegerField = ____unit.UnitIntegerField
7
8
  local UnitPropulsionWindowField = ____unit.UnitPropulsionWindowField
8
9
  local UnitScalingValueField = ____unit.UnitScalingValueField
9
- ____exports.PROPULSION_WINDOW_UNIT_FLOAT_FIELD = UnitPropulsionWindowField:create(fourCC("urpw"))
10
- ____exports.UNIT_CLASSIFICATIONS_FIELD = UnitClassificationsField:create(fourCC("utyp"))
11
- ____exports.FLY_HEIGHT_UNIT_FLOAT_FIELD = UnitFlyHeightField:create(fourCC("ufyh"))
12
- ____exports.SCALING_VALUE_UNIT_FLOAT_FIELD = UnitScalingValueField:create(fourCC("usca"))
13
- ____exports.HEALTH_REGENERATION_RATE_UNIT_FLOAT_FIELD = UnitFloatField:create(fourCC("uhpr"))
14
- ____exports.MANA_REGENERATION_RATE_UNIT_FLOAT_FIELD = UnitFloatField:create(fourCC("umpr"))
15
- ____exports.UNIT_HEALTH_REGENERATION_TYPE_FIELD = UnitHealthRegenerationTypeField:create(fourCC("uhrt"))
10
+ ____exports.PROPULSION_WINDOW_UNIT_FIELD = UnitPropulsionWindowField:create(fourCC("urpw"))
11
+ ____exports.CLASSIFICATIONS_UNIT_FIELD = UnitClassificationsField:create(fourCC("utyp"))
12
+ ____exports.FLY_HEIGHT_UNIT_FIELD = UnitFlyHeightField:create(fourCC("ufyh"))
13
+ ____exports.SCALING_VALUE_UNIT_FIELD = UnitScalingValueField:create(fourCC("usca"))
14
+ ____exports.HEALTH_REGENERATION_RATE_UNIT_FIELD = UnitFloatField:create(fourCC("uhpr"))
15
+ ____exports.MANA_REGENERATION_RATE_UNIT_FIELD = UnitFloatField:create(fourCC("umpr"))
16
+ ____exports.HEALTH_REGENERATION_TYPE_UNIT_FIELD = UnitHealthRegenerationTypeField:create(fourCC("uhrt"))
17
+ ____exports.STRENGTH_UNIT_FIELD = UnitIntegerField:create(fourCC("ustc"))
18
+ ____exports.AGILITY_UNIT_FIELD = UnitIntegerField:create(fourCC("uagc"))
19
+ ____exports.INTELLIGENCE_UNIT_FIELD = UnitIntegerField:create(fourCC("uinc"))
16
20
  return ____exports
package/engine/unit.d.ts CHANGED
@@ -19,6 +19,7 @@ import "./internal/unit/invulnerability-counter";
19
19
  import "./internal/unit/detach-missiles";
20
20
  import "./internal/unit/main-selected";
21
21
  import "./internal/unit/add-item-to-slot-init";
22
+ import "./internal/unit/attributes";
22
23
  import "./internal/unit/fly-height";
23
24
  import "./internal/unit/scale";
24
25
  import "./internal/unit/band-aids/ancestral-spirit-cannibalize";
package/engine/unit.lua CHANGED
@@ -19,6 +19,7 @@ require("engine.internal.unit.invulnerability-counter")
19
19
  require("engine.internal.unit.detach-missiles")
20
20
  require("engine.internal.unit.main-selected")
21
21
  require("engine.internal.unit.add-item-to-slot-init")
22
+ require("engine.internal.unit.attributes")
22
23
  require("engine.internal.unit.fly-height")
23
24
  require("engine.internal.unit.scale")
24
25
  require("engine.internal.unit.band-aids.ancestral-spirit-cannibalize")
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.1d3eae2",
4
+ "version": "0.0.1-dev.1da5f63",
5
5
  "description": "A typescript library for Warcraft III using Warpack.",
6
6
  "keywords": [
7
7
  "warcraft",