wwwwwwzx

G6MemoryRNG

Jan 20th, 2018
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.79 KB | None | 0 0
  1. int __fastcall sub_469A94(__int64 a1, int a2, int a3, int a4, unsigned int NewMemory, int NewTextVar, signed int Force, int IsOT)
  2. {
  3.   signed int v8; // r9
  4.   int CurrMemory; // r8
  5.   unsigned int CurrIntensity; // r7
  6.   int NewIntensity; // r6
  7.   _DWORD *MemoryTable; // r4
  8.   unsigned int R1; // r10
  9.   unsigned int ChangePossibility; // r11
  10.   unsigned __int16 NewIntensity; // r4
  11.   int v17; // r0
  12.   char v18; // r1
  13.   signed int v19; // r2
  14.   int v20; // r0
  15.   int v21; // r1
  16.   int NewFeeling; // r7
  17.   int R2; // [sp+8h] [bp-40h]
  18.   int R3; // [sp+Ch] [bp-3Ch]
  19.   __int64 v25; // [sp+14h] [bp-34h]
  20.   int v26; // [sp+1Ch] [bp-2Ch]
  21.   int v27; // [sp+20h] [bp-28h]
  22.  
  23.   v25 = a1;
  24.   v26 = a2;
  25.   v27 = a3;
  26.   ForceChange = Force;
  27.   if ( !NewMemory || NewMemory >= 70 )
  28.     return nullsub_1(0, 0);
  29.   CurrMemory = getmemory_4D2728(a1, SHIDWORD(a1));
  30.   CurrIntensity = getmemory_4D2728(v25, a4);
  31.   NewIntensity = dword_58A134[7 * NewMemory];
  32.   MemoryTable = &dword_58A134[7 * NewMemory];
  33.   R1 = TinyMT_Global_Rand(100) + 1;
  34.   ChangePossibility = MemoryTable[1];
  35.   R2 = TinyMT_Global_Rand(256);
  36.   R3 = TinyMT_Global_Rand(256);
  37.   if ( MemoryTable[3] == 1 )
  38.   {
  39.     if ( IsOT )
  40.     {
  41.       if ( CurrMemory )
  42.       {
  43.         if ( MemoryTable[2] == 1 )
  44.           return 0;
  45.         goto LABEL_13;
  46.       }
  47.       ForceChange = 1;
  48.     }
  49.     else if ( !CurrMemory )
  50.     {
  51.       ForceChange = 1;
  52.     }
  53.   }
  54.   if ( MemoryTable[2] == 1 )
  55.     goto LABEL_29;
  56. LABEL_13:
  57.   if ( ForceChange )
  58.     goto LABEL_29;
  59.   if ( R1 > ChangePossibility )
  60.     return 0;
  61.   if ( !CurrMemory )                            // Blank Memory
  62.     goto LABEL_29;
  63.   if ( CurrIntensity >= 7 )                     // Maximum Intensity
  64.     return 0;
  65.   if ( CurrMemory == NewMemory )                // Same Memory Value
  66.     return 0;
  67.   if ( CurrIntensity > NewIntensity + 2 )       // Stronger Intensity
  68.     return 0;
  69.   if ( CurrIntensity * R2 < NewIntensity * R3 )
  70.   {
  71. LABEL_29:                                       // Set random feeling according to new memory value
  72.     v17 = 0;
  73.     v18 = 0;
  74.     v19 = 32;
  75.     do
  76.     {
  77.       if ( MemoryTable[6] & (1 << v18) )
  78.         ++v17;
  79.       --v19;
  80.       ++v18;
  81.     }
  82.     while ( v19 );
  83.     if ( v17 )
  84.     {
  85.       v20 = TinyMT_Global_Rand(v17);
  86.       v21 = 0;
  87.       NewFeeling = 0;
  88.       while ( 1 )
  89.       {
  90.         if ( MemoryTable[6] & (1 << NewFeeling) )
  91.         {
  92.           if ( v21 == v20 )
  93.           {
  94.             setmemory_3B42A0(v25, SHIDWORD(v25), NewMemory);
  95.             setmemory_3B42A0(v25, v26, NewTextVar);
  96.             setmemory_3B42A0(v25, v27, NewFeeling);
  97.             return setmemory_3B42A0(v25, a4, NewIntensity);
  98.           }
  99.           ++v21;
  100.         }
  101.         if ( ++NewFeeling >= 32 )
  102.           return nullsub_1(0, 0);
  103.       }
  104.     }
  105.     return nullsub_1(0, 0);
  106.   }
  107.   NewIntensity = CurrIntensity + 1;
  108.   if ( CurrIntensity + 1 >= 7 )
  109.     NewIntensity = 7;
  110.   return setmemory_3B42A0(v25, a4, NewIntensity);
  111. }
  112.  
  113. // Table: dword_58A134
  114. // [0] Minimum Intensity
  115. // [1] Possibility of changing memory
  116. // [2] OT flag1
  117. // [3] OT flag2
  118. // [4] ???
  119. // [5] TextVar Type(0 none, 1 location, 2 item, 3 pokemon, 4 move)
  120. // [6] Possible feeling bitflags
  121. 0, 0, 0, 0, 0x26, 0, 0  //0
  122. 1, 100, 1, 0, 0x27, 1, 0x4CBFD  //1
  123. 1, 100, 1, 0, 0x28, 1, 0x4BFD  //2
  124. 1, 100, 1, 0, 0x29, 1, 0x4CBFD  //3
  125. 1, 100, 1, 1, 0x2A, 1, 0x4CBFD  //4
  126. 2, 5, 0, 0, 0x2B, 2, 0xFFFBFB  //5
  127. 2, 5, 0, 0, 0x2C, 1, 0x84FFF9  //6
  128. 2, 5, 0, 0, 0x2D, 3, 0x47FFFF  //7
  129. 2, 5, 0, 0, 0x2E, 0, 0xBF7FFA  //8
  130. 2, 5, 0, 0, 0x2F, 3, 0x7660B0  //9
  131. 2, 5, 0, 0, 0x30, 0, 0x80BDF9  //10
  132. 2, 5, 0, 0, 0x31, 0, 0x88FB7A  //11
  133. 2, 5, 0, 0, 0x32, 4, 0x83F79  //12
  134. 2, 5, 0, 0, 0x33, 3, 0x1FE  //13
  135. 3, 10, 0, 0, 0x34, 3, 0xCFEFFF  //14
  136. 3, 20, 0, 0, 0x35, 2, 0x84EBAF  //15
  137. 3, 10, 0, 0, 0x36, 4, 0xB368B0  //16
  138. 3, 1, 0, 0, 0x37, 3, 0x91F7E  //17
  139. 4, 50, 0, 0, 0x38, 3, 0x320A0  //18
  140. 4, 30, 0, 0, 0x39, 1, 0x80DDD  //19
  141. 3, 5, 0, 0, 0x3A, 0, 0x81A7B  //20
  142. 3, 5, 0, 0, 0x3B, 3, 0x404030  //21
  143. 3, 20, 0, 0, 0x3C, 0, 0xFFFFF  //22
  144. 3, 5, 0, 0, 0x3D, 0, 0x9A08BC  //23
  145. 3, 5, 0, 0, 0x3E, 1, 0x89A7B  //24
  146. 3, 5, 0, 0, 0x3F, 3, 0x32AA  //25
  147. 3, 1, 0, 0, 0x40, 2, 0x80FF7A  //26 0x1A - Use Item
  148. 4, 50, 0, 0, 0x41, 0, 0xFFFFF  //27
  149. 5, 100, 0, 0, 0x42, 0, 0x805FD  //28
  150. 5, 50, 0, 0, 0x43, 3, 0x98278  //29 0x1D - Encounter Legends
  151. 5, 50, 0, 0, 0x44, 0, 0xB3FFF  //30
  152. 2, 2, 0, 0, 0x45, 1, 0x8BBFFA  //31
  153. 2, 2, 0, 0, 0x46, 1, 0x8BBFFE  //32
  154. 2, 5, 0, 0, 0x47, 1, 0x81A97C  //33
  155. 2, 5, 0, 0, 0x48, 2, 0x8BB97C  //34
  156. 2, 5, 0, 0, 0x49, 1, 0x8BBF7F  //35
  157. 2, 5, 0, 0, 0x4A, 1, 0x8BBF7F  //36
  158. 2, 5, 0, 0, 0x4B, 1, 0x8BBF7F  //37
  159. 2, 5, 0, 0, 0x4C, 1, 0x8BBF7F  //38
  160. 2, 2, 0, 0, 0x4D, 1, 0xAC3ABE  //39
  161. 3, 20, 0, 0, 0x4E, 2, 0xBFFFFF  //40
  162. 3, 20, 0, 0, 0x4F, 0, 0x8B837C  //41
  163. 1, 5, 0, 0, 0x50, 1, 0x848AFA  //42
  164. 3, 10, 0, 0, 0x51, 0, 0x88FFFE  //43
  165. 2, 1, 0, 0, 0x52, 3, 0x8B0B7C  //44
  166. 2, 1, 0, 0, 0x53, 3, 0xB76AB2  //45 0x2D - Run away
  167. 4, 50, 0, 0, 0x54, 0, 0x8B1FFF  //46
  168. 3, 30, 0, 0, 0x55, 0, 0xBE7AB8  //47
  169. 4, 20, 0, 0, 0x56, 4, 0xB77EB8  //48
  170. 4, 20, 0, 0, 0x57, 4, 0x8C9FFD  //49
  171. 4, 10, 0, 0, 0x58, 3, 0xBF9BFF  //50
  172. 4, 10, 0, 0, 0x59, 2, 0xF408B0  //51
  173. 2, 1, 0, 0, 0x5A, 1, 0xBCFE7A  //52
  174. 4, 10, 0, 0, 0x5B, 3, 0x8F3F72  //53
  175. 2, 1, 0, 0, 0x5C, 1, 0x90DB7A  //54
  176. 4, 50, 0, 0, 0x5D, 0, 0xBCEBFF  //55
  177. 3, 30, 0, 0, 0x5E, 0, 0xBC5838  //56
  178. 3, 30, 0, 0, 0x5F, 1, 0x9C3FFE  //57
  179. 4, 30, 0, 0, 0x60, 1, 0x9CFFFF  //58
  180. 2, 2, 0, 0, 0x61, 1, 0x96D83A  //59
  181. 3, 50, 0, 0, 0x62, 3, 0xB770B0  //60
  182. 3, 20, 0, 0, 0x63, 0, 0x881F7A  //61
  183. 3, 20, 0, 0, 0x64, 0, 0x839F7A  //62
  184. 3, 20, 0, 0, 0x65, 0, 0x839F7A  //63
  185. 3, 20, 0, 0, 0x66, 0, 0x839F7A  //64
  186. 2, 10, 0, 0, 0x67, 0, 0x53897F  //65
  187. 3, 10, 0, 0, 0x68, 0, 0x41BB6F  //66
  188. 4, 50, 0, 0, 0x69, 0, 0xC35FF  //67
  189. 4, 20, 0, 0, 0x6A, 0, 0x8BBF7F  //68 0x44 - Soaring in sky
  190. 2, 5, 0, 0, 0x6B, 0, 0x8BBF7F  //69
Add Comment
Please, Sign In to add comment