91
DF Modding / Re: Historical figure personality analysis science
« on: November 30, 2021, 04:25:34 pm »Are you able to actually see the code? How did you figure all this out?I identified the function for creating history_event_collection_warst (which is extremely easy to find because of runtime type information, or RTTI), and I traced that backwards to find the function used for declaring wars (or accepting/refusing peace treaties) during worldgen, then I found the function call that takes a unit_personality and an array of personality facet weights and figured out which weights were being assigned.
Of course, this was only possible because I had already located the relevant code in version 0.28.181.40d so I knew exactly what I was looking for.
The code itself is just x86 assembly language with some annotations, looking mostly like this:
Code: [Select]
1405031ea ad8 48 8d 8d b0 LEA RCX=>weights2,[RBP + 0x1b0]
01 00 00
1405031f1 ad8 e8 2a 91 f8 ff CALL init_personality_weights void init_personality_weights(in
1405031f6 ad8 b8 01 00 00 00 MOV EAX,0x1
1405031fb ad8 89 85 68 02 MOV dword ptr [RBP + weights2[46]+0x9d8],EAX
00 00
140503201 ad8 89 85 fc 01 MOV dword ptr [RBP + weights2[19]+0x9d8],EAX
00 00
140503207 ad8 89 85 04 02 MOV dword ptr [RBP + weights2[21]+0x9d8],EAX
00 00
14050320d ad8 89 85 50 02 MOV dword ptr [RBP + weights2[40]+0x9d8],EAX
00 00
140503213 ad8 4c 8b 6d f0 MOV R13,qword ptr [RBP + local_9e8+0x9d8]
140503217 ad8 49 8b 8d 30 MOV RCX,qword ptr [R13 + 0x130]
01 00 00
14050321e ad8 48 8d 95 b0 LEA RDX=>weights2,[RBP + 0x1b0]
01 00 00
140503225 ad8 48 8b 49 18 MOV RCX,qword ptr [RCX + 0x18]
140503229 ad8 e8 b2 d8 40 00 CALL unit_personality::getOverallScore int getOverallScore(unit_persona
and this:Code: [Select]
14050326e ad8 48 8d 8d b0 LEA RCX=>weights2,[RBP + 0x1b0]
01 00 00
140503275 ad8 e8 c6 90 f8 ff CALL FUN_14048c340 undefined FUN_14048c340()
14050327a ad8 b8 01 00 00 00 MOV EAX,0x1
14050327f ad8 89 85 68 02 MOV dword ptr [RBP + weights2[46]+0x9d8],EAX
00 00
140503285 ad8 89 85 fc 01 MOV dword ptr [RBP + weights2[19]+0x9d8],EAX
00 00
14050328b ad8 89 85 04 02 MOV dword ptr [RBP + weights2[21]+0x9d8],EAX
00 00
140503291 ad8 89 85 c4 01 MOV dword ptr [RBP + weights2[5]+0x9d8],EAX
00 00
140503297 ad8 49 8b 8d 30 MOV RCX,qword ptr [R13 + 0x130]
01 00 00
14050329e ad8 48 8d 95 b0 LEA RDX=>weights2,[RBP + 0x1b0]
01 00 00
1405032a5 ad8 48 8b 49 18 MOV RCX,qword ptr [RCX + 0x18]
1405032a9 ad8 e8 32 d8 40 00 CALL unit_personality::getOverallScore int getOverallScore(unit_persona
(the indices on the "weights" and "weights2" arrays identify which traits are being evaluated - the "unit_personality::getOverallScore" function is being called against historical_figure.info.personality)Also, can you figure out why the brainscan script can't find any patterns?I haven't looked at your script, so I don't know why it wouldn't have found anything.