2444
2443
sg_ArchiveCoord( this->pos, 1 );
2445
2444
sg_ArchiveReal( this->verletSpeed_, 1 );
2449
startPos_ = this->pos;
2450
startDir_ = this->dir;
2452
tString logTurnsMsg;
2453
logTurnsMsg << "spawned " << this->MapPosition().x << " " << this->MapPosition().y << " " << this->MapDirection().x << " " << this->MapDirection().y;
2454
LogPlayersCycleTurns(this, logTurnsMsg);
2456
turnedPositions.push_back(startPos_);
2448
startPos_ = this->pos;
2449
startDir_ = this->dir;
2451
tString logTurnsMsg;
2452
logTurnsMsg << "spawned " << this->MapPosition().x << " " << this->MapPosition().y << " " << this->MapDirection().x << " " << this->MapDirection().y;
2453
LogPlayersCycleTurns(this, logTurnsMsg);
2455
turnedPositions.push_back(startPos_);
2457
2456
turnedDirections.push_back(startDir_);
3741
static void se_cycleTurn(std::istream &s)
3743
ePlayerNetID *player = NULL;
3744
player = se_GetLocalPlayer();
3746
tString times, turn;
3750
int x = atoi(times);
3753
gCycle *cycle = dynamic_cast<gCycle *>(player->Object());
3754
if (cycle && cycle->Alive())
3756
if (turn.Filter() == "left")
3758
for(int i = 0; i < x; i++)
3760
cycle->Act(&gCycle::se_turnLeft, 1);
3763
else if (turn.Filter() == "right")
3765
for(int i = 0; i < x; i++)
3767
cycle->Act(&gCycle::se_turnRight, 1);
3773
msg << "Usage: CYCLE_TURN <times> [turn: left | right] required.\n";
3774
sn_ConsoleOut(msg, player->Owner());
3740
static void se_cycleTurn(std::istream &s)
3742
ePlayerNetID *player = NULL;
3743
player = se_GetLocalPlayer();
3745
tString times, turn;
3749
int x = atoi(times);
3752
gCycle *cycle = dynamic_cast<gCycle *>(player->Object());
3753
if (cycle && cycle->Alive())
3755
if (turn.Filter() == "left")
3757
for(int i = 0; i < x; i++)
3759
cycle->Act(&gCycle::se_turnLeft, 1);
3762
else if (turn.Filter() == "right")
3764
for(int i = 0; i < x; i++)
3766
cycle->Act(&gCycle::se_turnRight, 1);
3772
msg << "Usage: CYCLE_TURN <times> [turn: left | right] required.\n";
3773
sn_ConsoleOut(msg, player->Owner());
3779
3778
static tConfItemFunc se_cycleTurnConf("CYCLE_TURN", &se_cycleTurn);
3906
3905
gFakeDirDriveSetter fakeSetter( dirDriveFake );
3908
3907
lastDirDrive = lastDirDriveBack;
3912
REAL thisRadians = atan2f(dirDrive.y, dirDrive.x);
3913
REAL thisDegrees = thisRadians * (180.0 / M_PI);
3914
con << "Turn Angle: " << thisDegrees << " | x: " << dirDrive.x << " y: " << dirDrive.y << "\n\n";
3918
if (sg_RaceTimerEnabled && (sg_RaceSafeAngles != ""))
3920
bool racer_safe = false;
3922
tArray<tString> degreesList = sg_RaceSafeAngles.Split(",");
3923
for(int iD = 0; iD < degreesList.Len(); iD++)
3925
if (degreesList[iD].Filter() == "") continue;
3927
// if this is set, then all angles are safe.
3928
// any angle after this is unsafe
3929
REAL degrees = atof(degreesList[iD]);
3935
REAL radians = degrees * (M_PI / 180.0);
3936
eCoord radianCoord = eCoord(cos(radians), sin(radians));
3938
REAL radX = radianCoord.x;
3939
REAL radXA = radX * 10.0f;
3940
REAL radXB = ((int)radXA) / 10.0f;
3941
radianCoord.x = ((radXB == 0) ? 0 : radX);
3943
REAL radY = radianCoord.y;
3944
REAL radYA = radY * 10.0f;
3945
REAL radYB = ((int)radYA) / 10.0f;
3946
radianCoord.y = ((radYB == 0) ? 0 : radY);
3948
con << radXB << " " << radYB << "\n";
3951
// check the direction this player is turning into and if its safe, good. if not, lets check again
3952
if ((radianCoord.x == dirDrive.x) && (radianCoord.y == dirDrive.y))
3955
con << "Checked Angle: " << degrees << " | x: " << radianCoord.x << " y: " << radianCoord.y << "\n\n";
3966
gRacePlayer *racer = gRacePlayer::GetPlayer(Player());
3968
racer->SetSafe(racer_safe);
3973
logTurnPos << pos.x << " " << pos.y << " " << dirDrive.x << " " << dirDrive.y;
3974
LogPlayersCycleTurns(this, logTurnPos);
3976
turnedPositions.push_back(pos);
3911
REAL thisRadians = atan2f(dirDrive.y, dirDrive.x);
3912
REAL thisDegrees = thisRadians * (180.0 / M_PI);
3913
con << "Turn Angle: " << thisDegrees << " | x: " << dirDrive.x << " y: " << dirDrive.y << "\n\n";
3917
if (sg_RaceTimerEnabled && (sg_RaceSafeAngles != ""))
3919
bool racer_safe = false;
3921
tArray<tString> degreesList = sg_RaceSafeAngles.Split(",");
3922
for(int iD = 0; iD < degreesList.Len(); iD++)
3924
if (degreesList[iD].Filter() == "") continue;
3926
// if this is set, then all angles are safe.
3927
// any angle after this is unsafe
3928
REAL degrees = atof(degreesList[iD]);
3934
REAL radians = degrees * (M_PI / 180.0);
3935
eCoord radianCoord = eCoord(cos(radians), sin(radians));
3937
REAL radX = radianCoord.x;
3938
REAL radXA = radX * 10.0f;
3939
REAL radXB = ((int)radXA) / 10.0f;
3940
radianCoord.x = ((radXB == 0) ? 0 : radX);
3942
REAL radY = radianCoord.y;
3943
REAL radYA = radY * 10.0f;
3944
REAL radYB = ((int)radYA) / 10.0f;
3945
radianCoord.y = ((radYB == 0) ? 0 : radY);
3947
con << radXB << " " << radYB << "\n";
3950
// check the direction this player is turning into and if its safe, good. if not, lets check again
3951
if ((radianCoord.x == dirDrive.x) && (radianCoord.y == dirDrive.y))
3954
con << "Checked Angle: " << degrees << " | x: " << radianCoord.x << " y: " << radianCoord.y << "\n\n";
3965
gRacePlayer *racer = gRacePlayer::GetPlayer(Player());
3967
racer->SetSafe(racer_safe);
3972
logTurnPos << pos.x << " " << pos.y << " " << dirDrive.x << " " << dirDrive.y;
3973
LogPlayersCycleTurns(this, logTurnPos);
3975
turnedPositions.push_back(pos);
3977
3976
turnedDirections.push_back(dirDrive);
4130
4129
pZone->RequestSync();
4135
static eLadderLogWriter se_cycleDestroyedWriter("CYCLE_DESTROYED", false);
4137
bool sg_cycleRespawnZone = false;
4138
static tSettingItem<bool> sg_cycleRespawnZoneConf("CYCLE_RESPAWN_ZONE", sg_cycleRespawnZone);
4140
bool sg_cycleRespawnZoneType = false;
4141
static tSettingItem<bool> sg_cycleRespawnZoneTypeConf("CYCLE_RESPAWN_ZONE_TYPE", sg_cycleRespawnZoneType);
4143
float sg_cycleRespawnZoneRadius = 2.5;
4144
static tSettingItem<float> sg_cycleRespawnZoneRadiusConf("CYCLE_RESPAWN_ZONE_RADIUS", sg_cycleRespawnZoneRadius);
4146
float sg_cycleRespawnZoneGrowth = -0.4;
4147
static tSettingItem<float> sg_cycleRespawnZoneGrowthConf("CYCLE_RESPAWN_ZONE_GROWTH", sg_cycleRespawnZoneGrowth);
4149
static void sg_cycleRespawnZone_Create(gCycle *cycle)
4151
eGrid *grid = eGrid::CurrentGrid();
4154
if (!sg_cycleRespawnZone) return;
4156
//con << "Cycle respawn zone activated...\n";
4157
ePlayerNetID *player = cycle->Player();
4159
eCoord resPos, resDir;
4160
if (sg_cycleRespawnZoneType)
4162
resPos = cycle->StartPosition();
4163
resDir = cycle->StartDirection();
4167
resPos = cycle->Position();
4168
resDir = cycle->Direction();
4173
gRespawnZoneHack *cycleRespawnZone = new gRespawnZoneHack(grid, resPos, player, true);
4174
cycleRespawnZone->SetRadius(sg_cycleRespawnZoneRadius * gArena::SizeMultiplier());
4175
cycleRespawnZone->SetExpansionSpeed(sg_cycleRespawnZoneGrowth);
4176
cycleRespawnZone->SetColor(cycle->color_);
4177
cycleRespawnZone->SetSpawnDirection(resDir);
4179
cycleRespawnZone->RequestSync();
4134
static eLadderLogWriter se_cycleDestroyedWriter("CYCLE_DESTROYED", false);
4136
bool sg_cycleRespawnZone = false;
4137
static tSettingItem<bool> sg_cycleRespawnZoneConf("CYCLE_RESPAWN_ZONE", sg_cycleRespawnZone);
4139
bool sg_cycleRespawnZoneType = false;
4140
static tSettingItem<bool> sg_cycleRespawnZoneTypeConf("CYCLE_RESPAWN_ZONE_TYPE", sg_cycleRespawnZoneType);
4142
float sg_cycleRespawnZoneRadius = 2.5;
4143
static tSettingItem<float> sg_cycleRespawnZoneRadiusConf("CYCLE_RESPAWN_ZONE_RADIUS", sg_cycleRespawnZoneRadius);
4145
float sg_cycleRespawnZoneGrowth = -0.4;
4146
static tSettingItem<float> sg_cycleRespawnZoneGrowthConf("CYCLE_RESPAWN_ZONE_GROWTH", sg_cycleRespawnZoneGrowth);
4148
static void sg_cycleRespawnZone_Create(gCycle *cycle)
4150
eGrid *grid = eGrid::CurrentGrid();
4153
if (!sg_cycleRespawnZone) return;
4155
//con << "Cycle respawn zone activated...\n";
4156
ePlayerNetID *player = cycle->Player();
4158
eCoord resPos, resDir;
4159
if (sg_cycleRespawnZoneType)
4161
resPos = cycle->StartPosition();
4162
resDir = cycle->StartDirection();
4166
resPos = cycle->Position();
4167
resDir = cycle->Direction();
4172
gRespawnZoneHack *cycleRespawnZone = new gRespawnZoneHack(grid, resPos, player, true);
4173
cycleRespawnZone->SetRadius(sg_cycleRespawnZoneRadius * gArena::SizeMultiplier());
4174
cycleRespawnZone->SetExpansionSpeed(sg_cycleRespawnZoneGrowth);
4175
cycleRespawnZone->SetColor(cycle->color_);
4176
cycleRespawnZone->SetSpawnDirection(resDir);
4178
cycleRespawnZone->RequestSync();
4183
4182
void gCycle::Kill(){
4184
4183
// keep this cycle alive
4185
4184
tJUST_CONTROLLED_PTR< gCycle > keep( this->GetRefcount()>0 ? this : 0 );
4187
if (sn_GetNetState() != nCLIENT)
4186
if (sn_GetNetState() != nCLIENT)
4189
4188
RequestSync(true);
4212
4211
Die( lastTime );
4213
4212
tNEW(gExplosion)(grid, pos,lastTime, color_, this );
4214
// eEdge::SeethroughHasChanged();
4216
if (this && Player())
4218
tString logTurnsMsg;
4219
logTurnsMsg << "death " << MapPosition().x << " " << MapPosition().y << " " << MapDirection().x << " " << MapDirection().y;
4220
LogPlayersCycleTurns(this, logTurnsMsg);
4222
se_cycleDestroyedWriter << Player()->GetUserName() << MapPosition().x << MapPosition().y << MapDirection().x << MapDirection().y << (Player()->CurrentTeam()?ePlayerNetID::FilterName(Team()->Name()):"") << se_GameTime();
4223
se_cycleDestroyedWriter.write();
4225
Player()->LogActivity(ACTIVITY_DIED);
4227
sg_cycleRespawnZone_Create(this);
4229
if (sg_RaceTimerEnabled)
4231
gRace::ZoneOut(Player(), lastTime);
4213
// eEdge::SeethroughHasChanged();
4215
if (this && Player())
4217
tString logTurnsMsg;
4218
logTurnsMsg << "death " << MapPosition().x << " " << MapPosition().y << " " << MapDirection().x << " " << MapDirection().y;
4219
LogPlayersCycleTurns(this, logTurnsMsg);
4221
se_cycleDestroyedWriter << Player()->GetUserName() << MapPosition().x << MapPosition().y << MapDirection().x << MapDirection().y << ePlayerNetID::FilterName(Team()->Name()) << se_GameTime();
4222
se_cycleDestroyedWriter.write();
4224
Player()->LogActivity(ACTIVITY_DIED);
4226
sg_cycleRespawnZone_Create(this);
4228
if (sg_RaceTimerEnabled)
4230
gRace::ZoneOut(Player(), lastTime);
4236
4235
if ( currentWall )
4652
4651
// then, render the rest
4653
4652
RenderAll( camera, cycle, wallList_ );
4656
bool sg_HideCycles = false;
4655
bool sg_HideCycles = false;
4657
4656
static tConfItem<bool> sg_HideCyclesConf("HIDE_CYCLES", sg_HideCycles);
4659
// Should we hide the chat flag above the player's cycle when the user is silenced?
4660
static bool se_HideSilencedPyramidChatFlag = true;
4661
static tSettingItem<bool> se_HideSilencedPyramidChatFlagConf("HIDE_SILENCED_PYRAMID_CHATFLAG", se_HideSilencedPyramidChatFlag);
4664
4658
void gCycle::Render(const eCamera *cam){
4666
4660
// for use when there's rendering problems on one specific occasion
4868
4862
REAL alpha = 1;
4869
4863
const REAL timeout = .5f;
4873
// If the HIDE_SILENCED_PYRAMID_CHATFLAG command is set to false and the player is not silenced, show the tab chatflag.
4874
if (!(se_HideSilencedPyramidChatFlag && player->AccessSilenced()))
4876
if (player->IsChatting())
4878
renderPyramid = true;
4879
colorPyramid.b = 0.0f;
4881
else if (!player->IsActive())
4883
renderPyramid = true;
4884
colorPyramid.b = 0.0f;
4885
colorPyramid.g = 0.0f;
4887
else if (cam && cam->Center() == this && se_GameTime() < timeout && player->CurrentTeam() && player->CurrentTeam()->NumPlayers() > 1)
4889
renderPyramid = true;
4890
alpha = timeout - se_GameTime();
4867
if ( player->IsChatting() )
4869
renderPyramid = true;
4870
colorPyramid.b = 0.0f;
4872
else if ( !player->IsActive() )
4874
renderPyramid = true;
4875
colorPyramid.b = 0.0f;
4876
colorPyramid.g = 0.0f;
4878
else if ( cam && cam->Center() == this && se_GameTime() < timeout && player->CurrentTeam() && player->CurrentTeam()->NumPlayers() > 1 )
4880
renderPyramid = true;
4881
alpha = timeout - se_GameTime();
4894
4885
if ( renderPyramid )
4896
4887
GLfloat s=sin(lastTime);
5229
5220
glLoadIdentity();
5231
5222
/*glColor4f(1, 1, 1, alpha);
5232
DisplayText(xp, yp, rCWIDTH_NORMAL, rCHEIGHT_NORMAL, this->player->GetName(), 0, 0);*/
5223
DisplayText(xp, yp, rCWIDTH_NORMAL, rCHEIGHT_NORMAL, this->player->GetName(), 0, 0);*/
5233
5224
glTranslatef(xp, yp, 0.);
5235
5226
glColor4f(1, 1, 1, alpha);
5434
5425
nextSync = nextSyncOwner = -1;
5436
lastSyncOwnerGameTime_ = 0;
5438
startPos_ = this->pos;
5439
startDir_ = this->dir;
5441
tString logTurnsMsg;
5442
logTurnsMsg << "spawned " << this->MapPosition().x << " " << this->MapPosition().y << " " << this->MapDirection().x << " " << this->MapDirection().y;
5443
LogPlayersCycleTurns(this, logTurnsMsg);
5445
turnedPositions.push_back(startPos_);
5427
lastSyncOwnerGameTime_ = 0;
5429
startPos_ = this->pos;
5430
startDir_ = this->dir;
5432
tString logTurnsMsg;
5433
logTurnsMsg << "spawned " << this->MapPosition().x << " " << this->MapPosition().y << " " << this->MapDirection().x << " " << this->MapDirection().y;
5434
LogPlayersCycleTurns(this, logTurnsMsg);
5436
turnedPositions.push_back(startPos_);
5446
5437
turnedDirections.push_back(startDir_);
6679
6670
static tSettingItem<int> conf_megashotDirections ("MEGA_SHOT_DIR", sg_megashotDirections);
6681
6672
static int sg_megashotExplosion = 1;
6682
static tSettingItem<int> conf_megashotExplosion ("MEGA_SHOT_EXPLOSION", sg_megashotExplosion);
6684
static bool sg_shotPenetrateWalls = false;
6685
static tSettingItem<bool> sg_shotPenetrateWallsConf("SHOT_PENETRATE_WALLS", sg_shotPenetrateWalls);
6673
static tSettingItem<int> conf_megashotExplosion ("MEGA_SHOT_EXPLOSION", sg_megashotExplosion);
6675
static bool sg_shotPenetrateWalls = false;
6676
static tSettingItem<bool> sg_shotPenetrateWallsConf("SHOT_PENETRATE_WALLS", sg_shotPenetrateWalls);
6687
6678
static eLadderLogWriter sg_ZoneShotReleased("ZONE_SHOT_RELEASED", false);
6689
6680
#define FIX_BRAKE_BUG
7181
7169
static tConfItemFunc sg_TeleportPlayer_conf("TELEPORT_PLAYER",&sg_TeleportPlayer);
7184
static void sg_setCycleSpeed(std::istream &s)
7186
tString playerStr, speedStr;
7189
ePlayerNetID *player = ePlayerNetID::FindPlayerByName(playerStr);
7193
gCycle *pCycle = dynamic_cast<gCycle *>(player->Object());
7194
if (pCycle && pCycle->Alive())
7197
REAL speed = atof(speedStr);
7198
if (speed <= 0) speed = 0;
7200
pCycle->verletSpeed_ = speed;
7201
pCycle->RequestSync();
7205
static tConfItemFunc sg_setCycleSpeedConf("SET_CYCLE_SPEED", sg_setCycleSpeed);
7207
static void sg_setCycleRubber(std::istream &s)
7209
tString playerStr, rubberStr;
7212
ePlayerNetID *player = ePlayerNetID::FindPlayerByName(playerStr);
7216
gCycle *pCycle = dynamic_cast<gCycle *>(player->Object());
7217
if (pCycle && pCycle->Alive())
7220
REAL rubber = atof(rubberStr);
7221
if (rubber < 0) rubber = 0;
7223
pCycle->SetRubber(rubber);
7224
pCycle->RequestSync();
7228
static tConfItemFunc sg_setCycleRubberConf("SET_CYCLE_RUBBER", sg_setCycleRubber);
7172
static void sg_setCycleSpeed(std::istream &s)
7174
tString playerStr, speedStr;
7177
ePlayerNetID *player = ePlayerNetID::FindPlayerByName(playerStr);
7181
gCycle *pCycle = dynamic_cast<gCycle *>(player->Object());
7182
if (pCycle && pCycle->Alive())
7185
REAL speed = atof(speedStr);
7186
if (speed <= 0) speed = 0;
7188
pCycle->verletSpeed_ = speed;
7189
pCycle->RequestSync();
7193
static tConfItemFunc sg_setCycleSpeedConf("SET_CYCLE_SPEED", sg_setCycleSpeed);
7195
static void sg_setCycleRubber(std::istream &s)
7197
tString playerStr, rubberStr;
7200
ePlayerNetID *player = ePlayerNetID::FindPlayerByName(playerStr);
7204
gCycle *pCycle = dynamic_cast<gCycle *>(player->Object());
7205
if (pCycle && pCycle->Alive())
7208
REAL rubber = atof(rubberStr);
7209
if (rubber < 0) rubber = 0;
7211
pCycle->SetRubber(rubber);
7212
pCycle->RequestSync();
7216
static tConfItemFunc sg_setCycleRubberConf("SET_CYCLE_RUBBER", sg_setCycleRubber);