diff --git a/core/assets/abilityBehaviors/humanHeroActives.json b/core/assets/abilityBehaviors/humanHeroActives.json index 8b1fe60e..5e6411cb 100644 --- a/core/assets/abilityBehaviors/humanHeroActives.json +++ b/core/assets/abilityBehaviors/humanHeroActives.json @@ -269,7 +269,7 @@ } } },{ - "type": "iterateUnitsInRangeOfLocation", + "type": "iterateUnitsInRangeOfLocationMatchingCondition", "location": { "type": "getStoredLocationByKey", "key": { @@ -280,6 +280,12 @@ "range": { "type": "getAbilityArea" }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + }, "iterationActions": [{ "type": "createTimedArtBuff", "buffId": { @@ -458,7 +464,7 @@ } } },{ - "type": "iterateUnitsInRangeOfLocation", + "type": "iterateUnitsInRangeOfLocationMatchingCondition", "location": { "type": "getStoredLocationByKey", "key": { @@ -469,6 +475,12 @@ "range": { "type": "getAbilityArea" }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + }, "iterationActions": [{ "type": "createTimedArtBuff", "buffId": { diff --git a/core/assets/abilityBehaviors/nightElfUnitActives.json b/core/assets/abilityBehaviors/nightElfUnitActives.json index ffd85719..137e6c1b 100644 --- a/core/assets/abilityBehaviors/nightElfUnitActives.json +++ b/core/assets/abilityBehaviors/nightElfUnitActives.json @@ -133,7 +133,13 @@ }, "effectType": "CASTER" },{ - "type": "iterateUnitsInRangeOfUnit", + "type": "iterateUnitsInRangeOfUnitMatchingCondition", + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + }, "iterationActions": [{ "type": "createTimedBuff", "buffId": { @@ -752,7 +758,13 @@ } }, "thenActions": [{ - "type": "iterateUnitsInRangeOfUnit", + "type": "iterateUnitsInRangeOfUnitMatchingCondition", + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + }, "iterationActions": [{ "type": "if", "condition": { diff --git a/core/assets/abilityBehaviors/undeadUnitActives.json b/core/assets/abilityBehaviors/undeadUnitActives.json index 7955f2ea..4675c2ef 100644 --- a/core/assets/abilityBehaviors/undeadUnitActives.json +++ b/core/assets/abilityBehaviors/undeadUnitActives.json @@ -372,12 +372,21 @@ "type": "getAbilityArea" }, "condition": { - "type": "not", - "condition": { - "type": "isUnitMaxHp", - "unit": { + "type": "and", + "condition1": { + "type": "isUnitValidTarget", + "target": { "type": "getMatchingUnit" } + }, + "condition2": { + "type": "not", + "condition": { + "type": "isUnitMaxHp", + "unit": { + "type": "getMatchingUnit" + } + } } }, "iterationActions": [{ @@ -572,12 +581,21 @@ "type": "getAbilityArea" }, "condition": { - "type": "not", - "condition": { - "type": "isUnitMaxMp", - "unit": { + "type": "and", + "condition1": { + "type": "isUnitValidTarget", + "target": { "type": "getMatchingUnit" } + }, + "condition2": { + "type": "not", + "condition": { + "type": "isUnitMaxMp", + "unit": { + "type": "getMatchingUnit" + } + } } }, "iterationActions": [{ diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnit.java index 3c1d78dd..f73bd78d 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnit.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnit.java @@ -1263,6 +1263,16 @@ private void computeAllDerivedFields() { computeDerivedFields(NonStackingStatBuffType.DEF); computeDerivedFields(NonStackingStatBuffType.HPGEN); computeDerivedFields(NonStackingStatBuffType.MPGEN); + if (this.getUnitSpecificAttacks() != null) { + computeDerivedFields(NonStackingStatBuffType.ALLATK); + computeDerivedFields(NonStackingStatBuffType.ATKSPD); + } + computeDerivedFields(NonStackingStatBuffType.HPSTEAL); + computeDerivedFields(NonStackingStatBuffType.MVSPD); + computeDerivedFields(NonStackingStatBuffType.THORNS); + computeDerivedFields(NonStackingStatBuffType.THORNSPCT); + computeDerivedFields(NonStackingStatBuffType.MAXHP); + computeDerivedFields(NonStackingStatBuffType.MAXMP); } private void computeAllUnitStates(CSimulation game) { @@ -1488,7 +1498,7 @@ public void setTypeId(final CSimulation game, final War3ID typeId, boolean updat final List persistedAbilities = new ArrayList<>(); final List removedAbilities = new ArrayList<>(); for (final CAbility ability : this.abilities) { - if (!ability.isPermanent() && !sharedAbilities.contains(ability.getAlias())) { + if (!ability.isPermanent() && !sharedAbilities.contains(ability.getAlias()) && !(ability.getAbilityCategory() == CAbilityCategory.BUFF)) { ability.onRemove(game, this); game.onAbilityRemovedFromUnit(this, ability); removedAbilities.add(ability); @@ -1507,12 +1517,12 @@ public void setTypeId(final CSimulation game, final War3ID typeId, boolean updat } else { this.mana = manaRatio * this.maximumMana; } - computeAllDerivedFields(); game.getWorldCollision().addUnit(this); for (final CAbility ability : persistedAbilities) { ability.onSetUnitType(game, this); game.onAbilityAddedToUnit(this, ability); } + computeAllDerivedFields(); this.computeAllUnitStates(game); } @@ -4418,10 +4428,10 @@ public void updateFogOfWar(final CSimulation game) { if (sightRadius > 0) { final float radSq = sightRadius * sightRadius / (CPlayerFogOfWar.GRID_STEP * CPlayerFogOfWar.GRID_STEP); final CPlayerFogOfWar fogOfWar = game.getPlayer(this.playerIndex).getFogOfWar(); + final boolean flying = this.getUnitType().getMovementType() == MovementType.FLY; final float myX = getX(); final float myY = getY(); - final int myZ = this.getUnitType().getMovementType() == MovementType.FLY ? Integer.MAX_VALUE - : game.getTerrainHeight(myX, myY); + final int myZ = flying ? Integer.MAX_VALUE : game.getTerrainHeight(myX, myY); final PathingGrid pathingGrid = game.getPathingGrid(); fogOfWar.setState(pathingGrid.getFogOfWarIndexX(myX), pathingGrid.getFogOfWarIndexY(myY), (byte) 0); @@ -4432,33 +4442,33 @@ public void updateFogOfWar(final CSimulation game) { for (int a = 1; a <= Math.max(maxYi - myYi, maxXi - myXi); a++) { int distance = a * a; - if (distance <= radSq && !pathingGrid.isBlockVision(myX, myY - (a - 1) * CPlayerFogOfWar.GRID_STEP) + if (distance <= radSq && (flying || !pathingGrid.isBlockVision(myX, myY - (a - 1) * CPlayerFogOfWar.GRID_STEP)) && fogOfWar.getState(myXi, myYi - a + 1) == 0 - && (game.isTerrainWater(myX, myY - a * CPlayerFogOfWar.GRID_STEP) + && (flying || game.isTerrainWater(myX, myY - a * CPlayerFogOfWar.GRID_STEP) || myZ > game.getTerrainHeight(myX, myY - a * CPlayerFogOfWar.GRID_STEP) || (!game.isTerrainRomp(myX, myY - a * CPlayerFogOfWar.GRID_STEP) && myZ == game .getTerrainHeight(myX, myY - a * CPlayerFogOfWar.GRID_STEP)))) { fogOfWar.setState(myXi, myYi - a, (byte) 0); } - if (distance <= radSq && !pathingGrid.isBlockVision(myX, myY + (a - 1) * CPlayerFogOfWar.GRID_STEP) + if (distance <= radSq && (flying || !pathingGrid.isBlockVision(myX, myY + (a - 1) * CPlayerFogOfWar.GRID_STEP)) && fogOfWar.getState(myXi, myYi + a - 1) == 0 - && (game.isTerrainWater(myX, myY + a * CPlayerFogOfWar.GRID_STEP) + && (flying || game.isTerrainWater(myX, myY + a * CPlayerFogOfWar.GRID_STEP) || myZ > game.getTerrainHeight(myX, myY + a * CPlayerFogOfWar.GRID_STEP) || (!game.isTerrainRomp(myX, myY + a * CPlayerFogOfWar.GRID_STEP) && myZ == game .getTerrainHeight(myX, myY + a * CPlayerFogOfWar.GRID_STEP)))) { fogOfWar.setState(myXi, myYi + a, (byte) 0); } - if (distance <= radSq && !pathingGrid.isBlockVision(myX - (a - 1) * CPlayerFogOfWar.GRID_STEP, myY) + if (distance <= radSq && (flying || !pathingGrid.isBlockVision(myX - (a - 1) * CPlayerFogOfWar.GRID_STEP, myY)) && fogOfWar.getState(myXi - a + 1, myYi) == 0 - && (game.isTerrainWater(myX - a * CPlayerFogOfWar.GRID_STEP, myY) + && (flying || game.isTerrainWater(myX - a * CPlayerFogOfWar.GRID_STEP, myY) || myZ > game.getTerrainHeight(myX - a * CPlayerFogOfWar.GRID_STEP, myY) || (!game.isTerrainRomp(myX - a * CPlayerFogOfWar.GRID_STEP, myY) && myZ == game .getTerrainHeight(myX - a * CPlayerFogOfWar.GRID_STEP, myY)))) { fogOfWar.setState(myXi - a, myYi, (byte) 0); } - if (distance <= radSq && !pathingGrid.isBlockVision(myX + (a - 1) * CPlayerFogOfWar.GRID_STEP, myY) + if (distance <= radSq && (flying || !pathingGrid.isBlockVision(myX + (a - 1) * CPlayerFogOfWar.GRID_STEP, myY)) && fogOfWar.getState(myXi + a - 1, myYi) == 0 - && (game.isTerrainWater(myX + a * CPlayerFogOfWar.GRID_STEP, myY) + && (flying || game.isTerrainWater(myX + a * CPlayerFogOfWar.GRID_STEP, myY) || myZ > game.getTerrainHeight(myX + a * CPlayerFogOfWar.GRID_STEP, myY) || (!game.isTerrainRomp(myX + a * CPlayerFogOfWar.GRID_STEP, myY) && myZ == game .getTerrainHeight(myX + a * CPlayerFogOfWar.GRID_STEP, myY)))) { @@ -4473,11 +4483,11 @@ public void updateFogOfWar(final CSimulation game) { int xf = x * CPlayerFogOfWar.GRID_STEP; int yf = y * CPlayerFogOfWar.GRID_STEP; - if ((game.isTerrainWater(myX - xf, myY - yf) + if ((flying || game.isTerrainWater(myX - xf, myY - yf) || myZ > game.getTerrainHeight(myX - xf, myY - yf) || (!game.isTerrainRomp(myX - xf, myY - yf) && myZ == game.getTerrainHeight(myX - xf, myY - yf))) - && !pathingGrid.isBlockVision(myX - xf, myY - yf) + && (flying || !pathingGrid.isBlockVision(myX - xf, myY - yf)) && fogOfWar.getState(myXi - x + 1, myYi - y + 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi - x + 1, myYi - y) == 0 @@ -4486,11 +4496,11 @@ public void updateFogOfWar(final CSimulation game) { && !pathingGrid.isBlockVision(myXi - x, myYi - y + 1)))) { fogOfWar.setState(myXi - x, myYi - y, (byte) 0); } - if ((game.isTerrainWater(myX - xf, myY + yf) + if ((flying || game.isTerrainWater(myX - xf, myY + yf) || myZ > game.getTerrainHeight(myX - xf, myY + yf) || (!game.isTerrainRomp(myX - xf, myY + yf) && myZ == game.getTerrainHeight(myX - xf, myY + yf))) - && !pathingGrid.isBlockVision(myX - xf, myY + yf) + && (flying || !pathingGrid.isBlockVision(myX - xf, myY + yf)) && fogOfWar.getState(myXi - x + 1, myYi + y - 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi - x + 1, myYi + y) == 0 @@ -4499,11 +4509,11 @@ public void updateFogOfWar(final CSimulation game) { && !pathingGrid.isBlockVision(myXi - x, myYi + y - 1)))) { fogOfWar.setState(myXi - x, myYi + y, (byte) 0); } - if ((game.isTerrainWater(myX + xf, myY - yf) + if ((flying || game.isTerrainWater(myX + xf, myY - yf) || myZ > game.getTerrainHeight(myX + xf, myY - yf) || (!game.isTerrainRomp(myX + xf, myY - yf) && myZ == game.getTerrainHeight(myX + xf, myY - yf))) - && !pathingGrid.isBlockVision(myX + xf, myY - yf) + && (flying || !pathingGrid.isBlockVision(myX + xf, myY - yf)) && fogOfWar.getState(myXi + x - 1, myYi - y + 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi + x - 1, myYi - y) == 0 @@ -4512,11 +4522,11 @@ public void updateFogOfWar(final CSimulation game) { && !pathingGrid.isBlockVision(myXi + x, myYi - y + 1)))) { fogOfWar.setState(myXi + x, myYi - y, (byte) 0); } - if ((game.isTerrainWater(myX + xf, myY + yf) + if ((flying || game.isTerrainWater(myX + xf, myY + yf) || myZ > game.getTerrainHeight(myX + xf, myY + yf) || (!game.isTerrainRomp(myX + xf, myY + yf) && myZ == game.getTerrainHeight(myX + xf, myY + yf))) - && !pathingGrid.isBlockVision(myX + xf, myY + yf) + && (flying || !pathingGrid.isBlockVision(myX + xf, myY + yf)) && fogOfWar.getState(myXi + x - 1, myYi + y - 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi + x - 1, myYi + y) == 0 diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CUnitAttackVisionFogModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CUnitAttackVisionFogModifier.java index 83a39e54..675cdabc 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CUnitAttackVisionFogModifier.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CUnitAttackVisionFogModifier.java @@ -27,10 +27,10 @@ public void setPlayerIndex(int playerIndex) { public void update(final CSimulation game, final CPlayer player, final PathingGrid pathingGrid, final CPlayerFogOfWar fogOfWar) { if (!this.unit.isDead() && !this.unit.isHidden() && ATTACKING_UNIT_VISION_RADIUS > 0) { + final boolean flying = this.unit.getUnitType().getMovementType() == MovementType.FLY; final float myX = this.unit.getX(); final float myY = this.unit.getY(); - final int myZ = this.unit.getUnitType().getMovementType() == MovementType.FLY ? Integer.MAX_VALUE - : game.getTerrainHeight(myX, myY); + final int myZ = flying ? Integer.MAX_VALUE : game.getTerrainHeight(myX, myY); fogOfWar.setState(game.getPathingGrid().getFogOfWarIndexX(myX), game.getPathingGrid().getFogOfWarIndexY(myY), (byte) 0); @@ -42,36 +42,36 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr int distance = a * a; if (distance <= ATTACKING_UNIT_VISION_RADIUS_SQ - && !pathingGrid.isBlockVision(myX, myY - (a - 1) * CPlayerFogOfWar.GRID_STEP) + && (flying || !pathingGrid.isBlockVision(myX, myY - (a - 1) * CPlayerFogOfWar.GRID_STEP)) && fogOfWar.getState(myXi, myYi - a + 1) == 0 - && (game.isTerrainWater(myX, myY - a * CPlayerFogOfWar.GRID_STEP) + && (flying || game.isTerrainWater(myX, myY - a * CPlayerFogOfWar.GRID_STEP) || myZ > game.getTerrainHeight(myX, myY - a * CPlayerFogOfWar.GRID_STEP) || (!game.isTerrainRomp(myX, myY - a * CPlayerFogOfWar.GRID_STEP) && myZ == game.getTerrainHeight(myX, myY - a * CPlayerFogOfWar.GRID_STEP)))) { fogOfWar.setState(myXi, myYi - a, (byte) 0); } if (distance <= ATTACKING_UNIT_VISION_RADIUS_SQ - && !pathingGrid.isBlockVision(myX, myY + (a - 1) * CPlayerFogOfWar.GRID_STEP) + && (flying || !pathingGrid.isBlockVision(myX, myY + (a - 1) * CPlayerFogOfWar.GRID_STEP)) && fogOfWar.getState(myXi, myYi + a - 1) == 0 - && (game.isTerrainWater(myX, myY + a * CPlayerFogOfWar.GRID_STEP) + && (flying || game.isTerrainWater(myX, myY + a * CPlayerFogOfWar.GRID_STEP) || myZ > game.getTerrainHeight(myX, myY + a * CPlayerFogOfWar.GRID_STEP) || (!game.isTerrainRomp(myX, myY + a * CPlayerFogOfWar.GRID_STEP) && myZ == game.getTerrainHeight(myX, myY + a * CPlayerFogOfWar.GRID_STEP)))) { fogOfWar.setState(myXi, myYi + a, (byte) 0); } if (distance <= ATTACKING_UNIT_VISION_RADIUS_SQ - && !pathingGrid.isBlockVision(myX - (a - 1) * CPlayerFogOfWar.GRID_STEP, myY) + && (flying || !pathingGrid.isBlockVision(myX - (a - 1) * CPlayerFogOfWar.GRID_STEP, myY)) && fogOfWar.getState(myXi - a + 1, myYi) == 0 - && (game.isTerrainWater(myX - a * CPlayerFogOfWar.GRID_STEP, myY) + && (flying || game.isTerrainWater(myX - a * CPlayerFogOfWar.GRID_STEP, myY) || myZ > game.getTerrainHeight(myX - a * CPlayerFogOfWar.GRID_STEP, myY) || (!game.isTerrainRomp(myX - a * CPlayerFogOfWar.GRID_STEP, myY) && myZ == game.getTerrainHeight(myX - a * CPlayerFogOfWar.GRID_STEP, myY)))) { fogOfWar.setState(myXi - a, myYi, (byte) 0); } if (distance <= ATTACKING_UNIT_VISION_RADIUS_SQ - && !pathingGrid.isBlockVision(myX + (a - 1) * CPlayerFogOfWar.GRID_STEP, myY) + && (flying || !pathingGrid.isBlockVision(myX + (a - 1) * CPlayerFogOfWar.GRID_STEP, myY)) && fogOfWar.getState(myXi + a - 1, myYi) == 0 - && (game.isTerrainWater(myX + a * CPlayerFogOfWar.GRID_STEP, myY) + && (flying || game.isTerrainWater(myX + a * CPlayerFogOfWar.GRID_STEP, myY) || myZ > game.getTerrainHeight(myX + a * CPlayerFogOfWar.GRID_STEP, myY) || (!game.isTerrainRomp(myX + a * CPlayerFogOfWar.GRID_STEP, myY) && myZ == game.getTerrainHeight(myX + a * CPlayerFogOfWar.GRID_STEP, myY)))) { @@ -86,10 +86,11 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr int xf = x * CPlayerFogOfWar.GRID_STEP; int yf = y * CPlayerFogOfWar.GRID_STEP; - if ((game.isTerrainWater(myX - xf, myY - yf) || myZ > game.getTerrainHeight(myX - xf, myY - yf) + if ((flying || game.isTerrainWater(myX - xf, myY - yf) + || myZ > game.getTerrainHeight(myX - xf, myY - yf) || (!game.isTerrainRomp(myX - xf, myY - yf) && myZ == game.getTerrainHeight(myX - xf, myY - yf))) - && !pathingGrid.isBlockVision(myX - xf, myY - yf) + && (flying || !pathingGrid.isBlockVision(myX - xf, myY - yf)) && fogOfWar.getState(myXi - x + 1, myYi - y + 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi - x + 1, myYi - y) == 0 @@ -98,10 +99,11 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr && !pathingGrid.isBlockVision(myXi - x, myYi - y + 1)))) { fogOfWar.setState(myXi - x, myYi - y, (byte) 0); } - if ((game.isTerrainWater(myX - xf, myY + yf) || myZ > game.getTerrainHeight(myX - xf, myY + yf) + if ((flying || game.isTerrainWater(myX - xf, myY + yf) + || myZ > game.getTerrainHeight(myX - xf, myY + yf) || (!game.isTerrainRomp(myX - xf, myY + yf) && myZ == game.getTerrainHeight(myX - xf, myY + yf))) - && !pathingGrid.isBlockVision(myX - xf, myY + yf) + && (flying || !pathingGrid.isBlockVision(myX - xf, myY + yf)) && fogOfWar.getState(myXi - x + 1, myYi + y - 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi - x + 1, myYi + y) == 0 @@ -110,10 +112,11 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr && !pathingGrid.isBlockVision(myXi - x, myYi + y - 1)))) { fogOfWar.setState(myXi - x, myYi + y, (byte) 0); } - if ((game.isTerrainWater(myX + xf, myY - yf) || myZ > game.getTerrainHeight(myX + xf, myY - yf) + if ((flying || game.isTerrainWater(myX + xf, myY - yf) + || myZ > game.getTerrainHeight(myX + xf, myY - yf) || (!game.isTerrainRomp(myX + xf, myY - yf) && myZ == game.getTerrainHeight(myX + xf, myY - yf))) - && !pathingGrid.isBlockVision(myX + xf, myY - yf) + && (flying || !pathingGrid.isBlockVision(myX + xf, myY - yf)) && fogOfWar.getState(myXi + x - 1, myYi - y + 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi + x - 1, myYi - y) == 0 @@ -122,10 +125,11 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr && !pathingGrid.isBlockVision(myXi + x, myYi - y + 1)))) { fogOfWar.setState(myXi + x, myYi - y, (byte) 0); } - if ((game.isTerrainWater(myX + xf, myY + yf) || myZ > game.getTerrainHeight(myX + xf, myY + yf) + if ((flying || game.isTerrainWater(myX + xf, myY + yf) + || myZ > game.getTerrainHeight(myX + xf, myY + yf) || (!game.isTerrainRomp(myX + xf, myY + yf) && myZ == game.getTerrainHeight(myX + xf, myY + yf))) - && !pathingGrid.isBlockVision(myX + xf, myY + yf) + && (flying || !pathingGrid.isBlockVision(myX + xf, myY + yf)) && fogOfWar.getState(myXi + x - 1, myYi + y - 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi + x - 1, myYi + y) == 0 diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CUnitDeathVisionFogModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CUnitDeathVisionFogModifier.java index d53b4010..81efe46e 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CUnitDeathVisionFogModifier.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CUnitDeathVisionFogModifier.java @@ -25,9 +25,10 @@ public void onAdd(final CSimulation game, final CPlayer player) { public void update(final CSimulation game, final CPlayer player, final PathingGrid pathingGrid, final CPlayerFogOfWar fogOfWar) { if (DYING_UNIT_VISION_RADIUS > 0) { + final boolean flying = this.unit.getUnitType().getMovementType() == MovementType.FLY; final float myX = this.unit.getX(); final float myY = this.unit.getY(); - final int myZ = this.unit.getUnitType().getMovementType() == MovementType.FLY ? Integer.MAX_VALUE + final int myZ = flying ? Integer.MAX_VALUE : game.getTerrainHeight(myX, myY); fogOfWar.setState(game.getPathingGrid().getFogOfWarIndexX(myX), game.getPathingGrid().getFogOfWarIndexY(myY), (byte) 0); @@ -40,36 +41,36 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr int distance = a * a; if (distance <= DYING_UNIT_VISION_RADIUS_SQ - && !pathingGrid.isBlockVision(myX, myY - (a - 1) * CPlayerFogOfWar.GRID_STEP) + && (flying || !pathingGrid.isBlockVision(myX, myY - (a - 1) * CPlayerFogOfWar.GRID_STEP)) && fogOfWar.getState(myXi, myYi - a + 1) == 0 - && (game.isTerrainWater(myX, myY - a * CPlayerFogOfWar.GRID_STEP) + && (flying || game.isTerrainWater(myX, myY - a * CPlayerFogOfWar.GRID_STEP) || myZ > game.getTerrainHeight(myX, myY - a * CPlayerFogOfWar.GRID_STEP) || (!game.isTerrainRomp(myX, myY - a * CPlayerFogOfWar.GRID_STEP) && myZ == game.getTerrainHeight(myX, myY - a * CPlayerFogOfWar.GRID_STEP)))) { fogOfWar.setState(myXi, myYi - a, (byte) 0); } if (distance <= DYING_UNIT_VISION_RADIUS_SQ - && !pathingGrid.isBlockVision(myX, myY + (a - 1) * CPlayerFogOfWar.GRID_STEP) + && (flying || !pathingGrid.isBlockVision(myX, myY + (a - 1) * CPlayerFogOfWar.GRID_STEP)) && fogOfWar.getState(myXi, myYi + a - 1) == 0 - && (game.isTerrainWater(myX, myY + a * CPlayerFogOfWar.GRID_STEP) + && (flying || game.isTerrainWater(myX, myY + a * CPlayerFogOfWar.GRID_STEP) || myZ > game.getTerrainHeight(myX, myY + a * CPlayerFogOfWar.GRID_STEP) || (!game.isTerrainRomp(myX, myY + a * CPlayerFogOfWar.GRID_STEP) && myZ == game.getTerrainHeight(myX, myY + a * CPlayerFogOfWar.GRID_STEP)))) { fogOfWar.setState(myXi, myYi + a, (byte) 0); } if (distance <= DYING_UNIT_VISION_RADIUS_SQ - && !pathingGrid.isBlockVision(myX - (a - 1) * CPlayerFogOfWar.GRID_STEP, myY) + && (flying || !pathingGrid.isBlockVision(myX - (a - 1) * CPlayerFogOfWar.GRID_STEP, myY)) && fogOfWar.getState(myXi - a + 1, myYi) == 0 - && (game.isTerrainWater(myX - a * CPlayerFogOfWar.GRID_STEP, myY) + && (flying || game.isTerrainWater(myX - a * CPlayerFogOfWar.GRID_STEP, myY) || myZ > game.getTerrainHeight(myX - a * CPlayerFogOfWar.GRID_STEP, myY) || (!game.isTerrainRomp(myX - a * CPlayerFogOfWar.GRID_STEP, myY) && myZ == game.getTerrainHeight(myX - a * CPlayerFogOfWar.GRID_STEP, myY)))) { fogOfWar.setState(myXi - a, myYi, (byte) 0); } if (distance <= DYING_UNIT_VISION_RADIUS_SQ - && !pathingGrid.isBlockVision(myX + (a - 1) * CPlayerFogOfWar.GRID_STEP, myY) + && (flying || !pathingGrid.isBlockVision(myX + (a - 1) * CPlayerFogOfWar.GRID_STEP, myY)) && fogOfWar.getState(myXi + a - 1, myYi) == 0 - && (game.isTerrainWater(myX + a * CPlayerFogOfWar.GRID_STEP, myY) + && (flying || game.isTerrainWater(myX + a * CPlayerFogOfWar.GRID_STEP, myY) || myZ > game.getTerrainHeight(myX + a * CPlayerFogOfWar.GRID_STEP, myY) || (!game.isTerrainRomp(myX + a * CPlayerFogOfWar.GRID_STEP, myY) && myZ == game.getTerrainHeight(myX + a * CPlayerFogOfWar.GRID_STEP, myY)))) { @@ -84,10 +85,10 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr int xf = x * CPlayerFogOfWar.GRID_STEP; int yf = y * CPlayerFogOfWar.GRID_STEP; - if ((game.isTerrainWater(myX - xf, myY - yf) || myZ > game.getTerrainHeight(myX - xf, myY - yf) + if ((flying || game.isTerrainWater(myX - xf, myY - yf) || myZ > game.getTerrainHeight(myX - xf, myY - yf) || (!game.isTerrainRomp(myX - xf, myY - yf) && myZ == game.getTerrainHeight(myX - xf, myY - yf))) - && !pathingGrid.isBlockVision(myX - xf, myY - yf) + && (flying || !pathingGrid.isBlockVision(myX - xf, myY - yf)) && fogOfWar.getState(myXi - x + 1, myYi - y + 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi - x + 1, myYi - y) == 0 @@ -96,10 +97,10 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr && !pathingGrid.isBlockVision(myXi - x, myYi - y + 1)))) { fogOfWar.setState(myXi - x, myYi - y, (byte) 0); } - if ((game.isTerrainWater(myX - xf, myY + yf) || myZ > game.getTerrainHeight(myX - xf, myY + yf) + if ((flying || game.isTerrainWater(myX - xf, myY + yf) || myZ > game.getTerrainHeight(myX - xf, myY + yf) || (!game.isTerrainRomp(myX - xf, myY + yf) && myZ == game.getTerrainHeight(myX - xf, myY + yf))) - && !pathingGrid.isBlockVision(myX - xf, myY + yf) + && (flying || !pathingGrid.isBlockVision(myX - xf, myY + yf)) && fogOfWar.getState(myXi - x + 1, myYi + y - 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi - x + 1, myYi + y) == 0 @@ -108,10 +109,10 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr && !pathingGrid.isBlockVision(myXi - x, myYi + y - 1)))) { fogOfWar.setState(myXi - x, myYi + y, (byte) 0); } - if ((game.isTerrainWater(myX + xf, myY - yf) || myZ > game.getTerrainHeight(myX + xf, myY - yf) + if ((flying || game.isTerrainWater(myX + xf, myY - yf) || myZ > game.getTerrainHeight(myX + xf, myY - yf) || (!game.isTerrainRomp(myX + xf, myY - yf) && myZ == game.getTerrainHeight(myX + xf, myY - yf))) - && !pathingGrid.isBlockVision(myX + xf, myY - yf) + && (flying || !pathingGrid.isBlockVision(myX + xf, myY - yf)) && fogOfWar.getState(myXi + x - 1, myYi - y + 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi + x - 1, myYi - y) == 0 @@ -120,10 +121,10 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr && !pathingGrid.isBlockVision(myXi + x, myYi - y + 1)))) { fogOfWar.setState(myXi + x, myYi - y, (byte) 0); } - if ((game.isTerrainWater(myX + xf, myY + yf) || myZ > game.getTerrainHeight(myX + xf, myY + yf) + if ((flying || game.isTerrainWater(myX + xf, myY + yf) || myZ > game.getTerrainHeight(myX + xf, myY + yf) || (!game.isTerrainRomp(myX + xf, myY + yf) && myZ == game.getTerrainHeight(myX + xf, myY + yf))) - && !pathingGrid.isBlockVision(myX + xf, myY + yf) + && (flying || !pathingGrid.isBlockVision(myX + xf, myY + yf)) && fogOfWar.getState(myXi + x - 1, myYi + y - 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi + x - 1, myYi + y) == 0 diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CUnitVisionFogModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CUnitVisionFogModifier.java index 4ac4c85a..8c520976 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CUnitVisionFogModifier.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CUnitVisionFogModifier.java @@ -28,11 +28,11 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr final float sightRadius = game.isDay() && !alwaysNightVision ? this.unit.getUnitType().getSightRadiusDay() : this.unit.getUnitType().getSightRadiusNight(); if (sightRadius > 0) { + final boolean flying = this.unit.getUnitType().getMovementType() == MovementType.FLY; final float radSq = sightRadius * sightRadius / (CPlayerFogOfWar.GRID_STEP * CPlayerFogOfWar.GRID_STEP); final float myX = this.unit.getX(); final float myY = this.unit.getY(); - final int myZ = this.unit.getUnitType().getMovementType() == MovementType.FLY ? Integer.MAX_VALUE - : game.getTerrainHeight(myX, myY); + final int myZ = flying ? Integer.MAX_VALUE : game.getTerrainHeight(myX, myY); fogOfWar.setState(game.getPathingGrid().getFogOfWarIndexX(myX), game.getPathingGrid().getFogOfWarIndexY(myY), (byte) 0); @@ -43,33 +43,37 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr for (int a = 1; a <= Math.max(maxYi - myYi, maxXi - myXi); a++) { int distance = a * a; - if (distance <= radSq && !pathingGrid.isBlockVision(myX, myY - (a - 1) * CPlayerFogOfWar.GRID_STEP) + if (distance <= radSq + && (flying || !pathingGrid.isBlockVision(myX, myY - (a - 1) * CPlayerFogOfWar.GRID_STEP)) && fogOfWar.getState(myXi, myYi - a + 1) == 0 - && (game.isTerrainWater(myX, myY - a * CPlayerFogOfWar.GRID_STEP) + && (flying || game.isTerrainWater(myX, myY - a * CPlayerFogOfWar.GRID_STEP) || myZ > game.getTerrainHeight(myX, myY - a * CPlayerFogOfWar.GRID_STEP) || (!game.isTerrainRomp(myX, myY - a * CPlayerFogOfWar.GRID_STEP) && myZ == game .getTerrainHeight(myX, myY - a * CPlayerFogOfWar.GRID_STEP)))) { fogOfWar.setState(myXi, myYi - a, (byte) 0); } - if (distance <= radSq && !pathingGrid.isBlockVision(myX, myY + (a - 1) * CPlayerFogOfWar.GRID_STEP) + if (distance <= radSq + && (flying || !pathingGrid.isBlockVision(myX, myY + (a - 1) * CPlayerFogOfWar.GRID_STEP)) && fogOfWar.getState(myXi, myYi + a - 1) == 0 - && (game.isTerrainWater(myX, myY + a * CPlayerFogOfWar.GRID_STEP) + && (flying || game.isTerrainWater(myX, myY + a * CPlayerFogOfWar.GRID_STEP) || myZ > game.getTerrainHeight(myX, myY + a * CPlayerFogOfWar.GRID_STEP) || (!game.isTerrainRomp(myX, myY + a * CPlayerFogOfWar.GRID_STEP) && myZ == game .getTerrainHeight(myX, myY + a * CPlayerFogOfWar.GRID_STEP)))) { fogOfWar.setState(myXi, myYi + a, (byte) 0); } - if (distance <= radSq && !pathingGrid.isBlockVision(myX - (a - 1) * CPlayerFogOfWar.GRID_STEP, myY) + if (distance <= radSq + && (flying || !pathingGrid.isBlockVision(myX - (a - 1) * CPlayerFogOfWar.GRID_STEP, myY)) && fogOfWar.getState(myXi - a + 1, myYi) == 0 - && (game.isTerrainWater(myX - a * CPlayerFogOfWar.GRID_STEP, myY) + && (flying || game.isTerrainWater(myX - a * CPlayerFogOfWar.GRID_STEP, myY) || myZ > game.getTerrainHeight(myX - a * CPlayerFogOfWar.GRID_STEP, myY) || (!game.isTerrainRomp(myX - a * CPlayerFogOfWar.GRID_STEP, myY) && myZ == game .getTerrainHeight(myX - a * CPlayerFogOfWar.GRID_STEP, myY)))) { fogOfWar.setState(myXi - a, myYi, (byte) 0); } - if (distance <= radSq && !pathingGrid.isBlockVision(myX + (a - 1) * CPlayerFogOfWar.GRID_STEP, myY) + if (distance <= radSq + && (flying || !pathingGrid.isBlockVision(myX + (a - 1) * CPlayerFogOfWar.GRID_STEP, myY)) && fogOfWar.getState(myXi + a - 1, myYi) == 0 - && (game.isTerrainWater(myX + a * CPlayerFogOfWar.GRID_STEP, myY) + && (flying || game.isTerrainWater(myX + a * CPlayerFogOfWar.GRID_STEP, myY) || myZ > game.getTerrainHeight(myX + a * CPlayerFogOfWar.GRID_STEP, myY) || (!game.isTerrainRomp(myX + a * CPlayerFogOfWar.GRID_STEP, myY) && myZ == game .getTerrainHeight(myX + a * CPlayerFogOfWar.GRID_STEP, myY)))) { @@ -84,11 +88,11 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr int xf = x * CPlayerFogOfWar.GRID_STEP; int yf = y * CPlayerFogOfWar.GRID_STEP; - if ((game.isTerrainWater(myX - xf, myY - yf) + if ((flying || game.isTerrainWater(myX - xf, myY - yf) || myZ > game.getTerrainHeight(myX - xf, myY - yf) || (!game.isTerrainRomp(myX - xf, myY - yf) && myZ == game.getTerrainHeight(myX - xf, myY - yf))) - && !pathingGrid.isBlockVision(myX - xf, myY - yf) + && (flying || !pathingGrid.isBlockVision(myX - xf, myY - yf)) && fogOfWar.getState(myXi - x + 1, myYi - y + 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi - x + 1, myYi - y) == 0 @@ -97,11 +101,11 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr && !pathingGrid.isBlockVision(myXi - x, myYi - y + 1)))) { fogOfWar.setState(myXi - x, myYi - y, (byte) 0); } - if ((game.isTerrainWater(myX - xf, myY + yf) + if ((flying || game.isTerrainWater(myX - xf, myY + yf) || myZ > game.getTerrainHeight(myX - xf, myY + yf) || (!game.isTerrainRomp(myX - xf, myY + yf) && myZ == game.getTerrainHeight(myX - xf, myY + yf))) - && !pathingGrid.isBlockVision(myX - xf, myY + yf) + && (flying || !pathingGrid.isBlockVision(myX - xf, myY + yf)) && fogOfWar.getState(myXi - x + 1, myYi + y - 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi - x + 1, myYi + y) == 0 @@ -110,11 +114,11 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr && !pathingGrid.isBlockVision(myXi - x, myYi + y - 1)))) { fogOfWar.setState(myXi - x, myYi + y, (byte) 0); } - if ((game.isTerrainWater(myX + xf, myY - yf) + if ((flying || game.isTerrainWater(myX + xf, myY - yf) || myZ > game.getTerrainHeight(myX + xf, myY - yf) || (!game.isTerrainRomp(myX + xf, myY - yf) && myZ == game.getTerrainHeight(myX + xf, myY - yf))) - && !pathingGrid.isBlockVision(myX + xf, myY - yf) + && (flying || !pathingGrid.isBlockVision(myX + xf, myY - yf)) && fogOfWar.getState(myXi + x - 1, myYi - y + 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi + x - 1, myYi - y) == 0 @@ -123,11 +127,11 @@ public void update(final CSimulation game, final CPlayer player, final PathingGr && !pathingGrid.isBlockVision(myXi + x, myYi - y + 1)))) { fogOfWar.setState(myXi + x, myYi - y, (byte) 0); } - if ((game.isTerrainWater(myX + xf, myY + yf) + if ((flying || game.isTerrainWater(myX + xf, myY + yf) || myZ > game.getTerrainHeight(myX + xf, myY + yf) || (!game.isTerrainRomp(myX + xf, myY + yf) && myZ == game.getTerrainHeight(myX + xf, myY + yf))) - && !pathingGrid.isBlockVision(myX + xf, myY + yf) + && (flying || !pathingGrid.isBlockVision(myX + xf, myY + yf)) && fogOfWar.getState(myXi + x - 1, myYi + y - 1) == 0 && (x == y || (x > y && fogOfWar.getState(myXi + x - 1, myYi + y) == 0