Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ProxPlayer: calcular a distância entre dois players, baseado no calculo de distância em plano cartesiano.
- //by: Jeffrey_Hatrix
- stock Float: ProxPlayer ( playerId, otherId )
- {
- if ( playerId == INVALID_PLAYER_ID || otherId == INVALID_PLAYER_ID )
- {
- return -1.0 ;
- }
- new Float: pos [ 6 ] ;
- GetPlayerPos ( playerId , pos [ 0 ] , pos [ 1 ] , pos [ 2 ] ) ;
- GetPlayerPos ( otherId , pos [ 3 ] , pos [ 4 ] , pos [ 5 ] ) ;
- return ( floatsqroot ( floatadd ( floatmul ( floatsub ( pos [ 0 ] , pos [ 3 ] ) , floatsub ( pos [ 0 ] , pos [ 3 ] ) ) , floatadd ( floatmul ( floatsub ( pos [ 1 ] , pos [ 4 ] ) , floatsub ( pos [ 1 ] , pos [ 4 ] ) ) , floatmul ( floatsub ( pos [ 2 ] , pos [ 5 ] ) , floatsub ( pos [ 2 ] , pos [ 5 ] ) ) ) ) ) ) ;
- }
- // OU
- stock Float: ProxPlayer ( playerId, otherId )
- {
- new Float: pos [ 0b0110 ] ;
- GetPlayerPos ( playerId , pos [ 0b0000 ] , pos [ 0b0001 ] , pos [ 0b0010 ] ) ;
- GetPlayerPos ( otherId , pos [ 0b0011 ] , pos [ 0b0100 ] , pos [ 0b0101 ] ) ;
- return ( ( playerId == INVALID_PLAYER_ID ) ? ( -0b0001.0 ) : ( ( otherId == INVALID_PLAYER_ID ) ? ( -0b0001.0 ) : ( floatsqroot ( floatadd ( floatmul ( floatsub ( pos [ 0b0000 ] , pos [ 0b0011 ] ) , floatsub ( pos [ 0b0000 ] , pos [ 0b0011 ] ) , floatadd ( floatmul ( floatsub ( pos [ 0b0001 ] , pos [ 0b0100 ] ) , floatsub ( pos [ 0b0001 ] , pos [ 0b0100 ] ) ) , floatmul ( floatsub ( pos [ 0b0010 ] , pos [ 0b0110 ] ) , floatsub ( pos [ 0b0010 ] , pos [ 0b0110 ] ) ) ) ) ) ) ) ;
- } // Versão atualizada: 23/07/2012 - By Willian Luigi
Advertisement
Add Comment
Please, Sign In to add comment