Skip to Content
The Alchemy Project

src/field/script_commands_ropes.c

Ropes, tightropes and hanging vines: chains of nodes laid between two points or round one, drawn and updated each tick, and the leader crossing them. More…

Included by script_commands.c.

Macros

NameDescription
#defineROPE_DEPTH 58A sprite's depth slot is its point's y + z in pixels plus a bias: an actor's sprite adds 62 and its shadow 60 (fdRenderApplyProjectedPlacement), a rope's and a tightrope's sprites this, a hanging vine's links HANGING_VINE_DEPTH.
#defineROPE_PUSH_STEPS 12The leader steps onto a rope or tightrope once it has pushed against its post (FIELD_STATE.blockedSteps) for more than this many ticks.
#defineROPE_POST_HOOKED 99A post whose sceneByte byte holds this keeps in watchedActor a hook giving the point Lash throws the rope to (fdRopeLash); no scene marks a post so.
#defineDEBUG_FIRST_POST (ACTOR_FIRST_PLACED + 4)The posts the unused debug hooks (fdRopeDebugSwing, fdTightropeDebugSwing) swing rope 0 between: the fifth and sixth actors a scene places.
#defineDEBUG_SECOND_POST (ACTOR_FIRST_PLACED + 5)
#defineVINE_LINK_PICTURE_SIZE (16 * 16)The bytes of a link's picture, 16 by 16 pixels of 256 colours.
#defineVINE_SWING_ALONE (TRIG_TURN / 256)A vine's swing: its top link stays put, the first link below it sways one and a half times the swing either way, and each link below that half a swing more (fdHangingVineUpdate).
#defineVINE_SWING_BESIDE (TRIG_TURN / 2048)
#defineVINE_LINK_LAG 800Each link sways this far behind the one above it, a turn being TRIG_TURN.
#defineHANGING_VINE_DEPTH 34A vine link's depth slot bias, as ROPE_DEPTH a rope's.
#defineSIDE_TURN (side) ((side) * (DEGtoANG(180)))The half turn on the leader's side of the anchor: 0 on its right, 1 on its left.
#defineVINE_PHASE_MASK (TRIG_ANGLE_MASK & ~0xff)A vine's phase within one turn, its low byte dropped: a phase grows by TRIG_TURN / 128 a tick and never wraps.
#defineVINE_SWING_STEP (TRIG_TURN / 1024)A vine's swing, as VINE_SWING_ALONE: wound up a step a tick as Whirlwind blows on it, while the leader hangs on, and while it carries the leader across.
#defineVINE_SWING_HELD (TRIG_TURN * 3 / 128)
#defineVINE_SWING_CARRYING (TRIG_TURN / 32)

Enumerations

NameDescription
enumPOST_ANIMATION { ANIM_POST_TIE, ANIM_POST_UNTIE, ANIM_POST_TIED }The animations of a rope's or tightrope's post (SPRITE_TIGHTROPE_POST).
enumHANGING_VINE_LINK_KIND { VINE_LINK_FREE, VINE_LINK_ANCHOR, VINE_LINK_TOP, VINE_LINK_U … }HANGING_VINE_LINK.kind: a free link, the anchor (not drawn), then a link showing each of the four pictures, in their order in VRAM.

Functions

NameDescription
voidfdRopeInit (void)Allocates the ropes' state, loads their node picture and starts fdRopeDraw and fdRopeUpdate.
voidfdRopeDraw (void)The ropes' drawing event: a sprite at the midpoint of each pair of neighbouring nodes, 4 pixels up, turned along the pair and given its rope's priority, for the pairs on screen; a rope's first node keeps the last turn.
voidfdRopeUpdate (void)The ropes' event: unless the field is handling a request, raises FIELD_RAISED_CUE_ROPE_ON when the leader has pushed at one end of a tied rope, or FIELD_RAISED_CUE_ROPE_OFF while on one; then swings each swinging rope, its swing losing a twentieth a tick until under a tenth of a pixel.
ROPE_NODE *fdRopeAllocateNode (void)Returns the first unused of the ropes' 128 nodes, or NULL.
voidfdRopeTie (Sint32 index, Sint32 id, Sint32 other)Lays rope index tied between posts id and other, and shows both posts with the rope wound round them.
Sint32fdRopeLayTied (Sint32 index, Sint32 x1, Sint32 y1, Sint32 z1, Sint32 x2, Sint32 y2, Sint32 z2)Builds rope index's nodes on the line between two points, one for each 6 pixels, waved a pixel either way by one whole sine; marks it tied and swinging and sets its flag.
voidfdRopeSwingBetween (Sint32 index, Sint32 from, Sint32 to, FIXED height)Lays rope index again between posts from and to, its middle bowed height pixels (16.16) aside.
extern Sint16syTrigAtanHalfword (Sint32 x, Sint32 y)VIEW(ropes): routine syAtan as returning Sint16; system.h has it return Sint32.
Sint32fdRopeLayBowed (Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ, FIXED height)Lays a rope's nodes along the line between two points again, bowed by half a sine height pixels (16.16) high.
voidfdRopeCoil (Sint32 index, Sint32 firstId, Sint32 secondId)Coils rope index at post firstId, its length reaching post secondId: the rope as it waits to be lashed.
Sint32fdRopeLayCoil (Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ)Builds rope index's nodes, one for each 6 pixels between two points, as a flat spiral around the first point: the rope coiled at its post.
voidfdRopeGetEndNodePos (Sint32 index, Sint32 *pos)Writes where rope index's last node is, its far end, into position.
Sint32fdRopeThrow (Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ, Sint32 wave)Throws rope index from one point to another over twice its node count in ticks: the end flies on an arc and each node follows the one ahead at 6 pixels; then the rope swings and its flag is set.
Sint32fdRopeRecoil (Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ, Sint32 wave)Pulls a thrown rope back into its coil at the first point, one node a tick, clearing its flag, starting four ticks after both posts start to unwind.
voidfdRopeLash (Sint32 index, Sint32 fromId, Sint32 toId)Lash: throws rope index from post fromId to post toId and winds it round both.
voidfdRopeUntie (Sint32 index, Sint32 fromId, Sint32 toId)Unties rope index between posts fromId and toId (fdRopeRecoil).
voidfdRopeReservedNoOperation (void)Unused: nothing refers to it.
voidfdRopeDebugSwing (ACTOR *actor)Unused: nothing refers to it.
BoolfdRopeIsLeaderAtEnd (Sint32 firstId, Sint32 secondId)Returns 1 when the leader stands on the metatile of post firstId or secondId, or a metatile beside it along an axis, at the same height.
Sint32fdRopeFindById (Sint32 id, Sint32 *value, Sint32 *index)Finds the rope whose first post is id: writes its other post and its index and returns 0, or returns -1.
Sint32fdRopeGetState (Sint32 index)Returns rope index's ROPE_SLOT_STATE, or -1 while the ropes have no state.
voidfdRopePlace (Sint32 index, Sint32 flag, Sint32 firstId, Sint32 secondId)Gives rope index its flag and places it between posts firstId and secondId: tied when the flag is set, else coiled at the first.
voidfdTightropeInit (void)Allocates the tightropes' state, loads their node picture and starts fdTightropeDraw and fdTightropeUpdate.
voidfdTightropeDraw (void)The tightropes' drawing event: as fdRopeDraw, a sprite at the midpoint of each pair of neighbouring nodes, 4 pixels up, for the pairs on screen, all of a tightrope turned along it.
voidfdTightropeUpdate (void)The tightropes' event: fdRopeUpdate for the tightropes, raising FIELD_RAISED_CUE_TIGHTROPE_ON and FIELD_RAISED_CUE_TIGHTROPE_OFF; the middle of a wobbling tightrope bobs up and down.
TIGHTROPE_NODE *fdTightropeAllocateNode (void)Returns the first unused of the tightropes' 128 nodes, or NULL.
Sint32fdTightropePlace (Sint32 slotNo, Sint32 firstId, Sint32 secondId)Lays tightrope slotNo straight between posts firstId and secondId, and shows the rope wound round both.
Sint32fdTightropeLay (Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ)Builds tightrope index's nodes on the straight line between two points, one for each 6 pixels.
voidfdTightropeWobbleBetween (Sint32 index, Sint32 from, Sint32 to, FIXED height)Lays tightrope index again between posts from and to, its middle raised height pixels (16.16).
Sint32fdTightropeLayBowed (Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ, FIXED height)fdRopeLayBowed for a tightrope: lays its nodes along the line between two points again, raised by half a sine height pixels (16.16) high.
voidfdTightropeCoil (Sint32 index, Sint32 from, Sint32 to)Unused: nothing refers to it.
Sint32fdTightropeLayCoil (Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ)fdRopeLayCoil for a tightrope.
voidfdTightropeLash (Sint32 index, Sint32 firstId, Sint32 secondId)Unused: nothing refers to it.
Sint32fdTightropeThrow (Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ)fdRopeThrow for a tightrope.
voidfdTightropeUntie (Sint32 index, Sint32 firstId, Sint32 secondId)Unused: nothing refers to it.
Sint32fdTightropeRecoil (Sint32 slot, Sint32 x1, Sint32 y1, Sint32 z1, Sint32 x2, Sint32 y2, Sint32 z2, Sint32 wave)fdRopeRecoil for a tightrope.
voidfdTightropeRelease (Sint32 index)Frees tightrope index's nodes; it is no longer drawn.
voidfdTightropeSettle (Sint32 index)Stops tightrope index's wobble and marks its nodes not to be walked.
voidfdTightropeDebugSwing (ACTOR *actor)Unused: nothing refers to it.
HANGING_VINE_WORK *fdHangingVineInit (Sint32 spriteId)Starts the hanging vines: takes and clears their state, loads the vine's pictures for an anchor of SPRITE_SPROUTING_LEAVES, else the chain's, and adds the events fdHangingVineDraw and fdHangingVineUpdate.
voidfdHangingVineDraw (void)The vines' drawing event: each link's picture at the midpoint between it and the link above, turned along the vine, for the links on screen.
voidfdHangingVineUpdate (void)The vines' event: sways each active vine's links below its anchor, the swing easing towards VINE_SWING_BESIDE while the leader stands beside the vine, else towards VINE_SWING_ALONE.
HANGING_VINE_SLOT *fdHangingVineFindFreeSlot (void)Returns the first of HANGING_VINE_STATE's eight slots with no chain, or NULL.
HANGING_VINE_SLOT *fdHangingVineFindSlot (Sint32 id)Returns the vine slot among HANGING_VINE_STATE's eight that holds actor id, or NULL.
HANGING_VINE_LINK *fdHangingVineAllocateLink (void)Returns the first unused of the vines' 128 links, or NULL.
voidfdHangingVineHang (Sint32 objectId, Sint32 grow)Hangs a vine of seven links from the anchor actor objectId, clearing the five metatiles it hangs over, starting the vines first if they are not running; with grow set, the vine drops into place over 28 ticks.
voidfdHangingVineSwing (Sint32 id)Whirlwind on the vine hanging from actor id: the vine swings out to the leader's side and the leader takes hold.
voidfdHangingVinePlace (Sint32 id, Sint32 force)Hangs a vine at once from high above actor id down to its feet (fdHangingVineHang): an actor that is not moving is lifted and moved 16 pixels north first, which fdHangingVineHang undoes; a moving one has its vine only when force is set.

Variables

NameDescription
extern Sint32RopeLashPhaseSix words of zero.
extern Sint32RopeUntiePhase
extern Sint32RopeDebugSwinging
extern Sint32TightropeLashPhase
extern Sint32TightropeUntiePhase
extern Sint32TightropeDebugSwinging
extern const Uint8HangingVineVineTopPicture [], HangingVineVineUpperPicture[], HangingVineVineLowerPicture[]The four pictures of each kind of hanging link, a vine's and a chain's: top, upper, lower and bottom.
extern const Uint8HangingVineVineBottomPicture [], HangingVineChainTopPicture[], HangingVineChainMiddlePicture[]

Description

Ropes, tightropes and hanging vines: chains of nodes laid between two points or round one, drawn and updated each tick, and the leader crossing them. Part of script_commands.c.

Macros in detail

ROPE_DEPTH

#define ROPE_DEPTH 58

A sprite's depth slot is its point's y + z in pixels plus a bias: an actor's sprite adds 62 and its shadow 60 (fdRenderApplyProjectedPlacement), a rope's and a tightrope's sprites this, a hanging vine's links HANGING_VINE_DEPTH.

Referenced by fdRopeDraw() and fdTightropeDraw().

Definition at line 16 of file script_commands_ropes.c.

ROPE_PUSH_STEPS

#define ROPE_PUSH_STEPS 12

The leader steps onto a rope or tightrope once it has pushed against its post (FIELD_STATE.blockedSteps) for more than this many ticks.

Referenced by fdRopeUpdate() and fdTightropeUpdate().

Definition at line 33 of file script_commands_ropes.c.

ROPE_POST_HOOKED

#define ROPE_POST_HOOKED 99

A post whose sceneByte byte holds this keeps in watchedActor a hook giving the point Lash throws the rope to (fdRopeLash); no scene marks a post so.

Referenced by fdRopeLash().

Definition at line 37 of file script_commands_ropes.c.

DEBUG_FIRST_POST

#define DEBUG_FIRST_POST (ACTOR_FIRST_PLACED + 4)

The posts the unused debug hooks (fdRopeDebugSwing, fdTightropeDebugSwing) swing rope 0 between: the fifth and sixth actors a scene places.

Referenced by fdRopeDebugSwing() and fdTightropeDebugSwing().

Definition at line 41 of file script_commands_ropes.c.

DEBUG_SECOND_POST

#define DEBUG_SECOND_POST (ACTOR_FIRST_PLACED + 5)

Referenced by fdRopeDebugSwing() and fdTightropeDebugSwing().

Definition at line 42 of file script_commands_ropes.c.

#define VINE_LINK_PICTURE_SIZE (16 * 16)

The bytes of a link's picture, 16 by 16 pixels of 256 colours.

Referenced by fdHangingVineDraw() and fdHangingVineInit().

Definition at line 1585 of file script_commands_ropes.c.

VINE_SWING_ALONE

#define VINE_SWING_ALONE (TRIG_TURN / 256)

A vine's swing: its top link stays put, the first link below it sways one and a half times the swing either way, and each link below that half a swing more (fdHangingVineUpdate). A vine left alone eases to the first, and while the leader stands beside it to the second.

Referenced by fdHangingVineHang() and fdHangingVineUpdate().

Definition at line 1603 of file script_commands_ropes.c.

VINE_SWING_BESIDE

#define VINE_SWING_BESIDE (TRIG_TURN / 2048)

Referenced by fdHangingVineUpdate().

Definition at line 1604 of file script_commands_ropes.c.

#define VINE_LINK_LAG 800

Each link sways this far behind the one above it, a turn being TRIG_TURN.

Referenced by fdHangingVineSwing() and fdHangingVineUpdate().

Definition at line 1606 of file script_commands_ropes.c.

HANGING_VINE_DEPTH

#define HANGING_VINE_DEPTH 34

A vine link's depth slot bias, as ROPE_DEPTH a rope's.

Referenced by fdHangingVineDraw().

Definition at line 1609 of file script_commands_ropes.c.

SIDE_TURN

#define SIDE_TURN(side) ((side) * (DEGtoANG(180)))

The half turn on the leader's side of the anchor: 0 on its right, 1 on its left.

Referenced by fdHangingVineSwing().

Definition at line 1992 of file script_commands_ropes.c.

VINE_PHASE_MASK

#define VINE_PHASE_MASK (TRIG_ANGLE_MASK & ~0xff)

A vine's phase within one turn, its low byte dropped: a phase grows by TRIG_TURN / 128 a tick and never wraps.

Referenced by fdHangingVineSwing().

Definition at line 1996 of file script_commands_ropes.c.

VINE_SWING_STEP

#define VINE_SWING_STEP (TRIG_TURN / 1024)

A vine's swing, as VINE_SWING_ALONE: wound up a step a tick as Whirlwind blows on it, while the leader hangs on, and while it carries the leader across.

Referenced by fdHangingVineSwing().

Definition at line 2001 of file script_commands_ropes.c.

VINE_SWING_HELD

#define VINE_SWING_HELD (TRIG_TURN * 3 / 128)

Referenced by fdHangingVineSwing().

Definition at line 2002 of file script_commands_ropes.c.

VINE_SWING_CARRYING

#define VINE_SWING_CARRYING (TRIG_TURN / 32)

Referenced by fdHangingVineSwing().

Definition at line 2003 of file script_commands_ropes.c.

Enumerations in detail

POST_ANIMATION

enum POST_ANIMATION

The animations of a rope's or tightrope's post (SPRITE_TIGHTROPE_POST).

EnumeratorValueDescription
ANIM_POST_TIE2the rope winding round the post, then ANIM_POST_TIED
ANIM_POST_UNTIE3the rope unwinding, then the bare post
ANIM_POST_TIED4the rope wound round the post

Definition at line 6 of file script_commands_ropes.c.

enum HANGING_VINE_LINK_KIND

HANGING_VINE_LINK.kind: a free link, the anchor (not drawn), then a link showing each of the four pictures, in their order in VRAM.

EnumeratorValueDescription
VINE_LINK_FREE
VINE_LINK_ANCHOR
VINE_LINK_TOP
VINE_LINK_UPPER
VINE_LINK_LOWER
VINE_LINK_BOTTOM

Definition at line 1589 of file script_commands_ropes.c.

Functions in detail

fdRopeInit

void fdRopeInit(void)

Allocates the ropes' state, loads their node picture and starts fdRopeDraw and fdRopeUpdate. A scene with ropes to lash calls it first.

References fdRopeDraw(), fdRopeUpdate(), RopeTiles, syDecompressTaggedLZ(), syHeapAllocate(), syHeapRelease(), syHeapSlotAllocateEWRAM(), sySetEvent(), syVRAMCacheFindFreeEntry() and syVRAMCacheLoad().

Referenced by scAlhafranCaveSetUpJail(), scApojiiIslandsInitHaze(), scCavernsInitIndra(), scGabombaStatueInitLowerCogs(), scGabombaStatueInitSteel(), scGabombaStatueInitUpperCogs(), scInit(), scKandoreanTempleStartFogRoom(), scKandoreanTempleStartPoisRoom(), scKibomboInitVillage(), scMadraCatacombsSetUpChampaTunnel(), scMadraCatacombsSetUpVillage(), scSettlementsSetUpKaltIsland(), scShamanVillageSetUpVillage(), scShrineOfTheSeaGodInitBrokenBridges(), scShrineOfTheSeaGodInitEntrance() and scYampiDesertSetUpSandSlides().

Definition at line 46 of file script_commands_ropes.c.

fdRopeDraw

void fdRopeDraw(void)

The ropes' drawing event: a sprite at the midpoint of each pair of neighbouring nodes, 4 pixels up, turned along the pair and given its rope's priority, for the pairs on screen; a rope's first node keeps the last turn.

References fdMapStateView(), Sint32, syAtan(), syOAMAddSpriteAtDepthClamped(), syOAMMatrixAllocateFromTransform() and VramCacheEntries.

Referenced by fdRopeInit().

Definition at line 64 of file script_commands_ropes.c.

fdRopeUpdate

void fdRopeUpdate(void)

The ropes' event: unless the field is handling a request, raises FIELD_RAISED_CUE_ROPE_ON when the leader has pushed at one end of a tied rope, or FIELD_RAISED_CUE_ROPE_OFF while on one; then swings each swinging rope, its swing losing a twentieth a tick until under a tenth of a pixel.

References fdFindNearbyTalkTarget(), fdRopeIsLeaderAtEnd(), fdRopeSwingBetween(), MainRoutineStateWork, Sint32, syGameFlagGet() and sySin().

Referenced by fdRopeInit().

Definition at line 154 of file script_commands_ropes.c.

fdRopeAllocateNode

ROPE_NODE *fdRopeAllocateNode(void)

Returns the first unused of the ropes' 128 nodes, or NULL.

References Sint32.

Referenced by fdRopeLayCoil(), fdRopeLayTied() and fdTightropeLayCoil().

Definition at line 206 of file script_commands_ropes.c.

fdRopeTie

void fdRopeTie(Sint32 index, Sint32 id, Sint32 other)

Lays rope index tied between posts id and other, and shows both posts with the rope wound round them.

References fdActorLookup(), fdActorSelectAnimationStub(), fdRopeLayTied() and Sint32.

Referenced by fdRopePlace() and scInit().

Definition at line 223 of file script_commands_ropes.c.

fdRopeLayTied

Sint32 fdRopeLayTied(Sint32 index, Sint32 x1, Sint32 y1, Sint32 z1, Sint32 x2, Sint32 y2, Sint32 z2)

Builds rope index's nodes on the line between two points, one for each 6 pixels, waved a pixel either way by one whole sine; marks it tied and swinging and sets its flag.

References fdRopeAllocateNode(), result, Sint32, syAtan(), syCos(), syGameFlagSet(), sySin() and sySquartIWRAM().

Referenced by fdRopeTie().

Definition at line 255 of file script_commands_ropes.c.

fdRopeSwingBetween

void fdRopeSwingBetween(Sint32 index, Sint32 from, Sint32 to, FIXED height)

Lays rope index again between posts from and to, its middle bowed height pixels (16.16) aside.

References fdActorLookup(), fdRopeLayBowed() and Sint32.

Referenced by fdRopeDebugSwing() and fdRopeUpdate().

Definition at line 324 of file script_commands_ropes.c.

syTrigAtanHalfword

extern Sint16 syTrigAtanHalfword(Sint32 x, Sint32 y)

VIEW(ropes): routine syAtan as returning Sint16; system.h has it return Sint32.

Referenced by fdRopeLayBowed().

Definition at line 342 of file script_commands_ropes.c.

fdRopeLayBowed

Sint32 fdRopeLayBowed(Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ, FIXED height)

Lays a rope's nodes along the line between two points again, bowed by half a sine height pixels (16.16) high.

References Sint32, syCos(), sySin() and syTrigAtanHalfword().

Referenced by fdRopeSwingBetween().

Definition at line 346 of file script_commands_ropes.c.

fdRopeCoil

void fdRopeCoil(Sint32 index, Sint32 firstId, Sint32 secondId)

Coils rope index at post firstId, its length reaching post secondId: the rope as it waits to be lashed.

References fdActorLookup(), fdRopeLayCoil() and Sint32.

Referenced by fdRopePlace(), scInit() and scLemuriaTryStuckDoor().

Definition at line 384 of file script_commands_ropes.c.

fdRopeLayCoil

Sint32 fdRopeLayCoil(Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ)

Builds rope index's nodes, one for each 6 pixels between two points, as a flat spiral around the first point: the rope coiled at its post.

References fdRopeAllocateNode(), result, Sint32, syAtan(), syCos() and sySin().

Referenced by fdRopeCoil().

Definition at line 413 of file script_commands_ropes.c.

fdRopeGetEndNodePos

void fdRopeGetEndNodePos(Sint32 index, Sint32 *pos)

Writes where rope index's last node is, its far end, into position.

References Sint32.

Referenced by fdPsynergyUpdateLash().

Definition at line 463 of file script_commands_ropes.c.

fdRopeThrow

Sint32 fdRopeThrow(Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ, Sint32 wave)

Throws rope index from one point to another over twice its node count in ticks: the end flies on an arc and each node follows the one ahead at 6 pixels; then the rope swings and its flag is set. Does nothing to a rope already thrown. The callers pass the wobble fdTightropeRecoil takes, which a rope leaves unused, and read no result: 0, or nothing for a rope already thrown.

References Sint32, syAtan(), syCos(), syGameFlagSet(), syHeapAllocate(), syHeapRelease(), sySin() and sySynch().

Referenced by fdRopeLash().

Definition at lines 484 and 580 of file script_commands_ropes.c.

fdRopeRecoil

Sint32 fdRopeRecoil(Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ, Sint32 wave)

Pulls a thrown rope back into its coil at the first point, one node a tick, clearing its flag, starting four ticks after both posts start to unwind. The far end and the wobble are fdTightropeRecoil's arguments, which a rope leaves unused; as with fdRopeThrow, no caller reads the result.

References fdActorSelectAnimationStub(), Sint32, syAtan(), syCos(), syGameFlagClear(), syHeapAllocate(), syHeapRelease(), sySin() and sySynch().

Referenced by fdRopeLash() and fdRopeUntie().

Definition at lines 492 and 706 of file script_commands_ropes.c.

fdRopeLash

void fdRopeLash(Sint32 index, Sint32 fromId, Sint32 toId)

Lash: throws rope index from post fromId to post toId and winds it round both. A rope coiled too short to reach falls back to its post.

References fdActorLookup(), fdActorSelectAnimationStub(), fdRopeRecoil(), fdRopeThrow(), RopeLashPhase, Sint32, sySin() and sySynch().

Referenced by fdPsynergyLash(), scGarohLashRope(), scLemuriaTryStuckDoor(), scOseniaCliffsLashRope() and scSettlementsLashRope().

Definition at line 503 of file script_commands_ropes.c.

fdRopeUntie

void fdRopeUntie(Sint32 index, Sint32 fromId, Sint32 toId)

Unties rope index between posts fromId and toId (fdRopeRecoil).

References fdActorLookup(), fdRopeRecoil(), RopeUntiePhase, Sint32 and sySin().

Definition at line 676 of file script_commands_ropes.c.

fdRopeReservedNoOperation

void fdRopeReservedNoOperation(void)

Unused: nothing refers to it. Does nothing.

Definition at line 801 of file script_commands_ropes.c.

fdRopeDebugSwing

void fdRopeDebugSwing(ACTOR *actor)

Unused: nothing refers to it. An actor hook that, once L is pressed, lays rope 0 again between DEBUG_FIRST_POST and DEBUG_SECOND_POST every tick.

References fdRopeSwingBetween(), PerWork and RopeDebugSwinging.

Definition at line 809 of file script_commands_ropes.c.

fdRopeIsLeaderAtEnd

Bool fdRopeIsLeaderAtEnd(Sint32 firstId, Sint32 secondId)

Returns 1 when the leader stands on the metatile of post firstId or secondId, or a metatile beside it along an axis, at the same height.

References fdActorGetById(), MainRoutineStateWork and Sint32.

Referenced by fdRopeUpdate() and fdTightropeUpdate().

Definition at line 823 of file script_commands_ropes.c.

fdRopeFindById

Sint32 fdRopeFindById(Sint32 id, Sint32 *value, Sint32 *index)

Finds the rope whose first post is id: writes its other post and its index and returns 0, or returns -1.

References Sint32.

Referenced by fdPsynergyLashOnTarget().

Definition at line 869 of file script_commands_ropes.c.

fdRopeGetState

Sint32 fdRopeGetState(Sint32 index)

Returns rope index's ROPE_SLOT_STATE, or -1 while the ropes have no state.

References Sint32.

Referenced by scGabombaStatueLashRope().

Definition at line 889 of file script_commands_ropes.c.

fdRopePlace

void fdRopePlace(Sint32 index, Sint32 flag, Sint32 firstId, Sint32 secondId)

Gives rope index its flag and places it between posts firstId and secondId: tied when the flag is set, else coiled at the first. A scene places each of its ropes with it.

References fdRopeCoil(), fdRopeTie(), Sint32 and syGameFlagGet().

Referenced by scAlhafranCaveSetUpJail(), scApojiiIslandsInitHaze(), scCavernsInitIndra(), scDehkanPlateauInitTightropes(), scFieldRopePlace(), scInit(), scKandoreanTemplePoiWaitsByTheNorthRope(), scKandoreanTempleStartFogRoom(), scKandoreanTempleStartPoisRoom(), scKibomboInitVillage(), scShamanVillageSetUpVillage(), scShrineOfTheSeaGodInitBrokenBridges(), scShrineOfTheSeaGodInitEntrance() and scYampiDesertPlaceRope().

Definition at line 903 of file script_commands_ropes.c.

fdTightropeInit

void fdTightropeInit(void)

Allocates the tightropes' state, loads their node picture and starts fdTightropeDraw and fdTightropeUpdate.

References fdTightropeDraw(), fdTightropeUpdate(), RopeTiles, syDecompressTaggedLZ(), syHeapAllocate(), syHeapRelease(), syHeapSlotAllocateEWRAM(), sySetEvent(), syVRAMCacheFindFreeEntry() and syVRAMCacheLoad().

Referenced by scDehkanPlateauInitTightropes(), scGarohInitPath(), scGondowanCliffsSetUpPass(), scInit(), scKandoreanTempleStartLiftRoom(), scPrepareMap() and scTrialRoadSetUpSandStage().

Definition at line 923 of file script_commands_ropes.c.

fdTightropeDraw

void fdTightropeDraw(void)

The tightropes' drawing event: as fdRopeDraw, a sprite at the midpoint of each pair of neighbouring nodes, 4 pixels up, for the pairs on screen, all of a tightrope turned along it.

References fdMapStateView(), Sint32, syOAMAddSpriteAtDepthClamped(), syOAMMatrixAllocateFromTransform() and VramCacheEntries.

Referenced by fdTightropeInit().

Definition at line 941 of file script_commands_ropes.c.

fdTightropeUpdate

void fdTightropeUpdate(void)

The tightropes' event: fdRopeUpdate for the tightropes, raising FIELD_RAISED_CUE_TIGHTROPE_ON and FIELD_RAISED_CUE_TIGHTROPE_OFF; the middle of a wobbling tightrope bobs up and down.

References fdFindNearbyTalkTarget(), fdRopeIsLeaderAtEnd(), fdTightropeWobbleBetween(), MainRoutineStateWork, Sint32, syGameFlagGet() and sySin().

Referenced by fdTightropeInit().

Definition at line 1026 of file script_commands_ropes.c.

fdTightropeAllocateNode

TIGHTROPE_NODE *fdTightropeAllocateNode(void)

Returns the first unused of the tightropes' 128 nodes, or NULL.

References Sint32.

Referenced by fdTightropeLay().

Definition at line 1082 of file script_commands_ropes.c.

fdTightropePlace

Sint32 fdTightropePlace(Sint32 slotNo, Sint32 firstId, Sint32 secondId)

Lays tightrope slotNo straight between posts firstId and secondId, and shows the rope wound round both. Declared Sint32, as the scenes call it, though it returns no value; no caller reads one.

References fdActorLookup(), fdActorSelectAnimationStub(), fdTightropeLay() and Sint32.

Referenced by scDehkanPlateauInitTightropes(), scEasternAlhafraPoundStake(), scGarohInitPath(), scGondowanCliffsSetUpPass(), scInit(), scKandoreanTempleStartLiftRoom(), scPrepareMap() and scTrialRoadSetUpSandStage().

Definition at line 1100 of file script_commands_ropes.c.

fdTightropeLay

Sint32 fdTightropeLay(Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ)

Builds tightrope index's nodes on the straight line between two points, one for each 6 pixels.

References fdTightropeAllocateNode(), result, Sint32 and syAtan().

Referenced by fdTightropePlace().

Definition at line 1126 of file script_commands_ropes.c.

fdTightropeWobbleBetween

void fdTightropeWobbleBetween(Sint32 index, Sint32 from, Sint32 to, FIXED height)

Lays tightrope index again between posts from and to, its middle raised height pixels (16.16).

References fdActorLookup(), fdTightropeLayBowed() and Sint32.

Referenced by fdTightropeDebugSwing() and fdTightropeUpdate().

Definition at line 1177 of file script_commands_ropes.c.

fdTightropeLayBowed

Sint32 fdTightropeLayBowed(Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ, FIXED height)

fdRopeLayBowed for a tightrope: lays its nodes along the line between two points again, raised by half a sine height pixels (16.16) high.

References Sint32, syIWRAMMulFX() and sySin().

Referenced by fdTightropeWobbleBetween().

Definition at line 1198 of file script_commands_ropes.c.

fdTightropeCoil

void fdTightropeCoil(Sint32 index, Sint32 from, Sint32 to)

Unused: nothing refers to it. fdRopeCoil for a tightrope.

References fdActorLookup(), fdTightropeLayCoil() and Sint32.

Definition at line 1237 of file script_commands_ropes.c.

fdTightropeLayCoil

Sint32 fdTightropeLayCoil(Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ)

fdRopeLayCoil for a tightrope. Only the unused fdTightropeCoil calls it, and it takes its nodes from the ropes' pool.

References fdRopeAllocateNode(), result, Sint32, syAtan(), syCos() and sySin().

Referenced by fdTightropeCoil().

Definition at line 1261 of file script_commands_ropes.c.

fdTightropeLash

void fdTightropeLash(Sint32 index, Sint32 firstId, Sint32 secondId)

Unused: nothing refers to it. fdRopeLash for a tightrope, without the short rope's fall.

References fdActorLookup(), fdActorSelectAnimationStub(), fdTightropeThrow(), Sint32, sySin(), sySynch() and TightropeLashPhase.

Definition at line 1312 of file script_commands_ropes.c.

fdTightropeThrow

Sint32 fdTightropeThrow(Sint32 index, Sint32 x, Sint32 y, Sint32 z, Sint32 toX, Sint32 toY, Sint32 toZ)

fdRopeThrow for a tightrope.

References Sint32, syAtan(), syCos(), syHeapAllocate(), syHeapRelease(), sySin() and sySynch().

Referenced by fdTightropeLash().

Definition at line 1335 of file script_commands_ropes.c.

fdTightropeUntie

void fdTightropeUntie(Sint32 index, Sint32 firstId, Sint32 secondId)

Unused: nothing refers to it. fdRopeUntie for a tightrope.

References fdActorLookup(), fdTightropeRecoil(), Sint32, sySin() and TightropeUntiePhase.

Definition at line 1427 of file script_commands_ropes.c.

fdTightropeRecoil

Sint32 fdTightropeRecoil(Sint32 slot, Sint32 x1, Sint32 y1, Sint32 z1, Sint32 x2, Sint32 y2, Sint32 z2, Sint32 wave)

fdRopeRecoil for a tightrope.

References fdActorSelectAnimationStub(), Sint32, syAtan(), syCos(), syHeapAllocate(), syHeapRelease(), sySin(), sySquartIWRAM() and sySynch().

Referenced by fdTightropeUntie().

Definition at line 1454 of file script_commands_ropes.c.

fdTightropeRelease

void fdTightropeRelease(Sint32 index)

Frees tightrope index's nodes; it is no longer drawn.

References Sint32.

Referenced by scEasternAlhafraPoundStake().

Definition at line 1543 of file script_commands_ropes.c.

fdTightropeSettle

void fdTightropeSettle(Sint32 index)

Stops tightrope index's wobble and marks its nodes not to be walked.

References Sint32.

Referenced by scInit().

Definition at line 1554 of file script_commands_ropes.c.

fdTightropeDebugSwing

void fdTightropeDebugSwing(ACTOR *actor)

Unused: nothing refers to it. fdRopeDebugSwing for a tightrope.

References fdTightropeWobbleBetween(), PerWork and TightropeDebugSwinging.

Definition at line 1565 of file script_commands_ropes.c.

fdHangingVineInit

HANGING_VINE_WORK *fdHangingVineInit(Sint32 spriteId)

Starts the hanging vines: takes and clears their state, loads the vine's pictures for an anchor of SPRITE_SPROUTING_LEAVES, else the chain's, and adds the events fdHangingVineDraw and fdHangingVineUpdate.

References fdHangingVineDraw(), fdHangingVineUpdate(), HangingVineChainBottomPicture, HangingVineVineBottomPicture, HangingVineVineTopPicture, Sint32, syDecompressTaggedLZ(), syHeapAllocate(), syHeapRelease(), syHeapSlotAllocateEWRAM(), sySetEvent(), syVRAMCacheFindFreeEntry() and syVRAMCacheLoad().

Referenced by fdHangingVineHang().

Definition at line 1621 of file script_commands_ropes.c.

fdHangingVineDraw

void fdHangingVineDraw(void)

The vines' drawing event: each link's picture at the midpoint between it and the link above, turned along the vine, for the links on screen.

References fdMapStateView(), Sint32, syAtan(), syOAMAddSpriteAtDepthClamped(), syOAMMatrixAllocateFromTransform() and VramCacheEntries.

Referenced by fdHangingVineInit().

Definition at line 1663 of file script_commands_ropes.c.

fdHangingVineUpdate

void fdHangingVineUpdate(void)

The vines' event: sways each active vine's links below its anchor, the swing easing towards VINE_SWING_BESIDE while the leader stands beside the vine, else towards VINE_SWING_ALONE.

References fdActorGetById(), fdPartyGetLeaderActor(), Sint32, syCos() and sySin().

Referenced by fdHangingVineInit().

Definition at line 1752 of file script_commands_ropes.c.

fdHangingVineFindFreeSlot

HANGING_VINE_SLOT *fdHangingVineFindFreeSlot(void)

Returns the first of HANGING_VINE_STATE's eight slots with no chain, or NULL.

References Sint32.

Referenced by fdHangingVineHang().

Definition at line 1825 of file script_commands_ropes.c.

fdHangingVineFindSlot

HANGING_VINE_SLOT *fdHangingVineFindSlot(Sint32 id)

Returns the vine slot among HANGING_VINE_STATE's eight that holds actor id, or NULL.

References Sint32.

Referenced by fdHangingVineHang() and fdHangingVineSwing().

Definition at line 1844 of file script_commands_ropes.c.

HANGING_VINE_LINK *fdHangingVineAllocateLink(void)

Returns the first unused of the vines' 128 links, or NULL.

References Sint32.

Referenced by fdHangingVineHang().

Definition at line 1862 of file script_commands_ropes.c.

fdHangingVineHang

void fdHangingVineHang(Sint32 objectId, Sint32 grow)

Hangs a vine of seven links from the anchor actor objectId, clearing the five metatiles it hangs over, starting the vines first if they are not running; with grow set, the vine drops into place over 28 ticks.

References fdActorGetById(), fdActorSelectAnimationStub(), fdActorSetSpriteFlagsStub(), fdHangingVineAllocateLink(), fdHangingVineFindFreeSlot(), fdHangingVineFindSlot(), fdHangingVineInit(), Sint32 and sySynch().

Referenced by fdHangingVinePlace() and fdPsynergyGrowthOnTarget().

Definition at line 1880 of file script_commands_ropes.c.

fdHangingVineSwing

void fdHangingVineSwing(Sint32 id)

Whirlwind on the vine hanging from actor id: the vine swings out to the leader's side and the leader takes hold. While the leader hangs on, B, Down or the direction away from the vine lets go; any other button leaps, and the vine carries the leader across to the far side.

References fdActorGetById(), fdActorSelectAnimationStub(), fdActorSetSpriteFlagsStub(), fdHangingVineFindSlot(), fdPartyGetLeaderActor(), PerWork, Sint32, syCos(), syIWRAMMulFX(), sySin(), sySoundPlayStub(), sySynch() and TickCount.

Referenced by fdPsynergyWhirlwind().

Definition at line 2009 of file script_commands_ropes.c.

fdHangingVinePlace

void fdHangingVinePlace(Sint32 id, Sint32 force)

Hangs a vine at once from high above actor id down to its feet (fdHangingVineHang): an actor that is not moving is lifted and moved 16 pixels north first, which fdHangingVineHang undoes; a moving one has its vine only when force is set.

References fdActorGetById(), fdHangingVineHang() and Sint32.

Referenced by scInit().

Definition at line 2176 of file script_commands_ropes.c.

Variables in detail

HangingVineVineTopPicture

extern const Uint8 HangingVineVineTopPicture[], HangingVineVineUpperPicture[], HangingVineVineLowerPicture[]

The four pictures of each kind of hanging link, a vine's and a chain's: top, upper, lower and bottom.

Referenced by fdHangingVineInit().

Definition at line 1579 of file script_commands_ropes.c.

HangingVineVineBottomPicture

extern const Uint8 HangingVineVineBottomPicture[], HangingVineChainTopPicture[], HangingVineChainMiddlePicture[]

Referenced by fdHangingVineInit().

Definition at line 1581 of file script_commands_ropes.c.