animation fixes for pool

This commit is contained in:
Lorenc Pekaj 2018-09-14 18:00:41 +10:00
parent a8c06186a4
commit f9d2262b58

View File

@ -174,6 +174,12 @@ hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
{
if ( g_poolTableData[ poolid ] [ E_STARTED ] )
{
// quit table
if ( HOLDING( KEY_SECONDARY_ATTACK ) ) {
Pool_SendTableMessage( poolid, COLOR_GREY, "-- "COL_WHITE" %s(%d) has left the table", ReturnPlayerName( playerid ), playerid );
return Pool_RemovePlayer( playerid );
}
// make pressing key fire annoying
if ( RELEASED( KEY_FIRE ) && g_poolTableData[ poolid ] [ E_AIMER ] != playerid && ! p_PoolChalking{ playerid } )
{
@ -249,13 +255,12 @@ hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
new
Float: distance_to_ball = GetDistanceFromPointToPoint( X, Y, Xa, Ya );
if ( distance_to_ball < 1.5 && Z < 999.5 )
if ( distance_to_ball < 1.8 && Z < 999.5 )
{
printf( "Distance To Ball %f", distance_to_ball );
TogglePlayerControllable( playerid, false );
GetAngleToXY( Xa, Ya, X, Y, poolrot );
SetPlayerFacingAngle(playerid, poolrot);
p_PoolAngle[ playerid ] [ 0 ] = poolrot;
p_PoolAngle[ playerid ] [ 1 ] = poolrot;
@ -266,7 +271,20 @@ hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
SetPlayerCameraPos( playerid, g_poolTableData[ poolid ] [ E_X ], g_poolTableData[ poolid ] [ E_Y ], g_poolTableData[ poolid ] [ E_Z ] + 2.0 );
ApplyAnimation( playerid, "POOL", "POOL_Med_Start", 4.1, 0, 1, 1, 0, 0, 1 );
if ( distance_to_ball < 1.20 ) {
distance_to_ball = 1.20;
}
GetXYInFrontOfPos( Xa, Ya, poolrot + 180 - 5.0, X, Y, distance_to_ball ); // offset 5 degrees
SetPlayerPos( playerid, X, Y, Z );
SetPlayerFacingAngle( playerid, poolrot );
if ( distance_to_ball > 1.5 ) {
ApplyAnimation( playerid, "POOL", "POOL_XLong_Start", 4.1, 0, 1, 1, 1, 1, 1 );
} else { //if ( distance_to_ball > 1.2 ) {
ApplyAnimation( playerid, "POOL", "POOL_Long_Start", 4.1, 0, 1, 1, 1, 1, 1 );
//ApplyAnimation( playerid, "POOL", "POOL_Med_Start", 4.1, 0, 1, 1, 1, 1, 1 );
}
g_poolTableData[ poolid ] [ E_AIMER ] = playerid;
g_poolTableData[ poolid ] [ E_POWER ] = 1.0;
@ -286,6 +304,7 @@ hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
ClearAnimations( playerid );
SetCameraBehindPlayer( playerid );
ApplyAnimation( playerid, "CARRY", "crry_prtial", 4.0, 0, 1, 1, 0, 0 );
g_poolTableData[ poolid ] [ E_AIMER ] = -1;
DestroyObject( g_poolTableData[ poolid ] [ E_AIMER_OBJECT ] );
@ -306,8 +325,13 @@ hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
Pool_UpdateScoreboard( poolid );
GetObjectPos( g_poolBallData[ poolid ] [ E_BALL_OBJECT ] [ 0 ], ball_x, ball_y, ball_z );
new Float: distance_to_ball = GetPlayerDistanceFromPoint( playerid, ball_x, ball_y, ball_z );
ApplyAnimation( playerid, "POOL", "POOL_Med_Shot", 4.1, 0, 1, 1, 0, 0, 1);
if ( distance_to_ball > 1.5 ) {
ApplyAnimation( playerid, "POOL", "POOL_XLong_Shot", 4.1, 0, 1, 1, 0, 0, 1 );
} else {
ApplyAnimation( playerid, "POOL", "POOL_Long_Shot", 4.1, 0, 1, 1, 0, 0, 1 );
}
speed = 0.4 + ( g_poolTableData[ poolid ] [ E_POWER ] * 2.0 ) / 100.0;
PHY_SetObjectVelocity(g_poolBallData[poolid] [E_BALL_OBJECT] [0], speed * floatsin(-p_PoolAngle[ playerid ] [ 0 ], degrees), speed * floatcos(-p_PoolAngle[ playerid ] [ 0 ], degrees));
@ -330,8 +354,9 @@ hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
{
if ( PRESSED( KEY_SECONDARY_ATTACK ) )
{
if ( IsPlayerPlayingPool( playerid ) ) {
Pool_SendTableMessage( poolid, COLOR_GREY, "-- "COL_WHITE" %s(%d) has left the table", ReturnPlayerName( playerid ), playerid );
if ( IsPlayerPlayingPool( playerid ) )
{
Pool_SendTableMessage( p_PoolID[ playerid ], COLOR_GREY, "-- "COL_WHITE" %s(%d) has left the table", ReturnPlayerName( playerid ), playerid );
return Pool_RemovePlayer( playerid );
}
@ -394,6 +419,7 @@ stock Pool_RemovePlayer( playerid )
p_PoolID[ playerid ] = -1;
DestroyDynamicObject( p_PoolHoleGuide[ playerid ] );
p_PoolHoleGuide[ playerid ] = -1;
RestoreCamera( playerid );
// check if the player is even in the table
if ( poolid != -1 && Iter_Contains( poolplayers< poolid >, playerid ) )
@ -699,6 +725,8 @@ stock Pool_EndGame( poolid )
g_poolTableData[ poolid ] [ E_EXTRA_SHOT ] = false;
KillTimer( g_poolTableData[ poolid ] [ E_TIMER ] );
DestroyObject( g_poolTableData[ poolid ] [ E_AIMER_OBJECT ] );
g_poolTableData[ poolid ] [ E_AIMER_OBJECT ] = -1;
for ( new i = 0; i < 16; i ++ ) if ( g_poolBallData[ poolid ] [ E_BALL_OBJECT ] [ i ] != -1 ) {
PHY_DeleteObject( g_poolBallData[ poolid ] [ E_BALL_OBJECT ] [ i ] );
@ -737,8 +765,14 @@ public PlayPoolSound( poolid, soundid ) {
public OnPoolUpdate( poolid )
{
if ( ! g_poolTableData[ poolid ] [ E_STARTED ] )
return 0;
if ( ! g_poolTableData[ poolid ] [ E_STARTED ] ) {
return 1;
}
if ( ! Iter_Count( poolplayers< poolid > ) ) {
// Pool_EndGame( poolid );
// return 1;
}
if ( g_poolTableData[ poolid ] [ E_AIMER ] != -1 )
{
@ -757,9 +791,8 @@ public OnPoolUpdate(poolid)
newrot = p_PoolAngle[ playerid ] [ 0 ] + (lr > 0 ? 0.9 : -0.9);
dist = GetDistanceBetweenPoints( X, Y, 0.0, Xa, Ya, 0.0 );
printf("%f", dist);
if ( dist < 0.85 ) {
dist = 0.85;
if ( dist < 1.20 ) {
dist = 1.20;
}
if ( AngleInRangeOfAngle( p_PoolAngle[ playerid ] [ 1 ], newrot, 30.0 ) )
@ -781,8 +814,8 @@ public OnPoolUpdate(poolid)
GetXYInFrontOfPos( Xa, Ya, newrot + 180, x, y, 0.085 );
SetObjectPos( g_poolTableData[ poolid ] [ E_AIMER_OBJECT ], x, y, Za );
SetObjectRot( g_poolTableData[ poolid ] [ E_AIMER_OBJECT ], 7.0, 0, p_PoolAngle[ playerid ] [ 0 ] + 180 );
GetXYInFrontOfPos(Xa, Ya, newrot + 180, X, Y, dist);
SetPlayerPos(playerid, X, Y, Z);
GetXYInFrontOfPos( Xa, Ya, newrot + 180 - 5.0, x, y, dist ); // offset 5 degrees
SetPlayerPos( playerid, x, y, Z );
SetPlayerFacingAngle( playerid, newrot );
}
}
@ -834,8 +867,8 @@ public RestoreCamera( playerid )
{
TextDrawHideForPlayer( playerid, g_PoolTextdraw );
HidePlayerProgressBar( playerid, g_PoolPowerBar[ playerid ] );
TogglePlayerControllable( playerid, 1 );
ApplyAnimation( playerid, "CARRY", "crry_prtial", 4.0, 0, 1, 1, 0, 0 );
return SetCameraBehindPlayer( playerid );
}
@ -950,6 +983,7 @@ public PHY_OnObjectUpdate( objectid )
if ( g_poolBallOffsetData[ poolball_index ] [ E_BALL_TYPE ] == E_CUE )
{
GameTextForPlayer( current_player, "~n~~n~~n~~r~~h~You have pocketed the cue ball!", 10000, 4 );
Pool_SendTableMessage( poolid, -1, "{2DD9A9} * * %s(%d) has wrongly pocketed the cue ball!", ReturnPlayerName( current_player ), current_player );
// penalty for that
g_poolTableData[ poolid ] [ E_FOULS ] ++;
@ -1015,12 +1049,12 @@ public PHY_OnObjectUpdate( objectid )
}
// mark final target hole
if ( p_PoolScore[ first_player ] == 7 || p_PoolScore[ second_player ] == 7 )
if ( ( p_PoolScore[ first_player ] == 7 && p_PoolHoleGuide[ first_player ] == -1 ) || ( p_PoolScore[ second_player ] == 7 && p_PoolHoleGuide[ second_player ] == -1 ) )
{
new
player_being_marked = p_PoolScore[ first_player ] == 7 ? first_player : second_player;
if ( ! IsValidDynamicObject( p_PoolHoleGuide[ player_being_marked ] ) )
if ( p_PoolHoleGuide[ player_being_marked ] == -1 )
{
new
opposite_holeid = g_poolHoleOpposite[ holeid ];