Skip to content

rq.party ​

since 0.22.0 changed 2.35.0

Reads and changes who is in the party.

The party has five ranks. Each holds a character id (the id of an entry in rq.units()) or 0 when it is empty. roster, state and set_state read and move the other characters (the first and second armies), and heal is the game's heal.

Functions ​

NameSummary
rq.party.getReturns the character id on each of the five ranks.
rq.party.setReplaces the whole party.
rq.party.rosterReturns every recruited character, or those in one place.
rq.party.stateReturns where a character is (登録状態).
rq.party.set_stateMoves a character between the first army (2), used in this quest (3) and the second army (4).
rq.party.healHeals the party as the game does: HP to the most, and with skills the skill uses too.

rq.party.get ​

lua
rq.party.get() -> integer[]

since 0.22.0

Returns the character id on each of the five ranks.

lua
for rank, id in ipairs(rq.party.get()) do
  if id ~= 0 then rq.log(rank, id) end
end
ReturnsTypeDescription
ranksinteger[]Five ids in rank order; 0 for an empty rank.

See also: rq.party.set

rq.party.set ​

lua
rq.party.set(ranks)

since 0.22.0

Replaces the whole party.

Raises an error, and changes nothing, during a battle, for a character that is not recruited, for a character listed twice, or for more than five ranks. A screen that is already open, such as the Party tab, does not redraw until it is opened again.

lua
local ranks = rq.party.get()
ranks[1], ranks[2] = ranks[2], ranks[1]   -- swap the first two ranks
rq.party.set(ranks)
ParameterTypeDescription
ranks(integer|false)[]Up to five character ids in rank order; 0 or false leaves a rank empty.

See also: rq.party.get

rq.party.roster ​

lua
rq.party.roster(state) -> rq.PartyMember[]

since 2.35.0

Returns every recruited character, or those in one place.

It reads the roster's slots in order. The party's ranks are rq.party.get.

lua
for _, m in ipairs(rq.party.roster(rq.ids.party_state.RESERVE)) do
  if m.status == rq.ids.state.DOWNED then rq.log(rq.chara.get(m.iic).name, "is down") end
end
ParameterTypeDescription
state (optional)integerOnly characters in this place, 0 to 4 (rq.ids.party_state).
ReturnsTypeDescription
membersrq.PartyMember []The characters.

rq.party.state ​

lua
rq.party.state(iic) -> integer

since 2.35.0

Returns where a character is (登録状態).

ParameterTypeDescription
iicintegerThe roster slot.
ReturnsTypeDescription
stateinteger0 not recruited (also a slot with no character), 1 in the party, 2 the first army, 3 used in this quest, 4 the second army (rq.ids.party_state).

rq.party.set_state ​

lua
rq.party.set_state(iic, state) -> boolean

since 2.35.0

Moves a character between the first army (2), used in this quest (3) and the second army (4).

A character marked used is not placed again until the quest ends, when the game puts it back in the first army; 2 gives it back now. Into and out of the party is rq.party.set; leaving is rq.chara.dismiss. A screen already open does not redraw until it opens again.

Raises an error for a slot with no character, one not recruited, a character in the party, or a state other than 2, 3 and 4.

lua
rq.party.set_state(iic, rq.ids.party_state.SECOND)
ParameterTypeDescription
iicintegerThe roster slot.
stateinteger2, 3 or 4 (rq.ids.party_state).
ReturnsTypeDescription
okbooleantrue.

rq.party.heal ​

lua
rq.party.heal(opts) -> integer

since 2.35.0

Heals the party as the game does: HP to the most, and with skills the skill uses too.

A downed character is left as it is, as the game's party heals do (PTA体力回復): set its status to 0 with rq.chara.set first to raise it. all heals every recruited character, not only the five ranks. Each heal is the game's own (C補給/体力, C補給/スキル).

Raises an error for options that are not true or false.

lua
rq.party.heal({ skills = true })      -- as a spring
rq.party.heal({ half = true })        -- up to half the HP
ParameterTypeDescription
opts (optional){skills?: boolean, half?: boolean, all?: boolean}skills fills the skill uses; half heals up to half the most HP (one above it is left as it is); all heals the whole roster.
ReturnsTypeDescription
countintegerHow many characters were healed.

See also: rq.chara.heal

Events ​

NameSummary
rq.party.on_go_homeRegisters a function that runs when the game would send a character home after a fight.

rq.party.on_go_home ​

lua
rq.party.on_go_home(fn) -> fun()

since 2.47.0

Registers a function that runs when the game would send a character home after a fight.

After each fight the game's 割り込み2/戦闘後 sends Aten home one time in five when she is in a party of two or more (her skill Go Home is only its description), and the wearer of item 209 always. The callback gets who and why, and returns another chance in percent: 0 keeps the character in the party, 100 sends them home, nil leaves it as it is. The callbacks run in the order they were added, each seeing the chance the one before it set. A return that is not a whole number from 0 to 100 is ignored, and written to the log once. An error in a callback is written to the log.

lua
rq.party.on_go_home(function(ctx)
  if ctx.reason == "aten" and rq.item.equipped(ctx.iic).item then return 0 end -- she stays
end)
ParameterTypeDescription
fnfun(ctx: rq.GoHomeCtx ): integer|nilReturns the chance, from 0 to 100, or nil.
ReturnsTypeDescription
removefun()Removes this callback.