Skip to content

Commit

Permalink
Implemented Ability Requirements!
Browse files Browse the repository at this point in the history
* AB: Implemented requirement checks
* AB: Added ability actions for adding and removing when the ability is disabled (used primarily for transformations)
* Core: Added hooks for ability requirement checks
* Core: Added callbacks to enable and disabled abilities as techtree requirements change
* Core: Updated ability tooltips to list requirements
* Core: Updated ability disable methods to track different sources of disabling

* AB: Fixed issues with morph flags not working on takeoff
* Core: Fixed issue with flying height changing unexpectedly on unit type change
  • Loading branch information
Glasislundr committed Nov 5, 2023
1 parent 389f540 commit 257dfe7
Show file tree
Hide file tree
Showing 30 changed files with 494 additions and 164 deletions.
28 changes: 14 additions & 14 deletions core/assets/abilityBehaviors/Transformations.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
}
}
},
"onAddAbility": [{
"onAddDisabledAbility": [{
"type": "if",
"condition": {
"type": "isToggleAbilityActive"
Expand Down Expand Up @@ -301,7 +301,7 @@
}],
"elseActions": []
}],
"onRemoveAbility": [{
"onRemoveDisabledAbility": [{
"type": "transformedUnitAbilityRemove",
"unit": {
"type": "getCastingUnit"
Expand Down Expand Up @@ -657,7 +657,7 @@
}
}
},
"onAddAbility": [{
"onAddDisabledAbility": [{
"type": "if",
"condition": {
"type": "isToggleAbilityActive"
Expand Down Expand Up @@ -745,7 +745,7 @@
}],
"elseActions": []
}],
"onRemoveAbility": [{
"onRemoveDisabledAbility": [{
"type": "transformedUnitAbilityRemove",
"unit": {
"type": "getCastingUnit"
Expand Down Expand Up @@ -1110,7 +1110,7 @@
}
}
},
"onAddAbility": [{
"onAddDisabledAbility": [{
"type": "createNonStackingStatBuff",
"buffType": {
"type": "getNonStackingStatBuffTypeFromString",
Expand Down Expand Up @@ -1226,7 +1226,7 @@
}],
"elseActions": []
}],
"onRemoveAbility": [{
"onRemoveDisabledAbility": [{
"type": "transformedUnitAbilityRemove",
"unit": {
"type": "getCastingUnit"
Expand Down Expand Up @@ -1621,7 +1621,7 @@
}
}
},
"onAddAbility": [{
"onAddDisabledAbility": [{
"type": "createStateModBuff",
"buffType": "ETHEREAL"
},{
Expand Down Expand Up @@ -1732,7 +1732,7 @@
}
}]
}],
"onRemoveAbility": [{
"onRemoveDisabledAbility": [{
"type": "transformedUnitAbilityRemove",
"unit": {
"type": "getCastingUnit"
Expand Down Expand Up @@ -2108,7 +2108,7 @@
}
}
},
"onAddAbility": [{
"onAddDisabledAbility": [{
"type": "createStateModBuff",
"buffType": "ETHEREAL"
},{
Expand Down Expand Up @@ -2211,7 +2211,7 @@
}],
"elseActions": []
}],
"onRemoveAbility": [{
"onRemoveDisabledAbility": [{
"type": "transformedUnitAbilityRemove",
"unit": {
"type": "getCastingUnit"
Expand Down Expand Up @@ -2596,7 +2596,7 @@
}
}
},
"onAddAbility": [{
"onAddDisabledAbility": [{
"type": "if",
"condition": {
"type": "isToggleAbilityActive"
Expand Down Expand Up @@ -2678,7 +2678,7 @@
}],
"elseActions": []
}],
"onRemoveAbility": [{
"onRemoveDisabledAbility": [{
"type": "transformedUnitAbilityRemove",
"unit": {
"type": "getCastingUnit"
Expand Down Expand Up @@ -3038,7 +3038,7 @@
}
}
},
"onAddAbility": [{
"onAddDisabledAbility": [{
"type": "createNonStackingStatBuff",
"buffType": {
"type": "getNonStackingStatBuffTypeFromString",
Expand All @@ -3055,7 +3055,7 @@
"dataField": "E"
}
}],
"onRemoveAbility": [{
"onRemoveDisabledAbility": [{
"type": "transformedUnitAbilityRemove",
"unit": {
"type": "getCastingUnit"
Expand Down
2 changes: 1 addition & 1 deletion core/assets/abilityBehaviors/humanUnitActives.json
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@
}
}
}],
"onAddAbility": [{
"onAddDisabledAbility": [{
"type": "if",
"condition": {
"type": "isToggleAbilityActive"
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/etheller/warsmash/parsers/jass/Jass2.java
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,7 @@ public JassValue call(final List<JassValue> arguments, final GlobalScope globalS
final double facing = arguments.get(3).visit(RealJassValueVisitor.getInstance());
final War3ID blightedMineRawcode = War3ID.fromString("ugol");
final War3ID goldMineRawcode = War3ID.fromString("ngol");
player.addTechtreeUnlocked(blightedMineRawcode);
player.addTechtreeUnlocked(simulation, blightedMineRawcode);
final CUnit blightedMine = CommonEnvironment.this.simulation.createUnitSimple(
blightedMineRawcode, player.getId(), (float) x, (float) y, (float) facing);
final CUnit goldMine = CommonEnvironment.this.simulation.createUnitSimple(goldMineRawcode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void missingRequirement(final War3ID type, final int level) {
final CUnitType unitType = unitData.getUnitType(type);
String requirementString;
if (unitType != null) {
requirementString = unitType.getName();
requirementString = level + " " + unitType.getName() + (level > 1 ? "s" : "");
} else {
final CUpgradeType upgradeType = upgradeData
.getType(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ private void addCommandButton(final CAbility ability, final IconUI iconUI, final
private void addCommandButton(final CAbility ability, final Texture icon, final Texture iconDisabled,
final String toolTip, String uberTip, final int buttonPosX, final int buttonPosY, final int handleId,
final int orderId, final int autoCastOrderId, final boolean autoCastActive, final boolean menuButton,
int goldCost, int lumberCost, int foodCost, final int manaCost, final int numberOverlay,
int goldCost, int lumberCost, int foodCost, int manaCost, final int numberOverlay,
final char hotkey) {
boolean requiresPatron = false;
if (this.unit.getPlayerIndex() != this.localPlayerIndex) {
Expand Down Expand Up @@ -496,6 +496,7 @@ private void addCommandButton(final CAbility ability, final Texture icon, final
goldCost = 0;
lumberCost = 0;
foodCost = 0;
manaCost = 0;
}
if (this.previewCallback.isShowingRequirements()) {
uberTip = this.previewCallback.getRequirementsText() + "|r" + uberTip;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public CUnit createUnitSimple(final War3ID typeId, final int playerIndex, final
if (newUnitType.getFoodMade() != 0) {
player.setFoodCap(player.getFoodCap() + newUnitType.getFoodMade());
}
player.addTechtreeUnlocked(typeId);
player.addTechtreeUnlocked(this, typeId);
// nudge unit
newUnit.setPointAndCheckUnstuck(x, y, this);
if (!newUnit.isBuilding()) {
Expand Down Expand Up @@ -677,7 +677,7 @@ public void unitsLoaded() {
final CPlayer player = this.players.get(unit.getPlayerIndex());
player.setUnitFoodUsed(unit, unit.getUnitType().getFoodUsed());
player.setUnitFoodMade(unit, unit.getUnitType().getFoodMade());
player.addTechtreeUnlocked(unit.getTypeId());
player.addTechtreeUnlocked(this, unit.getTypeId());
}
}

Expand Down
Loading

0 comments on commit 257dfe7

Please sign in to comment.