Fixed some multiplayer bugs

This commit is contained in:
Anuken
2022-02-11 14:07:36 -05:00
parent 3728d137cd
commit ba3e2f6f67
5 changed files with 27 additions and 16 deletions

View File

@@ -3320,7 +3320,7 @@ public class Blocks{
ammo(Items.scrap, new BasicBulletType(){{
damage = 40;
speed = 8f;
speed = 8.5f;
width = 11f;
height = 16f;
trailColor = Pal.bulletYellowBack;
@@ -3329,13 +3329,20 @@ public class Blocks{
collidesTiles = false;
shootEffect = Fx.shootBig2;
smokeEffect = Fx.shootBigSmoke2;
frontColor = Color.white;
backColor = Color.valueOf("869cbe");
lifetime = 34f;
//controversial
homingDelay = 10f;
homingPower = 0.01f;
}});
//TODO bullet.
//recoilAmount = 1f;
reloadTime = 8f;
shootLength = 15f;
shootLength = 14f;
rotateSpeed = 5f;
coolantUsage = 30f / 60f;
@@ -3350,7 +3357,7 @@ public class Blocks{
widthSpread = true;
targetGround = false;
spread = 4.6f;
inaccuracy = 8f;
inaccuracy = 9f;
restitution = 0.1f;
shootWarmupSpeed = 0.08f;
@@ -3359,7 +3366,7 @@ public class Blocks{
acceptCoolant = false;
scaledHealth = 340;
range = 250f;
range = 270f;
size = 4;
}};

View File

@@ -34,7 +34,8 @@ import static mindustry.Vars.*;
public class NetClient implements ApplicationListener{
private static final float dataTimeout = 60 * 20;
private static final float playerSyncTime = 5;
/** ticks between syncs, e.g. 5 means 60/5 = 12 syncs/sec*/
private static final float playerSyncTime = 4;
private static final Reads dataReads = new Reads(null);
private long ping;

View File

@@ -728,12 +728,9 @@ public class DesktopInput extends InputHandler{
}
Call.commandUnits(player, ids, attack instanceof Building b ? b : null, attack instanceof Unit u ? u : null, target);
}
}
return super.tap(x, y, count, button);
}

View File

@@ -194,6 +194,9 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
public static void commandUnits(Player player, int[] unitIds, @Nullable Building buildTarget, @Nullable Unit unitTarget, @Nullable Vec2 posTarget){
if(player == null || unitIds == null) return;
//why did I ever think this was a good idea
if(unitTarget != null && unitTarget.isNull()) unitTarget = null;
if(net.server() && !netServer.admins.allowAction(player, ActionType.commandUnits, event -> {
event.unitIDs = unitIds;
})){

View File

@@ -443,15 +443,18 @@ public class Weapon implements Cloneable{
if(unitSpawned == null){
return bullet.create(unit, unit.team, x, y, angle, (1f - velocityRnd) + Mathf.random(velocityRnd), lifescl);
}else{
Unit spawned = unitSpawned.create(unit.team);
spawned.set(x, y);
spawned.rotation = angle;
//immediately spawn at top speed, since it was launched
spawned.vel.trns(angle, unitSpawned.speed);
if(spawned.controller() instanceof MissileAI ai){
ai.shooter = unit;
//don't spawn units clientside!
if(!net.client()){
Unit spawned = unitSpawned.create(unit.team);
spawned.set(x, y);
spawned.rotation = angle;
//immediately spawn at top speed, since it was launched
spawned.vel.trns(angle, unitSpawned.speed);
if(spawned.controller() instanceof MissileAI ai){
ai.shooter = unit;
}
spawned.add();
}
spawned.add();
//TODO assign AI target here?
return null;
}