Jump to content
Age of History
  • 0
Pnompenb

What is the AttackRange setting responsible for in units?

Question

1 answer to this question

Recommended Posts

  • 0

It affects in battle combat (src/aoc/kingdoms/lukasz/map/battles/Battle.class):

public final void updateAttack(BattleLine nAttacking, int iRoundID, int iDefense) {
    for(int i = 0; i < GameValues.battle.BATTLE_MAX_BATTLE_WIDTH; ++i) {
        if (this.firstLine.get(i) != null) {
            ((BattleRegiment)this.firstLine.get(i)).cL = 0;
        }
    }

    int generalExtraCasualties = 0;
    if (nAttacking.armyGeneral != null) {
        if (this.armyGeneral != null) {
            generalExtraCasualties = Math.max(0, nAttacking.armyGeneral.getAttack() - this.armyGeneral.getDefense() - iDefense);
        } else {
            generalExtraCasualties = Math.max(0, nAttacking.armyGeneral.getAttack() - iDefense);
        }
    }

    for(int i = 0; i < GameValues.battle.BATTLE_MAX_BATTLE_WIDTH; ++i) {
        if (nAttacking.firstLine.get(i) != null) {
            float fArmyPercLeft = (float)((BattleRegiment)nAttacking.firstLine.get(i)).aR.num / (float)((Game_Ages.Data_Ages)Game.gameAges.lAges.get(Game_Calendar.CURRENT_AGEID)).REGIMENT_SIZE;
            if (this.firstLine.get(i) != null && ((BattleRegiment)this.firstLine.get(i)).aR.num > 0) {
                BattleRegiment var13 = (BattleRegiment)this.firstLine.get(i);
                var13.cL += this.getAttackCasualties(iRoundID, generalExtraCasualties, fArmyPercLeft, (float)((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)nAttacking.firstLine.get(i)).aR.uID)).get(((BattleRegiment)nAttacking.firstLine.get(i)).aR.aID)).getAttack(((BattleRegiment)nAttacking.firstLine.get(i)).c) / (float)(((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)this.firstLine.get(i)).aR.uID)).get(((BattleRegiment)this.firstLine.get(i)).aR.aID)).getDefense(((BattleRegiment)this.firstLine.get(i)).c) + iDefense), ((BattleRegiment)nAttacking.firstLine.get(i)).c);
                this.iLastAttackRoundID = iRoundID;
            } else {
                for(int j = 1; j < ((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)nAttacking.firstLine.get(i)).aR.uID)).get(((BattleRegiment)nAttacking.firstLine.get(i)).aR.aID)).AttackRange + 1; ++j) {
                    if (i + j < GameValues.battle.BATTLE_MAX_BATTLE_WIDTH && this.firstLine.get(i + j) != null && ((BattleRegiment)this.firstLine.get(i + j)).aR.num > 0) {
                        BattleRegiment var12 = (BattleRegiment)this.firstLine.get(i + j);
                        var12.cL += this.getAttackCasualties(iRoundID, generalExtraCasualties, fArmyPercLeft, (float)((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)nAttacking.firstLine.get(i)).aR.uID)).get(((BattleRegiment)nAttacking.firstLine.get(i)).aR.aID)).getAttack(((BattleRegiment)nAttacking.firstLine.get(i)).c) / (float)(((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)this.firstLine.get(i + j)).aR.uID)).get(((BattleRegiment)this.firstLine.get(i + j)).aR.aID)).getDefense(((BattleRegiment)this.firstLine.get(i + j)).c) + iDefense), ((BattleRegiment)nAttacking.firstLine.get(i)).c);
                        this.iLastAttackRoundID = iRoundID;
                        break;
                    }

                    if (i - j >= 0 && this.firstLine.get(i - j) != null && ((BattleRegiment)this.firstLine.get(i - j)).aR.num > 0) {
                        BattleRegiment var10000 = (BattleRegiment)this.firstLine.get(i - j);
                        var10000.cL += this.getAttackCasualties(iRoundID, generalExtraCasualties, fArmyPercLeft, (float)((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)nAttacking.firstLine.get(i)).aR.uID)).get(((BattleRegiment)nAttacking.firstLine.get(i)).aR.aID)).getAttack(((BattleRegiment)nAttacking.firstLine.get(i)).c) / (float)(((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)this.firstLine.get(i - j)).aR.uID)).get(((BattleRegiment)this.firstLine.get(i - j)).aR.aID)).getDefense(((BattleRegiment)this.firstLine.get(i - j)).c) + iDefense), ((BattleRegiment)nAttacking.firstLine.get(i)).c);
                        this.iLastAttackRoundID = iRoundID;
                        break;
                    }
                }
            }
        }
    }

    for(int i = 0; i < GameValues.battle.BATTLE_MAX_BATTLE_WIDTH; ++i) {
        if (nAttacking.secondLine.get(i) != null && ((ArmyManager.Data_UnitTypes)ArmyManager.lUnitsTypes.get(((BattleRegiment)nAttacking.secondLine.get(i)).aR.uID)).Line >= 2) {
            float fArmyPercLeft = (float)((BattleRegiment)nAttacking.secondLine.get(i)).aR.num / (float)((Game_Ages.Data_Ages)Game.gameAges.lAges.get(Game_Calendar.CURRENT_AGEID)).REGIMENT_SIZE;
            if (this.firstLine.get(i) != null && ((BattleRegiment)this.firstLine.get(i)).aR.num > 0) {
                BattleRegiment var16 = (BattleRegiment)this.firstLine.get(i);
                var16.cL += this.getAttackCasualties(iRoundID, generalExtraCasualties, fArmyPercLeft, (float)((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)nAttacking.secondLine.get(i)).aR.uID)).get(((BattleRegiment)nAttacking.secondLine.get(i)).aR.aID)).getAttack(((BattleRegiment)nAttacking.secondLine.get(i)).c) / (float)(((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)this.firstLine.get(i)).aR.uID)).get(((BattleRegiment)this.firstLine.get(i)).aR.aID)).getDefense(((BattleRegiment)this.firstLine.get(i)).c) + iDefense), ((BattleRegiment)nAttacking.secondLine.get(i)).c);
                this.iLastAttackRoundID = iRoundID;
            } else {
                for(int j = 1; j < ((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)nAttacking.secondLine.get(i)).aR.uID)).get(((BattleRegiment)nAttacking.secondLine.get(i)).aR.aID)).AttackRange + 1; ++j) {
                    if (i + j < GameValues.battle.BATTLE_MAX_BATTLE_WIDTH && this.firstLine.get(i + j) != null && ((BattleRegiment)this.firstLine.get(i + j)).aR.num > 0) {
                        BattleRegiment var15 = (BattleRegiment)this.firstLine.get(i + j);
                        var15.cL += this.getAttackCasualties(iRoundID, generalExtraCasualties, fArmyPercLeft, (float)((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)nAttacking.secondLine.get(i)).aR.uID)).get(((BattleRegiment)nAttacking.secondLine.get(i)).aR.aID)).getAttack(((BattleRegiment)nAttacking.secondLine.get(i)).c) / (float)(((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)this.firstLine.get(i + j)).aR.uID)).get(((BattleRegiment)this.firstLine.get(i + j)).aR.aID)).getDefense(((BattleRegiment)this.firstLine.get(i + j)).c) + iDefense), ((BattleRegiment)nAttacking.secondLine.get(i)).c);
                        this.iLastAttackRoundID = iRoundID;
                        break;
                    }

                    if (i - j >= 0 && this.firstLine.get(i - j) != null && ((BattleRegiment)this.firstLine.get(i - j)).aR.num > 0) {
                        BattleRegiment var14 = (BattleRegiment)this.firstLine.get(i - j);
                        var14.cL += this.getAttackCasualties(iRoundID, generalExtraCasualties, fArmyPercLeft, (float)((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)nAttacking.secondLine.get(i)).aR.uID)).get(((BattleRegiment)nAttacking.secondLine.get(i)).aR.aID)).getAttack(((BattleRegiment)nAttacking.secondLine.get(i)).c) / (float)(((ArmyManager.Data_Army)((ArrayList)ArmyManager.lArmy.get(((BattleRegiment)this.firstLine.get(i - j)).aR.uID)).get(((BattleRegiment)this.firstLine.get(i - j)).aR.aID)).getDefense(((BattleRegiment)this.firstLine.get(i - j)).c) + iDefense), ((BattleRegiment)nAttacking.secondLine.get(i)).c);
                        this.iLastAttackRoundID = iRoundID;
                        break;
                    }
                }
            }
        }
    }

}

Here, .aR is the abbreviation for AttackRange, and this is precisely what it does. The actual code is quite verbose, but the TLDR is that it looks in all directions up to AttackRange (radiating outwards), and inflicts damage this way. More surprising is that it doesn't appear to just affect backline/frontline combat (it iterates left and right with i + j and i - j), but also flanking units; though I could be wrong on this one.

AttackRange does not determine Province AttackRange, only in-province battles.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Age of History Games