electric zapper for the siege UFO miniboss

This commit is contained in:
Bob 2022-02-08 21:59:42 +01:00
parent 417969fe83
commit ae2e169609
5 changed files with 180 additions and 17 deletions

View File

@ -167,13 +167,21 @@ public abstract class EntityUFOBase extends EntityFlying implements IMob {
int wX = (int)Math.floor(this.target.posX - vec.xCoord / length * overshoot);
int wZ = (int)Math.floor(this.target.posZ - vec.zCoord / length * overshoot);
this.setWaypoint(wX, Math.max(this.worldObj.getHeightValue(wX, wZ) + 2 + rand.nextInt(2), (int) this.target.posY + rand.nextInt(3)), wZ);
this.setWaypoint(wX, Math.max(this.worldObj.getHeightValue(wX, wZ), (int) this.target.posY) + targetHeightOffset(), wZ);
}
protected int targetHeightOffset() {
return 2 + rand.nextInt(2);
}
protected int wanderHeightOffset() {
return 2 + rand.nextInt(3);
}
protected void setCourseWithoutTaget() {
int x = (int) Math.floor(posX + rand.nextGaussian() * 5);
int z = (int) Math.floor(posZ + rand.nextGaussian() * 5);
this.setWaypoint(x, this.worldObj.getHeightValue(x, z) + 2 + rand.nextInt(3), z);
this.setWaypoint(x, this.worldObj.getHeightValue(x, z) + wanderHeightOffset(), z);
}
public void setWaypoint(int x, int y, int z) {

View File

@ -1,30 +1,49 @@
package com.hbm.entity.mob.siege;
import java.util.List;
import com.hbm.entity.mob.EntityUFOBase;
import com.hbm.entity.projectile.EntitySiegeLaser;
import com.hbm.items.ModItems;
import com.hbm.lib.ModDamageSource;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
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.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class EntitySiegeCraft extends EntityUFOBase implements IBossDisplayData {
private int attackCooldown;
private int beamCountdown;
public EntitySiegeCraft(World world) {
super(world);
this.setSize(7F, 1F);
this.isImmuneToFire = true;
this.ignoreFrustumCheck = true;
}
@Override
protected void entityInit() {
super.entityInit();
this.getDataWatcher().addObject(12, (int) 0);
this.getDataWatcher().addObject(13, 0F);
this.getDataWatcher().addObject(14, 0F);
this.getDataWatcher().addObject(15, 0F);
this.getDataWatcher().addObject(16, (byte) 0);
}
public void setTier(SiegeTier tier) {
@ -39,6 +58,38 @@ public class EntitySiegeCraft extends EntityUFOBase implements IBossDisplayData
SiegeTier tier = SiegeTier.tiers[this.getDataWatcher().getWatchableObjectInt(12)];
return tier != null ? tier : SiegeTier.CLAY;
}
public void setBeam(boolean beam) {
this.getDataWatcher().updateObject(16, beam ? (byte) 1 : (byte) 0);
}
public boolean getBeam() {
return this.getDataWatcher().getWatchableObjectByte(16) == 1;
}
public void setLockon(double x, double y, double z) {
this.getDataWatcher().updateObject(13, (float) x);
this.getDataWatcher().updateObject(14, (float) y);
this.getDataWatcher().updateObject(15, (float) z);
}
public Vec3 getLockon() {
return Vec3.createVectorHelper(
this.getDataWatcher().getWatchableObjectFloat(13),
this.getDataWatcher().getWatchableObjectFloat(14),
this.getDataWatcher().getWatchableObjectFloat(15)
);
}
@Override
protected int targetHeightOffset() {
return 7 + rand.nextInt(5);
}
@Override
protected int wanderHeightOffset() {
return 10 + rand.nextInt(2);
}
@Override
protected void updateEntityActionState() {
@ -55,9 +106,80 @@ public class EntitySiegeCraft extends EntityUFOBase implements IBossDisplayData
if(this.attackCooldown > 0) {
this.attackCooldown--;
}
if(this.beamCountdown > 0) {
this.beamCountdown--;
}
if(rand.nextInt(50) == 0) {
NBTTagCompound dPart = new NBTTagCompound();
dPart.setString("type", "tau");
dPart.setByte("count", (byte)(2 + rand.nextInt(3)));
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(dPart, posX + rand.nextGaussian() * 2, posY + rand.nextGaussian(), posZ + rand.nextGaussian() * 2), new TargetPoint(worldObj.provider.dimensionId, posX, posY, posZ, 50));
}
boolean beam = false;
if(this.target == null || this.beamCountdown <= 0) {
this.beamCountdown = 300; //200 - 100: nothing, 100 - 40: update lockon, 40 - 20: fix lockon, 20 - 0: beam
} else {
if(this.beamCountdown >= 60 && this.beamCountdown < 120) {
double x = this.target.posX;
double y = this.target.posY + this.target.height * 0.5;
double z = this.target.posZ;
this.setLockon(x, y, z);
}
if(this.beamCountdown >= 40 && this.beamCountdown < 100) {
Vec3 lockon = this.getLockon();
NBTTagCompound fx = new NBTTagCompound();
fx.setString("type", "vanillaburst");
fx.setString("mode", "reddust");
fx.setDouble("motion", 0.2D);
fx.setInteger("count", 5);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(fx, lockon.xCoord, lockon.yCoord, lockon.zCoord), new TargetPoint(this.dimension, lockon.xCoord, lockon.yCoord, lockon.zCoord, 100));
}
if(this.beamCountdown < 40) {
Vec3 lockon = this.getLockon();
if(this.beamCountdown == 39) {
worldObj.playSoundEffect(lockon.xCoord, lockon.yCoord, lockon.zCoord, "hbm:entity.ufoBlast", 5.0F, 0.9F + worldObj.rand.nextFloat() * 0.2F);
}
List<Entity> entities = worldObj.getEntitiesWithinAABBExcludingEntity(this, AxisAlignedBB.getBoundingBox(lockon.xCoord, lockon.yCoord, lockon.zCoord, lockon.xCoord, lockon.yCoord, lockon.zCoord).expand(2, 2, 2));
for(Entity e : entities) {
if(this.canAttackClass(e.getClass())) {
e.attackEntityFrom(ModDamageSource.causeCombineDamage(this, e), 1000F);
e.setFire(5);
if(e instanceof EntityLivingBase)
ContaminationUtil.contaminate((EntityLivingBase)e, HazardType.RADIATION, ContaminationType.CREATIVE, 5F);
}
}
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "plasmablast");
data.setFloat("r", 0.0F);
data.setFloat("g", 0.75F);
data.setFloat("b", 1.0F);
data.setFloat("pitch", -90 + rand.nextFloat() * 180);
data.setFloat("yaw", rand.nextFloat() * 180F);
data.setFloat("scale", 5F);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, lockon.xCoord, lockon.yCoord, lockon.zCoord), new TargetPoint(dimension, lockon.xCoord, lockon.yCoord, lockon.zCoord, 150));
beam = true;
}
}
this.setBeam(beam);
if(this.attackCooldown == 0 && this.target != null) {
this.attackCooldown = 20 + rand.nextInt(5);
this.attackCooldown = 30 + rand.nextInt(10);
double x = posX;
double y = posY;
@ -66,15 +188,29 @@ public class EntitySiegeCraft extends EntityUFOBase implements IBossDisplayData
Vec3 vec = Vec3.createVectorHelper(target.posX - x, target.posY + target.height * 0.5 - y, target.posZ - z).normalize();
SiegeTier tier = this.getTier();
EntitySiegeLaser laser = new EntitySiegeLaser(worldObj, this);
laser.setPosition(x, y, z);
laser.setThrowableHeading(vec.xCoord, vec.yCoord, vec.zCoord, 1F, 0.15F);
laser.setColor(0x808080);
laser.setDamage(tier.damageMod);
laser.setExplosive(tier.laserExplosive);
laser.setBreakChance(tier.laserBreak);
if(tier.laserIncendiary) laser.setIncendiary();
worldObj.spawnEntityInWorld(laser);
float health = getHealth() / getMaxHealth();
int r = (int)(0xff * (1 - health));
int g = (int)(0xff * health);
int b = 0;
int color = (r << 16) | (g << 8) | b;
for(int i = 0; i < 7; i++) {
Vec3 copy = Vec3.createVectorHelper(vec.xCoord, vec.yCoord, vec.zCoord);
copy.rotateAroundY((float)Math.PI / 180F * (i - 3) * 5F);
EntitySiegeLaser laser = new EntitySiegeLaser(worldObj, this);
laser.setPosition(x, y, z);
laser.setThrowableHeading(copy.xCoord, copy.yCoord, copy.zCoord, 1F, 0.0F);
laser.setColor(color);
laser.setDamage(tier.damageMod);
laser.setBreakChance(tier.laserBreak * 2);
if(tier.laserIncendiary) laser.setIncendiary();
worldObj.spawnEntityInWorld(laser);
}
this.playSound("hbm:weapon.ballsLaser", 2.0F, 1.0F);
}
}

View File

@ -2689,8 +2689,8 @@ public class ModItems {
ingot_saturnite = new ItemCustomLore().setRarity(EnumRarity.rare).setUnlocalizedName("ingot_saturnite").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":ingot_saturnite");
plate_saturnite = new ItemCustomLore().setRarity(EnumRarity.rare).setUnlocalizedName("plate_saturnite").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":plate_saturnite");
ingot_fiberglass = new ItemCustomLore().setUnlocalizedName("ingot_fiberglass").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":ingot_fiberglass");
ingot_asbestos = new Item().setUnlocalizedName("ingot_asbestos").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":ingot_asbestos");
powder_asbestos = new Item().setUnlocalizedName("powder_asbestos").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":powder_asbestos");
ingot_asbestos = new ItemCustomLore().setUnlocalizedName("ingot_asbestos").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":ingot_asbestos");
powder_asbestos = new ItemCustomLore().setUnlocalizedName("powder_asbestos").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":powder_asbestos");
ingot_electronium = new ItemCustomLore().setUnlocalizedName("ingot_electronium").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":ingot_electronium");
nugget_zirconium = new ItemCustomLore().setUnlocalizedName("nugget_zirconium").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nugget_zirconium");
nugget_mercury = new Item().setUnlocalizedName("nugget_mercury_tiny").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nugget_mercury_tiny");

View File

@ -1300,8 +1300,8 @@ public class ClientProxy extends ServerProxy {
}
if("ufo".equals(type)) {
ParticleMukeCloud cloud = new ParticleMukeCloud(man, world, x, y, z, 0, 0, 0);
double motion = data.getDouble("motion");
ParticleMukeCloud cloud = new ParticleMukeCloud(man, world, x, y, z, rand.nextGaussian() * motion, 0, rand.nextGaussian() * motion);
Minecraft.getMinecraft().effectRenderer.addEffect(cloud);
}

View File

@ -9,6 +9,7 @@ import com.hbm.entity.mob.siege.SiegeTier;
import com.hbm.lib.RefStrings;
import com.hbm.main.ResourceManager;
import com.hbm.render.util.BeamPronter;
import com.hbm.render.util.RenderMiscEffects;
import com.hbm.render.util.BeamPronter.EnumBeamType;
import com.hbm.render.util.BeamPronter.EnumWaveType;
@ -25,6 +26,7 @@ public class RenderSiegeCraft extends Render {
GL11.glPushMatrix();
GL11.glTranslated(x, y + 0.5, z);
GL11.glPushMatrix();
EntitySiegeCraft ufo = (EntitySiegeCraft) entity;
//BossStatus.setBossStatus(ufo, false);
@ -58,6 +60,11 @@ public class RenderSiegeCraft extends Render {
GL11.glPopAttrib();
GL11.glEnable(GL11.GL_TEXTURE_2D);
if(ufo.getBeam()) {
bindTexture(new ResourceLocation(RefStrings.MODID + ":textures/misc/glintBF.png"));
RenderMiscEffects.renderClassicGlint(ufo.worldObj, f1, ResourceManager.siege_ufo, "UFO", 0.5F, 1.0F, 1.0F, 5, 1F);
}
GL11.glColor3f(1F, 1F, 1F);
Random rand = new Random(entity.ticksExisted / 4);
@ -65,7 +72,7 @@ public class RenderSiegeCraft extends Render {
GL11.glPushMatrix();
for(int i = 0; i < 8; i++) {
GL11.glRotated(45D, 0, 1, 0);
if(rand.nextInt(5) == 0) {
if(rand.nextInt(5) == 0 || ufo.getBeam()) {
GL11.glPushMatrix();
GL11.glTranslated(4, 0, 0);
BeamPronter.prontBeam(Vec3.createVectorHelper(-1.125, 0, 2.875), EnumWaveType.RANDOM, EnumBeamType.LINE, 0x80d0ff, 0xffffff, (int)(System.currentTimeMillis() % 1000) / 50, 15, 0.125F, 1, 0);
@ -73,6 +80,18 @@ public class RenderSiegeCraft extends Render {
}
}
GL11.glPopMatrix();
GL11.glPopMatrix();
if(ufo.getBeam()) {
GL11.glPushMatrix();
Vec3 delta = ufo.getLockon().addVector(-ufo.posX, -ufo.posY, -ufo.posZ);
double length = delta.lengthVector();
double scale = 0.1D;
BeamPronter.prontBeam(delta, EnumWaveType.SPIRAL, EnumBeamType.SOLID, 0x101020, 0x101020, 0, (int)(length + 1), 0F, 6, (float)scale * 0.75F);
BeamPronter.prontBeam(delta, EnumWaveType.RANDOM, EnumBeamType.SOLID, 0x202060, 0x202060, entity.ticksExisted / 2, (int)(length / 2 + 1), (float)scale * 1.5F, 2, 0.0625F);
BeamPronter.prontBeam(delta, EnumWaveType.RANDOM, EnumBeamType.SOLID, 0x202060, 0x202060, entity.ticksExisted / 4, (int)(length / 2 + 1), (float)scale * 1.5F, 2, 0.0625F);
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}