-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented a custom radial version of Mekanism's "Attack Amplificati…
…on Unit" and reworked damage/energy evaluation. Now attack damage increases with available energy and bonus attack damage (which in turn depends on the enabled mekaweapons:attackamplification_unit(s)). For example, let's say we have enough units installed to select "High (16)": - energy < defaultEnergyUsage --> attackDamage = 0 - defaultEnergyUsage <= energy < energyNeeded --> baseDamage (=50) <= attackDamage < baseDamage * damageMultiplicator (=150) - energyNeeded <= energy --> attackDamage = baseDamage * damageMultiplicator (=150) Korean(ko_kr) and Chinese(zh_cn) translations are not implemented.
- Loading branch information
1 parent
12462cc
commit fafa50e
Showing
19 changed files
with
411 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package meranha.mekaweapons; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import mekanism.api.energy.IEnergyContainer; | ||
import mekanism.api.gear.IModule; | ||
import mekanism.api.math.MathUtils; | ||
import mekanism.common.util.StorageUtils; | ||
import meranha.mekaweapons.items.ModuleWeaponAttackAmplificationUnit; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
public class MekaWeaponsUtils { | ||
public static long getTotalDamage(@NotNull ItemStack stack, @Nullable IModule<ModuleWeaponAttackAmplificationUnit> attackAmplificationUnit, int baseDamage, long energyUsage) { | ||
IEnergyContainer energyContainer = StorageUtils.getEnergyContainer(stack, 0); | ||
long energy = energyContainer != null ? energyContainer.getEnergy() : 0; | ||
if(energy < energyUsage) { | ||
return -1; | ||
} | ||
|
||
double damage = baseDamage; | ||
if (attackAmplificationUnit != null) { | ||
int unitDamage = attackAmplificationUnit.getCustomInstance().getDamage(); | ||
if (unitDamage > 0) { | ||
double additionalDamage = baseDamage * attackAmplificationUnit.getCustomInstance().getDamageMultiplicator(); | ||
long energyCost = getEnergyNeeded(energyUsage, unitDamage); | ||
// todo always max damage if in creative | ||
if (energy < energyCost){ | ||
//If we don't have enough power use it at a reduced power level (this will be false the majority of the time) | ||
damage += additionalDamage * MathUtils.divideToLevel(energy - energyUsage, energyCost - energyUsage); | ||
} else { | ||
damage += additionalDamage; | ||
} | ||
} | ||
} | ||
|
||
return Math.round(damage) - 1; | ||
} | ||
|
||
public static long getEnergyNeeded(@Nullable IModule<ModuleWeaponAttackAmplificationUnit> attackAmplificationUnit, long energyUsage) { | ||
if (attackAmplificationUnit != null) { | ||
return getEnergyNeeded(energyUsage, attackAmplificationUnit.getCustomInstance().getDamage()); | ||
} | ||
return MekaWeapons.general.mekaBowEnergyUsage.get(); | ||
} | ||
|
||
private static long getEnergyNeeded(double energyUsage, int unitDamage) { | ||
return MathUtils.clampToLong(energyUsage * (1 + unitDamage / 4F)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.