Entity||doc135317

September 20, 2022

Entity

Introduction

Entity is inherited from Object (Entity Object) and further defines the base Object on how living creatures behave in the game world. Including HP and death, templates and actions, movements and jumps, etc., Entity Class is the most vibrant element of the game world. Monsters, NPCs, and players are all defined by the Entity Class

How to create an entity object in the game world

On the server-side, use EntityServer.Create to create an entity object.

On the client-side, use EntityClient.CreateClientEntity to create an entity object.

Constructor

void Entity.addValueDef (  string key,  variant init,  boolean toSelf,  boolean toOther,  boolean saveDB,  boolean client  )
Add value definition
void Entity.addValueFunc (  string key,  function func  )
The callback function when the value defined by the registered value changes
Entity EntityServer.Create (  CreateParams params,  function func  )
Generate an entity object on the server side
Entity EntityClient.CreateClientEntity (  CreateParams params )
Generate an entity object on the client side

Properties

string name

name

float curHp

The entity's current health value

float curVp

The entity's current hunger value

boolean isMoving

Whether the current entity is moving. In the riding and riding state, the displacement caused by the riding object or the riding object does not count as the movement of the current entity

boolean onGround

Is it on the ground

boolean isFlying

Is it in the air

Function

void setHp (  float hp  )

Set the health value of the entity

float addHp (  float hp  )

Increases the health of the entity

void setVp (  float vp  )

Set the starvation value of the entity

float addVp (  float vp  )

Increases the hunger bar of the entity

variant prop (  string key )

Get entity properties

void setProp (  string key,  variant value  )

Set entity properties

void setValue (  string key,  variant value,  boolean noSync  )

set value defined value

void getValue (  string key )

get the value defined by the value

void addSkill (  string fullName)

Add skills

void removeSkill (  string fullName)

remove skill

Buff addBuff (  string buffName, int time  )

Add Buff

void removeBuff (  Buff buff)

remove buff

EntityTrays tray (    )

Returns the container instance that holds the tray instance

Object owner (    )

Returns the owner of the object

boolean isDead (    )

Returns whether the current entity object is in a dead state

void addItem (  string fullName,  int count,  function proc,  string reason  )

Additive tool

table getNearbyEntities (  float maxDistance,  function filter  )

Returns a list of nearby entity objects

float getSpeed (    )

Get the current movement speed of the current entity

boolean jump (  int x,  int z  )

jump

boolean isSwimming (    )

Are you swimming

int getCollidableUnderfootObjId (    )

Returns the object Id of the object at the foot of the current entity

boolean isControl (    )

Returns whether the current entity is controlled by the player

void setBodyTurnSpeed (  float speed  )

Sets the current entity's turn speed

float getBodyTurnSpeed (    )

Get the current entity's turn speed

Vector3 isClimbing (    )

Get the block you are climbing

void changeFlyMode (  float mode  )

Change entity flight mode coefficients

void setPos (  Vector3 pos,  float yaw,  float pitch  )

set coordinates

void setMapPos (  Map map,  Vector3 pos,  float yaw,  float pitch  )

Set up map and coordinates

Vector3 curBlockPos (    )

Get the block position occupied by the current entity

Vector3 getFrontPos (  float dis,  boolean isFoot,  boolean bCenter  )

Get the coordinates of the front of the object

void setAlwaysAction (  string action  )

Set permanent action

int updateUpperAction (  string action,  int ticks)

Update upper action

string getBaseAction (    )

Get the basic action of the current entity object

string getUpperAction (    )

Get the upper action of the current entity object

void getPrevBaseAction (    )

Get the last basic action of the current entity object

string getPrevUpperAction (    )

Get the last upper action of the current entity object

void setActionMapping (  string actionSrc,  string actionDst  )

Set the mapping of action names in the action mapping table of the entity object

void removeActionMapping (  string action  )

Remove the mapping of action names in the content of the entity's action mapping table

void setActorPause (  boolean isPause  )

Set entity action pause (frozen state)

boolean getActorPause (    )

Gets whether the entity action is paused (frozen state)

void setActorAnimRewind (  boolean rewind  )

Set whether the action of the entity is reversed

boolean isActorAnimRewind (    )

Gets whether the action of the entity is in reverse mode

void refreshUpperAction (    )

Reset upper body movements

void refreshBaseAction (    )

Reset full body movements

void setBaseActionScale (  float scale  )

Set the overall playback speed of the entity action

float getBaseActionScale (    )

Get the overall playback speed of the entity action

void setActionTimeScale (  string action,  float scale  )

Sets the playback speed of the specified action of the entity

float getActionTimeScale (  string action  )

Get the playback speed of the specified action of the entity

void removeActionTimeScale (  string action  )

Removes the playback speed of an entity's specified action

boolean isActionInTimeScaleMap (  string action  )

Returns whether the specified action has a playback speed set

void addEffect (  string name,  string effectName,  boolean once,  Vector3 pos,  float yaw,  Vector3 scale,  string socketName  )

Add playback effects to entity objects

void delEffect (  string name,  boolean smooth  )

Remove effects from solid objects

string getActorName (    )

Get the role model name of the current entity object

void setActorScale (  Vector3 scale  )

Sets the scaling of the entity object character model

void setAlpha (  float alpha,  int time  )

Set the transparency of the entity object character model

int play3dSound (  string filename,  boolean isLoop  )

play sound

void setGuideTarget (  Vector3 targetPosition,  string texName,  float speed  )

Set the guidance information and use the coordinates as the guidance target

void setGuideTarget1 (  Entity targetEntity,  string texName,  float speed  )

Set up guidance information, with entities as guidance targets

void delGuideTarget (    )

Close guidance information

void setGhost (  boolean enable,  table color,  int interval,  int num  )

Set whether to render the client entity afterimage effect

item getHandItem (    )

Get handheld item

void setHoldModelARGBStrength (  float r,  float g,  float b,  float a  )

Set the ARGB color coefficient of the held item model

table getHoldModelARGBStrength (    )

Get the ARGB color coefficient of the held item model

void setUseOverlayColorReplaceMode (  string masterSlaveName,  boolean isUse  )

Set whether to use the replacement mode of the skin color

void setOverlayColor (  string masterSlaveName,  table color  )

set skin color

void applySkin (  SkinData skin  )

Apply skin

void changeSkin (  SkinData skinData  )

change skin

void setEntityHide (  boolean hide  )

Set whether to hide entity objects

boolean getInvisible (    )

Get whether the current entity object is invisible

void changeActor (  string actorName,  boolean clearSkin  )

Change the role model

void setEntityActorFlashEffect (  boolean add  )

Set whether the flickering effect of the model is enabled

void setPlayerControl (  Entity player  )

Sets the player controller that controls the specified server entity

void face2Pos (  Vector3 pos  )

facing the specified coordinates

Team getTeam (    )

Get the team instance of the entity object

void serverRebirth (  Map map,  Vector3 pos,  float yaw,  float pitch  )

rebirth

void setRebirthPos (  Vector3 pos,  Map map  )

Set respawn coordinates

Vector3 getRebirthPos (    )

Get respawn coordinates

int takeDamage (  int damage,  Entity from,  boolean isFormula,  strin cause  )

Inflicts damage to solid objects

void kill (  Entity from,  strin cause  )

Kill physical objects

void doHurtRepel (  Vector3 vector  )

Put the entity into the hit state and specify the vector of displacement

void getAIControl (    )

Get the AI Controller

void startAI (    )

Enable entity AI

void stopAI (    )

Turn off entity AI

void setAITargetPos (  Vector3 vector ,bool enable  )

set target point

void enableAITargetPos (  bool enable  )

Enable target point

Event

trigger ENTITY_ENTER

Trigger an event when an entity object is created

trigger ENTITY_LEAVE

Trigger an event when an entity object is destroyed

trigger ENTITY_CLICK

Trigger an event when an entity object is clicked

trigger ENTITY_TOUCHDOWN

The event is triggered when the entity object falls off the map and bottoms out

trigger ENTITY_DIE

Trigger an event when an entity object dies

trigger ENTITY_DAMAGE

Trigger an event when a solid object takes damage

trigger ENTITY_REBIRTH

Trigger an event when the entity object is reborn

trigger HAND_ITEM_CHANGED

Trigger the event when the entity object is holding the item to change

trigger ENTITY_USE_ITEM

Trigger an event when an entity object uses a item

trigger WEAR_EQUIPMEN

Trigger an event when an entity object equips a item

trigger TAKEOFF_EQUIPMEN

Event fired when entity object unloads item

trigger JOIN_TEAM

Trigger an event when an entity object joins a team

trigger LEAVE_TEAM

Triggers an event when an entity object leaves the queue

trigger ENTER_MAP

Trigger an event when an entity object enters the map

trigger LEAVE_MAP

Trigger an event when an entity object leaves the map

trigger ENTITY_TOUCH_ALL

Entity object touch entity object event

trigger ENTITY_APART

Detach event after entity object touches entity object

trigger ENTITY_HITTED

Event fired when entity object is hit by projectile

trigger HIT_ENTITY

Event fired when entity objects hit other objects with projectiles

trigger HIT_BLOCK

Event fired when entity object hits block with projectile

trigger ENTITY_HITTED_BY_RAY

Trigger event when entity object is hit by ray skill

trigger HIT_ENTITY_BY_RAY

Event triggered when solid object hits another object with ray skill

trigger HIT_BLOCK_BY_RAY

Trigger event when entity object hits block with ray skill

trigger SETTLE_ITEM

Triggered when an item is added to the player's tray

trigger REMOVE_ITEM

Triggered when an item is removed from the player's tray

trigger ENTITY_TOUCH_PART_BEGIN

Entity and part touch event

trigger ENTITY_TOUCH_PART_END

Entity and part leave touch event