Football fixes

This commit is contained in:
Beny 2020-09-13 07:25:05 +02:00
parent e70bffccf3
commit 1b779b772e
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)
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);
}
}
@ -69,7 +69,7 @@ public abstract class InteractionPushable extends InteractionDefault {
if (this.currentThread != null)
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);
}
}
@ -80,6 +80,7 @@ public abstract class InteractionPushable extends InteractionDefault {
super.onWalkOn(roomUnit, room, objects);
int velocity;
boolean isDrag = false;
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
@ -92,13 +93,14 @@ public abstract class InteractionPushable extends InteractionDefault {
velocity = this.getDragVelocity(roomUnit, room);
direction = this.getDragDirection(roomUnit, room);
this.onDrag(room, roomUnit, velocity, direction);
isDrag = true;
}
if (velocity > 0) {
if (this.currentThread != null)
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);
}
}

View File

@ -1,5 +1,6 @@
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.football.FootballGame;
import com.eu.habbo.habbohotel.items.Item;
@ -34,12 +35,18 @@ public class InteractionFootball extends InteractionPushable {
if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2)
return 0;
return 6;
if (roomUnit.getPath().size() == 0 && roomUnit.tilesWalked() == 1)
return 6;
return 1;
}
@Override
public int getWalkOffVelocity(RoomUnit roomUnit, Room room) {
return 6;
if (roomUnit.getPath().size() == 0)
return 6;
return 1;
}
@Override
@ -79,8 +86,17 @@ public class InteractionFootball extends InteractionPushable {
@Override
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
@ -176,8 +192,11 @@ public class InteractionFootball extends InteractionPushable {
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());
/*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
@ -194,7 +213,7 @@ public class InteractionFootball extends InteractionPushable {
@Override
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);
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

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.
private RoomUserRotation currentDirection; //The current direction the item is moving in
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.room = room;
this.kicker = kicker;
this.currentDirection = direction;
this.totalSteps = steps;
this.currentStep = 0;
this.isDrag = isDrag;
}
@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)) {
RoomUserRotation oldDirection = this.currentDirection;
this.currentDirection = this.ball.getBounceDirection(this.room, this.currentDirection);
if(!this.isDrag) {
this.currentDirection = this.ball.getBounceDirection(this.room, this.currentDirection);
}
if (this.currentDirection != oldDirection) {
this.ball.onBounce(this.room, oldDirection, this.currentDirection, this.kicker);