Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Human and NightElf Build #5

Open
wants to merge 6 commits into
base: experimental
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@ public class CUnitType {
private final boolean revivesHeroes;

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 boolean isBldg, final MovementType movementType, final float defaultFlyingHeight,
final float collisionSize, final EnumSet<CUnitClassification> classifications,
final List<CUnitAttack> attacks, final String armorType, final boolean raise, final boolean decay,
final CDefenseType defenseType, final float impactZ, final BufferedImage buildingPathingPixelMap,
final float deathTime, final EnumSet<CTargetType> targetedAs, final float defaultAcquisitionRange,
final float minimumAttackRange, final List<War3ID> structuresBuilt, final List<War3ID> unitsTrained,
final List<War3ID> researchesAvailable, final CUnitRace unitRace, final int goldCost, final int lumberCost,
final int foodUsed, final int foodMade, final int buildTime,
final EnumSet<CBuildingPathingType> preventedPathingTypes,
final EnumSet<CBuildingPathingType> requiredPathingTypes, final float propWindow, final float turnRate,
final List<CUnitTypeRequirement> requirements, final int level, final boolean hero, final int strength,
final float strengthPerLevel, final int agility, final float agilityPerLevel, final int intelligence,
final float intelligencePerLevel, final CPrimaryAttribute primaryAttribute,
final List<War3ID> heroAbilityList, final List<String> heroProperNames, final int properNamesCount,
final boolean canFlee, final int priority, final boolean revivesHeroes) {
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 float collisionSize, final EnumSet<CUnitClassification> classifications,
final List<CUnitAttack> attacks, final String armorType, final boolean raise, final boolean decay,
final CDefenseType defenseType, final float impactZ, final BufferedImage buildingPathingPixelMap,
final float deathTime, final EnumSet<CTargetType> targetedAs, final float defaultAcquisitionRange,
final float minimumAttackRange, final List<War3ID> structuresBuilt, final List<War3ID> unitsTrained,
final List<War3ID> researchesAvailable, final CUnitRace unitRace, final int goldCost, final int lumberCost,
final int foodUsed, final int foodMade, final int buildTime,
final EnumSet<CBuildingPathingType> preventedPathingTypes,
final EnumSet<CBuildingPathingType> requiredPathingTypes, final float propWindow, final float turnRate,
final List<CUnitTypeRequirement> requirements, final int level, final boolean hero, final int strength,
final float strengthPerLevel, final int agility, final float agilityPerLevel, final int intelligence,
final float intelligencePerLevel, final CPrimaryAttribute primaryAttribute,
final List<War3ID> heroAbilityList, final List<String> heroProperNames, final int properNamesCount,
final boolean canFlee, final int priority, final boolean revivesHeroes) {
this.name = name;
this.legacyName = legacyName;
this.typeId = typeId;
Expand Down Expand Up @@ -365,4 +365,4 @@ public int getPriority() {
public boolean isRevivesHeroes() {
return this.revivesHeroes;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void onTick(final CSimulation game, final CUnit unit) {
public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, AbilityTarget target) {
final CPlayer player = game.getPlayer(caster.getPlayerIndex());
player.refundFor(caster.getUnitType());
caster.setConstructionCanceled(true);
caster.setLife(game, 0);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build;

import java.awt.image.BufferedImage;
import java.util.List;

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.CUnitType;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor;
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.CBehaviorHumanBuild;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.build.CBehaviorNightElfBuild;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer;

public class CAbilityHumanBuild extends AbstractCAbilityBuild {
private CBehaviorHumanBuild buildBehavior;

public CAbilityHumanBuild(final int handleId, final List<War3ID> structuresBuilt) {
super(handleId, structuresBuilt);
// TODO Auto-generated constructor stub
}

@Override
Expand All @@ -25,8 +30,7 @@ public int getBaseOrderId() {

@Override
public void onAdd(final CSimulation game, final CUnit unit) {
// TODO Auto-generated method stub

this.buildBehavior = new CBehaviorHumanBuild(unit);
}

@Override
Expand All @@ -37,21 +41,37 @@ public void onRemove(final CSimulation game, final CUnit unit) {

@Override
public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) {
// TODO Auto-generated method stub
return null;
return caster.pollNextOrderBehavior(game);
}

@Override
public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId,
final AbilityPointTarget point) {
// caster.getMoveBehavior().reset(point.x, point.y, )
return null;
final War3ID orderIdAsRawtype = new War3ID(orderId);
final CUnitType unitType = game.getUnitData().getUnitType(orderIdAsRawtype);
final BufferedImage buildingPathingPixelMap = unitType.getBuildingPathingPixelMap();
if (buildingPathingPixelMap != null) {
point.x = (float) Math.floor(point.x / 64f) * 64f;
point.y = (float) Math.floor(point.y / 64f) * 64f;
if (((buildingPathingPixelMap.getWidth() / 2) % 2) == 1) {
point.x += 32f;
}
if (((buildingPathingPixelMap.getHeight() / 2) % 2) == 1) {
point.y += 32f;
}
}
final CPlayer player = game.getPlayer(caster.getPlayerIndex());
player.chargeFor(unitType);
if (unitType.getFoodUsed() != 0) {
player.setFoodUsed(player.getFoodUsed() + unitType.getFoodUsed());
}
return this.buildBehavior.reset(point, orderId, getBaseOrderId());
}

@Override
public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) {
// TODO Auto-generated method stub
return null;
return caster.pollNextOrderBehavior(game);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ public class CAbilityHumanRepair extends AbstractGenericSingleIconActiveAbility
private final float repairCostRatio;
private final float repairTimeRatio;
private final float castRange;
private final float powerBuildCostRatio;
private final float powerBuildTimeRatio;
private CBehaviorHumanRepair behaviorRepair;

/*
//old version left in for compatibility
public CAbilityHumanRepair(int handleId, War3ID alias, EnumSet<CTargetType> targetsAllowed,
float navalRangeBonus, float repairCostRatio, float repairTimeRatio,
float castRange) {
Expand All @@ -32,6 +36,21 @@ public CAbilityHumanRepair(int handleId, War3ID alias, EnumSet<CTargetType> targ
this.repairCostRatio = repairCostRatio;
this.repairTimeRatio = repairTimeRatio;
this.castRange = castRange;
this.powerBuildCostRatio = 0;
this.powerBuildTimeRatio = 0;
}*/

public CAbilityHumanRepair(int handleId, War3ID alias, EnumSet<CTargetType> targetsAllowed,
float navalRangeBonus, float repairCostRatio, float repairTimeRatio,
float castRange, float powerBuildCostRatio, float powerBuildTimeRatio) {
super(handleId, alias);
this.targetsAllowed = targetsAllowed;
this.navalRangeBonus = navalRangeBonus;
this.repairCostRatio = repairCostRatio;
this.repairTimeRatio = repairTimeRatio;
this.castRange = castRange;
this.powerBuildCostRatio = powerBuildCostRatio;
this.powerBuildTimeRatio = powerBuildTimeRatio;
}

@Override
Expand Down Expand Up @@ -132,4 +151,8 @@ public float getRepairTimeRatio() {
public float getCastRange() {
return castRange;
}

public float getPowerBuildCostRatio() { return powerBuildCostRatio; }

public float getPowerBuildTimeRatio() { return powerBuildTimeRatio; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor;
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.CBehaviorNightElfBuild;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.build.CBehaviorOrcBuild;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer;

public class CAbilityNightElfBuild extends AbstractCAbilityBuild {
private CBehaviorOrcBuild buildBehavior;
private CBehaviorNightElfBuild buildBehavior;

public CAbilityNightElfBuild(final int handleId, final List<War3ID> structuresBuilt) {
super(handleId, structuresBuilt);
Expand All @@ -29,7 +30,7 @@ public <T> T visit(final CAbilityVisitor<T> visitor) {

@Override
public void onAdd(final CSimulation game, final CUnit unit) {
this.buildBehavior = new CBehaviorOrcBuild(unit);
this.buildBehavior = new CBehaviorNightElfBuild(unit);
}

@Override
Expand Down Expand Up @@ -74,4 +75,9 @@ public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final
public int getBaseOrderId() {
return OrderIds.nightelfbuild;
}

@Override
public void onCancelFromQueue(CSimulation game, CUnit unit, int orderId) {
super.onCancelFromQueue(game, unit, orderId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class CAbilityTypeDefinitionHumanRepair extends AbstractCAbilityTypeDefin
implements CAbilityTypeDefinition {
protected static final War3ID COST_RATIO = War3ID.fromString("Rep1");
protected static final War3ID TIME_RATIO = War3ID.fromString("Rep2");
protected static final War3ID POWER_COST_RATIO = War3ID.fromString("Rep3");
protected static final War3ID POWER_TIME_RATIO = War3ID.fromString("Rep4");
protected static final War3ID NAVAL_RANGE_BONUS = War3ID.fromString("Rep5");

@Override
Expand All @@ -23,9 +25,11 @@ protected CAbilityTypeHumanRepairLevelData createLevelData(final MutableGameObje
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 powerBuildCostRatio = abilityEditorData.getFieldAsFloat(POWER_COST_RATIO,level);
final float powerBuildTimeRatio = abilityEditorData.getFieldAsFloat(POWER_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);
return new CAbilityTypeHumanRepairLevelData(targetsAllowedAtLevel, navalRangeBonus, costRatio, timeRatio, castRange, powerBuildCostRatio, powerBuildTimeRatio);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ public CAbilityTypeHumanRepair(final War3ID alias, final War3ID code,
@Override
public CAbility createAbility(final int handleId) {
final CAbilityTypeHumanRepairLevelData levelData = getLevelData(0);
//System.out.println("Time: "+levelData.getPowerbuildTimeRatio() + " Cost: " + levelData.getPowerbuildCostRatio() );
return new CAbilityHumanRepair(handleId, getAlias(), levelData.getTargetsAllowed(),
levelData.getNavalRangeBonus(), levelData.getRepairCostRatio(), levelData.getRepairTimeRatio(),
levelData.getCastRange());
levelData.getCastRange(), levelData.getPowerbuildCostRatio(), levelData.getPowerbuildTimeRatio());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ public class CAbilityTypeHumanRepairLevelData extends CAbilityTypeLevelData {
private final float navalRangeBonus;
private final float repairCostRatio;
private final float repairTimeRatio;
private final float powerbuildCostRatio;
private final float powerbuildTimeRatio;
private final float castRange;

public CAbilityTypeHumanRepairLevelData(EnumSet<CTargetType> targetsAllowed, float navalRangeBonus, float repairCostRatio, float repairTimeRatio, float castRange) {
public CAbilityTypeHumanRepairLevelData(EnumSet<CTargetType> targetsAllowed, float navalRangeBonus, float repairCostRatio,
float repairTimeRatio, float castRange, float powerBuildCostRatio, float powerBuildTimeRatio) {
super(targetsAllowed);
this.navalRangeBonus = navalRangeBonus;
this.repairCostRatio = repairCostRatio;
this.repairTimeRatio = repairTimeRatio;
this.powerbuildCostRatio = powerBuildCostRatio;
this.powerbuildTimeRatio = powerBuildTimeRatio;
this.castRange = castRange;
}

Expand All @@ -35,4 +40,8 @@ public float getRepairCostRatio() {
public float getRepairTimeRatio() {
return repairTimeRatio;
}

public float getPowerbuildCostRatio(){ return powerbuildCostRatio; };

public float getPowerbuildTimeRatio() { return powerbuildTimeRatio; }
}
Loading