Skip to content

Commit

Permalink
Merge pull request #11 from Glasislundr/abilitybuilder
Browse files Browse the repository at this point in the history
Quick Fixes!
  • Loading branch information
Glasislundr authored Nov 25, 2023
2 parents 64a880b + 1ffa273 commit cb8317e
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 85 deletions.
16 changes: 14 additions & 2 deletions core/assets/abilityBehaviors/humanHeroActives.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
}
}
},{
"type": "iterateUnitsInRangeOfLocation",
"type": "iterateUnitsInRangeOfLocationMatchingCondition",
"location": {
"type": "getStoredLocationByKey",
"key": {
Expand All @@ -280,6 +280,12 @@
"range": {
"type": "getAbilityArea"
},
"condition": {
"type": "isUnitValidTarget",
"target": {
"type": "getMatchingUnit"
}
},
"iterationActions": [{
"type": "createTimedArtBuff",
"buffId": {
Expand Down Expand Up @@ -458,7 +464,7 @@
}
}
},{
"type": "iterateUnitsInRangeOfLocation",
"type": "iterateUnitsInRangeOfLocationMatchingCondition",
"location": {
"type": "getStoredLocationByKey",
"key": {
Expand All @@ -469,6 +475,12 @@
"range": {
"type": "getAbilityArea"
},
"condition": {
"type": "isUnitValidTarget",
"target": {
"type": "getMatchingUnit"
}
},
"iterationActions": [{
"type": "createTimedArtBuff",
"buffId": {
Expand Down
16 changes: 14 additions & 2 deletions core/assets/abilityBehaviors/nightElfUnitActives.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@
},
"effectType": "CASTER"
},{
"type": "iterateUnitsInRangeOfUnit",
"type": "iterateUnitsInRangeOfUnitMatchingCondition",
"condition": {
"type": "isUnitValidTarget",
"target": {
"type": "getMatchingUnit"
}
},
"iterationActions": [{
"type": "createTimedBuff",
"buffId": {
Expand Down Expand Up @@ -752,7 +758,13 @@
}
},
"thenActions": [{
"type": "iterateUnitsInRangeOfUnit",
"type": "iterateUnitsInRangeOfUnitMatchingCondition",
"condition": {
"type": "isUnitValidTarget",
"target": {
"type": "getMatchingUnit"
}
},
"iterationActions": [{
"type": "if",
"condition": {
Expand Down
34 changes: 26 additions & 8 deletions core/assets/abilityBehaviors/undeadUnitActives.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [{
Expand Down Expand Up @@ -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": [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -1488,7 +1498,7 @@ public void setTypeId(final CSimulation game, final War3ID typeId, boolean updat
final List<CAbility> persistedAbilities = new ArrayList<>();
final List<CAbility> 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);
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);

Expand All @@ -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)))) {
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)))) {
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit cb8317e

Please sign in to comment.