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 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public class CUnit extends CWidget {
private float constructionProgress;
//added by MfromAz - if it's bad that's on me
private ConstructionFlag constuctionProcessType;
private boolean constructionPowerBuild = false;
private boolean hidden = false;
private boolean paused = false;
private boolean acceptingOrders = true;
Expand Down Expand Up @@ -268,6 +269,10 @@ public void setConsumed(boolean consumed){

public void setConstuctionProcessType(ConstructionFlag flag) {this.constuctionProcessType = flag;}

public void setConstructionPowerBuild(boolean constructionPowerBuild){this.constructionPowerBuild= constructionPowerBuild;}

public boolean isConstructionPowerBuilding(){return constructionPowerBuild;}

/**
* Updates one tick of simulation logic and return true if it's time to remove
* this unit from the game.
Expand Down Expand Up @@ -340,12 +345,19 @@ else if (!this.paused) {
setRallyPoint(this);
}
if (this.constructing) {
this.constructionProgress += WarsmashConstants.SIMULATION_STEP_TIME;


final int buildTime = this.unitType.getBuildTime();
//ignore this for human build (MFROMAZ)
final float healthGain = (WarsmashConstants.SIMULATION_STEP_TIME / buildTime)
* (this.maximumLife * (1.0f - WarsmashConstants.BUILDING_CONSTRUCT_START_LIFE));
setLife(game, Math.min(this.life + healthGain, this.maximumLife));
if(this.constuctionProcessType==null||this.constuctionProcessType!=ConstructionFlag.REQURIE_REPAIR) {
this.constructionProgress += WarsmashConstants.SIMULATION_STEP_TIME;
final float healthGain = (WarsmashConstants.SIMULATION_STEP_TIME / buildTime)
* (this.maximumLife * (1.0f - WarsmashConstants.BUILDING_CONSTRUCT_START_LIFE));
setLife(game, Math.min(this.life + healthGain, this.maximumLife));
}else{
this.constructionPowerBuild = false;
//resetting here every frame so that workers can set it to true on the next one again
}
if (this.constructionProgress >= buildTime) {
this.constructing = false;
this.constructionProgress = 0;
Expand All @@ -359,6 +371,7 @@ else if (!this.paused) {
}

//create Blight here (MFROMAZ)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you creating blight here? That would be cool, but I get the impression this might only be a dangling comment. I think that when your commit was authored, I did not have blight in the engine. However, at this point the experimental branch implements the ability code 'Abli' with the outward growth at high speed when a building finishes construction. (As an example, see this video at time 1:26)


final Iterator<CAbility> abilityIterator = this.abilities.iterator();
while (abilityIterator.hasNext()) {
final CAbility ability = abilityIterator.next();
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 @@ -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