Repository navigation
Blade Creation
How the game lets you resonate a Core Crystal into a Blade, as far as the matched code shows it. The draw itself, the part that decides which Blade you get, is matched: see "How the draw works". Some functions of the creation screen are not decompiled yet (last section).
Reading guide: Class::function names are the game's own (from its symbol table); path is the file in the repository; "inferred" means the repository gives a member or constant a role from the way code uses it, not from a name the game ships (see Home). Snapshot: main at commit a313ecb66.
- The creation screen is a six-page menu: driver, core crystal, boosters, confirm, creating, result.
- A booster adds idea levels to one of the four idea types of the new Blade (
GfBladeCreate::setupAddBooster). - Two pity counters (assure point, assure count) and a "rare blade appear type" live in the save data. The appear type is drawn once, from 1 to 5, when a game with no value is set up (
GfBladeManager::setupGame). - The draw (
GfBladeCreate::createBladeNewVersion) adds the crystal'sAssurePto the assure point, resets it when a rare Blade comes out, and increments the assure count when the pity fires (see "How the draw works").
File: src/application/BF2/gf/menu/object/gf_menu_obj_blade_create.cpp.
The screen has six pages, named by the layout layers in the file (unknown002[6]): LAY_dr_select, LAY_core_select, LAY_bst_select, LAY_confirm, LAY_create, LAY_result. Page flow is in GfMenuObjBladeCreate::nextPage and returnPage:
| From page | Forward (nextPage) |
Back (returnPage) |
|---|---|---|
| 0 driver | 1 | (leaves the screen) |
| 1 core crystal | 2 booster, or 3 confirm when the skip flag PageContext::unknown2c is set |
(back to driver select through the main listener) |
| 2 booster | 3 | 1 |
| 3 confirm | 4 | 2, or 1 when the booster page was skipped |
| 4 create | 5 | 3 |
| 5 result | (ends) | - |
What the pages enforce, all matched:
-
Which crystals can be chosen.
GfMenuObjBladeCreate::isValidCrystalaccepts a crystal whenGfItemUtil::isValidCrystalaccepts it.GfItemUtil::isValidCrystal(src/application/BF2/gf/util/gf_item_util.cpp) looks at theConditioncolumn of the crystal table: if the entry has a non-zero condition it must be satisfied (GfGameCond::isGameCond), otherwise the crystal is valid. In addition, one specific crystal item (constantITEM_UNKNOWN_45005) is only accepted when the selected driver id is 6. The refusal messages are chosen bygetInvalidCrystalMsgID: message id0xd4for that driver restriction,0xa9for a failed condition. -
Free blade slot. When the player confirms a crystal, the menu calls
GfBladeManager::isBindRareBladeCrystal(item). If the crystal is not bound to a specific Blade andGfDataBlade::getEnableCountForCreateBlade()returns 0, the menu plays the error sound and opens common window0xbeinstead of continuing (CrystalSelectListener::reciveEvent, event 8). A crystal is "bound" when its item type is the crystal-list type and theBladeIDcolumn of the crystal table is non-zero (isBindRareBladeCrystal). A bound crystal skips the slot check and sets the page-skip flag. Note:getEnableCountForCreateBladeitself is not decompiled yet (see below), so what exactly it counts is unknown. The wiki only knows that zero blocks creation. -
Boosters. The booster list is built from the item box entries of the booster item type (inferred role of the type), through
GfMenuItemList::setupFromBoxinCrystalSelectListener::reciveEvent. If it is empty, the page is skipped (the same skip flag is set). Each booster row belongs to one of four idea types:BoosterSelectListener::reciveEventsubtractsBdat::getIdTop(BDAT_ITM_BOOSTER_LIST)from the selected entry's value and only plays the booster effect when the result is below 4. The count selection (BoosterNumListener) offersmin(n, 5)steps, wherenis a field of the selected list entry (unknown08, role not established); the clamp is the codeif (level > 5) level = 5. The idea preview is updated byupdateIdea, which passes the chosen number as the added idea level of that booster's idea type toGfMenuReference::setDriverAddIdeaLv. -
Confirm.
ConfirmListeneropens a common text window (id0x46, or0xc4in the variantunknown11b4) and, on a yes, goes to the creation page. -
Result.
seqResultConfirm: when two internal flags of the screen (unknown11b4andunknown11bc, roles not established) are both set, it callsSCOM_PARTY_ADD::addBlade(blade, driver, 1)for the new Blade and closes the sub layer. Otherwise it opens common window 7 (a confirmation) and either goes to the Blade set screen (GfMenuObjBladeSet2) or ends. When the Blade list has no room the screen opens common window 8 (seqResultBladeFull).seqSaverequests a save intoSAVESLOT_UNKNOWN_22(the default save slot, see Save-Data). -
Presentation.
seqCreate*steps play the driver's hold animation, fade out, build the Blade, play a jingle and an event, thenseqResult*shows the Blade. Only the step list is matched (seqCreateSetup: start driver, wait 120 frames, start sound effect, wait driver, wait fade, build blade).seqCreateBuildBladeis not decompiled yet.
The four idea types are the heart of the system. Every driver (SDataDriver::m_idea, offset 0x00) and every Blade (SDataBlade::m_idea, offset 0x0c) carries an SDataIdea: four entries, each with a point total and a level (src/application/BF2/gf/data/gf_data_idea.h). The member name comes from the game's accessors DataObjDriver::getIdea() and DataObjBlade::getIdea(), which return its address.
-
Points to level.
GfDataIdea::calcLevel(point)walks levels 1 to 10 and returns the last level whose needed point value does not exceed the points; the needed points come from theNeedPointcolumn of theBLD_Ideatable throughGfBdatBlade::getBLD_IdeaNeedPoint(gf_data_idea.cpp). The maximum level is 10 (IDEA_LEVEL_UNKNOWN_10, inferred name).SDataIdea::setPointstores the points and recomputes the level. -
Which elements an idea covers.
GfDataIdea::getIdeaAttributemaps idea 0 to attribute ids 1 and 2, idea 1 to 3 and 6, idea 2 to 4 and 5, idea 3 to 7 and 8. The repository infers that the eight ids are the eight elements; the mapping itself is matched. -
Boosters.
GfBladeCreate::setupAddBooster(booster)appends the booster to a list that holds up to 128 entries, reads the booster'sIdeaandCategorycolumns (GfBdatItem::getBoosterIdea,getBoosterCategory) and sets the level of that category in the creation info tocurrent level + idea(SDataIdea::setLevel). So a booster raises one idea type by the number given in its table row. Who calls it for each booster is in the creation screen code, part of which is not decompiled yet. -
Idea levels in conditions. Game conditions can require idea levels:
GfGameCondcomparesDataIdeaAcc::getLevel(idea)of the party member with the per-idea level read byGfBdatCond::getConditionIdeaIdeaLevel(src/application/BF2/gf/game/gf_game_cond.cpp). -
Ratio helper.
DataIdeaAcc::getSubRatio(level, offset, idea)compares a required level with the current level (plus offset, clamped to 0 to 10) and returns a weight read from rows 1 to 9 ofBLD_CreateConfig, multiplied by 0.1: a difference of 5 or more uses row 9, 4 row 8, 3 row 7, 2 row 6, 1 row 5, 0 row 4, -1 row 3, -2 row 2 and anything lower row 1.DataIdeaAcc::getRatiosums the four idea weights, rounds to nearest, then picks a value from rows 10 to 14 depending on whether the rounded sum is above 0, 1, 2 or 3 (src/application/BF2/gf/data/gf_data_param_acc.cpp). The blade draw does not use these two functions (it usesBLD_IdeaProbRev), and no other matched code calls them.
Blade creation draws from the game's single shared Mersenne Twister through GfBladeManager::getRandom(max) and getRandomF1(), which simply forward to ml::mtRand(max) and ml::mtRandf2(). How that generator works, how it is seeded from the system tick, and why its outcomes cannot be steered (it is reseeded at framework start-up and burns 0 to 15 extra numbers every frame) is described in Random-Numbers.
All three values are in SDataGame (src/application/BF2/gf/data/gf_data_game.h), accessed through GfDataBladeCreate (src/application/BF2/gf/data/gf_data_blade_create.cpp). Roles are inferred by the repository from accessor names.
Offset in SDataGame
|
Accessors | What the matched code does |
|---|---|---|
0x10ad48 (u32) assure point |
getAssurePoint, addAssurePoint(amount), resetAssurePoint
|
adds with saturation at 0xffffffff; reset sets 0 |
0x10ad4c (u32) assure count |
getAssureCount, addAssureCount(amount), resetAssureCount
|
same saturating add; reset sets 0 |
0x10ad50 (u16 in the struct) rare blade appear type |
getRareBladeAppearType, setRareBladeAppearType(type)
|
the setter stores the low byte of the argument |
GfBladeManager::setupGame (src/application/BF2/gf/game/blade/gf_blade_manager.cpp) is called from GfGameManager::setupGame, which GfManager::setupDeafult and GfManager::setupContinueGame both run (see Engine-Overview):
if (GfDataBladeCreate::getRareBladeAppearType() != 0) return;
GfDataBladeCreate::setRareBladeAppearType(ml::mtRand(5) + 1); // a value from 1 to 5
GfDataBladeCreate::resetAssureCount();
So the appear type is drawn once for a game whose stored value is 0 and then stays in the save; the assure count is reset to 0 at the same moment. A loaded save that already holds a non-zero type keeps it. GfGameUtil::setupNewGameParam copies all three values from a given SDataGame (used by GfManager::setupPowerNewGame), and both save and load go through the whole SDataGame, so the three values persist.
The BLD_RareList table has five Prob columns and five Assure columns per row (GfBdatBlade::getBLD_RareListProb1..5, getBLD_RareListAssure1..5, and the indexed getBLD_RareListProb(id, index), getBLD_RareListAssure(id, index)), plus Blade and Condition. The draw indexes both with getRareBladeAppearType() - 1, so the appear type picks the column (with the off-by-one of the Assure getter table described in step 8 below).
GfBdatBlade (src/application/BF2/gf/data/gf_bdat_blade.cpp) wraps these tables (see BDAT-Data for the mechanism). Only table and column names are listed, no values.
-
BLD_IdeaTable: columnsItem,IdeaBlue,IdeaRed,IdeaWhite,IdeaBlack,Condition,BladeTable. -
BLD_BladeTable: 16 pairsCharaID1..16andCharID1..16Percent(getBladeTableCharaID(id, index)). -
BLD_BladeList:Category,StatusID. -
BLD_CommonList:QuestRace,Gender,Weapon,Atr,ModelTable,IdeaType,IdeaMin,IdeaMax,Ratio,RarityMin,RarityMax,Fskill, three arts, three skill and three field-skill achievement sets, a key achievement set,FavoriteCategoryMax,FavoriteItemMax. -
BLD_NameList:Category,Race,Gender. -
BLD_BladeModelList:QuestRace,Gender,IdeaMin,IdeaMax, two models,PartsNumMin,PartsNumMax, four parts. -
BLD_CreateConfig: a singleValuecolumn read by row (used by the ratio helper above and byGfKizunaringUtil::getCompleteKizunaringReward). -
BLD_Idea:NeedPoint,ProbRev,AtrDamRev. -
BLD_RareListandBLD_ReleaceReward(the table name is spelled this way in the game): see above, and seven reward columns. -
FLD_IdeaTable:TrustPoint,WpnRatio,NArtsProbRev,BladeChangeRev,BladeArtsRev.BladeChangeRevis read by the battle code for the blade-change cooldown (src/application/BF2/battle/utility_battle.cpp). - Shared battle tables read through
GfBdatBlade(idsBDAT_BTL_CMN_BL_CAPACITY,BDAT_BTL_CMN_BL_POWER,BDAT_BTL_CMN_BL_NEW_BL_ARTS,BDAT_BTL_CMN_BL_STATUS_TYPE,BDAT_BTL_CMN_BL_ARMOR): the accessors are named after the game'sCmnBl_Capacity,CmnBl_Power,CmnBl_NewBlArts,CmnBl_StatusTypeandCmnBl_Armorcolumn groups. Capacity has probability columns for the number and level of arts, skills, orbs and new arts plusRevcolumns; power hasMinLv,MaxLvand tenPowcolumns.
Names in the first list are the game's table names, as the accessor names in gf_bdat_blade.cpp and the project's table-id derivation show (BDAT_BLD_IDEA_TABLE for BLD_IdeaTable, and so on). From the column names a Blade seems to be built from a capacity step (how many arts, skills, orbs) and a power step (a stat curve by level), but the matched code does not apply them anywhere yet; that is an inference from names only.
Crystals and boosters come from GfBdatItem (src/application/BF2/gf/data/gf_bdat_item.cpp, ids BDAT_ITM_CRYSTAL_LIST and BDAT_ITM_BOOSTER_LIST): the crystal list has columns Condition, ValueMax and BladeID; the booster list has Category, Idea and ValueMax.
GfBladeCreateInfo / GfBladeCreate (src/application/BF2/gf/game/blade/gf_blade_create.h). The layout is now complete (size 0xa58, every member group checked by a static_assert; roles inferred): 0x00 driver, 0x04 core crystal, 0x08 list of boosters (up to 128), 0x210 idea levels added by the boosters, 0x244 flag "rare result", 0x248/0x258 two short lists (the second receives the two "silhouette" candidates shown during the animation), 0x268 onwards race, gender, weapon type, weapon, attribute and name, then a full copy of the future Blade (model, voice, arts, skills, field skills, trust quests, favourites), 0xa3a flag "result valid", 0xa3c crystal kind, 0xa40 chosen idea category, 0xa4c rare Blade of the result (non-zero means a rare Blade), 0xa50 power (0 to 15) of a generated common Blade.
Matched functions:
-
GfBladeCreate::setupDriver(driver): stores the driver. -
GfBladeCreate::setupCoreCrystal(crystal): stores the crystal ifGfItemUtil::isValidCrystalaccepts it; returns false otherwise. -
GfBladeCreate::setupAddBooster(booster): described above. -
GfBladeCreate::isEnableAddBlade(): true whenGfDataBlade::getEnableCountForCreateBlade() != 0. -
GfBladeCreate::isResultRare(): true when the rare-result flag is set or the rare Blade field is non-zero. -
GfBladeCreate::getResultBlade(SDataBlade &): false when the result is not valid, otherwise callssetupSDataBladeto fill the save-data record and returns true. -
GfBladeCreateInfo::getBladeName: picks the Blade name from the common Blade name table, or from the driver name table when the result is flagged rare, using the text ids above. -
GfBladeCreate::clear: callsGfBladeCreateInfo::clear. -
GfBladeCreateInfo::GfBladeCreateInfo()andGfBladeCreateInfo::clear(): construct and reset every member (the game has only the base-object constructor symbol, so the constructor is defined inline). -
GfBladeCreate::setupSDataBlade(SDataBlade &, const GfBladeCreateInfo &): copies the result into the save record of the new Blade.
A created Blade ends up as an SDataBlade record (see Drivers-Blades-Party and src/application/BF2/gf/data/gf_data_blade.h). Valid Blade ids run from 1001 to 1422: GfDataBlade::isValid(blade) is blade - 1001 < 422, and SDataGame holds 422 Blade records.
Status. The draw function gf::GfBladeCreate::createBladeNewVersion() (0x7100302848, 5,132 bytes) and its four local helpers are matched (byte-identical) in src/application/BF2/gf/game/blade/gf_blade_manager.cpp. Every step below is read from that code. For example, the rare attempt is if (rareProb > ml::mtRand(100) + 1), the luck factor is sqrtf(luck) * 0.01f * 1.3f + 0.95f floored at 1, and the pity threshold is assureBase + assureCount * assureStep with CreateConfig values 0x28 and 0x29.
Inputs: the driver, the core crystal, the boosters (and their idea levels). Per save: the rare Blade group (1 to 5, rolled once at new game, see Random-Numbers), the assure point counter and the assure count.
-
Crystal kind. 2 when the crystal's row in the item crystal list has a
BladeID, else 1 when it has aCommonID, else 0. A kind-2 crystal gives exactly that Blade (alias 1022 becomes 1050 when 1050 is in the party; if the Blade cannot be activated the draw stops without a result). Nothing else is rolled. -
Pity points. For kinds 0 and 1,
GfDataBladeCreate::addAssurePointadds the crystal'sAssurePvalue. - Idea category. With boosters, the category of the first booster. Without, a uniformly random one among the driver's idea categories that share the highest level.
-
Rare attempt. Only when
crystal.RareTableProb > mtRand(100) + 1, so the attempt chance is(RareTableProb − 1) / 100, one point below the table value. -
Candidates. Every
BLD_RareListrow whose Blade can be activated, whose condition passes (GfGameCond::isGameCond), that is not marked unselectable, and that is not already in the party (unless it was released). -
Independent roll per candidate.
chance% = Prob[group] × crystal.RareBladeRev × 0.01 × luckFactor, multiplied byBLD_IdeaProbRev[boosters + driver idea level] × 0.01only for Blades whose attribute matches the chosen idea.luckFactor = max(1, √luck × 0.013 + 0.95). The candidate is kept whenchance ≥ mtRandf2() × 100. - Tiebreak. Among the kept candidates: those matching the idea attribute (if any), then those with the lowest base probability, then one uniformly at random. A winner resets the pity points and becomes the result.
-
Pity, only when no rare Blade was drawn. It fires when the pity points reach
CreateConfig[0x28] + assureCount × CreateConfig[0x29]and a rare row is available whose assure column for the save's group is non-zero. It resets the points, increments the count, and picks among those rows by a roulette on their probabilities. The column lookup is off by one (matched code):_gfbdb::getBLD_RareListAssure(id, index)uses the getter table{Assure1, Assure1, Assure2, Assure3, Assure4}(src/application/BF2/gf/data/gf_bdat_blade.cpp), so groups 2 to 5 read the assure column of the group before, andAssure5is never read. The probability getter next to it uses{Prob1, ..., Prob5}. -
Common Blade when nothing rare came out (helper
0x7100304434, about 10 KB). Power 0 to 15 from theCmnBl_Powerrow of the driver level, plus the crystal'sCommonPow, plus (boosters + idea level) / 5, capped at 15. The crystal'sCommonIDfixes the common-list row; otherwise aCommonListrow is drawn, weighted byRatio, among rows whose idea mask and level range fit. Then attribute, weapon, race, gender, model, name, voice, arts, skills, field skills, trust quests and favourites, all from BDAT tables andmtRand/mtRandf2. - The two silhouettes shown during the animation are picked from a separate list of up to four candidates: one available rare Blade matching the idea, one not matching, and two freshly generated common Blades. They never roll the rare attempt of step 4 and do not affect the result.
- Finally the result is marked valid and the achievement counter
SCOM_ACHIEV_INC::createBladeCreate()is raised;getResultBlade/setupSDataBladethen build the save record.
| Function | Address | Size (bytes) | Role |
|---|---|---|---|
gf::GfDataBlade::getEnableCountForCreateBlade() |
0x71002a15d8 |
164 | the number that must be non-zero for a creation |
gf::GfMenuObjBladeCreate::CreationListener::reciveEvent |
0x71003fadec |
1824 | handler of the creation page |
gf::GfMenuObjBladeCreate::seqCreateBuildBlade() |
0x71003fc7e0 |
1192 | builds the Blade after the animation |
gf::GfMenuObjBladeCreate::initialize() |
0x71003f6e4c |
5764 | sets up the screen |
gf::SDataGame::SDataGame() |
0x7100143f28 |
4408 | default values of the save data (so the initial value of the three counters above is not shown) |
BDAT-Data, Save-Data, Engine-Overview, Drivers-Blades-Party, Menus-and-UI