Multiplayer bugfixes / Balancing

This commit is contained in:
Anuken
2019-04-04 14:46:41 -04:00
parent bab87c0da8
commit 2d18df2011
14 changed files with 56 additions and 50 deletions

View File

@@ -1043,7 +1043,7 @@ public class Blocks implements ContentList{
differentialGenerator = new ItemLiquidGenerator(true, true, "differential-generator"){{ differentialGenerator = new ItemLiquidGenerator(true, true, "differential-generator"){{
requirements(Category.power, ItemStack.with(Items.copper, 140, Items.titanium, 100, Items.lead, 200, Items.silicon, 130, Items.metaglass, 100)); requirements(Category.power, ItemStack.with(Items.copper, 140, Items.titanium, 100, Items.lead, 200, Items.silicon, 130, Items.metaglass, 100));
powerProduction = 13f; powerProduction = 16f;
itemDuration = 50f; itemDuration = 50f;
hasLiquids = true; hasLiquids = true;
size = 3; size = 3;
@@ -1083,9 +1083,9 @@ public class Blocks implements ContentList{
requirements(Category.power, ItemStack.with(Items.lead, 1000, Items.silicon, 600, Items.graphite, 800, Items.thorium, 200, Items.surgealloy, 500, Items.metaglass, 500)); requirements(Category.power, ItemStack.with(Items.lead, 1000, Items.silicon, 600, Items.graphite, 800, Items.thorium, 200, Items.surgealloy, 500, Items.metaglass, 500));
size = 4; size = 4;
health = 900; health = 900;
powerProduction = 80f; powerProduction = 100f;
itemDuration = 40f; itemDuration = 40f;
consumes.power(23f); consumes.power(25f);
consumes.item(Items.blastCompound); consumes.item(Items.blastCompound);
consumes.liquid(Liquids.cryofluid, 0.8f); consumes.liquid(Liquids.cryofluid, 0.8f);
}}; }};
@@ -1505,12 +1505,12 @@ public class Blocks implements ContentList{
shootShake = 2f; shootShake = 2f;
powerUsed = 0.5f; powerUsed = 0.5f;
consumes.powerBuffered(1200f); consumes.powerBuffered(1200f);
range = 160f; range = 190f;
reload = 170f; reload = 170f;
firingMoveFract = 0.1f; firingMoveFract = 0.2f;
shootDuration = 220f; shootDuration = 220f;
health = 165 * size * size; health = 200 * size * size;
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.5f)).update(false); consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.5f)).update(false);
}}; }};

View File

@@ -533,13 +533,13 @@ public class Bullets implements ContentList{
} }
}; };
meltdownLaser = new BulletType(0.001f, 35){ meltdownLaser = new BulletType(0.001f, 50){
Color tmpColor = new Color(); Color tmpColor = new Color();
Color[] colors = {Color.valueOf("ec745855"), Color.valueOf("ec7458aa"), Color.valueOf("ff9c5a"), Color.WHITE}; Color[] colors = {Color.valueOf("ec745855"), Color.valueOf("ec7458aa"), Color.valueOf("ff9c5a"), Color.WHITE};
float[] tscales = {1f, 0.7f, 0.5f, 0.2f}; float[] tscales = {1f, 0.7f, 0.5f, 0.2f};
float[] strokes = {2f, 1.5f, 1f, 0.3f}; float[] strokes = {2f, 1.5f, 1f, 0.3f};
float[] lenscales = {1f, 1.12f, 1.15f, 1.17f}; float[] lenscales = {1f, 1.12f, 1.15f, 1.17f};
float length = 200f; float length = 220f;
{ {
hitEffect = Fx.hitMeltdown; hitEffect = Fx.hitMeltdown;

View File

@@ -63,6 +63,7 @@ public class NetClient implements ApplicationListener{
public NetClient(){ public NetClient(){
Net.handleClient(Connect.class, packet -> { Net.handleClient(Connect.class, packet -> {
Log.info("Connecting to server: {0}", packet.addressTCP);
player.isAdmin = false; player.isAdmin = false;

View File

@@ -190,20 +190,7 @@ public class NetServer implements ApplicationListener{
//playing in pvp mode automatically assigns players to teams //playing in pvp mode automatically assigns players to teams
if(state.rules.pvp){ if(state.rules.pvp){
//find team with minimum amount of players and auto-assign player to that. player.setTeam(assignTeam());
Team min = Structs.findMin(Team.all, team -> {
if(state.teams.isActive(team)){
int count = 0;
for(Player other : playerGroup.all()){
if(other.getTeam() == team){
count ++;
}
}
return count;
}
return Integer.MAX_VALUE;
});
player.setTeam(min);
Log.info("Auto-assigned player {0} to team {1}.", player.name, player.getTeam()); Log.info("Auto-assigned player {0} to team {1}.", player.name, player.getTeam());
} }
@@ -221,6 +208,22 @@ public class NetServer implements ApplicationListener{
}); });
} }
public Team assignTeam(){
//find team with minimum amount of players and auto-assign player to that.
return Structs.findMin(Team.all, team -> {
if(state.teams.isActive(team)){
int count = 0;
for(Player other : playerGroup.all()){
if(other.getTeam() == team){
count ++;
}
}
return count;
}
return Integer.MAX_VALUE;
});
}
public void sendWorldData(Player player, int clientID){ public void sendWorldData(Player player, int clientID){
ByteArrayOutputStream stream = new ByteArrayOutputStream(); ByteArrayOutputStream stream = new ByteArrayOutputStream();
DeflaterOutputStream def = new DeflaterOutputStream(stream); DeflaterOutputStream def = new DeflaterOutputStream(stream);
@@ -427,7 +430,7 @@ public class NetServer implements ApplicationListener{
Log.err("Cannot kick unknown player!"); Log.err("Cannot kick unknown player!");
return; return;
}else{ }else{
Log.info("Kicking connection #{0} / IP: {1}. Reason: {2}", connection, con.address, reason); Log.info("Kicking connection #{0} / IP: {1}. Reason: {2}", connection, con.address, reason.name());
} }
Player player = connections.get(con.id); Player player = connections.get(con.id);

View File

@@ -133,7 +133,7 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool
public float damageMultiplier(){ public float damageMultiplier(){
if(owner instanceof Unit){ if(owner instanceof Unit){
return type.damage * ((Unit) owner).getDamageMultipler(); return ((Unit) owner).getDamageMultipler();
} }
if(owner instanceof Lightning && data instanceof Float){ if(owner instanceof Lightning && data instanceof Float){

View File

@@ -357,6 +357,8 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
interpolator.read(lastx, lasty, x, y, rotation); interpolator.read(lastx, lasty, x, y, rotation);
rotation = lastrot; rotation = lastrot;
x = lastx;
y = lasty;
} }
public void onSuperDeath(){ public void onSuperDeath(){

View File

@@ -211,8 +211,6 @@ public abstract class GroundUnit extends BaseUnit{
if(tile == targetTile) return; if(tile == targetTile) return;
float angle = angleTo(targetTile);
velocity.add(vec.trns(angleTo(targetTile), type.speed*Time.delta())); velocity.add(vec.trns(angleTo(targetTile), type.speed*Time.delta()));
if(Units.invalidateTarget(target, this)){ if(Units.invalidateTarget(target, this)){
rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed); rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed);
@@ -237,8 +235,6 @@ public abstract class GroundUnit extends BaseUnit{
if(tile == targetTile || core == null || dst(core) < 90f) return; if(tile == targetTile || core == null || dst(core) < 90f) return;
float angle = angleTo(targetTile);
velocity.add(vec.trns(angleTo(targetTile), type.speed*Time.delta())); velocity.add(vec.trns(angleTo(targetTile), type.speed*Time.delta()));
rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed); rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed);
} }

View File

@@ -879,10 +879,10 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
interpolator.read(lastx, lasty, x, y, rotation, baseRotation); interpolator.read(lastx, lasty, x, y, rotation, baseRotation);
rotation = lastrot; rotation = lastrot;
x = lastx;
y = lasty;
if(isLocal){ if(isLocal){
x = lastx;
y = lasty;
velocity.x = lastvx; velocity.x = lastvx;
velocity.y = lastvy; velocity.y = lastvy;
}else{ }else{

View File

@@ -95,7 +95,9 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
@Override @Override
public void damage(float amount){ public void damage(float amount){
super.damage(calculateDamage(amount)); if(!Net.client()){
super.damage(calculateDamage(amount));
}
hitTime = hitDuration; hitTime = hitDuration;
} }

View File

@@ -83,7 +83,7 @@ public class Map implements Comparable<Map>{
} }
public String tag(String name){ public String tag(String name){
return tags.containsKey(name) && !tags.get(name).trim().isEmpty() ? tags.get(name): Core.bundle.get("unknown"); return tags.containsKey(name) && !tags.get(name).trim().isEmpty() ? tags.get(name) : Core.bundle.get("unknown");
} }
public boolean hasTag(String name){ public boolean hasTag(String name){

View File

@@ -163,7 +163,7 @@ public class Administration{
public boolean adminPlayer(String id, String usid){ public boolean adminPlayer(String id, String usid){
PlayerInfo info = getCreateInfo(id); PlayerInfo info = getCreateInfo(id);
if(info.admin) if(info.admin && info.adminUsid != null && info.adminUsid.equals(usid))
return false; return false;
info.adminUsid = usid; info.adminUsid = usid;

View File

@@ -36,7 +36,6 @@ public class Interpolator{
} }
public void update(){ public void update(){
if(lastUpdated != 0 && updateSpacing != 0){ if(lastUpdated != 0 && updateSpacing != 0){
float timeSinceUpdate = Time.timeSinceMillis(lastUpdated); float timeSinceUpdate = Time.timeSinceMillis(lastUpdated);
float alpha = Math.min(timeSinceUpdate / updateSpacing, 2f); float alpha = Math.min(timeSinceUpdate / updateSpacing, 2f);

View File

@@ -69,10 +69,10 @@ public class PlayerListFragment extends Fragment{
playerGroup.all().sort((p1, p2) -> p1.getTeam().compareTo(p2.getTeam())); playerGroup.all().sort((p1, p2) -> p1.getTeam().compareTo(p2.getTeam()));
playerGroup.forEach(player -> { playerGroup.forEach(user -> {
NetConnection connection = player.con; NetConnection connection = user.con;
if(connection == null && Net.server() && !player.isLocal) return; if(connection == null && Net.server() && !user.isLocal) return;
Table button = new Table(); Table button = new Table();
button.left(); button.left();
@@ -90,15 +90,15 @@ public class PlayerListFragment extends Fragment{
} }
}; };
table.margin(8); table.margin(8);
table.add(new Image(player.mech.iconRegion)).grow(); table.add(new Image(user.mech.iconRegion)).grow();
button.add(table).size(h); button.add(table).size(h);
button.labelWrap("[#" + player.color.toString().toUpperCase() + "]" + player.name).width(170f).pad(10); button.labelWrap("[#" + user.color.toString().toUpperCase() + "]" + user.name).width(170f).pad(10);
button.add().grow(); button.add().grow();
button.addImage("icon-admin").size(14 * 2).visible(() -> player.isAdmin && !(!player.isLocal && Net.server())).padRight(5).get().updateVisibility(); button.addImage("icon-admin").size(14 * 2).visible(() -> user.isAdmin && !(!user.isLocal && Net.server())).padRight(5).get().updateVisibility();
if((Net.server() || player.isAdmin) && !player.isLocal && (!player.isAdmin || Net.server())){ if((Net.server() || player.isAdmin) && !user.isLocal && (!user.isAdmin || Net.server())){
button.add().growY(); button.add().growY();
float bs = (h) / 2f; float bs = (h) / 2f;
@@ -107,36 +107,36 @@ public class PlayerListFragment extends Fragment{
t.defaults().size(bs); t.defaults().size(bs);
t.addImageButton("icon-ban", "clear-partial", 14 * 2, t.addImageButton("icon-ban", "clear-partial", 14 * 2,
() -> ui.showConfirm("$confirm", "$confirmban", () -> Call.onAdminRequest(player, AdminAction.ban))); () -> ui.showConfirm("$confirm", "$confirmban", () -> Call.onAdminRequest(user, AdminAction.ban)));
t.addImageButton("icon-cancel", "clear-partial", 16 * 2, t.addImageButton("icon-cancel", "clear-partial", 16 * 2,
() -> ui.showConfirm("$confirm", "$confirmkick", () -> Call.onAdminRequest(player, AdminAction.kick))); () -> ui.showConfirm("$confirm", "$confirmkick", () -> Call.onAdminRequest(user, AdminAction.kick)));
t.row(); t.row();
t.addImageButton("icon-admin", "clear-toggle-partial", 14 * 2, () -> { t.addImageButton("icon-admin", "clear-toggle-partial", 14 * 2, () -> {
if(Net.client()) return; if(Net.client()) return;
String id = player.uuid; String id = user.uuid;
if(netServer.admins.isAdmin(id, connection.address)){ if(netServer.admins.isAdmin(id, connection.address)){
ui.showConfirm("$confirm", "$confirmunadmin", () -> netServer.admins.unAdminPlayer(id)); ui.showConfirm("$confirm", "$confirmunadmin", () -> netServer.admins.unAdminPlayer(id));
}else{ }else{
ui.showConfirm("$confirm", "$confirmadmin", () -> netServer.admins.adminPlayer(id, player.usid)); ui.showConfirm("$confirm", "$confirmadmin", () -> netServer.admins.adminPlayer(id, user.usid));
} }
}) })
.update(b -> b.setChecked(player.isAdmin)) .update(b -> b.setChecked(user.isAdmin))
.disabled(b -> Net.client()) .disabled(b -> Net.client())
.touchable(() -> Net.client() ? Touchable.disabled : Touchable.enabled) .touchable(() -> Net.client() ? Touchable.disabled : Touchable.enabled)
.checked(player.isAdmin); .checked(user.isAdmin);
t.addImageButton("icon-zoom-small", "clear-partial", 14 * 2, () -> ui.showError("Currently unimplemented.")/*Call.onAdminRequest(player, AdminAction.trace)*/); t.addImageButton("icon-zoom-small", "clear-partial", 14 * 2, () -> ui.showError("Currently unimplemented.")/*Call.onAdminRequest(user, AdminAction.trace)*/);
}).padRight(12).size(bs + 10f, bs); }).padRight(12).size(bs + 10f, bs);
} }
content.add(button).padBottom(-6).width(350f).maxHeight(h + 14); content.add(button).padBottom(-6).width(350f).maxHeight(h + 14);
content.row(); content.row();
content.addImage("blank").height(3f).color(state.rules.pvp ? player.getTeam().color : Pal.accent).growX(); content.addImage("blank").height(3f).color(state.rules.pvp ? user.getTeam().color : Pal.accent).growX();
content.row(); content.row();
}); });

View File

@@ -144,7 +144,7 @@ public class ServerControl implements ApplicationListener{
Call.onInfoMessage((state.rules.pvp Call.onInfoMessage((state.rules.pvp
? "[YELLOW]The " + event.winner.name() + " team is victorious![]" : "[SCARLET]Game over![]") ? "[YELLOW]The " + event.winner.name() + " team is victorious![]" : "[SCARLET]Game over![]")
+ "\nNext selected map:[accent] "+map.name()+"[]" + "\nNext selected map:[accent] "+map.name()+"[]"
+ (map.author() != null ? " by[accent] " + map.author() + "[]" : "") + "."+ + (map.tags.containsKey("author") && !map.tags.get("author").trim().isEmpty() ? " by[accent] " + map.author() + "[]" : "") + "."+
"\nNew game begins in " + roundExtraTime + " seconds."); "\nNew game begins in " + roundExtraTime + " seconds.");
info("Selected next map to be {0}.", map.name()); info("Selected next map to be {0}.", map.name());
@@ -662,6 +662,9 @@ public class ServerControl implements ApplicationListener{
logic.play(); logic.play();
for(Player p : players){ for(Player p : players){
p.reset(); p.reset();
if(state.rules.pvp){
p.setTeam(netServer.assignTeam());
}
netServer.sendWorldData(p, p.con.id); netServer.sendWorldData(p, p.con.id);
} }
inExtraRound = false; inExtraRound = false;