Skip to content

Instantly share code, notes, and snippets.

@esterTion esterTion/0_Arcaea_Ayu_Random_Frag Secret
Last active Jan 18, 2019

Embed
What would you like to do?
Arcaea Ayu Random Frag
shit title place holder

彩梦随机算法ida导出及美化版源码
代码版权 ©lowiro 2018

Fragments random algorithm ida export and prettified source code
Source copyright ©lowiro 2018

void CharacterAbilityModifyFragmentRNG::modifyPlayAward(PlayAward *award, GameResult *result)
{
if ( ArcUtil::calculateScore(/*score calculate parameters*/) >= 5500001 ) {
int isClearType2Or3 = 0;
if ( GameResult::getCalculatedClearType(v3) == 2 || GameResult::getCalculatedClearType(v3) == 3)
isClearType2Or3 = 1;
/*
lran48 generates int from 0 to 2^31
lran48() * 4.6566e-10 generates float from 0 to 0.99999723552768,
which is roughly 0 to 1
*/
float randomVal = (float)((float)lrand48() * 4.6566e-10);
int modifiedFrag;
if ( randomVal < 0.0000005 ) {
modifiedFrag = 9999;
} else if ( randomVal < 0.00001 ) {
modifiedFrag = 616;
} else if ( randomVal < 0.9 ) {
modifiedFrag = std::uniform_int_distribution(-10, 20);
} else {
modifiedFrag = std::uniform_int_distribution(1, 10) * 10;
}
if (isClearType2Or3 && modifiedFrag <= 0) {
modifiedFrag = std::uniform_int_distribution(1, 20);
}
award->partner = modifiedFrag;
}
}
int __fastcall CharacterAbilityModifyFragmentRNG::modifyPlayAward(int a1, int playAward, GameResult *gameResult)
{
GameResult *gameResult_; // r5
int playAward_; // r6
signed int isClearType2Or3; // r5
int clearType; // r0
double v7; // d0
int modifiedFrag; // r0
signed int modifiedFragLessThan1; // r1
int v11; // [sp+8h] [bp-18h]
int v12; // [sp+Ch] [bp-14h]
int v13; // [sp+10h] [bp-10h]
gameResult_ = gameResult;
playAward_ = playAward;
if ( ArcUtil::calculateScore(
(ArcUtil *)(*((_QWORD *)gameResult_ + 3) >> 32),
*((_QWORD *)gameResult_ + 3),
*((_QWORD *)gameResult + 2) >> 32,
*((_QWORD *)gameResult + 2),
*((_QWORD *)gameResult_ + 3) + (*((_QWORD *)gameResult_ + 3) >> 32) + (*((_QWORD *)gameResult + 2) >> 32)) >= 5500001 )
{
if ( GameResult::getCalculatedClearType(gameResult_) == 2 )
{
isClearType2Or3 = 1;
}
else
{
clearType = GameResult::getCalculatedClearType(gameResult_);
isClearType2Or3 = 0;
if ( clearType == 3 )
isClearType2Or3 = 1;
}
v7 = (float)((float)lrand48() * 4.6566e-10);
if ( v7 >= 0.0000005 )
{
if ( v7 >= 0.00001 )
{
if ( v7 >= 0.9 )
{
v11 = 1;
v12 = 10;
cocos2d::RandomHelper::getEngine((cocos2d::RandomHelper *)&byte_9[1]);
modifiedFrag = 10
* std::__ndk1::uniform_int_distribution<int>::operator()<std::__ndk1::mersenne_twister_engine<unsigned int,32u,624u,397u,31u,2567483615u,11u,4294967295u,7u,2636928640u,15u,4022730752u,18u,1812433253u>>();
}
else
{
v11 = -10;
v12 = 20;
cocos2d::RandomHelper::getEngine((cocos2d::RandomHelper *)&dword_14);
modifiedFrag = std::__ndk1::uniform_int_distribution<int>::operator()<std::__ndk1::mersenne_twister_engine<unsigned int,32u,624u,397u,31u,2567483615u,11u,4294967295u,7u,2636928640u,15u,4022730752u,18u,1812433253u>>();
}
modifiedFragLessThan1 = 0;
if ( modifiedFrag < 1 )
modifiedFragLessThan1 = 1;
if ( (modifiedFragLessThan1 & isClearType2Or3) == 1 )
{
v11 = 1;
v12 = 20;
cocos2d::RandomHelper::getEngine((cocos2d::RandomHelper *)&dword_14);
modifiedFrag = std::__ndk1::uniform_int_distribution<int>::operator()<std::__ndk1::mersenne_twister_engine<unsigned int,32u,624u,397u,31u,2567483615u,11u,4294967295u,7u,2636928640u,15u,4022730752u,18u,1812433253u>>();
}
}
else
{
modifiedFrag = 616;
}
}
else
{
modifiedFrag = 9999;
}
*(_DWORD *)(playAward_ + 16) = modifiedFrag;
}
return _stack_chk_guard - v13;
}
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.