Skip to content

Ben's AI spell fixes#224

Open
Kert wants to merge 5 commits intomasterfrom
ben-ai-spell-fixes
Open

Ben's AI spell fixes#224
Kert wants to merge 5 commits intomasterfrom
ben-ai-spell-fixes

Conversation

@Kert
Copy link
Copy Markdown
Collaborator

@Kert Kert commented Dec 13, 2021

No description provided.

break;
case AI_BALL_SPALL:
this->NextPos(&hex);
if(hex > 43)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what this is for?

Copy link
Copy Markdown
Collaborator Author

@Kert Kert Dec 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for area spells: fireball, fireblast, meteorshower and coldring

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean: what's special about hex 43?

@jkoppel
Copy link
Copy Markdown
Owner

jkoppel commented Dec 14, 2021

Very good work!

With all this AI code imported, how did you test it?

What's next?

@Kert
Copy link
Copy Markdown
Collaborator Author

Kert commented Dec 15, 2021

Not sure how to test this properly
What I did is I started a bunch of battles of against AI and see if something breaks

@jkoppel
Copy link
Copy Markdown
Owner

jkoppel commented Dec 16, 2021

@gandalfgray For your original patch, how did you test it?

@gandalfgray
Copy link
Copy Markdown

gandalfgray commented Dec 16, 2021

@gandalfgray For your original patch, how did you test it?

Sometimes by printing some values to special file (during battle, for example). Sometimes just by playing. Sometimes things are obious.

|| creatureIdx == CREATURE_BONE_DRAGON) {
numDragons++;
if(stack->OtherArmyAdjacent(cr->owningSide, cr->stackIdx))
if(stack->OtherArmyAdjacent(otherSide, cr->stackIdx))
Copy link
Copy Markdown

@gandalfgray gandalfgray Dec 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, 1-owningSide и otherSide - одно и то же

int numShooters = 0;
for(int j = 0; this->numCreatures[otherSide] > j; ++j) {
if(this->creatures[owningSide][j].creature.creature_flags & SHOOTER)
if(this->creatures[otherSide][j].creature.creature_flags & SHOOTER)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, otherSide и 1-owningSide - то же самое :)

if(stack->GetAttackMask(stack->occupiedHex, 1, -1) == 255) {
int hexXCoord = stack->occupiedHex % 13;
int distFromOptimalColumn;
if(!this->currentActionSide)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь должно быть:
if(!(stack->owningSide))

case SPELL_CURSE:
aiSpellType = AI_TARGET_DAMAGE_OR_DEBUFF_SPELL;
targetSide = 1 - this->currentActionSide;
default:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a break here?

if(aiSpellType == AI_TARGET_BUFF_SPELL
|| aiSpellType == AI_TARGET_DAMAGE_OR_DEBUFF_SPELL
|| aiSpellType == AI_MASS_DEBUFF_SPELL
|| aiSpellType == AI_MASS_BUFF_SPELL
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As written, only AI_MASS_DEBUFF_SPELL will reach this line. What's with the rest of this?

break;
case AI_BALL_SPALL:
this->NextPos(&hex);
if(hex > 43)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean: what's special about hex 43?

if(this->creatures[otherSide][j].creature.creature_flags & SHOOTER)
numShooters++;
}
double shooterVal = numShooters / this->numCreatures[otherSide];
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does integer division. It will basically always be zero. Is it supposed to be this way?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fightValue multiplier is missing.

if(hasAdjacentDragons)
dragonsVal = 1.0;
else
dragonsVal = numDragons / this->numCreatures[otherSide];
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will basically always return 0. Should it be this way?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fightValue multiplier is missing, sorry.

My last comment concerned raw 211 (if(!(stack->owningSide)) instead of if(!this->currentActionSide))
After I see my comment was ignored and progress completely stopped I did not add new comments.

}
}

int combatManager::RawEffectSpellInfluence(army *stack, int eff) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument should be STACK_MODIFYING_EFFECT, not int.

dragonsVal = 1.0;
else
dragonsVal = numDragons / this->numCreatures[otherSide];
preResult = 0.28 * dragonsVal;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dragonsVal cannot be higher than 1.

Therefore preResult cannot be higher than 0.28.

preResult gets rounded to an int, i.e.: 0.

Therefore: The effect of dragon slayer is always 0 and the AI never casts it.

Is this right?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, looking at the decompiled code, this problem seems to have already been there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants