Modding:Entity: Difference between revisions
(added defaultGetName function) |
(Add get/set body description functions) |
||
| Line 56: | Line 56: | ||
=== boolean getCursed() === | === boolean getCursed() === | ||
Is this entity cursed? | Is this entity cursed? | ||
=== [[Modding:BodyDescription|BodyDescription]] getBodyDescription() === | |||
Gets body description for this npc -- may be nil if no body description has been set. | |||
Added in r56.1 | |||
== Private Methods == | == Private Methods == | ||
=== setBodyDescription([[Modding:BodyDescription|BodyDescription]] bodyDescription) === | |||
Sets/overwrites body description for this npc. | |||
Added in r56.1 | |||
=== Default versions of functions === | === Default versions of functions === | ||
Latest revision as of 22:56, 9 January 2026
Static Public Methods
static Entity generate(string entityName)
Generate a new entity of the given type based on the entity type string. Null if unknown entity.
Public Methods
string getName()
Gets name of entity
string getLookDesc()
Gets look description(the text displayed when looking at item)
boolean isExaminable()
Allow player to examine object? If so, the item is shown in the room item list. Otherwise, the object is invisible
boolean isAttackable()
Is player allowed to (attempt) to do an attack on this object -- shown when looking at object
boolean isUseable()
Is player shown a use button on this object -- shown when looking at object
boolean isPickupable()
Should object display a pick-up option if not yet in inventory? May or may not *actually* be pickupable. To do / attempt to do a pickup, use the Player class.
boolean isDropable()
Should object display a drop item button if is in inventory? May or may not *actually* be dropable. Use Player class to make the actual attempt.
void deleteEntity()
Removes entity from either the inventory or room that it exists in.
boolean isPlayerHere()
If entity is in world, is the player in this same room?
int isPlayerAdjacent()
If entity is in the world, is the player in a room adjacent to the one entity is in? If so, which room ID?
If not, room ID is 0. If player is in the same room, then room ID 0 is also returned.
Location getLocation()
Gets location of this entity. Returns null if entity is in inventory, or otherwise not in world.
void moveEntity(string newMapName:String, int newRoomID)
Moves entity from whereever it is (including inventory) into a particular location. If picking up the item, should use the functions on the Player class instead.
void moveEntityToSameRoomAsPlayer()
Move entity from wherever it is (including inventory) into the same room as the player is in.
void makeCursed()
Marks this entity as cursed. In order for this to have any effect, you should write a custom function for playerAttemptDropCheck.
Generally this would be called on start-up. Curse status can be modified by NPCs that can perform purification.
See Weight Pendant for an example of cursed items.
boolean getCursed()
Is this entity cursed?
BodyDescription getBodyDescription()
Gets body description for this npc -- may be nil if no body description has been set.
Added in r56.1
Private Methods
setBodyDescription(BodyDescription bodyDescription)
Sets/overwrites body description for this npc.
Added in r56.1
Default versions of functions
These are useful for calling if you want to do some logic first, and then fall back to the usual monster logic.
string defaultGetName(NameType nameType = NameType.Unspecified)
As of r56.1, this is mostly useful to advanced monster mods, but is available to all entities. (Entities currently have no way to set the initial name value, so calling the default get name will just return "uninitialized entity". It is useful for advanced monster mods since they can set the name via 'initialValues' and thus access when UI name is supposed to be sleeping, etc.)