Skip to content

Field Gimmicks

Kevin Bonnoron edited this page Nov 21, 2026 · 1 revision

Field Gimmicks (gmk)

Everything that lives on the field map and reacts to the player is a gimmick: enemies that spawn and respawn, NPCs, mobs, treasure boxes, collection points, precious items, landmarks, doors, elevators, jump and warp points, salvage points, damage zones, music and sound areas, tutorials, map-jump triggers and more. This page describes the matched rules. Namespace gmk, folder src/application/BF2/gmk/ (G/ below) with the field-side code in src/application/BF2/gf/field/ (F/). Reading guide: Home. Snapshot: main at commit a313ecb66. See Event-System for cutscenes, which share the hide mechanism and start from several gimmicks.

Coverage. Most gimmick functions are matched (gmk is about 70% of its code bytes), but the code that parses a level file into instances (TGmkList<...>::createGmk, about 3,000 bytes per type, 40+ instantiations) and most spawn placement functions are not decompiled. So how a gimmick instance gets its position is not shown; the rules for when it appears and disappears mostly are. Members named unknownXX carry inferred roles.

Data model

  • One list per type. Each gimmick type has a TGmkList<T, BdatInfo, MAGIC, VERSION, GOB> (G/gmk_list.h; created in GmkSet::createGmkLists, G/gmk_manager.cpp). Instances come from a level binary gmk/<file>.lvb (loaded through CommonResource) whose header carries a 32-bit magic number and a version, both template arguments of the list: for example the landmark list uses magic 0x4b4d444c and version 2 (GmkLandmarkList, G/gmk_landmark.h). In this page the four-letter tags in parentheses after a type (KMDL, ENEM, ...) are those magic constants written as big-endian ASCII (0x4b4d444c is KMDL); they are labels for this wiki, not strings stored by name in the code. The chunk holds a transform (position, rotation, scale; 0x40 bytes), "gob info" (name, transform index, shape type) and type-specific data.
  • Shapes (inferred): point, sphere, box, capsule; the scale stores the shape size (sphere uses x, box xyz, capsule x and y).
  • Binding to BDAT. initGmkBdatInfo finds the BDAT row whose name equals the name in the level file and builds the type's BdatInfo from that row; the row index is the gimmick's BDAT id (G/gmk_list_impl.h, AGmkBase::findBdatRowIndex). The sheet for each type is named in RSC_GmkSetList (in bdat/common_gmk.bdat, see BDAT-Data) through columns named <prefix> (file) and <prefix>_bdat (sheet); the prefixes are enemy, npc, mapObj, tbox, event, fieldLock, effect, se, mob, landmark, formPc, formPcEv, collection, areaBgm, areaWeather, salvage, mapGimmick, precious, grave, kizunaTalk, jump, warp, squad, door, elevator, mapJump, fieldVolume, climbing, blade, dmgGimmick, footPrint, antiBladeArea, tutorial (G/gmk_manager.cpp). RSC_GmkSetList.mapId ties a gimmick set to a map of FLD_maplist; the column bdat names the per-map gimmick BDAT (gmk/<name>.bdat) and salvage a salvage-children level file. There are 58 gimmick types (GMK_TYPE_NUM).

Update flow

  1. GfFieldGimmick creates one GmkManager with one GmkSet (F/gf_field_gimmick.cpp).
  2. GmkManager::update first updates the common BDAT, then runs its sequence seqWaitValidateResDefBdatFp then seqUpdate. seqUpdate runs, in this order: the phantom manager, the squad manager, five active lists (TGmkActiveList: precious, SE, SE line, event, tutorial; each updates every member every frame through updateInActiveList), then every GmkSet::update.
  3. GmkSet::update updates the map BDAT and the NPC manager, then its own sequence: wait for the map id, create the map BDAT and map gimmick data, create the lists (createGmkLists), then update each list.
  4. Cost is spread over frames. A list updates updateGmkNumPerFrame instances per frame, round-robin, and passes each deltaTime * ceil(n / updateNum). Instances per frame: enemy 32, routed enemy 8, map object 8, routed map object 4, treasure box 8, event 8, battle lock 8, field lock 8, effect 8, SE 8, SE line 4, mob 8, routed mob 4, landmark 8, and 1 for the others; NPCs are updated by GmkNpcManager (32 per frame).
  5. Interest position. Distance rules use the player's position by default (the camera can be selected instead). If it does not exist, distance conditions return false.
  6. Pop wait. GfFieldGimmick::update can force an immediate update of everything and wait until every gimmick object has a valid view, with a 10.0 s timeout that forces "valid". Events use it too (startGimmickPopWait, see Event-System).
  7. A set can be created with no game entities (canCreateGameEntity() false); the world-map locator atlas uses this to read gimmick positions of other maps (GfGmkLocatorAtlas::create).

Conditions shared by gimmicks

Most rows carry some of these columns (G/gmk_cond.h, gmk_manager.cpp):

Condition Rule
ScenarioFlagCond ScenarioFlagMin <= scenario flag <= ScenarioFlagMax; enabled only when the max is non-zero. The scenario flag is the story counter (see Save-Data).
QuestFlagCond the quest's state is within [QuestFlagMin, QuestFlagMax] (columns QuestFlag, QuestFlagMin, QuestFlagMax)
DistHvCond a cylinder test on squared horizontal and vertical distance; the depop distance is forced above the pop distance (plus 1 if equal, clampDepopDist)
DistCond a sphere test on squared distance
TimeCond GfFieldTime::getTimeRangeBits() & mask (mask default 0xffff; columns TimeRange or POP_TIME)
WeatherCond GfFieldWeather::getCurrentMapWeatherBit() & bits (default 0xff; column popWeather)
CloudCond cloud sea 0 or 1 (flag popCloud)
InOutDoorCond indoor when GfGameManager::isRoom(), else outdoor
GameFlagCond a local game flag of width 1, 2, 4, 8, 16 or 32 bits equals a value
BootedGmkCond gimmickType (1 map gimmick, 2 door, 3 elevator, 4 warp, 5 jump, 6 damage gimmick) and gimmickID: true when that gimmick is solved (map gimmick) or finished (door)
generic Condition GfGameCond::isGameCond(Condition) when the column is non-zero

An enemy's pop-position water check (PopPosSafeCond) probes 10 m and has four modes: none, water, water shallower than a depth, any.

Persistent progress flags

Gimmick progress lives in the game flags (GfGameFlag::getLocal(bits, id), ids = index + base; see Save-Data):

Gimmick Base Width and meaning
treasure box 0x7c15 2 bits: 0 closed, 1 opened, 2 dug up
precious 0xb7ef 1 bit: obtained
landmark 0xc7d9 1 bit: found
map gimmick 0xab66 1 bit: solved
collection 0x715c 1 bit: waiting to respawn
salvage 0x2e1c 1 bit: accessed
door 0x94b6 2 bits: progress
tutorial 0xd392 1 bit: booted
kizuna talk index itself 2 bits: 1 available, 2 seen

The gimmick types

Enemies (GmkEnemy, GmkRoutedEnemy, G/gmk_enemy/). A placement can hold up to 4 enemy entries (ene1num to ene4num) plus Condition, POP_TIME, popWeather, popCloud, a priority, a summon-only flag (pop_smn), a squad id and scale, a formation and range, and invincibility conditions. Distances come from the placement or the map defaults (FLD_maplist: ene_disp_r/h, ene_release_r/h, e_repoptime); the depop distance is the pop radius plus a release value. Defaults when absent: radius 100, height 50, release 110 and 55; list defaults 100 / 50 / +10 / +5 with a 3 minute repop; the repop timer is e_repoptime * 60. State machine: pop/depop, then a repop counter after the last enemy dies (if not summon-only), then pop/depop again; defeated named enemies are dropped from the set. A pop also requires the object capacity for enemies not to be full, and a depop requires not being in battle. A summon-only placement can be forced up by graves and summons. Not decompiled: the whole placement (PopInfo::create/update/validatePopPos/findPopPosRot, seqUpdatePopDepop).

NPCs (GmkNpc, GmkRoutedNpc, GmkNpcManager). Columns Group, BattleReaction, and, when Group == 0, scenario, quest, time and generic conditions, plus visible and invisible distances. There is one live object per NPC id: every placement of the same character id is a candidate, candidates are sorted by BDAT id and the first whose condition matches becomes active. The NPC id space is CHR_Dr rows, then CHR_Bl, then RSC_NpcList. A pop happens in range; despawn takes 1 s of fade when the depop condition or distance matches, never while an enemy-type object is in battle or an NPC behaviour flag is set; during a screen fade-out all NPCs update at once. In battle a placement can pop only when BattleReaction != 0. Field Blades (GmkBlade) follow the same logic with BladeSizeCheck.

Mobs (GmkMob, GmkRoutedMob): crowd characters. Columns include Group (member count from FLD_NpcGroupId.memberNum), squadId, motion, collision, reaction range, percent and motion, BattleReaction, visible and invisible distances; pop info: scale range, motion speed range, mount points, MobID or MOBGroupID (up to 8 ids from FLD_MobGroupList) and PopMin / PopMax. The number of mobs is mtRand(PopMin, PopMax + 1), rolled when the group is created. A global mob-distance budget (getMobPopDistSq, reset every two full passes) adds a limit to pop distance.

Treasure boxes (GmkTbox, GfFieldTbox). Row columns: Condition, Digflg (buried box), msgVisible, msgdigVisible, RSC_ID which points at RSC_TboxList (visible_Radius, invisible_Radius, category flag TBOX_category). States: closed or opened; a buried closed box starts at alpha 0 and is targetable only until opened. The 2-bit flag above tracks closed, opened and dug. On access: a buried closed box goes to state 2 (the box appears, then a second access opens it); otherwise state 1 and no longer targetable. Boxes of the "disappearing" category fade out 5.0 s after opening. A field skill can lock a box (FSID, or FSID2 for a buried box still closed). The opening sequence waits for RSC_TboxList.FS_starttime, the field-skill check and UI, then TBOX_open_starttime, plays C_open or C_excavation and a sound, and creates a drop-item emitter whose parameters come from RSC_TboxList (baseHeight, box_distance, initWaitTime, initWaitTimeRand). A quest "gimmick" task can complete when the box drops its item (SCOM_QUEST_GIMMICK::createTresure). GfFieldTbox::seqCheckFs is not decompiled.

Collection points (GmkCollection, GfFieldCollect). Pop distance is the FLD_WildcardData row 1 (squared); an icon shows within it. Respawn takes FLD_maplist.m_repoptime * 60 after collecting (counted in seqUpdateRepopCounter) and the flag above persists it across map jumps. Collecting runs the field-skill UI, increments two stat counters, spawns a drop-item emitter, then a chain of extra emitters using FLD_WildcardData row 5 (wait time) and row 6 (distance).

Precious items (GmkPrecious). Columns itmID, Condition, QuestID, scenario and quest flags, POP_TIME, popWeather. Pop distance is FLD_WildcardData row 34 (squared). Pickup is by touch, not by interaction: updateInActiveList runs every frame, checks you are not in battle and not blocked, and tests the mover against a pickup area (radius, height above, depth below); on contact it sets the flag, adds the item (SCOM_ADD_ITEM(itmID, 1)) and shows the popup.

Landmarks (GmkLandmark, KMDL). Columns MSGID, category, cndID, noTelop, rewards getEXP, getSP, developZone, get_DPT, and MAPJUMPID. A phantom volume exists while cndID holds. On entering (when the landmark UI is allowed), beginEvent: the first time it creates an inn experience reward (SCOM_ADD_EXP::createInnExp(getEXP)), SCOM_ADD_SP(getSP), a development point reward (SCOM_ADD_DEVELOP(developZone, get_DPT), see World-Progression) and a "discover landmark" quest report; later visits report "arrive". Then a location telop (unless noTelop) and the flag. Categories: 0 landmark (stat 0x33), 1 unexplored area (0x35), 2 area (0x34), 3 field-skill landmark. Categories 0 and 1 with a MAPJUMPID register a fast-travel point.

Event, field lock, battle lock, map jump. GmkEvent (EVNT): while its condition holds a phantom exists; when the player is inside and isPlayEventOK(), it starts EventID and reports "arrive place" to quests; it re-arms when control is free again. GmkFieldLock (FDLC): a collision block exists while its combined condition holds; after the player has stayed away more than 2 s and bumps it, its message plays. GmkBattleLock (BTLC): a barrier that exists while enemies hold it (a counter above 0, set elsewhere) and isEnableCreateBattleLock(); it goes away when the counter drops to 0, except while scenario flag 7039 is active and the player is in battle. GmkMapJump (MPJP): when entered and isMapjumpOK(), starts GfPlayFactory::createMapjump(MapJumpId).

Triggers and squads. GmkTrigger (TRGR) holds index ranges into the same set's map-gimmick, enemy and routed-enemy lists: while the player is inside its phantom every linked placement is told "pop condition met", outside "not met", replacing the normal pop-distance rule (area-activated ambushes). GmkSquad (DLQS leader, BMQS member): type 1 uses authored member points, type 2 a circle; a circle member picks a random position at U(0.5, 1.0) * radius * scale and a random angle around the leader and re-rolls when it arrives.

Map gimmicks (GmkMapGimmick, GfFieldMapGimmick). Columns popTime, popWeather, Condition, nameRadius (pop radius = nameRadius + 10), mapobjID, MSG_ray. It spawns while unsolved and within range and despawns when solved. On access: OP_Condition, OP_Time, OP_weather and OP_ scenario, quest and booted conditions decide whether it can be opened (otherwise missMSG_ID shows); then a field-skill check (FSID, evaluated by GfGameUtil::evalSumFs(fsId, nameId); FSID == 0 always passes), an optional gimmick camera (gmkCamName), and up to N LOD stages (G<n>_LODmodel, G<n>_LODanime_play); when finished it sets the solved flag and reports SCOM_QUEST_GIMMICK::createMapGimmick. Jump and warp gimmicks also use FSID.

Doors and elevators. Door progress (2 bits): 0 before boot, 1 booted, 2 shut down, 3 special booted (inferred). response_type 5 is a one-way door (opens only from its front side, a dot product with the forward axis below 0); types 6 and 7 close or open when the player leaves; locked doors show missMSG_ID. Columns also cover LOD model, open/close flags, sound type/id/size, camera gimmick ids and attributes, door_nextwait. Elevators have call and lift radii, lift, shutter and switch models and sounds, lift_reverse, call_liftspeed, elevator_nextwait and two map-jump ids (liftAMapJumpId, liftBMapJumpId).

Salvage points (GmkSalvage). Up to 3 locators of type 1 (collect-type drop), 2 (treasure box), 4 (enemy) and one of type 3; pop distances FLD_WildcardData rows 30 and 58 (squared); enemies are disposed when out of the second distance and not in battle; if an enemy locator's enemy leaves, the treasure box locators are disposed. A raffle (RaffleInfo: treasure box count, button challenge point, skill point) decides the contents; the raffle functions are not decompiled.

Graves, kizuna talk. GmkGrave (VARG) shows a grave when the named enemy has been defeated (GfDataEnemy::getEnemySuppress != 0) and the player is in range; interacting force-pops the enemy again. GmkKizunaTalk (TKZK): appears within FLD_WildcardData row 30 distance when ConditionID holds (flag becomes 1); on access, if EVCondition holds it plays EventID and sets flag 2, otherwise shows the hint from FLD_KizunaTalkTitle.

Areas and effects. GmkAreaBgm: an area volume with 4 conditions A to D (RSC_BgmCondition: ConditionA..D giving BgmIDA..D); the first match, A first, wins and is pushed on a stack that drives GfFieldBgm::setGimmickBgmID. GmkAreaWeather is just a phantom. GmkSe / GmkSeLine: columns se_type, play_once, seName, volumeMAX/MIN, InRoom_volume, SEpopTime, wtrSEType. GmkEffect: a looping field effect with time, weather, indoor and cloud conditions. GmkAntiBladeArea: an area volume with column BTL_MapRevId; the most recently entered area is exposed to battle code (getBdatIdOfActiveGmkAntiBladeArea), where it triggers the per-area driver stat override (see Battle-System). GmkTutorial: a one-time tutorial trigger volume; booting sets its flag and creates the tutorial script (others with the same data name and id are marked too). GmkClimbing: an icon within climiconRadius when its conditions match.

Damage zones (GmkDmgGimmick, GmkDmgPhantomManager, GfFieldDmg). A zone (columns Condition, DEPOP_Condition, DEPOP_gimmickType/ID, DMG_interval, Pc_dmg, EN_dmg, effect and sound names) is active while Condition holds and neither depop condition holds. Every DMG_interval seconds, party members inside get field damage Pc_dmg (enemies EN_dmg) if gimmick damage is enabled. Damage formula (GfFieldDmg::calculateDamage): floor(maxHP * rate * 0.01) minus floor(damage * reduction), and the damage never kills: it is clamped to hp - 1 (GfFieldDmg::applyDamage). The ground-damage sheet FLD_DmgFloor has MAPID, Condition, attributeID, DMG_interval, Pc_dmg, EN_dmg.

Blades in the world. Free Blades appear at Blade gimmicks: reserve Blades not in the party are distributed over free Blade slots; each placement has a 0.75 chance (unknown005 = 0.75f, inferred role "prefer a rare Blade") to pick a rare Blade first, and the two special Blades of the pair count as one (GfFieldGimmick::gevMapjump, gevBladeActivate).

Formations, routes, cameras. GmkForm / GmkFormPc are party formation points (a leader and up to 5 other points, with an offset position and rotation applied to every point; an event variant exists). GmkRoute / GmkRoutePoint (VRUC / CTPT) are paths with closed, forward, reverse and stop-at-end flags, a curve radius and a width side, used by routed enemies, NPCs, mobs, map objects and footprints. GmkCamera plays a gimmick camera clip from a name (.eva), with a party-display mode; doors and map gimmicks use it. GmkAcc is a weak accessor to a gimmick by set id, type and index (or type and BDAT id), invalidated when its list is disposed.

Not decompiled yet (notable)

GmkSet::traverseGmkGameObj (1,800 bytes), GmkPhantomManager::update (460), AGmkBase::getMatrix, getPositionInShape, isInsideShape, the enemy and mob placement functions listed above, GmkNpcManager::create/addGmkNpc/isGroupCondMatched, GmkSquad::updatePosRotY (2,508), GmkSalvage::createRaffle (2,552), GmkMapGimmick::seqInit/seqUpdate/validateLodState, GmkWarp::update, GmkEffect::create/seqUpdate, GfFieldTbox::seqCheckFs (0x71002ed5a4) and every TGmkList<...>::createGmk instantiation.

See also

Event-System, World-Progression, Battle-System, BDAT-Data, Save-Data

Clone this wiki locally