Module engine.Actor
Functions
| _M:act () | Called when it is time to act |
| _M:addTemporaryValue (prop, v, noupdate) | Computes a "temporary" value into a property Example: You cant to give an actor a boost to life_regen, but you do not want it to be permanent You cannot simply increase life_regen, so you use this method which will increase it AND store the increase. |
| _M:attr (prop, v, fix) | Increases/decreases an attribute The attributes are just actor properties, but this ensures they are numbers and not booleans thus making them compatible with temporary values system |
| _M:canMove (x, y, terrain_only) | Can the actor go there |
| _M:canSee (actor) | Can the actor see the target actor This does not check LOS or such, only the actual ability to see it. By default this returns true, but a module can override it to check for telepathy, invisibility, stealth, ... |
| _M:enoughEnergy (val) | Do we have enough energy |
| _M:getTarget () | Gets the actor target Does nothing, AI redefines it so should a "Player" class |
| _M:isNear (x, y, radius) | Are we within a certain distance of the target |
| _M:knockback (srcx, srcy, dist) | Knock back the actor |
| _M:move (x, y, force, map) | Moves an actor on the map *WARNING*: changing x and y properties manualy is *WRONG* and will blow up in your face. |
| _M:moveDir (dir) | Moves into the given direction (calls actor:move() internally) |
| _M:onTemporaryValueChange (prop, sub, v) | Called when a temporary value changes (added or deleted) This does nothing by default, you can overload it to react to changes |
| _M:reactionToward (target) | What is our reaction toward the target See Faction:factionReaction() |
| _M:removeTemporaryValue (prop, id, noupdate) | Removes a temporary value, see addTemporaryValue() |
| _M:setTarget (target) | Sets the actor target Does nothing, AI redefines it so should a "Player" class |
| _M:teleportRandom (x, y, dist) | Teleports randomly to a passable grid |
| _M:useEnergy (val) | Use some energy |
Functions
- _M:act ()
- Called when it is time to act
- _M:addTemporaryValue (prop, v, noupdate)
-
Computes a "temporary" value into a property Example: You cant to give an actor a boost to life_regen, but you do not want it to be permanent
You cannot simply increase life_regen, so you use this method which will increase it AND store the increase. it will return an "increase id" that can be passed to removeTemporaryValue() to remove the effect.Parameters
- prop: the property to affect
- v: the value to add (only numbers supported for now)
- noupdate: if true the actual property is not changed and needs to be changed by the caller
Return value:
an id that can be passed to removeTemporaryValue() to delete this value - _M:attr (prop, v, fix)
-
Increases/decreases an attribute The attributes are just actor properties, but this ensures they are numbers and not booleans thus making them compatible with temporary values system
Parameters
- prop: the property to use
- v: the value to add, if nil this the function return
- fix: forces the value to v, do not add
Return value:
nil if v was specified. If not then it returns the current value if it exists and is not 0 otherwise returns nil - _M:canMove (x, y, terrain_only)
-
Can the actor go there
Parameters
- x:
- y:
- terrain_only: if true checks only the terrain, otherwise checks all entities
- _M:canSee (actor)
-
Can the actor see the target actor This does not check LOS or such, only the actual ability to see it.
By default this returns true, but a module can override it to check for telepathy, invisibility, stealth, ...Parameters
- actor: the target actor to check
Return value:
true or false and a number from 0 to 100 representing the "chance" to be seen - _M:enoughEnergy (val)
-
Do we have enough energy
Parameters
- val:
- _M:getTarget ()
- Gets the actor target Does nothing, AI redefines it so should a "Player" class
- _M:isNear (x, y, radius)
-
Are we within a certain distance of the target
Parameters
- x: the spot we test for near-ness
- y: the spot we test for near-ness
- radius: how close we should be (defaults to 1)
- _M:knockback (srcx, srcy, dist)
-
Knock back the actor
Parameters
- srcx:
- srcy:
- dist:
- _M:move (x, y, force, map)
-
Moves an actor on the map *WARNING*: changing x and y properties manualy is *WRONG* and will blow up in your face. Use this method. Always.
Parameters
- x: coord of the destination
- y: coord of the destination
- force: if true do not check for the presence of an other entity. *Use wisely*
- map: the map to move onto
Return value:
true if a move was *ATTEMPTED*. This means the actor will proably want to use energy - _M:moveDir (dir)
-
Moves into the given direction (calls actor:move() internally)
Parameters
- dir:
- _M:onTemporaryValueChange (prop, sub, v)
-
Called when a temporary value changes (added or deleted) This does nothing by default, you can overload it to react to changes
Parameters
- prop: the property changing
- sub: the sub element of the property if it is a table, or nil
- v: the value of the change
- _M:reactionToward (target)
-
What is our reaction toward the target See Faction:factionReaction()
Parameters
- target:
- _M:removeTemporaryValue (prop, id, noupdate)
-
Removes a temporary value, see addTemporaryValue()
Parameters
- prop: the property to affect
- id: the id of the increase to delete
- noupdate: if true the actual property is not changed and needs to be changed by the caller
- _M:setTarget (target)
-
Sets the actor target Does nothing, AI redefines it so should a "Player" class
Parameters
- target:
- _M:teleportRandom (x, y, dist)
-
Teleports randomly to a passable grid
Parameters
- x: the coord of the teleporatation
- y: the coord of the teleporatation
- dist: the radius of the random effect, if set to 0 it is a precise teleport
Return value:
true if the teleport worked - _M:useEnergy (val)
-
Use some energy
Parameters
- val: