Merge branch 'football-fixes' into 'dev'

Football fixes

See merge request morningstar/Arcturus-Community!291
This commit is contained in:
Harmonic 2020-09-19 13:16:25 -04:00
commit 58ceabf338
3 changed files with 37 additions and 11 deletions

View File

@ -50,7 +50,7 @@ public abstract class InteractionPushable extends InteractionDefault {
if (this.currentThread != null) if (this.currentThread != null)
this.currentThread.dead = true; this.currentThread.dead = true;
this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity); this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity, false);
Emulator.getThreading().run(this.currentThread, 0); Emulator.getThreading().run(this.currentThread, 0);
} }
} }
@ -69,7 +69,7 @@ public abstract class InteractionPushable extends InteractionDefault {
if (this.currentThread != null) if (this.currentThread != null)
this.currentThread.dead = true; this.currentThread.dead = true;
this.currentThread = new KickBallAction(this, room, client.getHabbo().getRoomUnit(), direction, velocity); this.currentThread = new KickBallAction(this, room, client.getHabbo().getRoomUnit(), direction, velocity, false);
Emulator.getThreading().run(this.currentThread, 0); Emulator.getThreading().run(this.currentThread, 0);
} }
} }
@ -80,6 +80,7 @@ public abstract class InteractionPushable extends InteractionDefault {
super.onWalkOn(roomUnit, room, objects); super.onWalkOn(roomUnit, room, objects);
int velocity; int velocity;
boolean isDrag = false;
RoomUserRotation direction; RoomUserRotation direction;
if (this.getX() == roomUnit.getGoal().x && this.getY() == roomUnit.getGoal().y) //User clicked on the tile the ball is on, they want to kick it if (this.getX() == roomUnit.getGoal().x && this.getY() == roomUnit.getGoal().y) //User clicked on the tile the ball is on, they want to kick it
@ -92,13 +93,14 @@ public abstract class InteractionPushable extends InteractionDefault {
velocity = this.getDragVelocity(roomUnit, room); velocity = this.getDragVelocity(roomUnit, room);
direction = this.getDragDirection(roomUnit, room); direction = this.getDragDirection(roomUnit, room);
this.onDrag(room, roomUnit, velocity, direction); this.onDrag(room, roomUnit, velocity, direction);
isDrag = true;
} }
if (velocity > 0) { if (velocity > 0) {
if (this.currentThread != null) if (this.currentThread != null)
this.currentThread.dead = true; this.currentThread.dead = true;
this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity); this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity, isDrag);
Emulator.getThreading().run(this.currentThread, 0); Emulator.getThreading().run(this.currentThread, 0);
} }
} }

View File

@ -1,5 +1,6 @@
package com.eu.habbo.habbohotel.items.interactions.games.football; package com.eu.habbo.habbohotel.items.interactions.games.football;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.games.football.FootballGame; import com.eu.habbo.habbohotel.games.football.FootballGame;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
@ -34,12 +35,18 @@ public class InteractionFootball extends InteractionPushable {
if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2) if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2)
return 0; return 0;
if (roomUnit.getPath().size() == 0 && roomUnit.tilesWalked() == 1)
return 6; return 6;
return 1;
} }
@Override @Override
public int getWalkOffVelocity(RoomUnit roomUnit, Room room) { public int getWalkOffVelocity(RoomUnit roomUnit, Room room) {
if (roomUnit.getPath().size() == 0)
return 6; return 6;
return 1;
} }
@Override @Override
@ -79,8 +86,17 @@ public class InteractionFootball extends InteractionPushable {
@Override @Override
public int getNextRollDelay(int currentStep, int totalSteps) { public int getNextRollDelay(int currentStep, int totalSteps) {
int t = 2500;
return (totalSteps == 1) ? 500 : 100 * ((t = t / t - 1) * t * t * t * t + 1) + (currentStep * 100); if(totalSteps > 4) {
if(currentStep <= 4) {
return 125;
}
}
return 500;
/*int t = 2500;
return (totalSteps == 1) ? 500 : 100 * ((t = t / t - 1) * t * t * t * t + 1) + (currentStep * 100);*/
} }
@Override @Override
@ -176,8 +192,11 @@ public class InteractionFootball extends InteractionPushable {
game.onScore(kicker, color); game.onScore(kicker, color);
} }
this.setExtradata(nextRoll <= 200 ? "8" : (nextRoll <= 250 ? "7" : (nextRoll <= 300 ? "6" : (nextRoll <= 350 ? "5" : (nextRoll <= 400 ? "4" : (nextRoll <= 450 ? "3" : (nextRoll <= 500 ? "2" : "1"))))))); this.setExtradata(Math.abs(currentStep - (totalSteps + 1)) + "");
room.sendComposer(new ItemStateComposer(this).compose()); room.sendComposer(new ItemStateComposer(this).compose());
/*this.setExtradata(nextRoll <= 200 ? "8" : (nextRoll <= 250 ? "7" : (nextRoll <= 300 ? "6" : (nextRoll <= 350 ? "5" : (nextRoll <= 400 ? "4" : (nextRoll <= 450 ? "3" : (nextRoll <= 500 ? "2" : "1")))))));
room.sendComposer(new ItemStateComposer(this).compose());*/
} }
@Override @Override
@ -194,7 +213,7 @@ public class InteractionFootball extends InteractionPushable {
@Override @Override
public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) {
HabboItem topItem = room.getTopItemAt(from.x, from.y, this); HabboItem topItem = room.getTopItemAt(from.x, from.y, this);
return !(room.hasHabbosAt(to.x, to.y) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1)); return !((Emulator.getRandom().nextInt(10) >= 3 && room.hasHabbosAt(to.x, to.y)) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1));
} }
@Override @Override

View File

@ -18,14 +18,16 @@ public class KickBallAction implements Runnable {
public boolean dead = false; //When true the run() function will not execute. Used when another user kicks the ball whilst it is arleady moving. public boolean dead = false; //When true the run() function will not execute. Used when another user kicks the ball whilst it is arleady moving.
private RoomUserRotation currentDirection; //The current direction the item is moving in private RoomUserRotation currentDirection; //The current direction the item is moving in
private int currentStep; //The current step of the move sequence private int currentStep; //The current step of the move sequence
public final boolean isDrag;
public KickBallAction(InteractionPushable ball, Room room, RoomUnit kicker, RoomUserRotation direction, int steps) { public KickBallAction(InteractionPushable ball, Room room, RoomUnit kicker, RoomUserRotation direction, int steps, boolean isDrag) {
this.ball = ball; this.ball = ball;
this.room = room; this.room = room;
this.kicker = kicker; this.kicker = kicker;
this.currentDirection = direction; this.currentDirection = direction;
this.totalSteps = steps; this.totalSteps = steps;
this.currentStep = 0; this.currentStep = 0;
this.isDrag = isDrag;
} }
@Override @Override
@ -39,7 +41,10 @@ public class KickBallAction implements Runnable {
if (next == null || !this.ball.validMove(this.room, this.room.getLayout().getTile(this.ball.getX(), this.ball.getY()), next)) { if (next == null || !this.ball.validMove(this.room, this.room.getLayout().getTile(this.ball.getX(), this.ball.getY()), next)) {
RoomUserRotation oldDirection = this.currentDirection; RoomUserRotation oldDirection = this.currentDirection;
if(!this.isDrag) {
this.currentDirection = this.ball.getBounceDirection(this.room, this.currentDirection); this.currentDirection = this.ball.getBounceDirection(this.room, this.currentDirection);
}
if (this.currentDirection != oldDirection) { if (this.currentDirection != oldDirection) {
this.ball.onBounce(this.room, oldDirection, this.currentDirection, this.kicker); this.ball.onBounce(this.room, oldDirection, this.currentDirection, this.kicker);