AI script? #7
Unanswered
vjeko1701b
asked this question in
Q&A
Replies: 0 comments
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
I've been trying to get the Kaiba AI to use Shadow Spell instead of Spellbinding Circle. Since most of my hex edit efforts failed, I ran the engine trough ghidra trying to make more sense of some parts of the code.
I ran into this script which IMHO really resembles a lot of AI scripts I've seen in the past. Unfortunately, since it was decompiled from compiled engine, there's no way of knowing the original names for the variables and functions but the structure does seem like a "decision" making set of instructions under certain circumstances. Also, all the cards mentioned seem to be traps. I'm just wondering if I'm being stupid. xD
I've added my comments to the code with possible meanings.
`
bool FUN_00555e00(undefined2 *param_1,undefined4 param_2,int param_3)
{
ushort uVar1; //card identity check
int iVar2; //perhaps field state check? Number of Monsters?
byte *pbVar3;
bool bVar4; //boolean true/false check, perhaps can/can't be activated or ATK higher/lower?
FUN_00545820(*(byte )(param_1 + 1) & 1);
FUN_00545820(1 - ((byte )(param_1 + 1) & 1));
if (param_3 != 0) {
return false;
}
if ((byte *)(param_1 + 3) == ((byte)param_1[1] & 1)) {
return false;
}
if ((param_1[1] & 0xfc00) != 0x4000) {
return false;
}
uVar1 = FUN_00401a70(*param_1);
if (uVar1 < 0x421) { //if var1 less than 1057??
if (uVar1 != 0x420) { //if var1 not Mirror Force
if (0x3c0 < uVar1) { //if Negate Attack less than var1
if (uVar1 != 0x3de) { //if var1 not Magic-Arm Shield
return false; //Don't activate??? All seem to need or benefit from more than one Monster
}
if (4 < *(byte )((int)param_1 + 9)) {
return false;
}
iVar2 = FUN_00545820((byte )(param_1 + 1) & 1);
if (iVar2 == 0) {
return false;
}
iVar2 = FUN_005459a0((byte )(param_1 + 1) & 1);
if (iVar2 == 0) {
return false;
}
iVar2 = FUN_00545860(1 - ((byte *)(param_1 + 1) & 1),1,0);
return 1 < iVar2;
}
if (uVar1 == 0x3c0) { //if var1 is Negate Attack
return true; //Activate
}
if (uVar1 != 0x2ad) { //if var1 not Widespread Ruin
if (uVar1 != 0x3b1) { //if var1 not Magical Hats
return false; //Don't activate???
}
if (4 < *(byte )((int)param_1 + 9)) {
return false;
}
iVar2 = FUN_00545820((byte )(param_1 + 1) & 1);
if (iVar2 == 0) {
return false;
}
iVar2 = FUN_005459a0((byte )(param_1 + 1) & 1);
if (iVar2 < 2) {
return false;
}
iVar2 = FUN_0056e1f0((byte )(param_1 + 1) & 1,0x3b1,0);
return 1 < iVar2;
}
}
iVar2 = 0;
pbVar3 = &DAT_00a14982 + (-(uint)(ushort)param_1[1] - 1 & 1) * 0xd54;
do {
if ((((uint *)(pbVar3 + -6) & 0xfff) != 0) && ((*pbVar3 & 1) == 0)) {
return true;
}
iVar2 = iVar2 + 1;
pbVar3 = pbVar3 + 0x94;
} while (iVar2 < 10);
}
else {
if (uVar1 < 0x588) { //if var1 less than 1416
if (uVar1 == 0x587) { //if var1 is Mask of Weakness
return true; //Activate
}
if (uVar1 == 0x44a) { //if var1 is Enchanted Javelin
return true; //Activate
}
bVar4 = uVar1 == 0x4be; //bvar4(true/false) uvar1 is Magic Cylinder
}
else {
bVar4 = uVar1 == 0x590; //bvar4(true/false) and uvar1 is Fairy Box
}
if (bVar4) {
return true; //???? But these seem to benefit from high attack monsters
}
}
return false;
}
`
Beta Was this translation helpful? Give feedback.
All reactions