Commonly used Entity utility functions.
Game/Scripts/Utils/EntityUtils.lua
Game/Scripts/common.lua
Dumps all entity identifiers (EntityId), names, classes, positions and angles, which are currently used in the map, to console.
e.g:
[userdata: 00000002]..name=Grunt1 clsid=Grunt pos=1016.755,1042.764,100.000 ang=0.000,0.000,1.500
[userdata: 00000003]..name=Grunt2 clsid=Grunt pos=1020.755,1072.784,100.000 ang=0.000,0.000,0.500
...
Compares two entities by name, which is commonly used while sorting tables.
Parameters | Description |
---|---|
ent1 | first entity table |
ent2 | second entity table |
local entities = System.GetEntitiesByClass("SomeEntityClass");
table.sort(entities, CompareEntitiesByName);
Compares two entities by their squared distance. If the distance to the point from entity one is greater than the distance to the point from entity two it returns true, otherwise it returns false.
Parameters | Description |
---|---|
ent1 | first entity table |
ent2 | second entity table |
point | 3D position vector |
local ent1 = System.GetEntityByName("NameEntityOne");
local ent2 = System.GetEntityByName("NameEntityTwo");
if(CompareEntitiesByDistanceFromPoint( ent1, ent2, g_localActor:GetPos()))then
Log("Entity One is further away from the Player than Entity two...");
end
Processes an entity event broadcast.
Parameters | Description |
---|---|
sender | the entity which originally sent the event |
event | string based entity event to process |
BroadcastEvent(self, "Used");
Creates a new table that is a derived version of a parent entity table. Commonly used to simplify the creation of a new entity script based on another entity.
Parameters | Description |
---|---|
_DerivedClass | derived class table |
_Parent | parent or base class table |
Creates a new table that is derived class of parent entity. The Child's Properties will override the ones from the parent.
Parameters | Description |
---|---|
_DerivedClass | derived class table |
_Parent | parent or base class table |
Adds usable functionality, like OnUsed event, to a given entity table.
Parameters | Description |
---|---|
entity | entity table |
MyEntity = { ... whatever you usually put here ... }
MakeUsable(MyEntity)
function MyEntity:OnSpawn() ...
function MyEntity:OnReset()
self:ResetOnUsed()
...
end
Adds a bPickable property to the entity properties table to add a basic pickable functionality to a given entity.
Parameters | Description |
---|---|
entity | entity table |
Adds spawn functionality to a given entity. Commonly used for AI actors during the creation.
Parameters | Description |
---|---|
entity | entity table |
Physicalizes an entity based on the given entity slot and physics properties.
Parameters | Description |
---|---|
entity | entity table |
nSlot | entity slot you want to physicalize |
Properties | physics properties table |
bActive | not used |