Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
events.c File Reference
#include "engine/game.h"
#include "field/field_map.h"
Include dependency graph for events.c:

Go to the source code of this file.

Functions

s32 testBit (u8 *bits, s32 index, s32 set)
 Whether bit index of a bitset is set (set != 0) or clear (set 0)
 
void setBit (u8 *bits, s32 index, s32 set)
 Sets or clears bit index of a bitset.
 
s32 checkItemSet (s32 op, s32 arg)
 Special condition 0x00: the player has every item of a set (the European and Japanese versions have a second set)
 
s32 checkPartner (u32 op, s32 arg)
 Special conditions 0x10: tests partners (unlocked, in the party, levels) or unlocks one; the European and Japanese versions add four.
 
s32 checkMoney (s32 op, s32 item)
 Special conditions 0x20: whether the player has MONEY_REQUIRED[item], or gives or takes an amount.
 
s32 checkProgressRange (s32 unused, s32 index)
 Special conditions 0x30: whether GAME.progress is within PROGRESS_RANGES[index].
 
s32 checkFlagCount (s32 group, s32 mode)
 Special conditions 0x40: group 0 as in the USA version; group 1 whether four flags of group 0x10 are set.
 
s32 showActorIcon (s32 op, s32 arg)
 Special condition 0x50: the field actor's icon (FIELDSTG's task 0x16, FIELD_TASK_ICON) plays its animation 3, as event command 0x34A does.
 
s32 checkSpecialCondition (s32 id, s32 expected)
 Runs SPECIAL_CONDITIONS entry id; whether its result equals expected
 
s32 checkProgress (s32 value, s32 mode)
 Conditions 0x60: whether GAME.progress is value (mode != 0) or not.
 
s32 checkItem (s32 index, s32 mode)
 Conditions 0x80-0x8E: whether the player has item index, in the bag or equipped (mode != 0), or not.
 
s32 checkCard (s32 card, s32 have)
 Conditions 0x92: whether the player has card item (have != 0) or not.
 
s32 checkPartyStat (s32 index, s32 mode)
 Conditions 0x72: whether the party's total of battle stat 5 reaches PARTY_STAT_THRESHOLDS[index] (mode != 0) or not.
 
s32 checkWarpArg (s32 id, s32 mode)
 Conditions 0x7E: the values a warp leaves for its stage (GAME.place for ids under 30, GAME.placeArg above)
 
s32 unequipItem (s32 partner, s32 item)
 Takes item item off a partner (one of type 7 empties slots 2 and 3 both); 1 if it had it.
 
void changeItem (s32 item, s32 add)
 Actions 0x80-0x8E: gives an item (up to 99) or takes one, from the bag or else off a partner.
 
void changeCard (s32 card, s32 add)
 Actions 0x92: gives or takes a copy of a card.
 
void startCardBattle (s32 opponent, s32 kind)
 Actions 0x76 and 0x78: a card battle (MODE_CARD_GAME) against an opponent.
 
s32 checkCondition (u16 code, u16 value)
 Event scripts test conditions and run actions given as (code, value) pairs.
 
void applyAction (s32 code, s32 value)
 Actions: the same flag groups (set to value), 0x70 special actions, 0x74 an overlay hook, 0x76/0x78, 0x7A, 0x7C, 0x94 mode changes through the overlay (0x8008AEB4), 0x80-0x8E give/take an item, 0x92 a card.
 
s32 checkConditions (u16 *list)
 All the (code, value) pairs until 0xFFFF must hold.
 
void applyActions (u16 *list)
 Runs every (code, value) action until 0xFFFF.
 
void updateModeFlags (void)
 On a mode change: clears the temporary flags if asked, and sets flags 0x10-0x12 after a card battle.
 

Variables

GameFlags FLAGS_00
 The flag bitset FLAGS_00 and the event functions.
 
SpecialCondition SPECIAL_CONDITIONS []
 checkSpecialCondition's conditions, up to an id of 0xFF
 
s32 MONEY_REQUIRED []
 checkMoney's amounts, by its argument
 
s32 MONEY_GAINS []
 
s32 MONEY_LOSSES []
 
u8 PROGRESS_RANGES [][2]
 checkProgressRange's ranges of GAME.progress: { min, max }; 0x63 is past the end of the story
 
s32 PARTY_STAT_THRESHOLDS []
 checkPartyStat's thresholds
 

Function Documentation

◆ testBit()

s32 testBit ( u8 *  bits,
s32  index,
s32  set 
)

Whether bit index of a bitset is set (set != 0) or clear (set 0)

Definition at line 5 of file events.c.

Referenced by checkCondition(), and checkFlagCount().

Here is the caller graph for this function:

◆ setBit()

void setBit ( u8 *  bits,
s32  index,
s32  set 
)

Sets or clears bit index of a bitset.

Definition at line 16 of file events.c.

Referenced by applyAction().

Here is the caller graph for this function:

◆ checkItemSet()

s32 checkItemSet ( s32  op,
s32  arg 
)

Special condition 0x00: the player has every item of a set (the European and Japanese versions have a second set)

Definition at line 29 of file events.c.

Referenced by checkSpecialCondition().

Here is the caller graph for this function:

◆ checkPartner()

s32 checkPartner ( u32  op,
s32  arg 
)

Special conditions 0x10: tests partners (unlocked, in the party, levels) or unlocks one; the European and Japanese versions add four.

Definition at line 65 of file events.c.

Referenced by checkSpecialCondition().

Here is the caller graph for this function:

◆ checkMoney()

s32 checkMoney ( s32  op,
s32  item 
)

Special conditions 0x20: whether the player has MONEY_REQUIRED[item], or gives or takes an amount.

Definition at line 156 of file events.c.

Referenced by checkSpecialCondition().

Here is the caller graph for this function:

◆ checkProgressRange()

s32 checkProgressRange ( s32  unused,
s32  index 
)

Special conditions 0x30: whether GAME.progress is within PROGRESS_RANGES[index].

Definition at line 182 of file events.c.

Referenced by checkSpecialCondition().

Here is the caller graph for this function:

◆ checkFlagCount()

s32 checkFlagCount ( s32  group,
s32  mode 
)

Special conditions 0x40: group 0 as in the USA version; group 1 whether four flags of group 0x10 are set.

Definition at line 231 of file events.c.

Referenced by checkSpecialCondition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showActorIcon()

s32 showActorIcon ( s32  op,
s32  arg 
)

Special condition 0x50: the field actor's icon (FIELDSTG's task 0x16, FIELD_TASK_ICON) plays its animation 3, as event command 0x34A does.

Definition at line 277 of file events.c.

Referenced by checkSpecialCondition().

Here is the caller graph for this function:

◆ checkSpecialCondition()

s32 checkSpecialCondition ( s32  id,
s32  expected 
)

Runs SPECIAL_CONDITIONS entry id; whether its result equals expected

Definition at line 285 of file events.c.

Referenced by applyAction(), and checkCondition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkProgress()

s32 checkProgress ( s32  value,
s32  mode 
)

Conditions 0x60: whether GAME.progress is value (mode != 0) or not.

Definition at line 322 of file events.c.

Referenced by checkCondition().

Here is the caller graph for this function:

◆ checkItem()

s32 checkItem ( s32  index,
s32  mode 
)

Conditions 0x80-0x8E: whether the player has item index, in the bag or equipped (mode != 0), or not.

Definition at line 339 of file events.c.

Referenced by checkCondition().

Here is the caller graph for this function:

◆ checkCard()

s32 checkCard ( s32  card,
s32  have 
)

Conditions 0x92: whether the player has card item (have != 0) or not.

Definition at line 353 of file events.c.

Referenced by checkCondition().

Here is the caller graph for this function:

◆ checkPartyStat()

s32 checkPartyStat ( s32  index,
s32  mode 
)

Conditions 0x72: whether the party's total of battle stat 5 reaches PARTY_STAT_THRESHOLDS[index] (mode != 0) or not.

Definition at line 370 of file events.c.

Referenced by checkCondition().

Here is the caller graph for this function:

◆ checkWarpArg()

s32 checkWarpArg ( s32  id,
s32  mode 
)

Conditions 0x7E: the values a warp leaves for its stage (GAME.place for ids under 30, GAME.placeArg above)

Definition at line 397 of file events.c.

Referenced by checkCondition().

Here is the caller graph for this function:

◆ unequipItem()

s32 unequipItem ( s32  partner,
s32  item 
)

Takes item item off a partner (one of type 7 empties slots 2 and 3 both); 1 if it had it.

Definition at line 436 of file events.c.

Referenced by changeItem().

Here is the caller graph for this function:

◆ changeItem()

void changeItem ( s32  item,
s32  add 
)

Actions 0x80-0x8E: gives an item (up to 99) or takes one, from the bag or else off a partner.

Definition at line 457 of file events.c.

Referenced by applyAction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ changeCard()

void changeCard ( s32  card,
s32  add 
)

Actions 0x92: gives or takes a copy of a card.

Definition at line 485 of file events.c.

Referenced by applyAction().

Here is the caller graph for this function:

◆ startCardBattle()

void startCardBattle ( s32  opponent,
s32  kind 
)

Actions 0x76 and 0x78: a card battle (MODE_CARD_GAME) against an opponent.

< CARDGAME: a card battle

Definition at line 497 of file events.c.

Referenced by applyAction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkCondition()

s32 checkCondition ( u16  code,
u16  value 
)

Event scripts test conditions and run actions given as (code, value) pairs.

code >> 9 picks the kind, code & 0x1FF the flag or item: groups 0x00-0x40 (code >> 8 & ~1): the flag bitsets FLAGS_00 and GAME.flags02-flags40 0x60 GAME.progress, 0x70 SPECIAL_CONDITIONS, 0x72 party stat totals, 0x80-0x8E items, 0x92 cards. A condition holds when it equals value.

Definition at line 509 of file events.c.

Referenced by checkConditions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyAction()

void applyAction ( s32  code,
s32  value 
)

Actions: the same flag groups (set to value), 0x70 special actions, 0x74 an overlay hook, 0x76/0x78, 0x7A, 0x7C, 0x94 mode changes through the overlay (0x8008AEB4), 0x80-0x8E give/take an item, 0x92 a card.

< STGTRAIN

< STITSHOP

< STCRDSHP

< STGDGLAB

< STDGNAME

Definition at line 563 of file events.c.

Referenced by applyActions(), and updateModeFlags().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkConditions()

s32 checkConditions ( u16 *  list)

All the (code, value) pairs until 0xFFFF must hold.

Definition at line 652 of file events.c.

Here is the call graph for this function:

◆ applyActions()

void applyActions ( u16 *  list)

Runs every (code, value) action until 0xFFFF.

Definition at line 665 of file events.c.

Here is the call graph for this function:

◆ updateModeFlags()

void updateModeFlags ( void  )

On a mode change: clears the temporary flags if asked, and sets flags 0x10-0x12 after a card battle.

< CARDGAME: a card battle

< 0 0x00-0x40: FLAGS_00, GAME.flags02-flags40

< 0 0x00-0x40: FLAGS_00, GAME.flags02-flags40

< 0 0x00-0x40: FLAGS_00, GAME.flags02-flags40

Definition at line 678 of file events.c.

Here is the call graph for this function:

Variable Documentation

◆ FLAGS_00

GameFlags FLAGS_00
Initial value:
= {
}
void applyActions(u16 *list)
Runs every (code, value) action until 0xFFFF.
Definition events.c:665
s32 checkConditions(u16 *list)
All the (code, value) pairs until 0xFFFF must hold.
Definition events.c:652
s32 checkCondition(u16 code, u16 value)
Event scripts test conditions and run actions given as (code, value) pairs.
Definition events.c:509
void applyAction(s32 code, s32 value)
Actions: the same flag groups (set to value), 0x70 special actions, 0x74 an overlay hook,...
Definition events.c:563
void updateModeFlags(void)
On a mode change: clears the temporary flags if asked, and sets flags 0x10-0x12 after a card battle.
Definition events.c:678

The flag bitset FLAGS_00 and the event functions.

Definition at line 701 of file events.c.

Referenced by applyAction(), CARDGAME_updateBattle(), checkCondition(), createCharacters(), createCommand827(), createParty(), createTileLift(), endEvent100(), endEvent1000(), endEvent101(), endEvent1010(), endEvent1020(), endEvent1030(), endEvent1040(), endEvent1041(), endEvent1050(), endEvent1060(), endEvent1070(), endEvent1080(), endEvent1245(), endEvent1260(), endEvent1261(), endEvent1262(), endEvent1263(), endEvent1264(), endEvent1265(), endEvent1266(), endEvent1267(), endEvent1268(), endEvent1269(), endEvent1270(), endEvent1271(), endEvent1272(), endEvent1273(), endEvent1274(), endEvent1275(), endEvent1276(), endEvent1277(), endEvent1278(), endEvent1279(), endEvent1280(), endEvent1281(), endEvent1282(), endEvent1283(), endEvent1284(), endEvent1285(), endEvent1286(), endEvent1287(), endEvent1288(), endEvent1289(), endEvent1290(), endEvent1291(), endEvent1292(), endEvent1293(), endEvent1294(), endEvent1295(), endEvent1296(), endEvent1297(), endEvent1298(), endEvent1300(), endEvent1301(), endEvent1302(), endEvent1303(), endEvent1304(), endEvent1305(), endEvent1415(), endEvent1455(), endEvent1456(), endEvent1457(), endEvent1458(), endEvent1459(), endEvent1460(), endEvent1461(), endEvent1462(), endEvent1463(), endEvent1464(), endEvent150(), endEvent1530(), endEvent1600(), endEvent1608(), endEvent1612(), endEvent1646(), endEvent1648(), endEvent170(), endEvent180(), endEvent230(), endEvent250(), endEvent260(), endEvent261(), endEvent271(), endEvent272(), endEvent290(), endEvent310(), endEvent340(), endEvent350(), endEvent351(), endEvent352(), endEvent360(), endEvent370(), endEvent375(), endEvent376(), endEvent380(), endEvent390(), endEvent400(), endEvent410(), endEvent421(), endEvent422(), endEvent430(), endEvent431(), endEvent440(), endEvent450(), endEvent460(), endEvent470(), endEvent480(), endEvent490(), endEvent50(), endEvent500(), endEvent510(), endEvent511(), endEvent520(), endEvent530(), endEvent532(), endEvent540(), endEvent550(), endEvent552(), endEvent570(), endEvent571(), endEvent572(), endEvent580(), endEvent60(), endEvent61(), endEvent660(), endEvent680(), endEvent681(), endEvent682(), endEvent685(), endEvent70(), endEvent700(), endEvent71(), endEvent710(), endEvent720(), endEvent730(), endEvent735(), endEvent740(), endEvent741(), endEvent745(), endEvent750(), endEvent751(), endEvent760(), endEvent780(), endEvent781(), endEvent790(), endEvent791(), endEvent80(), endEvent800(), endEvent801(), endEvent810(), endEvent811(), endEvent830(), endEvent840(), endEvent850(), endEvent860(), endEvent870(), endEvent871(), endEvent880(), endEvent881(), endEvent882(), endEvent883(), endEvent884(), endEvent885(), endEvent890(), endEvent891(), endEvent892(), endEvent894(), endEvent900(), endEvent9000(), endEvent9001(), endEvent9002(), endEvent9003(), endEvent9004(), endEvent9005(), endEvent9006(), endEvent9007(), endEvent9008(), endEvent9009(), endEvent901(), endEvent9010(), endEvent9011(), endEvent9012(), endEvent9013(), endEvent9014(), endEvent9015(), endEvent910(), endEvent911(), endEvent920(), endEvent921(), endEvent925(), endEvent931(), endEvent932(), endEvent933(), endEvent934(), endEvent960(), endEvent970(), endEvent981(), endEvent990(), endEvents1507To1509(), FIELDSTG_controlPlayer(), FIELDSTG_createLift(), FIELDSTG_offerTrigger(), FIELDSTG_runStoryEvents(), FIELDSTG_startEventBattle5(), runTalk(), setupStage(), setUsedFlag(), startField(), STSTATUS_getVisitedAreas(), updateModeFlags(), updateStage(), and updateTimer().

◆ SPECIAL_CONDITIONS

SpecialCondition SPECIAL_CONDITIONS[]

checkSpecialCondition's conditions, up to an id of 0xFF

Definition at line 706 of file events.c.

Referenced by checkSpecialCondition().

◆ MONEY_REQUIRED

s32 MONEY_REQUIRED[]
Initial value:
= {
800, 1600, 2700, 4000, 6000, 8700, 11500, 17500, 24000, 32000,
}

checkMoney's amounts, by its argument

Definition at line 762 of file events.c.

Referenced by checkMoney().

◆ MONEY_GAINS

s32 MONEY_GAINS[]
Initial value:
= {
100, 300, 600, 1000, 1600, 3000, 5000, 8500,
}

Definition at line 765 of file events.c.

Referenced by checkMoney().

◆ MONEY_LOSSES

s32 MONEY_LOSSES[]
Initial value:
= {
800, 1600, 2700, 4000, 6000, 8700, 11500, 17500, 24000, 32000,
}

Definition at line 768 of file events.c.

Referenced by checkMoney().

◆ PROGRESS_RANGES

u8 PROGRESS_RANGES[][2]

checkProgressRange's ranges of GAME.progress: { min, max }; 0x63 is past the end of the story

Definition at line 773 of file events.c.

Referenced by checkProgressRange().

◆ PARTY_STAT_THRESHOLDS

s32 PARTY_STAT_THRESHOLDS[]
Initial value:
= {
60, 150, 210, 285, 378, 492, 630, 795, 990, 1218, 1482, 1785, 2049, 2277, 2472,
}

checkPartyStat's thresholds

Definition at line 811 of file events.c.

Referenced by checkPartyStat().