mirror of
https://github.com/Retera/WarsmashModEngine.git
synced 2022-07-31 17:38:59 +02:00
Merge branch 'main' of https://github.com/Retera/WarsmashModEngine into main
This commit is contained in:
commit
4c84c373b4
@ -1127,10 +1127,14 @@ public class War3MapViewer extends AbstractMdxModelViewer {
|
|||||||
final int playerIndex = unit.getPlayer();
|
final int playerIndex = unit.getPlayer();
|
||||||
final int customTeamColor = unit.getCustomTeamColor();
|
final int customTeamColor = unit.getCustomTeamColor();
|
||||||
final float unitAngle = unit.getAngle();
|
final float unitAngle = unit.getAngle();
|
||||||
|
int editorConfigHitPointPercent = unit.getHitpoints();
|
||||||
|
|
||||||
final CUnit unitCreated = createNewUnit(modifications, unitId, unitX, unitY, unitZ, playerIndex,
|
final CUnit unitCreated = createNewUnit(modifications, unitId, unitX, unitY, unitZ, playerIndex,
|
||||||
customTeamColor, unitAngle);
|
customTeamColor, unitAngle);
|
||||||
if (unitCreated != null) {
|
if(unitCreated != null) {
|
||||||
|
if (editorConfigHitPointPercent > 0) {
|
||||||
|
unitCreated.setLife(simulation, unitCreated.getMaximumLife() * (editorConfigHitPointPercent / 100f));
|
||||||
|
}
|
||||||
if (unit.getGoldAmount() != 0) {
|
if (unit.getGoldAmount() != 0) {
|
||||||
unitCreated.setGold(unit.getGoldAmount());
|
unitCreated.setGold(unit.getGoldAmount());
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,11 @@ public class CDestructable extends CWidget {
|
|||||||
this.pathingInstanceDeath = pathingInstanceDeath;
|
this.pathingInstanceDeath = pathingInstanceDeath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getMaxLife() {
|
||||||
|
return destType.getMaxLife();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getFlyHeight() {
|
public float getFlyHeight() {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -8,18 +8,18 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType;
|
|||||||
public class CDestructableType {
|
public class CDestructableType {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final float life;
|
private final float maxLife;
|
||||||
private final EnumSet<CTargetType> targetedAs;
|
private final EnumSet<CTargetType> targetedAs;
|
||||||
private final String armorType;
|
private final String armorType;
|
||||||
private final int buildTime;
|
private final int buildTime;
|
||||||
private final BufferedImage pathingPixelMap;
|
private final BufferedImage pathingPixelMap;
|
||||||
private final BufferedImage pathingDeathPixelMap;
|
private final BufferedImage pathingDeathPixelMap;
|
||||||
|
|
||||||
public CDestructableType(final String name, final float life, final EnumSet<CTargetType> targetedAs,
|
public CDestructableType(final String name, final float maxLife, final EnumSet<CTargetType> targetedAs,
|
||||||
final String armorType, final int buildTime, final BufferedImage pathingPixelMap,
|
final String armorType, final int buildTime, final BufferedImage pathingPixelMap,
|
||||||
final BufferedImage pathingDeathPixelMap) {
|
final BufferedImage pathingDeathPixelMap) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.life = life;
|
this.maxLife = maxLife;
|
||||||
this.targetedAs = targetedAs;
|
this.targetedAs = targetedAs;
|
||||||
this.armorType = armorType;
|
this.armorType = armorType;
|
||||||
this.buildTime = buildTime;
|
this.buildTime = buildTime;
|
||||||
@ -31,8 +31,8 @@ public class CDestructableType {
|
|||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getLife() {
|
public float getMaxLife() {
|
||||||
return this.life;
|
return this.maxLife;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnumSet<CTargetType> getTargetedAs() {
|
public EnumSet<CTargetType> getTargetedAs() {
|
||||||
|
@ -75,7 +75,7 @@ public class CItem extends CWidget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMaxLife() {
|
public float getMaxLife() {
|
||||||
return this.itemType.getHitPoints();
|
return itemType.getMaxLife();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPointAndCheckUnstuck(final float newX, final float newY, final CSimulation game) {
|
public void setPointAndCheckUnstuck(final float newX, final float newY, final CSimulation game) {
|
||||||
|
@ -17,7 +17,7 @@ public class CItemType {
|
|||||||
private final int stockMax;
|
private final int stockMax;
|
||||||
private final int stockReplenishInterval;
|
private final int stockReplenishInterval;
|
||||||
private final int stockStartDelay;
|
private final int stockStartDelay;
|
||||||
private final int hitPoints;
|
private final int maxLife;
|
||||||
private final String armorType;
|
private final String armorType;
|
||||||
private final int level;
|
private final int level;
|
||||||
private final int levelUnclassified;
|
private final int levelUnclassified;
|
||||||
@ -30,12 +30,12 @@ public class CItemType {
|
|||||||
private final boolean includeAsRandomChoice;
|
private final boolean includeAsRandomChoice;
|
||||||
|
|
||||||
public CItemType(final List<War3ID> abilityList, final War3ID cooldownGroup, final boolean ignoreCooldown,
|
public CItemType(final List<War3ID> abilityList, final War3ID cooldownGroup, final boolean ignoreCooldown,
|
||||||
final int numberOfCharges, final boolean activelyUsed, final boolean perishable,
|
final int numberOfCharges, final boolean activelyUsed, final boolean perishable,
|
||||||
final boolean useAutomaticallyWhenAcquired, final int goldCost, final int lumberCost, final int stockMax,
|
final boolean useAutomaticallyWhenAcquired, final int goldCost, final int lumberCost, final int stockMax,
|
||||||
final int stockReplenishInterval, final int stockStartDelay, final int hitPoints, final String armorType,
|
final int stockReplenishInterval, final int stockStartDelay, final int maxLife, final String armorType,
|
||||||
final int level, final int levelUnclassified, final int priority, final boolean sellable,
|
final int level, final int levelUnclassified, final int priority, final boolean sellable,
|
||||||
final boolean pawnable, final boolean droppedWhenCarrierDies, final boolean canBeDropped,
|
final boolean pawnable, final boolean droppedWhenCarrierDies, final boolean canBeDropped,
|
||||||
final boolean validTargetForTransformation, final boolean includeAsRandomChoice) {
|
final boolean validTargetForTransformation, final boolean includeAsRandomChoice) {
|
||||||
this.abilityList = abilityList;
|
this.abilityList = abilityList;
|
||||||
this.cooldownGroup = cooldownGroup;
|
this.cooldownGroup = cooldownGroup;
|
||||||
this.ignoreCooldown = ignoreCooldown;
|
this.ignoreCooldown = ignoreCooldown;
|
||||||
@ -48,7 +48,7 @@ public class CItemType {
|
|||||||
this.stockMax = stockMax;
|
this.stockMax = stockMax;
|
||||||
this.stockReplenishInterval = stockReplenishInterval;
|
this.stockReplenishInterval = stockReplenishInterval;
|
||||||
this.stockStartDelay = stockStartDelay;
|
this.stockStartDelay = stockStartDelay;
|
||||||
this.hitPoints = hitPoints;
|
this.maxLife = maxLife;
|
||||||
this.armorType = armorType;
|
this.armorType = armorType;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.levelUnclassified = levelUnclassified;
|
this.levelUnclassified = levelUnclassified;
|
||||||
@ -109,8 +109,8 @@ public class CItemType {
|
|||||||
return this.stockStartDelay;
|
return this.stockStartDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHitPoints() {
|
public int getMaxLife() {
|
||||||
return this.hitPoints;
|
return this.maxLife;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getArmorType() {
|
public String getArmorType() {
|
||||||
|
@ -1225,6 +1225,11 @@ public class CUnit extends CWidget {
|
|||||||
setPointAndCheckUnstuck(structure.getX(), structure.getY(), simulation);
|
setPointAndCheckUnstuck(structure.getX(), structure.getY(), simulation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getMaxLife() {
|
||||||
|
return unitType.getMaxLife();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLife(final CSimulation simulation, final float life) {
|
public void setLife(final CSimulation simulation, final float life) {
|
||||||
final boolean wasDead = isDead();
|
final boolean wasDead = isDead();
|
||||||
|
@ -22,7 +22,7 @@ public class CUnitType {
|
|||||||
private final String name;
|
private final String name;
|
||||||
private final String legacyName;
|
private final String legacyName;
|
||||||
private final War3ID typeId;
|
private final War3ID typeId;
|
||||||
private final int life;
|
private final int maxLife;
|
||||||
private final int manaInitial;
|
private final int manaInitial;
|
||||||
private final int manaMaximum;
|
private final int manaMaximum;
|
||||||
private final int speed;
|
private final int speed;
|
||||||
@ -76,7 +76,7 @@ public class CUnitType {
|
|||||||
private final boolean canFlee;
|
private final boolean canFlee;
|
||||||
private final int priority;
|
private final int priority;
|
||||||
|
|
||||||
public CUnitType(final String name, final String legacyName, final War3ID typeId, final int life,
|
public CUnitType(final String name, final String legacyName, final War3ID typeId, final int maxLife,
|
||||||
final int manaInitial, final int manaMaximum, final int speed, final int defense, final String abilityList,
|
final int manaInitial, final int manaMaximum, final int speed, final int defense, final String abilityList,
|
||||||
final boolean isBldg, final MovementType movementType, final float defaultFlyingHeight,
|
final boolean isBldg, final MovementType movementType, final float defaultFlyingHeight,
|
||||||
final float collisionSize, final EnumSet<CUnitClassification> classifications,
|
final float collisionSize, final EnumSet<CUnitClassification> classifications,
|
||||||
@ -96,7 +96,7 @@ public class CUnitType {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.legacyName = legacyName;
|
this.legacyName = legacyName;
|
||||||
this.typeId = typeId;
|
this.typeId = typeId;
|
||||||
this.life = life;
|
this.maxLife = maxLife;
|
||||||
this.manaInitial = manaInitial;
|
this.manaInitial = manaInitial;
|
||||||
this.manaMaximum = manaMaximum;
|
this.manaMaximum = manaMaximum;
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
@ -160,8 +160,8 @@ public class CUnitType {
|
|||||||
return this.typeId;
|
return this.typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLife() {
|
public int getMaxLife() {
|
||||||
return this.life;
|
return this.maxLife;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getManaInitial() {
|
public int getManaInitial() {
|
||||||
|
@ -64,6 +64,8 @@ public abstract class CWidget implements AbilityTarget {
|
|||||||
return this.life <= 0;
|
return this.life <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract float getMaxLife();
|
||||||
|
|
||||||
public abstract boolean canBeTargetedBy(CSimulation simulation, CUnit source,
|
public abstract boolean canBeTargetedBy(CSimulation simulation, CUnit source,
|
||||||
final EnumSet<CTargetType> targetsAllowed);
|
final EnumSet<CTargetType> targetsAllowed);
|
||||||
|
|
||||||
|
@ -0,0 +1,135 @@
|
|||||||
|
package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build;
|
||||||
|
|
||||||
|
import com.etheller.warsmash.util.War3ID;
|
||||||
|
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.CWidget;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbstractGenericSingleIconActiveAbility;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.build.CBehaviorHumanRepair;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
public class CAbilityHumanRepair extends AbstractGenericSingleIconActiveAbility {
|
||||||
|
private EnumSet<CTargetType> targetsAllowed;
|
||||||
|
private final float navalRangeBonus;
|
||||||
|
private final float repairCostRatio;
|
||||||
|
private final float repairTimeRatio;
|
||||||
|
private final float castRange;
|
||||||
|
private CBehaviorHumanRepair behaviorRepair;
|
||||||
|
|
||||||
|
public CAbilityHumanRepair(int handleId, War3ID alias, EnumSet<CTargetType> targetsAllowed,
|
||||||
|
float navalRangeBonus, float repairCostRatio, float repairTimeRatio,
|
||||||
|
float castRange) {
|
||||||
|
super(handleId, alias);
|
||||||
|
this.targetsAllowed = targetsAllowed;
|
||||||
|
this.navalRangeBonus = navalRangeBonus;
|
||||||
|
this.repairCostRatio = repairCostRatio;
|
||||||
|
this.repairTimeRatio = repairTimeRatio;
|
||||||
|
this.castRange = castRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void innerCheckCanTarget(CSimulation game, CUnit unit, int orderId, CWidget target, AbilityTargetCheckReceiver<CWidget> receiver) {
|
||||||
|
if(target.canBeTargetedBy(game, unit, targetsAllowed)) {
|
||||||
|
receiver.targetOk(target);
|
||||||
|
} else {
|
||||||
|
receiver.orderIdNotAccepted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void innerCheckCanSmartTarget(CSimulation game, CUnit unit, int orderId, CWidget target, AbilityTargetCheckReceiver<CWidget> receiver) {
|
||||||
|
innerCheckCanTarget(game, unit, orderId, target, receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void innerCheckCanTarget(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, AbilityTargetCheckReceiver<AbilityPointTarget> receiver) {
|
||||||
|
receiver.mustTargetType(AbilityTargetCheckReceiver.TargetType.UNIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void innerCheckCanSmartTarget(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, AbilityTargetCheckReceiver<AbilityPointTarget> receiver) {
|
||||||
|
innerCheckCanTarget(game, unit, orderId, target, receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void innerCheckCanTargetNoTarget(CSimulation game, CUnit unit, int orderId, AbilityTargetCheckReceiver<Void> receiver) {
|
||||||
|
receiver.orderIdNotAccepted();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void innerCheckCanUse(CSimulation game, CUnit unit, int orderId, AbilityActivationReceiver receiver) {
|
||||||
|
receiver.useOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdd(CSimulation game, CUnit unit) {
|
||||||
|
behaviorRepair = new CBehaviorHumanRepair(unit, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRemove(CSimulation game, CUnit unit) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTick(CSimulation game, CUnit unit) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCancelFromQueue(CSimulation game, CUnit unit, int orderId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target) {
|
||||||
|
return behaviorRepair.reset(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBaseOrderId() {
|
||||||
|
return OrderIds.repair;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isToggleOn() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumSet<CTargetType> getTargetsAllowed() {
|
||||||
|
return targetsAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getNavalRangeBonus() {
|
||||||
|
return navalRangeBonus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getRepairCostRatio() {
|
||||||
|
return repairCostRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getRepairTimeRatio() {
|
||||||
|
return repairTimeRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getCastRange() {
|
||||||
|
return castRange;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl;
|
||||||
|
|
||||||
|
import com.etheller.warsmash.units.manager.MutableObjectData.MutableGameObject;
|
||||||
|
import com.etheller.warsmash.util.War3ID;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.CAbilityTypeDefinition;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.impl.CAbilityTypeHumanRepair;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.impl.CAbilityTypeHumanRepairLevelData;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CAbilityTypeDefinitionHumanRepair extends AbstractCAbilityTypeDefinition<CAbilityTypeHumanRepairLevelData>
|
||||||
|
implements CAbilityTypeDefinition {
|
||||||
|
protected static final War3ID COST_RATIO = War3ID.fromString("Rep1");
|
||||||
|
protected static final War3ID TIME_RATIO = War3ID.fromString("Rep2");
|
||||||
|
protected static final War3ID NAVAL_RANGE_BONUS = War3ID.fromString("Rep5");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CAbilityTypeHumanRepairLevelData createLevelData(final MutableGameObject abilityEditorData, final int level) {
|
||||||
|
final String targetsAllowedAtLevelString = abilityEditorData.getFieldAsString(TARGETS_ALLOWED, level);
|
||||||
|
final EnumSet<CTargetType> targetsAllowedAtLevel = CTargetType.parseTargetTypeSet(targetsAllowedAtLevelString);
|
||||||
|
final float costRatio = abilityEditorData.getFieldAsFloat(COST_RATIO, level);
|
||||||
|
final float timeRatio = abilityEditorData.getFieldAsFloat(TIME_RATIO, level);
|
||||||
|
final float navalRangeBonus = abilityEditorData.getFieldAsFloat(NAVAL_RANGE_BONUS, level);
|
||||||
|
final float castRange = abilityEditorData.getFieldAsFloat(CAST_RANGE, level);
|
||||||
|
return new CAbilityTypeHumanRepairLevelData(targetsAllowedAtLevel, navalRangeBonus, costRatio, timeRatio, castRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CAbilityType<?> innerCreateAbilityType(final War3ID alias, final MutableGameObject abilityEditorData,
|
||||||
|
final List<CAbilityTypeHumanRepairLevelData> levelData) {
|
||||||
|
return new CAbilityTypeHumanRepair(alias, abilityEditorData.getCode(), levelData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.impl;
|
||||||
|
|
||||||
|
import com.etheller.warsmash.util.War3ID;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityHumanRepair;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CAbilityTypeHumanRepair extends CAbilityType<CAbilityTypeHumanRepairLevelData> {
|
||||||
|
|
||||||
|
public CAbilityTypeHumanRepair(final War3ID alias, final War3ID code,
|
||||||
|
final List<CAbilityTypeHumanRepairLevelData> levelData) {
|
||||||
|
super(alias, code, levelData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CAbility createAbility(final int handleId) {
|
||||||
|
final CAbilityTypeHumanRepairLevelData levelData = getLevelData(0);
|
||||||
|
return new CAbilityHumanRepair(handleId, getAlias(), levelData.getTargetsAllowed(),
|
||||||
|
levelData.getNavalRangeBonus(), levelData.getRepairCostRatio(), levelData.getRepairTimeRatio(),
|
||||||
|
levelData.getCastRange());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.impl;
|
||||||
|
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityTypeLevelData;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
public class CAbilityTypeHumanRepairLevelData extends CAbilityTypeLevelData {
|
||||||
|
|
||||||
|
private final float navalRangeBonus;
|
||||||
|
private final float repairCostRatio;
|
||||||
|
private final float repairTimeRatio;
|
||||||
|
private final float castRange;
|
||||||
|
|
||||||
|
public CAbilityTypeHumanRepairLevelData(EnumSet<CTargetType> targetsAllowed, float navalRangeBonus, float repairCostRatio, float repairTimeRatio, float castRange) {
|
||||||
|
super(targetsAllowed);
|
||||||
|
this.navalRangeBonus = navalRangeBonus;
|
||||||
|
this.repairCostRatio = repairCostRatio;
|
||||||
|
this.repairTimeRatio = repairTimeRatio;
|
||||||
|
this.castRange = castRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getCastRange() {
|
||||||
|
return this.castRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getNavalRangeBonus() {
|
||||||
|
return navalRangeBonus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getRepairCostRatio() {
|
||||||
|
return repairCostRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getRepairTimeRatio() {
|
||||||
|
return repairTimeRatio;
|
||||||
|
}
|
||||||
|
}
|
@ -36,7 +36,7 @@ public abstract class CAbstractRangedBehavior implements CRangedBehavior {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract CBehavior update(CSimulation simulation, boolean withinRange);
|
protected abstract CBehavior update(CSimulation simulation, boolean withinFacingWindow);
|
||||||
|
|
||||||
protected abstract CBehavior updateOnInvalidTarget(CSimulation simulation);
|
protected abstract CBehavior updateOnInvalidTarget(CSimulation simulation);
|
||||||
|
|
||||||
|
@ -71,10 +71,10 @@ public class CBehaviorAttack extends CAbstractRangedBehavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CBehavior update(final CSimulation simulation, final boolean withinRange) {
|
public CBehavior update(final CSimulation simulation, final boolean withinFacingWindow) {
|
||||||
final int cooldownEndTime = this.unit.getCooldownEndTime();
|
final int cooldownEndTime = this.unit.getCooldownEndTime();
|
||||||
final int currentTurnTick = simulation.getGameTurnTick();
|
final int currentTurnTick = simulation.getGameTurnTick();
|
||||||
if (withinRange) {
|
if (withinFacingWindow) {
|
||||||
if (this.damagePointLaunchTime != 0) {
|
if (this.damagePointLaunchTime != 0) {
|
||||||
if (currentTurnTick >= this.damagePointLaunchTime) {
|
if (currentTurnTick >= this.damagePointLaunchTime) {
|
||||||
int minDamage = this.unitAttack.getMinDamage();
|
int minDamage = this.unitAttack.getMinDamage();
|
||||||
|
@ -30,7 +30,7 @@ public class CBehaviorFollow extends CAbstractRangedBehavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CBehavior update(final CSimulation simulation, final boolean withinRange) {
|
protected CBehavior update(final CSimulation simulation, final boolean withinFacingWindow) {
|
||||||
this.unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.STAND, SequenceUtils.EMPTY, 1.0f, false);
|
this.unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.STAND, SequenceUtils.EMPTY, 1.0f, false);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,88 @@
|
|||||||
|
package com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.build;
|
||||||
|
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.*;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityHumanRepair;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetStillAliveAndTargetableVisitor;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CAbstractRangedBehavior;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.harvest.CBehaviorHarvest;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds;
|
||||||
|
|
||||||
|
public class CBehaviorHumanRepair extends CAbstractRangedBehavior {
|
||||||
|
private final CAbilityHumanRepair ability;
|
||||||
|
private AbilityTargetStillAliveAndTargetableVisitor stillAliveVisitor;
|
||||||
|
|
||||||
|
public CBehaviorHumanRepair(CUnit unit, CAbilityHumanRepair ability) {
|
||||||
|
super(unit);
|
||||||
|
this.ability = ability;
|
||||||
|
stillAliveVisitor = new AbilityTargetStillAliveAndTargetableVisitor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CBehaviorHumanRepair reset(final CWidget target) {
|
||||||
|
innerReset(target, false);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWithinRange(CSimulation simulation) {
|
||||||
|
float castRange = ability.getCastRange();
|
||||||
|
if(target instanceof CUnit) {
|
||||||
|
CUnit unitTarget = (CUnit)target;
|
||||||
|
if(unitTarget.getUnitType().getMovementType() == PathingGrid.MovementType.FLOAT) {
|
||||||
|
castRange += ability.getNavalRangeBonus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return unit.canReach(target, castRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CBehavior update(CSimulation simulation, boolean withinFacingWindow) {
|
||||||
|
unit.getUnitAnimationListener().playAnimation(false, AnimationTokens.PrimaryTag.STAND,
|
||||||
|
SequenceUtils.WORK, 1.0f, true);
|
||||||
|
if(this.target instanceof CWidget) {
|
||||||
|
CWidget targetWidget = (CWidget) this.target;
|
||||||
|
float newLifeValue = targetWidget.getLife() + 1;
|
||||||
|
boolean done = newLifeValue > targetWidget.getMaxLife();
|
||||||
|
if(done) {
|
||||||
|
newLifeValue = targetWidget.getMaxLife();
|
||||||
|
}
|
||||||
|
targetWidget.setLife(simulation, newLifeValue);
|
||||||
|
if(done) {
|
||||||
|
return unit.pollNextOrderBehavior(simulation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CBehavior updateOnInvalidTarget(CSimulation simulation) {
|
||||||
|
return unit.pollNextOrderBehavior(simulation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean checkTargetStillValid(CSimulation simulation) {
|
||||||
|
return target.visit(stillAliveVisitor.reset(simulation, unit, ability.getTargetsAllowed()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void resetBeforeMoving(CSimulation simulation) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void begin(CSimulation game) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void end(CSimulation game, boolean interrupted) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endMove(CSimulation game, boolean interrupted) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHighlightOrderId() {
|
||||||
|
return OrderIds.repair;
|
||||||
|
}
|
||||||
|
}
|
@ -45,7 +45,7 @@ public class CBehaviorOrcBuild extends CAbstractRangedBehavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CBehavior update(final CSimulation simulation, final boolean withinRange) {
|
protected CBehavior update(final CSimulation simulation, final boolean withinFacingWindow) {
|
||||||
if (!this.unitCreated) {
|
if (!this.unitCreated) {
|
||||||
this.unitCreated = true;
|
this.unitCreated = true;
|
||||||
final CUnitType unitTypeToCreate = simulation.getUnitData().getUnitType(this.orderId);
|
final CUnitType unitTypeToCreate = simulation.getUnitData().getUnitType(this.orderId);
|
||||||
|
@ -56,7 +56,7 @@ public class CBehaviorUndeadBuild extends CAbstractRangedBehavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CBehavior update(final CSimulation simulation, final boolean withinRange) {
|
protected CBehavior update(final CSimulation simulation, final boolean withinFacingWindow) {
|
||||||
if (this.doneTick != 0) {
|
if (this.doneTick != 0) {
|
||||||
if (simulation.getGameTurnTick() > this.doneTick) {
|
if (simulation.getGameTurnTick() > this.doneTick) {
|
||||||
return this.unit.pollNextOrderBehavior(simulation);
|
return this.unit.pollNextOrderBehavior(simulation);
|
||||||
|
@ -47,7 +47,7 @@ public class CBehaviorHarvest extends CAbstractRangedBehavior
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWithinRange(final CSimulation simulation) {
|
public boolean isWithinRange(final CSimulation simulation) {
|
||||||
return this.unit.canReach(this.target, this.unit.getUnitType().getCollisionSize());
|
return this.unit.canReach(this.target, abilityHarvest.getTreeAttack().getRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,7 +56,7 @@ public class CBehaviorHarvest extends CAbstractRangedBehavior
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CBehavior update(final CSimulation simulation, final boolean withinRange) {
|
protected CBehavior update(final CSimulation simulation, final boolean withinFacingWindow) {
|
||||||
this.simulation = simulation;
|
this.simulation = simulation;
|
||||||
return this.target.visit(this);
|
return this.target.visit(this);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class CBehaviorReturnResources extends CAbstractRangedBehavior implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CBehavior update(final CSimulation simulation, final boolean withinRange) {
|
protected CBehavior update(final CSimulation simulation, final boolean withinFacingWindow) {
|
||||||
this.simulation = simulation;
|
this.simulation = simulation;
|
||||||
return this.target.visit(this);
|
return this.target.visit(this);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public class CBehaviorDropItem extends CAbstractRangedBehavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CBehavior update(final CSimulation simulation, final boolean withinRange) {
|
protected CBehavior update(final CSimulation simulation, final boolean withinFacingWindow) {
|
||||||
this.inventory.dropItem(simulation, this.unit, this.targetItem, this.target.getX(), this.target.getY(), true);
|
this.inventory.dropItem(simulation, this.unit, this.targetItem, this.target.getX(), this.target.getY(), true);
|
||||||
return this.unit.pollNextOrderBehavior(simulation);
|
return this.unit.pollNextOrderBehavior(simulation);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class CBehaviorGetItem extends CAbstractRangedBehavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CBehavior update(final CSimulation simulation, final boolean withinRange) {
|
protected CBehavior update(final CSimulation simulation, final boolean withinFacingWindow) {
|
||||||
final CItem targetItem = this.target.visit(AbilityTargetItemVisitor.INSTANCE);
|
final CItem targetItem = this.target.visit(AbilityTargetItemVisitor.INSTANCE);
|
||||||
this.inventory.giveItem(simulation, this.unit, targetItem, true);
|
this.inventory.giveItem(simulation, this.unit, targetItem, true);
|
||||||
return this.unit.pollNextOrderBehavior(simulation);
|
return this.unit.pollNextOrderBehavior(simulation);
|
||||||
|
@ -10,6 +10,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility;
|
|||||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityGeneric;
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityGeneric;
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType;
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType;
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.CAbilityTypeDefinition;
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.CAbilityTypeDefinition;
|
||||||
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.*;
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.CAbilityTypeDefinitionChannelTest;
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.CAbilityTypeDefinitionChannelTest;
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.CAbilityTypeDefinitionColdArrows;
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.CAbilityTypeDefinitionColdArrows;
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.CAbilityTypeDefinitionCoupleInstant;
|
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.CAbilityTypeDefinitionCoupleInstant;
|
||||||
@ -38,6 +39,7 @@ public class CAbilityData {
|
|||||||
this.codeToAbilityTypeDefinition.put(War3ID.fromString("Ahar"), new CAbilityTypeDefinitionHarvest());
|
this.codeToAbilityTypeDefinition.put(War3ID.fromString("Ahar"), new CAbilityTypeDefinitionHarvest());
|
||||||
this.codeToAbilityTypeDefinition.put(War3ID.fromString("ANcl"), new CAbilityTypeDefinitionChannelTest());
|
this.codeToAbilityTypeDefinition.put(War3ID.fromString("ANcl"), new CAbilityTypeDefinitionChannelTest());
|
||||||
this.codeToAbilityTypeDefinition.put(War3ID.fromString("AInv"), new CAbilityTypeDefinitionInventory());
|
this.codeToAbilityTypeDefinition.put(War3ID.fromString("AInv"), new CAbilityTypeDefinitionInventory());
|
||||||
|
this.codeToAbilityTypeDefinition.put(War3ID.fromString("Arep"), new CAbilityTypeDefinitionHumanRepair());
|
||||||
this.codeToAbilityTypeDefinition.put(War3ID.fromString("Avul"), new CAbilityTypeDefinitionInvulnerable());
|
this.codeToAbilityTypeDefinition.put(War3ID.fromString("Avul"), new CAbilityTypeDefinitionInvulnerable());
|
||||||
this.codeToAbilityTypeDefinition.put(War3ID.fromString("Acoi"), new CAbilityTypeDefinitionCoupleInstant());
|
this.codeToAbilityTypeDefinition.put(War3ID.fromString("Acoi"), new CAbilityTypeDefinitionCoupleInstant());
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class CDestructableData {
|
|||||||
|
|
||||||
final CDestructableType unitTypeInstance = getUnitTypeInstance(typeId, unitType);
|
final CDestructableType unitTypeInstance = getUnitTypeInstance(typeId, unitType);
|
||||||
|
|
||||||
final float life = unitTypeInstance.getLife();
|
final float life = unitTypeInstance.getMaxLife();
|
||||||
|
|
||||||
final CDestructable destructable = new CDestructable(handleId, x, y, life, unitTypeInstance, pathingInstance,
|
final CDestructable destructable = new CDestructable(handleId, x, y, life, unitTypeInstance, pathingInstance,
|
||||||
pathingInstanceDeath);
|
pathingInstanceDeath);
|
||||||
|
@ -55,7 +55,7 @@ public class CItemData {
|
|||||||
final MutableGameObject itemType = this.itemData.get(typeId);
|
final MutableGameObject itemType = this.itemData.get(typeId);
|
||||||
final CItemType itemTypeInstance = getItemTypeInstance(typeId, itemType);
|
final CItemType itemTypeInstance = getItemTypeInstance(typeId, itemType);
|
||||||
|
|
||||||
return new CItem(handleId, x, y, itemTypeInstance.getHitPoints(), typeId, itemTypeInstance);
|
return new CItem(handleId, x, y, itemTypeInstance.getMaxLife(), typeId, itemTypeInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CItemType getItemType(final War3ID typeId) {
|
public CItemType getItemType(final War3ID typeId) {
|
||||||
|
@ -192,7 +192,7 @@ public class CUnitData {
|
|||||||
final int handleId = handleIdAllocator.createId();
|
final int handleId = handleIdAllocator.createId();
|
||||||
|
|
||||||
final CUnitType unitTypeInstance = getUnitTypeInstance(typeId, buildingPathingPixelMap, unitType);
|
final CUnitType unitTypeInstance = getUnitTypeInstance(typeId, buildingPathingPixelMap, unitType);
|
||||||
final int life = unitTypeInstance.getLife();
|
final int life = unitTypeInstance.getMaxLife();
|
||||||
final int manaInitial = unitTypeInstance.getManaInitial();
|
final int manaInitial = unitTypeInstance.getManaInitial();
|
||||||
final int manaMaximum = unitTypeInstance.getManaMaximum();
|
final int manaMaximum = unitTypeInstance.getManaMaximum();
|
||||||
final int speed = unitTypeInstance.getSpeed();
|
final int speed = unitTypeInstance.getSpeed();
|
||||||
|
Loading…
Reference in New Issue
Block a user