Blight affect trees, acolyte ring base, and other small fixes

This commit is contained in:
Retera 2022-01-23 03:57:53 -05:00
parent b5cab399b6
commit df64211678
8 changed files with 61 additions and 21 deletions

View File

@ -36,7 +36,7 @@ public class WarsmashConstants {
// workaround to fix it if you need the local files
// to take priority over built-ins for tilesets.
public static final boolean FIX_FLAT_FILES_TILESET_LOADING = false;
public static final boolean ENABLE_MUSIC = true;
public static final boolean ENABLE_MUSIC = false;
public static final boolean LOAD_UNITS_FROM_WORLDEDIT_DATA = false;
public static final boolean CRASH_ON_INCOMPATIBLE_132_FEATURES = false;
public static final boolean FIRE_DEATH_EVENTS_ON_REMOVEUNIT = false;

View File

@ -100,6 +100,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.rendersim.RenderWidget;
import com.etheller.warsmash.viewer5.handlers.w3x.rendersim.ability.AbilityDataUI;
import com.etheller.warsmash.viewer5.handlers.w3x.rendersim.ability.AbilityUI;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructableEnumFunction;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit;
@ -920,6 +921,25 @@ public class War3MapViewer extends AbstractMdxModelViewer {
return null;
}
@Override
public void createSpellEffectFacing(final War3ID alias, final float harvestStandX,
final float harvestStandY, final float angle) {
final AbilityUI abilityUI = War3MapViewer.this.abilityDataUI.getUI(alias);
final String effectPath = abilityUI.getEffectArt(0);
final MdxModel spawnedEffectModel = loadModelMdx(effectPath);
if (spawnedEffectModel != null) {
final MdxComplexInstance modelInstance = (MdxComplexInstance) spawnedEffectModel
.addInstance();
modelInstance.setLocation(harvestStandX, harvestStandY,
War3MapViewer.this.terrain.getGroundHeight(harvestStandX, harvestStandY));
modelInstance.setScene(War3MapViewer.this.worldScene);
final RenderSpellEffect renderAttackInstant = new RenderSpellEffect(modelInstance,
War3MapViewer.this, angle, RenderSpellEffect.DEFAULT_ANIMATION_QUEUE);
renderAttackInstant.setAnimations(RenderSpellEffect.STAND_ONLY, false);
War3MapViewer.this.projectiles.add(renderAttackInstant);
}
}
@Override
public void spawnUnitReadySound(final CUnit trainedUnit) {
final RenderUnit renderPeer = War3MapViewer.this.unitToRenderPeer.get(trainedUnit);
@ -2541,5 +2561,20 @@ public class War3MapViewer extends AbstractMdxModelViewer {
final Rectangle blightRectangleCellUnits = new Rectangle(cellMinX, cellMinY, cellMaxX - cellMinX,
cellMaxY - cellMinY);
this.terrain.updateGroundTextures(blightRectangleCellUnits);
if (blighted) {
this.simulation.getWorldCollision().enumDestructablesInRect(blightRectangle,
new CDestructableEnumFunction() {
@Override
public boolean call(final CDestructable destructable) {
final boolean checkIsOnBlight = destructable.checkIsOnBlight(War3MapViewer.this.simulation);
if (checkIsOnBlight) {
// no mechanic to unblight so this is intentionally one-way
destructable.setBlighted(true);
}
return false;
}
});
}
}
}

View File

@ -602,6 +602,11 @@ public class CSimulation implements CPlayerAPI {
artAttachmentHeight);
}
public void createSpellEffectFacing(final War3ID alias, final float harvestStandX, final float harvestStandY,
final float angle) {
this.simulationRenderController.createSpellEffectFacing(alias, harvestStandX, harvestStandY, angle);
}
public void tagTreeOwned(final CDestructable target) {
this.ownedTreeSet.add(target);
}

View File

@ -29,11 +29,9 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.hero.CAbi
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.inventory.CAbilityInventory;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.mine.CAbilityBlightedGoldMine;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.mine.CAbilityGoldMine;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityQueue;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.upgrade.CAbilityUpgrade;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorAttack;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorAttackListener;
@ -310,18 +308,12 @@ public class CUnit extends CWidget {
this.classifications.addAll(this.unitType.getClassifications());
this.acquisitionRange = this.unitType.getDefaultAcquisitionRange();
for (final CAbility ability : this.abilities) {
if (ability instanceof CAbilityQueue) {
((CAbilityQueue) ability).onSetUnitType(this.unitType);
}
else if (ability instanceof CAbilityUpgrade) {
((CAbilityUpgrade) ability).onSetUnitType(this.unitType);
}
else {
// refresh abilities...
ability.onRemove(game, this);
ability.onAdd(game, this);
}
ability.onRemove(game, this);
game.onAbilityRemovedFromUnit(this, ability);
}
this.abilities.clear();
game.getUnitData().addDefaultAbilitiesToUnit(game, game.getHandleIdAllocator(), this.unitType, false, -1,
this.speed, this);
computeDerivedFields();
}

View File

@ -54,6 +54,7 @@ public class CAbilityBlightedGoldMine extends AbstractGenericNoIconAbility {
final float harvestStandY = unit.getY()
+ (float) (StrictMath.sin(thisMinerAngle) * this.radiusOfMiningRing);
this.minerLocs[i] = new Vector2(harvestStandX, harvestStandY);
game.createSpellEffectFacing(getAlias(), harvestStandX, harvestStandY, (float) (thisMinerAngle));
}
}
@ -158,7 +159,7 @@ public class CAbilityBlightedGoldMine extends AbstractGenericNoIconAbility {
if (this.activeMiners[i] == null) {
final double thisMineDistSq = acolyte.distanceSquaredNoCollision(this.minerLocs[i].x,
this.minerLocs[i].y);
if (minerDistSq > thisMineDistSq) {
if (thisMineDistSq < minerDistSq) {
minerIndex = i;
minerDistSq = thisMineDistSq;
}

View File

@ -1,5 +1,6 @@
package com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.harvest;
import com.badlogic.gdx.math.Vector2;
import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag;
import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation;
@ -66,11 +67,9 @@ public class CBehaviorAcolyteHarvest extends CAbstractRangedBehavior {
return HarvestStartResult.DENIED;
}
final double angleSize = (StrictMath.PI * 2) / abilityBlightedGoldMine.getMaxNumberOfMiners();
final float radiusOfMiningRing = abilityBlightedGoldMine.getRadiusOfMiningRing();
final double thisMinerAngle = angleSize * newIndex;
this.harvestStandX = targetUnit.getX() + (float) (StrictMath.cos(thisMinerAngle) * radiusOfMiningRing);
this.harvestStandY = targetUnit.getY() + (float) (StrictMath.sin(thisMinerAngle) * radiusOfMiningRing);
final Vector2 minerLoc = abilityBlightedGoldMine.getMinerLoc(newIndex);
this.harvestStandX = minerLoc.x;
this.harvestStandY = minerLoc.y;
simulation.unitSoundEffectEvent(this.unit, this.abilityAcolyteHarvest.getAlias());
return HarvestStartResult.ACCEPTED;
}

View File

@ -220,6 +220,13 @@ public class CUnitData {
final CUnit unit = new CUnit(handleId, playerIndex, x, y, life, typeId, facing, manaInitial, life, lifeRegen,
manaMaximum, speed, unitTypeInstance, pathingInstance);
addDefaultAbilitiesToUnit(simulation, handleIdAllocator, unitTypeInstance, true, manaInitial, speed, unit);
return unit;
}
public void addDefaultAbilitiesToUnit(final CSimulation simulation, final HandleIdAllocator handleIdAllocator,
final CUnitType unitTypeInstance, final boolean resetMana, final int manaInitial, final int speed,
final CUnit unit) {
if (speed > 0) {
unit.add(simulation, new CAbilityMove(handleIdAllocator.createId()));
}
@ -288,7 +295,6 @@ public class CUnitData {
}
}
}
return unit;
}
private CUnitType getUnitTypeInstance(final War3ID typeId, final BufferedImage buildingPathingPixelMap,

View File

@ -85,4 +85,6 @@ public interface SimulationRenderController {
void unitCancelUpgradingEvent(CUnit unit, War3ID upgradeIdType);
void setBlight(float x, float y, float radius, boolean blighted);
void createSpellEffectFacing(War3ID alias, float harvestStandX, float harvestStandY, float angle);
}