2010-11-20 10:37:14 +00:00
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
2008-07-06 11:21:21 +00:00
# include <new>
2010-05-29 07:25:38 +00:00
# include <engine/shared/config.h>
# include <game/server/gamecontext.h>
# include <game/mapitems.h>
2010-08-23 19:37:27 +00:00
2010-05-29 07:25:38 +00:00
# include "character.h"
# include "laser.h"
# include "projectile.h"
2008-07-06 11:21:21 +00:00
2011-04-09 06:41:31 +00:00
# include <stdio.h>
# include <string.h>
# include <game/server/gamemodes/DDRace.h>
# include <game/server/score.h>
# include "light.h"
2010-05-29 07:25:38 +00:00
MACRO_ALLOC_POOL_ID_IMPL ( CCharacter , MAX_CLIENTS )
2008-09-24 09:03:49 +00:00
2011-01-29 00:59:50 +00:00
// Character, "physical" player's part
2010-05-29 07:25:38 +00:00
CCharacter : : CCharacter ( CGameWorld * pWorld )
2011-01-19 17:27:50 +00:00
: CEntity ( pWorld , CGameWorld : : ENTTYPE_CHARACTER )
2008-09-23 07:43:41 +00:00
{
2010-06-03 15:39:42 +00:00
m_ProximityRadius = ms_PhysSize ;
2010-05-29 07:25:38 +00:00
m_Health = 0 ;
m_Armor = 0 ;
2008-09-23 07:43:41 +00:00
}
2008-07-06 11:21:21 +00:00
2010-05-29 07:25:38 +00:00
void CCharacter : : Reset ( )
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
Destroy ( ) ;
2008-07-06 11:21:21 +00:00
}
2010-05-29 07:25:38 +00:00
bool CCharacter : : Spawn ( CPlayer * pPlayer , vec2 Pos )
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
m_EmoteStop = - 1 ;
m_LastAction = - 1 ;
2012-10-06 11:47:37 +00:00
m_LastNoAmmoSound = - 1 ;
2010-05-29 07:25:38 +00:00
m_LastWeapon = WEAPON_HAMMER ;
m_QueuedWeapon = - 1 ;
2014-12-29 14:54:55 +00:00
m_LastRefillJumps = false ;
2014-02-09 22:31:29 +00:00
m_LastPenalty = false ;
2015-03-10 21:57:40 +00:00
m_LastBonus = false ;
2015-07-09 00:08:14 +00:00
2010-05-29 07:25:38 +00:00
m_pPlayer = pPlayer ;
m_Pos = Pos ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
m_Core . Reset ( ) ;
2013-12-12 13:35:01 +00:00
m_Core . Init ( & GameServer ( ) - > m_World . m_Core , GameServer ( ) - > Collision ( ) , & ( ( CGameControllerDDRace * ) GameServer ( ) - > m_pController ) - > m_Teams . m_Core , & ( ( CGameControllerDDRace * ) GameServer ( ) - > m_pController ) - > m_TeleOuts ) ;
2014-04-14 08:56:14 +00:00
m_Core . m_ActiveWeapon = WEAPON_GUN ;
2010-05-29 07:25:38 +00:00
m_Core . m_Pos = m_Pos ;
GameServer ( ) - > m_World . m_Core . m_apCharacters [ m_pPlayer - > GetCID ( ) ] = & m_Core ;
2011-01-29 00:59:50 +00:00
2010-05-29 07:25:38 +00:00
m_ReckoningTick = 0 ;
mem_zero ( & m_SendCore , sizeof ( m_SendCore ) ) ;
mem_zero ( & m_ReckoningCore , sizeof ( m_ReckoningCore ) ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
GameServer ( ) - > m_World . InsertEntity ( this ) ;
m_Alive = true ;
2011-01-29 00:59:50 +00:00
2010-05-29 07:25:38 +00:00
GameServer ( ) - > m_pController - > OnCharacterSpawn ( this ) ;
2011-01-29 00:59:50 +00:00
2013-02-01 11:08:23 +00:00
Teams ( ) - > OnCharacterSpawn ( GetPlayer ( ) - > GetCID ( ) ) ;
2011-01-29 00:59:50 +00:00
DDRaceInit ( ) ;
2015-07-09 00:08:14 +00:00
2014-04-18 12:27:58 +00:00
m_TuneZone = GameServer ( ) - > Collision ( ) - > IsTune ( GameServer ( ) - > Collision ( ) - > GetMapIndex ( Pos ) ) ;
m_TuneZoneOld = - 1 ; // no zone leave msg on spawn
2014-03-27 00:28:44 +00:00
m_NeededFaketuning = 0 ; // reset fake tunings on respawn and send the client
2014-04-18 12:27:58 +00:00
SendZoneMsgs ( ) ; // we want a entermessage also on spawn
2014-03-27 00:28:44 +00:00
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ;
2011-01-29 00:59:50 +00:00
2014-09-26 00:05:22 +00:00
Server ( ) - > StartRecord ( m_pPlayer - > GetCID ( ) ) ;
2008-07-06 11:21:21 +00:00
return true ;
}
2010-05-29 07:25:38 +00:00
void CCharacter : : Destroy ( )
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
GameServer ( ) - > m_World . m_Core . m_apCharacters [ m_pPlayer - > GetCID ( ) ] = 0 ;
m_Alive = false ;
2008-07-06 11:21:21 +00:00
}
2010-05-29 07:25:38 +00:00
void CCharacter : : SetWeapon ( int W )
2008-07-06 11:21:21 +00:00
{
2014-04-14 08:56:14 +00:00
if ( W = = m_Core . m_ActiveWeapon )
2008-07-06 11:21:21 +00:00
return ;
2011-04-13 18:37:12 +00:00
2014-04-14 08:56:14 +00:00
m_LastWeapon = m_Core . m_ActiveWeapon ;
2010-05-29 07:25:38 +00:00
m_QueuedWeapon = - 1 ;
2014-09-06 22:15:03 +00:00
m_Core . m_ActiveWeapon = W ;
2011-09-02 18:04:18 +00:00
GameServer ( ) - > CreateSound ( m_Pos , SOUND_WEAPON_SWITCH , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2011-04-13 18:37:12 +00:00
2014-04-14 08:56:14 +00:00
if ( m_Core . m_ActiveWeapon < 0 | | m_Core . m_ActiveWeapon > = NUM_WEAPONS )
m_Core . m_ActiveWeapon = 0 ;
2008-07-06 11:21:21 +00:00
}
2014-12-25 10:37:44 +00:00
void CCharacter : : SetSolo ( bool Solo )
{
Teams ( ) - > m_Core . SetSolo ( m_pPlayer - > GetCID ( ) , Solo ) ;
if ( Solo )
m_NeededFaketuning | = FAKETUNE_SOLO ;
else
m_NeededFaketuning & = ~ FAKETUNE_SOLO ;
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ; // update tunings
}
2010-05-29 07:25:38 +00:00
bool CCharacter : : IsGrounded ( )
2008-07-06 11:21:21 +00:00
{
2010-08-29 03:46:09 +00:00
if ( GameServer ( ) - > Collision ( ) - > CheckPoint ( m_Pos . x + m_ProximityRadius / 2 , m_Pos . y + m_ProximityRadius / 2 + 5 ) )
2008-07-06 11:21:21 +00:00
return true ;
2010-08-29 03:46:09 +00:00
if ( GameServer ( ) - > Collision ( ) - > CheckPoint ( m_Pos . x - m_ProximityRadius / 2 , m_Pos . y + m_ProximityRadius / 2 + 5 ) )
2008-07-06 11:21:21 +00:00
return true ;
2015-04-16 15:28:03 +00:00
int index = GameServer ( ) - > Collision ( ) - > GetPureMapIndex ( vec2 ( m_Pos . x , m_Pos . y + m_ProximityRadius / 2 + 4 ) ) ;
int tile = GameServer ( ) - > Collision ( ) - > GetTileIndex ( index ) ;
int flags = GameServer ( ) - > Collision ( ) - > GetTileFlags ( index ) ;
if ( tile = = TILE_STOPA | | ( tile = = TILE_STOP & & flags = = ROTATION_0 ) | | ( tile = = TILE_STOPS & & ( flags = = ROTATION_0 | | flags = = ROTATION_180 ) ) )
return true ;
tile = GameServer ( ) - > Collision ( ) - > GetFTileIndex ( index ) ;
flags = GameServer ( ) - > Collision ( ) - > GetFTileFlags ( index ) ;
if ( tile = = TILE_STOPA | | ( tile = = TILE_STOP & & flags = = ROTATION_0 ) | | ( tile = = TILE_STOPS & & ( flags = = ROTATION_0 | | flags = = ROTATION_180 ) ) )
return true ;
2008-07-06 11:21:21 +00:00
return false ;
}
2014-04-13 23:34:50 +00:00
void CCharacter : : HandleJetpack ( )
{
vec2 Direction = normalize ( vec2 ( m_LatestInput . m_TargetX , m_LatestInput . m_TargetY ) ) ;
bool FullAuto = false ;
2014-04-14 08:56:14 +00:00
if ( m_Core . m_ActiveWeapon = = WEAPON_GRENADE | | m_Core . m_ActiveWeapon = = WEAPON_SHOTGUN | | m_Core . m_ActiveWeapon = = WEAPON_RIFLE )
2014-04-13 23:34:50 +00:00
FullAuto = true ;
2014-04-14 08:56:14 +00:00
if ( m_Jetpack & & m_Core . m_ActiveWeapon = = WEAPON_GUN )
2014-04-13 23:34:50 +00:00
FullAuto = true ;
// check if we gonna fire
bool WillFire = false ;
if ( CountInput ( m_LatestPrevInput . m_Fire , m_LatestInput . m_Fire ) . m_Presses )
WillFire = true ;
2014-04-14 08:56:14 +00:00
if ( FullAuto & & ( m_LatestInput . m_Fire & 1 ) & & m_aWeapons [ m_Core . m_ActiveWeapon ] . m_Ammo )
2014-04-13 23:34:50 +00:00
WillFire = true ;
if ( ! WillFire )
return ;
// check for ammo
2014-04-14 08:56:14 +00:00
if ( ! m_aWeapons [ m_Core . m_ActiveWeapon ] . m_Ammo )
2014-04-13 23:34:50 +00:00
{
return ;
}
2014-04-14 08:56:14 +00:00
switch ( m_Core . m_ActiveWeapon )
2014-04-13 23:34:50 +00:00
{
case WEAPON_GUN :
{
if ( m_Jetpack )
{
2014-06-04 18:16:44 +00:00
float Strength ;
if ( ! m_TuneZone )
Strength = GameServer ( ) - > Tuning ( ) - > m_JetpackStrength ;
else
Strength = GameServer ( ) - > TuningList ( ) [ m_TuneZone ] . m_JetpackStrength ;
TakeDamage ( Direction * - 1.0f * ( Strength / 100.0f / 6.11f ) , g_pData - > m_Weapons . m_Hammer . m_pBase - > m_Damage , m_pPlayer - > GetCID ( ) , m_Core . m_ActiveWeapon ) ;
2014-04-13 23:34:50 +00:00
}
}
}
}
2008-07-06 11:21:21 +00:00
2010-05-29 07:25:38 +00:00
void CCharacter : : HandleNinja ( )
2008-07-06 11:21:21 +00:00
{
2014-04-14 08:56:14 +00:00
if ( m_Core . m_ActiveWeapon ! = WEAPON_NINJA )
2010-05-29 07:25:38 +00:00
return ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
if ( ( Server ( ) - > Tick ( ) - m_Ninja . m_ActivationTick ) > ( g_pData - > m_Weapons . m_Ninja . m_Duration * Server ( ) - > TickSpeed ( ) / 1000 ) )
2008-07-06 11:21:21 +00:00
{
// time's up, return
2016-10-08 17:42:42 +00:00
RemoveNinja ( ) ;
2010-05-29 07:25:38 +00:00
return ;
2008-07-06 11:21:21 +00:00
}
2011-04-13 18:37:12 +00:00
2013-12-09 12:53:26 +00:00
int NinjaTime = m_Ninja . m_ActivationTick + ( g_pData - > m_Weapons . m_Ninja . m_Duration * Server ( ) - > TickSpeed ( ) / 1000 ) - Server ( ) - > Tick ( ) ;
if ( NinjaTime % Server ( ) - > TickSpeed ( ) = = 0 & & NinjaTime / Server ( ) - > TickSpeed ( ) < = 5 )
{
GameServer ( ) - > CreateDamageInd ( m_Pos , 0 , NinjaTime / Server ( ) - > TickSpeed ( ) , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
}
m_Armor = 10 - ( NinjaTime / 15 ) ;
2010-05-29 07:25:38 +00:00
// force ninja Weapon
SetWeapon ( WEAPON_NINJA ) ;
2008-07-06 11:21:21 +00:00
2010-05-29 07:25:38 +00:00
m_Ninja . m_CurrentMoveTime - - ;
2008-07-06 11:21:21 +00:00
2010-05-29 07:25:38 +00:00
if ( m_Ninja . m_CurrentMoveTime = = 0 )
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
// reset velocity
2011-03-13 18:00:00 +00:00
m_Core . m_Vel = m_Ninja . m_ActivationDir * m_Ninja . m_OldVelAmount ;
2008-07-06 11:21:21 +00:00
}
2010-05-29 07:25:38 +00:00
if ( m_Ninja . m_CurrentMoveTime > 0 )
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
// Set velocity
m_Core . m_Vel = m_Ninja . m_ActivationDir * g_pData - > m_Weapons . m_Ninja . m_Velocity ;
vec2 OldPos = m_Pos ;
2010-06-03 15:39:42 +00:00
GameServer ( ) - > Collision ( ) - > MoveBox ( & m_Core . m_Pos , & m_Core . m_Vel , vec2 ( m_ProximityRadius , m_ProximityRadius ) , 0.f ) ;
2011-04-13 18:37:12 +00:00
2008-07-06 11:21:21 +00:00
// reset velocity so the client doesn't predict stuff
2010-05-29 07:25:38 +00:00
m_Core . m_Vel = vec2 ( 0.f , 0.f ) ;
2008-07-06 11:21:21 +00:00
2010-05-29 07:25:38 +00:00
// check if we Hit anything along the way
2008-07-06 11:21:21 +00:00
{
2011-01-19 17:27:50 +00:00
CCharacter * aEnts [ MAX_CLIENTS ] ;
2010-05-29 07:25:38 +00:00
vec2 Dir = m_Pos - OldPos ;
2010-06-03 15:39:42 +00:00
float Radius = m_ProximityRadius * 2.0f ;
2010-05-29 07:25:38 +00:00
vec2 Center = OldPos + Dir * 0.5f ;
2011-01-19 17:27:50 +00:00
int Num = GameServer ( ) - > m_World . FindEntities ( Center , Radius , ( CEntity * * ) aEnts , MAX_CLIENTS , CGameWorld : : ENTTYPE_CHARACTER ) ;
2008-07-06 11:21:21 +00:00
2013-08-04 20:50:14 +00:00
// check that we're not in solo part
if ( Teams ( ) - > m_Core . GetSolo ( m_pPlayer - > GetCID ( ) ) )
return ;
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < Num ; + + i )
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
if ( aEnts [ i ] = = this )
2008-07-06 11:21:21 +00:00
continue ;
2011-04-13 18:37:12 +00:00
2013-08-04 20:50:14 +00:00
// Don't hit players in other teams
if ( Team ( ) ! = aEnts [ i ] - > Team ( ) )
continue ;
// Don't hit players in solo parts
if ( Teams ( ) - > m_Core . GetSolo ( aEnts [ i ] - > m_pPlayer - > GetCID ( ) ) )
return ;
2010-05-29 07:25:38 +00:00
// make sure we haven't Hit this object before
bool bAlreadyHit = false ;
for ( int j = 0 ; j < m_NumObjectsHit ; j + + )
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
if ( m_apHitObjects [ j ] = = aEnts [ i ] )
bAlreadyHit = true ;
2008-07-06 11:21:21 +00:00
}
2010-05-29 07:25:38 +00:00
if ( bAlreadyHit )
2008-07-06 11:21:21 +00:00
continue ;
// check so we are sufficiently close
2010-06-03 15:39:42 +00:00
if ( distance ( aEnts [ i ] - > m_Pos , m_Pos ) > ( m_ProximityRadius * 2.0f ) )
2008-07-06 11:21:21 +00:00
continue ;
2011-01-29 00:59:50 +00:00
// Hit a player, give him damage and stuffs...
2011-09-02 18:04:18 +00:00
GameServer ( ) - > CreateSound ( aEnts [ i ] - > m_Pos , SOUND_NINJA_HIT , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2008-07-06 11:21:21 +00:00
// set his velocity to fast upward (for now)
2010-05-29 07:25:38 +00:00
if ( m_NumObjectsHit < 10 )
m_apHitObjects [ m_NumObjectsHit + + ] = aEnts [ i ] ;
2011-04-13 18:37:12 +00:00
2011-07-30 16:08:24 +00:00
aEnts [ i ] - > TakeDamage ( vec2 ( 0 , - 10.0f ) , g_pData - > m_Weapons . m_Ninja . m_pBase - > m_Damage , m_pPlayer - > GetCID ( ) , WEAPON_NINJA ) ;
2008-07-06 11:21:21 +00:00
}
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
return ;
2008-07-06 11:21:21 +00:00
}
2010-05-29 07:25:38 +00:00
return ;
2008-07-06 11:21:21 +00:00
}
2010-05-29 07:25:38 +00:00
void CCharacter : : DoWeaponSwitch ( )
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
// make sure we can switch
if ( m_ReloadTimer ! = 0 | | m_QueuedWeapon = = - 1 | | m_aWeapons [ WEAPON_NINJA ] . m_Got )
2008-07-06 11:21:21 +00:00
return ;
2010-05-29 07:25:38 +00:00
// switch Weapon
SetWeapon ( m_QueuedWeapon ) ;
2008-07-06 11:21:21 +00:00
}
2010-05-29 07:25:38 +00:00
void CCharacter : : HandleWeaponSwitch ( )
2008-07-06 11:21:21 +00:00
{
2014-04-14 08:56:14 +00:00
int WantedWeapon = m_Core . m_ActiveWeapon ;
2010-05-29 07:25:38 +00:00
if ( m_QueuedWeapon ! = - 1 )
WantedWeapon = m_QueuedWeapon ;
2011-04-09 06:41:31 +00:00
2011-02-13 05:35:13 +00:00
bool Anything = false ;
2011-02-08 23:03:42 +00:00
for ( int i = 0 ; i < NUM_WEAPONS - 1 ; + + i )
if ( m_aWeapons [ i ] . m_Got )
Anything = true ;
if ( ! Anything )
return ;
2010-05-29 07:25:38 +00:00
// select Weapon
int Next = CountInput ( m_LatestPrevInput . m_NextWeapon , m_LatestInput . m_NextWeapon ) . m_Presses ;
int Prev = CountInput ( m_LatestPrevInput . m_PrevWeapon , m_LatestInput . m_PrevWeapon ) . m_Presses ;
2008-07-06 11:21:21 +00:00
2010-05-29 07:25:38 +00:00
if ( Next < 128 ) // make sure we only try sane stuff
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
while ( Next ) // Next Weapon selection
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
WantedWeapon = ( WantedWeapon + 1 ) % NUM_WEAPONS ;
if ( m_aWeapons [ WantedWeapon ] . m_Got )
Next - - ;
2008-07-06 11:21:21 +00:00
}
}
2010-05-29 07:25:38 +00:00
if ( Prev < 128 ) // make sure we only try sane stuff
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
while ( Prev ) // Prev Weapon selection
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
WantedWeapon = ( WantedWeapon - 1 ) < 0 ? NUM_WEAPONS - 1 : WantedWeapon - 1 ;
if ( m_aWeapons [ WantedWeapon ] . m_Got )
Prev - - ;
2008-07-06 11:21:21 +00:00
}
}
2010-05-29 07:25:38 +00:00
// Direct Weapon selection
if ( m_LatestInput . m_WantedWeapon )
WantedWeapon = m_Input . m_WantedWeapon - 1 ;
2008-07-06 11:21:21 +00:00
// check for insane values
2014-04-14 08:56:14 +00:00
if ( WantedWeapon > = 0 & & WantedWeapon < NUM_WEAPONS & & WantedWeapon ! = m_Core . m_ActiveWeapon & & m_aWeapons [ WantedWeapon ] . m_Got )
2010-05-29 07:25:38 +00:00
m_QueuedWeapon = WantedWeapon ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
DoWeaponSwitch ( ) ;
2008-07-06 11:21:21 +00:00
}
2010-05-29 07:25:38 +00:00
void CCharacter : : FireWeapon ( )
2008-07-06 11:21:21 +00:00
{
2011-01-29 00:59:50 +00:00
if ( m_ReloadTimer ! = 0 )
2008-07-06 11:21:21 +00:00
return ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
DoWeaponSwitch ( ) ;
vec2 Direction = normalize ( vec2 ( m_LatestInput . m_TargetX , m_LatestInput . m_TargetY ) ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
bool FullAuto = false ;
2014-04-14 08:56:14 +00:00
if ( m_Core . m_ActiveWeapon = = WEAPON_GRENADE | | m_Core . m_ActiveWeapon = = WEAPON_SHOTGUN | | m_Core . m_ActiveWeapon = = WEAPON_RIFLE )
2010-05-29 07:25:38 +00:00
FullAuto = true ;
2014-04-14 08:56:14 +00:00
if ( m_Jetpack & & m_Core . m_ActiveWeapon = = WEAPON_GUN )
2013-11-13 12:25:26 +00:00
FullAuto = true ;
2008-07-06 11:21:21 +00:00
2016-05-02 14:25:34 +00:00
// don't fire non auto weapons when player is deep and sv_deepfly is disabled
if ( ! g_Config . m_SvDeepfly & & ! FullAuto & & m_DeepFreeze )
return ;
2008-07-06 11:21:21 +00:00
// check if we gonna fire
2010-05-29 07:25:38 +00:00
bool WillFire = false ;
if ( CountInput ( m_LatestPrevInput . m_Fire , m_LatestInput . m_Fire ) . m_Presses )
WillFire = true ;
2011-04-13 18:37:12 +00:00
2014-04-14 08:56:14 +00:00
if ( FullAuto & & ( m_LatestInput . m_Fire & 1 ) & & m_aWeapons [ m_Core . m_ActiveWeapon ] . m_Ammo )
2010-05-29 07:25:38 +00:00
WillFire = true ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
if ( ! WillFire )
2008-07-06 11:21:21 +00:00
return ;
2011-04-13 18:37:12 +00:00
2008-07-06 11:21:21 +00:00
// check for ammo
2014-04-14 08:56:14 +00:00
if ( ! m_aWeapons [ m_Core . m_ActiveWeapon ] . m_Ammo )
2008-07-06 11:21:21 +00:00
{
2011-04-09 06:41:31 +00:00
/*// 125ms is a magical limit of how fast a human can click
2011-01-29 00:59:50 +00:00
m_ReloadTimer = 125 * Server ( ) - > TickSpeed ( ) / 1000 ;
GameServer ( ) - > CreateSound ( m_Pos , SOUND_WEAPON_NOAMMO ) ; */
2011-04-09 06:41:31 +00:00
// Timer stuff to avoid shrieking orchestra caused by unfreeze-plasma
2010-11-04 23:52:37 +00:00
if ( m_PainSoundTimer < = 0 )
{
m_PainSoundTimer = 1 * Server ( ) - > TickSpeed ( ) ;
2011-09-02 18:04:18 +00:00
GameServer ( ) - > CreateSound ( m_Pos , SOUND_PLAYER_PAIN_LONG , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2010-11-04 23:52:37 +00:00
}
2008-07-06 11:21:21 +00:00
return ;
}
2014-11-02 09:59:22 +00:00
2010-06-03 15:39:42 +00:00
vec2 ProjStartPos = m_Pos + Direction * m_ProximityRadius * 0.75f ;
2011-04-13 18:37:12 +00:00
2014-04-14 08:56:14 +00:00
switch ( m_Core . m_ActiveWeapon )
2008-07-06 11:21:21 +00:00
{
case WEAPON_HAMMER :
{
2010-05-29 07:25:38 +00:00
// reset objects Hit
m_NumObjectsHit = 0 ;
2011-09-02 18:04:18 +00:00
GameServer ( ) - > CreateSound ( m_Pos , SOUND_HAMMER_FIRE , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2010-08-24 14:32:46 +00:00
2011-07-25 20:16:20 +00:00
if ( m_Hit & DISABLE_HIT_HAMMER ) break ;
2011-04-13 18:37:12 +00:00
2011-01-19 17:27:50 +00:00
CCharacter * apEnts [ MAX_CLIENTS ] ;
2010-05-29 07:25:38 +00:00
int Hits = 0 ;
2011-04-13 18:37:12 +00:00
int Num = GameServer ( ) - > m_World . FindEntities ( ProjStartPos , m_ProximityRadius * 0.5f , ( CEntity * * ) apEnts ,
2011-01-19 17:27:50 +00:00
MAX_CLIENTS , CGameWorld : : ENTTYPE_CHARACTER ) ;
2008-07-06 11:21:21 +00:00
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < Num ; + + i )
2008-07-06 11:21:21 +00:00
{
2011-01-09 19:53:19 +00:00
CCharacter * pTarget = apEnts [ i ] ;
2011-04-13 18:37:12 +00:00
2011-04-09 06:41:31 +00:00
//if ((pTarget == this) || GameServer()->Collision()->IntersectLine(ProjStartPos, pTarget->m_Pos, NULL, NULL))
2014-09-22 16:56:59 +00:00
if ( ( pTarget = = this | | ( pTarget - > IsAlive ( ) & & ! CanCollide ( pTarget - > GetPlayer ( ) - > GetCID ( ) ) ) ) )
2008-07-06 11:21:21 +00:00
continue ;
// set his velocity to fast upward (for now)
2011-01-23 16:58:28 +00:00
if ( length ( pTarget - > m_Pos - ProjStartPos ) > 0.0f )
2011-09-02 18:04:18 +00:00
GameServer ( ) - > CreateHammerHit ( pTarget - > m_Pos - normalize ( pTarget - > m_Pos - ProjStartPos ) * m_ProximityRadius * 0.5f , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2011-01-23 16:58:28 +00:00
else
2011-09-02 18:04:18 +00:00
GameServer ( ) - > CreateHammerHit ( ProjStartPos , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
vec2 Dir ;
2011-04-10 13:07:36 +00:00
if ( length ( pTarget - > m_Pos - m_Pos ) > 0.0f )
Dir = normalize ( pTarget - > m_Pos - m_Pos ) ;
else
Dir = vec2 ( 0.f , - 1.f ) ;
2011-04-15 04:04:21 +00:00
/*pTarget->TakeDamage(vec2(0.f, -1.f) + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f, g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage,
2014-04-14 08:56:14 +00:00
m_pPlayer - > GetCID ( ) , m_Core . m_ActiveWeapon ) ; */
2011-04-13 18:37:12 +00:00
2014-04-13 17:11:21 +00:00
float Strength ;
if ( ! m_TuneZone )
Strength = GameServer ( ) - > Tuning ( ) - > m_HammerStrength ;
else
Strength = GameServer ( ) - > TuningList ( ) [ m_TuneZone ] . m_HammerStrength ;
2011-04-15 04:04:21 +00:00
vec2 Temp = pTarget - > m_Core . m_Vel + normalize ( Dir + vec2 ( 0.f , - 1.1f ) ) * 10.0f ;
2011-01-12 09:08:17 +00:00
if ( Temp . x > 0 & & ( ( pTarget - > m_TileIndex = = TILE_STOP & & pTarget - > m_TileFlags = = ROTATION_270 ) | | ( pTarget - > m_TileIndexL = = TILE_STOP & & pTarget - > m_TileFlagsL = = ROTATION_270 ) | | ( pTarget - > m_TileIndexL = = TILE_STOPS & & ( pTarget - > m_TileFlagsL = = ROTATION_90 | | pTarget - > m_TileFlagsL = = ROTATION_270 ) ) | | ( pTarget - > m_TileIndexL = = TILE_STOPA ) | | ( pTarget - > m_TileFIndex = = TILE_STOP & & pTarget - > m_TileFFlags = = ROTATION_270 ) | | ( pTarget - > m_TileFIndexL = = TILE_STOP & & pTarget - > m_TileFFlagsL = = ROTATION_270 ) | | ( pTarget - > m_TileFIndexL = = TILE_STOPS & & ( pTarget - > m_TileFFlagsL = = ROTATION_90 | | pTarget - > m_TileFFlagsL = = ROTATION_270 ) ) | | ( pTarget - > m_TileFIndexL = = TILE_STOPA ) | | ( pTarget - > m_TileSIndex = = TILE_STOP & & pTarget - > m_TileSFlags = = ROTATION_270 ) | | ( pTarget - > m_TileSIndexL = = TILE_STOP & & pTarget - > m_TileSFlagsL = = ROTATION_270 ) | | ( pTarget - > m_TileSIndexL = = TILE_STOPS & & ( pTarget - > m_TileSFlagsL = = ROTATION_90 | | pTarget - > m_TileSFlagsL = = ROTATION_270 ) ) | | ( pTarget - > m_TileSIndexL = = TILE_STOPA ) ) )
2010-11-01 12:29:56 +00:00
Temp . x = 0 ;
2011-01-12 09:08:17 +00:00
if ( Temp . x < 0 & & ( ( pTarget - > m_TileIndex = = TILE_STOP & & pTarget - > m_TileFlags = = ROTATION_90 ) | | ( pTarget - > m_TileIndexR = = TILE_STOP & & pTarget - > m_TileFlagsR = = ROTATION_90 ) | | ( pTarget - > m_TileIndexR = = TILE_STOPS & & ( pTarget - > m_TileFlagsR = = ROTATION_90 | | pTarget - > m_TileFlagsR = = ROTATION_270 ) ) | | ( pTarget - > m_TileIndexR = = TILE_STOPA ) | | ( pTarget - > m_TileFIndex = = TILE_STOP & & pTarget - > m_TileFFlags = = ROTATION_90 ) | | ( pTarget - > m_TileFIndexR = = TILE_STOP & & pTarget - > m_TileFFlagsR = = ROTATION_90 ) | | ( pTarget - > m_TileFIndexR = = TILE_STOPS & & ( pTarget - > m_TileFFlagsR = = ROTATION_90 | | pTarget - > m_TileFFlagsR = = ROTATION_270 ) ) | | ( pTarget - > m_TileFIndexR = = TILE_STOPA ) | | ( pTarget - > m_TileSIndex = = TILE_STOP & & pTarget - > m_TileSFlags = = ROTATION_90 ) | | ( pTarget - > m_TileSIndexR = = TILE_STOP & & pTarget - > m_TileSFlagsR = = ROTATION_90 ) | | ( pTarget - > m_TileSIndexR = = TILE_STOPS & & ( pTarget - > m_TileSFlagsR = = ROTATION_90 | | pTarget - > m_TileSFlagsR = = ROTATION_270 ) ) | | ( pTarget - > m_TileSIndexR = = TILE_STOPA ) ) )
2010-11-01 12:29:56 +00:00
Temp . x = 0 ;
2011-01-12 09:08:17 +00:00
if ( Temp . y < 0 & & ( ( pTarget - > m_TileIndex = = TILE_STOP & & pTarget - > m_TileFlags = = ROTATION_180 ) | | ( pTarget - > m_TileIndexB = = TILE_STOP & & pTarget - > m_TileFlagsB = = ROTATION_180 ) | | ( pTarget - > m_TileIndexB = = TILE_STOPS & & ( pTarget - > m_TileFlagsB = = ROTATION_0 | | pTarget - > m_TileFlagsB = = ROTATION_180 ) ) | | ( pTarget - > m_TileIndexB = = TILE_STOPA ) | | ( pTarget - > m_TileFIndex = = TILE_STOP & & pTarget - > m_TileFFlags = = ROTATION_180 ) | | ( pTarget - > m_TileFIndexB = = TILE_STOP & & pTarget - > m_TileFFlagsB = = ROTATION_180 ) | | ( pTarget - > m_TileFIndexB = = TILE_STOPS & & ( pTarget - > m_TileFFlagsB = = ROTATION_0 | | pTarget - > m_TileFFlagsB = = ROTATION_180 ) ) | | ( pTarget - > m_TileFIndexB = = TILE_STOPA ) | | ( pTarget - > m_TileSIndex = = TILE_STOP & & pTarget - > m_TileSFlags = = ROTATION_180 ) | | ( pTarget - > m_TileSIndexB = = TILE_STOP & & pTarget - > m_TileSFlagsB = = ROTATION_180 ) | | ( pTarget - > m_TileSIndexB = = TILE_STOPS & & ( pTarget - > m_TileSFlagsB = = ROTATION_0 | | pTarget - > m_TileSFlagsB = = ROTATION_180 ) ) | | ( pTarget - > m_TileSIndexB = = TILE_STOPA ) ) )
2010-11-01 12:29:56 +00:00
Temp . y = 0 ;
2011-01-12 09:08:17 +00:00
if ( Temp . y > 0 & & ( ( pTarget - > m_TileIndex = = TILE_STOP & & pTarget - > m_TileFlags = = ROTATION_0 ) | | ( pTarget - > m_TileIndexT = = TILE_STOP & & pTarget - > m_TileFlagsT = = ROTATION_0 ) | | ( pTarget - > m_TileIndexT = = TILE_STOPS & & ( pTarget - > m_TileFlagsT = = ROTATION_0 | | pTarget - > m_TileFlagsT = = ROTATION_180 ) ) | | ( pTarget - > m_TileIndexT = = TILE_STOPA ) | | ( pTarget - > m_TileFIndex = = TILE_STOP & & pTarget - > m_TileFFlags = = ROTATION_0 ) | | ( pTarget - > m_TileFIndexT = = TILE_STOP & & pTarget - > m_TileFFlagsT = = ROTATION_0 ) | | ( pTarget - > m_TileFIndexT = = TILE_STOPS & & ( pTarget - > m_TileFFlagsT = = ROTATION_0 | | pTarget - > m_TileFFlagsT = = ROTATION_180 ) ) | | ( pTarget - > m_TileFIndexT = = TILE_STOPA ) | | ( pTarget - > m_TileSIndex = = TILE_STOP & & pTarget - > m_TileSFlags = = ROTATION_0 ) | | ( pTarget - > m_TileSIndexT = = TILE_STOP & & pTarget - > m_TileSFlagsT = = ROTATION_0 ) | | ( pTarget - > m_TileSIndexT = = TILE_STOPS & & ( pTarget - > m_TileSFlagsT = = ROTATION_0 | | pTarget - > m_TileSFlagsT = = ROTATION_180 ) ) | | ( pTarget - > m_TileSIndexT = = TILE_STOPA ) ) )
2010-11-01 12:29:56 +00:00
Temp . y = 0 ;
2011-01-20 14:10:32 +00:00
Temp - = pTarget - > m_Core . m_Vel ;
2014-04-13 17:11:21 +00:00
pTarget - > TakeDamage ( ( vec2 ( 0.f , - 1.0f ) + Temp ) * Strength , g_pData - > m_Weapons . m_Hammer . m_pBase - > m_Damage ,
2014-04-14 08:56:14 +00:00
m_pPlayer - > GetCID ( ) , m_Core . m_ActiveWeapon ) ;
2011-01-12 09:08:17 +00:00
pTarget - > UnFreeze ( ) ;
2014-07-16 00:59:39 +00:00
if ( m_FreezeHammer )
pTarget - > Freeze ( ) ;
2010-05-29 07:25:38 +00:00
Hits + + ;
2008-07-06 11:21:21 +00:00
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
// if we Hit anything, we have to wait for the reload
if ( Hits )
m_ReloadTimer = Server ( ) - > TickSpeed ( ) / 3 ;
2011-04-13 18:37:12 +00:00
2008-07-06 11:21:21 +00:00
} break ;
case WEAPON_GUN :
{
2014-01-11 12:59:20 +00:00
if ( ! m_Jetpack | | ! m_pPlayer - > m_NinjaJetpack )
2014-01-09 18:00:41 +00:00
{
2014-03-12 23:49:07 +00:00
int Lifetime ;
if ( ! m_TuneZone )
Lifetime = ( int ) ( Server ( ) - > TickSpeed ( ) * GameServer ( ) - > Tuning ( ) - > m_GunLifetime ) ;
else
2014-04-13 14:49:58 +00:00
Lifetime = ( int ) ( Server ( ) - > TickSpeed ( ) * GameServer ( ) - > TuningList ( ) [ m_TuneZone ] . m_GunLifetime ) ;
2015-07-09 00:08:14 +00:00
2014-01-09 18:00:41 +00:00
CProjectile * pProj = new CProjectile
(
GameWorld ( ) ,
WEAPON_GUN , //Type
m_pPlayer - > GetCID ( ) , //Owner
ProjStartPos , //Pos
Direction , //Dir
2014-03-12 23:49:07 +00:00
Lifetime , //Span
2014-01-09 18:00:41 +00:00
0 , //Freeze
0 , //Explosive
0 , //Force
- 1 , //SoundImpact
WEAPON_GUN //Weapon
) ;
// pack the Projectile and send it to the client Directly
CNetObj_Projectile p ;
pProj - > FillInfo ( & p ) ;
2013-11-13 12:25:26 +00:00
2014-01-09 18:00:41 +00:00
CMsgPacker Msg ( NETMSGTYPE_SV_EXTRAPROJECTILE ) ;
Msg . AddInt ( 1 ) ;
for ( unsigned i = 0 ; i < sizeof ( CNetObj_Projectile ) / sizeof ( int ) ; i + + )
Msg . AddInt ( ( ( int * ) & p ) [ i ] ) ;
2015-03-19 08:57:47 +00:00
Server ( ) - > SendMsg ( & Msg , MSGFLAG_VITAL , m_pPlayer - > GetCID ( ) ) ;
2014-10-25 22:50:10 +00:00
GameServer ( ) - > CreateSound ( m_Pos , SOUND_GUN_FIRE , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2014-01-09 18:00:41 +00:00
}
2008-07-06 11:21:21 +00:00
} break ;
2011-04-13 18:37:12 +00:00
2008-07-06 11:21:21 +00:00
case WEAPON_SHOTGUN :
{
2010-07-29 05:21:18 +00:00
/*int ShotSpread = 2;
2008-07-06 11:21:21 +00:00
2010-05-29 07:25:38 +00:00
CMsgPacker Msg ( NETMSGTYPE_SV_EXTRAPROJECTILE ) ;
Msg . AddInt ( ShotSpread * 2 + 1 ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
for ( int i = - ShotSpread ; i < = ShotSpread ; + + i )
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
float Spreading [ ] = { - 0.185f , - 0.070f , 0 , 0.070f , 0.185f } ;
float a = GetAngle ( Direction ) ;
a + = Spreading [ i + 2 ] ;
float v = 1 - ( absolute ( i ) / ( float ) ShotSpread ) ;
float Speed = mix ( ( float ) GameServer ( ) - > Tuning ( ) - > m_ShotgunSpeeddiff , 1.0f , v ) ;
2011-01-09 19:53:19 +00:00
CProjectile * pProj = new CProjectile ( GameWorld ( ) , WEAPON_SHOTGUN ,
2010-05-29 07:25:38 +00:00
m_pPlayer - > GetCID ( ) ,
ProjStartPos ,
vec2 ( cosf ( a ) , sinf ( a ) ) * Speed ,
2011-01-29 00:59:50 +00:00
( int ) ( Server ( ) - > TickSpeed ( ) * GameServer ( ) - > Tuning ( ) - > m_ShotgunLifetime ) ,
2008-07-06 11:21:21 +00:00
1 , 0 , 0 , - 1 , WEAPON_SHOTGUN ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
// pack the Projectile and send it to the client Directly
CNetObj_Projectile p ;
2011-01-09 19:53:19 +00:00
pProj - > FillInfo ( & p ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
for ( unsigned i = 0 ; i < sizeof ( CNetObj_Projectile ) / sizeof ( int ) ; i + + )
Msg . AddInt ( ( ( int * ) & p ) [ i ] ) ;
2008-07-06 11:21:21 +00:00
}
2015-03-19 08:57:47 +00:00
Server ( ) - > SendMsg ( & Msg , MSGFLAG_VITAL , m_pPlayer - > GetCID ( ) ) ;
2011-04-13 18:37:12 +00:00
2010-07-29 05:21:18 +00:00
GameServer ( ) - > CreateSound ( m_Pos , SOUND_SHOTGUN_FIRE ) ; */
2014-03-15 16:48:25 +00:00
float LaserReach ;
if ( ! m_TuneZone )
LaserReach = GameServer ( ) - > Tuning ( ) - > m_LaserReach ;
else
2014-04-13 14:49:58 +00:00
LaserReach = GameServer ( ) - > TuningList ( ) [ m_TuneZone ] . m_LaserReach ;
2015-07-09 00:08:14 +00:00
2014-03-15 16:48:25 +00:00
new CLaser ( & GameServer ( ) - > m_World , m_Pos , Direction , LaserReach , m_pPlayer - > GetCID ( ) , WEAPON_SHOTGUN ) ;
2011-09-02 18:04:18 +00:00
GameServer ( ) - > CreateSound ( m_Pos , SOUND_SHOTGUN_FIRE , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2008-07-06 11:21:21 +00:00
} break ;
case WEAPON_GRENADE :
{
2014-03-12 23:49:07 +00:00
int Lifetime ;
if ( ! m_TuneZone )
Lifetime = ( int ) ( Server ( ) - > TickSpeed ( ) * GameServer ( ) - > Tuning ( ) - > m_GrenadeLifetime ) ;
else
2014-04-13 14:49:58 +00:00
Lifetime = ( int ) ( Server ( ) - > TickSpeed ( ) * GameServer ( ) - > TuningList ( ) [ m_TuneZone ] . m_GrenadeLifetime ) ;
2015-07-09 00:08:14 +00:00
2011-01-29 00:59:50 +00:00
CProjectile * pProj = new CProjectile
2011-04-09 06:41:31 +00:00
(
GameWorld ( ) ,
WEAPON_GRENADE , //Type
m_pPlayer - > GetCID ( ) , //Owner
ProjStartPos , //Pos
Direction , //Dir
2014-03-12 23:49:07 +00:00
Lifetime , //Span
2011-04-09 06:41:31 +00:00
0 , //Freeze
true , //Explosive
0 , //Force
SOUND_GRENADE_EXPLODE , //SoundImpact
WEAPON_GRENADE //Weapon
) ; //SoundImpact
2010-08-24 14:32:46 +00:00
2011-01-29 00:59:50 +00:00
// pack the Projectile and send it to the client Directly
CNetObj_Projectile p ;
2014-11-02 09:59:22 +00:00
pProj - > FillInfo ( & p ) ;
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
CMsgPacker Msg ( NETMSGTYPE_SV_EXTRAPROJECTILE ) ;
Msg . AddInt ( 1 ) ;
for ( unsigned i = 0 ; i < sizeof ( CNetObj_Projectile ) / sizeof ( int ) ; i + + )
Msg . AddInt ( ( ( int * ) & p ) [ i ] ) ;
2015-03-19 08:57:47 +00:00
Server ( ) - > SendMsg ( & Msg , MSGFLAG_VITAL , m_pPlayer - > GetCID ( ) ) ;
2011-04-13 18:37:12 +00:00
2011-09-02 18:04:18 +00:00
GameServer ( ) - > CreateSound ( m_Pos , SOUND_GRENADE_FIRE , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2008-07-06 11:21:21 +00:00
} break ;
2011-04-09 06:41:31 +00:00
2008-07-06 11:21:21 +00:00
case WEAPON_RIFLE :
{
2014-03-15 16:48:25 +00:00
float LaserReach ;
2014-03-12 23:49:07 +00:00
if ( ! m_TuneZone )
2014-03-15 16:48:25 +00:00
LaserReach = GameServer ( ) - > Tuning ( ) - > m_LaserReach ;
2014-03-12 23:49:07 +00:00
else
2014-04-13 14:49:58 +00:00
LaserReach = GameServer ( ) - > TuningList ( ) [ m_TuneZone ] . m_LaserReach ;
2015-07-09 00:08:14 +00:00
2014-03-12 23:49:07 +00:00
new CLaser ( GameWorld ( ) , m_Pos , Direction , LaserReach , m_pPlayer - > GetCID ( ) , WEAPON_RIFLE ) ;
2011-09-02 18:04:18 +00:00
GameServer ( ) - > CreateSound ( m_Pos , SOUND_RIFLE_FIRE , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2008-07-06 11:21:21 +00:00
} break ;
2011-04-13 18:37:12 +00:00
2008-10-08 18:36:30 +00:00
case WEAPON_NINJA :
{
2011-01-29 00:59:50 +00:00
// reset Hit objects
m_NumObjectsHit = 0 ;
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
m_Ninja . m_ActivationDir = Direction ;
m_Ninja . m_CurrentMoveTime = g_pData - > m_Weapons . m_Ninja . m_Movetime * Server ( ) - > TickSpeed ( ) / 1000 ;
2011-03-13 18:00:00 +00:00
m_Ninja . m_OldVelAmount = length ( m_Core . m_Vel ) ;
2010-08-24 14:32:46 +00:00
2011-09-02 18:04:18 +00:00
GameServer ( ) - > CreateSound ( m_Pos , SOUND_NINJA_FIRE , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2011-01-29 00:59:50 +00:00
} break ;
2011-04-13 18:37:12 +00:00
2008-07-06 11:21:21 +00:00
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
m_AttackTick = Server ( ) - > Tick ( ) ;
2011-04-13 18:37:12 +00:00
2014-04-14 08:56:14 +00:00
/*if(m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo > 0) // -1 == unlimited
m_aWeapons [ m_Core . m_ActiveWeapon ] . m_Ammo - - ; */
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
if ( ! m_ReloadTimer )
2015-02-12 14:20:22 +00:00
{
float FireDelay ;
if ( ! m_TuneZone )
GameServer ( ) - > Tuning ( ) - > Get ( 38 + m_Core . m_ActiveWeapon , & FireDelay ) ;
else
GameServer ( ) - > TuningList ( ) [ m_TuneZone ] . Get ( 38 + m_Core . m_ActiveWeapon , & FireDelay ) ;
m_ReloadTimer = FireDelay * Server ( ) - > TickSpeed ( ) / 1000 ;
}
2008-07-06 11:21:21 +00:00
}
2010-05-29 07:25:38 +00:00
void CCharacter : : HandleWeapons ( )
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
//ninja
HandleNinja ( ) ;
2014-04-13 23:34:50 +00:00
HandleJetpack ( ) ;
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
if ( m_PainSoundTimer > 0 )
2010-11-04 23:52:37 +00:00
m_PainSoundTimer - - ;
2008-10-08 18:36:30 +00:00
2008-07-06 11:21:21 +00:00
// check reload timer
2010-05-29 07:25:38 +00:00
if ( m_ReloadTimer )
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
m_ReloadTimer - - ;
return ;
2008-07-06 11:21:21 +00:00
}
2010-05-29 07:25:38 +00:00
// fire Weapon, if wanted
2014-11-02 09:59:22 +00:00
FireWeapon ( ) ;
2011-01-29 00:59:50 +00:00
/*
2008-07-06 11:21:21 +00:00
// ammo regen
2014-04-14 08:56:14 +00:00
int AmmoRegenTime = g_pData - > m_Weapons . m_aId [ m_Core . m_ActiveWeapon ] . m_Ammoregentime ;
2010-05-29 07:25:38 +00:00
if ( AmmoRegenTime )
2008-07-06 11:21:21 +00:00
{
// If equipped and not active, regen ammo?
2010-05-29 07:25:38 +00:00
if ( m_ReloadTimer < = 0 )
2008-07-06 11:21:21 +00:00
{
2014-04-14 08:56:14 +00:00
if ( m_aWeapons [ m_Core . m_ActiveWeapon ] . m_AmmoRegenStart < 0 )
m_aWeapons [ m_Core . m_ActiveWeapon ] . m_AmmoRegenStart = Server ( ) - > Tick ( ) ;
2008-07-06 11:21:21 +00:00
2014-04-14 08:56:14 +00:00
if ( ( Server ( ) - > Tick ( ) - m_aWeapons [ m_Core . m_ActiveWeapon ] . m_AmmoRegenStart ) > = AmmoRegenTime * Server ( ) - > TickSpeed ( ) / 1000 )
2008-07-06 11:21:21 +00:00
{
// Add some ammo
2014-04-14 08:56:14 +00:00
m_aWeapons [ m_Core . m_ActiveWeapon ] . m_Ammo = min ( m_aWeapons [ m_Core . m_ActiveWeapon ] . m_Ammo + 1 , 10 ) ;
m_aWeapons [ m_Core . m_ActiveWeapon ] . m_AmmoRegenStart = - 1 ;
2008-07-06 11:21:21 +00:00
}
}
else
{
2014-04-14 08:56:14 +00:00
m_aWeapons [ m_Core . m_ActiveWeapon ] . m_AmmoRegenStart = - 1 ;
2008-07-06 11:21:21 +00:00
}
2011-04-13 23:27:49 +00:00
} */
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
return ;
}
void CCharacter : : GiveNinja ( )
{
m_Ninja . m_ActivationTick = Server ( ) - > Tick ( ) ;
m_aWeapons [ WEAPON_NINJA ] . m_Got = true ;
2011-04-09 06:41:31 +00:00
if ( ! m_FreezeTime )
m_aWeapons [ WEAPON_NINJA ] . m_Ammo = - 1 ;
2014-04-14 08:56:14 +00:00
if ( m_Core . m_ActiveWeapon ! = WEAPON_NINJA )
m_LastWeapon = m_Core . m_ActiveWeapon ;
m_Core . m_ActiveWeapon = WEAPON_NINJA ;
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
if ( ! m_aWeapons [ WEAPON_NINJA ] . m_Got )
2011-09-02 18:04:18 +00:00
GameServer ( ) - > CreateSound ( m_Pos , SOUND_PICKUP_NINJA , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2008-07-06 11:21:21 +00:00
}
2016-10-08 17:42:42 +00:00
void CCharacter : : RemoveNinja ( )
{
m_Ninja . m_CurrentMoveTime = 0 ;
m_aWeapons [ WEAPON_NINJA ] . m_Got = false ;
m_Core . m_ActiveWeapon = m_LastWeapon ;
2017-02-21 16:10:08 +00:00
2016-10-08 17:42:42 +00:00
SetWeapon ( m_Core . m_ActiveWeapon ) ;
}
2010-05-29 07:25:38 +00:00
void CCharacter : : SetEmote ( int Emote , int Tick )
{
m_EmoteType = Emote ;
m_EmoteStop = Tick ;
}
void CCharacter : : OnPredictedInput ( CNetObj_PlayerInput * pNewInput )
2008-07-06 11:21:21 +00:00
{
// check for changes
2016-08-27 15:06:52 +00:00
if ( mem_comp ( & m_SavedInput , pNewInput , sizeof ( CNetObj_PlayerInput ) ) ! = 0 )
2010-05-29 07:25:38 +00:00
m_LastAction = Server ( ) - > Tick ( ) ;
2011-04-13 18:37:12 +00:00
2008-07-06 11:21:21 +00:00
// copy new input
2010-05-29 07:25:38 +00:00
mem_copy ( & m_Input , pNewInput , sizeof ( m_Input ) ) ;
m_NumInputs + + ;
2011-04-13 18:37:12 +00:00
2011-12-10 17:21:12 +00:00
// it is not allowed to aim in the center
2010-05-29 07:25:38 +00:00
if ( m_Input . m_TargetX = = 0 & & m_Input . m_TargetY = = 0 )
2011-04-13 18:37:12 +00:00
m_Input . m_TargetY = - 1 ;
2017-08-25 11:20:10 +00:00
2017-08-25 11:27:37 +00:00
mem_copy ( & m_SavedInput , & m_Input , sizeof ( m_SavedInput ) ) ;
2008-07-06 11:21:21 +00:00
}
2010-05-29 07:25:38 +00:00
void CCharacter : : OnDirectInput ( CNetObj_PlayerInput * pNewInput )
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
mem_copy ( & m_LatestPrevInput , & m_LatestInput , sizeof ( m_LatestInput ) ) ;
mem_copy ( & m_LatestInput , pNewInput , sizeof ( m_LatestInput ) ) ;
2011-04-13 18:37:12 +00:00
2011-12-10 17:21:12 +00:00
// it is not allowed to aim in the center
if ( m_LatestInput . m_TargetX = = 0 & & m_LatestInput . m_TargetY = = 0 )
m_LatestInput . m_TargetY = - 1 ;
2011-01-03 11:50:38 +00:00
if ( m_NumInputs > 2 & & m_pPlayer - > GetTeam ( ) ! = TEAM_SPECTATORS )
2008-07-06 11:21:21 +00:00
{
2010-05-29 07:25:38 +00:00
HandleWeaponSwitch ( ) ;
FireWeapon ( ) ;
2008-07-06 11:21:21 +00:00
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
mem_copy ( & m_LatestPrevInput , & m_LatestInput , sizeof ( m_LatestInput ) ) ;
2008-07-06 11:21:21 +00:00
}
2011-06-09 20:30:03 +00:00
void CCharacter : : ResetInput ( )
{
2014-02-18 21:26:17 +00:00
m_Input . m_Direction = 0 ;
2014-01-22 13:04:46 +00:00
//m_Input.m_Hook = 0;
2011-06-09 20:30:03 +00:00
// simulate releasing the fire button
2014-02-18 21:26:17 +00:00
if ( ( m_Input . m_Fire & 1 ) ! = 0 )
m_Input . m_Fire + + ;
m_Input . m_Fire & = INPUT_STATE_MASK ;
m_Input . m_Jump = 0 ;
2011-06-09 20:30:03 +00:00
m_LatestPrevInput = m_LatestInput = m_Input ;
}
2011-01-29 00:59:50 +00:00
void CCharacter : : Tick ( )
2010-09-17 11:26:06 +00:00
{
2011-01-29 00:59:50 +00:00
/*if(m_pPlayer->m_ForceBalanced)
{
char Buf [ 128 ] ;
str_format ( Buf , sizeof ( Buf ) , " You were moved to %s due to team balancing " , GameServer ( ) - > m_pController - > GetTeamName ( m_pPlayer - > GetTeam ( ) ) ) ;
GameServer ( ) - > SendBroadcast ( Buf , m_pPlayer - > GetCID ( ) ) ;
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
m_pPlayer - > m_ForceBalanced = false ;
} */
2011-04-09 06:41:31 +00:00
2011-12-29 13:58:39 +00:00
if ( m_Paused )
return ;
2011-01-29 00:59:50 +00:00
DDRaceTick ( ) ;
2015-07-09 00:08:14 +00:00
2011-01-29 00:59:50 +00:00
m_Core . m_Input = m_Input ;
2014-03-25 00:13:46 +00:00
m_Core . Tick ( true , false ) ;
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
// handle Weapons
HandleWeapons ( ) ;
2010-08-28 20:53:42 +00:00
2011-01-29 23:58:47 +00:00
DDRacePostCoreTick ( ) ;
2010-08-28 20:53:42 +00:00
2011-01-29 00:59:50 +00:00
// Previnput
m_PrevInput = m_Input ;
2011-04-09 06:41:31 +00:00
2011-01-29 00:59:50 +00:00
m_PrevPos = m_Core . m_Pos ;
return ;
}
2010-08-28 20:53:42 +00:00
2011-01-29 00:59:50 +00:00
void CCharacter : : TickDefered ( )
{
// advance the dummy
{
CWorldCore TempWorld ;
2013-12-12 13:35:01 +00:00
m_ReckoningCore . Init ( & TempWorld , GameServer ( ) - > Collision ( ) , & ( ( CGameControllerDDRace * ) GameServer ( ) - > m_pController ) - > m_Teams . m_Core , & ( ( CGameControllerDDRace * ) GameServer ( ) - > m_pController ) - > m_TeleOuts ) ;
2011-09-01 18:29:08 +00:00
m_ReckoningCore . m_Id = m_pPlayer - > GetCID ( ) ;
2014-03-25 00:13:46 +00:00
m_ReckoningCore . Tick ( false , false ) ;
2011-01-29 00:59:50 +00:00
m_ReckoningCore . Move ( ) ;
m_ReckoningCore . Quantize ( ) ;
}
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
//lastsentcore
vec2 StartPos = m_Core . m_Pos ;
vec2 StartVel = m_Core . m_Vel ;
bool StuckBefore = GameServer ( ) - > Collision ( ) - > TestBox ( m_Core . m_Pos , vec2 ( 28.0f , 28.0f ) ) ;
2011-04-13 18:37:12 +00:00
2011-09-01 18:29:08 +00:00
m_Core . m_Id = m_pPlayer - > GetCID ( ) ;
2011-01-29 00:59:50 +00:00
m_Core . Move ( ) ;
bool StuckAfterMove = GameServer ( ) - > Collision ( ) - > TestBox ( m_Core . m_Pos , vec2 ( 28.0f , 28.0f ) ) ;
m_Core . Quantize ( ) ;
bool StuckAfterQuant = GameServer ( ) - > Collision ( ) - > TestBox ( m_Core . m_Pos , vec2 ( 28.0f , 28.0f ) ) ;
m_Pos = m_Core . m_Pos ;
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
if ( ! StuckBefore & & ( StuckAfterMove | | StuckAfterQuant ) )
{
// Hackish solution to get rid of strict-aliasing warning
union
2010-08-28 20:53:42 +00:00
{
2011-01-29 00:59:50 +00:00
float f ;
unsigned u ;
} StartPosX , StartPosY , StartVelX , StartVelY ;
StartPosX . f = StartPos . x ;
StartPosY . f = StartPos . y ;
StartVelX . f = StartVel . x ;
StartVelY . f = StartVel . y ;
char aBuf [ 256 ] ;
2011-04-13 18:37:12 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " STUCK!!! %d %d %d %f %f %f %f %x %x %x %x " ,
2011-01-29 00:59:50 +00:00
StuckBefore ,
StuckAfterMove ,
StuckAfterQuant ,
StartPos . x , StartPos . y ,
StartVel . x , StartVel . y ,
StartPosX . u , StartPosY . u ,
StartVelX . u , StartVelY . u ) ;
GameServer ( ) - > Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_DEBUG , " game " , aBuf ) ;
}
int Events = m_Core . m_TriggeredEvents ;
//int Mask = CmaskAllExceptOne(m_pPlayer->GetCID());
2011-04-13 18:37:12 +00:00
2011-02-05 04:33:11 +00:00
if ( Events & COREEVENT_GROUND_JUMP ) GameServer ( ) - > CreateSound ( m_Pos , SOUND_PLAYER_JUMP , Teams ( ) - > TeamMask ( Team ( ) , m_pPlayer - > GetCID ( ) ) ) ;
2011-04-13 18:37:12 +00:00
2011-09-02 18:04:18 +00:00
if ( Events & COREEVENT_HOOK_ATTACH_PLAYER ) GameServer ( ) - > CreateSound ( m_Pos , SOUND_HOOK_ATTACH_PLAYER , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
if ( Events & COREEVENT_HOOK_ATTACH_GROUND ) GameServer ( ) - > CreateSound ( m_Pos , SOUND_HOOK_ATTACH_GROUND , Teams ( ) - > TeamMask ( Team ( ) , m_pPlayer - > GetCID ( ) , m_pPlayer - > GetCID ( ) ) ) ;
if ( Events & COREEVENT_HOOK_HIT_NOHOOK ) GameServer ( ) - > CreateSound ( m_Pos , SOUND_HOOK_NOATTACH , Teams ( ) - > TeamMask ( Team ( ) , m_pPlayer - > GetCID ( ) , m_pPlayer - > GetCID ( ) ) ) ;
2011-01-29 00:59:50 +00:00
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
if ( m_pPlayer - > GetTeam ( ) = = TEAM_SPECTATORS )
{
m_Pos . x = m_Input . m_TargetX ;
m_Pos . y = m_Input . m_TargetY ;
}
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
// update the m_SendCore if needed
{
CNetObj_Character Predicted ;
CNetObj_Character Current ;
mem_zero ( & Predicted , sizeof ( Predicted ) ) ;
mem_zero ( & Current , sizeof ( Current ) ) ;
m_ReckoningCore . Write ( & Predicted ) ;
m_Core . Write ( & Current ) ;
// only allow dead reackoning for a top of 3 seconds
if ( m_Core . m_pReset | | m_ReckoningTick + Server ( ) - > TickSpeed ( ) * 3 < Server ( ) - > Tick ( ) | | mem_comp ( & Predicted , & Current , sizeof ( CNetObj_Character ) ) ! = 0 )
{
m_ReckoningTick = Server ( ) - > Tick ( ) ;
m_SendCore = m_Core ;
m_ReckoningCore = m_Core ;
m_Core . m_pReset = false ;
}
}
}
2012-01-09 23:49:31 +00:00
void CCharacter : : TickPaused ( )
{
+ + m_AttackTick ;
+ + m_DamageTakenTick ;
+ + m_Ninja . m_ActivationTick ;
+ + m_ReckoningTick ;
if ( m_LastAction ! = - 1 )
+ + m_LastAction ;
2014-04-14 08:56:14 +00:00
if ( m_aWeapons [ m_Core . m_ActiveWeapon ] . m_AmmoRegenStart > - 1 )
+ + m_aWeapons [ m_Core . m_ActiveWeapon ] . m_AmmoRegenStart ;
2012-01-09 23:49:31 +00:00
if ( m_EmoteStop > - 1 )
+ + m_EmoteStop ;
}
2011-01-29 00:59:50 +00:00
bool CCharacter : : IncreaseHealth ( int Amount )
{
if ( m_Health > = 10 )
return false ;
m_Health = clamp ( m_Health + Amount , 0 , 10 ) ;
return true ;
}
bool CCharacter : : IncreaseArmor ( int Amount )
{
if ( m_Armor > = 10 )
return false ;
m_Armor = clamp ( m_Armor + Amount , 0 , 10 ) ;
return true ;
}
void CCharacter : : Die ( int Killer , int Weapon )
{
2014-09-26 00:25:53 +00:00
if ( Server ( ) - > IsRecording ( m_pPlayer - > GetCID ( ) ) )
Server ( ) - > StopRecord ( m_pPlayer - > GetCID ( ) ) ;
2011-01-29 00:59:50 +00:00
int ModeSpecial = GameServer ( ) - > m_pController - > OnCharacterDeath ( this , GameServer ( ) - > m_apPlayers [ Killer ] , Weapon ) ;
char aBuf [ 256 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " kill killer='%d:%s' victim='%d:%s' weapon=%d special=%d " ,
Killer , Server ( ) - > ClientName ( Killer ) ,
m_pPlayer - > GetCID ( ) , Server ( ) - > ClientName ( m_pPlayer - > GetCID ( ) ) , Weapon , ModeSpecial ) ;
GameServer ( ) - > Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_DEBUG , " game " , aBuf ) ;
// send the kill message
CNetMsg_Sv_KillMsg Msg ;
Msg . m_Killer = Killer ;
Msg . m_Victim = m_pPlayer - > GetCID ( ) ;
Msg . m_Weapon = Weapon ;
Msg . m_ModeSpecial = ModeSpecial ;
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL , - 1 ) ;
// a nice sound
2011-09-02 18:04:18 +00:00
GameServer ( ) - > CreateSound ( m_Pos , SOUND_PLAYER_DIE , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
// this is for auto respawn after 3 secs
m_pPlayer - > m_DieTick = Server ( ) - > Tick ( ) ;
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
m_Alive = false ;
2010-05-29 07:25:38 +00:00
GameServer ( ) - > m_World . RemoveEntity ( this ) ;
2011-01-29 00:59:50 +00:00
GameServer ( ) - > m_World . m_Core . m_apCharacters [ m_pPlayer - > GetCID ( ) ] = 0 ;
2011-09-02 18:04:18 +00:00
GameServer ( ) - > CreateDeath ( m_Pos , m_pPlayer - > GetCID ( ) , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2014-04-12 10:08:20 +00:00
Teams ( ) - > OnCharacterDeath ( GetPlayer ( ) - > GetCID ( ) , Weapon ) ;
2011-01-29 00:59:50 +00:00
}
bool CCharacter : : TakeDamage ( vec2 Force , int Dmg , int From , int Weapon )
2008-07-06 11:21:21 +00:00
{
2014-04-02 17:55:42 +00:00
/*m_Core.m_Vel += Force;
if ( GameServer ( ) - > m_pController - > IsFriendlyFire ( m_pPlayer - > GetCID ( ) , From ) & & ! g_Config . m_SvTeamdamage )
return false ;
2011-01-29 00:59:50 +00:00
// m_pPlayer only inflicts half damage on self
if ( From = = m_pPlayer - > GetCID ( ) )
Dmg = max ( 1 , Dmg / 2 ) ;
m_DamageTaken + + ;
// create healthmod indicator
if ( Server ( ) - > Tick ( ) < m_DamageTakenTick + 25 )
{
// make sure that the damage indicators doesn't group together
GameServer ( ) - > CreateDamageInd ( m_Pos , m_DamageTaken * 0.25f , Dmg ) ;
}
else
{
m_DamageTaken = 0 ;
GameServer ( ) - > CreateDamageInd ( m_Pos , 0 , Dmg ) ;
}
if ( Dmg )
{
if ( m_Armor )
{
if ( Dmg > 1 )
{
m_Health - - ;
Dmg - - ;
}
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
if ( Dmg > m_Armor )
{
Dmg - = m_Armor ;
m_Armor = 0 ;
}
else
{
m_Armor - = Dmg ;
Dmg = 0 ;
}
}
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
m_Health - = Dmg ;
}
m_DamageTakenTick = Server ( ) - > Tick ( ) ;
// do damage Hit sound
if ( From > = 0 & & From ! = m_pPlayer - > GetCID ( ) & & GameServer ( ) - > m_apPlayers [ From ] )
2011-06-02 09:44:35 +00:00
{
2013-12-31 05:13:57 +00:00
int64_t Mask = CmaskOne ( From ) ;
2011-06-02 09:44:35 +00:00
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
{
if ( GameServer ( ) - > m_apPlayers [ i ] & & GameServer ( ) - > m_apPlayers [ i ] - > GetTeam ( ) = = TEAM_SPECTATORS & & GameServer ( ) - > m_apPlayers [ i ] - > m_SpectatorID = = From )
Mask | = CmaskOne ( i ) ;
}
GameServer ( ) - > CreateSound ( GameServer ( ) - > m_apPlayers [ From ] - > m_ViewPos , SOUND_HIT , Mask ) ;
}
2011-01-29 00:59:50 +00:00
// check for death
if ( m_Health < = 0 )
{
Die ( From , Weapon ) ;
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
// set attacker's face to happy (taunt!)
if ( From > = 0 & & From ! = m_pPlayer - > GetCID ( ) & & GameServer ( ) - > m_apPlayers [ From ] )
{
CCharacter * pChr = GameServer ( ) - > m_apPlayers [ From ] - > GetCharacter ( ) ;
if ( pChr )
{
pChr - > m_EmoteType = EMOTE_HAPPY ;
pChr - > m_EmoteStop = Server ( ) - > Tick ( ) + Server ( ) - > TickSpeed ( ) ;
}
}
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
return false ;
}
if ( Dmg > 2 )
GameServer ( ) - > CreateSound ( m_Pos , SOUND_PLAYER_PAIN_LONG ) ;
else
2011-04-09 06:41:31 +00:00
GameServer ( ) - > CreateSound ( m_Pos , SOUND_PLAYER_PAIN_SHORT ) ; */
2008-07-06 11:21:21 +00:00
2014-04-14 08:56:14 +00:00
if ( ! m_Jetpack | | m_Core . m_ActiveWeapon ! = WEAPON_GUN )
2014-01-09 18:50:37 +00:00
{
m_EmoteType = EMOTE_PAIN ;
m_EmoteStop = Server ( ) - > Tick ( ) + 500 * Server ( ) - > TickSpeed ( ) / 1000 ;
}
2008-07-06 11:21:21 +00:00
2011-01-29 00:59:50 +00:00
vec2 Temp = m_Core . m_Vel + Force ;
if ( Temp . x > 0 & & ( ( m_TileIndex = = TILE_STOP & & m_TileFlags = = ROTATION_270 ) | | ( m_TileIndexL = = TILE_STOP & & m_TileFlagsL = = ROTATION_270 ) | | ( m_TileIndexL = = TILE_STOPS & & ( m_TileFlagsL = = ROTATION_90 | | m_TileFlagsL = = ROTATION_270 ) ) | | ( m_TileIndexL = = TILE_STOPA ) | | ( m_TileFIndex = = TILE_STOP & & m_TileFFlags = = ROTATION_270 ) | | ( m_TileFIndexL = = TILE_STOP & & m_TileFFlagsL = = ROTATION_270 ) | | ( m_TileFIndexL = = TILE_STOPS & & ( m_TileFFlagsL = = ROTATION_90 | | m_TileFFlagsL = = ROTATION_270 ) ) | | ( m_TileFIndexL = = TILE_STOPA ) | | ( m_TileSIndex = = TILE_STOP & & m_TileSFlags = = ROTATION_270 ) | | ( m_TileSIndexL = = TILE_STOP & & m_TileSFlagsL = = ROTATION_270 ) | | ( m_TileSIndexL = = TILE_STOPS & & ( m_TileSFlagsL = = ROTATION_90 | | m_TileSFlagsL = = ROTATION_270 ) ) | | ( m_TileSIndexL = = TILE_STOPA ) ) )
Temp . x = 0 ;
if ( Temp . x < 0 & & ( ( m_TileIndex = = TILE_STOP & & m_TileFlags = = ROTATION_90 ) | | ( m_TileIndexR = = TILE_STOP & & m_TileFlagsR = = ROTATION_90 ) | | ( m_TileIndexR = = TILE_STOPS & & ( m_TileFlagsR = = ROTATION_90 | | m_TileFlagsR = = ROTATION_270 ) ) | | ( m_TileIndexR = = TILE_STOPA ) | | ( m_TileFIndex = = TILE_STOP & & m_TileFFlags = = ROTATION_90 ) | | ( m_TileFIndexR = = TILE_STOP & & m_TileFFlagsR = = ROTATION_90 ) | | ( m_TileFIndexR = = TILE_STOPS & & ( m_TileFFlagsR = = ROTATION_90 | | m_TileFFlagsR = = ROTATION_270 ) ) | | ( m_TileFIndexR = = TILE_STOPA ) | | ( m_TileSIndex = = TILE_STOP & & m_TileSFlags = = ROTATION_90 ) | | ( m_TileSIndexR = = TILE_STOP & & m_TileSFlagsR = = ROTATION_90 ) | | ( m_TileSIndexR = = TILE_STOPS & & ( m_TileSFlagsR = = ROTATION_90 | | m_TileSFlagsR = = ROTATION_270 ) ) | | ( m_TileSIndexR = = TILE_STOPA ) ) )
Temp . x = 0 ;
if ( Temp . y < 0 & & ( ( m_TileIndex = = TILE_STOP & & m_TileFlags = = ROTATION_180 ) | | ( m_TileIndexB = = TILE_STOP & & m_TileFlagsB = = ROTATION_180 ) | | ( m_TileIndexB = = TILE_STOPS & & ( m_TileFlagsB = = ROTATION_0 | | m_TileFlagsB = = ROTATION_180 ) ) | | ( m_TileIndexB = = TILE_STOPA ) | | ( m_TileFIndex = = TILE_STOP & & m_TileFFlags = = ROTATION_180 ) | | ( m_TileFIndexB = = TILE_STOP & & m_TileFFlagsB = = ROTATION_180 ) | | ( m_TileFIndexB = = TILE_STOPS & & ( m_TileFFlagsB = = ROTATION_0 | | m_TileFFlagsB = = ROTATION_180 ) ) | | ( m_TileFIndexB = = TILE_STOPA ) | | ( m_TileSIndex = = TILE_STOP & & m_TileSFlags = = ROTATION_180 ) | | ( m_TileSIndexB = = TILE_STOP & & m_TileSFlagsB = = ROTATION_180 ) | | ( m_TileSIndexB = = TILE_STOPS & & ( m_TileSFlagsB = = ROTATION_0 | | m_TileSFlagsB = = ROTATION_180 ) ) | | ( m_TileSIndexB = = TILE_STOPA ) ) )
Temp . y = 0 ;
if ( Temp . y > 0 & & ( ( m_TileIndex = = TILE_STOP & & m_TileFlags = = ROTATION_0 ) | | ( m_TileIndexT = = TILE_STOP & & m_TileFlagsT = = ROTATION_0 ) | | ( m_TileIndexT = = TILE_STOPS & & ( m_TileFlagsT = = ROTATION_0 | | m_TileFlagsT = = ROTATION_180 ) ) | | ( m_TileIndexT = = TILE_STOPA ) | | ( m_TileFIndex = = TILE_STOP & & m_TileFFlags = = ROTATION_0 ) | | ( m_TileFIndexT = = TILE_STOP & & m_TileFFlagsT = = ROTATION_0 ) | | ( m_TileFIndexT = = TILE_STOPS & & ( m_TileFFlagsT = = ROTATION_0 | | m_TileFFlagsT = = ROTATION_180 ) ) | | ( m_TileFIndexT = = TILE_STOPA ) | | ( m_TileSIndex = = TILE_STOP & & m_TileSFlags = = ROTATION_0 ) | | ( m_TileSIndexT = = TILE_STOP & & m_TileSFlagsT = = ROTATION_0 ) | | ( m_TileSIndexT = = TILE_STOPS & & ( m_TileSFlagsT = = ROTATION_0 | | m_TileSFlagsT = = ROTATION_180 ) ) | | ( m_TileSIndexT = = TILE_STOPA ) ) )
Temp . y = 0 ;
m_Core . m_Vel = Temp ;
2011-04-09 06:41:31 +00:00
2011-01-29 00:59:50 +00:00
return true ;
}
void CCharacter : : Snap ( int SnappingClient )
{
2013-12-31 05:13:57 +00:00
int id = m_pPlayer - > GetCID ( ) ;
2014-09-26 01:20:47 +00:00
if ( SnappingClient > - 1 & & ! Server ( ) - > Translate ( id , SnappingClient ) )
2013-12-31 05:13:57 +00:00
return ;
2011-01-29 00:59:50 +00:00
if ( NetworkClipped ( SnappingClient ) )
return ;
2011-04-13 18:37:12 +00:00
2014-09-26 01:20:47 +00:00
if ( SnappingClient > - 1 )
{
CCharacter * SnapChar = GameServer ( ) - > GetPlayerChar ( SnappingClient ) ;
CPlayer * SnapPlayer = GameServer ( ) - > m_apPlayers [ SnappingClient ] ;
2011-12-31 12:54:29 +00:00
2017-04-08 22:20:41 +00:00
if ( ( SnapPlayer - > GetTeam ( ) = = TEAM_SPECTATORS | | SnapPlayer - > IsPaused ( ) ) & & SnapPlayer - > m_SpectatorID ! = - 1
2014-09-26 01:20:47 +00:00
& & ! CanCollide ( SnapPlayer - > m_SpectatorID ) & & ! SnapPlayer - > m_ShowOthers )
return ;
2011-12-31 12:54:29 +00:00
2017-04-08 22:20:41 +00:00
if ( SnapPlayer - > GetTeam ( ) ! = TEAM_SPECTATORS & & ! SnapPlayer - > IsPaused ( ) & & SnapChar & & ! SnapChar - > m_Super
2014-09-26 01:20:47 +00:00
& & ! CanCollide ( SnappingClient ) & & ! SnapPlayer - > m_ShowOthers )
return ;
2011-04-09 06:41:31 +00:00
2017-04-08 22:20:41 +00:00
if ( ( SnapPlayer - > GetTeam ( ) = = TEAM_SPECTATORS | | SnapPlayer - > IsPaused ( ) ) & & SnapPlayer - > m_SpectatorID = = - 1
2014-09-26 01:20:47 +00:00
& & ! CanCollide ( SnappingClient ) & & SnapPlayer - > m_SpecTeam )
return ;
}
2014-08-09 17:53:38 +00:00
2011-12-29 13:58:39 +00:00
if ( m_Paused )
return ;
2013-12-31 05:13:57 +00:00
CNetObj_Character * pCharacter = static_cast < CNetObj_Character * > ( Server ( ) - > SnapNewItem ( NETOBJTYPE_CHARACTER , id , sizeof ( CNetObj_Character ) ) ) ;
2011-01-29 00:59:50 +00:00
if ( ! pCharacter )
return ;
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
// write down the m_Core
if ( ! m_ReckoningTick | | GameServer ( ) - > m_World . m_Paused )
{
// no dead reckoning when paused because the client doesn't know
// how far to perform the reckoning
pCharacter - > m_Tick = 0 ;
m_Core . Write ( pCharacter ) ;
}
else
{
pCharacter - > m_Tick = m_ReckoningTick ;
m_SendCore . Write ( pCharacter ) ;
}
2011-04-13 18:37:12 +00:00
2011-01-29 00:59:50 +00:00
// set emote
if ( m_EmoteStop < Server ( ) - > Tick ( ) )
{
Added the following settings to Close #123.
sv_time_in_broadcast, 1, 0, 1, CFGFLAG_SERVER, "Whether to display time in broadcast every interval or not by default, later the choice can be changed by players via chat commands"
sv_time_in_broadcast_interval, 1, 0, 60, CFGFLAG_SERVER, "How often to update the broadcast time"
sv_time_in_gametimer, 0, 0, 1, CFGFLAG_SERVER, "Whether to display time in the round/game timer or not by default, later the choice can be changed by players via chat commands"
Added the following Chat commands to give the player the choice over their settings:
"saytime", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSayTime, this, "Privately messages you your current time in this current running race"
"saytimeall", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSayTimeAll, this, "Publicly messages everyone your current time in this current running race"
"time", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTime, this, "Privately shows you your current time in this current running race in the broadcast message"
"broadcasttime", "?s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetBroadcastTime, this, "Personal Setting of showing time in the broadcast, broadcasttime s, where s = on for on, off for off, toggle for toggle and nothing to show current status"
"servergametime", "?s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetServerGameTime, this, "Personal Setting of showing time in the round/game timer, servergametime s, where s = on for on off for off, toggle for toggle and nothing to show current status"
Fixed Chat Command "eyeemote" and made it a set + toggle instead of just toggle for better bin techneques
Moved some vars from CCharacter to CPlayer to keep their status evern after death but not after disconnect.
So now players have the choice to see which timer they wanna see if any.
Note: These changes are all untested Stay away from this update on your main server until they are tested, i don't even know if they will compile propperly
2011-12-29 12:17:34 +00:00
m_EmoteType = m_pPlayer - > m_DefEmote ;
2011-01-29 00:59:50 +00:00
m_EmoteStop = - 1 ;
}
2015-03-14 17:55:50 +00:00
pCharacter - > m_Emote = m_EmoteType ;
2011-01-29 00:59:50 +00:00
2013-12-31 05:13:57 +00:00
if ( pCharacter - > m_HookedPlayer ! = - 1 )
{
if ( ! Server ( ) - > Translate ( pCharacter - > m_HookedPlayer , SnappingClient ) )
pCharacter - > m_HookedPlayer = - 1 ;
}
2011-01-29 00:59:50 +00:00
2015-03-14 17:55:50 +00:00
pCharacter - > m_AttackTick = m_AttackTick ;
pCharacter - > m_Direction = m_Input . m_Direction ;
pCharacter - > m_Weapon = m_Core . m_ActiveWeapon ;
2011-01-29 00:59:50 +00:00
pCharacter - > m_AmmoCount = 0 ;
pCharacter - > m_Health = 0 ;
pCharacter - > m_Armor = 0 ;
2011-02-05 02:28:05 +00:00
2015-03-14 17:55:50 +00:00
// change eyes and use ninja graphic if player is freeze
2011-02-05 02:28:05 +00:00
if ( m_DeepFreeze )
{
2011-08-14 15:23:57 +00:00
if ( pCharacter - > m_Emote = = EMOTE_NORMAL )
pCharacter - > m_Emote = EMOTE_PAIN ;
2011-02-05 02:28:05 +00:00
pCharacter - > m_Weapon = WEAPON_NINJA ;
}
else if ( m_FreezeTime > 0 | | m_FreezeTime = = - 1 )
2011-01-29 00:59:50 +00:00
{
2011-08-14 15:23:57 +00:00
if ( pCharacter - > m_Emote = = EMOTE_NORMAL )
pCharacter - > m_Emote = EMOTE_BLINK ;
2011-01-29 00:59:50 +00:00
pCharacter - > m_Weapon = WEAPON_NINJA ;
}
2015-03-14 17:55:50 +00:00
// jetpack and ninjajetpack prediction
if ( m_pPlayer - > GetCID ( ) = = SnappingClient )
{
if ( m_Jetpack & & pCharacter - > m_Weapon ! = WEAPON_NINJA )
{
if ( ! ( m_NeededFaketuning & FAKETUNE_JETPACK ) )
{
m_NeededFaketuning | = FAKETUNE_JETPACK ;
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ;
}
}
else
{
if ( m_NeededFaketuning & FAKETUNE_JETPACK )
{
m_NeededFaketuning & = ~ FAKETUNE_JETPACK ;
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ;
}
}
}
// change eyes, use ninja graphic and set ammo count if player has ninjajetpack
if ( m_pPlayer - > m_NinjaJetpack & & m_Jetpack & & m_Core . m_ActiveWeapon = = WEAPON_GUN & & ! m_DeepFreeze & & ! ( m_FreezeTime > 0 | | m_FreezeTime = = - 1 ) )
2014-01-09 18:00:41 +00:00
{
2015-03-14 17:55:50 +00:00
if ( pCharacter - > m_Emote = = EMOTE_NORMAL )
pCharacter - > m_Emote = EMOTE_HAPPY ;
2014-01-09 18:00:41 +00:00
pCharacter - > m_Weapon = WEAPON_NINJA ;
pCharacter - > m_AmmoCount = 10 ;
}
2011-01-29 00:59:50 +00:00
2011-06-19 09:28:39 +00:00
if ( m_pPlayer - > GetCID ( ) = = SnappingClient | | SnappingClient = = - 1 | |
( ! g_Config . m_SvStrictSpectateMode & & m_pPlayer - > GetCID ( ) = = GameServer ( ) - > m_apPlayers [ SnappingClient ] - > m_SpectatorID ) )
2011-01-29 00:59:50 +00:00
{
pCharacter - > m_Health = m_Health ;
pCharacter - > m_Armor = m_Armor ;
2014-04-14 08:56:14 +00:00
if ( m_aWeapons [ m_Core . m_ActiveWeapon ] . m_Ammo > 0 )
//pCharacter->m_AmmoCount = m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo;
pCharacter - > m_AmmoCount = ( ! m_FreezeTime ) ? m_aWeapons [ m_Core . m_ActiveWeapon ] . m_Ammo : 0 ;
2011-01-29 00:59:50 +00:00
}
2017-04-08 22:20:41 +00:00
if ( GetPlayer ( ) - > m_Afk | | GetPlayer ( ) - > IsPaused ( ) )
2017-05-19 17:12:52 +00:00
{
if ( m_FreezeTime > 0 | | m_FreezeTime = = - 1 | | m_DeepFreeze )
pCharacter - > m_Emote = EMOTE_NORMAL ;
else
pCharacter - > m_Emote = EMOTE_BLINK ;
}
2014-01-22 00:46:15 +00:00
2011-01-29 00:59:50 +00:00
if ( pCharacter - > m_Emote = = EMOTE_NORMAL )
{
if ( 250 - ( ( Server ( ) - > Tick ( ) - m_LastAction ) % ( 250 ) ) < 5 )
pCharacter - > m_Emote = EMOTE_BLINK ;
}
2014-09-18 10:14:00 +00:00
if ( m_pPlayer - > m_Halloween )
{
if ( 1200 - ( ( Server ( ) - > Tick ( ) - m_LastAction ) % ( 1200 ) ) < 5 )
{
GameServer ( ) - > SendEmoticon ( m_pPlayer - > GetCID ( ) , EMOTICON_GHOST ) ;
}
}
2011-03-01 17:31:20 +00:00
pCharacter - > m_PlayerFlags = GetPlayer ( ) - > m_PlayerFlags ;
2011-01-29 00:59:50 +00:00
}
2011-04-09 06:41:31 +00:00
2014-01-10 21:54:07 +00:00
int CCharacter : : NetworkClipped ( int SnappingClient )
{
return NetworkClipped ( SnappingClient , m_Pos ) ;
}
int CCharacter : : NetworkClipped ( int SnappingClient , vec2 CheckPos )
{
2014-02-02 18:56:10 +00:00
if ( SnappingClient = = - 1 | | GameServer ( ) - > m_apPlayers [ SnappingClient ] - > m_ShowAll )
return 0 ;
float dx = GameServer ( ) - > m_apPlayers [ SnappingClient ] - > m_ViewPos . x - CheckPos . x ;
float dy = GameServer ( ) - > m_apPlayers [ SnappingClient ] - > m_ViewPos . y - CheckPos . y ;
if ( absolute ( dx ) > 1000.0f | | absolute ( dy ) > 800.0f )
return 1 ;
if ( distance ( GameServer ( ) - > m_apPlayers [ SnappingClient ] - > m_ViewPos , CheckPos ) > 4000.0f )
return 1 ;
2014-01-10 21:54:07 +00:00
return 0 ;
}
2011-04-09 06:41:31 +00:00
// DDRace
2011-02-13 05:35:13 +00:00
bool CCharacter : : CanCollide ( int ClientID )
2011-01-29 00:59:50 +00:00
{
2011-02-13 05:35:13 +00:00
return Teams ( ) - > m_Core . CanCollide ( GetPlayer ( ) - > GetCID ( ) , ClientID ) ;
2011-01-29 00:59:50 +00:00
}
2011-02-13 05:35:13 +00:00
bool CCharacter : : SameTeam ( int ClientID )
2011-01-29 00:59:50 +00:00
{
2011-02-13 05:35:13 +00:00
return Teams ( ) - > m_Core . SameTeam ( GetPlayer ( ) - > GetCID ( ) , ClientID ) ;
2011-01-29 00:59:50 +00:00
}
2010-09-17 11:26:06 +00:00
int CCharacter : : Team ( )
{
2011-07-21 22:01:12 +00:00
return Teams ( ) - > m_Core . Team ( m_pPlayer - > GetCID ( ) ) ;
2010-08-28 20:53:42 +00:00
}
2010-09-17 11:26:06 +00:00
CGameTeams * CCharacter : : Teams ( )
{
2011-01-29 00:59:50 +00:00
return & ( ( CGameControllerDDRace * ) GameServer ( ) - > m_pController ) - > m_Teams ;
2010-09-08 16:22:11 +00:00
}
2011-06-05 11:56:04 +00:00
2011-01-29 00:59:50 +00:00
void CCharacter : : HandleBroadcast ( )
2008-07-06 11:21:21 +00:00
{
2010-10-08 13:33:42 +00:00
CPlayerData * pData = GameServer ( ) - > Score ( ) - > PlayerData ( m_pPlayer - > GetCID ( ) ) ;
2013-03-18 11:58:29 +00:00
if ( m_DDRaceState = = DDRACE_STARTED & & m_CpLastBroadcast ! = m_CpActive & &
2015-06-22 11:07:41 +00:00
m_CpActive > - 1 & & m_CpTick > Server ( ) - > Tick ( ) & & m_pPlayer - > m_ClientVersion = = VERSION_VANILLA & &
2011-06-05 11:56:04 +00:00
pData - > m_BestTime & & pData - > m_aBestCpTime [ m_CpActive ] ! = 0 )
2010-10-08 13:33:42 +00:00
{
Added the following settings to Close #123.
sv_time_in_broadcast, 1, 0, 1, CFGFLAG_SERVER, "Whether to display time in broadcast every interval or not by default, later the choice can be changed by players via chat commands"
sv_time_in_broadcast_interval, 1, 0, 60, CFGFLAG_SERVER, "How often to update the broadcast time"
sv_time_in_gametimer, 0, 0, 1, CFGFLAG_SERVER, "Whether to display time in the round/game timer or not by default, later the choice can be changed by players via chat commands"
Added the following Chat commands to give the player the choice over their settings:
"saytime", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSayTime, this, "Privately messages you your current time in this current running race"
"saytimeall", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSayTimeAll, this, "Publicly messages everyone your current time in this current running race"
"time", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTime, this, "Privately shows you your current time in this current running race in the broadcast message"
"broadcasttime", "?s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetBroadcastTime, this, "Personal Setting of showing time in the broadcast, broadcasttime s, where s = on for on, off for off, toggle for toggle and nothing to show current status"
"servergametime", "?s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetServerGameTime, this, "Personal Setting of showing time in the round/game timer, servergametime s, where s = on for on off for off, toggle for toggle and nothing to show current status"
Fixed Chat Command "eyeemote" and made it a set + toggle instead of just toggle for better bin techneques
Moved some vars from CCharacter to CPlayer to keep their status evern after death but not after disconnect.
So now players have the choice to see which timer they wanna see if any.
Note: These changes are all untested Stay away from this update on your main server until they are tested, i don't even know if they will compile propperly
2011-12-29 12:17:34 +00:00
char aBroadcast [ 128 ] ;
2011-06-05 11:56:04 +00:00
float Diff = m_CpCurrent [ m_CpActive ] - pData - > m_aBestCpTime [ m_CpActive ] ;
str_format ( aBroadcast , sizeof ( aBroadcast ) , " Checkpoint | Diff : %+5.2f " , Diff ) ;
GameServer ( ) - > SendBroadcast ( aBroadcast , m_pPlayer - > GetCID ( ) ) ;
2013-03-18 11:58:29 +00:00
m_CpLastBroadcast = m_CpActive ;
2011-06-05 11:56:04 +00:00
m_LastBroadcast = Server ( ) - > Tick ( ) ;
2010-08-10 04:28:17 +00:00
}
2017-02-27 22:10:19 +00:00
else if ( ( m_pPlayer - > m_TimerType = = CPlayer : : TIMERTYPE_BROADCAST | | m_pPlayer - > m_TimerType = = CPlayer : : TIMERTYPE_GAMETIMER_AND_BROADCAST ) & & m_DDRaceState = = DDRACE_STARTED & & m_LastBroadcast + Server ( ) - > TickSpeed ( ) * g_Config . m_SvTimeInBroadcastInterval < = Server ( ) - > Tick ( ) )
Added the following settings to Close #123.
sv_time_in_broadcast, 1, 0, 1, CFGFLAG_SERVER, "Whether to display time in broadcast every interval or not by default, later the choice can be changed by players via chat commands"
sv_time_in_broadcast_interval, 1, 0, 60, CFGFLAG_SERVER, "How often to update the broadcast time"
sv_time_in_gametimer, 0, 0, 1, CFGFLAG_SERVER, "Whether to display time in the round/game timer or not by default, later the choice can be changed by players via chat commands"
Added the following Chat commands to give the player the choice over their settings:
"saytime", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSayTime, this, "Privately messages you your current time in this current running race"
"saytimeall", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSayTimeAll, this, "Publicly messages everyone your current time in this current running race"
"time", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTime, this, "Privately shows you your current time in this current running race in the broadcast message"
"broadcasttime", "?s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetBroadcastTime, this, "Personal Setting of showing time in the broadcast, broadcasttime s, where s = on for on, off for off, toggle for toggle and nothing to show current status"
"servergametime", "?s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetServerGameTime, this, "Personal Setting of showing time in the round/game timer, servergametime s, where s = on for on off for off, toggle for toggle and nothing to show current status"
Fixed Chat Command "eyeemote" and made it a set + toggle instead of just toggle for better bin techneques
Moved some vars from CCharacter to CPlayer to keep their status evern after death but not after disconnect.
So now players have the choice to see which timer they wanna see if any.
Note: These changes are all untested Stay away from this update on your main server until they are tested, i don't even know if they will compile propperly
2011-12-29 12:17:34 +00:00
{
char aBuftime [ 64 ] ;
int IntTime = ( int ) ( ( float ) ( Server ( ) - > Tick ( ) - m_StartTime ) / ( ( float ) Server ( ) - > TickSpeed ( ) ) ) ;
str_format ( aBuftime , sizeof ( aBuftime ) , " %s%d:%s%d " , ( ( IntTime / 60 ) > 9 ) ? " " : " 0 " , IntTime / 60 , ( ( IntTime % 60 ) > 9 ) ? " " : " 0 " , IntTime % 60 ) ;
GameServer ( ) - > SendBroadcast ( aBuftime , m_pPlayer - > GetCID ( ) ) ;
2013-03-18 11:58:29 +00:00
m_CpLastBroadcast = m_CpActive ;
Added the following settings to Close #123.
sv_time_in_broadcast, 1, 0, 1, CFGFLAG_SERVER, "Whether to display time in broadcast every interval or not by default, later the choice can be changed by players via chat commands"
sv_time_in_broadcast_interval, 1, 0, 60, CFGFLAG_SERVER, "How often to update the broadcast time"
sv_time_in_gametimer, 0, 0, 1, CFGFLAG_SERVER, "Whether to display time in the round/game timer or not by default, later the choice can be changed by players via chat commands"
Added the following Chat commands to give the player the choice over their settings:
"saytime", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSayTime, this, "Privately messages you your current time in this current running race"
"saytimeall", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSayTimeAll, this, "Publicly messages everyone your current time in this current running race"
"time", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTime, this, "Privately shows you your current time in this current running race in the broadcast message"
"broadcasttime", "?s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetBroadcastTime, this, "Personal Setting of showing time in the broadcast, broadcasttime s, where s = on for on, off for off, toggle for toggle and nothing to show current status"
"servergametime", "?s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetServerGameTime, this, "Personal Setting of showing time in the round/game timer, servergametime s, where s = on for on off for off, toggle for toggle and nothing to show current status"
Fixed Chat Command "eyeemote" and made it a set + toggle instead of just toggle for better bin techneques
Moved some vars from CCharacter to CPlayer to keep their status evern after death but not after disconnect.
So now players have the choice to see which timer they wanna see if any.
Note: These changes are all untested Stay away from this update on your main server until they are tested, i don't even know if they will compile propperly
2011-12-29 12:17:34 +00:00
m_LastBroadcast = Server ( ) - > Tick ( ) ;
}
2011-01-29 00:59:50 +00:00
}
2011-01-21 09:44:29 +00:00
2011-01-29 00:59:50 +00:00
void CCharacter : : HandleSkippableTiles ( int Index )
{
2011-01-29 23:58:47 +00:00
// handle death-tiles and leaving gamelayer
2015-11-08 09:20:10 +00:00
if ( ( GameServer ( ) - > Collision ( ) - > GetCollisionAt ( m_Pos . x + m_ProximityRadius / 3.f , m_Pos . y - m_ProximityRadius / 3.f ) = = TILE_DEATH | |
GameServer ( ) - > Collision ( ) - > GetCollisionAt ( m_Pos . x + m_ProximityRadius / 3.f , m_Pos . y + m_ProximityRadius / 3.f ) = = TILE_DEATH | |
GameServer ( ) - > Collision ( ) - > GetCollisionAt ( m_Pos . x - m_ProximityRadius / 3.f , m_Pos . y - m_ProximityRadius / 3.f ) = = TILE_DEATH | |
GameServer ( ) - > Collision ( ) - > GetFCollisionAt ( m_Pos . x + m_ProximityRadius / 3.f , m_Pos . y - m_ProximityRadius / 3.f ) = = TILE_DEATH | |
GameServer ( ) - > Collision ( ) - > GetFCollisionAt ( m_Pos . x + m_ProximityRadius / 3.f , m_Pos . y + m_ProximityRadius / 3.f ) = = TILE_DEATH | |
GameServer ( ) - > Collision ( ) - > GetFCollisionAt ( m_Pos . x - m_ProximityRadius / 3.f , m_Pos . y - m_ProximityRadius / 3.f ) = = TILE_DEATH | |
GameServer ( ) - > Collision ( ) - > GetCollisionAt ( m_Pos . x - m_ProximityRadius / 3.f , m_Pos . y + m_ProximityRadius / 3.f ) = = TILE_DEATH ) & &
2011-08-31 21:36:41 +00:00
! m_Super & & ! ( Team ( ) & & Teams ( ) - > TeeFinished ( m_pPlayer - > GetCID ( ) ) ) )
2014-01-31 22:24:45 +00:00
{
Die ( m_pPlayer - > GetCID ( ) , WEAPON_WORLD ) ;
return ;
}
2015-03-28 20:52:43 +00:00
if ( GameLayerClipped ( m_Pos ) )
2014-01-31 22:24:45 +00:00
{
Die ( m_pPlayer - > GetCID ( ) , WEAPON_WORLD ) ;
return ;
}
2011-01-29 23:58:47 +00:00
if ( Index < 0 )
return ;
2011-01-21 09:44:29 +00:00
// handle speedup tiles
2011-01-29 00:59:50 +00:00
if ( GameServer ( ) - > Collision ( ) - > IsSpeedup ( Index ) )
2010-06-11 09:39:32 +00:00
{
2011-01-21 09:44:29 +00:00
vec2 Direction , MaxVel , TempVel = m_Core . m_Vel ;
int Force , MaxSpeed = 0 ;
float TeeAngle , SpeederAngle , DiffAngle , SpeedLeft , TeeSpeed ;
2011-01-29 00:59:50 +00:00
GameServer ( ) - > Collision ( ) - > GetSpeedup ( Index , & Direction , & Force , & MaxSpeed ) ;
2011-01-21 09:44:29 +00:00
if ( Force = = 255 & & MaxSpeed )
{
m_Core . m_Vel = Direction * ( MaxSpeed / 5 ) ;
}
else
{
if ( MaxSpeed > 0 & & MaxSpeed < 5 ) MaxSpeed = 5 ;
if ( MaxSpeed > 0 )
{
if ( Direction . x > 0.0000001f )
SpeederAngle = - atan ( Direction . y / Direction . x ) ;
else if ( Direction . x < 0.0000001f )
SpeederAngle = atan ( Direction . y / Direction . x ) + 2.0f * asin ( 1.0f ) ;
else if ( Direction . y > 0.0000001f )
SpeederAngle = asin ( 1.0f ) ;
else
SpeederAngle = asin ( - 1.0f ) ;
if ( SpeederAngle < 0 )
SpeederAngle = 4.0f * asin ( 1.0f ) + SpeederAngle ;
if ( TempVel . x > 0.0000001f )
TeeAngle = - atan ( TempVel . y / TempVel . x ) ;
else if ( TempVel . x < 0.0000001f )
TeeAngle = atan ( TempVel . y / TempVel . x ) + 2.0f * asin ( 1.0f ) ;
else if ( TempVel . y > 0.0000001f )
TeeAngle = asin ( 1.0f ) ;
else
TeeAngle = asin ( - 1.0f ) ;
if ( TeeAngle < 0 )
TeeAngle = 4.0f * asin ( 1.0f ) + TeeAngle ;
TeeSpeed = sqrt ( pow ( TempVel . x , 2 ) + pow ( TempVel . y , 2 ) ) ;
DiffAngle = SpeederAngle - TeeAngle ;
SpeedLeft = MaxSpeed / 5.0f - cos ( DiffAngle ) * TeeSpeed ;
2015-04-18 20:29:28 +00:00
if ( abs ( ( int ) SpeedLeft ) > Force & & SpeedLeft > 0.0000001f )
2011-01-21 09:44:29 +00:00
TempVel + = Direction * Force ;
2015-04-18 20:29:28 +00:00
else if ( abs ( ( int ) SpeedLeft ) > Force )
2011-01-21 09:44:29 +00:00
TempVel + = Direction * - Force ;
else
TempVel + = Direction * SpeedLeft ;
}
else
TempVel + = Direction * Force ;
if ( TempVel . x > 0 & & ( ( m_TileIndex = = TILE_STOP & & m_TileFlags = = ROTATION_270 ) | | ( m_TileIndexL = = TILE_STOP & & m_TileFlagsL = = ROTATION_270 ) | | ( m_TileIndexL = = TILE_STOPS & & ( m_TileFlagsL = = ROTATION_90 | | m_TileFlagsL = = ROTATION_270 ) ) | | ( m_TileIndexL = = TILE_STOPA ) | | ( m_TileFIndex = = TILE_STOP & & m_TileFFlags = = ROTATION_270 ) | | ( m_TileFIndexL = = TILE_STOP & & m_TileFFlagsL = = ROTATION_270 ) | | ( m_TileFIndexL = = TILE_STOPS & & ( m_TileFFlagsL = = ROTATION_90 | | m_TileFFlagsL = = ROTATION_270 ) ) | | ( m_TileFIndexL = = TILE_STOPA ) | | ( m_TileSIndex = = TILE_STOP & & m_TileSFlags = = ROTATION_270 ) | | ( m_TileSIndexL = = TILE_STOP & & m_TileSFlagsL = = ROTATION_270 ) | | ( m_TileSIndexL = = TILE_STOPS & & ( m_TileSFlagsL = = ROTATION_90 | | m_TileSFlagsL = = ROTATION_270 ) ) | | ( m_TileSIndexL = = TILE_STOPA ) ) )
TempVel . x = 0 ;
if ( TempVel . x < 0 & & ( ( m_TileIndex = = TILE_STOP & & m_TileFlags = = ROTATION_90 ) | | ( m_TileIndexR = = TILE_STOP & & m_TileFlagsR = = ROTATION_90 ) | | ( m_TileIndexR = = TILE_STOPS & & ( m_TileFlagsR = = ROTATION_90 | | m_TileFlagsR = = ROTATION_270 ) ) | | ( m_TileIndexR = = TILE_STOPA ) | | ( m_TileFIndex = = TILE_STOP & & m_TileFFlags = = ROTATION_90 ) | | ( m_TileFIndexR = = TILE_STOP & & m_TileFFlagsR = = ROTATION_90 ) | | ( m_TileFIndexR = = TILE_STOPS & & ( m_TileFFlagsR = = ROTATION_90 | | m_TileFFlagsR = = ROTATION_270 ) ) | | ( m_TileFIndexR = = TILE_STOPA ) | | ( m_TileSIndex = = TILE_STOP & & m_TileSFlags = = ROTATION_90 ) | | ( m_TileSIndexR = = TILE_STOP & & m_TileSFlagsR = = ROTATION_90 ) | | ( m_TileSIndexR = = TILE_STOPS & & ( m_TileSFlagsR = = ROTATION_90 | | m_TileSFlagsR = = ROTATION_270 ) ) | | ( m_TileSIndexR = = TILE_STOPA ) ) )
TempVel . x = 0 ;
if ( TempVel . y < 0 & & ( ( m_TileIndex = = TILE_STOP & & m_TileFlags = = ROTATION_180 ) | | ( m_TileIndexB = = TILE_STOP & & m_TileFlagsB = = ROTATION_180 ) | | ( m_TileIndexB = = TILE_STOPS & & ( m_TileFlagsB = = ROTATION_0 | | m_TileFlagsB = = ROTATION_180 ) ) | | ( m_TileIndexB = = TILE_STOPA ) | | ( m_TileFIndex = = TILE_STOP & & m_TileFFlags = = ROTATION_180 ) | | ( m_TileFIndexB = = TILE_STOP & & m_TileFFlagsB = = ROTATION_180 ) | | ( m_TileFIndexB = = TILE_STOPS & & ( m_TileFFlagsB = = ROTATION_0 | | m_TileFFlagsB = = ROTATION_180 ) ) | | ( m_TileFIndexB = = TILE_STOPA ) | | ( m_TileSIndex = = TILE_STOP & & m_TileSFlags = = ROTATION_180 ) | | ( m_TileSIndexB = = TILE_STOP & & m_TileSFlagsB = = ROTATION_180 ) | | ( m_TileSIndexB = = TILE_STOPS & & ( m_TileSFlagsB = = ROTATION_0 | | m_TileSFlagsB = = ROTATION_180 ) ) | | ( m_TileSIndexB = = TILE_STOPA ) ) )
TempVel . y = 0 ;
if ( TempVel . y > 0 & & ( ( m_TileIndex = = TILE_STOP & & m_TileFlags = = ROTATION_0 ) | | ( m_TileIndexT = = TILE_STOP & & m_TileFlagsT = = ROTATION_0 ) | | ( m_TileIndexT = = TILE_STOPS & & ( m_TileFlagsT = = ROTATION_0 | | m_TileFlagsT = = ROTATION_180 ) ) | | ( m_TileIndexT = = TILE_STOPA ) | | ( m_TileFIndex = = TILE_STOP & & m_TileFFlags = = ROTATION_0 ) | | ( m_TileFIndexT = = TILE_STOP & & m_TileFFlagsT = = ROTATION_0 ) | | ( m_TileFIndexT = = TILE_STOPS & & ( m_TileFFlagsT = = ROTATION_0 | | m_TileFFlagsT = = ROTATION_180 ) ) | | ( m_TileFIndexT = = TILE_STOPA ) | | ( m_TileSIndex = = TILE_STOP & & m_TileSFlags = = ROTATION_0 ) | | ( m_TileSIndexT = = TILE_STOP & & m_TileSFlagsT = = ROTATION_0 ) | | ( m_TileSIndexT = = TILE_STOPS & & ( m_TileSFlagsT = = ROTATION_0 | | m_TileSFlagsT = = ROTATION_180 ) ) | | ( m_TileSIndexT = = TILE_STOPA ) ) )
TempVel . y = 0 ;
m_Core . m_Vel = TempVel ;
}
2010-06-11 09:39:32 +00:00
}
2008-07-06 11:21:21 +00:00
}
2010-10-08 13:33:42 +00:00
void CCharacter : : HandleTiles ( int Index )
2011-01-29 00:59:50 +00:00
{
2010-10-08 13:33:42 +00:00
CGameControllerDDRace * Controller = ( CGameControllerDDRace * ) GameServer ( ) - > m_pController ;
int MapIndex = Index ;
2011-01-23 19:23:04 +00:00
//int PureMapIndex = GameServer()->Collision()->GetPureMapIndex(m_Pos);
2011-01-29 23:58:47 +00:00
float Offset = 4.0f ;
int MapIndexL = GameServer ( ) - > Collision ( ) - > GetPureMapIndex ( vec2 ( m_Pos . x + ( m_ProximityRadius / 2 ) + Offset , m_Pos . y ) ) ;
int MapIndexR = GameServer ( ) - > Collision ( ) - > GetPureMapIndex ( vec2 ( m_Pos . x - ( m_ProximityRadius / 2 ) - Offset , m_Pos . y ) ) ;
int MapIndexT = GameServer ( ) - > Collision ( ) - > GetPureMapIndex ( vec2 ( m_Pos . x , m_Pos . y + ( m_ProximityRadius / 2 ) + Offset ) ) ;
int MapIndexB = GameServer ( ) - > Collision ( ) - > GetPureMapIndex ( vec2 ( m_Pos . x , m_Pos . y - ( m_ProximityRadius / 2 ) - Offset ) ) ;
2010-10-08 13:33:42 +00:00
m_TileIndex = GameServer ( ) - > Collision ( ) - > GetTileIndex ( MapIndex ) ;
2010-11-01 01:51:17 +00:00
m_TileFlags = GameServer ( ) - > Collision ( ) - > GetTileFlags ( MapIndex ) ;
2010-10-08 13:33:42 +00:00
m_TileIndexL = GameServer ( ) - > Collision ( ) - > GetTileIndex ( MapIndexL ) ;
2010-11-01 01:51:17 +00:00
m_TileFlagsL = GameServer ( ) - > Collision ( ) - > GetTileFlags ( MapIndexL ) ;
2010-10-08 13:33:42 +00:00
m_TileIndexR = GameServer ( ) - > Collision ( ) - > GetTileIndex ( MapIndexR ) ;
2010-11-01 01:51:17 +00:00
m_TileFlagsR = GameServer ( ) - > Collision ( ) - > GetTileFlags ( MapIndexR ) ;
2010-10-08 13:33:42 +00:00
m_TileIndexB = GameServer ( ) - > Collision ( ) - > GetTileIndex ( MapIndexB ) ;
2010-11-01 01:51:17 +00:00
m_TileFlagsB = GameServer ( ) - > Collision ( ) - > GetTileFlags ( MapIndexB ) ;
2010-10-08 13:33:42 +00:00
m_TileIndexT = GameServer ( ) - > Collision ( ) - > GetTileIndex ( MapIndexT ) ;
2010-11-01 01:51:17 +00:00
m_TileFlagsT = GameServer ( ) - > Collision ( ) - > GetTileFlags ( MapIndexT ) ;
2010-10-08 13:33:42 +00:00
m_TileFIndex = GameServer ( ) - > Collision ( ) - > GetFTileIndex ( MapIndex ) ;
2010-11-01 01:51:17 +00:00
m_TileFFlags = GameServer ( ) - > Collision ( ) - > GetFTileFlags ( MapIndex ) ;
2010-10-08 13:33:42 +00:00
m_TileFIndexL = GameServer ( ) - > Collision ( ) - > GetFTileIndex ( MapIndexL ) ;
2010-11-01 01:51:17 +00:00
m_TileFFlagsL = GameServer ( ) - > Collision ( ) - > GetFTileFlags ( MapIndexL ) ;
2010-10-08 13:33:42 +00:00
m_TileFIndexR = GameServer ( ) - > Collision ( ) - > GetFTileIndex ( MapIndexR ) ;
2010-11-01 01:51:17 +00:00
m_TileFFlagsR = GameServer ( ) - > Collision ( ) - > GetFTileFlags ( MapIndexR ) ;
2010-10-08 13:33:42 +00:00
m_TileFIndexB = GameServer ( ) - > Collision ( ) - > GetFTileIndex ( MapIndexB ) ;
2010-11-01 01:51:17 +00:00
m_TileFFlagsB = GameServer ( ) - > Collision ( ) - > GetFTileFlags ( MapIndexB ) ;
2010-10-08 13:33:42 +00:00
m_TileFIndexT = GameServer ( ) - > Collision ( ) - > GetFTileIndex ( MapIndexT ) ;
2010-11-13 13:22:19 +00:00
m_TileFFlagsT = GameServer ( ) - > Collision ( ) - > GetFTileFlags ( MapIndexT ) ; //
2011-01-29 23:58:47 +00:00
m_TileSIndex = ( GameServer ( ) - > Collision ( ) - > m_pSwitchers & & GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetDTileNumber ( MapIndex ) ] . m_Status [ Team ( ) ] ) ? ( Team ( ) ! = TEAM_SUPER ) ? GameServer ( ) - > Collision ( ) - > GetDTileIndex ( MapIndex ) : 0 : 0 ;
m_TileSFlags = ( GameServer ( ) - > Collision ( ) - > m_pSwitchers & & GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetDTileNumber ( MapIndex ) ] . m_Status [ Team ( ) ] ) ? ( Team ( ) ! = TEAM_SUPER ) ? GameServer ( ) - > Collision ( ) - > GetDTileFlags ( MapIndex ) : 0 : 0 ;
m_TileSIndexL = ( GameServer ( ) - > Collision ( ) - > m_pSwitchers & & GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetDTileNumber ( MapIndexL ) ] . m_Status [ Team ( ) ] ) ? ( Team ( ) ! = TEAM_SUPER ) ? GameServer ( ) - > Collision ( ) - > GetDTileIndex ( MapIndexL ) : 0 : 0 ;
m_TileSFlagsL = ( GameServer ( ) - > Collision ( ) - > m_pSwitchers & & GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetDTileNumber ( MapIndexL ) ] . m_Status [ Team ( ) ] ) ? ( Team ( ) ! = TEAM_SUPER ) ? GameServer ( ) - > Collision ( ) - > GetDTileFlags ( MapIndexL ) : 0 : 0 ;
m_TileSIndexR = ( GameServer ( ) - > Collision ( ) - > m_pSwitchers & & GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetDTileNumber ( MapIndexR ) ] . m_Status [ Team ( ) ] ) ? ( Team ( ) ! = TEAM_SUPER ) ? GameServer ( ) - > Collision ( ) - > GetDTileIndex ( MapIndexR ) : 0 : 0 ;
m_TileSFlagsR = ( GameServer ( ) - > Collision ( ) - > m_pSwitchers & & GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetDTileNumber ( MapIndexR ) ] . m_Status [ Team ( ) ] ) ? ( Team ( ) ! = TEAM_SUPER ) ? GameServer ( ) - > Collision ( ) - > GetDTileFlags ( MapIndexR ) : 0 : 0 ;
m_TileSIndexB = ( GameServer ( ) - > Collision ( ) - > m_pSwitchers & & GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetDTileNumber ( MapIndexB ) ] . m_Status [ Team ( ) ] ) ? ( Team ( ) ! = TEAM_SUPER ) ? GameServer ( ) - > Collision ( ) - > GetDTileIndex ( MapIndexB ) : 0 : 0 ;
m_TileSFlagsB = ( GameServer ( ) - > Collision ( ) - > m_pSwitchers & & GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetDTileNumber ( MapIndexB ) ] . m_Status [ Team ( ) ] ) ? ( Team ( ) ! = TEAM_SUPER ) ? GameServer ( ) - > Collision ( ) - > GetDTileFlags ( MapIndexB ) : 0 : 0 ;
m_TileSIndexT = ( GameServer ( ) - > Collision ( ) - > m_pSwitchers & & GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetDTileNumber ( MapIndexT ) ] . m_Status [ Team ( ) ] ) ? ( Team ( ) ! = TEAM_SUPER ) ? GameServer ( ) - > Collision ( ) - > GetDTileIndex ( MapIndexT ) : 0 : 0 ;
m_TileSFlagsT = ( GameServer ( ) - > Collision ( ) - > m_pSwitchers & & GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetDTileNumber ( MapIndexT ) ] . m_Status [ Team ( ) ] ) ? ( Team ( ) ! = TEAM_SUPER ) ? GameServer ( ) - > Collision ( ) - > GetDTileFlags ( MapIndexT ) : 0 : 0 ;
2010-11-09 00:51:49 +00:00
//Sensitivity
2011-01-29 23:58:47 +00:00
int S1 = GameServer ( ) - > Collision ( ) - > GetPureMapIndex ( vec2 ( m_Pos . x + m_ProximityRadius / 3.f , m_Pos . y - m_ProximityRadius / 3.f ) ) ;
int S2 = GameServer ( ) - > Collision ( ) - > GetPureMapIndex ( vec2 ( m_Pos . x + m_ProximityRadius / 3.f , m_Pos . y + m_ProximityRadius / 3.f ) ) ;
int S3 = GameServer ( ) - > Collision ( ) - > GetPureMapIndex ( vec2 ( m_Pos . x - m_ProximityRadius / 3.f , m_Pos . y - m_ProximityRadius / 3.f ) ) ;
int S4 = GameServer ( ) - > Collision ( ) - > GetPureMapIndex ( vec2 ( m_Pos . x - m_ProximityRadius / 3.f , m_Pos . y + m_ProximityRadius / 3.f ) ) ;
2010-11-09 00:51:49 +00:00
int Tile1 = GameServer ( ) - > Collision ( ) - > GetTileIndex ( S1 ) ;
int Tile2 = GameServer ( ) - > Collision ( ) - > GetTileIndex ( S2 ) ;
int Tile3 = GameServer ( ) - > Collision ( ) - > GetTileIndex ( S3 ) ;
int Tile4 = GameServer ( ) - > Collision ( ) - > GetTileIndex ( S4 ) ;
int FTile1 = GameServer ( ) - > Collision ( ) - > GetFTileIndex ( S1 ) ;
int FTile2 = GameServer ( ) - > Collision ( ) - > GetFTileIndex ( S2 ) ;
int FTile3 = GameServer ( ) - > Collision ( ) - > GetFTileIndex ( S3 ) ;
int FTile4 = GameServer ( ) - > Collision ( ) - > GetFTileIndex ( S4 ) ;
2011-02-01 12:01:05 +00:00
if ( Index < 0 )
2014-02-09 22:31:29 +00:00
{
2014-12-29 14:54:55 +00:00
m_LastRefillJumps = false ;
2014-02-09 22:31:29 +00:00
m_LastPenalty = false ;
2015-03-10 21:57:40 +00:00
m_LastBonus = false ;
2011-02-01 12:01:05 +00:00
return ;
2014-02-09 22:31:29 +00:00
}
2010-10-08 13:33:42 +00:00
int cp = GameServer ( ) - > Collision ( ) - > IsCheckpoint ( MapIndex ) ;
2010-10-29 21:28:15 +00:00
if ( cp ! = - 1 & & m_DDRaceState = = DDRACE_STARTED & & cp > m_CpActive )
2010-10-08 13:33:42 +00:00
{
m_CpActive = cp ;
m_CpCurrent [ cp ] = m_Time ;
2011-01-29 23:58:47 +00:00
m_CpTick = Server ( ) - > Tick ( ) + Server ( ) - > TickSpeed ( ) * 2 ;
2014-01-30 15:49:15 +00:00
if ( m_pPlayer - > m_ClientVersion > = VERSION_DDRACE ) {
2010-11-30 02:24:15 +00:00
CPlayerData * pData = GameServer ( ) - > Score ( ) - > PlayerData ( m_pPlayer - > GetCID ( ) ) ;
CNetMsg_Sv_DDRaceTime Msg ;
Msg . m_Time = ( int ) m_Time ;
Msg . m_Check = 0 ;
Msg . m_Finish = 0 ;
if ( m_CpActive ! = - 1 & & m_CpTick > Server ( ) - > Tick ( ) )
{
if ( pData - > m_BestTime & & pData - > m_aBestCpTime [ m_CpActive ] ! = 0 )
{
float Diff = ( m_CpCurrent [ m_CpActive ] - pData - > m_aBestCpTime [ m_CpActive ] ) * 100 ;
Msg . m_Check = ( int ) Diff ;
}
}
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL , m_pPlayer - > GetCID ( ) ) ;
}
2010-10-08 13:33:42 +00:00
}
2010-10-30 18:48:30 +00:00
int cpf = GameServer ( ) - > Collision ( ) - > IsFCheckpoint ( MapIndex ) ;
if ( cpf ! = - 1 & & m_DDRaceState = = DDRACE_STARTED & & cpf > m_CpActive )
{
m_CpActive = cpf ;
m_CpCurrent [ cpf ] = m_Time ;
m_CpTick = Server ( ) - > Tick ( ) + Server ( ) - > TickSpeed ( ) * 2 ;
2014-01-30 15:49:15 +00:00
if ( m_pPlayer - > m_ClientVersion > = VERSION_DDRACE ) {
2010-11-30 02:24:15 +00:00
CPlayerData * pData = GameServer ( ) - > Score ( ) - > PlayerData ( m_pPlayer - > GetCID ( ) ) ;
CNetMsg_Sv_DDRaceTime Msg ;
Msg . m_Time = ( int ) m_Time ;
Msg . m_Check = 0 ;
Msg . m_Finish = 0 ;
if ( m_CpActive ! = - 1 & & m_CpTick > Server ( ) - > Tick ( ) )
{
if ( pData - > m_BestTime & & pData - > m_aBestCpTime [ m_CpActive ] ! = 0 )
{
float Diff = ( m_CpCurrent [ m_CpActive ] - pData - > m_aBestCpTime [ m_CpActive ] ) * 100 ;
Msg . m_Check = ( int ) Diff ;
}
}
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL , m_pPlayer - > GetCID ( ) ) ;
}
2010-10-30 18:48:30 +00:00
}
2011-05-17 23:12:39 +00:00
int tcp = GameServer ( ) - > Collision ( ) - > IsTCheckpoint ( MapIndex ) ;
if ( tcp )
m_TeleCheckpoint = tcp ;
2014-12-29 14:54:55 +00:00
// start
2016-05-21 19:51:38 +00:00
if ( ( ( m_TileIndex = = TILE_BEGIN ) | | ( m_TileFIndex = = TILE_BEGIN ) | | FTile1 = = TILE_BEGIN | | FTile2 = = TILE_BEGIN | | FTile3 = = TILE_BEGIN | | FTile4 = = TILE_BEGIN | | Tile1 = = TILE_BEGIN | | Tile2 = = TILE_BEGIN | | Tile3 = = TILE_BEGIN | | Tile4 = = TILE_BEGIN ) & & ( m_DDRaceState = = DDRACE_NONE | | m_DDRaceState = = DDRACE_FINISHED | | ( m_DDRaceState = = DDRACE_STARTED & & ! Team ( ) & & g_Config . m_SvTeam ! = 3 ) ) )
2010-10-08 13:33:42 +00:00
{
2010-11-06 22:54:35 +00:00
bool CanBegin = true ;
2014-09-23 15:33:33 +00:00
if ( g_Config . m_SvResetPickups )
2011-02-16 11:06:43 +00:00
{
for ( int i = WEAPON_SHOTGUN ; i < NUM_WEAPONS ; + + i )
{
m_aWeapons [ i ] . m_Got = false ;
2014-04-14 08:56:14 +00:00
if ( m_Core . m_ActiveWeapon = = i )
m_Core . m_ActiveWeapon = WEAPON_GUN ;
2011-02-16 11:06:43 +00:00
}
}
2011-02-14 21:34:46 +00:00
if ( g_Config . m_SvTeam = = 2 & & ( Team ( ) = = TEAM_FLOCK | | Teams ( ) - > Count ( Team ( ) ) < = 1 ) )
2011-01-29 14:31:50 +00:00
{
if ( m_LastStartWarning < Server ( ) - > Tick ( ) - 3 * Server ( ) - > TickSpeed ( ) )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " Server admin requires you to be in a team and with other tees to start " ) ;
m_LastStartWarning = Server ( ) - > Tick ( ) ;
}
2012-04-11 13:36:11 +00:00
Die ( GetPlayer ( ) - > GetCID ( ) , WEAPON_WORLD ) ;
2010-11-06 22:54:35 +00:00
CanBegin = false ;
}
2011-01-29 14:31:50 +00:00
if ( CanBegin )
{
2011-02-14 21:34:46 +00:00
Teams ( ) - > OnCharacterStart ( m_pPlayer - > GetCID ( ) ) ;
2010-11-06 22:54:35 +00:00
m_CpActive = - 2 ;
} else {
2011-04-09 06:41:31 +00:00
2010-11-06 22:54:35 +00:00
}
2011-04-09 06:41:31 +00:00
2013-08-23 23:03:45 +00:00
2010-10-08 13:33:42 +00:00
}
2013-08-23 23:03:45 +00:00
2014-12-29 14:54:55 +00:00
// finish
2010-11-09 00:51:49 +00:00
if ( ( ( m_TileIndex = = TILE_END ) | | ( m_TileFIndex = = TILE_END ) | | FTile1 = = TILE_END | | FTile2 = = TILE_END | | FTile3 = = TILE_END | | FTile4 = = TILE_END | | Tile1 = = TILE_END | | Tile2 = = TILE_END | | Tile3 = = TILE_END | | Tile4 = = TILE_END ) & & m_DDRaceState = = DDRACE_STARTED )
2010-10-08 13:33:42 +00:00
Controller - > m_Teams . OnCharacterFinish ( m_pPlayer - > GetCID ( ) ) ;
2014-12-29 14:54:55 +00:00
// freeze
2011-01-14 13:37:02 +00:00
if ( ( ( m_TileIndex = = TILE_FREEZE ) | | ( m_TileFIndex = = TILE_FREEZE ) ) & & ! m_Super & & ! m_DeepFreeze )
2011-01-25 09:34:14 +00:00
Freeze ( ) ;
2011-01-14 13:37:02 +00:00
else if ( ( ( m_TileIndex = = TILE_UNFREEZE ) | | ( m_TileFIndex = = TILE_UNFREEZE ) ) & & ! m_DeepFreeze )
2010-10-08 13:33:42 +00:00
UnFreeze ( ) ;
2014-12-29 14:54:55 +00:00
// deep freeze
2011-02-13 05:35:13 +00:00
if ( ( ( m_TileIndex = = TILE_DFREEZE ) | | ( m_TileFIndex = = TILE_DFREEZE ) ) & & ! m_Super & & ! m_DeepFreeze )
2011-01-14 13:37:02 +00:00
m_DeepFreeze = true ;
else if ( ( ( m_TileIndex = = TILE_DUNFREEZE ) | | ( m_TileFIndex = = TILE_DUNFREEZE ) ) & & ! m_Super & & m_DeepFreeze )
m_DeepFreeze = false ;
2014-12-29 14:54:55 +00:00
// endless hook
2011-01-29 23:58:47 +00:00
if ( ( ( m_TileIndex = = TILE_EHOOK_START ) | | ( m_TileFIndex = = TILE_EHOOK_START ) ) & & ! m_EndlessHook )
2011-01-16 22:13:21 +00:00
{
2011-09-02 18:04:18 +00:00
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " Endless hook has been activated " ) ;
2011-01-16 22:13:21 +00:00
m_EndlessHook = true ;
}
else if ( ( ( m_TileIndex = = TILE_EHOOK_END ) | | ( m_TileFIndex = = TILE_EHOOK_END ) ) & & m_EndlessHook )
{
2011-09-02 18:04:18 +00:00
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " Endless hook has been deactivated " ) ;
2011-01-16 22:13:21 +00:00
m_EndlessHook = false ;
}
2014-12-29 14:54:55 +00:00
// hit others
if ( ( ( m_TileIndex = = TILE_HIT_END ) | | ( m_TileFIndex = = TILE_HIT_END ) ) & & m_Hit ! = ( DISABLE_HIT_GRENADE | DISABLE_HIT_HAMMER | DISABLE_HIT_RIFLE | DISABLE_HIT_SHOTGUN ) )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can't hit others " ) ;
m_Hit = DISABLE_HIT_GRENADE | DISABLE_HIT_HAMMER | DISABLE_HIT_RIFLE | DISABLE_HIT_SHOTGUN ;
2016-04-20 09:59:14 +00:00
m_NeededFaketuning | = FAKETUNE_NOHAMMER ;
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ; // update tunings
2014-12-29 14:54:55 +00:00
}
else if ( ( ( m_TileIndex = = TILE_HIT_START ) | | ( m_TileFIndex = = TILE_HIT_START ) ) & & m_Hit ! = HIT_ALL )
2011-07-19 21:33:12 +00:00
{
2011-09-02 18:04:18 +00:00
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can hit others " ) ;
2011-07-25 20:16:20 +00:00
m_Hit = HIT_ALL ;
2016-04-20 09:59:14 +00:00
m_NeededFaketuning & = ~ FAKETUNE_NOHAMMER ;
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ; // update tunings
2011-07-19 21:33:12 +00:00
}
2014-12-29 14:54:55 +00:00
// collide with others
if ( ( ( m_TileIndex = = TILE_NPC_END ) | | ( m_TileFIndex = = TILE_NPC_END ) ) & & m_Core . m_Collision )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can't collide with others " ) ;
m_Core . m_Collision = false ;
m_NeededFaketuning | = FAKETUNE_NOCOLL ;
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ; // update tunings
}
2013-08-05 15:47:04 +00:00
else if ( ( ( m_TileIndex = = TILE_NPC_START ) | | ( m_TileFIndex = = TILE_NPC_START ) ) & & ! m_Core . m_Collision )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can collide with others " ) ;
m_Core . m_Collision = true ;
2014-04-06 10:22:27 +00:00
m_NeededFaketuning & = ~ FAKETUNE_NOCOLL ;
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ; // update tunings
2013-08-05 15:47:04 +00:00
}
2014-12-29 14:54:55 +00:00
// hook others
if ( ( ( m_TileIndex = = TILE_NPH_END ) | | ( m_TileFIndex = = TILE_NPH_END ) ) & & m_Core . m_Hook )
2013-11-22 14:10:55 +00:00
{
2014-12-29 14:54:55 +00:00
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can't hook others " ) ;
m_Core . m_Hook = false ;
m_NeededFaketuning | = FAKETUNE_NOHOOK ;
2014-04-13 23:34:50 +00:00
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ; // update tunings
2013-11-22 14:10:55 +00:00
}
2013-08-05 15:47:04 +00:00
else if ( ( ( m_TileIndex = = TILE_NPH_START ) | | ( m_TileFIndex = = TILE_NPH_START ) ) & & ! m_Core . m_Hook )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can hook others " ) ;
m_Core . m_Hook = true ;
2014-04-06 10:22:27 +00:00
m_NeededFaketuning & = ~ FAKETUNE_NOHOOK ;
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ; // update tunings
2013-08-05 15:47:04 +00:00
}
2014-12-29 14:54:55 +00:00
// unlimited air jumps
if ( ( ( m_TileIndex = = TILE_SUPER_START ) | | ( m_TileFIndex = = TILE_SUPER_START ) ) & & ! m_SuperJump )
2013-08-05 15:47:04 +00:00
{
2014-12-29 14:54:55 +00:00
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You have unlimited air jumps " ) ;
m_SuperJump = true ;
if ( m_Core . m_Jumps = = 0 )
{
m_NeededFaketuning & = ~ FAKETUNE_NOJUMP ;
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ; // update tunings
}
2013-08-05 15:47:04 +00:00
}
else if ( ( ( m_TileIndex = = TILE_SUPER_END ) | | ( m_TileFIndex = = TILE_SUPER_END ) ) & & m_SuperJump )
{
2014-09-27 17:10:15 +00:00
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You don't have unlimited air jumps " ) ;
2013-08-05 15:47:04 +00:00
m_SuperJump = false ;
2014-03-01 13:29:14 +00:00
if ( m_Core . m_Jumps = = 0 )
{
m_NeededFaketuning | = FAKETUNE_NOJUMP ;
2014-03-24 20:03:55 +00:00
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ; // update tunings
2014-03-01 13:29:14 +00:00
}
2013-08-05 15:47:04 +00:00
}
2014-12-29 14:54:55 +00:00
// walljump
if ( ( m_TileIndex = = TILE_WALLJUMP ) | | ( m_TileFIndex = = TILE_WALLJUMP ) )
2014-06-21 22:50:11 +00:00
{
2014-06-24 21:47:33 +00:00
if ( m_Core . m_Vel . y > 0 & & m_Core . m_Colliding & & m_Core . m_LeftWall )
2014-06-21 22:50:11 +00:00
{
2014-06-23 12:46:27 +00:00
m_Core . m_LeftWall = false ;
2014-06-24 21:47:33 +00:00
m_Core . m_JumpedTotal = m_Core . m_Jumps - 1 ;
2014-06-21 22:50:11 +00:00
m_Core . m_Jumped = 1 ;
}
}
2014-12-29 14:54:55 +00:00
// jetpack gun
if ( ( ( m_TileIndex = = TILE_JETPACK_START ) | | ( m_TileFIndex = = TILE_JETPACK_START ) ) & & ! m_Jetpack )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You have a jetpack gun " ) ;
m_Jetpack = true ;
}
2013-11-22 14:10:55 +00:00
else if ( ( ( m_TileIndex = = TILE_JETPACK_END ) | | ( m_TileFIndex = = TILE_JETPACK_END ) ) & & m_Jetpack )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You lost your jetpack gun " ) ;
m_Jetpack = false ;
}
2014-12-29 14:54:55 +00:00
2016-03-07 17:04:59 +00:00
// unlock team
2016-06-30 15:55:34 +00:00
else if ( ( ( m_TileIndex = = TILE_UNLOCK_TEAM ) | | ( m_TileFIndex = = TILE_UNLOCK_TEAM ) ) & & Teams ( ) - > TeamLocked ( Team ( ) ) )
2016-03-07 17:04:59 +00:00
{
Teams ( ) - > SetTeamLock ( Team ( ) , false ) ;
2016-06-30 15:55:34 +00:00
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
if ( Teams ( ) - > m_Core . Team ( i ) = = Team ( ) )
2016-07-03 21:23:33 +00:00
GameServer ( ) - > SendChatTarget ( i , " Your team was unlocked by an unlock team tile " ) ;
2016-03-07 17:04:59 +00:00
}
2014-12-29 14:54:55 +00:00
// solo part
2011-09-02 18:04:18 +00:00
if ( ( ( m_TileIndex = = TILE_SOLO_START ) | | ( m_TileFIndex = = TILE_SOLO_START ) ) & & ! Teams ( ) - > m_Core . GetSolo ( m_pPlayer - > GetCID ( ) ) )
{
2016-07-03 21:23:33 +00:00
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You are now in a solo part " ) ;
2014-12-25 10:37:44 +00:00
SetSolo ( true ) ;
2011-09-02 18:04:18 +00:00
}
else if ( ( ( m_TileIndex = = TILE_SOLO_END ) | | ( m_TileFIndex = = TILE_SOLO_END ) ) & & Teams ( ) - > m_Core . GetSolo ( m_pPlayer - > GetCID ( ) ) )
{
2016-07-03 21:23:33 +00:00
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You are now out of the solo part " ) ;
2014-12-25 10:37:44 +00:00
SetSolo ( false ) ;
2011-09-02 18:04:18 +00:00
}
2014-12-29 14:54:55 +00:00
// refill jumps
if ( ( ( m_TileIndex = = TILE_REFILL_JUMPS ) | | ( m_TileFIndex = = TILE_REFILL_JUMPS ) ) & & ! m_LastRefillJumps )
{
m_Core . m_JumpedTotal = 0 ;
2015-03-22 17:27:57 +00:00
m_Core . m_Jumped = 0 ;
2014-12-29 14:54:55 +00:00
m_LastRefillJumps = true ;
}
if ( ( m_TileIndex ! = TILE_REFILL_JUMPS ) & & ( m_TileFIndex ! = TILE_REFILL_JUMPS ) )
{
m_LastRefillJumps = false ;
}
// stopper
2011-02-07 02:22:13 +00:00
if ( ( ( m_TileIndex = = TILE_STOP & & m_TileFlags = = ROTATION_270 ) | | ( m_TileIndexL = = TILE_STOP & & m_TileFlagsL = = ROTATION_270 ) | | ( m_TileIndexL = = TILE_STOPS & & ( m_TileFlagsL = = ROTATION_90 | | m_TileFlagsL = = ROTATION_270 ) ) | | ( m_TileIndexL = = TILE_STOPA ) | | ( m_TileFIndex = = TILE_STOP & & m_TileFFlags = = ROTATION_270 ) | | ( m_TileFIndexL = = TILE_STOP & & m_TileFFlagsL = = ROTATION_270 ) | | ( m_TileFIndexL = = TILE_STOPS & & ( m_TileFFlagsL = = ROTATION_90 | | m_TileFFlagsL = = ROTATION_270 ) ) | | ( m_TileFIndexL = = TILE_STOPA ) | | ( m_TileSIndex = = TILE_STOP & & m_TileSFlags = = ROTATION_270 ) | | ( m_TileSIndexL = = TILE_STOP & & m_TileSFlagsL = = ROTATION_270 ) | | ( m_TileSIndexL = = TILE_STOPS & & ( m_TileSFlagsL = = ROTATION_90 | | m_TileSFlagsL = = ROTATION_270 ) ) | | ( m_TileSIndexL = = TILE_STOPA ) ) & & m_Core . m_Vel . x > 0 )
2010-10-08 13:33:42 +00:00
{
2014-12-29 19:06:00 +00:00
if ( ( int ) GameServer ( ) - > Collision ( ) - > GetPos ( MapIndexL ) . x )
2011-02-07 02:22:13 +00:00
if ( ( int ) GameServer ( ) - > Collision ( ) - > GetPos ( MapIndexL ) . x < ( int ) m_Core . m_Pos . x )
2011-02-06 18:38:24 +00:00
m_Core . m_Pos = m_PrevPos ;
2011-02-07 02:22:13 +00:00
m_Core . m_Vel . x = 0 ;
2010-10-08 13:33:42 +00:00
}
2011-02-07 02:22:13 +00:00
if ( ( ( m_TileIndex = = TILE_STOP & & m_TileFlags = = ROTATION_90 ) | | ( m_TileIndexR = = TILE_STOP & & m_TileFlagsR = = ROTATION_90 ) | | ( m_TileIndexR = = TILE_STOPS & & ( m_TileFlagsR = = ROTATION_90 | | m_TileFlagsR = = ROTATION_270 ) ) | | ( m_TileIndexR = = TILE_STOPA ) | | ( m_TileFIndex = = TILE_STOP & & m_TileFFlags = = ROTATION_90 ) | | ( m_TileFIndexR = = TILE_STOP & & m_TileFFlagsR = = ROTATION_90 ) | | ( m_TileFIndexR = = TILE_STOPS & & ( m_TileFFlagsR = = ROTATION_90 | | m_TileFFlagsR = = ROTATION_270 ) ) | | ( m_TileFIndexR = = TILE_STOPA ) | | ( m_TileSIndex = = TILE_STOP & & m_TileSFlags = = ROTATION_90 ) | | ( m_TileSIndexR = = TILE_STOP & & m_TileSFlagsR = = ROTATION_90 ) | | ( m_TileSIndexR = = TILE_STOPS & & ( m_TileSFlagsR = = ROTATION_90 | | m_TileSFlagsR = = ROTATION_270 ) ) | | ( m_TileSIndexR = = TILE_STOPA ) ) & & m_Core . m_Vel . x < 0 )
2010-10-08 13:33:42 +00:00
{
2011-02-07 02:22:13 +00:00
if ( ( int ) GameServer ( ) - > Collision ( ) - > GetPos ( MapIndexR ) . x )
if ( ( int ) GameServer ( ) - > Collision ( ) - > GetPos ( MapIndexR ) . x > ( int ) m_Core . m_Pos . x )
2011-02-06 18:38:24 +00:00
m_Core . m_Pos = m_PrevPos ;
2011-02-07 02:22:13 +00:00
m_Core . m_Vel . x = 0 ;
2010-10-08 13:33:42 +00:00
}
2011-02-07 02:22:13 +00:00
if ( ( ( m_TileIndex = = TILE_STOP & & m_TileFlags = = ROTATION_180 ) | | ( m_TileIndexB = = TILE_STOP & & m_TileFlagsB = = ROTATION_180 ) | | ( m_TileIndexB = = TILE_STOPS & & ( m_TileFlagsB = = ROTATION_0 | | m_TileFlagsB = = ROTATION_180 ) ) | | ( m_TileIndexB = = TILE_STOPA ) | | ( m_TileFIndex = = TILE_STOP & & m_TileFFlags = = ROTATION_180 ) | | ( m_TileFIndexB = = TILE_STOP & & m_TileFFlagsB = = ROTATION_180 ) | | ( m_TileFIndexB = = TILE_STOPS & & ( m_TileFFlagsB = = ROTATION_0 | | m_TileFFlagsB = = ROTATION_180 ) ) | | ( m_TileFIndexB = = TILE_STOPA ) | | ( m_TileSIndex = = TILE_STOP & & m_TileSFlags = = ROTATION_180 ) | | ( m_TileSIndexB = = TILE_STOP & & m_TileSFlagsB = = ROTATION_180 ) | | ( m_TileSIndexB = = TILE_STOPS & & ( m_TileSFlagsB = = ROTATION_0 | | m_TileSFlagsB = = ROTATION_180 ) ) | | ( m_TileSIndexB = = TILE_STOPA ) ) & & m_Core . m_Vel . y < 0 )
2010-10-08 13:33:42 +00:00
{
2011-02-07 02:22:13 +00:00
if ( ( int ) GameServer ( ) - > Collision ( ) - > GetPos ( MapIndexB ) . y )
if ( ( int ) GameServer ( ) - > Collision ( ) - > GetPos ( MapIndexB ) . y > ( int ) m_Core . m_Pos . y )
2011-02-06 18:38:24 +00:00
m_Core . m_Pos = m_PrevPos ;
2011-02-07 02:22:13 +00:00
m_Core . m_Vel . y = 0 ;
2010-10-08 13:33:42 +00:00
}
2011-02-07 02:22:13 +00:00
if ( ( ( m_TileIndex = = TILE_STOP & & m_TileFlags = = ROTATION_0 ) | | ( m_TileIndexT = = TILE_STOP & & m_TileFlagsT = = ROTATION_0 ) | | ( m_TileIndexT = = TILE_STOPS & & ( m_TileFlagsT = = ROTATION_0 | | m_TileFlagsT = = ROTATION_180 ) ) | | ( m_TileIndexT = = TILE_STOPA ) | | ( m_TileFIndex = = TILE_STOP & & m_TileFFlags = = ROTATION_0 ) | | ( m_TileFIndexT = = TILE_STOP & & m_TileFFlagsT = = ROTATION_0 ) | | ( m_TileFIndexT = = TILE_STOPS & & ( m_TileFFlagsT = = ROTATION_0 | | m_TileFFlagsT = = ROTATION_180 ) ) | | ( m_TileFIndexT = = TILE_STOPA ) | | ( m_TileSIndex = = TILE_STOP & & m_TileSFlags = = ROTATION_0 ) | | ( m_TileSIndexT = = TILE_STOP & & m_TileSFlagsT = = ROTATION_0 ) | | ( m_TileSIndexT = = TILE_STOPS & & ( m_TileSFlagsT = = ROTATION_0 | | m_TileSFlagsT = = ROTATION_180 ) ) | | ( m_TileSIndexT = = TILE_STOPA ) ) & & m_Core . m_Vel . y > 0 )
2010-10-08 13:33:42 +00:00
{
2011-02-07 02:22:13 +00:00
if ( ( int ) GameServer ( ) - > Collision ( ) - > GetPos ( MapIndexT ) . y )
if ( ( int ) GameServer ( ) - > Collision ( ) - > GetPos ( MapIndexT ) . y < ( int ) m_Core . m_Pos . y )
2011-02-06 18:38:24 +00:00
m_Core . m_Pos = m_PrevPos ;
2011-02-07 02:22:13 +00:00
m_Core . m_Vel . y = 0 ;
2010-10-08 13:33:42 +00:00
m_Core . m_Jumped = 0 ;
2013-08-23 23:03:45 +00:00
m_Core . m_JumpedTotal = 0 ;
2010-10-08 13:33:42 +00:00
}
2013-08-23 23:03:45 +00:00
2010-11-13 13:22:19 +00:00
// handle switch tiles
2010-11-14 11:14:18 +00:00
if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_SWITCHOPEN & & Team ( ) ! = TEAM_SUPER )
2010-11-22 20:43:22 +00:00
{
GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_Status [ Team ( ) ] = true ;
GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_EndTick [ Team ( ) ] = 0 ;
GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_Type [ Team ( ) ] = TILE_SWITCHOPEN ;
}
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_SWITCHTIMEDOPEN & & Team ( ) ! = TEAM_SUPER )
{
GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_Status [ Team ( ) ] = true ;
GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_EndTick [ Team ( ) ] = Server ( ) - > Tick ( ) + 1 + GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) * Server ( ) - > TickSpeed ( ) ;
GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_Type [ Team ( ) ] = TILE_SWITCHTIMEDOPEN ;
}
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_SWITCHTIMEDCLOSE & & Team ( ) ! = TEAM_SUPER )
{
GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_Status [ Team ( ) ] = false ;
GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_EndTick [ Team ( ) ] = Server ( ) - > Tick ( ) + 1 + GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) * Server ( ) - > TickSpeed ( ) ;
GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_Type [ Team ( ) ] = TILE_SWITCHTIMEDCLOSE ;
}
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_SWITCHCLOSE & & Team ( ) ! = TEAM_SUPER )
{
GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_Status [ Team ( ) ] = false ;
GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_EndTick [ Team ( ) ] = 0 ;
GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_Type [ Team ( ) ] = TILE_SWITCHCLOSE ;
}
2011-01-25 09:34:14 +00:00
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_FREEZE & & Team ( ) ! = TEAM_SUPER )
{
2015-05-31 16:21:12 +00:00
if ( GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) = = 0 | | GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_Status [ Team ( ) ] )
Freeze ( GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) ) ;
2011-01-25 09:34:14 +00:00
}
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_DFREEZE & & Team ( ) ! = TEAM_SUPER & & GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_Status [ Team ( ) ] )
{
m_DeepFreeze = true ;
}
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_DUNFREEZE & & Team ( ) ! = TEAM_SUPER & & GameServer ( ) - > Collision ( ) - > m_pSwitchers [ GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ] . m_Status [ Team ( ) ] )
{
m_DeepFreeze = false ;
}
2011-07-25 20:16:20 +00:00
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_HIT_START & & m_Hit & DISABLE_HIT_HAMMER & & GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) = = WEAPON_HAMMER )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can hammer hit others " ) ;
2014-04-06 10:22:27 +00:00
m_Hit & = ~ DISABLE_HIT_HAMMER ;
2016-04-20 09:59:14 +00:00
m_NeededFaketuning & = ~ FAKETUNE_NOHAMMER ;
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ; // update tunings
2011-07-25 20:16:20 +00:00
}
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_HIT_END & & ! ( m_Hit & DISABLE_HIT_HAMMER ) & & GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) = = WEAPON_HAMMER )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can't hammer hit others " ) ;
m_Hit | = DISABLE_HIT_HAMMER ;
2016-04-20 09:59:14 +00:00
m_NeededFaketuning | = FAKETUNE_NOHAMMER ;
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ; // update tunings
2011-07-25 20:16:20 +00:00
}
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_HIT_START & & m_Hit & DISABLE_HIT_SHOTGUN & & GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) = = WEAPON_SHOTGUN )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can shoot others with shotgun " ) ;
2014-04-06 10:22:27 +00:00
m_Hit & = ~ DISABLE_HIT_SHOTGUN ;
2011-07-25 20:16:20 +00:00
}
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_HIT_END & & ! ( m_Hit & DISABLE_HIT_SHOTGUN ) & & GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) = = WEAPON_SHOTGUN )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can't shoot others with shotgun " ) ;
m_Hit | = DISABLE_HIT_SHOTGUN ;
}
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_HIT_START & & m_Hit & DISABLE_HIT_GRENADE & & GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) = = WEAPON_GRENADE )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can shoot others with grenade " ) ;
2014-04-06 10:22:27 +00:00
m_Hit & = ~ DISABLE_HIT_GRENADE ;
2011-07-25 20:16:20 +00:00
}
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_HIT_END & & ! ( m_Hit & DISABLE_HIT_GRENADE ) & & GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) = = WEAPON_GRENADE )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can't shoot others with grenade " ) ;
m_Hit | = DISABLE_HIT_GRENADE ;
}
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_HIT_START & & m_Hit & DISABLE_HIT_RIFLE & & GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) = = WEAPON_RIFLE )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can shoot others with rifle " ) ;
2014-04-06 10:22:27 +00:00
m_Hit & = ~ DISABLE_HIT_RIFLE ;
2011-07-25 20:16:20 +00:00
}
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_HIT_END & & ! ( m_Hit & DISABLE_HIT_RIFLE ) & & GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) = = WEAPON_RIFLE )
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " You can't shoot others with rifle " ) ;
m_Hit | = DISABLE_HIT_RIFLE ;
}
2013-08-23 23:03:45 +00:00
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_JUMP )
{
int newJumps = GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) ;
if ( newJumps ! = m_Core . m_Jumps )
{
char aBuf [ 256 ] ;
2014-06-24 21:32:29 +00:00
if ( newJumps = = 1 )
str_format ( aBuf , sizeof ( aBuf ) , " You can jump %d time " , newJumps ) ;
else
str_format ( aBuf , sizeof ( aBuf ) , " You can jump %d times " , newJumps ) ;
2013-08-23 23:03:45 +00:00
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , aBuf ) ;
2014-03-01 13:29:14 +00:00
if ( newJumps = = 0 & & ! m_SuperJump )
2014-04-06 10:22:27 +00:00
{
2014-03-01 13:29:14 +00:00
m_NeededFaketuning | = FAKETUNE_NOJUMP ;
2014-04-06 10:22:27 +00:00
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ; // update tunings
}
else if ( m_Core . m_Jumps = = 0 )
{
m_NeededFaketuning & = ~ FAKETUNE_NOJUMP ;
GameServer ( ) - > SendTuningParams ( m_pPlayer - > GetCID ( ) , m_TuneZone ) ; // update tunings
}
m_Core . m_Jumps = newJumps ;
2013-08-23 23:03:45 +00:00
}
}
2014-02-09 22:31:29 +00:00
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_PENALTY & & ! m_LastPenalty )
{
int min = GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) ;
int sec = GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ;
2014-02-09 23:17:00 +00:00
int Team = Teams ( ) - > m_Core . Team ( m_Core . m_Id ) ;
2014-02-09 22:31:29 +00:00
m_StartTime - = ( min * 60 + sec ) * Server ( ) - > TickSpeed ( ) ;
2014-02-09 23:17:00 +00:00
if ( Team ! = TEAM_FLOCK & & Team ! = TEAM_SUPER )
{
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
{
2014-05-18 23:57:52 +00:00
if ( Teams ( ) - > m_Core . Team ( i ) = = Team & & i ! = m_Core . m_Id & & GameServer ( ) - > m_apPlayers [ i ] )
2014-02-09 23:17:00 +00:00
{
CCharacter * pChar = GameServer ( ) - > m_apPlayers [ i ] - > GetCharacter ( ) ;
if ( pChar )
pChar - > m_StartTime = m_StartTime ;
}
}
}
2014-02-09 22:31:29 +00:00
m_LastPenalty = true ;
}
2015-03-10 21:57:40 +00:00
else if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) = = TILE_BONUS & & ! m_LastBonus )
{
int min = GameServer ( ) - > Collision ( ) - > GetSwitchDelay ( MapIndex ) ;
int sec = GameServer ( ) - > Collision ( ) - > GetSwitchNumber ( MapIndex ) ;
int Team = Teams ( ) - > m_Core . Team ( m_Core . m_Id ) ;
m_StartTime + = ( min * 60 + sec ) * Server ( ) - > TickSpeed ( ) ;
if ( m_StartTime > Server ( ) - > Tick ( ) )
m_StartTime = Server ( ) - > Tick ( ) ;
if ( Team ! = TEAM_FLOCK & & Team ! = TEAM_SUPER )
{
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
{
if ( Teams ( ) - > m_Core . Team ( i ) = = Team & & i ! = m_Core . m_Id & & GameServer ( ) - > m_apPlayers [ i ] )
{
CCharacter * pChar = GameServer ( ) - > m_apPlayers [ i ] - > GetCharacter ( ) ;
if ( pChar )
pChar - > m_StartTime = m_StartTime ;
}
}
}
m_LastBonus = true ;
}
2014-02-09 22:31:29 +00:00
if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) ! = TILE_PENALTY )
{
m_LastPenalty = false ;
}
2013-08-23 23:03:45 +00:00
2015-03-10 21:57:40 +00:00
if ( GameServer ( ) - > Collision ( ) - > IsSwitch ( MapIndex ) ! = TILE_BONUS )
{
m_LastBonus = false ;
}
2010-10-08 13:33:42 +00:00
int z = GameServer ( ) - > Collision ( ) - > IsTeleport ( MapIndex ) ;
2013-08-13 02:59:25 +00:00
if ( ! g_Config . m_SvOldTeleportHook & & ! g_Config . m_SvOldTeleportWeapons & & z & & Controller - > m_TeleOuts [ z - 1 ] . size ( ) )
2010-10-08 13:33:42 +00:00
{
2014-01-13 16:00:49 +00:00
if ( m_Super )
return ;
2011-09-02 22:55:15 +00:00
int Num = Controller - > m_TeleOuts [ z - 1 ] . size ( ) ;
m_Core . m_Pos = Controller - > m_TeleOuts [ z - 1 ] [ ( ! Num ) ? Num : rand ( ) % Num ] ;
2014-04-04 22:35:18 +00:00
if ( ! g_Config . m_SvTeleportHoldHook )
{
m_Core . m_HookedPlayer = - 1 ;
m_Core . m_HookState = HOOK_RETRACTED ;
m_Core . m_TriggeredEvents | = COREEVENT_HOOK_RETRACT ;
m_Core . m_HookPos = m_Core . m_Pos ;
}
2015-08-22 17:24:10 +00:00
if ( g_Config . m_SvTeleportLoseWeapons )
{
2015-08-22 18:25:28 +00:00
for ( int i = WEAPON_SHOTGUN ; i < NUM_WEAPONS - 1 ; i + + )
2015-08-22 17:24:10 +00:00
m_aWeapons [ i ] . m_Got = false ;
}
2010-10-10 23:46:13 +00:00
return ;
2010-10-08 13:33:42 +00:00
}
int evilz = GameServer ( ) - > Collision ( ) - > IsEvilTeleport ( MapIndex ) ;
2014-01-13 16:00:49 +00:00
if ( evilz & & Controller - > m_TeleOuts [ evilz - 1 ] . size ( ) )
2010-10-08 13:33:42 +00:00
{
2014-01-13 16:00:49 +00:00
if ( m_Super )
return ;
2013-07-22 16:03:32 +00:00
int Num = Controller - > m_TeleOuts [ evilz - 1 ] . size ( ) ;
m_Core . m_Pos = Controller - > m_TeleOuts [ evilz - 1 ] [ ( ! Num ) ? Num : rand ( ) % Num ] ;
2013-08-13 02:59:25 +00:00
if ( ! g_Config . m_SvOldTeleportHook & & ! g_Config . m_SvOldTeleportWeapons )
2013-07-22 15:37:14 +00:00
{
m_Core . m_Vel = vec2 ( 0 , 0 ) ;
2014-04-04 22:35:18 +00:00
if ( ! g_Config . m_SvTeleportHoldHook )
{
m_Core . m_HookedPlayer = - 1 ;
m_Core . m_HookState = HOOK_RETRACTED ;
m_Core . m_TriggeredEvents | = COREEVENT_HOOK_RETRACT ;
GameWorld ( ) - > ReleaseHooked ( GetPlayer ( ) - > GetCID ( ) ) ;
m_Core . m_HookPos = m_Core . m_Pos ;
}
2015-08-22 17:24:10 +00:00
if ( g_Config . m_SvTeleportLoseWeapons )
{
2015-08-22 18:15:15 +00:00
for ( int i = WEAPON_SHOTGUN ; i < NUM_WEAPONS - 1 ; i + + )
2015-08-22 17:24:10 +00:00
m_aWeapons [ i ] . m_Got = false ;
}
2013-07-22 15:37:14 +00:00
}
2010-10-10 23:46:13 +00:00
return ;
2010-10-08 13:33:42 +00:00
}
2014-02-01 21:20:41 +00:00
if ( GameServer ( ) - > Collision ( ) - > IsCheckEvilTeleport ( MapIndex ) )
{
if ( m_Super )
return ;
// first check if there is a TeleCheckOut for the current recorded checkpoint, if not check previous checkpoints
for ( int k = m_TeleCheckpoint - 1 ; k > = 0 ; k - - )
{
if ( Controller - > m_TeleCheckOuts [ k ] . size ( ) )
{
int Num = Controller - > m_TeleCheckOuts [ k ] . size ( ) ;
m_Core . m_Pos = Controller - > m_TeleCheckOuts [ k ] [ ( ! Num ) ? Num : rand ( ) % Num ] ;
m_Core . m_Vel = vec2 ( 0 , 0 ) ;
2017-06-15 13:49:07 +00:00
2017-06-15 14:07:27 +00:00
if ( ! g_Config . m_SvTeleportHoldHook )
2017-06-15 13:49:07 +00:00
{
m_Core . m_HookedPlayer = - 1 ;
m_Core . m_HookState = HOOK_RETRACTED ;
m_Core . m_TriggeredEvents | = COREEVENT_HOOK_RETRACT ;
GameWorld ( ) - > ReleaseHooked ( GetPlayer ( ) - > GetCID ( ) ) ;
m_Core . m_HookPos = m_Core . m_Pos ;
}
2014-02-01 21:20:41 +00:00
return ;
}
}
// if no checkpointout have been found (or if there no recorded checkpoint), teleport to start
vec2 SpawnPos ;
if ( GameServer ( ) - > m_pController - > CanSpawn ( m_pPlayer - > GetTeam ( ) , & SpawnPos ) )
{
m_Core . m_Pos = SpawnPos ;
m_Core . m_Vel = vec2 ( 0 , 0 ) ;
2017-06-15 13:49:07 +00:00
2017-06-15 14:07:27 +00:00
if ( ! g_Config . m_SvTeleportHoldHook )
2017-06-15 13:49:07 +00:00
{
m_Core . m_HookedPlayer = - 1 ;
m_Core . m_HookState = HOOK_RETRACTED ;
m_Core . m_TriggeredEvents | = COREEVENT_HOOK_RETRACT ;
GameWorld ( ) - > ReleaseHooked ( GetPlayer ( ) - > GetCID ( ) ) ;
m_Core . m_HookPos = m_Core . m_Pos ;
}
2014-02-01 21:20:41 +00:00
}
return ;
}
2011-05-17 23:12:39 +00:00
if ( GameServer ( ) - > Collision ( ) - > IsCheckTeleport ( MapIndex ) )
{
2014-01-13 16:00:49 +00:00
if ( m_Super )
return ;
2011-09-02 22:42:01 +00:00
// first check if there is a TeleCheckOut for the current recorded checkpoint, if not check previous checkpoints
for ( int k = m_TeleCheckpoint - 1 ; k > = 0 ; k - - )
2011-05-17 23:12:39 +00:00
{
2011-09-02 22:42:01 +00:00
if ( Controller - > m_TeleCheckOuts [ k ] . size ( ) )
{
int Num = Controller - > m_TeleCheckOuts [ k ] . size ( ) ;
m_Core . m_Pos = Controller - > m_TeleCheckOuts [ k ] [ ( ! Num ) ? Num : rand ( ) % Num ] ;
2017-06-15 13:49:07 +00:00
2017-06-15 14:07:27 +00:00
if ( ! g_Config . m_SvTeleportHoldHook )
2017-06-15 13:49:07 +00:00
{
m_Core . m_HookedPlayer = - 1 ;
m_Core . m_HookState = HOOK_RETRACTED ;
m_Core . m_TriggeredEvents | = COREEVENT_HOOK_RETRACT ;
m_Core . m_HookPos = m_Core . m_Pos ;
}
2011-09-02 22:42:01 +00:00
return ;
}
2011-05-17 23:12:39 +00:00
}
2011-09-02 22:42:01 +00:00
// if no checkpointout have been found (or if there no recorded checkpoint), teleport to start
2011-05-17 23:12:39 +00:00
vec2 SpawnPos ;
if ( GameServer ( ) - > m_pController - > CanSpawn ( m_pPlayer - > GetTeam ( ) , & SpawnPos ) )
{
m_Core . m_Pos = SpawnPos ;
2017-06-15 13:49:07 +00:00
2017-06-15 14:07:27 +00:00
if ( ! g_Config . m_SvTeleportHoldHook )
2017-06-15 13:49:07 +00:00
{
m_Core . m_HookedPlayer = - 1 ;
m_Core . m_HookState = HOOK_RETRACTED ;
m_Core . m_TriggeredEvents | = COREEVENT_HOOK_RETRACT ;
m_Core . m_HookPos = m_Core . m_Pos ;
}
2011-05-17 23:12:39 +00:00
}
2011-09-02 22:42:01 +00:00
return ;
2011-05-17 23:12:39 +00:00
}
2010-10-08 13:33:42 +00:00
}
2014-03-12 23:49:07 +00:00
void CCharacter : : HandleTuneLayer ( )
{
2015-07-09 00:08:14 +00:00
2014-04-13 14:49:58 +00:00
m_TuneZoneOld = m_TuneZone ;
2014-03-12 23:49:07 +00:00
int CurrentIndex = GameServer ( ) - > Collision ( ) - > GetMapIndex ( m_Pos ) ;
m_TuneZone = GameServer ( ) - > Collision ( ) - > IsTune ( CurrentIndex ) ;
2014-04-13 14:49:58 +00:00
if ( m_TuneZone )
2014-04-29 01:34:23 +00:00
m_Core . m_pWorld - > m_Tuning [ g_Config . m_ClDummy ] = GameServer ( ) - > TuningList ( ) [ m_TuneZone ] ; // throw tunings from specific zone into gamecore
2014-03-12 23:49:07 +00:00
else
2014-04-29 01:34:23 +00:00
m_Core . m_pWorld - > m_Tuning [ g_Config . m_ClDummy ] = * GameServer ( ) - > Tuning ( ) ;
2014-04-13 14:49:58 +00:00
2014-03-12 23:49:07 +00:00
if ( m_TuneZone ! = m_TuneZoneOld ) // dont send tunigs all the time
{
2014-04-18 12:27:58 +00:00
// send zone msgs
SendZoneMsgs ( ) ;
}
}
2014-04-13 23:34:50 +00:00
2014-04-18 12:27:58 +00:00
void CCharacter : : SendZoneMsgs ( )
{
// send zone leave msg
2017-07-26 01:58:00 +00:00
// (m_TuneZoneOld >= 0: avoid zone leave msgs on spawn)
if ( m_TuneZoneOld > = 0 & & GameServer ( ) - > m_aaZoneLeaveMsg [ m_TuneZoneOld ] )
2014-04-18 12:27:58 +00:00
{
2017-07-26 01:58:00 +00:00
const char * pCur = GameServer ( ) - > m_aaZoneLeaveMsg [ m_TuneZoneOld ] ;
const char * pPos ;
while ( ( pPos = str_find ( pCur , " \\ n " ) ) )
2014-04-13 17:27:08 +00:00
{
2014-04-18 12:27:58 +00:00
char aBuf [ 256 ] ;
2017-07-26 01:58:00 +00:00
str_copy ( aBuf , pCur , pPos - pCur + 1 ) ;
aBuf [ pPos - pCur + 1 ] = ' \0 ' ;
pCur = pPos + 2 ;
2014-04-18 12:27:58 +00:00
GameServer ( ) - > SendChatTarget ( m_pPlayer - > GetCID ( ) , aBuf ) ;
2014-04-13 17:27:08 +00:00
}
2017-07-26 01:58:00 +00:00
GameServer ( ) - > SendChatTarget ( m_pPlayer - > GetCID ( ) , pCur ) ;
2014-04-18 12:27:58 +00:00
}
// send zone enter msg
2017-07-26 01:58:00 +00:00
if ( GameServer ( ) - > m_aaZoneEnterMsg [ m_TuneZone ] )
2014-04-18 12:27:58 +00:00
{
2017-07-26 01:58:00 +00:00
const char * pCur = GameServer ( ) - > m_aaZoneEnterMsg [ m_TuneZone ] ;
const char * pPos ;
while ( ( pPos = str_find ( pCur , " \\ n " ) ) )
2014-04-13 17:27:08 +00:00
{
2014-04-18 12:27:58 +00:00
char aBuf [ 256 ] ;
2017-07-26 01:58:00 +00:00
str_copy ( aBuf , pCur , pPos - pCur + 1 ) ;
aBuf [ pPos - pCur + 1 ] = ' \0 ' ;
pCur = pPos + 2 ;
2014-04-18 12:27:58 +00:00
GameServer ( ) - > SendChatTarget ( m_pPlayer - > GetCID ( ) , aBuf ) ;
2014-04-13 17:27:08 +00:00
}
2017-07-26 01:58:00 +00:00
GameServer ( ) - > SendChatTarget ( m_pPlayer - > GetCID ( ) , pCur ) ;
2014-03-12 23:49:07 +00:00
}
}
2011-01-29 00:59:50 +00:00
void CCharacter : : DDRaceTick ( )
2010-08-24 14:32:46 +00:00
{
2016-08-27 15:06:52 +00:00
mem_copy ( & m_Input , & m_SavedInput , sizeof ( m_Input ) ) ;
2011-01-29 00:59:50 +00:00
m_Armor = ( m_FreezeTime > = 0 ) ? 10 - ( m_FreezeTime / 15 ) : 0 ;
if ( m_Input . m_Direction ! = 0 | | m_Input . m_Jump ! = 0 )
m_LastMove = Server ( ) - > Tick ( ) ;
2010-08-24 14:32:46 +00:00
2011-01-29 00:59:50 +00:00
if ( m_FreezeTime > 0 | | m_FreezeTime = = - 1 )
2010-05-29 07:25:38 +00:00
{
2013-12-26 18:46:44 +00:00
if ( m_FreezeTime % Server ( ) - > TickSpeed ( ) = = Server ( ) - > TickSpeed ( ) - 1 | | m_FreezeTime = = - 1 )
2010-06-09 16:24:38 +00:00
{
2013-12-26 18:46:44 +00:00
GameServer ( ) - > CreateDamageInd ( m_Pos , 0 , ( m_FreezeTime + 1 ) / Server ( ) - > TickSpeed ( ) , Teams ( ) - > TeamMask ( Team ( ) , - 1 , m_pPlayer - > GetCID ( ) ) ) ;
2011-01-29 00:59:50 +00:00
}
if ( m_FreezeTime > 0 )
m_FreezeTime - - ;
else
m_Ninja . m_ActivationTick = Server ( ) - > Tick ( ) ;
m_Input . m_Direction = 0 ;
m_Input . m_Jump = 0 ;
m_Input . m_Hook = 0 ;
if ( m_FreezeTime = = 1 )
UnFreeze ( ) ;
2008-09-23 07:43:41 +00:00
}
2015-07-09 00:08:14 +00:00
2014-03-12 23:49:07 +00:00
HandleTuneLayer ( ) ; // need this before coretick
2015-04-16 15:28:03 +00:00
// look for save position for rescue feature
2015-06-30 16:46:36 +00:00
if ( g_Config . m_SvRescue ) {
2015-04-16 15:28:03 +00:00
int index = GameServer ( ) - > Collision ( ) - > GetPureMapIndex ( m_Pos ) ;
int tile = GameServer ( ) - > Collision ( ) - > GetTileIndex ( index ) ;
int ftile = GameServer ( ) - > Collision ( ) - > GetFTileIndex ( index ) ;
if ( IsGrounded ( ) & & tile ! = TILE_FREEZE & & tile ! = TILE_DFREEZE & & ftile ! = TILE_FREEZE & & ftile ! = TILE_DFREEZE ) {
m_PrevSavePos = m_Pos ;
m_SetSavePos = true ;
}
}
2011-01-29 00:59:50 +00:00
m_Core . m_Id = GetPlayer ( ) - > GetCID ( ) ;
2008-07-06 11:21:21 +00:00
}
2011-01-29 23:58:47 +00:00
void CCharacter : : DDRacePostCoreTick ( )
{
2013-03-18 11:58:29 +00:00
m_Time = ( float ) ( Server ( ) - > Tick ( ) - m_StartTime ) / ( ( float ) Server ( ) - > TickSpeed ( ) ) ;
Added the following settings to Close #123.
sv_time_in_broadcast, 1, 0, 1, CFGFLAG_SERVER, "Whether to display time in broadcast every interval or not by default, later the choice can be changed by players via chat commands"
sv_time_in_broadcast_interval, 1, 0, 60, CFGFLAG_SERVER, "How often to update the broadcast time"
sv_time_in_gametimer, 0, 0, 1, CFGFLAG_SERVER, "Whether to display time in the round/game timer or not by default, later the choice can be changed by players via chat commands"
Added the following Chat commands to give the player the choice over their settings:
"saytime", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSayTime, this, "Privately messages you your current time in this current running race"
"saytimeall", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSayTimeAll, this, "Publicly messages everyone your current time in this current running race"
"time", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTime, this, "Privately shows you your current time in this current running race in the broadcast message"
"broadcasttime", "?s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetBroadcastTime, this, "Personal Setting of showing time in the broadcast, broadcasttime s, where s = on for on, off for off, toggle for toggle and nothing to show current status"
"servergametime", "?s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetServerGameTime, this, "Personal Setting of showing time in the round/game timer, servergametime s, where s = on for on off for off, toggle for toggle and nothing to show current status"
Fixed Chat Command "eyeemote" and made it a set + toggle instead of just toggle for better bin techneques
Moved some vars from CCharacter to CPlayer to keep their status evern after death but not after disconnect.
So now players have the choice to see which timer they wanna see if any.
Note: These changes are all untested Stay away from this update on your main server until they are tested, i don't even know if they will compile propperly
2011-12-29 12:17:34 +00:00
if ( m_pPlayer - > m_DefEmoteReset > = 0 & & m_pPlayer - > m_DefEmoteReset < = Server ( ) - > Tick ( ) )
2014-06-21 22:50:11 +00:00
{
m_pPlayer - > m_DefEmoteReset = - 1 ;
m_EmoteType = m_pPlayer - > m_DefEmote = EMOTE_NORMAL ;
m_EmoteStop = - 1 ;
}
2011-01-29 23:58:47 +00:00
2014-06-21 22:50:11 +00:00
if ( m_EndlessHook | | ( m_Super & & g_Config . m_SvEndlessSuperHook ) )
m_Core . m_HookTick = 0 ;
2011-01-29 23:58:47 +00:00
2014-06-21 22:50:11 +00:00
if ( m_DeepFreeze & & ! m_Super )
Freeze ( ) ;
2011-01-29 23:58:47 +00:00
2014-06-21 22:50:11 +00:00
if ( m_Core . m_Jumps = = 0 & & ! m_Super )
m_Core . m_Jumped = 3 ;
else if ( m_Core . m_Jumps = = 1 & & m_Core . m_Jumped > 0 )
m_Core . m_Jumped = 3 ;
else if ( m_Core . m_JumpedTotal < m_Core . m_Jumps - 1 & & m_Core . m_Jumped > 1 )
m_Core . m_Jumped = 1 ;
2013-08-24 00:25:58 +00:00
2014-06-21 22:50:11 +00:00
if ( ( m_Super | | m_SuperJump ) & & m_Core . m_Jumped > 1 )
m_Core . m_Jumped = 1 ;
2011-01-29 23:58:47 +00:00
2014-06-21 22:50:11 +00:00
int CurrentIndex = GameServer ( ) - > Collision ( ) - > GetMapIndex ( m_Pos ) ;
HandleSkippableTiles ( CurrentIndex ) ;
2011-01-29 23:58:47 +00:00
2014-06-21 22:50:11 +00:00
// handle Anti-Skip tiles
std : : list < int > Indices = GameServer ( ) - > Collision ( ) - > GetMapIndices ( m_PrevPos , m_Pos ) ;
if ( ! Indices . empty ( ) )
for ( std : : list < int > : : iterator i = Indices . begin ( ) ; i ! = Indices . end ( ) ; i + + )
HandleTiles ( * i ) ;
else
{
HandleTiles ( CurrentIndex ) ;
}
2011-01-29 23:58:47 +00:00
2014-06-21 22:50:11 +00:00
HandleBroadcast ( ) ;
2011-01-29 23:58:47 +00:00
}
2011-01-25 09:34:14 +00:00
bool CCharacter : : Freeze ( int Seconds )
2010-08-24 14:32:46 +00:00
{
2011-01-25 09:34:14 +00:00
if ( ( Seconds < = 0 | | m_Super | | m_FreezeTime = = - 1 | | m_FreezeTime > Seconds * Server ( ) - > TickSpeed ( ) ) & & Seconds ! = - 1 )
2010-08-24 14:32:46 +00:00
return false ;
2011-01-25 09:34:14 +00:00
if ( m_FreezeTick < Server ( ) - > Tick ( ) - Server ( ) - > TickSpeed ( ) | | Seconds = = - 1 )
2010-07-29 05:21:18 +00:00
{
2011-01-25 09:34:14 +00:00
for ( int i = 0 ; i < NUM_WEAPONS ; i + + )
2010-08-24 14:32:46 +00:00
if ( m_aWeapons [ i ] . m_Got )
{
m_aWeapons [ i ] . m_Ammo = 0 ;
}
2011-01-25 09:34:14 +00:00
m_Armor = 0 ;
m_FreezeTime = Seconds = = - 1 ? Seconds : Seconds * Server ( ) - > TickSpeed ( ) ;
m_FreezeTick = Server ( ) - > Tick ( ) ;
2010-08-22 02:23:18 +00:00
return true ;
2010-08-24 14:32:46 +00:00
}
return false ;
}
bool CCharacter : : Freeze ( )
{
2011-01-25 09:34:14 +00:00
return Freeze ( g_Config . m_SvFreezeDelay ) ;
2010-08-24 14:32:46 +00:00
}
bool CCharacter : : UnFreeze ( )
{
2011-01-25 09:34:14 +00:00
if ( m_FreezeTime > 0 )
2010-08-22 02:23:18 +00:00
{
m_Armor = 10 ;
2010-08-24 14:32:46 +00:00
for ( int i = 0 ; i < NUM_WEAPONS ; i + + )
if ( m_aWeapons [ i ] . m_Got )
{
m_aWeapons [ i ] . m_Ammo = - 1 ;
}
2014-04-14 08:56:14 +00:00
if ( ! m_aWeapons [ m_Core . m_ActiveWeapon ] . m_Got )
m_Core . m_ActiveWeapon = WEAPON_GUN ;
2010-11-04 23:52:37 +00:00
m_FreezeTime = 0 ;
m_FreezeTick = 0 ;
2014-04-14 08:56:14 +00:00
if ( m_Core . m_ActiveWeapon = = WEAPON_HAMMER ) m_ReloadTimer = 0 ;
2014-02-19 21:30:34 +00:00
return true ;
2010-08-22 02:23:18 +00:00
}
2010-08-24 14:32:46 +00:00
return false ;
}
2016-10-08 17:42:42 +00:00
void CCharacter : : GiveWeapon ( int Weapon , bool Remove )
{
if ( Weapon = = WEAPON_NINJA )
{
if ( Remove )
RemoveNinja ( ) ;
else
GiveNinja ( ) ;
return ;
}
2017-02-21 16:10:08 +00:00
2016-10-08 17:42:42 +00:00
if ( Remove )
{
if ( GetActiveWeapon ( ) = = Weapon )
SetActiveWeapon ( WEAPON_GUN ) ;
}
else
{
if ( ! m_FreezeTime )
m_aWeapons [ Weapon ] . m_Ammo = - 1 ;
}
m_aWeapons [ Weapon ] . m_Got = ! Remove ;
}
2010-08-24 14:32:46 +00:00
void CCharacter : : GiveAllWeapons ( )
{
2015-08-22 18:15:15 +00:00
for ( int i = WEAPON_GUN ; i < NUM_WEAPONS - 1 ; i + + )
2014-12-15 19:48:58 +00:00
{
2016-10-08 17:42:42 +00:00
GiveWeapon ( i ) ;
2014-12-15 19:48:58 +00:00
}
2010-08-24 14:32:46 +00:00
}
2010-07-29 05:21:18 +00:00
2011-12-29 13:58:39 +00:00
void CCharacter : : Pause ( bool Pause )
{
m_Paused = Pause ;
if ( Pause )
{
GameServer ( ) - > m_World . m_Core . m_apCharacters [ m_pPlayer - > GetCID ( ) ] = 0 ;
GameServer ( ) - > m_World . RemoveEntity ( this ) ;
2014-12-15 19:49:16 +00:00
if ( m_Core . m_HookedPlayer ! = - 1 ) // Keeping hook would allow cheats
{
m_Core . m_HookedPlayer = - 1 ;
m_Core . m_HookState = HOOK_RETRACTED ;
m_Core . m_TriggeredEvents | = COREEVENT_HOOK_RETRACT ;
}
2011-12-29 13:58:39 +00:00
}
else
{
2012-04-27 13:01:26 +00:00
m_Core . m_Vel = vec2 ( 0 , 0 ) ;
2011-12-29 13:58:39 +00:00
GameServer ( ) - > m_World . m_Core . m_apCharacters [ m_pPlayer - > GetCID ( ) ] = & m_Core ;
GameServer ( ) - > m_World . InsertEntity ( this ) ;
}
}
2011-01-29 00:59:50 +00:00
void CCharacter : : DDRaceInit ( )
2008-07-06 11:21:21 +00:00
{
2011-12-29 13:58:39 +00:00
m_Paused = false ;
2011-01-29 00:59:50 +00:00
m_DDRaceState = DDRACE_NONE ;
m_PrevPos = m_Pos ;
2015-04-16 15:28:03 +00:00
m_SetSavePos = false ;
2011-01-29 00:59:50 +00:00
m_LastBroadcast = 0 ;
m_TeamBeforeSuper = 0 ;
m_Core . m_Id = GetPlayer ( ) - > GetCID ( ) ;
2011-02-14 21:34:46 +00:00
if ( g_Config . m_SvTeam = = 2 )
2011-01-29 14:31:50 +00:00
{
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , " Please join a team before you start " ) ;
m_LastStartWarning = Server ( ) - > Tick ( ) ;
}
2011-05-17 23:12:39 +00:00
m_TeleCheckpoint = 0 ;
2011-07-22 12:29:27 +00:00
m_EndlessHook = g_Config . m_SvEndlessDrag ;
2011-07-25 20:16:20 +00:00
m_Hit = g_Config . m_SvHit ? HIT_ALL : DISABLE_HIT_GRENADE | DISABLE_HIT_HAMMER | DISABLE_HIT_RIFLE | DISABLE_HIT_SHOTGUN ;
2013-08-05 15:47:04 +00:00
m_SuperJump = false ;
2013-11-22 14:10:55 +00:00
m_Jetpack = false ;
2013-08-23 23:03:45 +00:00
m_Core . m_Jumps = 2 ;
2014-07-16 00:59:39 +00:00
m_FreezeHammer = false ;
2013-11-15 23:44:49 +00:00
int Team = Teams ( ) - > m_Core . Team ( m_Core . m_Id ) ;
if ( Teams ( ) - > TeamLocked ( Team ) )
{
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
{
2014-05-18 23:57:52 +00:00
if ( Teams ( ) - > m_Core . Team ( i ) = = Team & & i ! = m_Core . m_Id & & GameServer ( ) - > m_apPlayers [ i ] )
2013-11-15 23:44:49 +00:00
{
CCharacter * pChar = GameServer ( ) - > m_apPlayers [ i ] - > GetCharacter ( ) ;
if ( pChar )
{
m_DDRaceState = pChar - > m_DDRaceState ;
m_StartTime = pChar - > m_StartTime ;
}
}
}
}
2011-02-14 18:36:30 +00:00
}
2015-04-16 15:28:03 +00:00
void CCharacter : : Rescue ( )
{
if ( m_SetSavePos & & ! m_Super & & ! m_DeepFreeze & & IsGrounded ( ) & & m_Pos = = m_PrevPos ) {
2015-06-30 16:46:36 +00:00
if ( m_LastRescue + g_Config . m_SvRescueDelay * Server ( ) - > TickSpeed ( ) > Server ( ) - > Tick ( ) )
{
char aBuf [ 256 ] ;
2017-07-26 01:58:00 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " You have to wait %d seconds until you can rescue yourself " , ( int ) ( ( m_LastRescue + g_Config . m_SvRescueDelay * Server ( ) - > TickSpeed ( ) - Server ( ) - > Tick ( ) ) / Server ( ) - > TickSpeed ( ) ) ) ;
2015-06-30 16:46:36 +00:00
GameServer ( ) - > SendChatTarget ( GetPlayer ( ) - > GetCID ( ) , aBuf ) ;
return ;
}
2015-04-16 15:28:03 +00:00
int index = GameServer ( ) - > Collision ( ) - > GetPureMapIndex ( m_Pos ) ;
if ( GameServer ( ) - > Collision ( ) - > GetTileIndex ( index ) = = TILE_FREEZE | | GameServer ( ) - > Collision ( ) - > GetFTileIndex ( index ) = = TILE_FREEZE ) {
2015-06-30 16:46:36 +00:00
m_LastRescue = Server ( ) - > Tick ( ) ;
2015-04-16 16:13:36 +00:00
m_Core . m_Pos = m_PrevSavePos ;
m_Pos = m_PrevSavePos ;
m_PrevPos = m_PrevSavePos ;
2015-04-16 15:28:03 +00:00
m_Core . m_Vel = vec2 ( 0 , 0 ) ;
m_Core . m_HookedPlayer = - 1 ;
m_Core . m_HookState = HOOK_RETRACTED ;
m_Core . m_TriggeredEvents | = COREEVENT_HOOK_RETRACT ;
GameWorld ( ) - > ReleaseHooked ( GetPlayer ( ) - > GetCID ( ) ) ;
m_Core . m_HookPos = m_Core . m_Pos ;
2015-04-16 16:13:36 +00:00
UnFreeze ( ) ;
2015-04-16 15:28:03 +00:00
}
}
}