Weapon system refactoring
@@ -325,7 +325,7 @@ project(":tools"){
|
|||||||
implementation arcModule("natives:natives-box2d-desktop")
|
implementation arcModule("natives:natives-box2d-desktop")
|
||||||
implementation arcModule("backends:backend-headless")
|
implementation arcModule("backends:backend-headless")
|
||||||
|
|
||||||
implementation "org.reflections:reflections:0.9.12"
|
implementation "org.reflections:reflections:0.9.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 607 B After Width: | Height: | Size: 597 B |
|
Before Width: | Height: | Size: 794 B After Width: | Height: | Size: 801 B |
|
Before Width: | Height: | Size: 709 B After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 927 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 524 B After Width: | Height: | Size: 526 B |
|
Before Width: | Height: | Size: 455 B After Width: | Height: | Size: 462 B |
|
Before Width: | Height: | Size: 604 B After Width: | Height: | Size: 648 B |
|
Before Width: | Height: | Size: 296 B After Width: | Height: | Size: 301 B |
|
Before Width: | Height: | Size: 362 B After Width: | Height: | Size: 353 B |
|
Before Width: | Height: | Size: 490 B After Width: | Height: | Size: 407 B |
|
Before Width: | Height: | Size: 448 B After Width: | Height: | Size: 639 B |
|
Before Width: | Height: | Size: 503 B After Width: | Height: | Size: 524 B |
|
Before Width: | Height: | Size: 313 B After Width: | Height: | Size: 320 B |
|
Before Width: | Height: | Size: 467 B After Width: | Height: | Size: 467 B |
|
Before Width: | Height: | Size: 663 B After Width: | Height: | Size: 656 B |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 659 B |
|
Before Width: | Height: | Size: 445 B After Width: | Height: | Size: 346 B |
|
Before Width: | Height: | Size: 794 B |
@@ -139,5 +139,4 @@ const ResizeEvent = Packages.mindustry.game.EventType.ResizeEvent
|
|||||||
const LaunchEvent = Packages.mindustry.game.EventType.LaunchEvent
|
const LaunchEvent = Packages.mindustry.game.EventType.LaunchEvent
|
||||||
const LoseEvent = Packages.mindustry.game.EventType.LoseEvent
|
const LoseEvent = Packages.mindustry.game.EventType.LoseEvent
|
||||||
const WinEvent = Packages.mindustry.game.EventType.WinEvent
|
const WinEvent = Packages.mindustry.game.EventType.WinEvent
|
||||||
const TurnEvent = Packages.mindustry.game.EventType.TurnEvent
|
|
||||||
const Trigger = Packages.mindustry.game.EventType.Trigger
|
const Trigger = Packages.mindustry.game.EventType.Trigger
|
||||||
|
|||||||
@@ -5659,6 +5659,13 @@ artillery
|
|||||||
orig: 48, 56
|
orig: 48, 56
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
|
beam-weapon
|
||||||
|
rotate: false
|
||||||
|
xy: 1957, 1771
|
||||||
|
size: 80, 80
|
||||||
|
orig: 80, 80
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
chaos
|
chaos
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 655, 156
|
xy: 655, 156
|
||||||
@@ -5785,20 +5792,6 @@ wraith
|
|||||||
orig: 48, 48
|
orig: 48, 48
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
beam-weapon
|
|
||||||
rotate: false
|
|
||||||
xy: 1957, 1771
|
|
||||||
size: 80, 80
|
|
||||||
orig: 80, 80
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
beam-weapon
|
|
||||||
rotate: false
|
|
||||||
xy: 1957, 1771
|
|
||||||
size: 80, 80
|
|
||||||
orig: 80, 80
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
|
|
||||||
sprites3.png
|
sprites3.png
|
||||||
size: 2048,1024
|
size: 2048,1024
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 849 KiB After Width: | Height: | Size: 849 KiB |
|
Before Width: | Height: | Size: 185 KiB After Width: | Height: | Size: 185 KiB |
@@ -5653,6 +5653,13 @@ artillery
|
|||||||
orig: 48, 56
|
orig: 48, 56
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
|
beam-weapon
|
||||||
|
rotate: false
|
||||||
|
xy: 2793, 803
|
||||||
|
size: 80, 80
|
||||||
|
orig: 80, 80
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
chaos
|
chaos
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 1023, 245
|
xy: 1023, 245
|
||||||
@@ -5779,20 +5786,6 @@ wraith
|
|||||||
orig: 48, 48
|
orig: 48, 48
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
beam-weapon
|
|
||||||
rotate: false
|
|
||||||
xy: 2793, 803
|
|
||||||
size: 80, 80
|
|
||||||
orig: 80, 80
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
beam-weapon
|
|
||||||
rotate: false
|
|
||||||
xy: 2793, 803
|
|
||||||
size: 80, 80
|
|
||||||
orig: 80, 80
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
|
|
||||||
sprites2.png
|
sprites2.png
|
||||||
size: 4096,512
|
size: 4096,512
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 186 KiB After Width: | Height: | Size: 186 KiB |
@@ -1592,6 +1592,7 @@ public class Blocks implements ContentList{
|
|||||||
inaccuracy = 10f;
|
inaccuracy = 10f;
|
||||||
shootCone = 30f;
|
shootCone = 30f;
|
||||||
shootSound = Sounds.shootSnap;
|
shootSound = Sounds.shootSnap;
|
||||||
|
targetGround = false;
|
||||||
|
|
||||||
health = 145 * size * size;
|
health = 145 * size * size;
|
||||||
}};
|
}};
|
||||||
@@ -1660,7 +1661,8 @@ public class Blocks implements ContentList{
|
|||||||
|
|
||||||
hasPower = true;
|
hasPower = true;
|
||||||
size = 2;
|
size = 2;
|
||||||
force = 3f;
|
force = 2.5f;
|
||||||
|
scaledForce = 5f;
|
||||||
range = 170f;
|
range = 170f;
|
||||||
damage = 0.08f;
|
damage = 0.08f;
|
||||||
health = 160 * size * size;
|
health = 160 * size * size;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package mindustry.content;
|
package mindustry.content;
|
||||||
|
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.math.*;
|
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import mindustry.ai.types.*;
|
import mindustry.ai.types.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
@@ -70,7 +69,7 @@ public class UnitTypes implements ContentList{
|
|||||||
weapons.add(new Weapon("large-weapon"){{
|
weapons.add(new Weapon("large-weapon"){{
|
||||||
reload = 14f;
|
reload = 14f;
|
||||||
x = 4f;
|
x = 4f;
|
||||||
alternate = true;
|
y = 2f;
|
||||||
ejectEffect = Fx.shellEjectSmall;
|
ejectEffect = Fx.shellEjectSmall;
|
||||||
bullet = Bullets.standardCopper;
|
bullet = Bullets.standardCopper;
|
||||||
}});
|
}});
|
||||||
@@ -88,7 +87,6 @@ public class UnitTypes implements ContentList{
|
|||||||
shootSound = Sounds.flame;
|
shootSound = Sounds.flame;
|
||||||
shootY = 2f;
|
shootY = 2f;
|
||||||
reload = 14f;
|
reload = 14f;
|
||||||
alternate = true;
|
|
||||||
recoil = 1f;
|
recoil = 1f;
|
||||||
ejectEffect = Fx.none;
|
ejectEffect = Fx.none;
|
||||||
bullet = Bullets.basicFlame;
|
bullet = Bullets.basicFlame;
|
||||||
@@ -107,8 +105,7 @@ public class UnitTypes implements ContentList{
|
|||||||
weapons.add(new Weapon("heal-weapon"){{
|
weapons.add(new Weapon("heal-weapon"){{
|
||||||
shootY = 1.5f;
|
shootY = 1.5f;
|
||||||
reload = 24f;
|
reload = 24f;
|
||||||
x = 1f;
|
x = 3.5f;
|
||||||
shootX = 3.5f;
|
|
||||||
alternate = false;
|
alternate = false;
|
||||||
ejectEffect = Fx.none;
|
ejectEffect = Fx.none;
|
||||||
recoil = 2f;
|
recoil = 2f;
|
||||||
@@ -160,10 +157,8 @@ public class UnitTypes implements ContentList{
|
|||||||
weapons.add(new Weapon("beam-weapon"){{
|
weapons.add(new Weapon("beam-weapon"){{
|
||||||
shake = 2f;
|
shake = 2f;
|
||||||
shootY = 4f;
|
shootY = 4f;
|
||||||
shootX = 6f;
|
x = 6.5f;
|
||||||
x = 0.25f;
|
|
||||||
reload = 50f;
|
reload = 50f;
|
||||||
alternate = true;
|
|
||||||
recoil = 4f;
|
recoil = 4f;
|
||||||
shootSound = Sounds.laser;
|
shootSound = Sounds.laser;
|
||||||
|
|
||||||
@@ -188,7 +183,6 @@ public class UnitTypes implements ContentList{
|
|||||||
y = 1f;
|
y = 1f;
|
||||||
x = 9f;
|
x = 9f;
|
||||||
reload = 60f;
|
reload = 60f;
|
||||||
alternate = true;
|
|
||||||
recoil = 4f;
|
recoil = 4f;
|
||||||
shake = 2f;
|
shake = 2f;
|
||||||
ejectEffect = Fx.shellEjectMedium;
|
ejectEffect = Fx.shellEjectMedium;
|
||||||
@@ -251,7 +245,6 @@ public class UnitTypes implements ContentList{
|
|||||||
weapons.add(new Weapon("eruption"){{
|
weapons.add(new Weapon("eruption"){{
|
||||||
shootY = 3f;
|
shootY = 3f;
|
||||||
reload = 10f;
|
reload = 10f;
|
||||||
alternate = true;
|
|
||||||
ejectEffect = Fx.none;
|
ejectEffect = Fx.none;
|
||||||
recoil = 1f;
|
recoil = 1f;
|
||||||
x = 7f;
|
x = 7f;
|
||||||
@@ -288,18 +281,14 @@ public class UnitTypes implements ContentList{
|
|||||||
legSplashDamage = 32;
|
legSplashDamage = 32;
|
||||||
legSplashRange = 30;
|
legSplashRange = 30;
|
||||||
|
|
||||||
for(boolean b : Mathf.booleans){
|
weapons.add(
|
||||||
weapons.add(
|
new Weapon("missiles-mount"){{
|
||||||
new Weapon("missiles-mount"){{
|
reload = 20f;
|
||||||
reload = 20f;
|
x = 4f;
|
||||||
x = 4f * Mathf.sign(b);
|
rotate = true;
|
||||||
rotate = true;
|
shake = 1f;
|
||||||
mirror = false;
|
bullet = Bullets.missileSwarm;
|
||||||
flipSprite = !b;
|
}});
|
||||||
shake = 1f;
|
|
||||||
bullet = Bullets.missileSwarm;
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
wraith = new UnitType("wraith"){{
|
wraith = new UnitType("wraith"){{
|
||||||
@@ -315,7 +304,6 @@ public class UnitTypes implements ContentList{
|
|||||||
y = 0f;
|
y = 0f;
|
||||||
x = 2f;
|
x = 2f;
|
||||||
reload = 15f;
|
reload = 15f;
|
||||||
alternate = true;
|
|
||||||
ejectEffect = Fx.shellEjectSmall;
|
ejectEffect = Fx.shellEjectSmall;
|
||||||
bullet = Bullets.standardCopper;
|
bullet = Bullets.standardCopper;
|
||||||
shootSound = Sounds.shoot;
|
shootSound = Sounds.shoot;
|
||||||
@@ -338,7 +326,6 @@ public class UnitTypes implements ContentList{
|
|||||||
shootY = 0f;
|
shootY = 0f;
|
||||||
reload = 12f;
|
reload = 12f;
|
||||||
shootCone = 180f;
|
shootCone = 180f;
|
||||||
alternate = true;
|
|
||||||
ejectEffect = Fx.none;
|
ejectEffect = Fx.none;
|
||||||
inaccuracy = 15f;
|
inaccuracy = 15f;
|
||||||
ignoreRotation = true;
|
ignoreRotation = true;
|
||||||
@@ -360,36 +347,31 @@ public class UnitTypes implements ContentList{
|
|||||||
engineOffset = 12f;
|
engineOffset = 12f;
|
||||||
engineSize = 3f;
|
engineSize = 3f;
|
||||||
|
|
||||||
for(boolean b : Mathf.booleans){
|
weapons.add(new Weapon("revenant-missiles"){{
|
||||||
weapons.add(
|
reload = 70f;
|
||||||
new Weapon("revenant-missiles"){{
|
x = 7f;
|
||||||
reload = 70f;
|
rotate = true;
|
||||||
x = 7f * Mathf.sign(b);
|
shake = 1f;
|
||||||
rotate = true;
|
|
||||||
mirror = false;
|
|
||||||
flipSprite = !b;
|
|
||||||
shake = 1f;
|
|
||||||
|
|
||||||
bullet = new MissileBulletType(2.7f, 12, "missile"){{
|
bullet = new MissileBulletType(2.7f, 12, "missile"){{
|
||||||
width = 8f;
|
width = 8f;
|
||||||
height = 8f;
|
height = 8f;
|
||||||
shrinkY = 0f;
|
shrinkY = 0f;
|
||||||
drag = -0.003f;
|
drag = -0.003f;
|
||||||
homingRange = 60f;
|
homingRange = 60f;
|
||||||
keepVelocity = false;
|
keepVelocity = false;
|
||||||
splashDamageRadius = 25f;
|
splashDamageRadius = 25f;
|
||||||
splashDamage = 10f;
|
splashDamage = 10f;
|
||||||
lifetime = 60f;
|
lifetime = 60f;
|
||||||
trailColor = Pal.unitBack;
|
trailColor = Pal.unitBack;
|
||||||
backColor = Pal.unitBack;
|
backColor = Pal.unitBack;
|
||||||
frontColor = Pal.unitFront;
|
frontColor = Pal.unitFront;
|
||||||
hitEffect = Fx.blastExplosion;
|
hitEffect = Fx.blastExplosion;
|
||||||
despawnEffect = Fx.blastExplosion;
|
despawnEffect = Fx.blastExplosion;
|
||||||
weaveScale = 6f;
|
weaveScale = 6f;
|
||||||
weaveMag = 1f;
|
weaveMag = 1f;
|
||||||
}};
|
}};
|
||||||
}});
|
}});
|
||||||
}
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
reaper = new UnitType("reaper"){{
|
reaper = new UnitType("reaper"){{
|
||||||
@@ -407,7 +389,6 @@ public class UnitTypes implements ContentList{
|
|||||||
weapons.add(new Weapon(){{
|
weapons.add(new Weapon(){{
|
||||||
y = 1.5f;
|
y = 1.5f;
|
||||||
reload = 28f;
|
reload = 28f;
|
||||||
alternate = true;
|
|
||||||
ejectEffect = Fx.shellEjectSmall;
|
ejectEffect = Fx.shellEjectSmall;
|
||||||
bullet = Bullets.standardCopper;
|
bullet = Bullets.standardCopper;
|
||||||
shootSound = Sounds.shoot;
|
shootSound = Sounds.shoot;
|
||||||
@@ -429,7 +410,6 @@ public class UnitTypes implements ContentList{
|
|||||||
weapons.add(new Weapon(){{
|
weapons.add(new Weapon(){{
|
||||||
y = 1.5f;
|
y = 1.5f;
|
||||||
reload = 28f;
|
reload = 28f;
|
||||||
alternate = true;
|
|
||||||
ejectEffect = Fx.shellEjectSmall;
|
ejectEffect = Fx.shellEjectSmall;
|
||||||
bullet = Bullets.standardCopper;
|
bullet = Bullets.standardCopper;
|
||||||
shootSound = Sounds.shoot;
|
shootSound = Sounds.shoot;
|
||||||
@@ -445,7 +425,6 @@ public class UnitTypes implements ContentList{
|
|||||||
weapons.add(new Weapon("mount-weapon"){{
|
weapons.add(new Weapon("mount-weapon"){{
|
||||||
reload = 10f;
|
reload = 10f;
|
||||||
x = 1.25f;
|
x = 1.25f;
|
||||||
alternate = true;
|
|
||||||
rotate = true;
|
rotate = true;
|
||||||
ejectEffect = Fx.shellEjectSmall;
|
ejectEffect = Fx.shellEjectSmall;
|
||||||
bullet = Bullets.standardCopper;
|
bullet = Bullets.standardCopper;
|
||||||
@@ -478,7 +457,6 @@ public class UnitTypes implements ContentList{
|
|||||||
y = 1.5f;
|
y = 1.5f;
|
||||||
reload = 40f;
|
reload = 40f;
|
||||||
x = 0.5f;
|
x = 0.5f;
|
||||||
alternate = true;
|
|
||||||
ejectEffect = Fx.none;
|
ejectEffect = Fx.none;
|
||||||
recoil = 2f;
|
recoil = 2f;
|
||||||
bullet = Bullets.healBulletBig;
|
bullet = Bullets.healBulletBig;
|
||||||
@@ -506,10 +484,8 @@ public class UnitTypes implements ContentList{
|
|||||||
|
|
||||||
weapons.add(new Weapon("small-basic-weapon"){{
|
weapons.add(new Weapon("small-basic-weapon"){{
|
||||||
reload = 15f;
|
reload = 15f;
|
||||||
x = -1f;
|
x = 2.75f;
|
||||||
y = -1f;
|
y = 1f;
|
||||||
shootX = 3.5f;
|
|
||||||
alternate = true;
|
|
||||||
|
|
||||||
bullet = new BasicBulletType(2.5f, 9){{
|
bullet = new BasicBulletType(2.5f, 9){{
|
||||||
width = 7f;
|
width = 7f;
|
||||||
@@ -551,28 +527,21 @@ public class UnitTypes implements ContentList{
|
|||||||
hitsize = 14f;
|
hitsize = 14f;
|
||||||
engineSize = 3f;
|
engineSize = 3f;
|
||||||
|
|
||||||
for(boolean b : Mathf.booleans){
|
weapons.add(
|
||||||
weapons.add(
|
new Weapon("heal-weapon-mount"){{
|
||||||
new Weapon("heal-weapon-mount"){{
|
reload = 25f;
|
||||||
reload = 25f;
|
x = 8f;
|
||||||
x = 8f * Mathf.sign(b);
|
y = -6f;
|
||||||
y = -6f;
|
rotate = true;
|
||||||
rotate = true;
|
bullet = Bullets.healBulletBig;
|
||||||
mirror = false;
|
}},
|
||||||
flipSprite = !b;
|
new Weapon("heal-weapon-mount"){{
|
||||||
bullet = Bullets.healBulletBig;
|
reload = 15f;
|
||||||
}},
|
x = 4f;
|
||||||
new Weapon("heal-weapon-mount"){{
|
y = 5f;
|
||||||
reload = 15f;
|
rotate = true;
|
||||||
x = 4f * Mathf.sign(b);
|
bullet = Bullets.healBullet;
|
||||||
y = 5f;
|
}});
|
||||||
rotate = true;
|
|
||||||
mirror = false;
|
|
||||||
flipSprite = !b;
|
|
||||||
bullet = Bullets.healBullet;
|
|
||||||
}}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -84,11 +84,17 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
|
|||||||
Weapon weapon = mount.weapon;
|
Weapon weapon = mount.weapon;
|
||||||
mount.reload = Math.max(mount.reload - Time.delta(), 0);
|
mount.reload = Math.max(mount.reload - Time.delta(), 0);
|
||||||
|
|
||||||
|
if(weapon.otherSide != -1 && weapon.alternate && mount.side == weapon.flipSprite &&
|
||||||
|
mount.reload + Time.delta() > weapon.reload/2f && mount.reload <= weapon.reload/2f){
|
||||||
|
mounts[weapon.otherSide].side = !mounts[weapon.otherSide].side;
|
||||||
|
mount.side = !mount.side;
|
||||||
|
}
|
||||||
|
|
||||||
//rotate if applicable
|
//rotate if applicable
|
||||||
if(weapon.rotate && (mount.rotate || mount.shoot)){
|
if(weapon.rotate && (mount.rotate || mount.shoot)){
|
||||||
float axisXOffset = weapon.mirror ? 0f : weapon.x;
|
float axisXOffset = weapon.x;
|
||||||
float axisX = this.x + Angles.trnsx(rotation, axisXOffset, weapon.y),
|
float axisX = this.x + Angles.trnsx(rotation, axisXOffset, weapon.y),
|
||||||
axisY = this.y + Angles.trnsy(rotation, axisXOffset, weapon.y);
|
axisY = this.y + Angles.trnsy(rotation, axisXOffset, weapon.y);
|
||||||
|
|
||||||
mount.targetRotation = Angles.angle(axisX, axisY, mount.aimX, mount.aimY) - rotation();
|
mount.targetRotation = Angles.angle(axisX, axisY, mount.aimX, mount.aimY) - rotation();
|
||||||
mount.rotation = Angles.moveToward(mount.rotation, mount.targetRotation, weapon.rotateSpeed * Time.delta());
|
mount.rotation = Angles.moveToward(mount.rotation, mount.targetRotation, weapon.rotateSpeed * Time.delta());
|
||||||
@@ -97,31 +103,31 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
|
|||||||
mount.targetRotation = angleTo(mount.aimX, mount.aimY);
|
mount.targetRotation = angleTo(mount.aimX, mount.aimY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mount.shoot && (ammo > 0 || !state.rules.unitAmmo || team().rules().infiniteAmmo)){
|
//shoot if applicable
|
||||||
|
if(mount.shoot && //must be shooting
|
||||||
|
(ammo > 0 || !state.rules.unitAmmo || team().rules().infiniteAmmo) && //check ammo
|
||||||
|
(!weapon.alternate || mount.side == weapon.flipSprite) &&
|
||||||
|
mount.reload <= 0.0001f && //reload has to be 0
|
||||||
|
Angles.within(weapon.rotate ? mount.rotation : this.rotation, mount.targetRotation, mount.weapon.shootCone) //has to be within the cone
|
||||||
|
){
|
||||||
|
|
||||||
float rotation = this.rotation - 90;
|
float rotation = this.rotation - 90;
|
||||||
|
float weaponRotation = rotation + (weapon.rotate ? mount.rotation : 0);
|
||||||
|
|
||||||
//shoot if applicable
|
//m a t h
|
||||||
if(mount.reload <= 0.0001f && Angles.within(weapon.rotate ? mount.rotation : this.rotation, mount.targetRotation, mount.weapon.shootCone)){
|
|
||||||
for(int i : (weapon.mirror && !weapon.alternate ? Mathf.signs : Mathf.one)){
|
|
||||||
i *= Mathf.sign(weapon.flipped) * (mount.weapon.mirror ? Mathf.sign(mount.side) : 1);
|
|
||||||
|
|
||||||
//m a t h
|
float mountX = this.x + Angles.trnsx(rotation, weapon.x, weapon.y),
|
||||||
float weaponRotation = rotation + (weapon.rotate ? mount.rotation : 0);
|
mountY = this.y + Angles.trnsy(rotation, weapon.x, weapon.y);
|
||||||
float mountX = this.x + Angles.trnsx(rotation, weapon.x * i, weapon.y),
|
float shootX = mountX + Angles.trnsx(weaponRotation, weapon.shootX, weapon.shootY),
|
||||||
mountY = this.y + Angles.trnsy(rotation, weapon.x * i, weapon.y);
|
shootY = mountY + Angles.trnsy(weaponRotation, weapon.shootX, weapon.shootY);
|
||||||
float shootX = mountX + Angles.trnsx(weaponRotation, weapon.shootX * i, weapon.shootY),
|
float shootAngle = weapon.rotate ? weaponRotation + 90 : Angles.angle(shootX, shootY, mount.aimX, mount.aimY) + (this.rotation - angleTo(mount.aimX, mount.aimY));
|
||||||
shootY = mountY + Angles.trnsy(weaponRotation, weapon.shootX * i, weapon.shootY);
|
|
||||||
float shootAngle = weapon.rotate ? weaponRotation + 90 : Angles.angle(shootX, shootY, mount.aimX, mount.aimY) + (this.rotation - angleTo(mount.aimX, mount.aimY));
|
|
||||||
|
|
||||||
shoot(weapon, shootX, shootY, mount.aimX, mount.aimY, shootAngle, -i);
|
shoot(weapon, shootX, shootY, mount.aimX, mount.aimY, shootAngle, Mathf.sign(weapon.x));
|
||||||
}
|
|
||||||
|
|
||||||
if(mount.weapon.mirror) mount.side = !mount.side;
|
mount.reload = weapon.reload;
|
||||||
mount.reload = weapon.reload;
|
|
||||||
|
|
||||||
ammo --;
|
ammo--;
|
||||||
if(ammo < 0) ammo = 0;
|
if(ammo < 0) ammo = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,24 +151,18 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
|
|||||||
Angles.shotgun(weapon.shots, weapon.spacing, rotation, f -> bullet(weapon, x, y, f + Mathf.range(weapon.inaccuracy), lifeScl));
|
Angles.shotgun(weapon.shots, weapon.spacing, rotation, f -> bullet(weapon, x, y, f + Mathf.range(weapon.inaccuracy), lifeScl));
|
||||||
}
|
}
|
||||||
|
|
||||||
Tmp.v1.trns(rotation + 180f, ammo.recoil);
|
|
||||||
|
|
||||||
if(this instanceof Velc){
|
if(this instanceof Velc){
|
||||||
//TODO apply force?
|
((Velc)this).vel().add(Tmp.v1.trns(rotation + 180f, ammo.recoil));
|
||||||
((Velc)this).vel().add(Tmp.v1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Tmp.v1.trns(rotation, 3f);
|
|
||||||
boolean parentize = ammo.keepVelocity;
|
boolean parentize = ammo.keepVelocity;
|
||||||
|
|
||||||
Effects.shake(weapon.shake, weapon.shake, x, y);
|
Effects.shake(weapon.shake, weapon.shake, x, y);
|
||||||
weapon.ejectEffect.at(x, y, rotation * side);
|
weapon.ejectEffect.at(x, y, rotation * side);
|
||||||
ammo.shootEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? this : null);
|
ammo.shootEffect.at(x, y, rotation, parentize ? this : null);
|
||||||
ammo.smokeEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? this : null);
|
ammo.smokeEffect.at(x, y, rotation, parentize ? this : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bullet(Weapon weapon, float x, float y, float angle, float lifescl){
|
private void bullet(Weapon weapon, float x, float y, float angle, float lifescl){
|
||||||
Tmp.v1.trns(angle, 3f);
|
weapon.bullet.create(this, team(), x, y, angle, (1f - weapon.velocityRnd) + Mathf.random(weapon.velocityRnd), lifescl);
|
||||||
weapon.bullet.create(this, team(), x + Tmp.v1.x, y + Tmp.v1.y, angle, (1f - weapon.velocityRnd) + Mathf.random(weapon.velocityRnd), lifescl);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ public class WeaponMount{
|
|||||||
public float targetRotation;
|
public float targetRotation;
|
||||||
/** aiming position in world coordinates */
|
/** aiming position in world coordinates */
|
||||||
public float aimX, aimY;
|
public float aimX, aimY;
|
||||||
/** side that's being shot - only valid for mirrors */
|
|
||||||
public boolean side;
|
|
||||||
/** whether to shoot right now */
|
/** whether to shoot right now */
|
||||||
public boolean shoot = false;
|
public boolean shoot = false;
|
||||||
/** whether to rotate to face the target right now */
|
/** whether to rotate to face the target right now */
|
||||||
public boolean rotate = false;
|
public boolean rotate = false;
|
||||||
|
/** extra state for alternating weapons */
|
||||||
|
public boolean side;
|
||||||
|
|
||||||
public WeaponMount(Weapon weapon){
|
public WeaponMount(Weapon weapon){
|
||||||
this.weapon = weapon;
|
this.weapon = weapon;
|
||||||
|
|||||||
@@ -137,6 +137,29 @@ public class UnitType extends UnlockableContent{
|
|||||||
range = Math.max(range, weapon.bullet.range());
|
range = Math.max(range, weapon.bullet.range());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add mirrored weapon variants
|
||||||
|
Seq<Weapon> mapped = new Seq<>();
|
||||||
|
for(Weapon w : weapons){
|
||||||
|
mapped.add(w);
|
||||||
|
|
||||||
|
//mirrors are copies with X values negated
|
||||||
|
if(w.mirror){
|
||||||
|
Weapon copy = w.copy();
|
||||||
|
copy.x *= -1;
|
||||||
|
copy.shootX *= -1;
|
||||||
|
copy.flipSprite = !copy.flipSprite;
|
||||||
|
mapped.add(copy);
|
||||||
|
|
||||||
|
//since there are now two weapons, the reload time must be doubled
|
||||||
|
w.reload *= 2f;
|
||||||
|
copy.reload *= 2f;
|
||||||
|
|
||||||
|
w.otherSide = mapped.size - 1;
|
||||||
|
copy.otherSide = mapped.size - 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.weapons = mapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
@@ -324,23 +347,17 @@ public class UnitType extends UnlockableContent{
|
|||||||
for(WeaponMount mount : unit.mounts){
|
for(WeaponMount mount : unit.mounts){
|
||||||
Weapon weapon = mount.weapon;
|
Weapon weapon = mount.weapon;
|
||||||
|
|
||||||
for(int i : (weapon.mirror ? Mathf.signs : Mathf.one)){
|
float rotation = unit.rotation - 90;
|
||||||
i *= Mathf.sign(weapon.flipped);
|
float weaponRotation = rotation + (weapon.rotate ? mount.rotation : 0);
|
||||||
|
float width = weapon.region.getWidth();
|
||||||
|
float recoil = -((mount.reload) / weapon.reload * weapon.recoil);
|
||||||
|
|
||||||
float rotation = unit.rotation - 90;
|
Draw.rect(weapon.region,
|
||||||
float weaponRotation = rotation + (weapon.rotate ? mount.rotation : 0);
|
unit.x + Angles.trnsx(rotation, weapon.x, weapon.y) + Angles.trnsx(weaponRotation, 0, recoil),
|
||||||
float width = i > 0 ? -weapon.region.getWidth() : weapon.region.getWidth();
|
unit.y + Angles.trnsy(rotation, weapon.x, weapon.y) + Angles.trnsy(weaponRotation, 0, recoil),
|
||||||
float recoil = -(mount.reload / weapon.reload * weapon.recoil) * (weapon.alternate ? Mathf.num(i == Mathf.sign(mount.side)) : 1);
|
width * Draw.scl * -Mathf.sign(weapon.flipSprite),
|
||||||
|
weapon.region.getHeight() * Draw.scl,
|
||||||
if(weapon.mirror) rotation = weaponRotation;
|
weaponRotation);
|
||||||
|
|
||||||
Draw.rect(weapon.region,
|
|
||||||
unit.x + Angles.trnsx(rotation, weapon.x * i, weapon.y) + Angles.trnsx(weaponRotation, 0, recoil),
|
|
||||||
unit.y + Angles.trnsy(rotation, weapon.x * i, weapon.y) + Angles.trnsy(weaponRotation, 0, recoil),
|
|
||||||
width * Draw.scl * -Mathf.sign(weapon.flipSprite),
|
|
||||||
weapon.region.getHeight() * Draw.scl,
|
|
||||||
weaponRotation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import mindustry.content.*;
|
|||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
import mindustry.io.*;
|
||||||
|
|
||||||
public class Weapon{
|
public class Weapon{
|
||||||
/** displayed weapon region */
|
/** displayed weapon region */
|
||||||
@@ -16,12 +17,12 @@ public class Weapon{
|
|||||||
public @NonNull BulletType bullet;
|
public @NonNull BulletType bullet;
|
||||||
/** shell ejection effect */
|
/** shell ejection effect */
|
||||||
public Effect ejectEffect = Fx.none;
|
public Effect ejectEffect = Fx.none;
|
||||||
/** whether to mirror the weapon (draw two of them, which is the default) */
|
/** whether to create a flipped copy of this weapon upon initialization. default: true */
|
||||||
public boolean mirror = true;
|
public boolean mirror = true;
|
||||||
/** whether to flip the weapon's position/side on the ship (only valid when mirror is false) */
|
/** whether to flip the weapon's sprite when rendering */
|
||||||
public boolean flipped = false, flipSprite = false;
|
public boolean flipSprite = false;
|
||||||
/** whether to shoot the weapons in different arms one after another, rather than all at once; only valid when mirror = true */
|
/** whether to shoot the weapons in different arms one after another, rather than all at once; only valid when mirror = true */
|
||||||
public boolean alternate = false;
|
public boolean alternate = true;
|
||||||
/** whether to rotate toward the target independently of unit */
|
/** whether to rotate toward the target independently of unit */
|
||||||
public boolean rotate = false;
|
public boolean rotate = false;
|
||||||
/** rotation speed of weapon when rotation is enabled, in degrees/t*/
|
/** rotation speed of weapon when rotation is enabled, in degrees/t*/
|
||||||
@@ -50,6 +51,8 @@ public class Weapon{
|
|||||||
public float shootCone = 5f;
|
public float shootCone = 5f;
|
||||||
/** whether shooter rotation is ignored when shooting. */
|
/** whether shooter rotation is ignored when shooting. */
|
||||||
public boolean ignoreRotation = false;
|
public boolean ignoreRotation = false;
|
||||||
|
/** internal value used for alternation - do not change! */
|
||||||
|
public int otherSide = -1;
|
||||||
/** sound used for shooting */
|
/** sound used for shooting */
|
||||||
public Sound shootSound = Sounds.pew;
|
public Sound shootSound = Sounds.pew;
|
||||||
/** displayed region (autoloaded) */
|
/** displayed region (autoloaded) */
|
||||||
@@ -63,6 +66,12 @@ public class Weapon{
|
|||||||
this("");
|
this("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Weapon copy(){
|
||||||
|
Weapon out = new Weapon();
|
||||||
|
JsonIO.json().copyFields(this, out);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
public void load(){
|
public void load(){
|
||||||
region = Core.atlas.find(name, Core.atlas.find("clear"));
|
region = Core.atlas.find(name, Core.atlas.find("clear"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class TractorBeamTurret extends Block{
|
|||||||
public float shootCone = 6f;
|
public float shootCone = 6f;
|
||||||
public float laserWidth = 0.6f;
|
public float laserWidth = 0.6f;
|
||||||
public float force = 0.3f;
|
public float force = 0.3f;
|
||||||
|
public float scaledForce = 0f;
|
||||||
public float damage = 0f;
|
public float damage = 0f;
|
||||||
public boolean targetAir = true, targetGround = false;
|
public boolean targetAir = true, targetGround = false;
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ public class TractorBeamTurret extends Block{
|
|||||||
|
|
||||||
//shoot when possible
|
//shoot when possible
|
||||||
if(Angles.within(rotation, dest, shootCone)){
|
if(Angles.within(rotation, dest, shootCone)){
|
||||||
target.impulse(Tmp.v1.set(this).sub(target).limit(force * efficiency() * timeScale));
|
target.impulse(Tmp.v1.set(this).sub(target).limit((force + (1f - target.dst(this) / range) * scaledForce) * efficiency() * timeScale));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
target = null;
|
target = null;
|
||||||
|
|||||||
@@ -302,6 +302,7 @@ public class Generators{
|
|||||||
if(type.isHidden()) return; //hidden units don't generate
|
if(type.isHidden()) return; //hidden units don't generate
|
||||||
|
|
||||||
type.load();
|
type.load();
|
||||||
|
type.init();
|
||||||
|
|
||||||
Image image = ImagePacker.get(type.parts > 0 ? type.partRegions[0] : type.region);
|
Image image = ImagePacker.get(type.parts > 0 ? type.partRegions[0] : type.region);
|
||||||
for(int i = 1; i < type.parts; i++){
|
for(int i = 1; i < type.parts; i++){
|
||||||
@@ -335,14 +336,10 @@ public class Generators{
|
|||||||
for(Weapon weapon : type.weapons){
|
for(Weapon weapon : type.weapons){
|
||||||
weapon.load();
|
weapon.load();
|
||||||
|
|
||||||
for(int i : (weapon.mirror ? Mathf.signs : Mathf.one)){
|
image.draw(weapon.region,
|
||||||
i *= Mathf.sign(weapon.flipped);
|
(int)(weapon.x / Draw.scl + image.width / 2f - weapon.region.getWidth() / 2f),
|
||||||
|
(int)(-weapon.y / Draw.scl + image.height / 2f - weapon.region.getHeight() / 2f),
|
||||||
image.draw(weapon.region,
|
weapon.flipSprite, false);
|
||||||
(int)(i * weapon.x / Draw.scl + image.width / 2 - weapon.region.getWidth() / 2),
|
|
||||||
(int)(-weapon.y / Draw.scl + image.height / 2f - weapon.region.getHeight() / 2f),
|
|
||||||
i > 0, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
image.save("unit-" + type.name + "-full");
|
image.save("unit-" + type.name + "-full");
|
||||||
|
|||||||