Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sead::SafeString action::ItemAmiiboCreateFromDropTable::getOneDrop(Bdrop *dropTable, const sead::SafeString& tableName)
{
int idx = Bdrop::findTableIndex(dropTable, tableName);
bool gotCompleteArmorSetFromThisAmiibo = true;
if ( idx >= 0 )
{
auto* table = &dropTable->tables[dropTable->numTables <= idx ? 0 : idx];
gotCompleteArmorSetFromThisAmiibo = all_of(table->columns, [](auto& column) {
if (!ActorInfoData::sInstance->hasTagByName(column->itemName, Tag_AmiiboArmorItem))
return true;
isGetFlag = "IsGet_" + column->itemName;
return GameDataMgr::sInstance && GameDataMgr::sInstance->getFlagBool(isGetFlag);
});
}
for (int i = 0; i < 1000; ++i)
{
sead::SafeString drop = Bdrop::getRandomDropFromTable(dropTable, tableName);
if ( !drop )
break;
// check whether all corresponding Flags are set
// (e.g. IsGet_AncientArrow must be set for Obj_AncientArrow_A_01 to drop)
bool canDropItem = all_of(this->flagActor, [](const FlagActorPair& pair) {
if (pair.actorName != drop)
return true;
return GameDataMgr::sInstance && GameDataMgr::sInstance->getFlagBool(pair.flagName);
});
// check whether all corresponding NotFlags are unset
canDropItem &= all_of(this->notFlagActor, [](const FlagActorPair& pair) {
if (pair.actorName != drop)
return true;
return !(GameDataMgr::sInstance && GameDataMgr::sInstance->getFlagBool(pair.flagName));
});
// if the player hasn't received the complete armor set,
// do not give them armor pieces that they have already received.
if ( !gotCompleteArmorSetFromThisAmiibo &&
ActorInfoData::sInstance->hasTagByName(drop.c_str(), Tag_AmiiboArmorItem) )
{
const bool alreadyGotArmorPiece =
GameDataMgr::sInstance && GameDataMgr::sInstance->getFlagBool("IsGet_" + drop);
canDropItem = canDropItem && !alreadyGotArmorPiece;
}
if ( drop->findIndex("GameRomHorse") != -1 )
{
if ( canDropItem && !getFlag_IsAmiiboDrop_GameRomHorseItem(0) )
return drop;
}
else if ( canDropItem )
{
return drop;
}
}
if ( tableName->findIndex("GreatHit") == -1 )
return &sead::SafeStringBase<char>::cEmptyString;
// otherwise, try again with a different name
bool dummy = false;
sead::FixedSafeString<0x40> newTableName;
sub_7100B0C56C(newTableName.c_str(), 0LL, newTableName.size(), tableName.c_str(), tableName.size(), "GreatHit", "BigHit", &dummy);
return this->getOneDrop(dropTable, newTableName);
}
sead::SafeStringBase *__fastcall AI_Action_ItemAmiiboCreateFromDropTable::getOneDrop(AI_Action_ItemAmiiboCreateFromDropTable *this, Bdrop *dropTable, sead::SafeStringBase *tableName)
{
// [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND]
gdm = GameDataMgr::sInstance;
idx = Bdrop::findTableIndex(dropTable, tableName);
if ( idx & 0x80000000 )
goto LABEL_51;
tables = dropTable->tables;
numTables = dropTable->numTables;
table = &tables[idx];
if ( numTables <= idx )
table = dropTable->tables;
numColumns = (signed int)table->numColumns;
if ( (signed int)numColumns < 1 )
{
LABEL_51:
hasNoNewAmiiboArmor = 1;
}
else
{
v10 = 0LL;
v11 = idx;
v125 = (signed int)table->numColumns;
while ( 1 )
{
_table = numTables <= idx ? tables : &tables[v11];
v15 = _table->numColumns;
columns = _table->columns;
column = v15 <= v10 ? columns : &columns[v10];
actorInfoData = ActorInfoData::sInstance;
column->itemName.value.vptr->assureTermination(&column->itemName.value);
if ( ActorInfoData::hasTagByName(actorInfoData, column->itemName.value.cstr, Tag_AmiiboArmorItem) )
{
v129.vptr = &sead::SafeString::vt;
v129.cstr = "IsGet_";
isGetFlag._.cstr = (char *)&v133;
isGetFlag._.vptr = (sead::SafeStringBase::vtable *)&`vtable for'sead::BufferedSafeStringBase<char>;
isGetFlag.length = 0x80;
sead::BufferedSafeStringBase<char>::assureTerminationImpl_(&isGetFlag);
isGetFlag._.vptr = (sead::SafeStringBase::vtable *)&off_71023619F8;
v19 = isGetFlag._.cstr;
v129.vptr->assureTermination(&v129);
v20 = v129.cstr;
if...
v25 = isGetFlag._.cstr;
isGetFlag._.vptr = &sead::FixedSafeString80::vt;
sead::BufferedSafeStringBase<char>::assureTerminationImpl_(&isGetFlag);
v26 = 0LL;
v27 = isGetFlag._.cstr + 1;
while...
v29 = v26 & ~((signed int)v26 >> 0x1F);
column->itemName.value.vptr->assureTermination(&column->itemName.value);
v12 = 0LL;
v30 = (signed __int64)(column->itemName.value.cstr + 1);
while...
if...
if...
LOBYTE(v129.vptr) = 0;
if ( !gdm )
break;
TriggerParam::getBoolByKey_0(*gdm->param.param, (bool *)&v129, &isGetFlag._, gdm->param.x);
v11 = idx;
numColumns = v125;
if ( !LOBYTE(v129.vptr) )
break;
}
if ( (signed __int64)++v10 >= numColumns )
goto LABEL_51;
numTables = dropTable->numTables;
tables = dropTable->tables;
}
hasNoNewAmiiboArmor = 0;
}
j = 0;
while ( 2 )
{
drop = Bdrop::getRandomDropFromTable(dropTable, tableName);
if ( *(unsigned __int8 *)drop->cstr == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
goto LABEL_181;
v34 = 0LL;
v35 = 1;
while ( 1 )
{
_this = (AI_Action_ItemAmiiboCreateFromDropTable *)((char *)this + 0xF0 * v34);
isGetFlag._.vptr = (sead::SafeStringBase::vtable *)&`vtable for'sead::BufferedSafeStringBase<char>;
isGetFlag._.cstr = (char *)&v133;
isGetFlag.length = 0x80;
sead::BufferedSafeStringBase<char>::assureTerminationImpl_(&isGetFlag);
isGetFlag._.vptr = (sead::SafeStringBase::vtable *)&off_71023619F8;
v37 = isGetFlag._.cstr;
_this->flagActor[0].flagName.s._.vptr->assureTermination((const sead::SafeString *)_this->flagActor);
v38 = _this->flagActor[0].flagName.s._.cstr;
if ( v37 != v38 )
{
v39 = _this->flagActor[0].flagName.s._.vptr->assureTermination;
v40 = _this->flagActor;
v41 = &_this->flagActor[0].flagName.s._.cstr;
v39(&v40->flagName.s._);
v42 = 0LL;
v43 = (signed __int64)(*v41 + 1);
while...
if ( (signed int)v42 >= isGetFlag.length )
LODWORD(v42) = isGetFlag.length - 1;
v45 = (signed int)v42;
memcpy_0(v37, v38, (signed int)v42);
v37[v45] = sead::SafeStringBase<char>::cNullChar;
}
isGetFlag._.vptr = &sead::FixedSafeString80::vt;
v46 = (AI_Action_ItemAmiiboCreateFromDropTable *)((char *)this + 0xF0 * v34);
v129.cstr = (char *)&v131;
v129.vptr = (sead::SafeStringBase::vtable *)&`vtable for'sead::BufferedSafeStringBase<char>;
v130 = 0x40;
sead::BufferedSafeStringBase<char>::assureTerminationImpl_((sead::BufferedSafeString *)&v129);
v129.vptr = (sead::SafeStringBase::vtable *)&off_7102356AC0;
v47 = v129.cstr;
v46->flagActor[0].actorName.s._.vptr->assureTermination((const sead::SafeString *)&v46->flagActor[0].actorName);
v48 = v46->flagActor[0].actorName.s._.cstr;
if...
v129.vptr = &sead::FixedSafeString40::vt;
sead::BufferedSafeStringBase<char>::assureTerminationImpl_((sead::BufferedSafeString *)&v129);
v129.vptr->assureTermination(&v129);
v56 = v129.cstr;
drop->vptr->assureTermination(drop);
v57 = drop->cstr;
if ( v56 == v57 )
break;
v58 = 0LL;
v59 = (signed __int64)(v57 + 1);
do...
LABEL_91:
if ( ++v34 >= 3 )
goto LABEL_94;
}
LABEL_89:
LOBYTE(v128.vptr) = 0;
if ( gdm )
{
TriggerParam::getBoolByKey_0(*gdm->param.param, (bool *)&v128, &isGetFlag._, gdm->param.x);
v35 = (unsigned __int8)v35 & (LOBYTE(v128.vptr) != 0);
if ( !LOBYTE(v128.vptr) )
goto LABEL_94;
goto LABEL_91;
}
v35 = 0;
LABEL_94:
v63 = 0LL;
while ( 2 )
{
v64 = (AI_Action_ItemAmiiboCreateFromDropTable *)((char *)this + 0xF0 * v63);
isGetFlag._.cstr = (char *)&v133;
isGetFlag._.vptr = (sead::SafeStringBase::vtable *)&`vtable for'sead::BufferedSafeStringBase<char>;
isGetFlag.length = 0x80;
sead::BufferedSafeStringBase<char>::assureTerminationImpl_(&isGetFlag);
v65 = isGetFlag._.cstr;
isGetFlag._.vptr = (sead::SafeStringBase::vtable *)&off_71023619F8;
v64->notFlagActor[0].flagName.s._.vptr->assureTermination((const sead::SafeString *)v64->notFlagActor);
v66 = v64->notFlagActor[0].flagName.s._.cstr;
if ( v65 != v66 )
{
v67 = v64->notFlagActor[0].flagName.s._.vptr->assureTermination;
v68 = v64->notFlagActor;
v69 = &v64->notFlagActor[0].flagName.s._.cstr;
v67(&v68->flagName.s._);
v70 = 0LL;
v71 = (signed __int64)(*v69 + 1);
while ( (*v69)[v70] != sead::SafeStringBase<char>::cNullChar )
{
if ( *(unsigned __int8 *)(v71 + v70) == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
{
LODWORD(v70) = v70 + 1;
break;
}
if ( *(unsigned __int8 *)(v71 + v70 + 1) == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
{
LODWORD(v70) = v70 + 2;
break;
}
v72 = v70 + 2;
v70 += 3LL;
if ( v72 >= 0x80000 )
{
LODWORD(v70) = 0;
break;
}
}
if ( (signed int)v70 >= isGetFlag.length )
LODWORD(v70) = isGetFlag.length - 1;
v73 = (signed int)v70;
memcpy_0(v65, v66, (signed int)v70);
v65[v73] = sead::SafeStringBase<char>::cNullChar;
}
isGetFlag._.vptr = &sead::FixedSafeString80::vt;
v74 = (AI_Action_ItemAmiiboCreateFromDropTable *)((char *)this + 0xF0 * v63);
v129.vptr = (sead::SafeStringBase::vtable *)&`vtable for'sead::BufferedSafeStringBase<char>;
v129.cstr = (char *)&v131;
v130 = 0x40;
sead::BufferedSafeStringBase<char>::assureTerminationImpl_((sead::BufferedSafeString *)&v129);
v75 = v129.cstr;
v129.vptr = (sead::SafeStringBase::vtable *)&off_7102356AC0;
v74->notFlagActor[0].actorName.s._.vptr->assureTermination((const sead::SafeString *)&v74->notFlagActor[0].actorName);
v76 = v74->notFlagActor[0].actorName.s._.cstr;
if ( v75 != v76 )
{
v77 = v74->notFlagActor[0].actorName.s._.vptr->assureTermination;
v78 = &v74->notFlagActor[0].actorName;
v79 = &v74->notFlagActor[0].actorName.s._.cstr;
v77(&v78->s._);
v80 = 0LL;
v81 = (signed __int64)(*v79 + 1);
while ( (*v79)[v80] != sead::SafeStringBase<char>::cNullChar )
{
if ( *(unsigned __int8 *)(v81 + v80) == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
{
LODWORD(v80) = v80 + 1;
break;
}
if ( *(unsigned __int8 *)(v81 + v80 + 1) == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
{
LODWORD(v80) = v80 + 2;
break;
}
v82 = v80 + 2;
v80 += 3LL;
if ( v82 >= 0x80000 )
{
LODWORD(v80) = 0;
break;
}
}
if ( (signed int)v80 >= v130 )
LODWORD(v80) = v130 - 1;
v83 = (signed int)v80;
memcpy_0(v75, v76, (signed int)v80);
v75[v83] = sead::SafeStringBase<char>::cNullChar;
}
v129.vptr = &sead::FixedSafeString40::vt;
sead::BufferedSafeStringBase<char>::assureTerminationImpl_((sead::BufferedSafeString *)&v129);
v129.vptr->assureTermination(&v129);
v84 = v129.cstr;
drop->vptr->assureTermination(drop);
v85 = drop->cstr;
if ( v84 != v85 )
{
v86 = 0LL;
v87 = (signed __int64)(v85 + 1);
do
{
v88 = (unsigned __int8)v129.cstr[v86];
if ( v88 != *(unsigned __int8 *)(v87 + v86 - 1) )
break;
if ( v88 == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
goto LABEL_129;
v89 = (unsigned __int8)v129.cstr[v86 + 1];
if ( v89 != *(unsigned __int8 *)(v87 + v86) )
break;
if ( v89 == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
goto LABEL_129;
v90 = (unsigned __int8)v129.cstr[v86 + 2];
if ( v90 != *(unsigned __int8 *)(v87 + v86 + 1) )
break;
if ( v90 == (unsigned __int8)sead::SafeStringBase<char>::cNullChar )
goto LABEL_129;
v86 += 3LL;
}
while ( v86 < 0x80001 );
LABEL_131:
if ( ++v63 >= 2 )
goto LABEL_134;
continue;
}
break;
}
LABEL_129:
LOBYTE(v128.vptr) = 0;
if ( !gdm )
goto LABEL_131;
TriggerParam::getBoolByKey_0(*gdm->param.param, (bool *)&v128, &isGetFlag._, gdm->param.x);
if ( !LOBYTE(v128.vptr) )
goto LABEL_131;
v35 = 0;
LABEL_134:
if ( !hasNoNewAmiiboArmor )
{
v91 = ActorInfoData::sInstance;
drop->vptr->assureTermination(drop);
if ( ActorInfoData::hasTagByName(v91, drop->cstr, Tag_AmiiboArmorItem) )
{
v129.vptr = &sead::SafeString::vt;
v129.cstr = "IsGet_";
isGetFlag._.cstr = (char *)&v133;
isGetFlag._.vptr = (sead::SafeStringBase::vtable *)&`vtable for'sead::BufferedSafeStringBase<char>;
isGetFlag.length = 0x80;
sead::BufferedSafeStringBase<char>::assureTerminationImpl_(&isGetFlag);
v92 = isGetFlag._.cstr;
isGetFlag._.vptr = (sead::SafeStringBase::vtable *)&off_71023619F8;
v129.vptr->assureTermination(&v129);
v93 = v129.cstr;
if...
v98 = isGetFlag._.cstr;
isGetFlag._.vptr = &sead::FixedSafeString80::vt;
sead::BufferedSafeStringBase<char>::assureTerminationImpl_(&isGetFlag);
v99 = 0LL;
v100 = isGetFlag._.cstr + 1;
while...
v102 = v99 & ~((signed int)v99 >> 0x1F);
drop->vptr->assureTermination(drop);
v103 = 0LL;
v104 = (signed __int64)(drop->cstr + 1);
while...
if...
if...
LOBYTE(v129.vptr) = 0;
if ( gdm )
{
TriggerParam::getBoolByKey_0(*gdm->param.param, (bool *)&v129, &isGetFlag._, gdm->param.x);
isGetAmiiboArmor = LOBYTE(v129.vptr);
}
else
{
isGetAmiiboArmor = 0;
}
v35 = (unsigned __int8)v35 & (isGetAmiiboArmor == 0);
}
}
isGetFlag._.vptr = &sead::SafeString::vt;
isGetFlag._.cstr = "GameRomHorse";
if ( sead::SafeStringBase<char>::findIndex(drop, &isGetFlag._) != 0xFFFFFFFF )
{
if ( v35 & ~getFlag_IsAmiiboDrop_GameRomHorseItem(0) & 1 )
return drop;
LABEL_180:
if ( ++j + 1 > 999 )
{
LABEL_181:
isGetFlag._.vptr = &sead::SafeString::vt;
isGetFlag._.cstr = "GreatHit";
if ( sead::SafeStringBase<char>::findIndex(tableName, &isGetFlag._) == 0xFFFFFFFF )
return &sead::SafeStringBase<char>::cEmptyString;
isGetFlag._.vptr = (sead::SafeStringBase::vtable *)&`vtable for'sead::BufferedSafeStringBase<char>;
isGetFlag._.cstr = (char *)&v133;
isGetFlag.length = 0x40;
sead::BufferedSafeStringBase<char>::assureTerminationImpl_(&isGetFlag);
v108 = isGetFlag._.cstr;
isGetFlag._.vptr = (sead::SafeStringBase::vtable *)&off_7102356AC0;
tableName->vptr->assureTermination(tableName);
v109 = tableName->cstr;
if ( v108 != v109 )
{
tableName->vptr->assureTermination(tableName);
v110 = 0LL;
v111 = tableName->cstr + 1;
while ( tableName->cstr[v110] != sead::SafeStringBase<char>::cNullChar )
{
if ( v111[v110] == sead::SafeStringBase<char>::cNullChar )
{
LODWORD(v110) = v110 + 1;
break;
}
if ( v111[v110 + 1] == sead::SafeStringBase<char>::cNullChar )
{
LODWORD(v110) = v110 + 2;
break;
}
v112 = v110 + 2;
v110 += 3LL;
if ( v112 >= 0x80000 )
{
LODWORD(v110) = 0;
break;
}
}
if ( (signed int)v110 >= isGetFlag.length )
LODWORD(v110) = isGetFlag.length - 1;
v113 = (signed int)v110;
memcpy_0(v108, v109, (signed int)v110);
v108[v113] = sead::SafeStringBase<char>::cNullChar;
}
isGetFlag._.vptr = &sead::FixedSafeString40::vt;
v114 = isGetFlag._.cstr;
v115 = isGetFlag.length;
v129.vptr = &sead::SafeString::vt;
v129.cstr = "GreatHit";
v134 = 0;
v128.vptr = &sead::SafeString::vt;
v128.cstr = "BigHit";
sead::BufferedSafeStringBase<char>::assureTerminationImpl_(&isGetFlag);
v116 = isGetFlag._.cstr;
isGetFlag._.vptr->assureTermination((const sead::SafeString *)&isGetFlag);
v117 = 0LL;
v118 = isGetFlag._.cstr + 1;
while ( isGetFlag._.cstr[v117] != sead::SafeStringBase<char>::cNullChar )
{
if ( v118[v117] == sead::SafeStringBase<char>::cNullChar )
{
LODWORD(v117) = v117 + 1;
break;
}
if ( v118[v117 + 1] == sead::SafeStringBase<char>::cNullChar )
{
LODWORD(v117) = v117 + 2;
break;
}
v119 = v117 + 2;
v117 += 3LL;
if ( v119 >= 0x80000 )
{
LODWORD(v117) = 0;
break;
}
}
sub_7100B0C56C(v114, 0LL, v115, v116, v117, &v129, &v128, (bool *)&v134);
return AI_Action_ItemAmiiboCreateFromDropTable::getOneDrop(this, dropTable, &isGetFlag._);
}
continue;
}
break;
}
if ( !(v35 & 1) )
goto LABEL_180;
return drop;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.