Module LevelNpcClass
Level NPC class, functions, and callback events
Class NpcControllerBase
| NpcControllerBase:__init (npc_obj) | Controller constructor, once called on first initialization of NPC-AI controller. Required to be defined in an NPC-AI controller class! |
| NpcControllerBase:onActivated () | Event callback called on every activation of NPC when it appears on player's camera. |
| NpcControllerBase:onLoop (frameDelay) | Event callback calling per every frame |
| NpcControllerBase:onKill (killEvent) | Event callback calling on attempt to kill NPC |
| NpcControllerBase:onHarm (harmEvent) | Event callback calling on attempt to hurt NPC |
| NpcControllerBase:onTransform (id) | Event callback calling on attempt to transform NPC into another |
Damage reasons enumeration (DamageReason)
| BaseNPC.DAMAGE_NOREASON | No reason of damage |
| BaseNPC.DAMAGE_STOMPED | NPC was stomped |
| BaseNPC.DAMAGE_BY_KICK | NPC was kicked |
| BaseNPC.DAMAGE_BY_PLAYER_ATTACK | NPC was attacked by player |
| BaseNPC.DAMAGE_TAKEN | NPC was taken by player (for example, NPC is a coin, item, weapon, power-up, etc.) |
| BaseNPC.DAMAGE_LAVABURN | NPC was burn in lava |
| BaseNPC.DAMAGE_PITFALL | NPC fell into the pit |
| BaseNPC.DAMAGE_CUSTOM_REASON | Custom reason base, use it as modifier to any custom damage reasons |
Warping side enumeration (WarpingSide)
| BaseNPC.WARP_TOP | NPC is in warping process and points top direction |
| BaseNPC.WARP_LEFT | NPC is in warping process and points left direction |
| BaseNPC.WARP_BOTTOM | NPC is in warping process and points bottom direction |
| BaseNPC.WARP_RIGHT | NPC is in warping process and points right direction |
Spawning algorithms enumeration (SpawnType)
| BaseNPC.SPAWN_APPEAR | Instant appearence with no effects |
| BaseNPC.SPAWN_WARP | Smooth appearence (for example, appearence from under ground) |
| BaseNPC.SPAWN_PROJECTILE | Projectile shoot, NPC will appear instantly with initial speed and smoke effect |
Spawning direction enumeration (SpawnDirection)
| BaseNPC.SPAWN_LEFT | Spawn NPC with left direction |
| BaseNPC.SPAWN_RIGHT | Spawn NPC with right direction |
| BaseNPC.SPAWN_UP | Spawn NPC with up direction |
| BaseNPC.SPAWN_DOWN | Spawn NPC with down direction |
Class BaseNPC
| BaseNPC.id | ID of NPC registered in config pack (Read Only) |
| BaseNPC.direction | Face direction of NPC |
| BaseNPC.not_movable | NPC will don't move horizontally |
| BaseNPC.contents | ID of NPC which contains inside this NPC |
| BaseNPC.special1 | Special value of NPC from level file entry |
| BaseNPC.special2 | Special value of NPC from level file entry |
| BaseNPC.isBoss | Is this NPC an important boss (a flag from level file) |
| BaseNPC.collideWithBlocks | Can NPC collide blocks? |
| BaseNPC.collideWithPlayers | Can NPC collide playable character? |
| BaseNPC.health | Health level of NPC |
| BaseNPC.frameDelay | Animation frame delay |
| BaseNPC.killableByFire | Is NPC vulnuable to fire attacks (Read Only) |
| BaseNPC.killableByIce | Is NPC vulnuable to ice/cold attacks (Read Only) |
| BaseNPC.killableByHammer | Is NPC vulnuable to hammer attacks (Read Only) |
| BaseNPC.killableByForcejump | Is NPC is vulnuable from a power jumps (Read Only) |
| BaseNPC.killableByStatue | Is NPC is vulnuable from a statue fell (Read Only) |
| BaseNPC.killableByVehicle | Is NPC is vulnuable from attacks by vehicles (Read Only) |
| BaseNPC.onGround | Is NPC stays on a solid surface (Read Only) |
| BaseNPC.motionSpeed | Self-motion speed of NPC in pixels per 1/65 of second (Read Only) |
| BaseNPC.onCliff | Is NPC stays on an edge of ground where it stays (Read Only) |
| BaseNPC.animationIsFinished | Is once-playing animation was finished (Read Only) |
| BaseNPC:transformTo (id) | Transform NPC into another NPC |
| BaseNPC:transformTo (id, type) | Transform NPC into another NPC or into the block |
| BaseNPC.transformedFromBlockID | Original ID of block from which NPC was transformed (Read Only) |
| BaseNPC.transformedFromNpcID | Original ID of NPC from which NPC was transformed (Read Only) |
| BaseNPC.spawnedGenType | Type of spawn algorithm originally produced this NPC (Read Only) |
| BaseNPC.spawnedGenDirection | Direction of NPC when it was originally spawned (Read Only) |
| BaseNPC:setBodyType () | Sets body type |
| BaseNPC:setSequenceLeft (frames) | Set custom animation sequence for left face direction |
| BaseNPC:setSequenceRight (frames) | Set custom animation sequence for right face direction |
| BaseNPC:setSequence (frames) | Set custom common animation sequence for all face directions |
| BaseNPC:setOnceAnimationMode (enabled) | Turn on once animation mode when changed animation sequence will play once after set |
| BaseNPC:setGfxOffset (x, y) | Set custom GFX offset |
| BaseNPC:setGfxOffset (x) | Set custom horizontal GFX offset |
| BaseNPC:setGfxOffset (y) | Set custom vertical GFX offset |
| BaseNPC:installInAreaDetector (left, top, right, bottom, filters) | Install an In-Area detector for relative area and get a referrence to it, boundary coordinates of a trap area are relative to center point of NPC |
| BaseNPC:installPlayerPosDetector () | Install a detector of capabilities and state of a nearest playable character ("Player Position" detector) |
| BaseNPC:installContactDetector () | Install a detector of contacted objects which will detect any objects contacted this NPC |
| BaseNPC:spawnNPC (npcID, spawnType, direction) | Spawn another NPC on same position as this NPC. |
| BaseNPC:spawnNPC (npcID, spawnType, direction, reSpawnable) | Spawn another NPC on same position as this NPC. |
| BaseNPC:setSpriteWarp (depth, direction, resizedBody) | Set cut off level of the sprite |
| BaseNPC:resetSpriteWarp () | Disables sprite cut off and resets it to normal state |
| BaseNPC:activateNeighbours () | Force activate nearest NPCs are touching this NPC are even not touching player's camera |
| BaseNPC:unregister () | Destroy NPC with no effects and no events |
| BaseNPC:kill (damageReason) | Kill this NPC with damage reason |
| BaseNPC:kill (damageReason, killedBy) | Kill this NPC with damage reason and telling who killed this NPC |
| BaseNPC:harm () | Harm this NPC with removing one health point |
| BaseNPC:harm (damageLevel) | Harm this NPC with removing given health point |
| BaseNPC:harm (damageLevel, damageReason) | Harm this NPC with removing given health point and reason of damage |
| BaseNPC:harm (damageLevel, damageReason, harmBy) | Harm this NPC with removing given health point, reason of damage and person who damaged this NPC |
Damaged By enumeration (killedBy)
| NpcHarmEvent.self | NPC made damage to itself |
| NpcHarmEvent.player | NPC was damaged by playable character |
| NpcHarmEvent.otherNPC | NPC was damaged by another NPC |
Class NpcHarmEvent
| NpcHarmEvent.cancel | Reject this event, it will not be executed |
| NpcHarmEvent.damage | Damage level caused by this event |
| NpcHarmEvent.reason_code | Damage reason code |
| NpcHarmEvent.killed_by | Who damaged this NPC |
| NpcHarmEvent.killer_p | Playable character who damaged this NPC or nil if NPC was not damaged by playable character |
| NpcHarmEvent.killer_n | Another NPC who damaged this NPC or nil if NPC was not damaged by other NPC |
Killed By enumeration (killedBy)
| NpcHarmEvent.self | NPC made damage to itself |
| NpcHarmEvent.player | NPC was damaged by playable character |
| NpcHarmEvent.otherNPC | NPC was damaged by another NPC |
Class NpcKillEvent
| NpcKillEvent.cancel | Reject this event, it will not be executed |
| NpcKillEvent.reason_code | Death reason code |
| NpcKillEvent.killed_by | Who killed this NPC |
| NpcKillEvent.killer_p | Playable character who killed this NPC or nil if NPC was not killed by playable character |
| NpcKillEvent.killer_n | Another NPC who killed this NPC or nil if NPC was not killed by other NPC |
Class ContactDetector
| ContactDetector:detected () | Check are contacts was detected |
| ContactDetector:getBlocks () | Get array of touching blocks |
| ContactDetector:getBGOs () | Get array of touching BGOs |
| ContactDetector:getNPCs () | Get array of touching NPCs |
| ContactDetector:getPlayers () | Get array of touching Playable Characters |
Class InAreaDetector
| InAreaDetector:detected () | Is any object appears in the trap zone |
| InAreaDetector:detected (id, type) | Is any object of specified id and type is in the trap zone |
| InAreaDetector:getBlocks () | Get array of blocks touching a trap zone |
| InAreaDetector:getBGOs () | Get array of BGOs touching a trap zone |
| InAreaDetector:getNPCs () | Get array of NPCs touching a trap zone |
| InAreaDetector:getPlayers () | Get array of Playable Characters touching a trap zone |
| InAreaDetector:contacts () | Get count of objects touching a trap zone |
Class PlayerPosDetector
| PlayerPosDetector:detected () | Was playable character detected on the scene? |
| PlayerPosDetector:directedTo () | Direction of left or right side where nearest playable character is located |
| PlayerPosDetector:playerDirection () | Face direction of nearest playable character |
| PlayerPosDetector:positionX () | Absolute horizintal position of nearest playable character |
| PlayerPosDetector:positionY () | Absolute vertical position of nearest playable character |
| PlayerPosDetector:playersCharID () | Get ID of nearest playable character |
| PlayerPosDetector:playerStateID () | Get ID of nearest playable character's state |
| PlayerPosDetector:playerPtr () | Get reference to nearest playable character |
Class NpcControllerBase
NPC-AI Controller base class, must be implemented for every NPC which needs more complex logic than engine provides
- NpcControllerBase:__init (npc_obj)
-
Controller constructor, once called on first initialization of NPC-AI controller.
Required to be defined in an NPC-AI controller class!Parameters:
- npc_obj BaseNPC Reference to actual NPC object
Usage:
class 'MyNPC' function MyNPC:initPros() self.timer = 0 self.state = 0 -- ... end function MyNPC:__init(npc_obj) self.npc_obj = npc_obj self:initProps() end -- ... return MyNPC
- NpcControllerBase:onActivated ()
-
Event callback called on every activation of NPC when it appears on player's camera.
Usage:
class 'MyNPC' function MyNPC:initPros() self.timer = 0 self.state = 0 -- ... end function MyNPC:onActivated() MyNPC:initPros() end -- ... return MyNPC
- NpcControllerBase:onLoop (frameDelay)
-
Event callback calling per every frame
Parameters:
- frameDelay double Frame delay in milliseconds. Use it for various timing processors.
Usage:
class 'MyNPC' -- A timer value local timer = 0 -- Play sound every one second function ticker(frameDelay) -- Iterate a timer timer = timer + frameDelay -- Check if timer reaches one whole second if(timer >= 1000)then -- Play a tick sound Audio.playSoundByRole(SoundRoles.MenuScroll) -- Reset timer to zero without lost of timing accuracy timer = timer - 1000 end end function MyNPC:onLoop(frameDelay) ticker(frameDelay) end return MyNPC
- NpcControllerBase:onKill (killEvent)
-
Event callback calling on attempt to kill NPC
Parameters:
- killEvent NpcKillEvent Kill event context. Can be used to identify reasons and gives ability to reject this event.
Usage:
class 'MyNPC' function MyNPC:onKill(killEvent) -- NPC is invincable to everything except of lava if(killEvent.reason_code ~= BaseNPC.DAMAGE_LAVABURN)then killEvent.cancel = true end end return MyNPC
- NpcControllerBase:onHarm (harmEvent)
-
Event callback calling on attempt to hurt NPC
Parameters:
- harmEvent NpcHarmEvent Harm event context. Can be used to identify reasons and gives ability to reject this event.
Usage:
class 'MyNPC' function MyNPC:onHarm(harmEvent) -- Say "Ouch" when NPC was kicked to ass, but don't harm NPC if(harmEvent.reason_code == BaseNPC.DAMAGE_BY_KICK)then Audio.playSound(5); harmEvent.cancel = true end end return MyNPC
- NpcControllerBase:onTransform (id)
-
Event callback calling on attempt to transform NPC into another
Parameters:
- id ulong Destinition ID to transform this NPC
Usage:
class 'MyNPC' function MyNPC:onTransform(id) -- Stop free motion of NPC on attempt to transform it self.npc_obj.speedX = 0 end return MyNPC
Damage reasons enumeration (DamageReason)
- BaseNPC.DAMAGE_NOREASON
- No reason of damage
- BaseNPC.DAMAGE_STOMPED
- NPC was stomped
- BaseNPC.DAMAGE_BY_KICK
- NPC was kicked
- BaseNPC.DAMAGE_BY_PLAYER_ATTACK
- NPC was attacked by player
- BaseNPC.DAMAGE_TAKEN
- NPC was taken by player (for example, NPC is a coin, item, weapon, power-up, etc.)
- BaseNPC.DAMAGE_LAVABURN
- NPC was burn in lava
- BaseNPC.DAMAGE_PITFALL
- NPC fell into the pit
- BaseNPC.DAMAGE_CUSTOM_REASON
- Custom reason base, use it as modifier to any custom damage reasons
Warping side enumeration (WarpingSide)
- BaseNPC.WARP_TOP
- NPC is in warping process and points top direction
- BaseNPC.WARP_LEFT
- NPC is in warping process and points left direction
- BaseNPC.WARP_BOTTOM
- NPC is in warping process and points bottom direction
- BaseNPC.WARP_RIGHT
- NPC is in warping process and points right direction
Spawning algorithms enumeration (SpawnType)
- BaseNPC.SPAWN_APPEAR
- Instant appearence with no effects
- BaseNPC.SPAWN_WARP
- Smooth appearence (for example, appearence from under ground)
- BaseNPC.SPAWN_PROJECTILE
- Projectile shoot, NPC will appear instantly with initial speed and smoke effect
Spawning direction enumeration (SpawnDirection)
- BaseNPC.SPAWN_LEFT
- Spawn NPC with left direction
- BaseNPC.SPAWN_RIGHT
- Spawn NPC with right direction
- BaseNPC.SPAWN_UP
- Spawn NPC with up direction
- BaseNPC.SPAWN_DOWN
- Spawn NPC with down direction
Class BaseNPC
Non-Playable Character Object base class, inherited from PhysBaseClass.PhysBase
- BaseNPC.id
-
ID of NPC registered in config pack (Read Only)
- id ulong
- BaseNPC.direction
-
Face direction of NPC
- direction int -1 is faced left, +1 is faced right, 0 is randomly selected drection (when you setting it up)
- BaseNPC.not_movable
-
NPC will don't move horizontally
- not_movable bool
- BaseNPC.contents
-
ID of NPC which contains inside this NPC
- contents long
- BaseNPC.special1
-
Special value of NPC from level file entry
- special1 long
- BaseNPC.special2
-
Special value of NPC from level file entry
- special2 long
- BaseNPC.isBoss
-
Is this NPC an important boss (a flag from level file)
- isBoss bool
- BaseNPC.collideWithBlocks
-
Can NPC collide blocks?
- collideWithBlocks bool
- BaseNPC.collideWithPlayers
-
Can NPC collide playable character?
- collideWithPlayers bool
- BaseNPC.health
-
Health level of NPC
- health long
- BaseNPC.frameDelay
-
Animation frame delay
- frameDelay int
- BaseNPC.killableByFire
-
Is NPC vulnuable to fire attacks (Read Only)
- killableByFire bool
- BaseNPC.killableByIce
-
Is NPC vulnuable to ice/cold attacks (Read Only)
- killableByIce bool
- BaseNPC.killableByHammer
-
Is NPC vulnuable to hammer attacks (Read Only)
- killableByHammer bool
- BaseNPC.killableByForcejump
-
Is NPC is vulnuable from a power jumps (Read Only)
- killableByForcejump bool
- BaseNPC.killableByStatue
-
Is NPC is vulnuable from a statue fell (Read Only)
- killableByStatue bool
- BaseNPC.killableByVehicle
-
Is NPC is vulnuable from attacks by vehicles (Read Only)
- killableByVehicle bool
- BaseNPC.onGround
-
Is NPC stays on a solid surface (Read Only)
- onGround bool
- BaseNPC.motionSpeed
-
Self-motion speed of NPC in pixels per 1/65 of second (Read Only)
- motionSpeed double
- BaseNPC.onCliff
-
Is NPC stays on an edge of ground where it stays (Read Only)
- onCliff bool
- BaseNPC.animationIsFinished
-
Is once-playing animation was finished (Read Only)
- animationIsFinished bool
- BaseNPC:transformTo (id)
-
Transform NPC into another NPC
Parameters:
- id ulong ID of NPC registered in the config pack
- BaseNPC:transformTo (id, type)
-
Transform NPC into another NPC or into the block
Parameters:
- id ulong ID of NPC or Block registered in the config pack
- type int Type of object to transform NPC: 1 - Another NPC, 2 - Block
- BaseNPC.transformedFromBlockID
-
Original ID of block from which NPC was transformed (Read Only)
- transformedFromBlockID ulong If 0, NPC was not transformed from block
- BaseNPC.transformedFromNpcID
-
Original ID of NPC from which NPC was transformed (Read Only)
- transformedFromNpcID ulong If 0, NPC was not transformed from another NPC
- BaseNPC.spawnedGenType
-
Type of spawn algorithm originally produced this NPC (Read Only)
- spawnedGenType SpawnType
- BaseNPC.spawnedGenDirection
-
Direction of NPC when it was originally spawned (Read Only)
- spawnedGenDirection SpawnDirection
- BaseNPC:setBodyType ()
- Sets body type
- BaseNPC:setSequenceLeft (frames)
-
Set custom animation sequence for left face direction
Parameters:
- frames table Array of frame indeces integers
- BaseNPC:setSequenceRight (frames)
-
Set custom animation sequence for right face direction
Parameters:
- frames table Array of frame indeces integers
- BaseNPC:setSequence (frames)
-
Set custom common animation sequence for all face directions
Parameters:
- frames table Array of frame indeces integers
- BaseNPC:setOnceAnimationMode (enabled)
-
Turn on once animation mode when changed animation sequence will play once after set
Parameters:
- enabled bool If true, once animation mode is turned on
- BaseNPC:setGfxOffset (x, y)
-
Set custom GFX offset
Parameters:
- x double Horizontal offset
- y double Vertical offset
- BaseNPC:setGfxOffset (x)
-
Set custom horizontal GFX offset
Parameters:
- x double Horizontal offset
- BaseNPC:setGfxOffset (y)
-
Set custom vertical GFX offset
Parameters:
- y double Vertical offset
- BaseNPC:installInAreaDetector (left, top, right, bottom, filters)
-
Install an In-Area detector for relative area and get a referrence to it,
boundary coordinates of a trap area are relative to center point of NPC
Parameters:
- left double Left border offset of the trap area
- top double Top border offset of the trap area
- right double Right border offset of the trap area
- bottom double Bottom border offset of the trap area
- filters
table
Array of integers are identifying object types needed to detect:
- 1 - blocks
- 2 - BGOs
- 3 - NPCs
- 4 - Playable characters
Returns:
-
InAreaDetector
Reference to initialized In-Area detector
- BaseNPC:installPlayerPosDetector ()
-
Install a detector of capabilities and state of a nearest playable character ("Player Position" detector)
Returns:
-
PlayerPosDetector
Reference to initialized "Player Position" detector
- BaseNPC:installContactDetector ()
-
Install a detector of contacted objects which will detect any objects contacted this NPC
Returns:
-
ContactDetector
Reference to initialized contacts detector
- BaseNPC:spawnNPC (npcID, spawnType, direction)
-
Spawn another NPC on same position as this NPC.
Spawned NPC will be destroyed on off screen timeout
Parameters:
- npcID ulong ID of NPC registered in config pack
- spawnType int Spawn algorithm
- direction int Spawn direction
Returns:
-
BaseNPC
NPC object of spawned NPC. nil if error has occouped to spawn NPC
- BaseNPC:spawnNPC (npcID, spawnType, direction, reSpawnable)
-
Spawn another NPC on same position as this NPC.
Spawned NPC will be destroyed on off screen timeout if reSpawnable flag is false.
If reSpawnable flag is true, NPC will be deactivated and will be activated on next
appearence on screen like all other regular NPCs.
Parameters:
- npcID ulong ID of NPC registered in config pack
- spawnType int Spawn algorithm
- direction int Spawn direction
- reSpawnable bool NPC will be kept on a level after going off screen. On false, NPC will be destroyed after off screen timeout
Returns:
-
BaseNPC
NPC object of spawned NPC. nil if error has occouped to spawn NPC
- BaseNPC:setSpriteWarp (depth, direction, resizedBody)
-
Set cut off level of the sprite
Parameters:
- depth float Warping depth between 1.0 and 0.0. 0 is fully visible, 1.0 is fully invisible
- direction WarpingSide Direction of "head" which will be shown while body is going into hide
- resizedBody bool Don't move sprite down to feet, use it when sprite warping is used together with physical body resizing
- BaseNPC:resetSpriteWarp ()
- Disables sprite cut off and resets it to normal state
- BaseNPC:activateNeighbours ()
- Force activate nearest NPCs are touching this NPC are even not touching player's camera
- BaseNPC:unregister ()
- Destroy NPC with no effects and no events
- BaseNPC:kill (damageReason)
-
Kill this NPC with damage reason
Parameters:
- damageReason DamageReason Code of death reason
- BaseNPC:kill (damageReason, killedBy)
-
Kill this NPC with damage reason and telling who killed this NPC
Parameters:
- damageReason DamageReason Code of death reason
- killedBy PhysBaseClass.PhysBase Reference to person object (playable character or NPC) who killed this NPC
- BaseNPC:harm ()
- Harm this NPC with removing one health point
- BaseNPC:harm (damageLevel)
-
Harm this NPC with removing given health point
Parameters:
- damageLevel int Count of health point to remove
- BaseNPC:harm (damageLevel, damageReason)
-
Harm this NPC with removing given health point and reason of damage
Parameters:
- damageLevel int Count of health point to remove
- damageReason DamageReason Code of damage reason
- BaseNPC:harm (damageLevel, damageReason, harmBy)
-
Harm this NPC with removing given health point, reason of damage and person who damaged this NPC
Parameters:
- damageLevel int Count of health point to remove
- damageReason DamageReason Code of damage reason
- harmBy PhysBaseClass.PhysBase Reference to person object (playable character or NPC) who harmed this NPC
Damaged By enumeration (killedBy)
- NpcHarmEvent.self
- NPC made damage to itself
- NpcHarmEvent.player
- NPC was damaged by playable character
- NpcHarmEvent.otherNPC
- NPC was damaged by another NPC
Class NpcHarmEvent
NPC Harm Event context
- NpcHarmEvent.cancel
-
Reject this event, it will not be executed
- cancel bool
- NpcHarmEvent.damage
-
Damage level caused by this event
- damage int
- NpcHarmEvent.reason_code
-
Damage reason code
- reason_code DamageReason
- NpcHarmEvent.killed_by
-
Who damaged this NPC
- killed_by killedBy
- NpcHarmEvent.killer_p
-
Playable character who damaged this NPC or nil if NPC was not damaged by playable character
- killer_p BasePlayer
- NpcHarmEvent.killer_n
-
Another NPC who damaged this NPC or nil if NPC was not damaged by other NPC
- killer_n BaseNPC
Killed By enumeration (killedBy)
- NpcHarmEvent.self
- NPC made damage to itself
- NpcHarmEvent.player
- NPC was damaged by playable character
- NpcHarmEvent.otherNPC
- NPC was damaged by another NPC
Class NpcKillEvent
NPC Kill Event context
- NpcKillEvent.cancel
-
Reject this event, it will not be executed
- cancel bool
- NpcKillEvent.reason_code
-
Death reason code
- reason_code DamageReason
- NpcKillEvent.killed_by
-
Who killed this NPC
- killed_by killedBy
- NpcKillEvent.killer_p
-
Playable character who killed this NPC or nil if NPC was not killed by playable character
- killer_p BasePlayer
- NpcKillEvent.killer_n
-
Another NPC who killed this NPC or nil if NPC was not killed by other NPC
- killer_n BaseNPC
Class ContactDetector
NPC contact detector context
- ContactDetector:detected ()
-
Check are contacts was detected
Returns:
-
bool
true if any object contacted this NPC
- ContactDetector:getBlocks ()
-
Get array of touching blocks
Returns:
-
table
Array of BaseBlock references to the block objects
- ContactDetector:getBGOs ()
-
Get array of touching BGOs
Returns:
-
table
Array of BaseBGO references to the BGO objects
- ContactDetector:getNPCs ()
-
Get array of touching NPCs
Returns:
-
table
Array of BaseNPC references to the NPC objects
- ContactDetector:getPlayers ()
-
Get array of touching Playable Characters
Returns:
-
table
Array of BasePlayer references to the Playable Characters objects
Class InAreaDetector
NPC In-Area detector context
- InAreaDetector:detected ()
-
Is any object appears in the trap zone
Returns:
-
bool True if any allowed by filter element is touches a trap of detector
- InAreaDetector:detected (id, type)
-
Is any object of specified id and type is in the trap zone
Parameters:
- id long ID of necessary element
- type long Type of necessary element
Returns:
-
bool True if any allowed by filter element is touches a trap of detector
- InAreaDetector:getBlocks ()
-
Get array of blocks touching a trap zone
Returns:
-
table
Array of BaseBlock references to the block objects
- InAreaDetector:getBGOs ()
-
Get array of BGOs touching a trap zone
Returns:
-
table
Array of BaseBGO references to the BGO objects
- InAreaDetector:getNPCs ()
-
Get array of NPCs touching a trap zone
Returns:
-
table
Array of BaseNPC references to the NPC objects
- InAreaDetector:getPlayers ()
-
Get array of Playable Characters touching a trap zone
Returns:
-
table
Array of BasePlayer references to the Playable Characters objects
- InAreaDetector:contacts ()
-
Get count of objects touching a trap zone
Returns:
-
int
Count of contacted objects
Class PlayerPosDetector
NPCs' Player position detector
- PlayerPosDetector:detected ()
-
Was playable character detected on the scene?
Returns:
-
bool
True if any playable character is alive and presented on the level scene
- PlayerPosDetector:directedTo ()
-
Direction of left or right side where nearest playable character is located
Returns:
-
bool
-1 if nearest playable character lefter than this NPC or +1 if righter
- PlayerPosDetector:playerDirection ()
-
Face direction of nearest playable character
Returns:
-
bool
-1 if nearest playable character is faced to left or +1 if nearest playable character is faced to right
- PlayerPosDetector:positionX ()
-
Absolute horizintal position of nearest playable character
Returns:
-
double
X position of nearest playable character
- PlayerPosDetector:positionY ()
-
Absolute vertical position of nearest playable character
Returns:
-
double
Y position of nearest playable character
- PlayerPosDetector:playersCharID ()
-
Get ID of nearest playable character
Returns:
-
ulong
ID of nearest playable character registered in config pack
- PlayerPosDetector:playerStateID ()
-
Get ID of nearest playable character's state
Returns:
-
ulong
ID of nearest playable character's state registered in config pack
- PlayerPosDetector:playerPtr ()
-
Get reference to nearest playable character
Returns:
-
BasePlayer
Reference to nearest playable character