Added old-school animations for the super shotgun, including new CONSTANT keyframe loading

This commit is contained in:
George Paton 2024-02-18 17:28:53 +11:00
parent 9ff31388c8
commit d08d503178
11 changed files with 10636 additions and 10711 deletions

View File

@ -115,7 +115,7 @@ public class EntityBulletBaseNT extends EntityThrowableInterp implements IBullet
if(gun != null && gun.getItem() instanceof ItemGunBase) { if(gun != null && gun.getItem() instanceof ItemGunBase) {
GunConfiguration cfg = ((ItemGunBase) gun.getItem()).mainConfig; GunConfiguration cfg = ((ItemGunBase) gun.getItem()).mainConfig;
if(cfg != null && cfg.hasSights && entity.isSneaking()) { if(cfg != null && (cfg.hasSights && entity.isSneaking()) || cfg.isCentered) {
offsetShot = false; offsetShot = false;
} }
} }

View File

@ -42,6 +42,8 @@ public class GunConfiguration implements Cloneable {
public boolean animationsLoaded = false; public boolean animationsLoaded = false;
//when sneaking, disables crosshair and centers the bullet spawn point //when sneaking, disables crosshair and centers the bullet spawn point
public boolean hasSights; public boolean hasSights;
//does this weapon behave like fully sick old-school boomer shooters
public boolean isCentered;
//texture overlay when sneaking //texture overlay when sneaking
public ResourceLocation scopeTexture; public ResourceLocation scopeTexture;
//whether the FOV multiplier should be absolute or multiplicative to other modifiers, multiplicative mode is experimental! //whether the FOV multiplier should be absolute or multiplicative to other modifiers, multiplicative mode is experimental!

View File

@ -180,7 +180,7 @@ public class Gun12GaugeFactory {
GunConfiguration config = new GunConfiguration(); GunConfiguration config = new GunConfiguration();
config.rateOfFire = 20; config.rateOfFire = 30;
config.roundsPerCycle = 2; config.roundsPerCycle = 2;
config.gunMode = GunConfiguration.MODE_NORMAL; config.gunMode = GunConfiguration.MODE_NORMAL;
config.firingMode = GunConfiguration.FIRE_MANUAL; config.firingMode = GunConfiguration.FIRE_MANUAL;
@ -190,33 +190,14 @@ public class Gun12GaugeFactory {
config.durability = 3000; config.durability = 3000;
config.reloadType = GunConfiguration.RELOAD_NONE; config.reloadType = GunConfiguration.RELOAD_NONE;
config.allowsInfinity = true; config.allowsInfinity = true;
config.hasSights = true; config.isCentered = true;
config.crosshair = Crosshair.L_CIRCLE; config.crosshair = Crosshair.L_CIRCLE;
config.reloadSound = GunConfiguration.RSOUND_REVOLVER; config.reloadSound = GunConfiguration.RSOUND_REVOLVER;
config.firingSound = "hbm:weapon.shottyShoot"; config.firingSound = "hbm:weapon.shottyShoot";
config.animations.put(AnimType.CYCLE, new BusAnimation() config.loadAnimations = i -> {
.addBus("SHOTTY_RECOIL", new BusAnimationSequence() config.animations.put(AnimType.CYCLE, ResourceManager.supershotty_anim.get("Fire"));
.addKeyframePosition(0.5, 0, 0, 50) };
.addKeyframePosition(0, 0, 0, 50)
)
.addBus("SHOTTY_BREAK", new BusAnimationSequence()
.addKeyframePosition(0, 0, 0, 100) //do nothing for 100ms
.addKeyframePosition(0, 0, 60, 200) //open
.addKeyframePosition(0, 0, 60, 500) //do nothing for 500ms
.addKeyframePosition(0, 0, 0, 200) //close
)
.addBus("SHOTTY_EJECT", new BusAnimationSequence()
.addKeyframePosition(0, 0, 0, 300) //do nothing for 300ms
.addKeyframePosition(1, 0, 0, 700) //fling!
)
.addBus("SHOTTY_INSERT", new BusAnimationSequence()
.addKeyframePosition(0, 0, 0, 300) //do nothing for 300ms
.addKeyframePosition(1, 0, 1, 0) //reposition
.addKeyframePosition(1, 0, 0, 350) //come in from the side
.addKeyframePosition(0, 0, 0, 150) //push
)
);
config.name = "supershotty"; config.name = "supershotty";
config.manufacturer = EnumGunManufacturer.UAC; config.manufacturer = EnumGunManufacturer.UAC;

View File

@ -849,6 +849,7 @@ public class ResourceManager {
public static final HashMap<String, BusAnimation> novac_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/novac.json")); public static final HashMap<String, BusAnimation> novac_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/novac.json"));
public static final HashMap<String, BusAnimation> ks23_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/ks23.json")); public static final HashMap<String, BusAnimation> ks23_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/ks23.json"));
public static final HashMap<String, BusAnimation> spas_12_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/spas12.json")); public static final HashMap<String, BusAnimation> spas_12_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/spas12.json"));
public static final HashMap<String, BusAnimation> supershotty_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/supershotty.json"));
public static final IModelCustom lance = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/lance.obj")); public static final IModelCustom lance = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/lance.obj"));

View File

@ -14,6 +14,7 @@ import com.google.gson.JsonArray;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import com.hbm.render.anim.BusAnimationKeyframe.InterpolationType;
import com.hbm.render.anim.BusAnimationSequence.Dimension; import com.hbm.render.anim.BusAnimationSequence.Dimension;
public class AnimationLoader { public class AnimationLoader {
@ -142,8 +143,9 @@ public class AnimationLoader {
double value = array.get(0).getAsDouble(); double value = array.get(0).getAsDouble();
int duration = array.get(1).getAsInt(); int duration = array.get(1).getAsInt();
InterpolationType interpolation = array.size() >= 3 ? InterpolationType.valueOf(array.get(2).getAsString()) : InterpolationType.LINEAR;
return new BusAnimationKeyframe(value, duration); return new BusAnimationKeyframe(value, duration, interpolation);
} }
} }

View File

@ -7,7 +7,7 @@ public class BusAnimationKeyframe {
//it's an enum so stuff like accelerated animations between just //it's an enum so stuff like accelerated animations between just
//two frames could be implemented //two frames could be implemented
public static enum InterpolationType { public static enum InterpolationType {
NONE, CONSTANT,
LINEAR LINEAR
} }

View File

@ -91,11 +91,16 @@ public class BusAnimationSequence {
continue; continue;
} }
if (currentFrame.interpolationType == InterpolationType.NONE || millis >= endTime) { if (millis >= endTime) {
transform[i] = currentFrame.value; transform[i] = currentFrame.value;
continue; continue;
} }
if (previousFrame != null && previousFrame.interpolationType == InterpolationType.CONSTANT) {
transform[i] = previousFrame.value;
continue;
}
double a = currentFrame.value; double a = currentFrame.value;
double b = previousFrame != null ? previousFrame.value : 0; double b = previousFrame != null ? previousFrame.value : 0;
double t = (double)(millis - startTime) / (double)currentFrame.duration; double t = (double)(millis - startTime) / (double)currentFrame.duration;

View File

@ -5,6 +5,7 @@ import org.lwjgl.opengl.GL11;
import com.hbm.items.weapon.ItemGunBase; import com.hbm.items.weapon.ItemGunBase;
import com.hbm.main.ResourceManager; import com.hbm.main.ResourceManager;
import com.hbm.render.anim.HbmAnimations; import com.hbm.render.anim.HbmAnimations;
import com.hbm.render.anim.HbmAnimations.Animation;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -41,10 +42,6 @@ public class ItemRenderWeaponShotty implements IItemRenderer {
GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glShadeModel(GL11.GL_SMOOTH);
String barrel = "Body_Cube.008";
String handle = "handle_Cylinder.005";
String shells = "boolets_Cylinder.008";
Minecraft.getMinecraft().renderEngine.bindTexture(ResourceManager.shotty_tex); Minecraft.getMinecraft().renderEngine.bindTexture(ResourceManager.shotty_tex);
EntityPlayer player = Minecraft.getMinecraft().thePlayer; EntityPlayer player = Minecraft.getMinecraft().thePlayer;
@ -53,69 +50,54 @@ public class ItemRenderWeaponShotty implements IItemRenderer {
case EQUIPPED_FIRST_PERSON: case EQUIPPED_FIRST_PERSON:
double[] recoil = HbmAnimations.getRelevantTransformation("SHOTTY_RECOIL");
double[] eject = HbmAnimations.getRelevantTransformation("SHOTTY_BREAK");
double[] ejectShell = HbmAnimations.getRelevantTransformation("SHOTTY_EJECT");
double[] insertShell = HbmAnimations.getRelevantTransformation("SHOTTY_INSERT");
GL11.glScalef(0.5F, 0.5F, 0.5F); GL11.glScalef(0.5F, 0.5F, 0.5F);
GL11.glRotatef(20F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(20F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(-10F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-95F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(1.75F, -0.2F, -0.3F); GL11.glTranslatef(-2.0F, 0.5F, -2.0F);
if(player.isSneaking()) { HbmAnimations.applyRelevantTransformation("Body");
GL11.glTranslatef(0F, 1.0F, -2.05F); ResourceManager.shotty.renderPart("Body");
GL11.glRotatef(3.5F, 0.0F, 1.0F, 0.0F);
} else {
GL11.glRotated(-eject[2] * 0.25, 0, 0, 1); HbmAnimations.applyRelevantTransformation("Barrel");
} ResourceManager.shotty.renderPart("Barrel");
GL11.glTranslated(-recoil[0] * 2, 0, 0); // If we've run out of ammo, stop drawing the shells after ejection has completed
GL11.glRotated(recoil[0] * 5, 0, 0, 1); Animation anim = HbmAnimations.getRelevantAnim();
int millis = anim != null ? (int)(System.currentTimeMillis() - anim.startMillis) : 0;
GL11.glPushMatrix(); if(ItemGunBase.getBeltSize(player, ItemGunBase.getBeltType(player, item, true)) > 0 || millis < 1000) {
GL11.glRotated(-eject[2] * 0.8, 0, 0, 1);
ResourceManager.shotty.renderPart(barrel);
GL11.glPushMatrix();
GL11.glRotated(ejectShell[0] * 90, 0, 0, 1);
GL11.glTranslated(-ejectShell[0] * 10, 0, 0);
ResourceManager.shotty.renderPart(shells);
GL11.glPopMatrix();
if(ItemGunBase.getBeltSize(player, ItemGunBase.getBeltType(player, item, true)) > 0) {
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslated(-insertShell[0], insertShell[2] * -2, insertShell[2] * -1); HbmAnimations.applyRelevantTransformation("ShellL");
ResourceManager.shotty.renderPart(shells); ResourceManager.shotty.renderPart("ShellL");
GL11.glPopMatrix();
GL11.glPushMatrix();
HbmAnimations.applyRelevantTransformation("ShellR");
ResourceManager.shotty.renderPart("ShellR");
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
GL11.glPopMatrix();
ResourceManager.shotty.renderPart(handle);
break; break;
case EQUIPPED: case EQUIPPED:
GL11.glRotatef(-80F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-170F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-10F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(-10F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(10F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(-10F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(5F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(5F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(0.5F, 0.0F, -0.4F); GL11.glTranslatef(-0.4F, 0.0F, -0.5F);
GL11.glScaled(0.35, 0.35, 0.35); GL11.glScaled(0.35, 0.35, 0.35);
ResourceManager.shotty.renderPart(handle); ResourceManager.shotty.renderPart("Body");
ResourceManager.shotty.renderPart(barrel); ResourceManager.shotty.renderPart("Barrel");
break; break;
case ENTITY: case ENTITY:
GL11.glScaled(0.5, 0.5, 0.5); GL11.glScaled(0.5, 0.5, 0.5);
GL11.glTranslatef(-1.0F, 0.2F, 0.0F); GL11.glTranslatef(0.0F, 0.2F, 0.0F);
ResourceManager.shotty.renderPart(handle); ResourceManager.shotty.renderPart("Body");
ResourceManager.shotty.renderPart(barrel); ResourceManager.shotty.renderPart("Barrel");
break; break;
default: break; default: break;

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff