@amxts/core 0.1.0 → 0.2.0

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 (74) hide show
  1. package/README.md +18 -23
  2. package/README.ru.md +19 -22
  3. package/as/amxts.d.ts +63 -3
  4. package/as/constants.ts +684 -116
  5. package/as/entities.ts +1905 -1364
  6. package/as/events.ts +1694 -905
  7. package/as/facade.ts +1240 -220
  8. package/as/fetch.ts +1519 -0
  9. package/as/flags.ts +159 -145
  10. package/as/hlds.ts +1071 -0
  11. package/as/hooks.ts +5226 -5379
  12. package/as/kit.ts +15 -5
  13. package/as/lib/check.ts +1 -1
  14. package/as/natives.ts +2658 -2499
  15. package/as/remote.ts +39 -15
  16. package/as/tsconfig.json +6 -2
  17. package/as/vector.ts +12 -9
  18. package/includes/order.txt +22 -29
  19. package/includes/sources.json +0 -8
  20. package/node_modules/assemblyscript/std/assembly/index.d.ts +20 -11
  21. package/package.json +29 -7
  22. package/runtime/deps/assemblyscript/dist/asc.js +86 -16
  23. package/runtime/deps/assemblyscript/dist/assemblyscript.js +29 -29
  24. package/runtime/licenses/MPL-2.0.txt +373 -0
  25. package/runtime/licenses/README.md +5 -1
  26. package/runtime/licenses/curl-COPYING +22 -0
  27. package/runtime/licenses/libssh2-COPYING +43 -0
  28. package/runtime/licenses/mbedTLS-LICENSE +553 -0
  29. package/runtime/natives.txt +108 -105
  30. package/runtime/patches/assemblyscript-0.28.20-amxts.patch +752 -296
  31. package/runtime/patches/wamr-2.4.5-amxts.patch +148 -0
  32. package/scripts/apply-docs.ts +2 -2
  33. package/scripts/auto-imports.ts +2 -2
  34. package/scripts/build-identity.ts +115 -0
  35. package/scripts/build-wasm.ts +101 -50
  36. package/scripts/check.ts +17 -3
  37. package/scripts/client-messages.ts +246 -0
  38. package/scripts/compile-pool.ts +128 -0
  39. package/scripts/compile-worker.ts +23 -0
  40. package/scripts/compile.ts +156 -59
  41. package/scripts/docker-server.ts +13 -3
  42. package/scripts/docs/as/amxts.ts +86 -0
  43. package/scripts/docs/as/facade.ts +688 -188
  44. package/scripts/docs/as/fetch.ts +805 -0
  45. package/scripts/docs/entities.ts +43 -144
  46. package/scripts/docs/events.ts +15 -26
  47. package/scripts/docs/game.ts +68 -22
  48. package/scripts/docs/messages.ts +330 -16
  49. package/scripts/editor-api.ts +101 -0
  50. package/scripts/hlds-events.ts +370 -0
  51. package/scripts/includes.ts +12 -10
  52. package/scripts/player-fields.ts +16 -15
  53. package/scripts/prebuilt.ts +65 -23
  54. package/scripts/prepare.ts +39 -28
  55. package/scripts/project.ts +120 -20
  56. package/scripts/reapi-events.ts +98 -0
  57. package/scripts/shared-modules.ts +85 -23
  58. package/scripts/source-map.ts +242 -0
  59. package/scripts/system.ts +1 -1
  60. package/scripts/typed-commands.ts +263 -0
  61. package/scripts/typed-configs.ts +23 -12
  62. package/scripts/ui.ts +3 -1
  63. package/scripts/upgrade-menus.ts +274 -0
  64. package/scripts/upgrade-names.ts +384 -0
  65. package/scripts/upgrade.ts +830 -0
  66. package/src/cli-api.mjs +37 -4
  67. package/src/system.mjs +74 -3
  68. package/src/testing/compile.ts +8 -5
  69. package/src/testing/natives.ts +199 -5
  70. package/src/testing/network.ts +531 -0
  71. package/src/testing/server.ts +565 -47
  72. package/src/testing/tables.ts +25 -0
  73. package/as/modules/http.ts +0 -184
  74. package/scripts/docs/as/modules/http.ts +0 -66
package/as/flags.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  //
4
4
  // Flag families as string literal types, and FlagList - the array a plugin
5
5
  // sees where Pawn has a bit mask.
6
- import { get_entvar, set_entvar, get_member, set_member } from "./natives";
6
+ import { __entvarCell, __setEntvarCell, __memberCell, __setMemberCell } from "./entities";
7
7
 
8
8
 
9
9
  // ---------------------------------------------------------------- the list
@@ -52,25 +52,25 @@ export abstract class FlagStore {
52
52
  abstract write(mask: i32): void;
53
53
  }
54
54
 
55
- /** A mask in an entvar - var_flags, var_effects, var_button. */
55
+ /** A mask in an entvar - var_flags, var_effects, var_button - at its offset in entvars_t. */
56
56
  export class EntvarFlags extends FlagStore {
57
- constructor(private entity: i32, private field: i32) { super(); }
58
- read(): i32 { return get_entvar(this.entity, this.field); }
59
- write(mask: i32): void { set_entvar(this.entity, this.field, mask); }
57
+ constructor(private entity: i32, private offset: i32) { super(); }
58
+ read(): i32 { return __entvarCell(this.entity, this.offset); }
59
+ write(mask: i32): void { __setEntvarCell(this.entity, this.offset, mask); }
60
60
  }
61
61
 
62
- /** A mask in a game member - m_iHideHUD. */
62
+ /** A mask in a game member - m_iHideHUD - by its place in entities.ts's member table. */
63
63
  export class MemberFlags extends FlagStore {
64
- constructor(private entity: i32, private field: i32) { super(); }
65
- read(): i32 { return get_member(this.entity, this.field); }
66
- write(mask: i32): void { set_member(this.entity, this.field, mask); }
64
+ constructor(private entity: i32, private member: i32) { super(); }
65
+ read(): i32 { return __memberCell(this.entity, this.member); }
66
+ write(mask: i32): void { __setMemberCell(this.entity, this.member, mask); }
67
67
  }
68
68
 
69
69
  /**
70
70
  * The flags a mask holds, as an array of names.
71
71
  *
72
72
  * `push` sets the bit where the mask lives as well, so
73
- * `player.hideHud.push("Money")` hides the money. Everything else is a plain
73
+ * `player.hideHud.push("money")` hides the money. Everything else is a plain
74
74
  * array: `includes`, `filter`, `length`, a for loop. To take flags away,
75
75
  * assign the array back - `player.hideHud = player.hideHud.filter(...)`.
76
76
  */
@@ -99,201 +99,215 @@ export function flagList<T>(store: FlagStore, family: FlagFamily): FlagList<T> {
99
99
 
100
100
  /** Parts of the HUD a player does not see - m_iHideHUD. */
101
101
  export type HideHud =
102
- | "Weapons"
103
- | "Flashlight"
104
- | "All"
105
- | "Health"
106
- | "Timer"
107
- | "Money"
108
- | "Crosshair"
109
- | "ObserverCrosshair";
102
+ | "weapons"
103
+ | "flashlight"
104
+ | "all"
105
+ | "health"
106
+ | "timer"
107
+ | "money"
108
+ | "crosshair"
109
+ | "observerCrosshair";
110
110
 
111
111
  /** The HideHud names and their bits, for the hood. */
112
112
  export const HIDE_HUD = new FlagFamily(
113
- ["Weapons", "Flashlight", "All", "Health", "Timer", "Money", "Crosshair", "ObserverCrosshair"],
113
+ ["weapons", "flashlight", "all", "health", "timer", "money", "crosshair", "observerCrosshair"],
114
114
  [1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7]
115
115
  );
116
116
 
117
117
  /** Buttons a player holds - var_button, var_oldbuttons. */
118
118
  export type Button =
119
- | "Attack"
120
- | "Jump"
121
- | "Duck"
122
- | "Forward"
123
- | "Back"
124
- | "Use"
125
- | "Cancel"
126
- | "Left"
127
- | "Right"
128
- | "MoveLeft"
129
- | "MoveRight"
130
- | "Attack2"
131
- | "Run"
132
- | "Reload"
133
- | "Alt1"
134
- | "Score";
119
+ | "attack"
120
+ | "jump"
121
+ | "duck"
122
+ | "forward"
123
+ | "back"
124
+ | "use"
125
+ | "cancel"
126
+ | "left"
127
+ | "right"
128
+ | "moveLeft"
129
+ | "moveRight"
130
+ | "attack2"
131
+ | "run"
132
+ | "reload"
133
+ | "alt1"
134
+ | "score";
135
135
 
136
136
  /** The Button names and their bits, for the hood. */
137
137
  export const BUTTON = new FlagFamily(
138
- ["Attack", "Jump", "Duck", "Forward", "Back", "Use", "Cancel", "Left", "Right", "MoveLeft", "MoveRight", "Attack2", "Run", "Reload", "Alt1", "Score"],
138
+ ["attack", "jump", "duck", "forward", "back", "use", "cancel", "left", "right", "moveLeft", "moveRight", "attack2", "run", "reload", "alt1", "score"],
139
139
  [1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, 1 << 8, 1 << 9, 1 << 10, 1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15]
140
140
  );
141
141
 
142
142
  /** Visual effects on an entity - var_effects. */
143
143
  export type Effect =
144
- | "BrightField"
145
- | "MuzzleFlash"
146
- | "BrightLight"
147
- | "DimLight"
148
- | "InvLight"
149
- | "NoInterp"
150
- | "Light"
151
- | "NoDraw"
152
- | "ForceVisibility"
153
- | "OwnerVisibility"
154
- | "OwnerNoVisibility"
155
- | "NoSlerp"
156
- | "FollowKeepRender";
144
+ | "brightField"
145
+ | "muzzleFlash"
146
+ | "brightLight"
147
+ | "dimLight"
148
+ | "invLight"
149
+ | "noInterp"
150
+ | "light"
151
+ | "noDraw"
152
+ | "forceVisibility"
153
+ | "ownerVisibility"
154
+ | "ownerNoVisibility"
155
+ | "noSlerp"
156
+ | "followKeepRender";
157
157
 
158
158
  /** The Effect names and their bits, for the hood. */
159
159
  export const EFFECT = new FlagFamily(
160
- ["BrightField", "MuzzleFlash", "BrightLight", "DimLight", "InvLight", "NoInterp", "Light", "NoDraw", "ForceVisibility", "OwnerVisibility", "OwnerNoVisibility", "NoSlerp", "FollowKeepRender"],
160
+ ["brightField", "muzzleFlash", "brightLight", "dimLight", "invLight", "noInterp", "light", "noDraw", "forceVisibility", "ownerVisibility", "ownerNoVisibility", "noSlerp", "followKeepRender"],
161
161
  [1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, 1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15]
162
162
  );
163
163
 
164
164
  /** Engine flags of an entity - var_flags. */
165
165
  export type EntityFlag =
166
- | "Fly"
167
- | "Swim"
168
- | "Conveyor"
169
- | "Client"
170
- | "InWater"
171
- | "Monster"
172
- | "GodMode"
173
- | "NoTarget"
174
- | "SkipLocalHost"
175
- | "OnGround"
176
- | "PartialGround"
177
- | "WaterJump"
178
- | "Frozen"
179
- | "FakeClient"
180
- | "Ducking"
181
- | "Float"
182
- | "Graphed"
183
- | "ImmuneWater"
184
- | "ImmuneSlime"
185
- | "ImmuneLava"
186
- | "Proxy"
187
- | "AlwaysThink"
188
- | "BaseVelocity"
189
- | "MonsterClip"
190
- | "OnTrain"
191
- | "WorldBrush"
192
- | "Spectator"
193
- | "CustomEntity"
194
- | "KillMe"
195
- | "Dormant";
166
+ | "fly"
167
+ | "swim"
168
+ | "conveyor"
169
+ | "client"
170
+ | "inWater"
171
+ | "monster"
172
+ | "godMode"
173
+ | "noTarget"
174
+ | "skipLocalHost"
175
+ | "onGround"
176
+ | "partialGround"
177
+ | "waterJump"
178
+ | "frozen"
179
+ | "fakeClient"
180
+ | "ducking"
181
+ | "float"
182
+ | "graphed"
183
+ | "immuneWater"
184
+ | "immuneSlime"
185
+ | "immuneLava"
186
+ | "proxy"
187
+ | "alwaysThink"
188
+ | "baseVelocity"
189
+ | "monsterClip"
190
+ | "onTrain"
191
+ | "worldBrush"
192
+ | "spectator"
193
+ | "customEntity"
194
+ | "killMe"
195
+ | "dormant";
196
196
 
197
197
  /** The EntityFlag names and their bits, for the hood. */
198
198
  export const ENTITY_FLAG = new FlagFamily(
199
- ["Fly", "Swim", "Conveyor", "Client", "InWater", "Monster", "GodMode", "NoTarget", "SkipLocalHost", "OnGround", "PartialGround", "WaterJump", "Frozen", "FakeClient", "Ducking", "Float", "Graphed", "ImmuneWater", "ImmuneSlime", "ImmuneLava", "Proxy", "AlwaysThink", "BaseVelocity", "MonsterClip", "OnTrain", "WorldBrush", "Spectator", "CustomEntity", "KillMe", "Dormant"],
199
+ ["fly", "swim", "conveyor", "client", "inWater", "monster", "godMode", "noTarget", "skipLocalHost", "onGround", "partialGround", "waterJump", "frozen", "fakeClient", "ducking", "float", "graphed", "immuneWater", "immuneSlime", "immuneLava", "proxy", "alwaysThink", "baseVelocity", "monsterClip", "onTrain", "worldBrush", "spectator", "customEntity", "killMe", "dormant"],
200
200
  [1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, 1 << 8, 1 << 9, 1 << 10, 1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15, 1 << 16, 1 << 17, 1 << 18, 1 << 19, 1 << 20, 1 << 21, 1 << 22, 1 << 23, 1 << 24, 1 << 25, 1 << 26, 1 << 29, 1 << 30, 1 << 31]
201
201
  );
202
202
 
203
203
  /** Kinds of damage - the damage type a hook receives. */
204
204
  export type Damage =
205
- | "Crush"
206
- | "Bullet"
207
- | "Slash"
208
- | "Burn"
209
- | "Freeze"
210
- | "Fall"
211
- | "Blast"
212
- | "Club"
213
- | "Shock"
214
- | "Sonic"
215
- | "EnergyBeam"
216
- | "NeverGib"
217
- | "AlwaysGib"
218
- | "Drown"
219
- | "Paralyze"
220
- | "NerveGas"
221
- | "Poison"
222
- | "Radiation"
223
- | "DrownRecover"
224
- | "Acid"
225
- | "SlowBurn"
226
- | "SlowFreeze"
227
- | "Mortar"
228
- | "Grenade";
205
+ | "crush"
206
+ | "bullet"
207
+ | "slash"
208
+ | "burn"
209
+ | "freeze"
210
+ | "fall"
211
+ | "blast"
212
+ | "club"
213
+ | "shock"
214
+ | "sonic"
215
+ | "energyBeam"
216
+ | "neverGib"
217
+ | "alwaysGib"
218
+ | "drown"
219
+ | "paralyze"
220
+ | "nerveGas"
221
+ | "poison"
222
+ | "radiation"
223
+ | "drownRecover"
224
+ | "acid"
225
+ | "slowBurn"
226
+ | "slowFreeze"
227
+ | "mortar"
228
+ | "grenade";
229
229
  // Not single bits, so not names: DMG_GENERIC = 0, DMG_GIB_CORPSE = 737, DMG_SHOWNHUD = 7815448.
230
230
 
231
231
  /** The Damage names and their bits, for the hood. */
232
232
  export const DAMAGE = new FlagFamily(
233
- ["Crush", "Bullet", "Slash", "Burn", "Freeze", "Fall", "Blast", "Club", "Shock", "Sonic", "EnergyBeam", "NeverGib", "AlwaysGib", "Drown", "Paralyze", "NerveGas", "Poison", "Radiation", "DrownRecover", "Acid", "SlowBurn", "SlowFreeze", "Mortar", "Grenade"],
233
+ ["crush", "bullet", "slash", "burn", "freeze", "fall", "blast", "club", "shock", "sonic", "energyBeam", "neverGib", "alwaysGib", "drown", "paralyze", "nerveGas", "poison", "radiation", "drownRecover", "acid", "slowBurn", "slowFreeze", "mortar", "grenade"],
234
234
  [1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, 1 << 8, 1 << 9, 1 << 10, 1 << 12, 1 << 13, 1 << 14, 1 << 15, 1 << 16, 1 << 17, 1 << 18, 1 << 19, 1 << 20, 1 << 21, 1 << 22, 1 << 23, 1 << 24]
235
235
  );
236
236
 
237
237
  /** What an admin may do - get_user_flags, users.ini letters. */
238
238
  export type Access =
239
- | "Immunity"
240
- | "Reservation"
241
- | "Kick"
242
- | "Ban"
243
- | "Slay"
244
- | "Map"
245
- | "Cvar"
246
- | "Cfg"
247
- | "Chat"
248
- | "Vote"
249
- | "Password"
250
- | "Rcon"
251
- | "LevelA"
252
- | "LevelB"
253
- | "LevelC"
254
- | "LevelD"
255
- | "LevelE"
256
- | "LevelF"
257
- | "LevelG"
258
- | "LevelH"
259
- | "Menu"
260
- | "BanTemp"
261
- | "Admin"
262
- | "User";
239
+ | "immunity"
240
+ | "reservation"
241
+ | "kick"
242
+ | "ban"
243
+ | "slay"
244
+ | "map"
245
+ | "cvar"
246
+ | "cfg"
247
+ | "chat"
248
+ | "vote"
249
+ | "password"
250
+ | "rcon"
251
+ | "levelA"
252
+ | "levelB"
253
+ | "levelC"
254
+ | "levelD"
255
+ | "levelE"
256
+ | "levelF"
257
+ | "levelG"
258
+ | "levelH"
259
+ | "menu"
260
+ | "banTemp"
261
+ | "admin"
262
+ | "user";
263
263
  // Not single bits, so not names: ADMIN_ALL = 0.
264
264
 
265
265
  /** The Access names and their bits, for the hood. */
266
266
  export const ACCESS = new FlagFamily(
267
- ["Immunity", "Reservation", "Kick", "Ban", "Slay", "Map", "Cvar", "Cfg", "Chat", "Vote", "Password", "Rcon", "LevelA", "LevelB", "LevelC", "LevelD", "LevelE", "LevelF", "LevelG", "LevelH", "Menu", "BanTemp", "Admin", "User"],
267
+ ["immunity", "reservation", "kick", "ban", "slay", "map", "cvar", "cfg", "chat", "vote", "password", "rcon", "levelA", "levelB", "levelC", "levelD", "levelE", "levelF", "levelG", "levelH", "menu", "banTemp", "admin", "user"],
268
268
  [1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, 1 << 8, 1 << 9, 1 << 10, 1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15, 1 << 16, 1 << 17, 1 << 18, 1 << 19, 1 << 20, 1 << 21, 1 << 24, 1 << 25]
269
269
  );
270
270
 
271
+ /** What the scoreboard shows beside a player - the ScoreAttrib message: dead, the bomb, the VIP, a defuse kit. */
272
+ export type ScoreStatus =
273
+ | "dead"
274
+ | "bomb"
275
+ | "vip"
276
+ | "defuseKit";
277
+ // Not single bits, so not names: SCORE_STATUS_NONE = 0.
278
+
279
+ /** The ScoreStatus names and their bits, for the hood. */
280
+ export const SCORE_STATUS = new FlagFamily(
281
+ ["dead", "bomb", "vip", "defuseKit"],
282
+ [1 << 0, 1 << 1, 1 << 2, 1 << 3]
283
+ );
284
+
271
285
  /** Modes a weapon is in - m_iWeaponState: a silencer on, burst fire, the shield drawn. */
272
286
  export type WeaponState =
273
- | "UspSilenced"
274
- | "Glock18Burst"
275
- | "M4a1Silenced"
276
- | "EliteLeft"
277
- | "FamasBurst"
278
- | "ShieldDrawn";
287
+ | "uspSilenced"
288
+ | "glock18Burst"
289
+ | "m4a1Silenced"
290
+ | "eliteLeft"
291
+ | "famasBurst"
292
+ | "shieldDrawn";
279
293
 
280
294
  /** The WeaponState names and their bits, for the hood. */
281
295
  export const WEAPON_STATE = new FlagFamily(
282
- ["UspSilenced", "Glock18Burst", "M4a1Silenced", "EliteLeft", "FamasBurst", "ShieldDrawn"],
296
+ ["uspSilenced", "glock18Burst", "m4a1Silenced", "eliteLeft", "famasBurst", "shieldDrawn"],
283
297
  [1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5]
284
298
  );
285
299
 
286
300
  /** The physics state of a player - m_afPhysicsFlags: on a ladder, on a train, ducking. */
287
301
  export type PhysicsFlag =
288
- | "OnLadder"
289
- | "OnTrain"
290
- | "OnBarnacle"
291
- | "Ducking"
292
- | "Using"
293
- | "Observer";
302
+ | "onLadder"
303
+ | "onTrain"
304
+ | "onBarnacle"
305
+ | "ducking"
306
+ | "using"
307
+ | "observer";
294
308
 
295
309
  /** The PhysicsFlag names and their bits, for the hood. */
296
310
  export const PHYSICS_FLAG = new FlagFamily(
297
- ["OnLadder", "OnTrain", "OnBarnacle", "Ducking", "Using", "Observer"],
311
+ ["onLadder", "onTrain", "onBarnacle", "ducking", "using", "observer"],
298
312
  [1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5]
299
313
  );