Helix shoot pattern / Min mod game version

This commit is contained in:
Anuke 2022-03-05 19:05:42 -05:00
parent 730691c589
commit d92c9cfcf8
11 changed files with 57 additions and 36 deletions

View File

@ -139,7 +139,7 @@ mod.disable = Disable
mod.content = Content:
mod.delete.error = Unable to delete mod. File may be in use.
mod.requiresversion = [scarlet]Requires min game version: [accent]{0}
mod.outdated = [scarlet]Not compatible with V6 (no minGameVersion: 105)
mod.outdatedv7 = [scarlet]Incompatible with V7 (no minGameVersion: 136)
mod.missingdependencies = [scarlet]Missing dependencies: {0}
mod.erroredcontent = [scarlet]Content Errors
mod.errors = Errors have occurred loading content.

View File

@ -41,7 +41,7 @@ public class Vars implements Loadable{
public static boolean loadLocales = true;
/** Whether the logger is loaded. */
public static boolean loadedLogger = false, loadedFileLogger = false;
/** Whether to enable various experimental features (e.g. spawn positions for spawn groups) */
/** Whether to enable various experimental features (e.g. spawn positions for spawn groups) TODO change */
public static boolean experimental = true;
/** Name of current Steam player. */
public static String steamPlayerName = "";
@ -165,8 +165,8 @@ public class Vars implements Loadable{
public static boolean headless;
/** whether steam is enabled for this game */
public static boolean steam;
/** whether typing into the console is enabled - developers only */
public static boolean enableConsole = false;
/** whether typing into the console is enabled - developers only TODO change */
public static boolean enableConsole = true;
/** whether to clear sector saves when landing */
public static boolean clearSectors = false;
/** whether any light rendering is enabled */

View File

@ -68,7 +68,7 @@ public class Planets{
r.attributes.set(Attribute.heat, 0.8f);
r.showSpawns = true;
r.fog = true;
r.staticFog = false; //TODO decide, is this a good idea?
r.staticFog = true; //TODO decide, is this a good idea?
};
unlockedOnLand.add(Blocks.coreBastion);

View File

@ -3142,6 +3142,7 @@ public class UnitTypes{
top = false;
layerOffset = -0.01f;
rotate = false;
shoot = new ShootHelix();
//TODO cooler + balancing
bullet = new BasicBulletType(5f, 15){{

View File

@ -0,0 +1,17 @@
package mindustry.entities.pattern;
import arc.math.*;
public class ShootHelix extends ShootPattern{
//TODO: pattern is broken without a proper offset
public float scl = 2f, mag = 0.5f, offset = Mathf.PI * 1.25f;
@Override
public void shoot(int totalShots, BulletHandler handler){
for(int i = 0; i < shots; i++){
for(int sign : Mathf.signs){
handler.shoot(0, 0, 0, firstShotDelay + shotDelay * i, b -> Mathf.sin(b.time + offset, scl, mag * sign));
}
}
}
}

View File

@ -14,10 +14,10 @@ public class ShootMulti extends ShootPattern{
@Override
public void shoot(int totalShots, BulletHandler handler){
source.shoot(totalShots, (x, y, rotation, delay) -> {
source.shoot(totalShots, (x, y, rotation, delay, move) -> {
for(var pattern : dest){
pattern.shoot(totalShots, (x2, y2, rot2, delay2) -> {
handler.shoot(x + x2, y + y2, rotation + rot2, delay + delay2);
pattern.shoot(totalShots, (x2, y2, rot2, delay2, mover) -> {
handler.shoot(x + x2, y + y2, rotation + rot2, delay + delay2, mover);
});
}
});

View File

@ -1,5 +1,7 @@
package mindustry.entities.pattern;
import mindustry.entities.*;
/** Handles different types of bullet patterns for shooting. */
public class ShootPattern{
/** amount of shots per "trigger pull" */
@ -23,6 +25,10 @@ public class ShootPattern{
* @param rotation rotation offset relative to weapon
* @param delay bullet delay in ticks
* */
void shoot(float x, float y, float rotation, float delay);
default void shoot(float x, float y, float rotation, float delay){
shoot(x, y, rotation, delay, null);
}
void shoot(float x, float y, float rotation, float delay, Mover move);
}
}

View File

@ -868,7 +868,7 @@ public class Mods implements Loadable{
!skipModLoading() &&
Core.settings.getBool("mod-" + baseName + "-enabled", true) &&
Version.isAtLeast(meta.minGameVersion) &&
(meta.getMinMajor() >= 105 || headless)
(meta.getMinMajor() >= 136 || headless)
){
if(ios){
throw new ModLoadException("Java class mods are not supported on iOS.");
@ -997,10 +997,10 @@ public class Mods implements Loadable{
return Version.isAtLeast(meta.minGameVersion);
}
/** @return whether this mod is outdated, e.g. not compatible with v6. */
/** @return whether this mod is outdated, e.g. not compatible with v7. */
public boolean isOutdated(){
//must be at least 105 to indicate v6 compat
return getMinMajor() < 105;
//must be at least 136 to indicate v7 compat
return getMinMajor() < 136;
}
public int getMinMajor(){

View File

@ -372,17 +372,19 @@ public class Weapon implements Cloneable{
bullet.chargeEffect.at(shootX, shootY, rotation, bullet.keepVelocity || parentizeEffects ? unit : null);
}
shoot.shoot(mount.totalShots, (xOffset, yOffset, angle, delay) -> {
shoot.shoot(mount.totalShots, (xOffset, yOffset, angle, delay, mover) -> {
if(delay > 0f){
Time.run(delay, () -> setupBullet(unit, mount, xOffset, yOffset, angle));
Time.run(delay, () -> setupBullet(unit, mount, xOffset, yOffset, angle, mover));
}else{
setupBullet(unit, mount, xOffset, yOffset, angle);
setupBullet(unit, mount, xOffset, yOffset, angle, mover);
}
mount.totalShots ++;
});
}
protected void setupBullet(Unit unit, WeaponMount mount, float xOffset, float yOffset, float angleOffset){
protected void setupBullet(Unit unit, WeaponMount mount, float xOffset, float yOffset, float angleOffset, Mover mover){
if(!unit.isAdded()) return;
float
weaponRotation = unit.rotation - 90 + (rotate ? mount.rotation : 0),
mountX = unit.x + Angles.trnsx(unit.rotation - 90, x, y),
@ -390,26 +392,21 @@ public class Weapon implements Cloneable{
bulletX = mountX + Angles.trnsx(weaponRotation, this.shootX + xOffset, this.shootY + yOffset),
bulletY = mountY + Angles.trnsy(weaponRotation, this.shootX + xOffset, this.shootY + yOffset),
shootAngle = bulletRotation(unit, mount, bulletX, bulletY) + angleOffset,
lifeScl = bullet.scaleVelocity ? Mathf.clamp(Mathf.dst(shootX, shootY, mount.aimX, mount.aimY) / bullet.range) : 1f;
lifeScl = bullet.scaleVelocity ? Mathf.clamp(Mathf.dst(shootX, shootY, mount.aimX, mount.aimY) / bullet.range) : 1f,
angle = angleOffset + shootAngle + Mathf.range(inaccuracy);
bullet(mount, unit, bulletX, bulletY, angleOffset + shootAngle + Mathf.range(inaccuracy), lifeScl, shootAngle, mountX, mountY);
}
protected void bullet(WeaponMount mount, Unit unit, float shootX, float shootY, float angle, float lifescl, float mountRotation, float mountX, float mountY){
if(!unit.isAdded()) return;
mount.bullet = bullet.create(unit, unit.team, shootX, shootY, angle, (1f - velocityRnd) + Mathf.random(velocityRnd), lifescl);
mount.bullet = bullet.create(unit, unit.team, bulletX, bulletY, angle, (1f - velocityRnd) + Mathf.random(velocityRnd), lifeScl, mover);
if(!continuous){
shootSound.at(shootX, shootY, Mathf.random(soundPitchMin, soundPitchMax));
shootSound.at(bulletX, bulletY, Mathf.random(soundPitchMin, soundPitchMax));
}
ejectEffect.at(mountX, mountY, angle * Mathf.sign(this.x));
bullet.shootEffect.at(shootX, shootY, angle, bullet.hitColor, unit);
bullet.smokeEffect.at(shootX, shootY, angle, bullet.hitColor, unit);
bullet.shootEffect.at(bulletX, bulletY, angle, bullet.hitColor, unit);
bullet.smokeEffect.at(bulletX, bulletY, angle, bullet.hitColor, unit);
unit.vel.add(Tmp.v1.trns(mountRotation + 180f, bullet.recoil));
Effect.shake(shake, shake, shootX, shootY);
unit.vel.add(Tmp.v1.trns(shootAngle + 180f, bullet.recoil));
Effect.shake(shake, shake, bulletX, bulletY);
mount.recoil = recoil;
mount.heat = 1f;
}

View File

@ -249,7 +249,7 @@ public class ModsDialog extends BaseDialog{
text.row();
if(item.isOutdated()){
text.labelWrap("@mod.outdated").growX();
text.labelWrap("@mod.outdatedv7").growX();
text.row();
}else if(!item.isSupported()){
text.labelWrap(Core.bundle.format("mod.requiresversion", item.meta.minGameVersion)).growX();

View File

@ -478,18 +478,18 @@ public class Turret extends ReloadTurret{
type.chargeEffect.at(bulletX, bulletY, rotation);
}
shoot.shoot(totalShots, (xOffset, yOffset, angle, delay) -> {
shoot.shoot(totalShots, (xOffset, yOffset, angle, delay, mover) -> {
queuedBullets ++;
if(delay > 0f){
Time.run(delay, () -> bullet(type, xOffset, yOffset, angle));
Time.run(delay, () -> bullet(type, xOffset, yOffset, angle, mover));
}else{
bullet(type, xOffset, yOffset, angle);
bullet(type, xOffset, yOffset, angle, mover);
}
totalShots ++;
});
}
protected void bullet(BulletType type, float xOffset, float yOffset, float angleOffset){
protected void bullet(BulletType type, float xOffset, float yOffset, float angleOffset, Mover mover){
queuedBullets --;
if(dead || !hasAmmo()) return;
@ -501,7 +501,7 @@ public class Turret extends ReloadTurret{
float lifeScl = type.scaleVelocity ? Mathf.clamp(Mathf.dst(bulletX, bulletY, targetPos.x, targetPos.y) / type.range, minRange / type.range, range() / type.range) : 1f;
handleBullet(type.create(this, team, bulletX, bulletY, shootAngle, 1f + Mathf.range(velocityInaccuracy), lifeScl), xOffset, yOffset, angleOffset);
handleBullet(type.create(this, team, bulletX, bulletY, shootAngle, 1f + Mathf.range(velocityInaccuracy), lifeScl, mover), xOffset, yOffset, angleOffset);
(shootEffect == Fx.none ? type.shootEffect : shootEffect).at(bulletX, bulletY, rotation, type.hitColor);
(smokeEffect == Fx.none ? type.smokeEffect : smokeEffect).at(bulletX, bulletY, rotation, type.hitColor);