fire system retouched - use /fires ... based off map icons ... no more textdraws
This commit is contained in:
parent
76d4b4e8fe
commit
05cd9b1722
@ -11,17 +11,20 @@
|
||||
/* ** Definitions ** */
|
||||
#define MAX_FIRES ( 10 )
|
||||
|
||||
#define FIRE_EXTINGUISH_PAYOUT ( 5000 )
|
||||
|
||||
/* ** Variables ** */
|
||||
enum E_FIRE_DATA
|
||||
{
|
||||
bool: E_CREATED, E_OBJECT, Float: E_HEALTH,
|
||||
E_HOUSE, Text3D: E_LABEL
|
||||
E_OBJECT, Float: E_HEALTH, E_HOUSE,
|
||||
Text3D: E_LABEL, E_MAP_ICON
|
||||
};
|
||||
|
||||
static stock
|
||||
g_fireData [ MAX_FIRES ] [ E_FIRE_DATA ],
|
||||
p_FireDistanceTimer [ MAX_PLAYERS ] = { -1, ... },
|
||||
bool: fire_toggled = false
|
||||
Iterator: fires < MAX_FIRES >,
|
||||
|
||||
p_FireTracker [ MAX_PLAYERS char ]
|
||||
;
|
||||
|
||||
/* ** Forwards ** */
|
||||
@ -55,125 +58,188 @@ hook OnPlayerUpdateEx( playerid )
|
||||
if ( p_Class[ playerid ] == CLASS_FIREMAN && ( iKeys & KEY_FIRE ) || ( iKeys & KEY_WALK ) )
|
||||
{
|
||||
new
|
||||
iVehicle = GetPlayerVehicleID( playerid );
|
||||
using_firetruck = GetVehicleModel( GetPlayerVehicleID( playerid ) ) == 407;
|
||||
|
||||
if ( GetPlayerWeapon( playerid ) == 42 || GetVehicleModel( iVehicle ) == 407 )
|
||||
if ( GetPlayerWeapon( playerid ) == 42 || using_firetruck )
|
||||
{
|
||||
for( new i = 0; i < sizeof( g_fireData ); i ++ ) if ( g_fireData[ i ] [ E_CREATED ] )
|
||||
foreach ( new i : fires )
|
||||
{
|
||||
static
|
||||
Float: fX, Float: fY, Float: fZ;
|
||||
|
||||
if ( GetDynamicObjectPos( g_fireData[ i ] [ E_OBJECT ], fX, fY, fZ ) )
|
||||
{
|
||||
// add a bit of height cause of the fire
|
||||
fZ += 2.3;
|
||||
|
||||
if ( IsPlayerInRangeOfPoint( playerid, ( GetVehicleModel( iVehicle ) == 407 ? 25.0 : 10.0 ), fX, fY, fZ ) )
|
||||
// check if range of point
|
||||
if ( IsPlayerInRangeOfPoint( playerid, ( using_firetruck ? 30.0 : 10.0 ), fX, fY, fZ ) )
|
||||
{
|
||||
if ( IsPlayerAimingAt( playerid, fX, fY, fZ, ( GetVehicleModel( iVehicle ) == 407 ? 3.0 : 1.0 ) ) )
|
||||
if ( IsPlayerAimingAt( playerid, fX, fY, fZ, ( using_firetruck ? 3.5 : 1.0 ) ) )
|
||||
{
|
||||
if ( g_fireData[ i ] [ E_HEALTH ] > 0.0 )
|
||||
{
|
||||
if ( ( g_fireData[ i ] [ E_HEALTH ] -= GetVehicleModel( iVehicle ) == 407 ? ( 2.85 + fRandomEx( 1.0, 5.0 ) ) : ( 1.25 + fRandomEx( 1.0, 5.0 ) ) ) < 0.0 )
|
||||
g_fireData[ i ] [ E_HEALTH ] = 0.0;
|
||||
|
||||
UpdateDynamic3DTextLabelText( g_fireData[ i ] [ E_LABEL ], COLOR_YELLOW, sprintf( "%0.1f", g_fireData[ i ] [ E_HEALTH ] ) );
|
||||
new
|
||||
Float: removed_health = ( 2.5 + fRandomEx( 1.0, 5.0 ) ) * ( using_firetruck ? 2.5 : 1.0 );
|
||||
|
||||
if ( ( g_fireData[ i ] [ E_HEALTH ] -= removed_health ) < 0.0 ) {
|
||||
g_fireData[ i ] [ E_HEALTH ] = 0.0;
|
||||
}
|
||||
else
|
||||
|
||||
UpdateDynamic3DTextLabelText( g_fireData[ i ] [ E_LABEL ], 0xA83434FF, sprintf( "House Fire %0.1f%", g_fireData[ i ] [ E_HEALTH ] ) );
|
||||
|
||||
if ( g_fireData[ i ] [ E_HEALTH ] <= 0.0 )
|
||||
{
|
||||
ach_HandleExtinguishedFires( playerid );
|
||||
SendClientMessageToFireman( -1, "{A83434}[FIREMAN]{FFFFFF} %s(%d) has extinguished house fire %d.", ReturnPlayerName( playerid ), playerid, i );
|
||||
SendClientMessageToFireman( -1, "{A83434}[FIREMAN]"COL_WHITE" %s(%d) has earned "COL_GOLD"%s"COL_WHITE" for extinguishing a house fire.", ReturnPlayerName( playerid ), playerid, cash_format( FIRE_EXTINGUISH_PAYOUT ) );
|
||||
GivePlayerScore( playerid, 2 );
|
||||
//GivePlayerExperience( playerid, E_FIREMAN );
|
||||
GivePlayerCash( playerid, 5000 );
|
||||
GivePlayerCash( playerid, FIRE_EXTINGUISH_PAYOUT );
|
||||
HouseFire_Remove( i );
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_fireData[ i ] [ E_CREATED ] = false;
|
||||
g_fireData[ i ] [ E_HOUSE ] = -1;
|
||||
DestroyDynamicObject( g_fireData[ i ] [ E_OBJECT ] );
|
||||
g_fireData[ i ] [ E_OBJECT ] = INVALID_OBJECT_ID;
|
||||
DestroyDynamic3DTextLabel( g_fireData[ i ] [ E_LABEL ] );
|
||||
g_fireData[ i ] [ E_LABEL ] = Text3D: INVALID_3DTEXT_ID;
|
||||
g_fireData[ i ] [ E_HEALTH ] = 0.0;
|
||||
UpdateDynamic3DTextLabelText( g_fireData[ i ] [ E_LABEL ], COLOR_YELLOW, sprintf( "%0.1f", g_fireData[ i ] [ E_HEALTH ] ) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
hook OnServerUpdate( )
|
||||
{
|
||||
// create fires if there are no fires existing and houses available
|
||||
if ( ! Iter_Count( fires ) && Iter_Count( houses ) ) {
|
||||
HouseFire_Create( );
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
hook OnServerGameDayEnd( )
|
||||
{
|
||||
HouseFire_Create( );
|
||||
return 1;
|
||||
}
|
||||
|
||||
hook OnPlayerDriveVehicle( playerid, vehicleid )
|
||||
{
|
||||
new
|
||||
modelid = GetVehicleModel( vehicleid );
|
||||
|
||||
if ( modelid == 407 ) {
|
||||
ShowPlayerHelpDialog( playerid, 2500, "You can see where fires are using ~g~/fires" );
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ** Commands ** */
|
||||
CMD:firetracker( playerid, params[ ] )
|
||||
CMD:firetracker( playerid, params[ ] ) cmd_fires( playerid, params );
|
||||
CMD:fires( playerid, params[ ] )
|
||||
{
|
||||
if ( p_Class[ playerid ] != CLASS_FIREMAN )
|
||||
return SendError( playerid, "You are not a fireman." );
|
||||
|
||||
if ( p_FireDistanceTimer[ playerid ] != -1 )
|
||||
return StopPlayerFireTracker( playerid ), SendServerMessage( playerid, "You have turned off your fire tracker." );
|
||||
p_FireTracker{ playerid } = ! p_FireTracker{ playerid };
|
||||
|
||||
KillTimer( p_FireDistanceTimer[ playerid ] );
|
||||
p_FireDistanceTimer[ playerid ] = SetTimerEx( "OnPlayerFireDistanceUpdate", 1000, true, "d", playerid );
|
||||
SendServerMessage( playerid, "Find the fires and extinguish them." );
|
||||
return 1;
|
||||
}
|
||||
|
||||
stock StopPlayerFireTracker( playerid )
|
||||
if ( p_FireTracker{ playerid } )
|
||||
{
|
||||
KillTimer( p_FireDistanceTimer[ playerid ] );
|
||||
p_FireDistanceTimer[ playerid ] = -1;
|
||||
|
||||
PlayerTextDrawHide( playerid, p_FireDistance1[ playerid ] );
|
||||
PlayerTextDrawHide( playerid, p_FireDistance2[ playerid ] );
|
||||
return 1;
|
||||
UpdatePlayerFireTracker( playerid );
|
||||
return SendServerMessage( playerid, "All house fires are now in your minimap as red markers." );
|
||||
}
|
||||
else
|
||||
{
|
||||
StopPlayerFireTracker( playerid );
|
||||
return SendServerMessage( playerid, "You have hidden all the fires from your radar." );
|
||||
}
|
||||
}
|
||||
|
||||
/* ** Functions ** */
|
||||
stock CreateFire( )
|
||||
stock HouseFire_Create( )
|
||||
{
|
||||
if ( fire_toggled )
|
||||
// create house house fires for random homes
|
||||
for ( new fireid = 0; fireid < MAX_FIRES; fireid ++ ) if ( ! Iter_Contains( fires, fireid ) )
|
||||
{
|
||||
for ( new i = 0; i < sizeof( g_fireData ); i ++ ) if ( g_fireData[ i ] [ E_CREATED ] == true )
|
||||
{
|
||||
g_fireData[ i ] [ E_CREATED ] = false;
|
||||
g_fireData[ i ] [ E_HOUSE ] = -1;
|
||||
DestroyDynamicObject( g_fireData[ i ] [ E_OBJECT ] );
|
||||
g_fireData[ i ] [ E_OBJECT ] = INVALID_OBJECT_ID;
|
||||
DestroyDynamic3DTextLabel( g_fireData[ i ] [ E_LABEL ] );
|
||||
g_fireData[ i ] [ E_LABEL ] = Text3D: INVALID_3DTEXT_ID;
|
||||
}
|
||||
new
|
||||
houseid = HouseFire_GetRandomHome( );
|
||||
|
||||
fire_toggled = false;
|
||||
CreateFire( );
|
||||
}
|
||||
else
|
||||
if ( Iter_Contains( houses, houseid ) )
|
||||
{
|
||||
static
|
||||
Float: X, Float: Y, Float: Z;
|
||||
|
||||
for ( new i = 0; i < sizeof( g_fireData ); i ++ )
|
||||
{
|
||||
new
|
||||
house = GetRandomCreatedHouse( );
|
||||
GetHousePos( houseid, X, Y, Z );
|
||||
|
||||
if ( Iter_Contains( houses, house ) )
|
||||
{
|
||||
GetHousePos( house, X, Y, Z );
|
||||
g_fireData[ i ] [ E_HEALTH ] = 100.0 + fRandomEx( 1, 25 );
|
||||
g_fireData[ i ] [ E_HOUSE ] = house;
|
||||
g_fireData[ i ] [ E_CREATED ] = true;
|
||||
g_fireData[ i ] [ E_LABEL ] = CreateDynamic3DTextLabel( sprintf( "%0.1f", g_fireData[ i ] [ E_HEALTH ] ), COLOR_YELLOW, X, Y, Z + 0.5, 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1 );
|
||||
g_fireData[ i ] [ E_OBJECT ] = CreateDynamicObject( 18691, X, Y, Z - 2.3, 0.0, 0.0, 0.0 );
|
||||
g_fireData[ fireid ] [ E_HEALTH ] = 100.0 + fRandomEx( 1, 25 );
|
||||
g_fireData[ fireid ] [ E_HOUSE ] = houseid;
|
||||
g_fireData[ fireid ] [ E_LABEL ] = CreateDynamic3DTextLabel( sprintf( "House Fire %0.1f%", g_fireData[ fireid ] [ E_HEALTH ] ), 0xA83434FF, X, Y, Z + 0.5, 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1 );
|
||||
g_fireData[ fireid ] [ E_OBJECT ] = CreateDynamicObject( 18691, X, Y, Z - 2.3, 0.0, 0.0, 0.0 );
|
||||
|
||||
// fire map icons
|
||||
g_fireData[ fireid ] [ E_MAP_ICON ] = CreateDynamicMapIcon( X, Y, Z, 0, 0xA83434FF, -1, -1, 0, 6000.0, MAPICON_GLOBAL );
|
||||
Streamer_RemoveArrayData( STREAMER_TYPE_MAP_ICON, g_fireData[ fireid ] [ E_MAP_ICON ], E_STREAMER_PLAYER_ID, 0 );
|
||||
|
||||
Iter_Add( fires, fireid );
|
||||
}
|
||||
}
|
||||
fire_toggled = true;
|
||||
|
||||
// show on radar when it is created
|
||||
foreach ( new playerid : Player ) if ( GetPlayerClass( playerid ) == CLASS_FIREMAN && p_FireTracker{ playerid } ) {
|
||||
UpdatePlayerFireTracker( playerid );
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
stock HouseFire_Remove( fireid )
|
||||
{
|
||||
DestroyDynamicObject( g_fireData[ fireid ] [ E_OBJECT ] );
|
||||
g_fireData[ fireid ] [ E_OBJECT ] = INVALID_OBJECT_ID;
|
||||
DestroyDynamic3DTextLabel( g_fireData[ fireid ] [ E_LABEL ] );
|
||||
g_fireData[ fireid ] [ E_LABEL ] = Text3D: INVALID_3DTEXT_ID;
|
||||
DestroyDynamicMapIcon( g_fireData[ fireid ] [ E_MAP_ICON ] );
|
||||
g_fireData[ fireid ] [ E_MAP_ICON ] = -1;
|
||||
Iter_Remove( fires, fireid );
|
||||
return 1;
|
||||
}
|
||||
|
||||
stock HouseFire_GetRandomHome( )
|
||||
{
|
||||
if ( ! Iter_Count( houses ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static szCity[ MAX_ZONE_NAME ];
|
||||
new ignoredHomes[ MAX_HOUSES ] = { -1, ... };
|
||||
|
||||
// first find homes to ignore
|
||||
for ( new i = 0; i < MAX_HOUSES; i ++ )
|
||||
{
|
||||
// Avoid Hills / Avoid V.I.P or Clan Homes
|
||||
if ( ! Iter_Contains( houses, i ) || g_houseData[ i ] [ E_EZ ] > 300.0 || g_houseData[ i ] [ E_COST ] < 500000 ) {
|
||||
ignoredHomes[ i ] = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
// check for house fire
|
||||
if ( IsHouseOnFire( i ) ) {
|
||||
ignoredHomes[ i ] = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
// San Fierro only
|
||||
Get2DCity( szCity, g_houseData[ i ] [ E_EX ], g_houseData[ i ] [ E_EY ], g_houseData[ i ] [ E_EZ ] );
|
||||
if ( ! strmatch( szCity, "San Fierro" ) ) {
|
||||
ignoredHomes[ i ] = i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
new
|
||||
random_home = randomExcept( ignoredHomes, sizeof( ignoredHomes ) );
|
||||
|
||||
// apparently 'safer' to return value from variable
|
||||
return random_home;
|
||||
}
|
||||
|
||||
stock IsHouseOnFire( houseid )
|
||||
{
|
||||
if ( houseid < 0 || houseid > MAX_HOUSES )
|
||||
@ -182,45 +248,111 @@ stock IsHouseOnFire( houseid )
|
||||
if ( ! Iter_Contains( houses, houseid ) )
|
||||
return 0;
|
||||
|
||||
for( new i, Float: X, Float: Y, Float: Z; i < sizeof( g_fireData ); i++ )
|
||||
static
|
||||
Float: X, Float: Y, Float: Z, Float: HX, Float: HY;
|
||||
|
||||
foreach ( new fireid : fires )
|
||||
{
|
||||
if ( g_fireData[ i ] [ E_CREATED ] )
|
||||
{
|
||||
GetDynamicObjectPos( g_fireData[ i ] [ E_OBJECT ], X, Y, Z ); // Z is unused due to the object.
|
||||
if ( g_houseData[ houseid ] [ E_EX ] == X && g_houseData[ houseid ] [ E_EY ] == Y )
|
||||
GetDynamicObjectPos( g_fireData[ fireid ] [ E_OBJECT ], X, Y, Z ); // Z is unused due to the object.
|
||||
GetHousePos( houseid, HX, HY, Z );
|
||||
|
||||
if ( HX == X && HY == Y )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function OnPlayerFireDistanceUpdate( playerid )
|
||||
stock UpdatePlayerFireTracker( playerid )
|
||||
{
|
||||
new
|
||||
Float: X, Float: Y, Float: Z, Float: dis,
|
||||
szFire1[ 128 ], szFire2[ 128 ]
|
||||
;
|
||||
// add player to map icon list
|
||||
foreach ( new fireid : fires ) {
|
||||
Streamer_AppendArrayData( STREAMER_TYPE_MAP_ICON, g_fireData[ fireid ] [ E_MAP_ICON ], E_STREAMER_PLAYER_ID, playerid );
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
for( new i; i < sizeof( g_fireData ); i++ )
|
||||
stock StopPlayerFireTracker( playerid )
|
||||
{
|
||||
GetDynamicObjectPos( g_fireData[ i ] [ E_OBJECT ], X, Y, Z );
|
||||
dis = GetPlayerDistanceFromPoint( playerid, X, Y, Z );
|
||||
if ( i < floatround( sizeof( g_fireData ) / 2 ) )
|
||||
// remove player from map icon list
|
||||
foreach ( new fireid : fires ) if ( Streamer_IsInArrayData( STREAMER_TYPE_MAP_ICON, g_fireData[ fireid ] [ E_MAP_ICON ], E_STREAMER_PLAYER_ID, playerid ) ) {
|
||||
Streamer_RemoveArrayData( STREAMER_TYPE_MAP_ICON, g_fireData[ fireid ] [ E_MAP_ICON ], E_STREAMER_PLAYER_ID, playerid );
|
||||
}
|
||||
|
||||
// reset firetracker
|
||||
p_FireTracker{ playerid } = false;
|
||||
return 1;
|
||||
}
|
||||
|
||||
stock Float: GetPointAngleToPoint( Float: x2, Float: y2, Float: X, Float: Y )
|
||||
{
|
||||
if ( g_fireData[ i ] [ E_CREATED ] == false ) format( szFire1, sizeof( szFire1 ), "%s~r~FIRE %d:%s ~g~Stopped~n~", szFire1, i,i==1?(" "):("") );
|
||||
else format( szFire1, sizeof( szFire1 ), "%s~r~FIRE %d:%s~w~ %0.0f m~n~", szFire1, i,i==1?("_"):(""), dis );
|
||||
new Float: DX, Float: DY;
|
||||
new Float: angle;
|
||||
|
||||
DX = floatabs( floatsub( x2, X ) );
|
||||
DY = floatabs( floatsub( y2, Y ) );
|
||||
|
||||
if ( DY == 0.0 || DX == 0.0 )
|
||||
{
|
||||
if ( DY == 0 && DX > 0 ) angle = 0.0;
|
||||
else if ( DY == 0 && DX < 0 ) angle = 180.0;
|
||||
else if ( DY > 0 && DX == 0 ) angle = 90.0;
|
||||
else if ( DY < 0 && DX == 0 ) angle = 270.0;
|
||||
else if ( DY == 0 && DX == 0 ) angle = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( g_fireData[ i ] [ E_CREATED ] == false ) format( szFire2, sizeof( szFire2 ), "%s~r~FIRE %d:%s ~g~Stopped~n~", szFire2, i,i==1?(" "):("") );
|
||||
else format( szFire2, sizeof( szFire2 ), "%s~r~FIRE %d:%s~w~ %0.0f m~n~", szFire2, i,i==1?("_"):(""), dis );
|
||||
angle = atan( DX / DY );
|
||||
if ( X > x2 && Y <= y2 ) angle += 90.0;
|
||||
else if ( X <= x2 && Y < y2 ) angle = floatsub( 90.0, angle );
|
||||
else if ( X < x2 && Y >= y2 ) angle -= 90.0;
|
||||
else if ( X >= x2 && Y > y2 ) angle = floatsub( 270.0, angle );
|
||||
}
|
||||
return floatadd( angle, 90.0 );
|
||||
}
|
||||
PlayerTextDrawSetString( playerid, p_FireDistance1[ playerid ], szFire1 );
|
||||
PlayerTextDrawSetString( playerid, p_FireDistance2[ playerid ], szFire2 );
|
||||
PlayerTextDrawShow( playerid, p_FireDistance1[ playerid ] );
|
||||
PlayerTextDrawShow( playerid, p_FireDistance2[ playerid ] );
|
||||
return 1;
|
||||
|
||||
stock Float: DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ) {
|
||||
|
||||
new Float: TGTDistance;
|
||||
|
||||
TGTDistance = floatsqroot( ( CamX - ObjX) * ( CamX - ObjX ) + ( CamY - ObjY ) * ( CamY - ObjY ) + ( CamZ - ObjZ ) * ( CamZ - ObjZ ) );
|
||||
|
||||
new Float: tmpX, Float: tmpY, Float: tmpZ;
|
||||
|
||||
tmpX = FrX * TGTDistance + CamX;
|
||||
tmpY = FrY * TGTDistance + CamY;
|
||||
tmpZ = FrZ * TGTDistance + CamZ;
|
||||
|
||||
return floatsqroot( ( tmpX - ObjX ) * ( tmpX - ObjX ) + ( tmpY - ObjY ) * ( tmpY - ObjY ) + ( tmpZ - ObjZ ) * ( tmpZ - ObjZ ) );
|
||||
}
|
||||
|
||||
stock IsPlayerAimingAt( playerid, Float: x, Float: y, Float: z, Float: radius ) // forgot who made this
|
||||
{
|
||||
new Float: camera_x, Float: camera_y, Float: camera_z;
|
||||
new Float: vector_x, Float: vector_y, Float: vector_z;
|
||||
|
||||
GetPlayerCameraPos( playerid, camera_x, camera_y, camera_z );
|
||||
GetPlayerCameraFrontVector( playerid, vector_x, vector_y, vector_z );
|
||||
|
||||
new Float: vertical, Float: horizontal;
|
||||
|
||||
switch ( GetPlayerWeapon( playerid ) )
|
||||
{
|
||||
case 34, 35, 36: return DistanceCameraTargetToLocation( camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z ) < radius;
|
||||
case 30, 31: vertical = 4.0, horizontal = -1.6;
|
||||
case 33: vertical = 2.7, horizontal = -1.0;
|
||||
default: vertical = 6.0, horizontal = -2.2;
|
||||
}
|
||||
|
||||
new Float: angle = GetPointAngleToPoint( 0, 0, floatsqroot( vector_x * vector_x + vector_y * vector_y ), vector_z ) - 270.0;
|
||||
new Float: resize_x, Float: resize_y, Float: resize_z = floatsin( angle + vertical, degrees );
|
||||
|
||||
GetXYInFrontOfPoint( resize_x, resize_y, GetPointAngleToPoint( 0, 0, vector_x, vector_y ) + horizontal, floatcos( angle + vertical, degrees ) );
|
||||
return DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z) < radius;
|
||||
}
|
||||
|
||||
stock GetXYInFrontOfPoint( &Float: x, &Float: y, Float: angle, Float: distance ) {
|
||||
x += ( distance * floatsin( -angle, degrees ) );
|
||||
y += ( distance * floatcos( -angle, degrees ) );
|
||||
}
|
||||
|
@ -620,9 +620,6 @@ thread OnHouseLoad( )
|
||||
SetHouseOwner( houseid, 1, "Lorenc" );
|
||||
}
|
||||
}
|
||||
|
||||
// The server crashes when the fires aren't correctly loaded.
|
||||
CreateFire( );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -47,9 +47,7 @@ new
|
||||
PlayerText: p_TruckingTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
|
||||
PlayerText: p_TrackPlayerTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
|
||||
PlayerText: p_GPSInformation [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
|
||||
PlayerText: p_AchievementTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
|
||||
PlayerText: p_FireDistance1 [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
|
||||
PlayerText: p_FireDistance2 [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }
|
||||
PlayerText: p_AchievementTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }
|
||||
;
|
||||
|
||||
/* ** Hooks ** */
|
||||
@ -525,22 +523,6 @@ hook OnPlayerConnect( playerid )
|
||||
PlayerTextDrawSetOutline(playerid, p_RobberyAmountTD[ playerid ], 1);
|
||||
PlayerTextDrawSetProportional(playerid, p_RobberyAmountTD[ playerid ], 1);
|
||||
PlayerTextDrawSetSelectable(playerid, p_RobberyAmountTD[ playerid ], 0);
|
||||
|
||||
p_FireDistance1[ playerid ] = CreatePlayerTextDraw(playerid, 26.000000, 182.000000, "_");
|
||||
PlayerTextDrawBackgroundColor(playerid, p_FireDistance1[ playerid ], 255);
|
||||
PlayerTextDrawFont(playerid, p_FireDistance1[ playerid ], 2);
|
||||
PlayerTextDrawLetterSize(playerid, p_FireDistance1[ playerid ], 0.210000, 1.200000);
|
||||
PlayerTextDrawColor(playerid, p_FireDistance1[ playerid ], -1);
|
||||
PlayerTextDrawSetOutline(playerid, p_FireDistance1[ playerid ], 1);
|
||||
PlayerTextDrawSetProportional(playerid, p_FireDistance1[ playerid ], 1);
|
||||
|
||||
p_FireDistance2[ playerid ] = CreatePlayerTextDraw(playerid, 26.000000, 236.000000, "_");
|
||||
PlayerTextDrawBackgroundColor(playerid, p_FireDistance2[ playerid ], 255);
|
||||
PlayerTextDrawFont(playerid, p_FireDistance2[ playerid ], 2);
|
||||
PlayerTextDrawLetterSize(playerid, p_FireDistance2[ playerid ], 0.209999, 1.200000);
|
||||
PlayerTextDrawColor(playerid, p_FireDistance2[ playerid ], -1);
|
||||
PlayerTextDrawSetOutline(playerid, p_FireDistance2[ playerid ], 1);
|
||||
PlayerTextDrawSetProportional(playerid, p_FireDistance2[ playerid ], 1);
|
||||
return Y_HOOKS_CONTINUE_RETURN_1;
|
||||
}
|
||||
|
||||
|
@ -1450,7 +1450,6 @@ public ZoneTimer( )
|
||||
g_WorldDayCount = ( g_WorldDayCount == 6 ? 0 : g_WorldDayCount + 1 );
|
||||
TextDrawSetString( g_WorldDayTD, GetDayToString( g_WorldDayCount ) );
|
||||
|
||||
CreateFire( );
|
||||
RenewWeed( );
|
||||
PlayerPlaceRandomHits( );
|
||||
|
||||
@ -1740,8 +1739,6 @@ public OnPlayerRequestClass( playerid, classid )
|
||||
TextDrawHideForPlayer( playerid, g_CurrentRankTD );
|
||||
TextDrawHideForPlayer( playerid, g_currentXPTD );
|
||||
TextDrawHideForPlayer( playerid, g_DoubleXPTD );
|
||||
PlayerTextDrawHide( playerid, p_FireDistance1[ playerid ] );
|
||||
PlayerTextDrawHide( playerid, p_FireDistance2[ playerid ] );
|
||||
p_MoneyBag{ playerid } = false;
|
||||
RemovePlayerAttachedObject( playerid, 1 );
|
||||
|
||||
@ -14191,44 +14188,6 @@ stock TimeConvert( seconds )
|
||||
return szTime;
|
||||
}
|
||||
|
||||
stock GetRandomCreatedHouse( )
|
||||
{
|
||||
if ( ! Iter_Count( houses ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static szCity[ MAX_ZONE_NAME ];
|
||||
new ignoredHomes[ MAX_HOUSES ] = { -1, ... };
|
||||
|
||||
// first find homes to ignore
|
||||
for ( new i = 0; i < MAX_HOUSES; i ++ )
|
||||
{
|
||||
// Avoid Hills / Avoid V.I.P or Clan Homes
|
||||
if ( ! Iter_Contains( houses, i ) || g_houseData[ i ] [ E_EZ ] > 300.0 || g_houseData[ i ] [ E_COST ] < 500000 ) {
|
||||
ignoredHomes[ i ] = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
// check for house fire
|
||||
if ( IsHouseOnFire( i ) ) {
|
||||
ignoredHomes[ i ] = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
// San Fierro only
|
||||
Get2DCity( szCity, g_houseData[ i ] [ E_EX ], g_houseData[ i ] [ E_EY ], g_houseData[ i ] [ E_EZ ] );
|
||||
if ( ! strmatch( szCity, "San Fierro" ) ) {
|
||||
ignoredHomes[ i ] = i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
new
|
||||
random_home = randomExcept( ignoredHomes, sizeof( ignoredHomes ) );
|
||||
|
||||
return random_home;
|
||||
}
|
||||
|
||||
stock SetPlayerFacePoint(playerid, Float: fX, Float: fY, Float: offset = 0.0)
|
||||
{
|
||||
static
|
||||
@ -15004,84 +14963,6 @@ stock GetDayToString( day )
|
||||
return string;
|
||||
}
|
||||
|
||||
Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ) {
|
||||
|
||||
new Float:TGTDistance;
|
||||
|
||||
TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));
|
||||
|
||||
new Float:tmpX, Float:tmpY, Float:tmpZ;
|
||||
|
||||
tmpX = FrX * TGTDistance + CamX;
|
||||
tmpY = FrY * TGTDistance + CamY;
|
||||
tmpZ = FrZ * TGTDistance + CamZ;
|
||||
|
||||
return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
|
||||
}
|
||||
|
||||
stock Float:GetPointAngleToPoint(Float:x2, Float:y2, Float:X, Float:Y) {
|
||||
|
||||
new Float:DX, Float:DY;
|
||||
new Float:angle;
|
||||
|
||||
DX = floatabs(floatsub(x2,X));
|
||||
DY = floatabs(floatsub(y2,Y));
|
||||
|
||||
if (DY == 0.0 || DX == 0.0) {
|
||||
if (DY == 0 && DX > 0) angle = 0.0;
|
||||
else if (DY == 0 && DX < 0) angle = 180.0;
|
||||
else if (DY > 0 && DX == 0) angle = 90.0;
|
||||
else if (DY < 0 && DX == 0) angle = 270.0;
|
||||
else if (DY == 0 && DX == 0) angle = 0.0;
|
||||
}
|
||||
else {
|
||||
angle = atan(DX/DY);
|
||||
|
||||
if (X > x2 && Y <= y2) angle += 90.0;
|
||||
else if (X <= x2 && Y < y2) angle = floatsub(90.0, angle);
|
||||
else if (X < x2 && Y >= y2) angle -= 90.0;
|
||||
else if (X >= x2 && Y > y2) angle = floatsub(270.0, angle);
|
||||
}
|
||||
|
||||
return floatadd(angle, 90.0);
|
||||
}
|
||||
|
||||
stock GetXYInFrontOfPoint(&Float:x, &Float:y, Float:angle, Float:distance) {
|
||||
x += (distance * floatsin(-angle, degrees));
|
||||
y += (distance * floatcos(-angle, degrees));
|
||||
}
|
||||
|
||||
stock IsPlayerAimingAt(playerid, Float:x, Float:y, Float:z, Float:radius)
|
||||
{
|
||||
new Float:camera_x;
|
||||
new Float:camera_y;
|
||||
new Float:camera_z;
|
||||
new Float:vector_x;
|
||||
new Float:vector_y;
|
||||
new Float:vector_z;
|
||||
|
||||
GetPlayerCameraPos(playerid, camera_x, camera_y, camera_z);
|
||||
GetPlayerCameraFrontVector(playerid, vector_x, vector_y, vector_z);
|
||||
|
||||
new Float:vertical, Float:horizontal;
|
||||
|
||||
switch (GetPlayerWeapon( playerid )) {
|
||||
case 34,35,36:
|
||||
{
|
||||
if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z) < radius) return true;
|
||||
return false;
|
||||
}
|
||||
case 30,31: {vertical = 4.0; horizontal = -1.6;}
|
||||
case 33: {vertical = 2.7; horizontal = -1.0;}
|
||||
default: {vertical = 6.0; horizontal = -2.2;}
|
||||
}
|
||||
new Float:angle = GetPointAngleToPoint(0, 0, floatsqroot(vector_x*vector_x+vector_y*vector_y), vector_z) - 270.0;
|
||||
new Float:resize_x, Float:resize_y, Float:resize_z = floatsin(angle+vertical, degrees);
|
||||
GetXYInFrontOfPoint(resize_x, resize_y, GetPointAngleToPoint(0, 0, vector_x, vector_y)+horizontal, floatcos(angle+vertical, degrees));
|
||||
|
||||
if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z) < radius) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
stock ShowAchievement( playerid, achievement[ ], score = -1 )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user