Skip to content

Commit

Permalink
Refactored Passive abilities!
Browse files Browse the repository at this point in the history
* AB: Brought passives up-to-date with actives
* AB: Implemented Chaos to demonstrate passives with requirements
* AB: Added cooldown indicator for Passives
* AB: Refactored Instant transformation actions (not slow ones) to function with passives
* AB: Fixed transform edge case with a paid transformation that has a duration
* AB: Fixed transform edge case where the timing of altitude adjustment could be messed up
* AB: Fixed cast animation timing where it would sometimes play over morph
* AB: Removed unneeded classes related to failed first Buff implementation
* Core: Changed selection method of animations to default to stand when others not found
* Core: Fixed crash when ability removed itself as part of onAdd actions
* Core: Fixed issue with change to requirements string
  • Loading branch information
Glasislundr committed Nov 5, 2023
1 parent 257dfe7 commit 49e4b2b
Show file tree
Hide file tree
Showing 31 changed files with 936 additions and 230 deletions.
100 changes: 100 additions & 0 deletions core/assets/abilityBehaviors/Transformations.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,20 @@
}
}
},
"requiresPayment": {
"type": "i2b",
"value": {
"type": "i&",
"value1": {
"type": "getAbilityDataAsInteger",
"dataField": "B"
},
"value2": {
"type": "rawInteger",
"value": 16
}
}
},
"altitudeAdjustmentDelay": {
"type": "getAbilityCastTime"
},
Expand Down Expand Up @@ -716,6 +730,20 @@
}
}
},
"requiresPayment": {
"type": "i2b",
"value": {
"type": "i&",
"value1": {
"type": "getAbilityDataAsInteger",
"dataField": "B"
},
"value2": {
"type": "rawInteger",
"value": 16
}
}
},
"altitudeAdjustmentDelay": {
"type": "getAbilityCastTime"
},
Expand Down Expand Up @@ -1185,6 +1213,20 @@
}
}
},
"requiresPayment": {
"type": "i2b",
"value": {
"type": "i&",
"value1": {
"type": "getAbilityDataAsInteger",
"dataField": "B"
},
"value2": {
"type": "rawInteger",
"value": 16
}
}
},
"altitudeAdjustmentDelay": {
"type": "getAbilityCastTime"
},
Expand Down Expand Up @@ -1683,6 +1725,20 @@
}
}
},
"requiresPayment": {
"type": "i2b",
"value": {
"type": "i&",
"value1": {
"type": "getAbilityDataAsInteger",
"dataField": "B"
},
"value2": {
"type": "rawInteger",
"value": 16
}
}
},
"altitudeAdjustmentDelay": {
"type": "getAbilityCastTime"
},
Expand Down Expand Up @@ -2170,6 +2226,20 @@
}
}
},
"requiresPayment": {
"type": "i2b",
"value": {
"type": "i&",
"value1": {
"type": "getAbilityDataAsInteger",
"dataField": "B"
},
"value2": {
"type": "rawInteger",
"value": 16
}
}
},
"altitudeAdjustmentDelay": {
"type": "getAbilityCastTime"
},
Expand Down Expand Up @@ -2655,6 +2725,20 @@
}
}
},
"requiresPayment": {
"type": "i2b",
"value": {
"type": "i&",
"value1": {
"type": "getAbilityDataAsInteger",
"dataField": "B"
},
"value2": {
"type": "rawInteger",
"value": 16
}
}
},
"altitudeAdjustmentDelay": {
"type": "getAbilityCastTime"
},
Expand Down Expand Up @@ -3221,5 +3305,21 @@
}
}]
}]
},{
"ids": [{"id":"Acha"}],
"type": "HIDDEN",
"onAddAbility": [{
"type": "transformUnitInstant",
"unit": {
"type": "getCastingUnit"
},
"alternateUnitId": {
"type": "getAbilityUnitId"
},
"permanent": {
"type": "rawBoolean",
"value": "true"
}
}]
}]
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static int matchRank(final EnumSet<AnimationTokens.SecondaryTag> goalTagS
return matchRank;
}

public static IndexedSequence selectSequence(final AnimationTokens.PrimaryTag type,
public static IndexedSequence selectSequence(AnimationTokens.PrimaryTag type,
final EnumSet<AnimationTokens.SecondaryTag> tags, final List<Sequence> sequences,
final boolean allowRarityVariations) {
List<IndexedSequence> filtered = filterSequences(type, tags, sequences);
Expand All @@ -141,6 +141,9 @@ public static IndexedSequence selectSequence(final AnimationTokens.PrimaryTag ty
}
}
if (fallbackTags == null) {
if (type == null) {
type = PrimaryTag.STAND;
}
for (int i = 0, l = sequences.size(); i < l; i++) {
final Sequence sequence = sequences.get(i);
if (sequence.getPrimaryTags().contains(type) || (type == null)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ public void missingRequirement(final War3ID type, final int level) {
final CUnitType unitType = unitData.getUnitType(type);
String requirementString;
if (unitType != null) {
requirementString = level + " " + unitType.getName() + (level > 1 ? "s" : "");
if (level > 1) {
requirementString = level + " " + unitType.getName() + "s";
} else {
requirementString = unitType.getName();
}
} else {
final CUpgradeType upgradeType = upgradeData
.getType(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1339,16 +1339,13 @@ public void checkDisabledAbilities(final CSimulation simulation, final boolean d
}
}
} else {
final Iterator<CAbility> abilityIterator = this.disabledAbilities.iterator();
while (abilityIterator.hasNext()) {
final CAbility ability = abilityIterator.next();
for (CAbility ability : new ArrayList<>(this.disabledAbilities)) {
if (ability.isRequirementsMet(simulation, this)) {
ability.setDisabled(false, CAbilityDisableType.REQUIREMENTS);
}
if (!ability.isDisabled()) {
// System.err.println("Enabling ability: " + ability.getAlias().asStringValue());
ability.onAdd(simulation, this);
abilityIterator.remove();
this.disabledAbilities.remove(ability);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability;

import java.util.List;
import java.util.Map;

import com.etheller.warsmash.util.War3ID;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.Aliased;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CLevelingAbility;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData;

public interface AbilityBuilderAbility extends CLevelingAbility, Aliased {
public List<CAbilityTypeAbilityBuilderLevelData> getLevelData();

public AbilityBuilderConfiguration getConfig();

public Map<String, Object> getLocalStore();

public float getArea();

public void startCooldown(CSimulation game, CUnit unit);

public void resetCooldown(CSimulation game, CUnit unit);

War3ID getOnTooltipOverride();

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver;

public interface AbilityBuilderActiveAbility extends GenericSingleIconActiveAbility {
public interface AbilityBuilderActiveAbility extends AbilityBuilderAbility, GenericSingleIconActiveAbility {
public List<CAbilityTypeAbilityBuilderLevelData> getLevelData();

public AbilityBuilderConfiguration getConfig();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability;

public interface AbilityBuilderPassiveAbility extends AbilityBuilderAbility {

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,6 @@ private void determineToggleableFields(CSimulation game, CUnit unit) {
this.active = true;
}
}

if (this.config.getOverrideFields() != null) {
if (this.config.getOverrideFields().getOnTooltipOverride() != null) {
this.onTooltipOverride = this.config.getOverrideFields().getOnTooltipOverride().callback(game, unit,
localStore, castId);
}
if (this.config.getOverrideFields().getOffTooltipOverride() != null) {
this.offTooltipOverride = this.config.getOverrideFields().getOffTooltipOverride().callback(game,
unit, localStore, castId);
}
}
}
}

Expand All @@ -241,6 +230,15 @@ protected void setSpellFields(CSimulation game, CUnit unit) {
this.manaCost = this.config.getOverrideFields().getManaCostOverride().callback(game, unit, localStore,
castId);
}

if (this.config.getOverrideFields().getOnTooltipOverride() != null) {
this.onTooltipOverride = this.config.getOverrideFields().getOnTooltipOverride().callback(game, unit,
localStore, castId);
}
if (this.config.getOverrideFields().getOffTooltipOverride() != null) {
this.offTooltipOverride = this.config.getOverrideFields().getOffTooltipOverride().callback(game,
unit, localStore, castId);
}
}

if (this.config.getDisplayFields() != null && this.config.getDisplayFields().getHideAreaCursor() != null) {
Expand Down
Loading

0 comments on commit 49e4b2b

Please sign in to comment.