469 lines
15 KiB
Java

package com.hbm.handler.guncfg;
import java.util.ArrayList;
import com.hbm.entity.projectile.EntityBulletBase;
import com.hbm.handler.BulletConfigSyncingUtil;
import com.hbm.handler.BulletConfiguration;
import com.hbm.handler.CasingEjector;
import com.hbm.handler.GunConfiguration;
import com.hbm.interfaces.IBulletHitBehavior;
import com.hbm.interfaces.IBulletImpactBehavior;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.items.ModItems;
import com.hbm.items.ItemAmmoEnums.Ammo50BMG;
import com.hbm.items.ItemAmmoEnums.AmmoLunaticSniper;
import com.hbm.lib.HbmCollection;
import com.hbm.lib.HbmCollection.EnumGunManufacturer;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.particle.SpentCasing;
import com.hbm.particle.SpentCasing.CasingType;
import com.hbm.potion.HbmPotion;
import com.hbm.render.anim.BusAnimation;
import com.hbm.render.anim.BusAnimationKeyframe;
import com.hbm.render.anim.BusAnimationSequence;
import com.hbm.render.anim.HbmAnimations.AnimType;
import com.hbm.render.util.RenderScreenOverlay.Crosshair;
import com.hbm.util.ContaminationUtil;
import com.hbm.util.ContaminationUtil.ContaminationType;
import com.hbm.util.ContaminationUtil.HazardType;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
public class Gun50BMGFactory {
private static final CasingEjector EJECTOR_BMG;
private static final CasingEjector EJECTOR_SNIPER;
private static final SpentCasing CASING50BMG;
private static final SpentCasing CASINGLUNA;
static {
EJECTOR_BMG = new CasingEjector().setMotion(-0.35, 0.9, 0).setOffset(-0.45, -0.2, 0.35).setAngleRange(0.01F, 0.05F);
EJECTOR_SNIPER = new CasingEjector().setMotion(-2, 0.15, 0).setOffset(-0.45, -0.2, 0.35).setAngleRange(0.02F, 0.05F);
CASING50BMG = new SpentCasing(CasingType.BOTTLENECK).setScale(3F).setBounceMotion(0.01F, 0.05F).setColor(SpentCasing.COLOR_CASE_BRASS);
CASINGLUNA = new SpentCasing(CasingType.BOTTLENECK).setScale(4F).setBounceMotion(0.02F, 0.05F).setColor(SpentCasing.COLOR_CASE_BRASS);
}
public static GunConfiguration getCalamityConfig() {
GunConfiguration config = new GunConfiguration();
config.rateOfFire = 1;
config.roundsPerCycle = 1;
config.gunMode = GunConfiguration.MODE_NORMAL;
config.firingMode = GunConfiguration.FIRE_AUTO;
config.reloadDuration = 20;
config.firingDuration = 0;
config.ammoCap = 50;
config.reloadType = GunConfiguration.RELOAD_FULL;
config.allowsInfinity = true;
config.crosshair = Crosshair.NONE;
config.durability = 15 * 50 * 10; //15 * capacity * default wear
config.reloadSound = GunConfiguration.RSOUND_MAG;
config.firingSound = "hbm:weapon.calShoot";
config.reloadSoundEnd = false;
config.animations.put(AnimType.CYCLE, new BusAnimation()
.addBus("RECOIL", new BusAnimationSequence()
.addKeyframe(new BusAnimationKeyframe(1, 0, 0, 25))
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 75))
)
);
config.animations.put(AnimType.RELOAD, new BusAnimation()
.addBus("MAG", new BusAnimationSequence()
.addKeyframe(new BusAnimationKeyframe(0, -1, 0, 500))
.addKeyframe(new BusAnimationKeyframe(0, 0, 0, 500))
)
);
config.name = "mg42";
config.manufacturer = EnumGunManufacturer.WGW;
config.config = HbmCollection.fiftyBMG;
config.ejector = EJECTOR_BMG;
return config;
}
public static GunConfiguration getSaddleConfig() {
GunConfiguration config = new GunConfiguration();
config.rateOfFire = 3;
config.roundsPerCycle = 1;
config.gunMode = GunConfiguration.MODE_NORMAL;
config.firingMode = GunConfiguration.FIRE_AUTO;
config.reloadDuration = 30;
config.firingDuration = 0;
config.ammoCap = 100;
config.reloadType = GunConfiguration.RELOAD_FULL;
config.allowsInfinity = true;
config.crosshair = Crosshair.L_BOX;
config.durability = 3500;
config.reloadSound = GunConfiguration.RSOUND_MAG;
config.firingSound = "hbm:weapon.calShoot";
config.name = "maximDouble";
config.manufacturer = EnumGunManufacturer.UNKNOWN;
config.config = HbmCollection.fiftyBMG;
config.ejector = EJECTOR_BMG;
return config;
}
public static BulletConfiguration getLunaticSabotRound() {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_luna_sniper.stackFromEnum(AmmoLunaticSniper.SABOT));
bullet.spread = 0.0F;
bullet.dmgMax = 500F;
bullet.dmgMin = 450F;
bullet.headshotMult = 2.5f;
bullet.wear = 2000;
bullet.velocity = 100;
bullet.doesPenetrate = true;
bullet.leadChance = 20;
bullet.incendiary = 10;
bullet.blockDamage = true;
bullet.bImpact = (projectile, x, y, z) -> projectile.worldObj.newExplosion(projectile, x, y, z, 5.0F, true, false);
bullet.spentCasing = CASINGLUNA.clone().register("LunaStock");
return bullet;
}
public static BulletConfiguration getLunaticIncendiaryRound() {
BulletConfiguration bullet = getLunaticSabotRound().clone();
bullet.ammo = new ComparableStack(ModItems.ammo_luna_sniper.stackFromEnum(AmmoLunaticSniper.INCENDIARY));
bullet.ammo.meta = 1;
bullet.incendiary = 50;
bullet.spentCasing = CASINGLUNA.clone().register("LunaInc");
return bullet;
}
public static BulletConfiguration getLunaticExplosiveRound() {
BulletConfiguration bullet = getLunaticSabotRound().clone();
bullet.ammo = new ComparableStack(ModItems.ammo_luna_sniper.stackFromEnum(AmmoLunaticSniper.EXPLOSIVE));
bullet.ammo.meta = 2;
bullet.explosive = 25;
bullet.bImpact = (projectile, x, y, z) -> projectile.worldObj.newExplosion(projectile, x, y, z, 25.0F, true, false);
bullet.spentCasing = CASINGLUNA.clone().register("LunaExp");
return bullet;
}
public static GunConfiguration getAR15Config() {
GunConfiguration config = new GunConfiguration();
config.rateOfFire = 1;
config.roundsPerCycle = 1;
config.gunMode = GunConfiguration.MODE_NORMAL;
config.firingMode = GunConfiguration.FIRE_AUTO;
config.reloadDuration = 20;
config.firingDuration = 0;
config.ammoCap = 50;
config.reloadType = GunConfiguration.RELOAD_FULL;
config.allowsInfinity = true;
config.crosshair = Crosshair.NONE;
config.durability = 100000;
config.reloadSound = GunConfiguration.RSOUND_MAG;
config.firingSound = "hbm:turret.howard_fire";
config.name = "ar15_50";
config.manufacturer = EnumGunManufacturer.ARMALITE;
config.config = new ArrayList<Integer>();
config.config.add(BulletConfigSyncingUtil.BMG50_FLECHETTE_AM);
config.config.add(BulletConfigSyncingUtil.BMG50_FLECHETTE_PO);
config.config.add(BulletConfigSyncingUtil.BMG50_FLECHETTE_NORMAL);
config.config.add(BulletConfigSyncingUtil.BMG50_NORMAL);
config.config.add(BulletConfigSyncingUtil.BMG50_INCENDIARY);
config.config.add(BulletConfigSyncingUtil.BMG50_PHOSPHORUS);
config.config.add(BulletConfigSyncingUtil.BMG50_EXPLOSIVE);
config.config.add(BulletConfigSyncingUtil.BMG50_AP);
config.config.add(BulletConfigSyncingUtil.BMG50_DU);
config.config.add(BulletConfigSyncingUtil.BMG50_STAR);
config.config.add(BulletConfigSyncingUtil.CHL_BMG50);
config.config.add(BulletConfigSyncingUtil.BMG50_SLEEK);
config.ejector = EJECTOR_BMG;
return config;
}
static float inaccuracy = 2.5F;
public static BulletConfiguration get50BMGConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_50bmg.stackFromEnum(Ammo50BMG.STOCK));
bullet.spread *= inaccuracy;
bullet.dmgMin = 30;
bullet.dmgMax = 36;
bullet.spentCasing = CASING50BMG.clone().register("50BMGStock");
return bullet;
}
public static BulletConfiguration get50BMGFireConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_50bmg.stackFromEnum(Ammo50BMG.INCENDIARY));
bullet.spread *= inaccuracy;
bullet.dmgMin = 30;
bullet.dmgMax = 36;
bullet.wear = 15;
bullet.incendiary = 5;
bullet.spentCasing = CASING50BMG.clone().register("50BMGInc");
return bullet;
}
public static BulletConfiguration get50BMGPhosphorusConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_50bmg.stackFromEnum(Ammo50BMG.PHOSPHORUS));
bullet.spread *= inaccuracy;
bullet.dmgMin = 30;
bullet.dmgMax = 36;
bullet.wear = 15;
bullet.incendiary = 5;
bullet.doesPenetrate = false;
PotionEffect eff = new PotionEffect(HbmPotion.phosphorus.id, 20 * 20, 0, true);
eff.getCurativeItems().clear();
bullet.effects = new ArrayList();
bullet.effects.add(new PotionEffect(eff));
bullet.bImpact = new IBulletImpactBehavior() {
@Override
public void behaveBlockHit(EntityBulletBase bullet, int x, int y, int z) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "vanillaburst");
data.setString("mode", "flame");
data.setInteger("count", 15);
data.setDouble("motion", 0.05D);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, bullet.posX, bullet.posY, bullet.posZ), new TargetPoint(bullet.dimension, bullet.posX, bullet.posY, bullet.posZ, 50));
}
};
bullet.spentCasing = CASING50BMG.clone().register("50BMGPhos");
return bullet;
}
public static BulletConfiguration get50BMGExplosiveConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_50bmg.stackFromEnum(Ammo50BMG.EXPLOSIVE));
bullet.spread *= inaccuracy;
bullet.dmgMin = 60;
bullet.dmgMax = 64;
bullet.wear = 25;
bullet.explosive = 1;
bullet.spentCasing = CASING50BMG.clone().register("50BMGExp");
return bullet;
}
public static BulletConfiguration get50BMGAPConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_50bmg.stackFromEnum(Ammo50BMG.AP));
bullet.spread *= inaccuracy;
bullet.dmgMin = 62;
bullet.dmgMax = 68;
bullet.wear = 15;
bullet.leadChance = 10;
bullet.spentCasing = CASING50BMG.clone().register("50BMGAP");
return bullet;
}
public static BulletConfiguration get50BMGDUConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_50bmg.stackFromEnum(Ammo50BMG.DU));
bullet.spread *= inaccuracy;
bullet.dmgMin = 80;
bullet.dmgMax = 86;
bullet.wear = 25;
bullet.leadChance = 50;
bullet.spentCasing = CASING50BMG.clone().register("50BMGDU");
return bullet;
}
public static BulletConfiguration get50BMGStarConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_50bmg.stackFromEnum(Ammo50BMG.STAR));
bullet.spread *= inaccuracy;
bullet.dmgMin = 98;
bullet.dmgMax = 102;
bullet.wear = 25;
bullet.leadChance = 100;
bullet.spentCasing = CASING50BMG.clone().register("50BMGStar");
return bullet;
}
public static BulletConfiguration get50BMGSleekConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_50bmg.stackFromEnum(Ammo50BMG.SLEEK));
bullet.spread *= inaccuracy;
bullet.dmgMin = 50;
bullet.dmgMax = 70;
bullet.wear = 10;
bullet.leadChance = 100;
bullet.doesPenetrate = false;
bullet.bHit = new IBulletHitBehavior() {
@Override
public void behaveEntityHit(EntityBulletBase bullet, Entity hit) {
if(bullet.worldObj.isRemote)
return;
EntityBulletBase meteor = new EntityBulletBase(bullet.worldObj, BulletConfigSyncingUtil.MASKMAN_METEOR);
meteor.setPosition(hit.posX, hit.posY + 30 + meteor.worldObj.rand.nextInt(10), hit.posZ);
meteor.motionY = -1D;
meteor.shooter = bullet.shooter;
bullet.worldObj.spawnEntityInWorld(meteor);
}
};
bullet.bImpact = new IBulletImpactBehavior() {
@Override
public void behaveBlockHit(EntityBulletBase bullet, int x, int y, int z) {
if(bullet.worldObj.isRemote)
return;
if(y == -1)
return;
EntityBulletBase meteor = new EntityBulletBase(bullet.worldObj, BulletConfigSyncingUtil.MASKMAN_METEOR);
meteor.setPosition(bullet.posX, bullet.posY + 30 + meteor.worldObj.rand.nextInt(10), bullet.posZ);
meteor.motionY = -1D;
meteor.shooter = bullet.shooter;
bullet.worldObj.spawnEntityInWorld(meteor);
}
};
bullet.spentCasing = CASING50BMG.clone().register("50BMGIF");
return bullet;
}
public static BulletConfiguration get50BMGFlechetteConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_50bmg.stackFromEnum(Ammo50BMG.FLECHETTE));
bullet.spread *= inaccuracy;
bullet.dmgMin = 50;
bullet.dmgMax = 54;
bullet.style = bullet.STYLE_FLECHETTE;
bullet.spentCasing = CASING50BMG.clone().register("50BMGFlech");
return bullet;
}
public static BulletConfiguration get50BMGFlechetteAMConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_50bmg.stackFromEnum(Ammo50BMG.FLECHETTE_AM));
bullet.spread *= inaccuracy;
bullet.dmgMin = 60;
bullet.dmgMax = 64;
bullet.style = bullet.STYLE_FLECHETTE;
bullet.bHit = new IBulletHitBehavior() {
@Override
public void behaveEntityHit(EntityBulletBase bullet, Entity hit) {
if(bullet.worldObj.isRemote)
return;
if(hit instanceof EntityLivingBase) {
ContaminationUtil.contaminate((EntityLivingBase) hit, HazardType.RADIATION, ContaminationType.RAD_BYPASS, 100F);
}
}
};
bullet.spentCasing = CASING50BMG.clone().register("50BMGAM");
return bullet;
}
public static BulletConfiguration get50BMGFlechettePOConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_50bmg.stackFromEnum(Ammo50BMG.FLECHETTE_PO));
bullet.spread *= inaccuracy;
bullet.dmgMin = 60;
bullet.dmgMax = 64;
bullet.style = bullet.STYLE_FLECHETTE;
bullet.bHit = new IBulletHitBehavior() {
@Override
public void behaveEntityHit(EntityBulletBase bullet, Entity hit) {
if(bullet.worldObj.isRemote)
return;
if(hit instanceof EntityLivingBase) {
ContaminationUtil.contaminate((EntityLivingBase) hit, HazardType.RADIATION, ContaminationType.RAD_BYPASS, 50F);
}
}
};
bullet.spentCasing = CASING50BMG.clone().register("50BMGPO");
return bullet;
}
}