Rat Class
A `Rat` which runs from hole to hole
Method Index
- _arrive()
- _beginRun()
- _chooseTarget()
- _determinePath(dest_x, dest_y)
- _emerge()
- _enterHole()
- _isCorridorPath(xs, ys)
- _tick() (inherited from Entity)
- _walkToNextTile()
- afterLoad(old, new) (inherited from Entity)
- clearDynamicInfo() (inherited from Entity)
- eraseObject() (inherited from Entity)
- getDrawingLayer() (inherited from Entity)
- getDynamicInfo() (inherited from Entity)
- getRoom() (inherited from Entity)
- getTile() (inherited from Entity)
- init(origin_wall)
- notifyNewObject(id) (inherited from Entity)
- notifyNewRoom(room) (inherited from Entity)
- onClick(ui, button)
- onDestroy() (inherited from Entity)
- onPickUp() (inherited from Entity)
- playAfterLoadSound() (inherited from Entity)
- playEntitySounds(name_pattern, min_silence_lengths, max_silence_lengths, num_silences) (inherited from Entity)
- playSound(name, played_callback, played_callback_delay) (inherited from Entity)
- resetAnimation() (inherited from Entity)
- setAnimation(animation, flags) (inherited from Entity)
- setDynamicInfo(type, value) (inherited from Entity)
- setLayer(layer, id) (inherited from Entity)
- setMood(mood_name, activate) (inherited from Entity)
- setMoodInfo(new_mood) (inherited from Entity)
- setPosition(x, y) (inherited from Entity)
- setSpeed(x, y) (inherited from Entity)
- setTile(x, y) (inherited from Entity)
- setTilePositionSpeed(tx, ty, px, py, sx, sy) (inherited from Entity)
- setTimer(tick_count, f) (inherited from Entity)
- setWaitingForSoundEffectsToBeTurnedOn() (inherited from Entity)
- tick() (inherited from Entity)
- tickDay() (inherited from Entity)
Member Index
- animation_flags (*)
- animation_idx (*)
- dynamic_info (*)
- last_move_direction
- layers (*)
- mood_info (*)
- mood_marker (*)
- num_animation_ticks (*)
- origin_wall
- path
- permanent_flags
- playing_sounds_in_random_sequence (*)
- random_sound_sequence_parameters (*)
- shot
- skip_next_tick (*)
- slow_animation (*)
- target
- th
- ticks (*)
- tile_x
- tile_y
- timer_function (*)
- timer_time (*)
- user_of (*)
- waiting_for_sound_effects_to_be_turned_on (*)
- world
function Rat:Rat(animation)
Parameters:
| Name | Type | Description |
|---|---|---|
| animation | ? | ? |
Declared on: line 71 of Lua/entities/rat.lua.
function Rat:_arrive()
The rat has reached the end of its run: enter the target hole if it is a
real rathole, otherwise just vanish.
Declared on: line 119 of Lua/entities/rat.lua.
function Rat:_beginRun()
Find a corridor path to the target hole and start following it, or leave if
there is no route.
Declared on: line 108 of Lua/entities/rat.lua.
function Rat:_chooseTarget()
Pick a destination rathole other than the one the rat started on.
("north"/"west"/"east"/"south").
Declared on: line 129 of Lua/entities/rat.lua.
function Rat:_determinePath(dest_x, dest_y)
Compute and store a corridor-only path from the rat's tile to the given
destination.
Parameters:
| Name | Type | Description |
|---|---|---|
| dest_x | integer | Destination tile X coordinate. |
| dest_y | integer | Destination tile Y coordinate. |
Declared on: line 166 of Lua/entities/rat.lua.
function Rat:_emerge()
Play the leaving-hole animation when emerging from a north hole, then run.
Other walls have no leaving animation, so the rat sets off immediately.
Declared on: line 93 of Lua/entities/rat.lua.
function Rat:_enterHole()
Play the entering-hole animation for the target hole's wall (north and west
have one; east and south holes are hidden), then remove the rat.
Declared on: line 222 of Lua/entities/rat.lua.
function Rat:_isCorridorPath(xs, ys)
Whether every tile on the given path is corridor (not inside a room), so the
rat stays out of rooms and never squeezes through closed doors -- matching the
original game, where rats scurry only in corridors.
Parameters:
| Name | Type | Description |
|---|---|---|
| xs | list | Path tile X coordinates. |
| ys | list | Path tile Y coordinates. |
Declared on: line 150 of Lua/entities/rat.lua.
function Rat:_walkToNextTile()
Walk the rat one tile further along its path, mirroring how humanoids move
(see `action_walk_raw`). The rat animates across a single tile over
`walk_quantity` ticks, then this runs again for the following tile until the
destination hole is reached. Keeping the tile position authoritative means
the rat stays clickable and detectable on the entity map.
Declared on: line 180 of Lua/entities/rat.lua.
function Rat:init(origin_wall)
Send the rat scurrying from its hole, along the corridors, to another
rathole where it disappears.
to pick the leaving animation (only north holes have one).
Parameters:
| Name | Type | Description |
|---|---|---|
| origin_wall | string or or or nil | The wall of the hole it emerges from, used |
Declared on: line 78 of Lua/entities/rat.lua.
function Rat:onClick(ui, button)
Shoot the rat on left-click: play the sounds, leave a dead-rat splat where
it was, and remove it. Guarded so a stale cursor entity cannot shoot the same
rat twice.
Parameters:
| Name | Type | Description |
|---|---|---|
| ui | GameUI | The game UI. |
| button | string | The mouse button used. |
Declared on: line 238 of Lua/entities/rat.lua.