isaacscript-common 10.2.2 → 11.0.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 +16 -11
- package/dist/isaacscript-common.lua +20 -17
- package/dist/package.lua +1 -1
- package/dist/src/functions/players.d.ts +7 -2
- package/dist/src/functions/players.d.ts.map +1 -1
- package/dist/src/functions/players.lua +6 -3
- package/dist/src/functions/tears.d.ts +8 -8
- package/dist/src/functions/tears.d.ts.map +1 -1
- package/dist/src/functions/tears.lua +12 -12
- package/package.json +1 -1
- package/src/functions/players.ts +8 -3
- package/src/functions/tears.ts +18 -14
package/dist/index.d.ts
CHANGED
|
@@ -4092,15 +4092,20 @@ export declare function getPlayerCollectiblesForCacheFlag(player: EntityPlayer,
|
|
|
4092
4092
|
/** Helper function to get only the familiars that belong to a specific player. */
|
|
4093
4093
|
export declare function getPlayerFamiliars(player: EntityPlayer): EntityFamiliar[];
|
|
4094
4094
|
|
|
4095
|
+
/**
|
|
4096
|
+
* Helper function to get the player from a tear, laser, bomb, etc. Returns undefined if the entity
|
|
4097
|
+
* does not correspond to any particular player.
|
|
4098
|
+
*
|
|
4099
|
+
* This function works by looking at the `Parent` and the `SpawnerEntity` fields (in that order).
|
|
4100
|
+
*/
|
|
4101
|
+
export declare function getPlayerFromEntity(entity: Entity): EntityPlayer | undefined;
|
|
4102
|
+
|
|
4095
4103
|
/**
|
|
4096
4104
|
* Helper function to get the corresponding `EntityPlayer` object that corresponds to a
|
|
4097
4105
|
* `PlayerIndex`.
|
|
4098
4106
|
*/
|
|
4099
4107
|
export declare function getPlayerFromIndex(playerIndex: PlayerIndex): EntityPlayer | undefined;
|
|
4100
4108
|
|
|
4101
|
-
/** Helper function to get the player from a tear, laser, bomb, etc. */
|
|
4102
|
-
export declare function getPlayerFromTear(entity: Entity): EntityPlayer | undefined;
|
|
4103
|
-
|
|
4104
4109
|
/**
|
|
4105
4110
|
* Helper function to get an object representing the player's health. You can use this in
|
|
4106
4111
|
* combination with the `setPlayerHealth` function to restore the player's health back to a certain
|
|
@@ -6442,10 +6447,10 @@ export declare function isTear(variable: unknown): variable is EntityTear;
|
|
|
6442
6447
|
* Helper function to check if a given tear is from a familiar (as opposed to e.g. a player). This
|
|
6443
6448
|
* is determined by looking at the parent.
|
|
6444
6449
|
*
|
|
6445
|
-
* For the special case of Incubus and Blood Babies, the
|
|
6446
|
-
*
|
|
6447
|
-
*
|
|
6448
|
-
* callback or on frame 1+.
|
|
6450
|
+
* For the special case of Incubus and Blood Babies, the parent of the tear is always the player,
|
|
6451
|
+
* but the spawner entity of the tear changes. On frame 0, the spawner entity is equal to the
|
|
6452
|
+
* player, and on frame 1, the spawner entity is equal to the familiar. For this reason, you can
|
|
6453
|
+
* only use this function in the `POST_TEAR_INIT_VERY_LATE` callback or on frame 1+.
|
|
6449
6454
|
*
|
|
6450
6455
|
* If this function is called on frame 0, it will throw a run-time error.
|
|
6451
6456
|
*/
|
|
@@ -6455,10 +6460,10 @@ export declare function isTearFromFamiliar(tear: EntityTear): boolean;
|
|
|
6455
6460
|
* Helper function to check if a given tear is from a player (as opposed to e.g. a familiar). This
|
|
6456
6461
|
* is determined by looking at the parent.
|
|
6457
6462
|
*
|
|
6458
|
-
* For the special case of Incubus and Blood Babies, the
|
|
6459
|
-
*
|
|
6460
|
-
*
|
|
6461
|
-
* callback or on frame 1+.
|
|
6463
|
+
* For the special case of Incubus and Blood Babies, the parent of the tear is always the player,
|
|
6464
|
+
* but the spawner entity of the tear changes. On frame 0, the spawner entity is equal to the
|
|
6465
|
+
* player, and on frame 1, the spawner entity is equal to the familiar. For this reason, you can
|
|
6466
|
+
* only use this function in the `POST_TEAR_INIT_VERY_LATE` callback or on frame 1+.
|
|
6462
6467
|
*
|
|
6463
6468
|
* If this function is called on frame 0, it will throw a run-time error.
|
|
6464
6469
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common
|
|
3
|
+
isaacscript-common 11.0.1
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -26300,8 +26300,11 @@ function ____exports.getPlayerCollectibleMap(self, player)
|
|
|
26300
26300
|
end
|
|
26301
26301
|
return collectibleMap
|
|
26302
26302
|
end
|
|
26303
|
-
--- Helper function to get the player from a tear, laser, bomb, etc.
|
|
26304
|
-
|
|
26303
|
+
--- Helper function to get the player from a tear, laser, bomb, etc. Returns undefined if the entity
|
|
26304
|
+
-- does not correspond to any particular player.
|
|
26305
|
+
--
|
|
26306
|
+
-- This function works by looking at the `Parent` and the `SpawnerEntity` fields (in that order).
|
|
26307
|
+
function ____exports.getPlayerFromEntity(self, entity)
|
|
26305
26308
|
if entity.Parent ~= nil then
|
|
26306
26309
|
local player = entity.Parent:ToPlayer()
|
|
26307
26310
|
if player ~= nil then
|
|
@@ -26470,7 +26473,7 @@ function ____exports.isDamageFromPlayer(self, damageSource)
|
|
|
26470
26473
|
if player ~= nil then
|
|
26471
26474
|
return true
|
|
26472
26475
|
end
|
|
26473
|
-
local indirectPlayer = ____exports.
|
|
26476
|
+
local indirectPlayer = ____exports.getPlayerFromEntity(nil, damageSource)
|
|
26474
26477
|
return indirectPlayer ~= nil
|
|
26475
26478
|
end
|
|
26476
26479
|
--- Helper function for detecting when a player is Eden or Tainted Eden. Useful for situations where
|
|
@@ -39249,39 +39252,39 @@ end
|
|
|
39249
39252
|
--- Helper function to check if a given tear is from a familiar (as opposed to e.g. a player). This
|
|
39250
39253
|
-- is determined by looking at the parent.
|
|
39251
39254
|
--
|
|
39252
|
-
-- For the special case of Incubus and Blood Babies, the
|
|
39253
|
-
--
|
|
39254
|
-
--
|
|
39255
|
-
-- callback or on frame 1+.
|
|
39255
|
+
-- For the special case of Incubus and Blood Babies, the parent of the tear is always the player,
|
|
39256
|
+
-- but the spawner entity of the tear changes. On frame 0, the spawner entity is equal to the
|
|
39257
|
+
-- player, and on frame 1, the spawner entity is equal to the familiar. For this reason, you can
|
|
39258
|
+
-- only use this function in the `POST_TEAR_INIT_VERY_LATE` callback or on frame 1+.
|
|
39256
39259
|
--
|
|
39257
39260
|
-- If this function is called on frame 0, it will throw a run-time error.
|
|
39258
39261
|
function ____exports.isTearFromFamiliar(self, tear)
|
|
39259
39262
|
if tear.FrameCount == 0 then
|
|
39260
39263
|
error("Failed to check if the given tear was from a player since the tear's frame count was equal to 0. (The \"isTearFromFamiliar\" function must only be used in the \"POST_TEAR_INIT_VERY_LATE\" callback or on frame 1 and onwards.)")
|
|
39261
39264
|
end
|
|
39262
|
-
if tear.
|
|
39265
|
+
if tear.SpawnerEntity == nil then
|
|
39263
39266
|
return false
|
|
39264
39267
|
end
|
|
39265
|
-
local familiar = tear.
|
|
39268
|
+
local familiar = tear.SpawnerEntity:ToFamiliar()
|
|
39266
39269
|
return familiar ~= nil
|
|
39267
39270
|
end
|
|
39268
39271
|
--- Helper function to check if a given tear is from a player (as opposed to e.g. a familiar). This
|
|
39269
39272
|
-- is determined by looking at the parent.
|
|
39270
39273
|
--
|
|
39271
|
-
-- For the special case of Incubus and Blood Babies, the
|
|
39272
|
-
--
|
|
39273
|
-
--
|
|
39274
|
-
-- callback or on frame 1+.
|
|
39274
|
+
-- For the special case of Incubus and Blood Babies, the parent of the tear is always the player,
|
|
39275
|
+
-- but the spawner entity of the tear changes. On frame 0, the spawner entity is equal to the
|
|
39276
|
+
-- player, and on frame 1, the spawner entity is equal to the familiar. For this reason, you can
|
|
39277
|
+
-- only use this function in the `POST_TEAR_INIT_VERY_LATE` callback or on frame 1+.
|
|
39275
39278
|
--
|
|
39276
39279
|
-- If this function is called on frame 0, it will throw a run-time error.
|
|
39277
39280
|
function ____exports.isTearFromPlayer(self, tear)
|
|
39278
39281
|
if tear.FrameCount == 0 then
|
|
39279
39282
|
error("Failed to check if the given tear was from a player since the tear's frame count was equal to 0. (The \"isTearFromPlayer\" function must only be used in the \"POST_TEAR_INIT_VERY_LATE\" callback or on frame 1 and onwards.)")
|
|
39280
39283
|
end
|
|
39281
|
-
if tear.
|
|
39284
|
+
if tear.SpawnerEntity == nil then
|
|
39282
39285
|
return false
|
|
39283
39286
|
end
|
|
39284
|
-
local player = tear.
|
|
39287
|
+
local player = tear.SpawnerEntity:ToPlayer()
|
|
39285
39288
|
return player ~= nil
|
|
39286
39289
|
end
|
|
39287
39290
|
return ____exports
|
|
@@ -46947,7 +46950,7 @@ return ____exports
|
|
|
46947
46950
|
["package"] = function(...)
|
|
46948
46951
|
return {
|
|
46949
46952
|
name = "isaacscript-common",
|
|
46950
|
-
version = "
|
|
46953
|
+
version = "11.0.1",
|
|
46951
46954
|
description = "Helper functions and features for IsaacScript mods.",
|
|
46952
46955
|
keywords = {"isaac", "rebirth", "afterbirth", "repentance"},
|
|
46953
46956
|
homepage = "https://isaacscript.github.io/",
|
package/dist/package.lua
CHANGED
|
@@ -73,8 +73,13 @@ export declare function getPlayerCollectibleCount(player: EntityPlayer, ...colle
|
|
|
73
73
|
* Note that this will filter out non-real collectibles like Lilith's Incubus.
|
|
74
74
|
*/
|
|
75
75
|
export declare function getPlayerCollectibleMap(player: EntityPlayer): Map<CollectibleType, int>;
|
|
76
|
-
/**
|
|
77
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Helper function to get the player from a tear, laser, bomb, etc. Returns undefined if the entity
|
|
78
|
+
* does not correspond to any particular player.
|
|
79
|
+
*
|
|
80
|
+
* This function works by looking at the `Parent` and the `SpawnerEntity` fields (in that order).
|
|
81
|
+
*/
|
|
82
|
+
export declare function getPlayerFromEntity(entity: Entity): EntityPlayer | undefined;
|
|
78
83
|
/**
|
|
79
84
|
* Helper function to get the proper name of the player. Use this instead of the
|
|
80
85
|
* `EntityPlayer.GetName` method because it accounts for Blue Baby, Lazarus II, and Tainted
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"players.d.ts","sourceRoot":"","sources":["../../../src/functions/players.ts"],"names":[],"mappings":"AAAA,OAA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wBAAgB,yBAAyB,CACvC,MAAM,EAAE,YAAY,EACpB,GAAG,gBAAgB,EAAE,eAAe,EAAE,GACrC,GAAG,CASL;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,YAAY,GACnB,GAAG,CAAC,eAAe,EAAE,GAAG,CAAC,CAc3B;AAED
|
|
1
|
+
{"version":3,"file":"players.d.ts","sourceRoot":"","sources":["../../../src/functions/players.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,eAAe,EACf,eAAe,EAGf,UAAU,EAEV,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAetC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAON;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,WAAW,GACvB,IAAI,CAON;AAED,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAGT;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAGrE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,kBAAkB,EAAE,UAAU,EAAE,GAAG,OAAO,CAIxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CASjE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,UAAU,GAAG,SAAS,CAMxB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,kBAAkB,EAAE,YAAY,GAAG,KAAK,GACvC,KAAK,CAMP;AAED,+FAA+F;AAC/F,wBAAgB,aAAa,IAAI,UAAU,EAAE,CAG5C;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAiB/D;AAED;;;GAGG;AACH,wBAAgB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G7D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,GAAG,gBAAgB,EAAE,eAAe,EAAE,GACrC,IAAI,CAIN;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,GAAG,gBAAgB,EAAE,eAAe,EAAE,GACrC,OAAO,CAIT;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAa/D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAalE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAON;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAIlE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,WAAW,GACvB,IAAI,CAON;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,UAAU,EACtB,MAAM,CAAC,EAAE,GAAG,EACZ,WAAW,UAAQ,GAClB,IAAI,CA6DN;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,aAAa,UAAO,GACnB,IAAI,CAsBN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAEN"}
|
|
@@ -244,8 +244,11 @@ function ____exports.getPlayerCollectibleMap(self, player)
|
|
|
244
244
|
end
|
|
245
245
|
return collectibleMap
|
|
246
246
|
end
|
|
247
|
-
--- Helper function to get the player from a tear, laser, bomb, etc.
|
|
248
|
-
|
|
247
|
+
--- Helper function to get the player from a tear, laser, bomb, etc. Returns undefined if the entity
|
|
248
|
+
-- does not correspond to any particular player.
|
|
249
|
+
--
|
|
250
|
+
-- This function works by looking at the `Parent` and the `SpawnerEntity` fields (in that order).
|
|
251
|
+
function ____exports.getPlayerFromEntity(self, entity)
|
|
249
252
|
if entity.Parent ~= nil then
|
|
250
253
|
local player = entity.Parent:ToPlayer()
|
|
251
254
|
if player ~= nil then
|
|
@@ -414,7 +417,7 @@ function ____exports.isDamageFromPlayer(self, damageSource)
|
|
|
414
417
|
if player ~= nil then
|
|
415
418
|
return true
|
|
416
419
|
end
|
|
417
|
-
local indirectPlayer = ____exports.
|
|
420
|
+
local indirectPlayer = ____exports.getPlayerFromEntity(nil, damageSource)
|
|
418
421
|
return indirectPlayer ~= nil
|
|
419
422
|
end
|
|
420
423
|
--- Helper function for detecting when a player is Eden or Tainted Eden. Useful for situations where
|
|
@@ -27,10 +27,10 @@ export declare function getTearsStat(fireDelay: float): float;
|
|
|
27
27
|
* Helper function to check if a given tear is from a familiar (as opposed to e.g. a player). This
|
|
28
28
|
* is determined by looking at the parent.
|
|
29
29
|
*
|
|
30
|
-
* For the special case of Incubus and Blood Babies, the
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* callback or on frame 1+.
|
|
30
|
+
* For the special case of Incubus and Blood Babies, the parent of the tear is always the player,
|
|
31
|
+
* but the spawner entity of the tear changes. On frame 0, the spawner entity is equal to the
|
|
32
|
+
* player, and on frame 1, the spawner entity is equal to the familiar. For this reason, you can
|
|
33
|
+
* only use this function in the `POST_TEAR_INIT_VERY_LATE` callback or on frame 1+.
|
|
34
34
|
*
|
|
35
35
|
* If this function is called on frame 0, it will throw a run-time error.
|
|
36
36
|
*/
|
|
@@ -39,10 +39,10 @@ export declare function isTearFromFamiliar(tear: EntityTear): boolean;
|
|
|
39
39
|
* Helper function to check if a given tear is from a player (as opposed to e.g. a familiar). This
|
|
40
40
|
* is determined by looking at the parent.
|
|
41
41
|
*
|
|
42
|
-
* For the special case of Incubus and Blood Babies, the
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* callback or on frame 1+.
|
|
42
|
+
* For the special case of Incubus and Blood Babies, the parent of the tear is always the player,
|
|
43
|
+
* but the spawner entity of the tear changes. On frame 0, the spawner entity is equal to the
|
|
44
|
+
* player, and on frame 1, the spawner entity is equal to the familiar. For this reason, you can
|
|
45
|
+
* only use this function in the `POST_TEAR_INIT_VERY_LATE` callback or on frame 1+.
|
|
46
46
|
*
|
|
47
47
|
* If this function is called on frame 0, it will throw a run-time error.
|
|
48
48
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tears.d.ts","sourceRoot":"","sources":["../../../src/functions/tears.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,GAAG,IAAI,CAKzE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,KAAK,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,KAAK,CAEpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"tears.d.ts","sourceRoot":"","sources":["../../../src/functions/tears.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,GAAG,IAAI,CAKzE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,KAAK,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,KAAK,CAEpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAgB5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAgB1D"}
|
|
@@ -27,39 +27,39 @@ end
|
|
|
27
27
|
--- Helper function to check if a given tear is from a familiar (as opposed to e.g. a player). This
|
|
28
28
|
-- is determined by looking at the parent.
|
|
29
29
|
--
|
|
30
|
-
-- For the special case of Incubus and Blood Babies, the
|
|
31
|
-
--
|
|
32
|
-
--
|
|
33
|
-
-- callback or on frame 1+.
|
|
30
|
+
-- For the special case of Incubus and Blood Babies, the parent of the tear is always the player,
|
|
31
|
+
-- but the spawner entity of the tear changes. On frame 0, the spawner entity is equal to the
|
|
32
|
+
-- player, and on frame 1, the spawner entity is equal to the familiar. For this reason, you can
|
|
33
|
+
-- only use this function in the `POST_TEAR_INIT_VERY_LATE` callback or on frame 1+.
|
|
34
34
|
--
|
|
35
35
|
-- If this function is called on frame 0, it will throw a run-time error.
|
|
36
36
|
function ____exports.isTearFromFamiliar(self, tear)
|
|
37
37
|
if tear.FrameCount == 0 then
|
|
38
38
|
error("Failed to check if the given tear was from a player since the tear's frame count was equal to 0. (The \"isTearFromFamiliar\" function must only be used in the \"POST_TEAR_INIT_VERY_LATE\" callback or on frame 1 and onwards.)")
|
|
39
39
|
end
|
|
40
|
-
if tear.
|
|
40
|
+
if tear.SpawnerEntity == nil then
|
|
41
41
|
return false
|
|
42
42
|
end
|
|
43
|
-
local familiar = tear.
|
|
43
|
+
local familiar = tear.SpawnerEntity:ToFamiliar()
|
|
44
44
|
return familiar ~= nil
|
|
45
45
|
end
|
|
46
46
|
--- Helper function to check if a given tear is from a player (as opposed to e.g. a familiar). This
|
|
47
47
|
-- is determined by looking at the parent.
|
|
48
48
|
--
|
|
49
|
-
-- For the special case of Incubus and Blood Babies, the
|
|
50
|
-
--
|
|
51
|
-
--
|
|
52
|
-
-- callback or on frame 1+.
|
|
49
|
+
-- For the special case of Incubus and Blood Babies, the parent of the tear is always the player,
|
|
50
|
+
-- but the spawner entity of the tear changes. On frame 0, the spawner entity is equal to the
|
|
51
|
+
-- player, and on frame 1, the spawner entity is equal to the familiar. For this reason, you can
|
|
52
|
+
-- only use this function in the `POST_TEAR_INIT_VERY_LATE` callback or on frame 1+.
|
|
53
53
|
--
|
|
54
54
|
-- If this function is called on frame 0, it will throw a run-time error.
|
|
55
55
|
function ____exports.isTearFromPlayer(self, tear)
|
|
56
56
|
if tear.FrameCount == 0 then
|
|
57
57
|
error("Failed to check if the given tear was from a player since the tear's frame count was equal to 0. (The \"isTearFromPlayer\" function must only be used in the \"POST_TEAR_INIT_VERY_LATE\" callback or on frame 1 and onwards.)")
|
|
58
58
|
end
|
|
59
|
-
if tear.
|
|
59
|
+
if tear.SpawnerEntity == nil then
|
|
60
60
|
return false
|
|
61
61
|
end
|
|
62
|
-
local player = tear.
|
|
62
|
+
local player = tear.SpawnerEntity:ToPlayer()
|
|
63
63
|
return player ~= nil
|
|
64
64
|
end
|
|
65
65
|
return ____exports
|
package/package.json
CHANGED
package/src/functions/players.ts
CHANGED
|
@@ -264,8 +264,13 @@ export function getPlayerCollectibleMap(
|
|
|
264
264
|
return collectibleMap;
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
/**
|
|
268
|
-
|
|
267
|
+
/**
|
|
268
|
+
* Helper function to get the player from a tear, laser, bomb, etc. Returns undefined if the entity
|
|
269
|
+
* does not correspond to any particular player.
|
|
270
|
+
*
|
|
271
|
+
* This function works by looking at the `Parent` and the `SpawnerEntity` fields (in that order).
|
|
272
|
+
*/
|
|
273
|
+
export function getPlayerFromEntity(entity: Entity): EntityPlayer | undefined {
|
|
269
274
|
if (entity.Parent !== undefined) {
|
|
270
275
|
const player = entity.Parent.ToPlayer();
|
|
271
276
|
if (player !== undefined) {
|
|
@@ -498,7 +503,7 @@ export function isDamageFromPlayer(damageSource: Entity): boolean {
|
|
|
498
503
|
return true;
|
|
499
504
|
}
|
|
500
505
|
|
|
501
|
-
const indirectPlayer =
|
|
506
|
+
const indirectPlayer = getPlayerFromEntity(damageSource);
|
|
502
507
|
return indirectPlayer !== undefined;
|
|
503
508
|
}
|
|
504
509
|
|
package/src/functions/tears.ts
CHANGED
|
@@ -36,10 +36,10 @@ export function getTearsStat(fireDelay: float): float {
|
|
|
36
36
|
* Helper function to check if a given tear is from a familiar (as opposed to e.g. a player). This
|
|
37
37
|
* is determined by looking at the parent.
|
|
38
38
|
*
|
|
39
|
-
* For the special case of Incubus and Blood Babies, the
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* callback or on frame 1+.
|
|
39
|
+
* For the special case of Incubus and Blood Babies, the parent of the tear is always the player,
|
|
40
|
+
* but the spawner entity of the tear changes. On frame 0, the spawner entity is equal to the
|
|
41
|
+
* player, and on frame 1, the spawner entity is equal to the familiar. For this reason, you can
|
|
42
|
+
* only use this function in the `POST_TEAR_INIT_VERY_LATE` callback or on frame 1+.
|
|
43
43
|
*
|
|
44
44
|
* If this function is called on frame 0, it will throw a run-time error.
|
|
45
45
|
*/
|
|
@@ -50,12 +50,14 @@ export function isTearFromFamiliar(tear: EntityTear): boolean {
|
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
// Normally, all tears have a
|
|
54
|
-
if (tear.
|
|
53
|
+
// Normally, all tears have a spawner entity, which is either the player or the familiar.
|
|
54
|
+
if (tear.SpawnerEntity === undefined) {
|
|
55
55
|
return false;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
// We cannot use `tear.SpawnerType` to determine this, since it is baked in to be equal to
|
|
59
|
+
// `EntityType.PLAYER` regardless of whether the tear is from a player or familiar.
|
|
60
|
+
const familiar = tear.SpawnerEntity.ToFamiliar();
|
|
59
61
|
return familiar !== undefined;
|
|
60
62
|
}
|
|
61
63
|
|
|
@@ -63,10 +65,10 @@ export function isTearFromFamiliar(tear: EntityTear): boolean {
|
|
|
63
65
|
* Helper function to check if a given tear is from a player (as opposed to e.g. a familiar). This
|
|
64
66
|
* is determined by looking at the parent.
|
|
65
67
|
*
|
|
66
|
-
* For the special case of Incubus and Blood Babies, the
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* callback or on frame 1+.
|
|
68
|
+
* For the special case of Incubus and Blood Babies, the parent of the tear is always the player,
|
|
69
|
+
* but the spawner entity of the tear changes. On frame 0, the spawner entity is equal to the
|
|
70
|
+
* player, and on frame 1, the spawner entity is equal to the familiar. For this reason, you can
|
|
71
|
+
* only use this function in the `POST_TEAR_INIT_VERY_LATE` callback or on frame 1+.
|
|
70
72
|
*
|
|
71
73
|
* If this function is called on frame 0, it will throw a run-time error.
|
|
72
74
|
*/
|
|
@@ -77,11 +79,13 @@ export function isTearFromPlayer(tear: EntityTear): boolean {
|
|
|
77
79
|
);
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
// Normally, all tears have a
|
|
81
|
-
if (tear.
|
|
82
|
+
// Normally, all tears have a spawner entity, which is either the player or the familiar.
|
|
83
|
+
if (tear.SpawnerEntity === undefined) {
|
|
82
84
|
return false;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
// We cannot use `tear.SpawnerType` to determine this, since it is baked in to be equal to
|
|
88
|
+
// `EntityType.PLAYER` regardless of whether the tear is from a player or familiar.
|
|
89
|
+
const player = tear.SpawnerEntity.ToPlayer();
|
|
86
90
|
return player !== undefined;
|
|
87
91
|
}
|