~swag/armagetronad/0.2.9-sty+ct+ap-fork

« back to all changes in this revision

Viewing changes to src/tron/gZone.cpp

  • Committer: SwagTron
  • Date: 2019-03-03 20:57:16 UTC
  • Revision ID: swagtron-20190303205716-nk32wtrusb3tum54
As far as I am aware, compiling 2.9 sty+ct+ap was incredibly difficult and impossible without using older versions merged with the latest revision (thanks to Nelg's help). Created a proper win32 folder, a readme file, and made it simple to compile for windows.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
#include "nConfig.h"
54
54
#include "gSpawn.h"
55
55
#include "gArena.h"
56
 
#include "tRandom.h"
57
 
 
58
 
//HACK RACE
59
 
#include "gRace.h"
60
 
 
 
56
#include "tRandom.h"
 
57
 
 
58
//HACK RACE
 
59
#include "gRace.h"
 
60
 
61
61
#include "gParser.h"
62
62
 
63
63
#include <time.h>
64
 
#include <algorithm>
65
 
 
66
 
static bool sg_SwapWinDeath = false;
 
64
#include <algorithm>
 
65
 
 
66
static bool sg_SwapWinDeath = false;
67
67
static tSettingItem<bool> sg_SwitchWinDeathColorCONF("SWAP_WINZONE_DEATHZONE_COLORS", sg_SwapWinDeath);
68
68
 
69
69
static int sg_zoneAlphaToggle = 0;
70
 
static tConfItem<int> sg_zoneAlphaToggleConf( "ZONE_ALPHA_TOGGLE", sg_zoneAlphaToggle );
 
70
static tSettingItem<int> sg_zoneAlphaToggleConf( "ZONE_ALPHA_TOGGLE", sg_zoneAlphaToggle );
71
71
 
72
72
static int sg_zoneDeath = 1;
73
73
static tSettingItem<int> sg_zoneDeathConf( "WIN_ZONE_DEATHS", sg_zoneDeath );
100
100
static tSettingItem<bool> sg_ballAutoRespawnConf( "BALL_AUTORESPAWN", sg_ballAutoRespawn );
101
101
 
102
102
static int sg_zoneSegments = 11;
103
 
static tConfItem<int> sg_zoneSegmentsConf( "ZONE_SEGMENTS", sg_zoneSegments );
 
103
static tSettingItem<int> sg_zoneSegmentsConf( "ZONE_SEGMENTS", sg_zoneSegments );
104
104
 
105
105
static REAL sg_zoneSegLength = .5;
106
 
static tConfItem<REAL> sg_zoneSegLengthConf( "ZONE_SEG_LENGTH", sg_zoneSegLength );
 
106
static tSettingItem<REAL> sg_zoneSegLengthConf( "ZONE_SEG_LENGTH", sg_zoneSegLength );
107
107
 
108
108
static REAL sg_zoneBottom = 0.0f;
109
 
static tConfItem<REAL> sg_zoneBottomConf( "ZONE_BOTTOM", sg_zoneBottom );
 
109
static tSettingItem<REAL> sg_zoneBottomConf( "ZONE_BOTTOM", sg_zoneBottom );
110
110
 
111
111
static REAL sg_zoneHeight = 5.0f;
112
 
static tConfItem<REAL> sg_zoneHeightConf( "ZONE_HEIGHT", sg_zoneHeight );
 
112
static tSettingItem<REAL> sg_zoneHeightConf( "ZONE_HEIGHT", sg_zoneHeight );
113
113
 
114
114
static eLadderLogWriter sg_flagConquestRoundWinWriter("FLAG_CONQUEST_ROUND_WIN", true);
115
115
static eLadderLogWriter sg_flagTimeoutWriter("FLAG_TIMEOUT", true);
119
119
static eLadderLogWriter sg_flagScoreWriter("FLAG_SCORE", true);
120
120
static eLadderLogWriter sg_flagHeldWriter("FLAG_HELD", true);
121
121
static eLadderLogWriter sg_baseRespawnWriter("BASE_RESPAWN", true);
122
 
static eLadderLogWriter sg_baseEnemyRespawnWriter("BASE_ENEMY_RESPAWN", true);
123
 
 
 
122
static eLadderLogWriter sg_baseEnemyRespawnWriter("BASE_ENEMY_RESPAWN", true);
 
123
 
124
124
static eLadderLogWriter sg_deathZoneActivated("DEATHZONE_ACTIVATED", true);
125
 
static eLadderLogWriter sg_winZoneActivated("WINZONE_ACTIVATED", true);
126
 
 
127
 
bool gWinZoneHack::winnerPlayer_ = false;
 
125
static eLadderLogWriter sg_winZoneActivated("WINZONE_ACTIVATED", true);
 
126
 
 
127
bool gWinZoneHack::winnerPlayer_ = false;
128
128
 
129
129
//! creates a win or death zone (according to configuration) at the specified position
130
130
gZone * sg_CreateWinDeathZone( eGrid * grid, const eCoord & pos )
133
133
    if ( sg_zoneDeath )
134
134
    {
135
135
        ret = tNEW( gDeathZoneHack( grid, pos ) );
136
 
        sn_ConsoleOut( "$instant_death_activated" );
137
 
 
138
 
        sg_deathZoneActivated << ret->GOID() << ret->GetName() << ret->MapPosition().x << ret->MapPosition().y;
 
136
        sn_ConsoleOut( "$instant_death_activated" );
 
137
 
 
138
        sg_deathZoneActivated << ret->GOID() << ret->GetName() << ret->MapPosition().x << ret->MapPosition().y;
139
139
        sg_deathZoneActivated.write();
140
140
    }
141
141
    else
148
148
        else
149
149
        {
150
150
            sn_ConsoleOut( "$instant_round_end_activated" );
151
 
        }
152
 
 
153
 
        sg_winZoneActivated << ret->GOID() << ret->GetName() << ret->MapPosition().x << ret->MapPosition().y;
 
151
        }
 
152
 
 
153
        sg_winZoneActivated << ret->GOID() << ret->GetName() << ret->MapPosition().x << ret->MapPosition().y;
154
154
        sg_winZoneActivated.write();
155
155
    }
156
156
 
215
215
 
216
216
int gZone::FindFirst(tString name)
217
217
{
218
 
    eGrid *grid = eGrid::CurrentGrid();
219
 
    if (!grid) return -1;
 
218
    eGrid *grid = eGrid::CurrentGrid();
 
219
    if (!grid) return -1;
220
220
 
221
221
    const tList<eGameObject>& gameObjects = grid->GameObjects();
222
222
    for (int j=gameObjects.Len()-1;j>=0;j--)
238
238
 
239
239
int gZone::FindNext(tString name, int prev_pos)
240
240
{
241
 
    eGrid *grid = eGrid::CurrentGrid();
242
 
    if (!grid) return -1;
 
241
    eGrid *grid = eGrid::CurrentGrid();
 
242
    if (!grid) return -1;
243
243
 
244
244
    const tList<eGameObject>& gameObjects = grid->GameObjects();
245
245
    for (int j=prev_pos-1;j>=0;j--)
276
276
    // store creation time
277
277
    referenceTime_ = createTime_ = lastTime = 0;
278
278
 
279
 
    destroyed_ = false;
 
279
    destroyed_ = false;
280
280
    zoneInit_ = false;
281
 
    dynamicCreation_ = dynamicCreation;
 
281
    dynamicCreation_ = dynamicCreation;
282
282
    delayCreation_ = delayCreation;
283
283
    wallInteract_ = false;
284
 
    wallBouncesLeft_ = 0;
 
284
    wallBouncesLeft_ = 0;
285
285
    wallPenetrate_ = false;
286
286
    targetRadius_ = 0;
287
287
    lastImpactTime_ = 0;
291
291
    pOwner_ = NULL;
292
292
    pSeekingCycle_ = NULL;
293
293
    seeking_ = false;            //??? change this to a game object, allow seeking any
294
 
    name_ = tString("");
 
294
    name_ = tString("");
295
295
    effect_ = tString("");
296
296
 
297
 
    color_.r = color_.g = color_.b = 1.0f;
298
 
 
 
297
    color_.r = color_.g = color_.b = 1.0f;
 
298
 
299
299
    // set fixed values
300
300
    SetRotationSpeed( .3f );
301
301
    SetRotationAcceleration( 0.0f );
311
311
        createTime_ -= 3.5;
312
312
    }
313
313
 
314
 
    // add to game grid
 
314
    // add to game grid
315
315
    if (!delayCreation)
316
316
        this->AddToList();
317
317
 
336
336
gZone::gZone( nMessage & m )
337
337
:eNetGameObject( m ), rotation_(1,0)
338
338
{
339
 
    destroyed_ = false;
 
339
    destroyed_ = false;
340
340
    zoneInit_ = false;
341
 
    dynamicCreation_ = false;
 
341
    dynamicCreation_ = false;
342
342
    delayCreation_ = false;
343
343
    wallInteract_ = false;
344
 
    wallBouncesLeft_ = 0;
 
344
    wallBouncesLeft_ = 0;
345
345
    wallPenetrate_ = false;
346
346
    lastImpactTime_ = 0;
347
347
    targetRadius_ = 0;
351
351
    pOwner_ = NULL;
352
352
    pSeekingCycle_ = NULL;
353
353
    seeking_ = false;
354
 
    name_ = tString("");
 
354
    name_ = tString("");
355
355
    effect_ = tString("");
356
356
 
357
357
    // read creation time
359
359
    referenceTime_ = lastTime = createTime_;
360
360
 
361
361
    // initialize color to white, ReadSync will fill in the true value if available
362
 
    color_.r = color_.g = color_.b = 1.0f;
363
 
 
 
362
    color_.r = color_.g = color_.b = 1.0f;
 
363
 
364
364
    // set fixed values
365
365
    SetRotationSpeed( .3f );
366
366
    SetRotationAcceleration( 0.0f );
367
367
 
368
 
    // add to game grid
 
368
    // add to game grid
369
369
    if(!delayCreation_)
370
370
        this->AddToList();
371
371
 
520
520
    {
521
521
        Zone->SetWallInteract(true);
522
522
        Zone->SetWallBouncesLeft(-1);
523
 
    }
524
 
    if (zonePenetrate)
525
 
    {
526
 
        Zone->SetWallPenetrate(true);
 
523
    }
 
524
    if (zonePenetrate)
 
525
    {
 
526
        Zone->SetWallPenetrate(true);
527
527
    }
528
528
    if(targetRadius != 0)
529
529
    {
541
541
    gSumoZoneHack *thisSumoZone = dynamic_cast<gSumoZoneHack *>(Zone);
542
542
    if(thisSumoZone){
543
543
        thisSumoZone->SetUnspawnedState();
544
 
    }
545
 
 
546
 
    Zone->SetEffect(zoneEffect);
 
544
    }
 
545
 
 
546
    Zone->SetEffect(zoneEffect);
547
547
 
548
548
    Zone->RequestSync();
549
549
 
718
718
    SetVelocity(V);
719
719
    SetPosition(P);
720
720
    RequestSync();
721
 
}
722
 
 
 
721
}
 
722
 
723
723
// *******************************************************************************
724
724
// *
725
725
// *    Collapse
726
726
// *
727
 
// *******************************************************************************
728
 
 
729
 
void gZone::Collapse()
730
 
{
731
 
    Vanish(-1);
732
 
    destroyed_ = true;
733
 
    SetReferenceTime();
734
 
    SetExpansionSpeed(-GetRadius());
 
727
// *******************************************************************************
 
728
 
 
729
void gZone::Collapse()
 
730
{
 
731
    Vanish(-1);
 
732
    destroyed_ = true;
 
733
    SetReferenceTime();
 
734
    SetExpansionSpeed(-GetRadius());
735
735
    SetRadius(0);
736
 
    RequestSync();
 
736
    RequestSync();
737
737
}
738
738
 
739
739
 
745
745
//!
746
746
//!     @param  time    the current time
747
747
//!
748
 
// *******************************************************************************
749
 
 
750
 
static bool sg_zoneWallDeath = false;
751
 
static tSettingItem<bool> sg_zoneWallDeathConf("ZONE_WALL_DEATH", sg_zoneWallDeath);
752
 
 
753
 
static REAL sg_zoneWallBoundary = -20.0;
754
 
bool restrictZoneBoundry(const REAL &newValue)
755
 
{
756
 
    //  we cannot have the boundry limit be greater than -1
757
 
    if (newValue > 0) return false;
758
 
    return true;
759
 
}
760
 
static tSettingItem<REAL> sg_zoneWallBoundaryConf("ZONE_WALL_BOUNDARY", sg_zoneWallBoundary, &restrictZoneBoundry);
761
 
 
 
748
// *******************************************************************************
 
749
 
 
750
static bool sg_zoneWallDeath = false;
 
751
static tSettingItem<bool> sg_zoneWallDeathConf("ZONE_WALL_DEATH", sg_zoneWallDeath);
 
752
 
 
753
static REAL sg_zoneWallBoundary = -20.0;
 
754
bool restrictZoneBoundry(const REAL &newValue)
 
755
{
 
756
    //  we cannot have the boundry limit be greater than -1
 
757
    if (newValue > 0) return false;
 
758
    return true;
 
759
}
 
760
static tSettingItem<REAL> sg_zoneWallBoundaryConf("ZONE_WALL_BOUNDARY", sg_zoneWallBoundary, &restrictZoneBoundry);
 
761
 
762
762
static eLadderLogWriter sg_OnlineZoneWriter("ONLINE_ZONE", false);
763
763
 
764
764
bool gZone::Timestep( REAL time )
772
772
        //??? game AND sync the last update on time.  Removing from game gets to
773
773
        //??? the client much later than the sync does if not killed and looks bad.
774
774
        return false;
775
 
    }
776
 
 
777
 
    if (!zoneInit_)
778
 
    {
779
 
        sg_OnlineZoneWriter << GOID() << name_ << effect_ << MapPosition().x << MapPosition().y << GetVelocity().x << GetVelocity().y
780
 
                            << GetRadius() << GetExpansionSpeed();
781
 
 
782
 
        zoneInit_ = true;
 
775
    }
 
776
 
 
777
    if (!zoneInit_)
 
778
    {
 
779
        sg_OnlineZoneWriter << GOID() << name_ << effect_ << MapPosition().x << MapPosition().y << GetVelocity().x << GetVelocity().y
 
780
                            << GetRadius() << GetExpansionSpeed();
 
781
 
 
782
        zoneInit_ = true;
783
783
    }
784
784
 
785
785
    bool doRequestSync = false;
868
868
            if (s_zoneWallInteractionFound)
869
869
            {
870
870
                if (wallBouncesLeft_ == 0)
871
 
                {
872
 
                    if ((wallPenetrate_ && !eWallRim::IsBound(GetPosition(), 0)) || (!wallPenetrate_))
 
871
                {
 
872
                    if ((wallPenetrate_ && !eWallRim::IsBound(GetPosition(), 0)) || (!wallPenetrate_))
873
873
                    {
874
874
                        // kill the zone as we hit a wall
875
875
                        //??? make kill code a common function
876
876
                        Collapse();
877
 
                        return false;
 
877
                        return false;
878
878
                    }
879
879
                }
880
880
                else
881
 
                {
882
 
                    if (wallPenetrate_ && !eWallRim::IsBound(GetPosition(), 0))
883
 
                    {
884
 
                        // bounce off wall
885
 
                        BounceOffPoint(GetPosition(), s_zoneWallInteractionImpactCoord);
886
 
                        lastImpactTime_ = time + s_zoneWallInteractionImpactTime;
887
 
 
888
 
                        if (wallBouncesLeft_ > 0)
889
 
                        {
890
 
                            wallBouncesLeft_--;
891
 
                        }
892
 
                    }
893
 
                    else
894
 
                    {
895
 
                        // bounce off wall
896
 
                        BounceOffPoint(GetPosition(), s_zoneWallInteractionImpactCoord);
897
 
                        lastImpactTime_ = time + s_zoneWallInteractionImpactTime;
898
 
 
899
 
                        if (wallBouncesLeft_ > 0)
900
 
                        {
901
 
                            wallBouncesLeft_--;
902
 
                        }
 
881
                {
 
882
                    if (wallPenetrate_ && !eWallRim::IsBound(GetPosition(), 0))
 
883
                    {
 
884
                        // bounce off wall
 
885
                        BounceOffPoint(GetPosition(), s_zoneWallInteractionImpactCoord);
 
886
                        lastImpactTime_ = time + s_zoneWallInteractionImpactTime;
 
887
 
 
888
                        if (wallBouncesLeft_ > 0)
 
889
                        {
 
890
                            wallBouncesLeft_--;
 
891
                        }
 
892
                    }
 
893
                    else
 
894
                    {
 
895
                        // bounce off wall
 
896
                        BounceOffPoint(GetPosition(), s_zoneWallInteractionImpactCoord);
 
897
                        lastImpactTime_ = time + s_zoneWallInteractionImpactTime;
 
898
 
 
899
                        if (wallBouncesLeft_ > 0)
 
900
                        {
 
901
                            wallBouncesLeft_--;
 
902
                        }
903
903
                    }
904
904
 
905
905
                    return false;
906
 
                }
 
906
                }
907
907
            }
908
908
 
909
909
            // only clip if zone is moving
927
927
                        //Don't allow going outside, kill it
928
928
                        Collapse();
929
929
                        return false;
930
 
                    }
931
 
 
932
 
                    gSoccerZoneHack *thisSockerBall = dynamic_cast<gSoccerZoneHack *>(this);
933
 
                    if (thisSockerBall && (thisSockerBall->GetType() == gSoccerZoneHack::gSoccer_BALL))
934
 
                    {
935
 
                        thisSockerBall->GoHome();
936
 
                    }
937
 
                    else
938
 
                    {
939
 
                        Collapse();
940
 
                        return false;
 
930
                    }
 
931
 
 
932
                    gSoccerZoneHack *thisSockerBall = dynamic_cast<gSoccerZoneHack *>(this);
 
933
                    if (thisSockerBall && (thisSockerBall->GetType() == gSoccerZoneHack::gSoccer_BALL))
 
934
                    {
 
935
                        thisSockerBall->GoHome();
 
936
                    }
 
937
                    else
 
938
                    {
 
939
                        Collapse();
 
940
                        return false;
941
941
                    }
942
942
                }
943
943
            }
944
 
        }
945
 
        else
946
 
        {
947
 
            if (sg_zoneWallDeath && !eWallRim::IsBound(GetPosition(), sg_zoneWallBoundary))
948
 
            {
949
 
                Collapse();
950
 
                return false;
951
 
            }
 
944
        }
 
945
        else
 
946
        {
 
947
            if (sg_zoneWallDeath && !eWallRim::IsBound(GetPosition(), sg_zoneWallBoundary))
 
948
            {
 
949
                Collapse();
 
950
                return false;
 
951
            }
952
952
        }
953
953
 
954
954
        if(!route_.empty() && time >= nextUpdate_)
991
991
            SetExpansionSpeed( -fallSpeed_ );
992
992
            targetRadius_ = 0;
993
993
            doRequestSync = true;
994
 
        }
995
 
 
996
 
        if (seeking_)
997
 
        {
 
994
        }
 
995
 
 
996
        if (seeking_)
 
997
        {
998
998
            if ((!pSeekingCycle_) || (!pSeekingCycle_->Player()) || (!pSeekingCycle_->Alive()))
999
999
            {
1000
1000
                //Seeking cycle is gone, shrink
1002
1002
                SetReferenceTime();
1003
1003
                SetExpansionSpeed( -GetRadius()*1 );
1004
1004
                targetRadius_ = 0;
1005
 
                seeking_ = false;
1006
 
 
 
1005
                seeking_ = false;
 
1006
 
1007
1007
                doRequestSync = true;
1008
 
            }
 
1008
            }
1009
1009
        }
1010
1010
 
1011
1011
        if (doRequestSync)
1029
1029
 
1030
1030
void gZone::OnVanish( void )
1031
1031
{
1032
 
}
1033
 
 
 
1032
}
 
1033
 
1034
1034
// *******************************************************************************
1035
1035
// *
1036
1036
// *    TriggerAvoidZone
1041
1041
//!     @param  zone          the zone player is getting near
1042
1042
//!     @param  time          the current time
1043
1043
//!
1044
 
// *******************************************************************************
1045
 
 
1046
 
bool sg_cyclesZonesAvoid = false;
1047
 
static tSettingItem<bool> sg_cyclesZonesAvoidConf("CYCLE_ZONES_AVOID", sg_cyclesZonesAvoid);
1048
 
 
1049
 
REAL sg_cycleZonesApproch = 100.0;
1050
 
static tSettingItem<REAL>sg_cycleZoneApprochConf("CYCLE_ZONES_APPROCH", sg_cycleZonesApproch);
1051
 
 
1052
 
static void TriggerAvoidZone(gCycle *target, gZone *Zone, REAL currentTime)
1053
 
{
1054
 
    //  don't execute if players won't want to avoid zones
1055
 
    if (!sg_cyclesZonesAvoid)
1056
 
        return;
1057
 
 
1058
 
    eGrid *grid = eGrid::CurrentGrid();
1059
 
    if (!grid) return;
1060
 
 
1061
 
    ePlayerNetID *player = target->Player();
1062
 
    if ((player->IsChatting()) && (player->IsActive()) || (!player->IsHuman()))
1063
 
    {
1064
 
        REAL tarX = target->Position().x;
1065
 
        REAL tarY = target->Position().y;
1066
 
        REAL zonX = Zone->Position().x;
1067
 
        REAL zonY = Zone->Position().y;
1068
 
 
1069
 
        REAL tarDirX = target->Direction().x;
1070
 
        REAL tarDirY = target->Direction().y;
1071
 
 
1072
 
        if ((tarX == zonX) || (tarY == zonY))
1073
 
        {
1074
 
            target->Act(&gCycle::se_turnRight, 1);
1075
 
        }
1076
 
 
1077
 
        if (tarDirX >= 0)
1078
 
        {
1079
 
            if (tarX < zonX)
1080
 
            {
1081
 
                if (tarY < zonY)
1082
 
                    target->Act(&gCycle::se_turnRight, 1);
1083
 
                else
1084
 
                    target->Act(&gCycle::se_turnLeft, 1);
1085
 
            }
1086
 
        }
1087
 
        else if (tarDirX <= -0.01)
1088
 
        {
1089
 
            if (tarX > zonX)
1090
 
            {
1091
 
                if (tarY < zonY)
1092
 
                    target->Act(&gCycle::se_turnLeft, 1);
1093
 
                else
1094
 
                    target->Act(&gCycle::se_turnRight, 1);
1095
 
            }
1096
 
        }
1097
 
        if (tarDirY >= 0)
1098
 
        {
1099
 
            if (tarY < zonY)
1100
 
            {
1101
 
                if (tarX < zonX)
1102
 
                    target->Act(&gCycle::se_turnLeft, 1);
1103
 
                else
1104
 
                    target->Act(&gCycle::se_turnRight, 1);
1105
 
            }
1106
 
        }
1107
 
        else if (tarDirY <= -0.01)
1108
 
        {
1109
 
            if (tarY > zonY)
1110
 
            {
1111
 
                if (tarX < zonX)
1112
 
                    target->Act(&gCycle::se_turnRight, 1);
1113
 
                else
1114
 
                    target->Act(&gCycle::se_turnLeft, 1);
1115
 
            }
1116
 
        }
1117
 
    }
1118
 
 
1119
 
    //  if all fails, cycle will enter the zone
 
1044
// *******************************************************************************
 
1045
 
 
1046
bool sg_cyclesZonesAvoid = false;
 
1047
static tSettingItem<bool> sg_cyclesZonesAvoidConf("CYCLE_ZONES_AVOID", sg_cyclesZonesAvoid);
 
1048
 
 
1049
REAL sg_cycleZonesApproch = 100.0;
 
1050
static tSettingItem<REAL>sg_cycleZoneApprochConf("CYCLE_ZONES_APPROCH", sg_cycleZonesApproch);
 
1051
 
 
1052
static void TriggerAvoidZone(gCycle *target, gZone *Zone, REAL currentTime)
 
1053
{
 
1054
    //  don't execute if players won't want to avoid zones
 
1055
    if (!sg_cyclesZonesAvoid)
 
1056
        return;
 
1057
 
 
1058
    eGrid *grid = eGrid::CurrentGrid();
 
1059
    if (!grid) return;
 
1060
 
 
1061
    ePlayerNetID *player = target->Player();
 
1062
    if ((player->IsChatting()) && (player->IsActive()) || (!player->IsHuman()))
 
1063
    {
 
1064
        REAL tarX = target->Position().x;
 
1065
        REAL tarY = target->Position().y;
 
1066
        REAL zonX = Zone->Position().x;
 
1067
        REAL zonY = Zone->Position().y;
 
1068
 
 
1069
        REAL tarDirX = target->Direction().x;
 
1070
        REAL tarDirY = target->Direction().y;
 
1071
 
 
1072
        if ((tarX == zonX) || (tarY == zonY))
 
1073
        {
 
1074
            target->Act(&gCycle::se_turnRight, 1);
 
1075
        }
 
1076
 
 
1077
        if (tarDirX >= 0)
 
1078
        {
 
1079
            if (tarX < zonX)
 
1080
            {
 
1081
                if (tarY < zonY)
 
1082
                    target->Act(&gCycle::se_turnRight, 1);
 
1083
                else
 
1084
                    target->Act(&gCycle::se_turnLeft, 1);
 
1085
            }
 
1086
        }
 
1087
        else if (tarDirX <= -0.01)
 
1088
        {
 
1089
            if (tarX > zonX)
 
1090
            {
 
1091
                if (tarY < zonY)
 
1092
                    target->Act(&gCycle::se_turnLeft, 1);
 
1093
                else
 
1094
                    target->Act(&gCycle::se_turnRight, 1);
 
1095
            }
 
1096
        }
 
1097
        if (tarDirY >= 0)
 
1098
        {
 
1099
            if (tarY < zonY)
 
1100
            {
 
1101
                if (tarX < zonX)
 
1102
                    target->Act(&gCycle::se_turnLeft, 1);
 
1103
                else
 
1104
                    target->Act(&gCycle::se_turnRight, 1);
 
1105
            }
 
1106
        }
 
1107
        else if (tarDirY <= -0.01)
 
1108
        {
 
1109
            if (tarY > zonY)
 
1110
            {
 
1111
                if (tarX < zonX)
 
1112
                    target->Act(&gCycle::se_turnRight, 1);
 
1113
                else
 
1114
                    target->Act(&gCycle::se_turnLeft, 1);
 
1115
            }
 
1116
        }
 
1117
    }
 
1118
 
 
1119
    //  if all fails, cycle will enter the zone
1120
1120
}
1121
1121
 
1122
1122
 
1137
1137
    gCycle* prey = dynamic_cast< gCycle* >( target );
1138
1138
    if ( prey )
1139
1139
    {
1140
 
        REAL r = this->Radius();
1141
 
        if (((prey->Position() - this->Position()).NormSquared() > r*r) && ((prey->Position() - this->Position()).NormSquared() < ((r*r) + (sg_cycleZonesApproch * 2))))
1142
 
        {
1143
 
            TriggerAvoidZone(prey, this, time);
1144
 
            OnNear(prey, time);
 
1140
        REAL r = this->Radius();
 
1141
        if (((prey->Position() - this->Position()).NormSquared() > r*r) && ((prey->Position() - this->Position()).NormSquared() < ((r*r) + (sg_cycleZonesApproch * 2))))
 
1142
        {
 
1143
            TriggerAvoidZone(prey, this, time);
 
1144
            OnNear(prey, time);
1145
1145
        }
1146
1146
        else if ( ( prey->Position() - this->Position() ).NormSquared() < r*r )
1147
1147
        {
1148
1148
            if ( prey->Player() && prey->Alive() )
1149
1149
            {
1150
 
                OnEnter( prey, time );
1151
 
                if (!isInside(prey)) // make sure this cycle isn't in zone already
1152
 
                {
1153
 
                    //  if not, then add them to the list
1154
 
                    AddPlayerInteraction(prey);
 
1150
                OnEnter( prey, time );
 
1151
                if (!isInside(prey)) // make sure this cycle isn't in zone already
 
1152
                {
 
1153
                    //  if not, then add them to the list
 
1154
                    AddPlayerInteraction(prey);
1155
1155
                }
1156
1156
            }
1157
 
        }
1158
 
        else
1159
 
        {
1160
 
            if (isInside(prey)) // make sure this cycle already is within the zone
1161
 
            {
1162
 
                OnExit(prey, time); // call the OnExit event
1163
 
                RemovePlayerInteraction(prey);  // remove them from the list
1164
 
            }
 
1157
        }
 
1158
        else
 
1159
        {
 
1160
            if (isInside(prey)) // make sure this cycle already is within the zone
 
1161
            {
 
1162
                OnExit(prey, time); // call the OnExit event
 
1163
                RemovePlayerInteraction(prey);  // remove them from the list
 
1164
            }
1165
1165
        }
1166
1166
    }
1167
1167
    else
1298
1298
                    }
1299
1299
                }
1300
1300
            }
1301
 
        }
1302
 
 
 
1301
        }
 
1302
 
1303
1303
        gSoccerZoneHack *gSoccerZone = dynamic_cast<gSoccerZoneHack *>(this);
1304
1304
        if (gSoccerZone)
1305
1305
        {
1308
1308
            {
1309
1309
                REAL dis = this->Radius() + gNormalZone->Radius();
1310
1310
                if ( ( gNormalZone->Position() - this->Position() ).NormSquared() < (dis * dis) )
1311
 
                {
1312
 
                    gSoccerZone->OnEnter(gNormalZone, time);
1313
 
                }
1314
 
            }
1315
 
        }
1316
 
 
 
1311
                {
 
1312
                    gSoccerZone->OnEnter(gNormalZone, time);
 
1313
                }
 
1314
            }
 
1315
        }
 
1316
 
1317
1317
        gObjectZoneHack *gObjectZone = dynamic_cast<gObjectZoneHack *>(this);
1318
1318
        if (gObjectZone)
1319
1319
        {
1322
1322
            {
1323
1323
                REAL dis = this->Radius() + gNormalZone->Radius();
1324
1324
                if ( ( gNormalZone->Position() - this->Position() ).NormSquared() < (dis * dis) )
1325
 
                {
1326
 
                    gObjectZone->OnEnter(gNormalZone, time);
1327
 
                }
1328
 
            }
 
1325
                {
 
1326
                    gObjectZone->OnEnter(gNormalZone, time);
 
1327
                }
 
1328
            }
1329
1329
        }
1330
1330
    }
1331
1331
}
1360
1360
 
1361
1361
void gZone::OnEnter( gZone * target, REAL time )
1362
1362
{
1363
 
}
1364
 
 
 
1363
}
 
1364
 
1365
1365
// *******************************************************************************
1366
1366
// *
1367
1367
// *    OnExit
1375
1375
 
1376
1376
void gZone::OnExit( gCycle *target, REAL time )
1377
1377
{
1378
 
}
1379
 
 
 
1378
}
 
1379
 
1380
1380
// *******************************************************************************
1381
1381
// *
1382
1382
// *    OnExit
1391
1391
void gZone::OnExit( gZone *target, REAL time )
1392
1392
{
1393
1393
}
1394
 
 
 
1394
 
1395
1395
// *******************************************************************************
1396
1396
// *
1397
1397
// *    OnNear
1405
1405
 
1406
1406
void gZone::OnNear( gCycle *target, REAL time )
1407
1407
{
1408
 
}
1409
 
 
 
1408
}
 
1409
 
1410
1410
// *******************************************************************************
1411
1411
// *
1412
1412
// *    OnNear
1476
1476
 
1477
1477
// extra alpha blending factors
1478
1478
static REAL sg_zoneAlpha = 1.0, sg_zoneAlphaServer = 1.0;
1479
 
static tConfItem< REAL > sg_zoneAlphaConf( "ZONE_ALPHA", sg_zoneAlpha );
 
1479
static tSettingItem< REAL > sg_zoneAlphaConf( "ZONE_ALPHA", sg_zoneAlpha );
1480
1480
static nSettingItem< REAL > sg_zoneAlphaConfServer( "ZONE_ALPHA_SERVER", sg_zoneAlphaServer );
1481
1481
 
1482
1482
// *******************************************************************************
1489
1489
//!
1490
1490
// *******************************************************************************
1491
1491
 
1492
 
 
1493
 
//Do we want zones to fade in when the game starts?
1494
 
static bool sg_zoneFadeIn = true;
1495
 
static tConfItem<bool> sg_zoneFadeInConf( "ZONE_FADE_IN", sg_zoneFadeIn);
1496
 
 
1497
 
REAL alpha;
1498
1492
void gZone::Render( const eCamera * cam )
1499
1493
{
1500
1494
    #ifndef DEDICATED
1503
1497
    if ( sg_zoneSegments < 1 )
1504
1498
        sg_zoneSegments = 11;
1505
1499
 
1506
 
    if (sg_zoneFadeIn)
1507
 
    {
1508
 
        alpha = (lastTime - createTime_) * .2f;
1509
 
        if (alpha > .7f)
1510
 
            alpha = .7f;
1511
 
        if (alpha <= 0)
1512
 
            return;
1513
 
        alpha *= sg_zoneAlpha * sg_zoneAlphaServer;
1514
 
    }
1515
 
    else
1516
 
    {
1517
 
        alpha = sg_zoneAlpha * sg_zoneAlphaServer;
1518
 
    }
 
1500
    REAL alpha = ( lastTime - createTime_ ) * .2f;
 
1501
    if ( alpha > .7f )
 
1502
    alpha = .7f;
 
1503
    if ( alpha <= 0 )
 
1504
        return;
 
1505
    alpha *= sg_zoneAlpha * sg_zoneAlphaServer;
1519
1506
 
1520
1507
        ModelMatrix();
1521
1508
    glPushMatrix();
1644
1631
bool gZone::RendersAlpha() const
1645
1632
{
1646
1633
    return sr_alphaBlend ? !sg_zoneAlphaToggle : sg_zoneAlphaToggle;
1647
 
}
1648
 
 
1649
 
// *******************************************************************************
1650
 
// *
1651
 
// *    Vanish
1652
 
// *
1653
 
// *******************************************************************************
1654
 
//!
1655
 
//!             @param  factor vanishing speed factor
1656
 
//!
1657
 
// *******************************************************************************
1658
 
 
1659
 
void gZone::Vanish( REAL factor )
1660
 
{
1661
 
    if ( GetExpansionSpeed() >= 0 )
1662
 
    {
1663
 
        SetReferenceTime();
1664
 
        SetExpansionSpeed( -GetRadius() * factor );
1665
 
        SetTargetRadius(0);
1666
 
        RequestSync();
1667
 
    }
1668
 
}
1669
 
 
1670
 
// *******************************************************************************
1671
 
// *
1672
 
// *    Win Zone Color Commands
 
1634
}
 
1635
 
 
1636
// *******************************************************************************
 
1637
// *
 
1638
// *    Vanish
 
1639
// *
 
1640
// *******************************************************************************
 
1641
//!
 
1642
//!             @param  factor vanishing speed factor
 
1643
//!
 
1644
// *******************************************************************************
 
1645
 
 
1646
void gZone::Vanish( REAL factor )
 
1647
{
 
1648
    if ( GetExpansionSpeed() >= 0 )
 
1649
    {
 
1650
        SetReferenceTime();
 
1651
        SetExpansionSpeed( -GetRadius() * factor );
 
1652
        SetTargetRadius(0);
 
1653
        RequestSync();
 
1654
    }
 
1655
}
 
1656
 
 
1657
// *******************************************************************************
 
1658
// *
 
1659
// *    Win Zone Color Commands
1673
1660
// *    Death Zone Color Commands
1674
1661
// *
1675
1662
// *******************************************************************************
1676
1663
//!
1677
1664
//!     @return True if alpha blending is used
1678
1665
//!
1679
 
// *******************************************************************************
1680
 
static int sg_ColorWinZoneRed = 0;
1681
 
static tSettingItem<int> sg_ColorWinZoneRedCONF("COLOR_WINZONE_RED", sg_ColorWinZoneRed);
1682
 
 
1683
 
static int sg_ColorWinZoneBlue = 0;
1684
 
static tSettingItem<int> sg_ColorWinZoneBlueCONF("COLOR_WINZONE_BLUE", sg_ColorWinZoneBlue);
1685
 
 
1686
 
static int sg_ColorWinZoneGreen = 15;
1687
 
static tSettingItem<int> sg_ColorWinZoneGreenCONF("COLOR_WINZONE_GREEN", sg_ColorWinZoneGreen);
1688
 
 
1689
 
static int sg_ColorDeathZoneRed = 15;
1690
 
static tSettingItem<int> sg_ColorDeathZoneRedCONF("COLOR_DEATHZONE_RED", sg_ColorDeathZoneRed);
1691
 
 
1692
 
static int sg_ColorDeathZoneBlue = 0;
1693
 
static tSettingItem<int> sg_ColorDeathZoneBlueCONF("COLOR_DEATHZONE_BLUE", sg_ColorDeathZoneBlue);
1694
 
 
1695
 
static int sg_ColorDeathZoneGreen = 0;
 
1666
// *******************************************************************************
 
1667
static int sg_ColorWinZoneRed = 0;
 
1668
static tSettingItem<int> sg_ColorWinZoneRedCONF("COLOR_WINZONE_RED", sg_ColorWinZoneRed);
 
1669
 
 
1670
static int sg_ColorWinZoneBlue = 0;
 
1671
static tSettingItem<int> sg_ColorWinZoneBlueCONF("COLOR_WINZONE_BLUE", sg_ColorWinZoneBlue);
 
1672
 
 
1673
static int sg_ColorWinZoneGreen = 15;
 
1674
static tSettingItem<int> sg_ColorWinZoneGreenCONF("COLOR_WINZONE_GREEN", sg_ColorWinZoneGreen);
 
1675
 
 
1676
static int sg_ColorDeathZoneRed = 15;
 
1677
static tSettingItem<int> sg_ColorDeathZoneRedCONF("COLOR_DEATHZONE_RED", sg_ColorDeathZoneRed);
 
1678
 
 
1679
static int sg_ColorDeathZoneBlue = 0;
 
1680
static tSettingItem<int> sg_ColorDeathZoneBlueCONF("COLOR_DEATHZONE_BLUE", sg_ColorDeathZoneBlue);
 
1681
 
 
1682
static int sg_ColorDeathZoneGreen = 0;
1696
1683
static tSettingItem<int> sg_ColorDeathZoneGreenCONF("COLOR_DEATHZONE_GREEN", sg_ColorDeathZoneGreen);
1697
1684
 
1698
1685
// *******************************************************************************
1705
1692
//!     @param  pos  Position to spawn the zone at
1706
1693
//!
1707
1694
// *******************************************************************************
1708
 
 
1709
 
 
 
1695
 
 
1696
 
1710
1697
gWinZoneHack::gWinZoneHack( eGrid * grid, const eCoord & pos, bool dynamicCreation, bool delayCreation)
1711
1698
:gZone( grid, pos, dynamicCreation, delayCreation)
1712
 
{
1713
 
    if (sg_SwapWinDeath == false)
 
1699
{
 
1700
    if (sg_SwapWinDeath == false)
1714
1701
    {
1715
1702
        color_.r = sg_ColorWinZoneRed / 15.0f;//0.0f;
1716
1703
        color_.b = sg_ColorWinZoneBlue / 15.0f;//1.0f;
1717
 
        color_.g = sg_ColorWinZoneGreen / 15.0f;//0.0f;
1718
 
    }
1719
 
    else
1720
 
    {
 
1704
        color_.g = sg_ColorWinZoneGreen / 15.0f;//0.0f;
 
1705
    }
 
1706
    else
 
1707
    {
1721
1708
        color_.r = sg_ColorDeathZoneRed / 15.0f;//1.0f;
1722
1709
        color_.b = sg_ColorDeathZoneBlue / 15.0f;//0.0f;
1723
 
        color_.g = sg_ColorDeathZoneGreen / 15.0f;//0.0f;
 
1710
        color_.g = sg_ColorDeathZoneGreen / 15.0f;//0.0f;
1724
1711
    }
1725
1712
}
1726
1713
 
1767
1754
//!
1768
1755
// *******************************************************************************
1769
1756
 
1770
 
static eLadderLogWriter sg_winzonePlayerEnterWriter("WINZONE_PLAYER_ENTER", true);
1771
 
 
1772
 
bool sg_winZonePlayerEnteredWin = true;
 
1757
static eLadderLogWriter sg_winzonePlayerEnterWriter("WINZONE_PLAYER_ENTER", true);
 
1758
 
 
1759
bool sg_winZonePlayerEnteredWin = true;
1773
1760
static tSettingItem<bool> sg_winZonePlayerEnteredWinConf("WINZONE_PLAYER_ENTER_WIN", sg_winZonePlayerEnteredWin);
1774
1761
 
1775
1762
void gWinZoneHack::OnEnter( gCycle * target, REAL time )
1776
 
{
 
1763
{
1777
1764
    sg_winzonePlayerEnterWriter << this->GOID() << name_ << MapPosition().x << MapPosition().y << target->Player()->GetUserName() << target->MapPosition().x << target->MapPosition().y << target->MapDirection().x << target->MapDirection().y << time;
1778
 
    sg_winzonePlayerEnterWriter.write();
1779
 
 
1780
 
    //HACK RACE begin
1781
 
    if ( sg_RaceTimerEnabled )
1782
 
    {
1783
 
        gRace::ZoneHit( target->Player(), time );
1784
 
    }
1785
 
    else
1786
 
    {
1787
 
        if (sg_winZonePlayerEnteredWin)
1788
 
        {
1789
 
            if (!winnerPlayer_)
1790
 
            {
1791
 
                LogWinnerCycleTurns(target);
1792
 
                winnerPlayer_ = true;
1793
 
            }
1794
 
 
1795
 
            static const char* message="$player_win_instant";
1796
 
            sg_DeclareWinner( target->Player()->CurrentTeam(), message );
1797
 
            destroyed_ = true;
1798
 
            Vanish( 0.5 );
1799
 
        }
1800
 
    }
 
1765
    sg_winzonePlayerEnterWriter.write();
 
1766
 
 
1767
    //HACK RACE begin
 
1768
    if ( sg_RaceTimerEnabled )
 
1769
    {
 
1770
        gRace::ZoneHit( target->Player(), time );
 
1771
    }
 
1772
    else
 
1773
    {
 
1774
        if (sg_winZonePlayerEnteredWin)
 
1775
        {
 
1776
            if (!winnerPlayer_)
 
1777
            {
 
1778
                LogWinnerCycleTurns(target);
 
1779
                winnerPlayer_ = true;
 
1780
            }
 
1781
 
 
1782
            static const char* message="$player_win_instant";
 
1783
            sg_DeclareWinner( target->Player()->CurrentTeam(), message );
 
1784
            destroyed_ = true;
 
1785
            Vanish( 0.5 );
 
1786
        }
 
1787
    }
1801
1788
    //HACK RACE end
1802
1789
}
1803
 
 
1804
 
void gWinZoneHack::OnExit( gCycle *target, REAL time )
1805
 
{
1806
 
    if (sg_RaceTimerEnabled)
1807
 
    {
1808
 
        gRace::ZoneOut( target->Player(), time );
1809
 
    }
1810
 
}
 
1790
 
 
1791
void gWinZoneHack::OnExit( gCycle *target, REAL time )
 
1792
{
 
1793
    if (sg_RaceTimerEnabled)
 
1794
    {
 
1795
        gRace::ZoneOut( target->Player(), time );
 
1796
    }
 
1797
}
1811
1798
 
1812
1799
 
1813
1800
// *******************************************************************************
1819
1806
//!     @param  grid Grid to put the zone into
1820
1807
//!     @param  pos  Position to spawn the zone at
1821
1808
//!
1822
 
// *******************************************************************************
1823
 
 
1824
 
bool sg_deathZoneRandomColors = false;
1825
 
static tSettingItem<bool> sg_deathZoneRandomColorsConf("DEATHZONE_RANDOM_COLORS", sg_deathZoneRandomColors);
1826
 
 
1827
 
bool sg_deathZoneRotation = false;
1828
 
static tSettingItem<bool> sg_deathZoneRotationConf("DEATHZONE_ROTATION", sg_deathZoneRotation);
1829
 
 
1830
 
REAL sg_deathZoneRotationSpeed = 0.3f;
1831
 
static tSettingItem<REAL> sg_deathZoneRotationSpeedConf("DEATHZONE_ROTATION_SPEED", sg_deathZoneRotationSpeed);
 
1809
// *******************************************************************************
 
1810
 
 
1811
bool sg_deathZoneRandomColors = false;
 
1812
static tSettingItem<bool> sg_deathZoneRandomColorsConf("DEATHZONE_RANDOM_COLORS", sg_deathZoneRandomColors);
 
1813
 
 
1814
bool sg_deathZoneRotation = false;
 
1815
static tSettingItem<bool> sg_deathZoneRotationConf("DEATHZONE_ROTATION", sg_deathZoneRotation);
 
1816
 
 
1817
REAL sg_deathZoneRotationSpeed = 0.3f;
 
1818
static tSettingItem<REAL> sg_deathZoneRotationSpeedConf("DEATHZONE_ROTATION_SPEED", sg_deathZoneRotationSpeed);
1832
1819
 
1833
1820
gDeathZoneHack::gDeathZoneHack( eGrid * grid, const eCoord & pos, bool dynamicCreation, eTeam * teamowner, bool delayCreation )
1834
1821
:gZone( grid, pos, dynamicCreation, delayCreation )
1835
1822
{
1836
1823
    pLastShotCollision = NULL;
1837
 
 
1838
 
    if (!sg_deathZoneRandomColors)
1839
 
    {
1840
 
        if (sg_SwapWinDeath == false)
 
1824
 
 
1825
    if (!sg_deathZoneRandomColors)
 
1826
    {
 
1827
        if (sg_SwapWinDeath == false)
1841
1828
        {
1842
1829
            color_.r = sg_ColorDeathZoneRed / 15.0f;//1.0f;
1843
1830
            color_.b = sg_ColorDeathZoneBlue / 15.0f;//0.0f;
1844
 
            color_.g = sg_ColorDeathZoneGreen / 15.0f;//0.0f;
1845
 
        }
1846
 
        else
1847
 
        {
 
1831
            color_.g = sg_ColorDeathZoneGreen / 15.0f;//0.0f;
 
1832
        }
 
1833
        else
 
1834
        {
1848
1835
            color_.r = sg_ColorWinZoneRed / 15.0f;//0.0f;
1849
1836
            color_.b = sg_ColorWinZoneBlue / 15.0f;//1.0f;
1850
 
            color_.g = sg_ColorWinZoneGreen / 15.0f;//0.0f;
1851
 
        }
1852
 
    }
1853
 
    else
1854
 
    {
1855
 
        tRandomizer &randomizer = tRandomizer::GetInstance();
1856
 
        REAL colorR = randomizer.Get(16) / 15.0f;
1857
 
        REAL colorG = randomizer.Get(16) / 15.0f;
1858
 
        REAL colorB = randomizer.Get(16) / 15.0f;
1859
 
 
1860
 
        color_.r = colorR;
1861
 
        color_.b = colorG;
1862
 
        color_.g = colorB;
1863
 
    }
1864
 
 
1865
 
    if (sg_deathZoneRotation)
 
1837
            color_.g = sg_ColorWinZoneGreen / 15.0f;//0.0f;
 
1838
        }
 
1839
    }
 
1840
    else
 
1841
    {
 
1842
        tRandomizer &randomizer = tRandomizer::GetInstance();
 
1843
        REAL colorR = randomizer.Get(16) / 15.0f;
 
1844
        REAL colorG = randomizer.Get(16) / 15.0f;
 
1845
        REAL colorB = randomizer.Get(16) / 15.0f;
 
1846
 
 
1847
        color_.r = colorR;
 
1848
        color_.b = colorG;
 
1849
        color_.g = colorB;
 
1850
    }
 
1851
 
 
1852
    if (sg_deathZoneRotation)
1866
1853
        SetRotationSpeed(sg_deathZoneRotationSpeed);
1867
1854
 
1868
 
    if (teamowner!=NULL)
1869
 
    {
1870
 
        team = teamowner;
1871
 
        deathZoneType = TYPE_TEAM;
1872
 
    }
1873
 
    else
1874
 
    {
1875
 
        deathZoneType = TYPE_NORMAL;
1876
 
    }
1877
 
 
 
1855
    if (teamowner!=NULL)
 
1856
    {
 
1857
        team = teamowner;
 
1858
        deathZoneType = TYPE_TEAM;
 
1859
    }
 
1860
    else
 
1861
    {
 
1862
        deathZoneType = TYPE_NORMAL;
 
1863
    }
 
1864
 
1878
1865
    if (!delayCreation)
1879
1866
        grid->AddGameObjectInteresting(this);
1880
1867
}
1889
1876
//!     @param  m Message to read creation data from
1890
1877
//!     @param  null
1891
1878
//!
1892
 
// *******************************************************************************
1893
 
 
 
1879
// *******************************************************************************
 
1880
 
1894
1881
 
1895
1882
 
1896
1883
gDeathZoneHack::gDeathZoneHack( nMessage & m )
1897
1884
: gZone( m )
1898
1885
{
1899
1886
    deathZoneType = TYPE_NORMAL;
1900
 
    pLastShotCollision = NULL;
1901
 
 
1902
 
    if (sg_deathZoneRotation)
 
1887
    pLastShotCollision = NULL;
 
1888
 
 
1889
    if (sg_deathZoneRotation)
1903
1890
        SetRotationSpeed(sg_deathZoneRotationSpeed);
1904
1891
}
1905
1892
 
1920
1907
        pLastShotCollision->pLastShotCollision = NULL;
1921
1908
        pLastShotCollision = NULL;
1922
1909
    }
1923
 
}
1924
 
 
1925
 
bool gDeathZoneHack::Timestep(REAL time)
1926
 
{
 
1910
}
 
1911
 
 
1912
bool gDeathZoneHack::Timestep(REAL time)
 
1913
{
1927
1914
    // delegate
1928
 
    bool returnStatus = gZone::Timestep( time );
1929
 
 
 
1915
    bool returnStatus = gZone::Timestep( time );
 
1916
 
1930
1917
    if (seeking_)
1931
1918
    {
1932
1919
        //Only run this every poll time to save on network traffic
1944
1931
 
1945
1932
            RequestSync();
1946
1933
        }
1947
 
    }
1948
 
 
1949
 
    return returnStatus;
 
1934
    }
 
1935
 
 
1936
    return returnStatus;
1950
1937
}
1951
1938
 
1952
1939
 
1953
1940
static int score_deathzone=-1;
1954
 
static tSettingItem<int> s_dz("SCORE_DEATHZONE",score_deathzone);
1955
 
static int score_deathzone_team=-1;
 
1941
static tSettingItem<int> s_dz("SCORE_DEATHZONE",score_deathzone);
 
1942
static int score_deathzone_team=-1;
1956
1943
static tSettingItem<int> s_dz_team("SCORE_DEATHZONE_TEAM",score_deathzone_team);
1957
1944
 
1958
1945
void gDeathZoneHack::OnVanish( void )
1984
1971
static tSettingItem<int> s_score_zombie_zone("SCORE_ZOMBIE_ZONE",score_zombie_zone);
1985
1972
 
1986
1973
static bool sg_shotKillSelf = false;
1987
 
static tSettingItem<bool> conf_shotKillSelf ("SHOT_KILL_SELF", sg_shotKillSelf);
1988
 
 
 
1974
static tSettingItem<bool> conf_shotKillSelf ("SHOT_KILL_SELF", sg_shotKillSelf);
 
1975
 
1989
1976
static bool sg_shotKillEnemies = true;
1990
1977
static tSettingItem<bool> conf_shotKillEnemies ("SHOT_KILL_ENEMIES", sg_shotKillEnemies);
1991
1978
 
2106
2093
static eLadderLogWriter sg_deathShotFragWriter("DEATH_SHOT_FRAG", true);
2107
2094
static eLadderLogWriter sg_deathShotSuicideWriter("DEATH_SHOT_SUICIDE", true);
2108
2095
static eLadderLogWriter sg_deathShotTeamkillWriter("DEATH_SHOT_TEAMKILL", true);
2109
 
static eLadderLogWriter sg_deathDeathZoneWriter("DEATH_DEATHZONE", true);
2110
 
static eLadderLogWriter sg_deathDeathZoneTeamWriter("DEATH_DEATHZONE_TEAM", false);
 
2096
static eLadderLogWriter sg_deathDeathZoneWriter("DEATH_DEATHZONE", true);
 
2097
static eLadderLogWriter sg_deathDeathZoneTeamWriter("DEATH_DEATHZONE_TEAM", false);
2111
2098
static eLadderLogWriter sg_deathZombieZoneWriter("DEATH_ZOMBIEZONE", true);
2112
2099
static eLadderLogWriter sg_deathDeathShotWriter("DEATH_DEATHSHOT", true);
2113
2100
static eLadderLogWriter sg_deathDeathSelfDestructWriter("DEATH_SELF_DESTRUCT", true);
2120
2107
        target->Kill();
2121
2108
        sg_deathDeathZoneWriter << target->Player()->GetUserName();
2122
2109
        sg_deathDeathZoneWriter.write();
2123
 
    }
 
2110
    }
2124
2111
    // check normal death zone linked to a team ...
2125
2112
    else if (team && deathZoneType == TYPE_TEAM)
2126
2113
    {
2128
2115
        {
2129
2116
            return;
2130
2117
        }
2131
 
        if (target->Player()->CurrentTeam() == team)
2132
 
        {
2133
 
            return;
2134
 
        }
2135
 
        else
2136
 
        {
 
2118
        if (target->Player()->CurrentTeam() == team)
 
2119
        {
 
2120
            return;
 
2121
        }
 
2122
        else
 
2123
        {
2137
2124
            target->Player()->AddScore(score_deathzone_team, "", "player_lose_deathzone_team");
2138
2125
            target->Kill();
2139
2126
            sg_deathDeathZoneTeamWriter << ePlayerNetID::FilterName( team->Name() ) << target->Player()->GetUserName();
2140
 
            sg_deathDeathZoneTeamWriter.write();
 
2127
            sg_deathDeathZoneTeamWriter.write();
2141
2128
        }
2142
2129
    }
2143
2130
    else
2184
2171
                }
2185
2172
            }
2186
2173
            else
2187
 
            {
2188
 
                if (!sg_shotKillEnemies)
2189
 
                    return;
 
2174
            {
 
2175
                if (!sg_shotKillEnemies)
 
2176
                    return;
2190
2177
 
2191
2178
                //The cycle may have been deleted since...  I think this is OK because Player() returns a checked pointer
2192
2179
 
2299
2286
 
2300
2287
        if (((deathZoneType == TYPE_ZOMBIE_ZONE) && ((!pSeekingCycle_) || (sg_zombieZoneVanish))) ||
2301
2288
            ((deathZoneType == TYPE_SELF_DESTRUCT) && (sg_selfDestructVanish)) ||
2302
 
            ((deathZoneType < TYPE_SELF_DESTRUCT) && (sg_shotKillVanish)) ||
 
2289
            ((deathZoneType < TYPE_SELF_DESTRUCT) && (sg_shotKillVanish)) ||
2303
2290
            ((deathZoneType == TYPE_SHOT && sg_shotKillEnemies)))
2304
2291
        {
2305
2292
#if 0
2484
2471
//!     @param  pos  Position to spawn the zone at
2485
2472
//!
2486
2473
// *******************************************************************************
2487
 
 
2488
 
static REAL sg_colorRubberZoneR = 15;
2489
 
static REAL sg_colorRubberZoneG = 10.5;
2490
 
static REAL sg_colorRubberZoneB = 3;
2491
 
static tSettingItem<REAL> sg_colorRubberZoneRConf("COLOR_RUBBERZONE_RED", sg_colorRubberZoneR);
2492
 
static tSettingItem<REAL> sg_colorRubberZoneGConf("COLOR_RUBBERZONE_GREEN", sg_colorRubberZoneG);
2493
 
static tSettingItem<REAL> sg_colorRubberZoneBConf("COLOR_RUBBERZONE_BLUE", sg_colorRubberZoneB);
 
2474
 
 
2475
static REAL sg_colorRubberZoneR = 15;
 
2476
static REAL sg_colorRubberZoneG = 10.5;
 
2477
static REAL sg_colorRubberZoneB = 3;
 
2478
static tSettingItem<REAL> sg_colorRubberZoneRConf("COLOR_RUBBERZONE_RED", sg_colorRubberZoneR);
 
2479
static tSettingItem<REAL> sg_colorRubberZoneGConf("COLOR_RUBBERZONE_GREEN", sg_colorRubberZoneG);
 
2480
static tSettingItem<REAL> sg_colorRubberZoneBConf("COLOR_RUBBERZONE_BLUE", sg_colorRubberZoneB);
2494
2481
 
2495
2482
gRubberZoneHack::gRubberZoneHack( eGrid * grid, const eCoord & pos, bool dynamicCreation, bool delayCreation)
2496
2483
:gZone( grid, pos, dynamicCreation, delayCreation)
2498
2485
    color_.r = sg_colorRubberZoneR / 15.0;
2499
2486
    color_.g = sg_colorRubberZoneG / 15.0;
2500
2487
    color_.b = sg_colorRubberZoneB / 15.0;
2501
 
 
 
2488
 
2502
2489
    if (!delayCreation)
2503
 
        grid->AddGameObjectInteresting(this);
2504
 
 
 
2490
        grid->AddGameObjectInteresting(this);
 
2491
 
2505
2492
    rmRubber = 1.0;
2506
2493
}
2507
2494
 
2529
2516
}
2530
2517
 
2531
2518
gZone & gRubberZoneHack::SetRubber(REAL rubber)
2532
 
{
2533
 
    rmRubber = rubber;
2534
 
 
2535
 
    if (rubberType_ == TYPE_RUBBER)
 
2519
{
 
2520
    rmRubber = rubber;
 
2521
 
 
2522
    if (rubberType_ == TYPE_RUBBER)
2536
2523
    {
2537
2524
        color_.r = 1.0f;
2538
2525
        REAL p_rubber = (1-(rmRubber/sg_rubberCycle));
2539
2526
        if (p_rubber <0)
2540
2527
            p_rubber=0;
2541
2528
        color_.g = (p_rubber);
2542
 
        color_.b = (p_rubber/3);
 
2529
        color_.b = (p_rubber/3);
2543
2530
    }
2544
2531
 
2545
2532
    return (*this);
2579
2566
//!     @brief    when DZ_RUBBER is not 0: change target's rubber instead of just killing
2580
2567
//!
2581
2568
// *******************************************************************************
2582
 
static eLadderLogWriter sg_deathRubberZoneWriter("DEATH_RUBBERZONE", true);
 
2569
static eLadderLogWriter sg_deathRubberZoneWriter("DEATH_RUBBERZONE", true);
2583
2570
 
2584
2571
void sg_RubberZoneHurt( gCycle * target, gRubberZoneHack *rubberZone)
2585
 
{
2586
 
    REAL rubber = target->GetRubber();
2587
 
    if (rubberZone->GetRubberType() == gRubberZoneHack::TYPE_RUBBER)
 
2572
{
 
2573
    REAL rubber = target->GetRubber();
 
2574
    if (rubberZone->GetRubberType() == gRubberZoneHack::TYPE_RUBBER)
2588
2575
    {
2589
2576
        if ( rubber + rubberZone->GetRubber() >= sg_rubberCycle )       // max rubber amount reached, kill the cycle
2590
2577
        {
2599
2586
            target->SetRubber( rubber + rubberZone->GetRubber() );
2600
2587
        }
2601
2588
        else                                                        // too low value, just set to zero
2602
 
            target->SetRubber( 0 );
2603
 
    }
2604
 
    else if (rubberZone->GetRubberType() == gRubberZoneHack::TYPE_ADJUST)
2605
 
    {
2606
 
        if (rubberZone->GetRubber() >= sg_rubberCycle)
2607
 
            rubberZone->SetRubber(sg_rubberCycle);
2608
 
 
2609
 
        target->SetRubber(rubberZone->GetRubber());
 
2589
            target->SetRubber( 0 );
 
2590
    }
 
2591
    else if (rubberZone->GetRubberType() == gRubberZoneHack::TYPE_ADJUST)
 
2592
    {
 
2593
        if (rubberZone->GetRubber() >= sg_rubberCycle)
 
2594
            rubberZone->SetRubber(sg_rubberCycle);
 
2595
 
 
2596
        target->SetRubber(rubberZone->GetRubber());
2610
2597
    }
2611
2598
}
2612
2599
 
2796
2783
 
2797
2784
 
2798
2785
static int sg_onSurviveScore = 0;
2799
 
static tSettingItem< int > sg_onSurviveConquestScoreConfig( "FORTRESS_HELD_SCORE", sg_onSurviveScore );
 
2786
static tSettingItem< int > sg_onSurviveConquestScoreConfig( "FORTRESS_HELD_SCORE", sg_onSurviveScore );
2800
2787
 
2801
2788
static REAL sg_collapseSpeed = .5;
2802
2789
static tSettingItem< REAL > sg_collapseSpeedConfig( "FORTRESS_COLLAPSE_SPEED", sg_collapseSpeed );
3444
3431
            int count = 0;
3445
3432
            CountZonesOfTeam( Grid(), team, count, farthest );
3446
3433
 
3447
 
            // discard team of farthest zone
 
3434
            // discard team of farthest zone
3448
3435
            // No NULL check is required here for farthest, since count is greater than 0 which implies farthest was set.
3449
3436
            if ( count > sg_baseZonesPerTeam )
3450
3437
            {
3700
3687
            }
3701
3688
        }
3702
3689
    }
3703
 
}
3704
 
 
 
3690
}
 
3691
 
3705
3692
// flag indicating whether base will respawn team if a team player's shot enters it
3706
3693
static bool sg_shotbaseRespawn = false;
3707
3694
static tSettingItem<bool> sg_shotBaseRespawnConfig ("SHOT_BASE_RESPAWN", sg_shotbaseRespawn);
3708
3695
 
3709
3696
// flag indicating whether base will respawn team if an enemy player's shot enters it
3710
3697
static bool sg_shotbaseEnemyRespawn = false;
3711
 
static tSettingItem<bool> sg_shotBaseEnemyRespawnConfig ("SHOT_BASE_ENEMY_RESPAWN", sg_shotbaseEnemyRespawn);
3712
 
 
3713
 
static int sg_scoreShotBase = 0;
 
3698
static tSettingItem<bool> sg_shotBaseEnemyRespawnConfig ("SHOT_BASE_ENEMY_RESPAWN", sg_shotbaseEnemyRespawn);
 
3699
 
 
3700
static int sg_scoreShotBase = 0;
3714
3701
static tSettingItem<int> sg_scoreShotBaseConf("SCORE_SHOT_BASE", sg_scoreShotBase);
3715
3702
 
3716
3703
 
3729
3716
{
3730
3717
                                 //it already hit the zone.
3731
3718
    if(currentState_ == State_Conquering || currentState_ == State_Conquered) return;
3732
 
    gBallZoneHack *ball = dynamic_cast<gBallZoneHack *>(target);
 
3719
    gBallZoneHack *ball = dynamic_cast<gBallZoneHack *>(target);
3733
3720
 
3734
3721
    // check ball team mode
3735
3722
    bool toScore;
3852
3839
                ball->GoHome();
3853
3840
            }
3854
3841
        }
3855
 
    }
3856
 
 
3857
 
    gDeathZoneHack *deathZone = dynamic_cast<gDeathZoneHack *>(target);
3858
 
    if (deathZone)
3859
 
    {
3860
 
        if (deathZone->GetType() == gDeathZoneHack::TYPE_SHOT)
3861
 
        {
3862
 
            ePlayerNetID *shotOwner = deathZone->GetOwner();
3863
 
            if (shotOwner && (((shotOwner->CurrentTeam() == team) && sg_shotbaseRespawn) || ((shotOwner->CurrentTeam() != team) && sg_shotbaseEnemyRespawn)))
3864
 
            {
 
3842
    }
 
3843
 
 
3844
    gDeathZoneHack *deathZone = dynamic_cast<gDeathZoneHack *>(target);
 
3845
    if (deathZone)
 
3846
    {
 
3847
        if (deathZone->GetType() == gDeathZoneHack::TYPE_SHOT)
 
3848
        {
 
3849
            ePlayerNetID *shotOwner = deathZone->GetOwner();
 
3850
            if (shotOwner && (((shotOwner->CurrentTeam() == team) && sg_shotbaseRespawn) || ((shotOwner->CurrentTeam() != team) && sg_shotbaseEnemyRespawn)))
 
3851
            {
3865
3852
                gSpawnPoint *pSpawn = Arena.ClosestSpawnPoint(GetPosition());
3866
3853
 
3867
3854
                if (pSpawn)
3883
3870
                            pSpawn->Spawn(pos, dir);
3884
3871
 
3885
3872
                            gCycle *pCycle = new gCycle(grid, pos, dir, pPlayer);
3886
 
                            pPlayer->ControlObject(pCycle);
3887
 
 
 
3873
                            pPlayer->ControlObject(pCycle);
 
3874
 
3888
3875
                            tColoredString playerName;
3889
3876
                            playerName << *pPlayer << tColoredString::ColorString(1,1,1);
3890
 
 
3891
 
                            if (shotOwner->CurrentTeam() == team)
 
3877
 
 
3878
                            if (shotOwner->CurrentTeam() == team)
3892
3879
                            {
3893
3880
                                tColoredString spawnerName;
3894
3881
                                spawnerName << shotOwner->GetColoredName() << tColoredString::ColorString(1,1,1);
3895
 
                                sn_ConsoleOut( tOutput( "$player_base_respawn", playerName, spawnerName ) );
3896
 
                            }
3897
 
                            else
 
3882
                                sn_ConsoleOut( tOutput( "$player_base_respawn", playerName, spawnerName ) );
 
3883
                            }
 
3884
                            else
3898
3885
                            {
3899
3886
                                tColoredString spawnerName;
3900
3887
                                spawnerName << shotOwner->GetColoredName() << tColoredString::ColorString(1,1,1);
3901
3888
                                sn_ConsoleOut( tOutput( "$player_base_enemy_respawn", playerName, spawnerName ) );
3902
 
                            }
3903
 
                        }
3904
 
                    }
3905
 
                }
3906
 
            }
3907
 
            tOutput win;
3908
 
            win.SetTemplateParameter(1, shotOwner->GetName());
3909
 
            win.SetTemplateParameter(3, team->Name());
3910
 
            win << "$player_shot_base";
3911
 
            shotOwner->AddScore(sg_scoreShotBase, win, "");
3912
 
        }
 
3889
                            }
 
3890
                        }
 
3891
                    }
 
3892
                }
 
3893
            }
 
3894
            tOutput win;
 
3895
            win.SetTemplateParameter(1, shotOwner->GetName());
 
3896
            win.SetTemplateParameter(3, team->Name());
 
3897
            win << "$player_shot_base";
 
3898
            shotOwner->AddScore(sg_scoreShotBase, win, "");
 
3899
        }
3913
3900
    }
3914
3901
}
3915
3902
 
3950
3937
}
3951
3938
 
3952
3939
void gSumoZoneHack::OnVanish( void )
3953
 
{
 
3940
{
3954
3941
    grid->RemoveGameObjectInteresting(this);
3955
3942
}
3956
3943
// *******************************************************************************
4530
4517
    lastImpactTime_ = 0;
4531
4518
 
4532
4519
    if (teamowner!=NULL) team = teamowner;
4533
 
 
 
4520
 
4534
4521
    if (!delayCreation)
4535
4522
        grid->AddGameObjectInteresting(this);
4536
4523
}
4831
4818
    ownerDropped_ = NULL;
4832
4819
    ownerDroppedTime_ = 0;
4833
4820
    lastHoldScoreTime_ = -1;
4834
 
    positionUpdatePending_ = false;
4835
 
 
4836
 
    passingTheFlag_ = false;
4837
 
    passingOwner_ = NULL;
 
4821
    positionUpdatePending_ = false;
 
4822
 
 
4823
    passingTheFlag_ = false;
 
4824
    passingOwner_ = NULL;
4838
4825
    passerOwnerFree_ = false;
4839
4826
 
4840
4827
    SetExpansionSpeed(0);
4869
4856
    ownerDropped_ = NULL;
4870
4857
    ownerDroppedTime_ = 0;
4871
4858
    lastHoldScoreTime_ = -1;
4872
 
    positionUpdatePending_ = false;
4873
 
 
4874
 
    passingTheFlag_ = false;
4875
 
    passingOwner_ = NULL;
 
4859
    positionUpdatePending_ = false;
 
4860
 
 
4861
    passingTheFlag_ = false;
 
4862
    passingOwner_ = NULL;
4876
4863
    passerOwnerFree_ = false;
4877
4864
}
4878
4865
 
4943
4930
static tSettingItem<float> sg_flagColorGConfig( "FLAG_COLOR_G", sg_flagColorG );
4944
4931
 
4945
4932
static float sg_flagColorB = -1;
4946
 
static tSettingItem<float> sg_flagColorBConfig( "FLAG_COLOR_B", sg_flagColorB );
4947
 
 
4948
 
REAL sg_flagPassSpeed = 30;
 
4933
static tSettingItem<float> sg_flagColorBConfig( "FLAG_COLOR_B", sg_flagColorB );
 
4934
 
 
4935
REAL sg_flagPassSpeed = 30;
4949
4936
static tSettingItem<REAL> sg_flagPassSpeedConf("FLAG_PASS_SPEED", sg_flagPassSpeed);
4950
4937
 
4951
4938
// *******************************************************************************
5192
5179
                }
5193
5180
            }
5194
5181
        }
5195
 
    }
5196
 
 
5197
 
    if (passingTheFlag_)
5198
 
    {
5199
 
        if (passingOwner_ && !owner_)
5200
 
        {
5201
 
            if (passingOwner_->Alive())
5202
 
            {
 
5182
    }
 
5183
 
 
5184
    if (passingTheFlag_)
 
5185
    {
 
5186
        if (passingOwner_ && !owner_)
 
5187
        {
 
5188
            if (passingOwner_->Alive())
 
5189
            {
5203
5190
                //Calculate new direction
5204
5191
                eCoord newDir = passingOwner_->Position() - GetPosition();
5205
5192
                newDir.Normalize();
5206
5193
 
5207
 
                SetReferenceTime();
5208
 
 
5209
 
                //  take in the speed of the flag speed command + the person who is going to receive the flag
 
5194
                SetReferenceTime();
 
5195
 
 
5196
                //  take in the speed of the flag speed command + the person who is going to receive the flag
5210
5197
                int newSpeed = sg_flagPassSpeed + (passingOwner_->verletSpeed_);
5211
 
                SetVelocity(newDir * newSpeed);
5212
 
 
5213
 
                RequestSync();
5214
 
            }
5215
 
            else
5216
 
            {
 
5198
                SetVelocity(newDir * newSpeed);
 
5199
 
 
5200
                RequestSync();
 
5201
            }
 
5202
            else
 
5203
            {
5217
5204
                SetReferenceTime();
5218
5205
                SetVelocity(se_zeroCoord);
5219
5206
                SetRadius(originalRadius_);
5220
5207
                SetExpansionSpeed(0);
5221
5208
                RequestSync();
5222
 
                positionUpdatePending_ = true;
5223
 
 
5224
 
                SetPassing(false);
5225
 
            }
5226
 
        }
5227
 
        else if(!passingOwner_)
5228
 
        {
 
5209
                positionUpdatePending_ = true;
 
5210
 
 
5211
                SetPassing(false);
 
5212
            }
 
5213
        }
 
5214
        else if(!passingOwner_)
 
5215
        {
5229
5216
            SetReferenceTime();
5230
5217
            SetVelocity(se_zeroCoord);
5231
5218
            SetRadius(originalRadius_);
5232
5219
            SetExpansionSpeed(0);
5233
5220
            RequestSync();
5234
 
            positionUpdatePending_ = true;
5235
 
 
5236
 
            SetPassing(false);
5237
 
        }
 
5221
            positionUpdatePending_ = true;
 
5222
 
 
5223
            SetPassing(false);
 
5224
        }
5238
5225
    }
5239
5226
 
5240
5227
    // delegate
5244
5231
    positionUpdatePending_ = false;
5245
5232
 
5246
5233
    return (returnStatus);
5247
 
}
5248
 
 
 
5234
}
 
5235
 
5249
5236
// *******************************************************************************
5250
5237
// *
5251
5238
// *    PassTheFlag
5252
5239
// *
5253
 
// *******************************************************************************
5254
 
 
5255
 
void gFlagZoneHack::PassComplete(gCycle *target)
5256
 
{
5257
 
    //  finish passing the flag
5258
 
    if (passingTheFlag_ && passingOwner_ && passerOwner_)
5259
 
    {
5260
 
        tOutput message;
5261
 
 
5262
 
        tColoredString playerName, passingName;
5263
 
        passingName << passerOwner_->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
5264
 
        playerName << target->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
5265
 
 
5266
 
        if (target == passingOwner_)
5267
 
        {
5268
 
            message.SetTemplateParameter(1, playerName);
5269
 
            message.SetTemplateParameter(2, passingName);
5270
 
            message << "$flag_pass_complete_same";
5271
 
        }
5272
 
        else
5273
 
        {
5274
 
            message.SetTemplateParameter(1, passingName);
5275
 
            message.SetTemplateParameter(2, playerName);
5276
 
            message << "$flag_pass_complete_diff";
5277
 
        }
5278
 
        sn_ConsoleOut(message);
5279
 
    }
5280
 
 
5281
 
    SetPassing(false);
5282
 
}
5283
 
 
5284
 
void gFlagZoneHack::PassFailed(gCycle *target)
5285
 
{
5286
 
    //  finish passing the flag
5287
 
    if (passingTheFlag_ && passingOwner_ && passerOwner_)
5288
 
    {
5289
 
        tOutput message;
5290
 
 
5291
 
        tColoredString playerName, passingName;
5292
 
        passingName << passerOwner_->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
5293
 
        playerName << target->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
5294
 
 
5295
 
        message.SetTemplateParameter(1, passingName);
5296
 
        message.SetTemplateParameter(2, playerName);
5297
 
        message << "$flag_pass_failed";
5298
 
        sn_ConsoleOut(message);
5299
 
    }
5300
 
 
5301
 
    SetPassing(false);
5302
 
}
5303
 
 
5304
 
void gFlagZoneHack::SetPassing(bool passed, gCycle *passOwner)
5305
 
{
5306
 
    if (passed)
5307
 
    {
5308
 
        passingTheFlag_ = true;
5309
 
        passingOwner_ = passOwner;
5310
 
        passerOwner_ = owner_;
5311
 
        passerOwnerFree_ = false;
5312
 
    }
5313
 
    else
5314
 
    {
5315
 
        passingTheFlag_ = false;
5316
 
        passingOwner_ = NULL;
5317
 
        passerOwner_ = NULL;
5318
 
        passerOwnerFree_ = false;
5319
 
    }
5320
 
}
5321
 
 
5322
 
enum gFlagPassMode
5323
 
{
5324
 
    gFLAGPASS_DISABLE = 0,  //! Disable passing the flag to team members
5325
 
    gFLAGPASS_CLOSEST = 1,  //! Picks a team member close to the passing player
5326
 
    gFLAGPASS_FURTHEST = 2, //! Picks a team member furthur to the passing player
5327
 
    gFLAGPASS_DISTANCE = 3, //! Picks a team member within the distance specified
5328
 
    gFLAGPASS_PERSON = 4    //! Picks a team member by the given name
5329
 
};
5330
 
tCONFIG_ENUM( gFlagPassMode );
5331
 
 
5332
 
gFlagPassMode sg_flagPassMode = gFLAGPASS_DISABLE;
5333
 
bool restrictFlagPassMode(const gFlagPassMode &newValue)
5334
 
{
5335
 
    if ((newValue < gFLAGPASS_DISABLE) || (newValue > gFLAGPASS_PERSON)) return false;
5336
 
    return true;
5337
 
}
5338
 
static tSettingItem<gFlagPassMode> sg_flagPassModeConf("FLAG_PASS_MODE", sg_flagPassMode, &restrictFlagPassMode);
5339
 
 
5340
 
REAL sg_flagPassDistance = 5.0;
5341
 
bool restrictFlagPassDistance(const REAL &newValue)
5342
 
{
5343
 
    if (newValue < 0) return false;
5344
 
    return true;
5345
 
}
5346
 
static tSettingItem<REAL> sg_flagPassDistanceConf("FLAG_PASS_DISTANCE", sg_flagPassDistance, &restrictFlagPassDistance);
5347
 
 
5348
 
void gFlagZoneHack::PassTheFlag(tString name)
5349
 
{
5350
 
    if (owner_)
5351
 
    {
5352
 
        if (sg_flagPassMode == gFLAGPASS_DISABLE) return;
5353
 
 
5354
 
        int alive = 0;
5355
 
        for (int i = 0; i < owner_->Team()->players.Len(); i++)
5356
 
        {
5357
 
            ePlayerNetID *p = owner_->Team()->players[i];
5358
 
            if (p && (p != owner_->Player()))
5359
 
            {
5360
 
                gCycle *pCycle = dynamic_cast<gCycle *>(p->Object());
5361
 
 
5362
 
                if (pCycle && pCycle->Alive())
5363
 
                {
5364
 
                    alive++;
5365
 
                }
5366
 
            }
5367
 
        }
5368
 
 
5369
 
        //  if no member is alive other than yourself, don't pass the flag
5370
 
        if (alive == 0) return;
5371
 
 
5372
 
        //  check the modes of each
5373
 
        gCycle *passOwner = NULL;
5374
 
        if (sg_flagPassMode == gFLAGPASS_CLOSEST)
5375
 
        {
5376
 
            REAL closestDistance = 0;
5377
 
            for (int i = 0; i < owner_->Team()->players.Len(); i++)
5378
 
            {
5379
 
                ePlayerNetID *p = owner_->Team()->players[i];
5380
 
                if (p && (p != owner_->Player()))
5381
 
                {
5382
 
                    gCycle *pCycle = dynamic_cast<gCycle *>(p->Object());
5383
 
 
5384
 
                    if (pCycle && pCycle->Alive())
5385
 
                    {
5386
 
                        eCoord otherpos = pCycle->Position() - owner_->Position();
5387
 
                        REAL distance = otherpos.NormSquared();
5388
 
                        if (!passOwner || (distance < closestDistance))
5389
 
                        {
5390
 
                            passOwner = pCycle;
5391
 
                            closestDistance = distance;
5392
 
                        }
5393
 
                    }
5394
 
                }
5395
 
            }
5396
 
 
5397
 
            if (passOwner)
5398
 
            {
5399
 
                // put the flag to move towards new owner
5400
 
                SetReferenceTime();
5401
 
                SetVelocity(passOwner->Direction() * owner_->verletSpeed_);
5402
 
                SetPosition(owner_->Position());
5403
 
                SetRadius(originalRadius_);
5404
 
                SetExpansionSpeed(0);
5405
 
                RequestSync();
5406
 
                positionUpdatePending_ = true;
5407
 
 
5408
 
                //  announce the passing activation
5409
 
                tOutput message;
5410
 
 
5411
 
                tColoredString playerName, passingName;
5412
 
                passingName << owner_->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
5413
 
                playerName << passOwner->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
5414
 
 
5415
 
                message.SetTemplateParameter(1, passingName);
5416
 
                message.SetTemplateParameter(2, playerName);
5417
 
                message << "$flag_pass_active";
5418
 
                sn_ConsoleOut(message);
5419
 
 
5420
 
                //  set the passing owner (one to receive the flag)
5421
 
                SetPassing(true, passOwner);
5422
 
 
5423
 
                // remove the current owner
5424
 
                RemoveOwner();
5425
 
            }
5426
 
        }
5427
 
        else if (sg_flagPassMode == gFLAGPASS_FURTHEST)
5428
 
        {
5429
 
            REAL furthestDistance = 0;
5430
 
            for (int i = 0; i < owner_->Team()->players.Len(); i++)
5431
 
            {
5432
 
                ePlayerNetID *p = owner_->Team()->players[i];
5433
 
                if (p && (p != owner_->Player()))
5434
 
                {
5435
 
                    gCycle *pCycle = dynamic_cast<gCycle *>(p->Object());
5436
 
 
5437
 
                    if (pCycle && pCycle->Alive())
5438
 
                    {
5439
 
                        eCoord otherpos = pCycle->Position() - owner_->Position();
5440
 
                        REAL distance = otherpos.NormSquared();
5441
 
                        if (!passOwner || (distance > furthestDistance))
5442
 
                        {
5443
 
                            passOwner = pCycle;
5444
 
                            furthestDistance = distance;
5445
 
                        }
5446
 
                    }
5447
 
                }
5448
 
            }
5449
 
 
5450
 
            if (passOwner)
5451
 
            {
5452
 
                // put the flag to move towards new owner
5453
 
                SetReferenceTime();
5454
 
                SetVelocity(passOwner->Direction() * owner_->verletSpeed_);
5455
 
                SetPosition(owner_->Position());
5456
 
                SetRadius(originalRadius_);
5457
 
                SetExpansionSpeed(0);
5458
 
                RequestSync();
5459
 
                positionUpdatePending_ = true;
5460
 
 
5461
 
                //  announce the passing activation
5462
 
                tOutput message;
5463
 
 
5464
 
                tColoredString playerName, passingName;
5465
 
                passingName << owner_->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
5466
 
                playerName << passOwner->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
5467
 
 
5468
 
                message.SetTemplateParameter(1, passingName);
5469
 
                message.SetTemplateParameter(2, playerName);
5470
 
                message << "$flag_pass_active";
5471
 
                sn_ConsoleOut(message);
5472
 
 
5473
 
                //  set the passing owner
5474
 
                SetPassing(true, passOwner);
5475
 
 
5476
 
                // remove the current owner
5477
 
                RemoveOwner();
5478
 
            }
5479
 
        }
5480
 
        else if (sg_flagPassMode == gFLAGPASS_DISTANCE)
5481
 
        {
5482
 
            REAL furthestDistance = 0;
5483
 
            for (int i = 0; i < owner_->Team()->players.Len(); i++)
5484
 
            {
5485
 
                ePlayerNetID *p = owner_->Team()->players[i];
5486
 
                if (p && (p != owner_->Player()))
5487
 
                {
5488
 
                    gCycle *pCycle = dynamic_cast<gCycle *>(p->Object());
5489
 
 
5490
 
                    if (pCycle && pCycle->Alive())
5491
 
                    {
5492
 
                        eCoord otherpos = pCycle->Position() - owner_->Position();
5493
 
                        REAL distance = otherpos.NormSquared();
5494
 
                        if (!passOwner || (distance > furthestDistance))
5495
 
                        {
5496
 
                            passOwner = pCycle;
5497
 
                            furthestDistance = distance;
5498
 
                        }
5499
 
 
5500
 
                        //  if distance is over the specified flag distance, break out of the function
5501
 
                        if (furthestDistance >= sg_flagPassDistance) break;
5502
 
                    }
5503
 
                }
5504
 
            }
5505
 
 
5506
 
            if (passOwner)
5507
 
            {
5508
 
                // put the flag to move towards new owner
5509
 
                SetReferenceTime();
5510
 
                SetVelocity(passOwner->Direction() * owner_->verletSpeed_);
5511
 
                SetPosition(owner_->Position());
5512
 
                SetRadius(originalRadius_);
5513
 
                SetExpansionSpeed(0);
5514
 
                RequestSync();
5515
 
                positionUpdatePending_ = true;
5516
 
 
5517
 
                //  announce the passing activation
5518
 
                tOutput message;
5519
 
 
5520
 
                tColoredString playerName, passingName;
5521
 
                passingName << owner_->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
5522
 
                playerName << passOwner->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
5523
 
 
5524
 
                message.SetTemplateParameter(1, passingName);
5525
 
                message.SetTemplateParameter(2, playerName);
5526
 
                message << "$flag_pass_active";
5527
 
                sn_ConsoleOut(message);
5528
 
 
5529
 
                //  set the passing owner
5530
 
                SetPassing(true, passOwner);
5531
 
 
5532
 
                // remove the current owner
5533
 
                RemoveOwner();
5534
 
            }
5535
 
        }
5536
 
        else if (sg_flagPassMode == gFLAGPASS_PERSON)
5537
 
        {
5538
 
            if (name.Filter() == "") return;
5539
 
 
5540
 
            ePlayerNetID *p = ePlayerNetID::FindPlayerByName(name);
5541
 
            if (!p) return;
5542
 
 
5543
 
            //  make sure that only the same team member will be allowed to get the pass of the flag
5544
 
            if (p->CurrentTeam() != owner_->Team()) return;
5545
 
 
5546
 
            passOwner = dynamic_cast<gCycle *>(p->Object());
5547
 
            if (passOwner)
5548
 
            {
5549
 
                // put the flag to move towards new owner
5550
 
                SetReferenceTime();
5551
 
                SetVelocity(passOwner->Direction() * owner_->verletSpeed_);
5552
 
                SetPosition(owner_->Position());
5553
 
                SetRadius(originalRadius_);
5554
 
                SetExpansionSpeed(0);
5555
 
                RequestSync();
5556
 
                positionUpdatePending_ = true;
5557
 
 
5558
 
                //  announce the passing activation
5559
 
                tOutput message;
5560
 
 
5561
 
                tColoredString playerName, passingName;
5562
 
                passingName << owner_->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
5563
 
                playerName << passOwner->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
5564
 
 
5565
 
                message.SetTemplateParameter(1, passingName);
5566
 
                message.SetTemplateParameter(2, playerName);
5567
 
                message << "$flag_pass_active";
5568
 
                sn_ConsoleOut(message);
5569
 
 
5570
 
                //  set the passing owner
5571
 
                SetPassing(true, passOwner);
5572
 
 
5573
 
                // remove the current owner
5574
 
                RemoveOwner();
5575
 
            }
5576
 
        }
5577
 
    }
 
5240
// *******************************************************************************
 
5241
 
 
5242
void gFlagZoneHack::PassComplete(gCycle *target)
 
5243
{
 
5244
    //  finish passing the flag
 
5245
    if (passingTheFlag_ && passingOwner_ && passerOwner_)
 
5246
    {
 
5247
        tOutput message;
 
5248
 
 
5249
        tColoredString playerName, passingName;
 
5250
        passingName << passerOwner_->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
 
5251
        playerName << target->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
 
5252
 
 
5253
        if (target == passingOwner_)
 
5254
        {
 
5255
            message.SetTemplateParameter(1, playerName);
 
5256
            message.SetTemplateParameter(2, passingName);
 
5257
            message << "$flag_pass_complete_same";
 
5258
        }
 
5259
        else
 
5260
        {
 
5261
            message.SetTemplateParameter(1, passingName);
 
5262
            message.SetTemplateParameter(2, playerName);
 
5263
            message << "$flag_pass_complete_diff";
 
5264
        }
 
5265
        sn_ConsoleOut(message);
 
5266
    }
 
5267
 
 
5268
    SetPassing(false);
 
5269
}
 
5270
 
 
5271
void gFlagZoneHack::PassFailed(gCycle *target)
 
5272
{
 
5273
    //  finish passing the flag
 
5274
    if (passingTheFlag_ && passingOwner_ && passerOwner_)
 
5275
    {
 
5276
        tOutput message;
 
5277
 
 
5278
        tColoredString playerName, passingName;
 
5279
        passingName << passerOwner_->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
 
5280
        playerName << target->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
 
5281
 
 
5282
        message.SetTemplateParameter(1, passingName);
 
5283
        message.SetTemplateParameter(2, playerName);
 
5284
        message << "$flag_pass_failed";
 
5285
        sn_ConsoleOut(message);
 
5286
    }
 
5287
 
 
5288
    SetPassing(false);
 
5289
}
 
5290
 
 
5291
void gFlagZoneHack::SetPassing(bool passed, gCycle *passOwner)
 
5292
{
 
5293
    if (passed)
 
5294
    {
 
5295
        passingTheFlag_ = true;
 
5296
        passingOwner_ = passOwner;
 
5297
        passerOwner_ = owner_;
 
5298
        passerOwnerFree_ = false;
 
5299
    }
 
5300
    else
 
5301
    {
 
5302
        passingTheFlag_ = false;
 
5303
        passingOwner_ = NULL;
 
5304
        passerOwner_ = NULL;
 
5305
        passerOwnerFree_ = false;
 
5306
    }
 
5307
}
 
5308
 
 
5309
enum gFlagPassMode
 
5310
{
 
5311
    gFLAGPASS_DISABLE = 0,  //! Disable passing the flag to team members
 
5312
    gFLAGPASS_CLOSEST = 1,  //! Picks a team member close to the passing player
 
5313
    gFLAGPASS_FURTHEST = 2, //! Picks a team member furthur to the passing player
 
5314
    gFLAGPASS_DISTANCE = 3, //! Picks a team member within the distance specified
 
5315
    gFLAGPASS_PERSON = 4    //! Picks a team member by the given name
 
5316
};
 
5317
tCONFIG_ENUM( gFlagPassMode );
 
5318
 
 
5319
gFlagPassMode sg_flagPassMode = gFLAGPASS_DISABLE;
 
5320
bool restrictFlagPassMode(const gFlagPassMode &newValue)
 
5321
{
 
5322
    if ((newValue < gFLAGPASS_DISABLE) || (newValue > gFLAGPASS_PERSON)) return false;
 
5323
    return true;
 
5324
}
 
5325
static tSettingItem<gFlagPassMode> sg_flagPassModeConf("FLAG_PASS_MODE", sg_flagPassMode, &restrictFlagPassMode);
 
5326
 
 
5327
REAL sg_flagPassDistance = 5.0;
 
5328
bool restrictFlagPassDistance(const REAL &newValue)
 
5329
{
 
5330
    if (newValue < 0) return false;
 
5331
    return true;
 
5332
}
 
5333
static tSettingItem<REAL> sg_flagPassDistanceConf("FLAG_PASS_DISTANCE", sg_flagPassDistance, &restrictFlagPassDistance);
 
5334
 
 
5335
void gFlagZoneHack::PassTheFlag(tString name)
 
5336
{
 
5337
    if (owner_)
 
5338
    {
 
5339
        if (sg_flagPassMode == gFLAGPASS_DISABLE) return;
 
5340
 
 
5341
        int alive = 0;
 
5342
        for (int i = 0; i < owner_->Team()->players.Len(); i++)
 
5343
        {
 
5344
            ePlayerNetID *p = owner_->Team()->players[i];
 
5345
            if (p && (p != owner_->Player()))
 
5346
            {
 
5347
                gCycle *pCycle = dynamic_cast<gCycle *>(p->Object());
 
5348
 
 
5349
                if (pCycle && pCycle->Alive())
 
5350
                {
 
5351
                    alive++;
 
5352
                }
 
5353
            }
 
5354
        }
 
5355
 
 
5356
        //  if no member is alive other than yourself, don't pass the flag
 
5357
        if (alive == 0) return;
 
5358
 
 
5359
        //  check the modes of each
 
5360
        gCycle *passOwner = NULL;
 
5361
        if (sg_flagPassMode == gFLAGPASS_CLOSEST)
 
5362
        {
 
5363
            REAL closestDistance = 0;
 
5364
            for (int i = 0; i < owner_->Team()->players.Len(); i++)
 
5365
            {
 
5366
                ePlayerNetID *p = owner_->Team()->players[i];
 
5367
                if (p && (p != owner_->Player()))
 
5368
                {
 
5369
                    gCycle *pCycle = dynamic_cast<gCycle *>(p->Object());
 
5370
 
 
5371
                    if (pCycle && pCycle->Alive())
 
5372
                    {
 
5373
                        eCoord otherpos = pCycle->Position() - owner_->Position();
 
5374
                        REAL distance = otherpos.NormSquared();
 
5375
                        if (!passOwner || (distance < closestDistance))
 
5376
                        {
 
5377
                            passOwner = pCycle;
 
5378
                            closestDistance = distance;
 
5379
                        }
 
5380
                    }
 
5381
                }
 
5382
            }
 
5383
 
 
5384
            if (passOwner)
 
5385
            {
 
5386
                // put the flag to move towards new owner
 
5387
                SetReferenceTime();
 
5388
                SetVelocity(passOwner->Direction() * owner_->verletSpeed_);
 
5389
                SetPosition(owner_->Position());
 
5390
                SetRadius(originalRadius_);
 
5391
                SetExpansionSpeed(0);
 
5392
                RequestSync();
 
5393
                positionUpdatePending_ = true;
 
5394
 
 
5395
                //  announce the passing activation
 
5396
                tOutput message;
 
5397
 
 
5398
                tColoredString playerName, passingName;
 
5399
                passingName << owner_->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
 
5400
                playerName << passOwner->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
 
5401
 
 
5402
                message.SetTemplateParameter(1, passingName);
 
5403
                message.SetTemplateParameter(2, playerName);
 
5404
                message << "$flag_pass_active";
 
5405
                sn_ConsoleOut(message);
 
5406
 
 
5407
                //  set the passing owner (one to receive the flag)
 
5408
                SetPassing(true, passOwner);
 
5409
 
 
5410
                // remove the current owner
 
5411
                RemoveOwner();
 
5412
            }
 
5413
        }
 
5414
        else if (sg_flagPassMode == gFLAGPASS_FURTHEST)
 
5415
        {
 
5416
            REAL furthestDistance = 0;
 
5417
            for (int i = 0; i < owner_->Team()->players.Len(); i++)
 
5418
            {
 
5419
                ePlayerNetID *p = owner_->Team()->players[i];
 
5420
                if (p && (p != owner_->Player()))
 
5421
                {
 
5422
                    gCycle *pCycle = dynamic_cast<gCycle *>(p->Object());
 
5423
 
 
5424
                    if (pCycle && pCycle->Alive())
 
5425
                    {
 
5426
                        eCoord otherpos = pCycle->Position() - owner_->Position();
 
5427
                        REAL distance = otherpos.NormSquared();
 
5428
                        if (!passOwner || (distance > furthestDistance))
 
5429
                        {
 
5430
                            passOwner = pCycle;
 
5431
                            furthestDistance = distance;
 
5432
                        }
 
5433
                    }
 
5434
                }
 
5435
            }
 
5436
 
 
5437
            if (passOwner)
 
5438
            {
 
5439
                // put the flag to move towards new owner
 
5440
                SetReferenceTime();
 
5441
                SetVelocity(passOwner->Direction() * owner_->verletSpeed_);
 
5442
                SetPosition(owner_->Position());
 
5443
                SetRadius(originalRadius_);
 
5444
                SetExpansionSpeed(0);
 
5445
                RequestSync();
 
5446
                positionUpdatePending_ = true;
 
5447
 
 
5448
                //  announce the passing activation
 
5449
                tOutput message;
 
5450
 
 
5451
                tColoredString playerName, passingName;
 
5452
                passingName << owner_->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
 
5453
                playerName << passOwner->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
 
5454
 
 
5455
                message.SetTemplateParameter(1, passingName);
 
5456
                message.SetTemplateParameter(2, playerName);
 
5457
                message << "$flag_pass_active";
 
5458
                sn_ConsoleOut(message);
 
5459
 
 
5460
                //  set the passing owner
 
5461
                SetPassing(true, passOwner);
 
5462
 
 
5463
                // remove the current owner
 
5464
                RemoveOwner();
 
5465
            }
 
5466
        }
 
5467
        else if (sg_flagPassMode == gFLAGPASS_DISTANCE)
 
5468
        {
 
5469
            REAL furthestDistance = 0;
 
5470
            for (int i = 0; i < owner_->Team()->players.Len(); i++)
 
5471
            {
 
5472
                ePlayerNetID *p = owner_->Team()->players[i];
 
5473
                if (p && (p != owner_->Player()))
 
5474
                {
 
5475
                    gCycle *pCycle = dynamic_cast<gCycle *>(p->Object());
 
5476
 
 
5477
                    if (pCycle && pCycle->Alive())
 
5478
                    {
 
5479
                        eCoord otherpos = pCycle->Position() - owner_->Position();
 
5480
                        REAL distance = otherpos.NormSquared();
 
5481
                        if (!passOwner || (distance > furthestDistance))
 
5482
                        {
 
5483
                            passOwner = pCycle;
 
5484
                            furthestDistance = distance;
 
5485
                        }
 
5486
 
 
5487
                        //  if distance is over the specified flag distance, break out of the function
 
5488
                        if (furthestDistance >= sg_flagPassDistance) break;
 
5489
                    }
 
5490
                }
 
5491
            }
 
5492
 
 
5493
            if (passOwner)
 
5494
            {
 
5495
                // put the flag to move towards new owner
 
5496
                SetReferenceTime();
 
5497
                SetVelocity(passOwner->Direction() * owner_->verletSpeed_);
 
5498
                SetPosition(owner_->Position());
 
5499
                SetRadius(originalRadius_);
 
5500
                SetExpansionSpeed(0);
 
5501
                RequestSync();
 
5502
                positionUpdatePending_ = true;
 
5503
 
 
5504
                //  announce the passing activation
 
5505
                tOutput message;
 
5506
 
 
5507
                tColoredString playerName, passingName;
 
5508
                passingName << owner_->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
 
5509
                playerName << passOwner->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
 
5510
 
 
5511
                message.SetTemplateParameter(1, passingName);
 
5512
                message.SetTemplateParameter(2, playerName);
 
5513
                message << "$flag_pass_active";
 
5514
                sn_ConsoleOut(message);
 
5515
 
 
5516
                //  set the passing owner
 
5517
                SetPassing(true, passOwner);
 
5518
 
 
5519
                // remove the current owner
 
5520
                RemoveOwner();
 
5521
            }
 
5522
        }
 
5523
        else if (sg_flagPassMode == gFLAGPASS_PERSON)
 
5524
        {
 
5525
            if (name.Filter() == "") return;
 
5526
 
 
5527
            ePlayerNetID *p = ePlayerNetID::FindPlayerByName(name);
 
5528
            if (!p) return;
 
5529
 
 
5530
            //  make sure that only the same team member will be allowed to get the pass of the flag
 
5531
            if (p->CurrentTeam() != owner_->Team()) return;
 
5532
 
 
5533
            passOwner = dynamic_cast<gCycle *>(p->Object());
 
5534
            if (passOwner)
 
5535
            {
 
5536
                // put the flag to move towards new owner
 
5537
                SetReferenceTime();
 
5538
                SetVelocity(passOwner->Direction() * owner_->verletSpeed_);
 
5539
                SetPosition(owner_->Position());
 
5540
                SetRadius(originalRadius_);
 
5541
                SetExpansionSpeed(0);
 
5542
                RequestSync();
 
5543
                positionUpdatePending_ = true;
 
5544
 
 
5545
                //  announce the passing activation
 
5546
                tOutput message;
 
5547
 
 
5548
                tColoredString playerName, passingName;
 
5549
                passingName << owner_->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
 
5550
                playerName << passOwner->Player()->GetColoredName() << tColoredString::ColorString(1,1,1);
 
5551
 
 
5552
                message.SetTemplateParameter(1, passingName);
 
5553
                message.SetTemplateParameter(2, playerName);
 
5554
                message << "$flag_pass_active";
 
5555
                sn_ConsoleOut(message);
 
5556
 
 
5557
                //  set the passing owner
 
5558
                SetPassing(true, passOwner);
 
5559
 
 
5560
                // remove the current owner
 
5561
                RemoveOwner();
 
5562
            }
 
5563
        }
 
5564
    }
5578
5565
}
5579
5566
 
5580
5567
 
5632
5619
 
5633
5620
    // check if the player is on our team or not (check will fail if team not enabled)
5634
5621
    if (target->Player()->CurrentTeam() == team)
5635
 
    {
5636
 
        PassFailed(target);
 
5622
    {
 
5623
        PassFailed(target);
5637
5624
 
5638
5625
        // player is on our team, if we're not at home, go back
5639
5626
        if (!IsHome())
5651
5638
    }
5652
5639
    // check if this player dropped the flag previously and ensure that player does not have another flag
5653
5640
    else if (((target != ownerDropped_) || (time > (ownerDroppedTime_ + sg_flagDropTime))) && (!playerHasFlag))
5654
 
    {
5655
 
        bool process = true;
5656
 
        if ((sg_flagPassMode > gFLAGPASS_DISABLE) && passingTheFlag_ && !passerOwnerFree_)
5657
 
            process = false;
5658
 
 
5659
 
        if (process)
 
5641
    {
 
5642
        bool process = true;
 
5643
        if ((sg_flagPassMode > gFLAGPASS_DISABLE) && passingTheFlag_ && !passerOwnerFree_)
 
5644
            process = false;
 
5645
 
 
5646
        if (process)
5660
5647
        {
5661
5648
            // take the flag
5662
5649
            owner_ = target;
5666
5653
            owner_->flag_ = this;
5667
5654
 
5668
5655
            blinkUpdateTime_ = -1000;
5669
 
            blinkTrackUpdateTime_ = -1000;
5670
 
 
 
5656
            blinkTrackUpdateTime_ = -1000;
 
5657
 
5671
5658
            PassComplete(target);
5672
5659
 
5673
5660
            // diminish the flag and put it at the original location
5687
5674
 
5688
5675
            tColoredString playerName;
5689
5676
            playerName << *target->Player() << tColoredString::ColorString(1,1,1);
5690
 
            sn_ConsoleOut( tOutput( "$player_flag_take", playerName ) );
 
5677
            sn_ConsoleOut( tOutput( "$player_flag_take", playerName ) );
5691
5678
        }
5692
5679
    }
5693
 
}
5694
 
 
 
5680
}
 
5681
 
5695
5682
// *******************************************************************************
5696
5683
// *
5697
5684
// *    OnExit
5703
5690
//!
5704
5691
// *******************************************************************************
5705
5692
 
5706
 
void gFlagZoneHack::OnExit( gCycle * target, REAL time )
5707
 
{
5708
 
    if ((sg_flagPassMode > gFLAGPASS_DISABLE) && passingTheFlag_ && !passerOwnerFree_)
5709
 
    {
5710
 
        if (passerOwner_ == target)
5711
 
            passerOwnerFree_ = true;
5712
 
    }
 
5693
void gFlagZoneHack::OnExit( gCycle * target, REAL time )
 
5694
{
 
5695
    if ((sg_flagPassMode > gFLAGPASS_DISABLE) && passingTheFlag_ && !passerOwnerFree_)
 
5696
    {
 
5697
        if (passerOwner_ == target)
 
5698
            passerOwnerFree_ = true;
 
5699
    }
5713
5700
}
5714
5701
 
5715
5702
 
5942
5929
ePlayerNetID *gTargetZoneHack::winner_ = 0;
5943
5930
 
5944
5931
static void sg_SetTargetCmd(std::istream &s)
5945
 
{
5946
 
    eGrid *grid = eGrid::CurrentGrid();
5947
 
    if ( !grid )
5948
 
    {
5949
 
        con << "Must be called while a grid exists!\n";
5950
 
        return;
5951
 
    }
 
5932
{
 
5933
    eGrid *grid = eGrid::CurrentGrid();
 
5934
    if ( !grid )
 
5935
    {
 
5936
        con << "Must be called while a grid exists!\n";
 
5937
        return;
 
5938
    }
5952
5939
 
5953
5940
    tString params;
5954
5941
    params.ReadLine( s, true );
5979
5966
        gTargetZoneHack *zone=dynamic_cast<gTargetZoneHack *>(gameObjects(zone_id));
5980
5967
        if (zone)
5981
5968
        {
5982
 
            if (event_str == "onenter")
 
5969
            if (event_str == "onenter")
5983
5970
            {
5984
5971
                zone->SetOnEnterCmd(cmd_str, mode_str);
5985
5972
                con << "Zone " << zone->GOID() << " command onenter '" << cmd_str << "'\n";
5986
 
            }
5987
 
            else if (event_str == "onvanish")
 
5973
            }
 
5974
            else if (event_str == "onvanish")
5988
5975
            {
5989
5976
                zone->SetOnVanishCmd(cmd_str, mode_str);
5990
5977
                con << "Zone " << zone->GOID() << " command onvanish '" << cmd_str << "'\n";
5991
 
            }
5992
 
            else if (event_str == "onexit")
5993
 
            {
 
5978
            }
 
5979
            else if (event_str == "onexit")
 
5980
            {
5994
5981
                zone->SetOnExitCmd(cmd_str, mode_str);
5995
 
                con << "Zone " << zone->GOID() << " command onexit '" << cmd_str << "'\n";
 
5982
                con << "Zone " << zone->GOID() << " command onexit '" << cmd_str << "'\n";
5996
5983
            }
5997
5984
            zone_id=gZone::FindNext(object_id_str, zone_id);
5998
5985
        }
6010
5997
//!     @param  grid Grid to put the zone into
6011
5998
//!     @param  pos  Position to spawn the zone at
6012
5999
//!
6013
 
// *******************************************************************************
6014
 
 
6015
 
//  target zone color settings
6016
 
REAL sg_targetZoneColorR = 0;
6017
 
REAL sg_targetZoneColorG = 15;
6018
 
REAL sg_targetZoneColorB = 0;
6019
 
static tSettingItem<REAL> sg_targetZoneColorRConf("TARGETZONE_COLOR_R", sg_targetZoneColorR);
6020
 
static tSettingItem<REAL> sg_targetZoneColorGConf("TARGETZONE_COLOR_G", sg_targetZoneColorG);
 
6000
// *******************************************************************************
 
6001
 
 
6002
//  target zone color settings
 
6003
REAL sg_targetZoneColorR = 0;
 
6004
REAL sg_targetZoneColorG = 15;
 
6005
REAL sg_targetZoneColorB = 0;
 
6006
static tSettingItem<REAL> sg_targetZoneColorRConf("TARGETZONE_COLOR_R", sg_targetZoneColorR);
 
6007
static tSettingItem<REAL> sg_targetZoneColorGConf("TARGETZONE_COLOR_G", sg_targetZoneColorG);
6021
6008
static tSettingItem<REAL> sg_targetZoneColorBConf("TARGETZONE_COLOR_B", sg_targetZoneColorB);
6022
6009
 
6023
6010
gTargetZoneHack::gTargetZoneHack( eGrid * grid, const eCoord & pos, bool dynamicCreation, bool delayCreation)
6025
6012
{
6026
6013
    //color_.r = 0.0f;
6027
6014
    //color_.g = 1.0f;
6028
 
    //color_.b = 0.0f;
6029
 
 
6030
 
    color_.r = sg_targetZoneColorR / 15.0f;
6031
 
    color_.g = sg_targetZoneColorG / 15.0f;
 
6015
    //color_.b = 0.0f;
 
6016
 
 
6017
    color_.r = sg_targetZoneColorR / 15.0f;
 
6018
    color_.g = sg_targetZoneColorG / 15.0f;
6032
6019
    color_.b = sg_targetZoneColorB / 15.0f;
6033
6020
 
6034
6021
    TargetZoneCounter_++;
6042
6029
    targetEmptyTime_ = -1.0;
6043
6030
    currentState_ = State_Safe;
6044
6031
    for(int i=0; i<MAXCLIENTS; i++) playersFlags[i] = 0;
6045
 
 
 
6032
 
6046
6033
    if (!delayCreation)
6047
6034
        grid->AddGameObjectInteresting(this);
6048
6035
 
6199
6186
        (currentState_ == State_Conquered))
6200
6187
    {
6201
6188
        return;
6202
 
    }
6203
 
 
6204
 
    // RACE HACK begin
6205
 
    if ( sg_RaceTimerEnabled )
6206
 
    {
6207
 
        gRace::ZoneHit( target->Player(), time );
6208
 
    }
6209
 
    // RACE HACK end
 
6189
    }
 
6190
 
 
6191
    // RACE HACK begin
 
6192
    if ( sg_RaceTimerEnabled )
 
6193
    {
 
6194
        gRace::ZoneHit( target->Player(), time );
 
6195
    }
 
6196
    // RACE HACK end
6210
6197
 
6211
6198
    // keep first player in memory, if it's the last zone, he is the winner ...
6212
6199
    if (!firstPlayer_)
6245
6232
            zoneScore_=0;
6246
6233
            targetEmptyTime_=time;
6247
6234
        }
6248
 
    }
 
6235
    }
6249
6236
 
6250
6237
    // message in edlog
6251
6238
    if (playersFlags[target->Player()->ListID()] != 2)
6254
6241
        sg_targetzonePlayerEnterWriter.write();
6255
6242
        playersFlags[target->Player()->ListID()] = 2;
6256
6243
    }
6257
 
}
6258
 
 
 
6244
}
 
6245
 
6259
6246
// *******************************************************************************
6260
6247
// *
6261
6248
// *    OnExit
6262
6249
// *
6263
 
// *******************************************************************************
 
6250
// *******************************************************************************
6264
6251
//!
6265
6252
//!     @param  target  the cycle that has left the zone
6266
6253
//!     @param  time    the current time
6267
6254
//!
6268
 
// *******************************************************************************
6269
 
 
6270
 
static eLadderLogWriter sg_targetzonePlayerLeftWriter("TARGETZONE_PLAYER_LEFT", false);
6271
 
 
6272
 
void gTargetZoneHack::OnExit(gCycle *target, REAL time)
6273
 
{
6274
 
    //send on exit commands
6275
 
    std::istringstream stream(&OnExitCmd(0));
6276
 
    tCurrentAccessLevel elevator( sg_SetTargetCmd_conf.GetRequiredLevel(), true );
6277
 
    tConfItemBase::LoadAll(stream);
6278
 
 
 
6255
// *******************************************************************************
 
6256
 
 
6257
static eLadderLogWriter sg_targetzonePlayerLeftWriter("TARGETZONE_PLAYER_LEFT", false);
 
6258
 
 
6259
void gTargetZoneHack::OnExit(gCycle *target, REAL time)
 
6260
{
 
6261
    //send on exit commands
 
6262
    std::istringstream stream(&OnExitCmd(0));
 
6263
    tCurrentAccessLevel elevator( sg_SetTargetCmd_conf.GetRequiredLevel(), true );
 
6264
    tConfItemBase::LoadAll(stream);
 
6265
 
6279
6266
    sg_targetzonePlayerLeftWriter << this->GOID() << name_ << MapPosition().x << MapPosition().y << target->Player()->GetUserName() << target->Player()->Object()->MapPosition().x << target->Player()->Object()->MapPosition().y << target->Player()->Object()->MapDirection().x << target->Player()->Object()->MapDirection().y << time;
6280
 
    sg_targetzonePlayerLeftWriter.write();
6281
 
 
6282
 
    if (playersFlags[target->Player()->ListID()])
6283
 
        playersFlags[target->Player()->ListID()] = 0;
6284
 
 
6285
 
    // RACE HACK begin
6286
 
    if ( sg_RaceTimerEnabled )
6287
 
    {
6288
 
        gRace::ZoneOut( target->Player(), time );
6289
 
    }
6290
 
    // RACE HACK end
 
6267
    sg_targetzonePlayerLeftWriter.write();
 
6268
 
 
6269
    if (playersFlags[target->Player()->ListID()])
 
6270
        playersFlags[target->Player()->ListID()] = 0;
 
6271
 
 
6272
    // RACE HACK begin
 
6273
    if ( sg_RaceTimerEnabled )
 
6274
    {
 
6275
        gRace::ZoneOut( target->Player(), time );
 
6276
    }
 
6277
    // RACE HACK end
6291
6278
}
6292
6279
 
6293
6280
// *******************************************************************************
6312
6299
        sg_DeclareWinner( firstPlayer_->CurrentTeam(), message );
6313
6300
    }
6314
6301
    // decrement target zone counter
6315
 
    TargetZoneCounter_--;
6316
 
 
 
6302
    TargetZoneCounter_--;
 
6303
 
6317
6304
    grid->RemoveGameObjectInteresting(this);
6318
6305
}
6319
6306
 
6352
6339
 
6353
6340
    PlayersInside_=0;
6354
6341
    EnteredTime_ = -1;
6355
 
    owner_=NULL;
6356
 
 
 
6342
    owner_=NULL;
 
6343
 
6357
6344
    if (!delayCreation)
6358
6345
        grid->AddGameObjectInteresting(this);
6359
6346
 
6568
6555
    color_.r = 0.0f;
6569
6556
    color_.g = 1.0f;
6570
6557
    color_.b = 0.0f;
6571
 
 
 
6558
 
6572
6559
    if (!delayCreation)
6573
6560
        grid->AddGameObjectInteresting(this);
6574
6561
 
6673
6660
// *******************************************************************************
6674
6661
 
6675
6662
void gTeleportZoneHack::OnVanish( void )
6676
 
{
 
6663
{
6677
6664
    grid->RemoveGameObjectInteresting(this);
6678
6665
}
6679
6666
 
6695
6682
    color_.r = 0.0f;
6696
6683
    color_.g = 0.5f;
6697
6684
    color_.b = 1.0f;
6698
 
 
 
6685
 
6699
6686
    if (!delayCreation)
6700
6687
        grid->AddGameObjectInteresting(this);
6701
6688
 
6764
6751
//!     @param  target  the cycle that has been found inside the zone
6765
6752
//!     @param  time    the current time
6766
6753
//!
6767
 
// *******************************************************************************
6768
 
 
6769
 
static int sg_BlastZoneScore = -1;
6770
 
static tSettingItem<int> sg_BlastZoneScoreConf("SCORE_BLASTZONE", sg_BlastZoneScore);
 
6754
// *******************************************************************************
 
6755
 
 
6756
static int sg_BlastZoneScore = -1;
 
6757
static tSettingItem<int> sg_BlastZoneScoreConf("SCORE_BLASTZONE", sg_BlastZoneScore);
6771
6758
static eLadderLogWriter sg_deathDeathBlastZoneWriter("BLASTZONE_PLAYER_ENTER", false);
6772
6759
 
6773
6760
void gBlastZoneHack::OnEnter( gCycle * target, REAL time )
6774
6761
{
6775
 
    target->SetWallBuilding(false);
6776
 
    target->Player()->Object()->Kill();
6777
 
 
 
6762
    target->SetWallBuilding(false);
 
6763
    target->Player()->Object()->Kill();
 
6764
 
6778
6765
    tOutput lose;
6779
 
    lose << "$player_blastzone_score";
6780
 
    target->Player()->AddScore( sg_BlastZoneScore, "", lose);
6781
 
 
6782
 
    sg_deathDeathBlastZoneWriter << target->Player()->GetUserName();
 
6766
    lose << "$player_blastzone_score";
 
6767
    target->Player()->AddScore( sg_BlastZoneScore, "", lose);
 
6768
 
 
6769
    sg_deathDeathBlastZoneWriter << target->Player()->GetUserName();
6783
6770
    sg_deathDeathBlastZoneWriter.write();
6784
6771
}
6785
6772
 
6791
6778
// *******************************************************************************
6792
6779
 
6793
6780
void gBlastZoneHack::OnVanish( void )
6794
 
{
 
6781
{
6795
6782
    grid->RemoveGameObjectInteresting(this);
6796
6783
}
6797
 
 
 
6784
 
6798
6785
// *******************************************************************************
6799
6786
// *
6800
6787
// *    gSpeedZoneHack
6812
6799
    color_.r = 0.0f;
6813
6800
    color_.g = 1.5f;
6814
6801
    color_.b = 1.0f;
6815
 
 
 
6802
 
6816
6803
    if (!delayCreation)
6817
6804
        grid->AddGameObjectInteresting(this);
6818
6805
 
6881
6868
//!     @param  target  the cycle that has been found inside the zone
6882
6869
//!     @param  time    the current time
6883
6870
//!
6884
 
// *******************************************************************************
6885
 
 
 
6871
// *******************************************************************************
 
6872
 
6886
6873
void gSpeedZoneHack::OnEnter( gCycle * target, REAL time )
6887
6874
{
6888
 
    if (speedType_ == TYPE_ACCEL)
6889
 
    {
6890
 
        target->verletSpeed_ += setSpeed_;
6891
 
    }
6892
 
    else if (speedType_ == TYPE_SPEED)
6893
 
    {
6894
 
        target->verletSpeed_ = setSpeed_;
 
6875
    if (speedType_ == TYPE_ACCEL)
 
6876
    {
 
6877
        target->verletSpeed_ += setSpeed_;
 
6878
    }
 
6879
    else if (speedType_ == TYPE_SPEED)
 
6880
    {
 
6881
        target->verletSpeed_ = setSpeed_;
6895
6882
    }
6896
6883
}
6897
6884
 
6902
6889
// *******************************************************************************
6903
6890
 
6904
6891
void gSpeedZoneHack::OnVanish( void )
6905
 
{
 
6892
{
6906
6893
    grid->RemoveGameObjectInteresting(this);
6907
6894
}
6908
6895
 
6923
6910
    color_.r = 1.0f;
6924
6911
    color_.g = 0.0f;
6925
6912
    color_.b = 0.5f;
6926
 
 
 
6913
 
6927
6914
    if (!delayCreation)
6928
 
        grid->AddGameObjectInteresting(this);
6929
 
 
 
6915
        grid->AddGameObjectInteresting(this);
 
6916
 
6930
6917
    seekSpeed_ = 1.0;
6931
6918
 
6932
6919
    SetExpansionSpeed(0);
6979
6966
bool gObjectZoneHack::Timestep( REAL time )
6980
6967
{
6981
6968
    // delegate
6982
 
    bool returnStatus = gZone::Timestep( time );
6983
 
 
 
6969
    bool returnStatus = gZone::Timestep( time );
 
6970
 
6984
6971
    if (seeking_)
6985
6972
    {
6986
6973
        //Only run this every poll time to save on network traffic
7013
7000
//!     @param  target  the cycle that has been found inside the zone
7014
7001
//!     @param  time    the current time
7015
7002
//!
7016
 
// *******************************************************************************
7017
 
 
7018
 
static eLadderLogWriter sg_objectZonePlayerEntered("OBJECTZONE_PLAYER_ENTERED", false);
7019
 
static eLadderLogWriter sg_objectZoneZoneEntered("OBJECTZONE_ZONE_ENTERED", false);
 
7003
// *******************************************************************************
 
7004
 
 
7005
static eLadderLogWriter sg_objectZonePlayerEntered("OBJECTZONE_PLAYER_ENTERED", false);
 
7006
static eLadderLogWriter sg_objectZoneZoneEntered("OBJECTZONE_ZONE_ENTERED", false);
7020
7007
void gObjectZoneHack::OnEnter( gCycle * target, REAL time )
7021
 
{
7022
 
    ePlayerNetID *p = target->Player();
7023
 
    if (p)
7024
 
    {
7025
 
        sg_objectZonePlayerEntered << GOID() << name_ << MapPosition().x << MapPosition().y << p->GetUserName() << target->MapPosition().x << target->MapPosition().y << target->MapDirection().x << target->MapDirection().y << time;
7026
 
        sg_objectZonePlayerEntered.write();
7027
 
    }
7028
 
}
7029
 
 
7030
 
//  for when zones enter this object zone
7031
 
void gObjectZoneHack::OnEnter(gZone *target, REAL time)
7032
 
{
7033
 
    if (target && !target->destroyed_)
7034
 
    {
7035
 
        sg_objectZoneZoneEntered << GOID() << name_ << MapPosition().x << MapPosition().y << target->GOID() << target->GetName() << target->MapPosition().x << target->MapPosition().y << target->GetVelocity().x << target->GetVelocity().y << time;
7036
 
        sg_objectZoneZoneEntered.write();
7037
 
    }
7038
 
}
7039
 
 
7040
 
static eLadderLogWriter sg_ObjectZoneSpawned("OBJECTZONE_SPAWNED", false);
7041
 
 
7042
 
static void sg_SpawnObjectZone(std::istream &s)
7043
 
{
 
7008
{
 
7009
    ePlayerNetID *p = target->Player();
 
7010
    if (p)
 
7011
    {
 
7012
        sg_objectZonePlayerEntered << GOID() << name_ << MapPosition().x << MapPosition().y << p->GetUserName() << target->MapPosition().x << target->MapPosition().y << target->MapDirection().x << target->MapDirection().y << time;
 
7013
        sg_objectZonePlayerEntered.write();
 
7014
    }
 
7015
}
 
7016
 
 
7017
//  for when zones enter this object zone
 
7018
void gObjectZoneHack::OnEnter(gZone *target, REAL time)
 
7019
{
 
7020
    if (target && !target->destroyed_)
 
7021
    {
 
7022
        sg_objectZoneZoneEntered << GOID() << name_ << MapPosition().x << MapPosition().y << target->GOID() << target->GetName() << target->MapPosition().x << target->MapPosition().y << target->GetVelocity().x << target->GetVelocity().y << time;
 
7023
        sg_objectZoneZoneEntered.write();
 
7024
    }
 
7025
}
 
7026
 
 
7027
static eLadderLogWriter sg_ObjectZoneSpawned("OBJECTZONE_SPAWNED", false);
 
7028
 
 
7029
static void sg_SpawnObjectZone(std::istream &s)
 
7030
{
7044
7031
    eGrid *grid = eGrid::CurrentGrid();
7045
 
    if(!grid)
7046
 
        return;
7047
 
 
7048
 
    tString params;
7049
 
    params.ReadLine(s, true);
7050
 
 
7051
 
    gObjectZoneHack *Zone = NULL;
7052
 
 
7053
 
    if (params.Filter() == "")
7054
 
    {
7055
 
        goto usage;
7056
 
        return;
7057
 
    }
7058
 
    else
7059
 
    {
7060
 
        float sizeMultiplier = gArena::SizeMultiplier();
7061
 
        float radius, growth;
7062
 
        tString name;
7063
 
        std::vector<eCoord> route;
7064
 
        int pos = 0;
7065
 
 
7066
 
        name = params.ExtractNonBlankSubString(pos);
7067
 
 
 
7032
    if(!grid)
 
7033
        return;
 
7034
 
 
7035
    tString params;
 
7036
    params.ReadLine(s, true);
 
7037
 
 
7038
    gObjectZoneHack *Zone = NULL;
 
7039
 
 
7040
    if (params.Filter() == "")
 
7041
    {
 
7042
        goto usage;
 
7043
        return;
 
7044
    }
 
7045
    else
 
7046
    {
 
7047
        float sizeMultiplier = gArena::SizeMultiplier();
 
7048
        float radius, growth;
 
7049
        tString name;
 
7050
        std::vector<eCoord> route;
 
7051
        int pos = 0;
 
7052
 
 
7053
        name = params.ExtractNonBlankSubString(pos);
 
7054
 
7068
7055
        tString zonePosXStr;
7069
 
        tString zonePosYStr;
7070
 
 
7071
 
        if (name.ToLower() == "n")
7072
 
        {
7073
 
            name = params.ExtractNonBlankSubString(pos);
7074
 
            zonePosXStr = params.ExtractNonBlankSubString(pos);
7075
 
        }
7076
 
        else
7077
 
        {
7078
 
            zonePosXStr = name;
7079
 
            name  = "";
7080
 
        }
 
7056
        tString zonePosYStr;
 
7057
 
 
7058
        if (name.ToLower() == "n")
 
7059
        {
 
7060
            name = params.ExtractNonBlankSubString(pos);
 
7061
            zonePosXStr = params.ExtractNonBlankSubString(pos);
 
7062
        }
 
7063
        else
 
7064
        {
 
7065
            zonePosXStr = name;
 
7066
            name  = "";
 
7067
        }
7081
7068
 
7082
7069
        //  handle x position and get y position
7083
7070
        if(zonePosXStr == "L")
7094
7081
        else
7095
7082
        {
7096
7083
            zonePosYStr = params.ExtractNonBlankSubString(pos);
7097
 
        }
7098
 
 
 
7084
        }
 
7085
 
7099
7086
        tString zoneSizeStr       = params.ExtractNonBlankSubString(pos);
7100
7087
        tString zoneGrowthStr     = params.ExtractNonBlankSubString(pos);
7101
7088
        tString zoneDirXStr       = params.ExtractNonBlankSubString(pos);
7102
 
        tString zoneDirYStr       = params.ExtractNonBlankSubString(pos);
 
7089
        tString zoneDirYStr       = params.ExtractNonBlankSubString(pos);
7103
7090
        tString zoneInteractive   = params.ExtractNonBlankSubString(pos);
7104
7091
        tString zoneRedStr        = params.ExtractNonBlankSubString(pos);
7105
7092
        tString zoneGreenStr      = params.ExtractNonBlankSubString(pos);
7106
7093
        tString zoneBlueStr       = params.ExtractNonBlankSubString(pos);
7107
 
        tString targetRadiusStr   = params.ExtractNonBlankSubString(pos);
7108
 
        tString seekOwnerStr      = params.ExtractNonBlankSubString(pos);
7109
 
        tString seekSpeedStr      = params.ExtractNonBlankSubString(pos);
7110
 
        tString seekUpdateTimeStr = params.ExtractNonBlankSubString(pos);
7111
 
 
 
7094
        tString targetRadiusStr   = params.ExtractNonBlankSubString(pos);
 
7095
        tString seekOwnerStr      = params.ExtractNonBlankSubString(pos);
 
7096
        tString seekSpeedStr      = params.ExtractNonBlankSubString(pos);
 
7097
        tString seekUpdateTimeStr = params.ExtractNonBlankSubString(pos);
 
7098
 
7112
7099
        eCoord zonePos    = route.empty() ? eCoord(atof(zonePosXStr)*sizeMultiplier,atof(zonePosYStr)*sizeMultiplier) : route.front();
7113
7100
        REAL zoneSize     = atof(zoneSizeStr)*sizeMultiplier;
7114
 
        REAL zoneGrowth   = atof(zoneGrowthStr)*sizeMultiplier;
7115
 
 
 
7101
        REAL zoneGrowth   = atof(zoneGrowthStr)*sizeMultiplier;
 
7102
 
7116
7103
        eCoord zoneDir = eCoord(atof(zoneDirXStr)*sizeMultiplier,atof(zoneDirYStr)*sizeMultiplier);
7117
7104
        gRealColor zoneColor;
7118
7105
        bool setColorFlag = false;
7119
7106
        if ((zoneRedStr.Filter() != "") && (zoneGreenStr.Filter() != "") && (zoneBlueStr.Filter() != ""))
7120
7107
        {
7121
 
            if (zoneRedStr == "r_rand")
7122
 
            {
7123
 
                tRandomizer &randomizer = tRandomizer::GetInstance();
7124
 
                zoneColor.r = randomizer.Get(0, 15.0) / 15.0;
7125
 
            }
7126
 
            else
7127
 
            {
7128
 
                zoneColor.r = atof(zoneRedStr) / 15.0;
7129
 
            }
7130
 
 
7131
 
            if (zoneGreenStr == "g_rand")
7132
 
            {
7133
 
                tRandomizer &randomizer = tRandomizer::GetInstance();
7134
 
                zoneColor.g = randomizer.Get(0, 15.0) / 15.0;
7135
 
            }
7136
 
            else
7137
 
            {
7138
 
                zoneColor.g = atof(zoneGreenStr) / 15.0;
7139
 
            }
7140
 
 
7141
 
            if (zoneBlueStr == "b_rand")
7142
 
            {
7143
 
                tRandomizer &randomizer = tRandomizer::GetInstance();
7144
 
                zoneColor.b = randomizer.Get(0, 15.0) / 15.0;
7145
 
            }
7146
 
            else
7147
 
            {
7148
 
                zoneColor.b = atof(zoneBlueStr) / 15.0;
 
7108
            if (zoneRedStr == "r_rand")
 
7109
            {
 
7110
                tRandomizer &randomizer = tRandomizer::GetInstance();
 
7111
                zoneColor.r = randomizer.Get(0, 15.0) / 15.0;
 
7112
            }
 
7113
            else
 
7114
            {
 
7115
                zoneColor.r = atof(zoneRedStr) / 15.0;
 
7116
            }
 
7117
 
 
7118
            if (zoneGreenStr == "g_rand")
 
7119
            {
 
7120
                tRandomizer &randomizer = tRandomizer::GetInstance();
 
7121
                zoneColor.g = randomizer.Get(0, 15.0) / 15.0;
 
7122
            }
 
7123
            else
 
7124
            {
 
7125
                zoneColor.g = atof(zoneGreenStr) / 15.0;
 
7126
            }
 
7127
 
 
7128
            if (zoneBlueStr == "b_rand")
 
7129
            {
 
7130
                tRandomizer &randomizer = tRandomizer::GetInstance();
 
7131
                zoneColor.b = randomizer.Get(0, 15.0) / 15.0;
 
7132
            }
 
7133
            else
 
7134
            {
 
7135
                zoneColor.b = atof(zoneBlueStr) / 15.0;
7149
7136
            }
7150
7137
            setColorFlag = true;
7151
 
        }
7152
 
 
 
7138
        }
 
7139
 
7153
7140
        bool zoneInteractiveBool = false;
7154
7141
        if (zoneInteractive.ToLower() == "true")
7155
 
            zoneInteractiveBool = true;
7156
 
 
7157
 
        Zone = tNEW(gObjectZoneHack(grid, zonePos, true));
7158
 
        Zone->SetRadius(zoneSize);
7159
 
        Zone->SetExpansionSpeed(zoneGrowth);
7160
 
        Zone->SetVelocity(zoneDir);
7161
 
 
 
7142
            zoneInteractiveBool = true;
 
7143
 
 
7144
        Zone = tNEW(gObjectZoneHack(grid, zonePos, true));
 
7145
        Zone->SetRadius(zoneSize);
 
7146
        Zone->SetExpansionSpeed(zoneGrowth);
 
7147
        Zone->SetVelocity(zoneDir);
 
7148
 
7162
7149
        if (setColorFlag)
7163
7150
        {
7164
7151
            zoneColor.r = (zoneColor.r>1.0)?1.0:zoneColor.r;
7165
7152
            zoneColor.g = (zoneColor.g>1.0)?1.0:zoneColor.g;
7166
7153
            zoneColor.b = (zoneColor.b>1.0)?1.0:zoneColor.b;
7167
7154
            Zone->SetColor(zoneColor);
7168
 
        }
7169
 
 
7170
 
        if (zoneInteractiveBool)
7171
 
        {
7172
 
            Zone->SetWallBouncesLeft(-1);
7173
 
            Zone->SetWallInteract(zoneInteractiveBool);
7174
 
        }
7175
 
 
7176
 
        REAL targetRadius = atof(targetRadiusStr)*sizeMultiplier;
7177
 
        if(targetRadius != 0)
7178
 
            Zone->SetTargetRadius(targetRadius);
7179
 
 
7180
 
        if (seekOwnerStr.Filter() != "")
7181
 
        {
7182
 
            ePlayerNetID *seekOwnerPlayer = ePlayerNetID::FindPlayerByName(seekOwnerStr);
7183
 
            if (seekOwnerPlayer && seekOwnerPlayer->Object() && seekOwnerPlayer->Object()->Alive())
7184
 
                Zone->SetSeekingCycle(dynamic_cast<gCycle *>(seekOwnerPlayer->Object()));
7185
 
        }
7186
 
 
7187
 
        REAL seekSpeed = atof(seekSpeedStr);
7188
 
        if (seekSpeed >= 0)
7189
 
            Zone->SetSeekSpeed(seekSpeed);
7190
 
        else
7191
 
            Zone->SetSeekSpeed(1.0);
7192
 
 
7193
 
        REAL seekingUpdateTime = atof(seekUpdateTimeStr);
7194
 
        if (seekingUpdateTime >= 0)
7195
 
            Zone->SetSeekUpdate(seekingUpdateTime);
7196
 
        else
7197
 
            Zone->SetSeekUpdate(0.5);
7198
 
 
 
7155
        }
 
7156
 
 
7157
        if (zoneInteractiveBool)
 
7158
        {
 
7159
            Zone->SetWallBouncesLeft(-1);
 
7160
            Zone->SetWallInteract(zoneInteractiveBool);
 
7161
        }
 
7162
 
 
7163
        REAL targetRadius = atof(targetRadiusStr)*sizeMultiplier;
 
7164
        if(targetRadius != 0)
 
7165
            Zone->SetTargetRadius(targetRadius);
 
7166
 
 
7167
        if (seekOwnerStr.Filter() != "")
 
7168
        {
 
7169
            ePlayerNetID *seekOwnerPlayer = ePlayerNetID::FindPlayerByName(seekOwnerStr);
 
7170
            if (seekOwnerPlayer && seekOwnerPlayer->Object() && seekOwnerPlayer->Object()->Alive())
 
7171
                Zone->SetSeekingCycle(dynamic_cast<gCycle *>(seekOwnerPlayer->Object()));
 
7172
        }
 
7173
 
 
7174
        REAL seekSpeed = atof(seekSpeedStr);
 
7175
        if (seekSpeed >= 0)
 
7176
            Zone->SetSeekSpeed(seekSpeed);
 
7177
        else
 
7178
            Zone->SetSeekSpeed(1.0);
 
7179
 
 
7180
        REAL seekingUpdateTime = atof(seekUpdateTimeStr);
 
7181
        if (seekingUpdateTime >= 0)
 
7182
            Zone->SetSeekUpdate(seekingUpdateTime);
 
7183
        else
 
7184
            Zone->SetSeekUpdate(0.5);
 
7185
 
7199
7186
        Zone->SetReferenceTime();
7200
 
        Zone->SetRotationSpeed( .3f );
 
7187
        Zone->SetRotationSpeed( .3f );
7201
7188
 
7202
7189
        if(!route.empty())
7203
7190
        {
7207
7194
                Zone->AddWaypoint(*iter);
7208
7195
            }
7209
7196
        }
7210
 
        Zone->SetName(name);
 
7197
        Zone->SetName(name);
7211
7198
        Zone->SetEffect(tString("object"));
7212
 
        Zone->RequestSync();
7213
 
 
7214
 
#ifdef DEBUG
7215
 
        con << Zone->GetEffect() << " " << Zone->GOID() << " " << Zone->GetName() << " " << Zone->MapPosition().x << " " << Zone->MapPosition().y << " " << Zone->GetVelocity().x << " " << Zone->GetVelocity().y << " " << (Zone->GetWallInteract()?"true":"false") << " " << Zone->GetColor().r << " " << Zone->GetColor().g << " " << Zone->GetColor().b << "\n";
7216
 
#endif
7217
 
 
7218
 
        sg_ObjectZoneSpawned << Zone->GOID() << Zone->GetName() << Zone->MapPosition().x << Zone->MapPosition().y << Zone->GetVelocity().x << Zone->GetVelocity().y << se_GameTime();
7219
 
        sg_ObjectZoneSpawned.write();
7220
 
 
7221
 
        return;
7222
 
    }
7223
 
 
7224
 
    usage:
7225
 
    {
7226
 
        tString usageMem;
7227
 
        ePlayerNetID *rec = 0;  //  get the caller to send the message
7228
 
 
 
7199
        Zone->RequestSync();
 
7200
 
 
7201
#ifdef DEBUG
 
7202
        con << Zone->GetEffect() << " " << Zone->GOID() << " " << Zone->GetName() << " " << Zone->MapPosition().x << " " << Zone->MapPosition().y << " " << Zone->GetVelocity().x << " " << Zone->GetVelocity().y << " " << (Zone->GetWallInteract()?"true":"false") << " " << Zone->GetColor().r << " " << Zone->GetColor().g << " " << Zone->GetColor().b << "\n";
 
7203
#endif
 
7204
 
 
7205
        sg_ObjectZoneSpawned << Zone->GOID() << Zone->GetName() << Zone->MapPosition().x << Zone->MapPosition().y << Zone->GetVelocity().x << Zone->GetVelocity().y << se_GameTime();
 
7206
        sg_ObjectZoneSpawned.write();
 
7207
 
 
7208
        return;
 
7209
    }
 
7210
 
 
7211
    usage:
 
7212
    {
 
7213
        tString usageMem;
 
7214
        ePlayerNetID *rec = 0;  //  get the caller to send the message
 
7215
 
7229
7216
        usageMem << "Usage:\n"
7230
7217
                    "SPAWN_OBJECTZONE <x> <y> <size> <growth> <xdir> <ydir> <interactive> <r> <g> <b> <target_size> <seek_owner> <seek_speed> <seek_update_time>\n"
7231
 
                    "Instead of <x> <y> one can write: L <x1> <y1> <x2> <y2> [...] Z\n"
7232
 
                    "To give the zone a name, SPAWN_OBJECTZONE n <name> ...\n";
7233
 
 
7234
 
        sn_ConsoleOut(usageMem, rec->Owner());
7235
 
    }
7236
 
}
7237
 
static tConfItemFunc sg_SpawnObjectZoneConf("SPAWN_OBJECTZONE", &sg_SpawnObjectZone);
7238
 
 
 
7218
                    "Instead of <x> <y> one can write: L <x1> <y1> <x2> <y2> [...] Z\n"
 
7219
                    "To give the zone a name, SPAWN_OBJECTZONE n <name> ...\n";
 
7220
 
 
7221
        sn_ConsoleOut(usageMem, rec->Owner());
 
7222
    }
 
7223
}
 
7224
static tConfItemFunc sg_SpawnObjectZoneConf("SPAWN_OBJECTZONE", &sg_SpawnObjectZone);
 
7225
 
7239
7226
// *******************************************************************************
7240
7227
// *
7241
7228
// *    OnExit
7242
7229
// *
7243
 
// *******************************************************************************
 
7230
// *******************************************************************************
7244
7231
//!
7245
7232
//!     @param  target  the cycle that has left the zone
7246
7233
//!     @param  time    the current time
7247
7234
//!
7248
 
// *******************************************************************************
7249
 
 
7250
 
static eLadderLogWriter sg_objectZonePlayerLeft("OBJECTZONE_PLAYER_LEFT", false);
 
7235
// *******************************************************************************
 
7236
 
 
7237
static eLadderLogWriter sg_objectZonePlayerLeft("OBJECTZONE_PLAYER_LEFT", false);
7251
7238
void gObjectZoneHack::OnExit( gCycle * target, REAL time )
7252
7239
{
7253
 
    ePlayerNetID *p = target->Player();
7254
 
    if (p)
7255
 
    {
7256
 
        sg_objectZonePlayerLeft << GOID() << name_ << MapPosition().x << MapPosition().y << p->GetUserName() << target->MapPosition().x << target->MapPosition().y << target->Direction().x << target->Direction().y << se_GameTime();
7257
 
        sg_objectZonePlayerLeft.write();
 
7240
    ePlayerNetID *p = target->Player();
 
7241
    if (p)
 
7242
    {
 
7243
        sg_objectZonePlayerLeft << GOID() << name_ << MapPosition().x << MapPosition().y << p->GetUserName() << target->MapPosition().x << target->MapPosition().y << target->Direction().x << target->Direction().y << se_GameTime();
 
7244
        sg_objectZonePlayerLeft.write();
7258
7245
    }
7259
7246
}
7260
7247
 
7265
7252
// *******************************************************************************
7266
7253
 
7267
7254
void gObjectZoneHack::OnVanish( void )
7268
 
{
 
7255
{
7269
7256
    grid->RemoveGameObjectInteresting(this);
7270
 
}
7271
 
 
 
7257
}
 
7258
 
7272
7259
// *******************************************************************************
7273
7260
// *
7274
7261
// *    gSoccerZoneHack::CheckTeamAssignment
7275
7262
// *
7276
 
// *******************************************************************************
7277
 
 
7278
 
bool gSoccerZoneHack::CheckTeamAssignment()
7279
 
{
 
7263
// *******************************************************************************
 
7264
 
 
7265
bool gSoccerZoneHack::CheckTeamAssignment()
 
7266
{
7280
7267
    // find the closest player
7281
7268
    if ( !team )
7282
7269
    {
7294
7281
                eCoord otherpos = other->Position() - Position();
7295
7282
                REAL distance = otherpos.NormSquared();
7296
7283
                if (!closest || (distance < closestDistance))
7297
 
                {
7298
 
                    closest = other;
 
7284
                {
 
7285
                    closest = other;
7299
7286
                    closestDistance = distance;
7300
7287
                }
7301
7288
            }
7319
7306
            return false;
7320
7307
        }
7321
7308
    }
7322
 
    return true;
7323
 
}
7324
 
 
 
7309
    return true;
 
7310
}
 
7311
 
7325
7312
// *******************************************************************************
7326
7313
// *
7327
7314
// *    gSoccerZoneHack
7331
7318
//!     @param  grid Grid to put the zone into
7332
7319
//!     @param  pos  Position to spawn the zone at
7333
7320
//!
7334
 
// *******************************************************************************
7335
 
 
 
7321
// *******************************************************************************
 
7322
 
7336
7323
//  this is for the soccer ball
7337
7324
gSoccerZoneHack::gSoccerZoneHack( eGrid * grid, const eCoord & pos, bool dynamicCreation, bool delayCreation)
7338
7325
:gZone( grid, pos, dynamicCreation, delayCreation)
7339
7326
{
7340
7327
    color_.r = 1.0f;
7341
7328
    color_.g = 0.5f;
7342
 
    color_.b = 0.5f;
7343
 
 
7344
 
    originalPosition_ = pos;
7345
 
    originalVelocity_ = eCoord(0,0);
7346
 
 
7347
 
    init_ = false;
7348
 
    ballShots_ = 0;
7349
 
 
 
7329
    color_.b = 0.5f;
 
7330
 
 
7331
    originalPosition_ = pos;
 
7332
    originalVelocity_ = eCoord(0,0);
 
7333
 
 
7334
    init_ = false;
 
7335
    ballShots_ = 0;
 
7336
 
7350
7337
    teamDistance_ = 0;
7351
 
 
 
7338
 
7352
7339
    if (!delayCreation)
7353
 
        grid->AddGameObjectInteresting(this);
7354
 
 
7355
 
    zoneType = 1;
7356
 
    team = NULL;
7357
 
 
7358
 
    SetWallInteract(true);
7359
 
    SetWallBouncesLeft(-1);
 
7340
        grid->AddGameObjectInteresting(this);
 
7341
 
 
7342
    zoneType = 1;
 
7343
    team = NULL;
 
7344
 
 
7345
    SetWallInteract(true);
 
7346
    SetWallBouncesLeft(-1);
7360
7347
 
7361
7348
    SetExpansionSpeed(0);
7362
7349
    SetRotationSpeed( .3f );
7363
7350
    RequestSync();
7364
 
}
7365
 
 
7366
 
//  this is for the soccer goal
 
7351
}
 
7352
 
 
7353
//  this is for the soccer goal
7367
7354
gSoccerZoneHack::gSoccerZoneHack( eGrid * grid, const eCoord & pos, bool dynamicCreation, eTeam *teamowner, bool delayCreation)
7368
7355
:gZone( grid, pos, dynamicCreation, delayCreation)
7369
7356
{
7370
7357
    color_.r = 1.0f;
7371
7358
    color_.g = 0.5f;
7372
 
    color_.b = 0.5f;
7373
 
 
7374
 
    originalPosition_ = pos;
7375
 
    originalVelocity_ = eCoord(0,0);
7376
 
 
7377
 
    init_ = false;
7378
 
    ballShots_ = 0;
7379
 
 
 
7359
    color_.b = 0.5f;
 
7360
 
 
7361
    originalPosition_ = pos;
 
7362
    originalVelocity_ = eCoord(0,0);
 
7363
 
 
7364
    init_ = false;
 
7365
    ballShots_ = 0;
 
7366
 
7380
7367
    teamDistance_ = 0;
7381
 
 
 
7368
 
7382
7369
    if (!delayCreation)
7383
 
        grid->AddGameObjectInteresting(this);
7384
 
 
7385
 
    if (teamowner)
7386
 
    {
7387
 
        team = teamowner;
7388
 
        color_.r = team->R() / 15;
7389
 
        color_.g = team->G() / 15;
7390
 
        color_.b = team->B() / 15;
7391
 
    }
7392
 
    else
 
7370
        grid->AddGameObjectInteresting(this);
 
7371
 
 
7372
    if (teamowner)
 
7373
    {
 
7374
        team = teamowner;
 
7375
        color_.r = team->R() / 15;
 
7376
        color_.g = team->G() / 15;
 
7377
        color_.b = team->B() / 15;
 
7378
    }
 
7379
    else
7393
7380
        CheckTeamAssignment();
7394
7381
 
7395
7382
    SetExpansionSpeed(0);
7437
7424
//!
7438
7425
//!     @param  time    the current time
7439
7426
//!
7440
 
// *******************************************************************************
7441
 
 
7442
 
bool sg_soccerBallSlowdown = true;
7443
 
static tSettingItem<bool> sg_soccerBallSlowdownConf("SOCCER_BALL_SLOWDOWN", sg_soccerBallSlowdown);
7444
 
 
7445
 
REAL sg_soccerBallSlowdownSpeed = 0.07;
7446
 
bool restrictBallSlowdownSpeed(const REAL &newValue)
7447
 
{
7448
 
    //  if values are less than 0 or greater than 1, no good!
7449
 
    if ((newValue <= 0) || (newValue >= 1))
7450
 
            return false;
7451
 
 
7452
 
    //  if values are in between 0 and 1, good!
7453
 
    return true;
7454
 
}
7455
 
static tSettingItem<REAL> sg_soccerBallSlowdownSpeedConf("SOCCER_BALL_SLOWDOWN_SPEED", sg_soccerBallSlowdownSpeed, &restrictBallSlowdownSpeed);
 
7427
// *******************************************************************************
 
7428
 
 
7429
bool sg_soccerBallSlowdown = true;
 
7430
static tSettingItem<bool> sg_soccerBallSlowdownConf("SOCCER_BALL_SLOWDOWN", sg_soccerBallSlowdown);
 
7431
 
 
7432
REAL sg_soccerBallSlowdownSpeed = 0.07;
 
7433
bool restrictBallSlowdownSpeed(const REAL &newValue)
 
7434
{
 
7435
    //  if values are less than 0 or greater than 1, no good!
 
7436
    if ((newValue <= 0) || (newValue >= 1))
 
7437
            return false;
 
7438
 
 
7439
    //  if values are in between 0 and 1, good!
 
7440
    return true;
 
7441
}
 
7442
static tSettingItem<REAL> sg_soccerBallSlowdownSpeedConf("SOCCER_BALL_SLOWDOWN_SPEED", sg_soccerBallSlowdownSpeed, &restrictBallSlowdownSpeed);
7456
7443
 
7457
7444
bool gSoccerZoneHack::Timestep( REAL time )
7458
7445
{
7459
7446
    // delegate
7460
 
    bool returnStatus = gZone::Timestep( time );
7461
 
 
7462
 
    if ((zoneType == gSoccer_GOAL) && !team)
7463
 
        if (!CheckTeamAssignment()) return true;;
7464
 
 
7465
 
    if (!init_)
7466
 
    {
7467
 
        originalVelocity_ = GetVelocity();
7468
 
 
7469
 
        //  less than 0.1 seconds due to unknown reasons...
7470
 
        //  making sure original radius is found to be greater than 0
7471
 
        if ((time < 0.1) && (GetRadius() > 0))
7472
 
            originalRadius_ = GetRadius();
7473
 
        else
7474
 
            //  installazation success!
7475
 
            init_ = true;
7476
 
    }
7477
 
 
7478
 
    //  for slowing down the soccer ball
7479
 
    if ((zoneType == gSoccer_BALL) && sg_soccerBallSlowdown && (GetVelocity() != eCoord(0,0)))
7480
 
    {
7481
 
        //  store the current speed for setup
7482
 
        eCoord currentVelocity = GetVelocity();
7483
 
 
7484
 
        //  get the values working with decreasing the velocity speed
7485
 
        if (currentVelocity.x < 0)
7486
 
            currentVelocity.x += sg_soccerBallSlowdownSpeed;
7487
 
        else if (currentVelocity.x > 0)
7488
 
            currentVelocity.x -= sg_soccerBallSlowdownSpeed;
7489
 
 
7490
 
        if (currentVelocity.y < 0)
7491
 
            currentVelocity.y += sg_soccerBallSlowdownSpeed;
7492
 
        else if (currentVelocity.y > 0)
7493
 
            currentVelocity.y -= sg_soccerBallSlowdownSpeed;
7494
 
 
7495
 
        if (((currentVelocity.x > -1) && (currentVelocity.x < 0)) || ((currentVelocity.x > 0) && (currentVelocity.x < 1)))
7496
 
            currentVelocity.x = 0;
7497
 
 
7498
 
        if (((currentVelocity.y > -1) && (currentVelocity.y < 0)) || ((currentVelocity.y > 0) && (currentVelocity.y < 1)))
7499
 
            currentVelocity.y = 0;
7500
 
 
7501
 
        //  set new velocity
7502
 
        SetVelocity(currentVelocity);
7503
 
 
7504
 
        //RequestSync();
7505
 
    }
 
7447
    bool returnStatus = gZone::Timestep( time );
 
7448
 
 
7449
    if ((zoneType == gSoccer_GOAL) && !team)
 
7450
        if (!CheckTeamAssignment()) return true;;
 
7451
 
 
7452
    if (!init_)
 
7453
    {
 
7454
        originalVelocity_ = GetVelocity();
 
7455
 
 
7456
        //  less than 0.1 seconds due to unknown reasons...
 
7457
        //  making sure original radius is found to be greater than 0
 
7458
        if ((time < 0.1) && (GetRadius() > 0))
 
7459
            originalRadius_ = GetRadius();
 
7460
        else
 
7461
            //  installazation success!
 
7462
            init_ = true;
 
7463
    }
 
7464
 
 
7465
    //  for slowing down the soccer ball
 
7466
    if ((zoneType == gSoccer_BALL) && sg_soccerBallSlowdown && (GetVelocity() != eCoord(0,0)))
 
7467
    {
 
7468
        //  store the current speed for setup
 
7469
        eCoord currentVelocity = GetVelocity();
 
7470
 
 
7471
        //  get the values working with decreasing the velocity speed
 
7472
        if (currentVelocity.x < 0)
 
7473
            currentVelocity.x += sg_soccerBallSlowdownSpeed;
 
7474
        else if (currentVelocity.x > 0)
 
7475
            currentVelocity.x -= sg_soccerBallSlowdownSpeed;
 
7476
 
 
7477
        if (currentVelocity.y < 0)
 
7478
            currentVelocity.y += sg_soccerBallSlowdownSpeed;
 
7479
        else if (currentVelocity.y > 0)
 
7480
            currentVelocity.y -= sg_soccerBallSlowdownSpeed;
 
7481
 
 
7482
        if (((currentVelocity.x > -1) && (currentVelocity.x < 0)) || ((currentVelocity.x > 0) && (currentVelocity.x < 1)))
 
7483
            currentVelocity.x = 0;
 
7484
 
 
7485
        if (((currentVelocity.y > -1) && (currentVelocity.y < 0)) || ((currentVelocity.y > 0) && (currentVelocity.y < 1)))
 
7486
            currentVelocity.y = 0;
 
7487
 
 
7488
        //  set new velocity
 
7489
        SetVelocity(currentVelocity);
 
7490
 
 
7491
        //RequestSync();
 
7492
    }
7506
7493
 
7507
7494
    return (returnStatus);
7508
 
}
7509
 
 
 
7495
}
 
7496
 
7510
7497
// *******************************************************************************
7511
7498
// *
7512
7499
// *    GoHome
7513
7500
// *
7514
 
// *******************************************************************************
7515
 
 
7516
 
void gSoccerZoneHack::GoHome()
7517
 
{
7518
 
    //  clear last team to hit the soccer ball
7519
 
    lastTeamIn_ = NULL;
7520
 
 
7521
 
    //  send soccer ball back to it's oriignal place on the grid
 
7501
// *******************************************************************************
 
7502
 
 
7503
void gSoccerZoneHack::GoHome()
 
7504
{
 
7505
    //  clear last team to hit the soccer ball
 
7506
    lastTeamIn_ = NULL;
 
7507
 
 
7508
    //  send soccer ball back to it's oriignal place on the grid
7522
7509
    SetReferenceTime();
7523
7510
    SetPosition(originalPosition_);
7524
 
    SetVelocity(originalVelocity_);
 
7511
    SetVelocity(originalVelocity_);
7525
7512
    SetRadius(originalRadius_);
7526
 
    RequestSync();
 
7513
    RequestSync();
7527
7514
}
7528
7515
 
7529
7516
 
7536
7523
//!     @param  target  the cycle that has been found inside the zone
7537
7524
//!     @param  time    the current time
7538
7525
//!
7539
 
// *******************************************************************************
7540
 
 
7541
 
bool sg_soccerGoalKillEnemies = false;
7542
 
static tSettingItem<bool> sg_soccerGoalKillEnemiesConf("SOCCER_GOAL_KILL_ENEMIES", sg_soccerGoalKillEnemies);
7543
 
 
7544
 
bool sg_soccerGoalRespawnAllies = true;
7545
 
static tSettingItem<bool> sg_soccerGoalRespawnAlliesConf("SOCCER_GOAL_RESPAWN_ALLIES", sg_soccerGoalRespawnAllies);
7546
 
 
7547
 
bool sg_soccerGoalRespawnEnemies = true;
7548
 
static tSettingItem<bool> sg_soccerGoalRespawnEnemiesConf("SOCCER_GOAL_RESPAWN_ENEMIES", sg_soccerGoalRespawnEnemies);
7549
 
 
7550
 
static eLadderLogWriter sg_soccerBallPlayerEntered("SOCCER_BALL_PLAYER_ENTERED", false);
7551
 
static eLadderLogWriter sg_soccerGoalPlayerEntered("SOCCER_GOAL_PLAYER_ENTERED", false);
7552
 
 
 
7526
// *******************************************************************************
 
7527
 
 
7528
bool sg_soccerGoalKillEnemies = false;
 
7529
static tSettingItem<bool> sg_soccerGoalKillEnemiesConf("SOCCER_GOAL_KILL_ENEMIES", sg_soccerGoalKillEnemies);
 
7530
 
 
7531
bool sg_soccerGoalRespawnAllies = true;
 
7532
static tSettingItem<bool> sg_soccerGoalRespawnAlliesConf("SOCCER_GOAL_RESPAWN_ALLIES", sg_soccerGoalRespawnAllies);
 
7533
 
 
7534
bool sg_soccerGoalRespawnEnemies = true;
 
7535
static tSettingItem<bool> sg_soccerGoalRespawnEnemiesConf("SOCCER_GOAL_RESPAWN_ENEMIES", sg_soccerGoalRespawnEnemies);
 
7536
 
 
7537
static eLadderLogWriter sg_soccerBallPlayerEntered("SOCCER_BALL_PLAYER_ENTERED", false);
 
7538
static eLadderLogWriter sg_soccerGoalPlayerEntered("SOCCER_GOAL_PLAYER_ENTERED", false);
 
7539
 
7553
7540
void gSoccerZoneHack::OnEnter( gCycle *target, REAL time )
7554
 
{
7555
 
    if (!team && (zoneType == gSoccer_BALL))
7556
 
    {
7557
 
        //  calculate the bounce off. Source: gBallZoneHack
 
7541
{
 
7542
    if (!team && (zoneType == gSoccer_BALL))
 
7543
    {
 
7544
        //  calculate the bounce off. Source: gBallZoneHack
7558
7545
        eCoord p2 = target->Position();
7559
7546
        eCoord v2 = target->Direction()*target->Speed();
7560
7547
 
7592
7579
        base.Normalize();
7593
7580
        eCoord new_v1 = base*-target->Speed();
7594
7581
        eCoord new_p1 = p1c + new_v1*(-t+0.01);
7595
 
        new_v1 = new_v1*(1+sg_ballCycleBoost*target->GetAcceleration()/100);
7596
 
 
7597
 
        SetPosition(new_p1);
7598
 
        SetVelocity(new_v1);
7599
 
 
7600
 
        RequestSync();
7601
 
 
7602
 
        //  set last player to hit the zone
7603
 
        lastTeamIn_ = target->Team();
7604
 
 
7605
 
        sg_soccerBallPlayerEntered << target->Player()->GetUserName() << target->Team()->Name().Filter();
7606
 
        sg_soccerBallPlayerEntered.write();
7607
 
 
7608
 
    }
7609
 
    else if (team && (zoneType == gSoccer_GOAL))
7610
 
    {
7611
 
        if (sg_soccerGoalKillEnemies)
7612
 
        {
7613
 
            if (target && (team != target->Team()))
7614
 
            {
7615
 
                sn_ConsoleOut(tOutput("$soccer_goal_enemy_entered", target->Player()->GetColoredName(), Team()->GetColoredName()));
7616
 
                target->Kill();
7617
 
            }
7618
 
        }
7619
 
        else
7620
 
        {
7621
 
            if (sg_soccerGoalRespawnAllies && (team == target->Team()))
7622
 
            {
7623
 
                gSpawnPoint *pSpawn = Arena.ClosestSpawnPoint(GetPosition());
7624
 
                if (pSpawn)
7625
 
                {
7626
 
                    for(int i = 0; i < Team()->NumPlayers(); i++)
7627
 
                    {
7628
 
                        ePlayerNetID *p = Team()->Player(i);
7629
 
                        if (p)
7630
 
                        {
7631
 
                            gCycle *cycle = dynamic_cast<gCycle *>(p->Object());
7632
 
                            if (!cycle || (!cycle->Alive()))
7633
 
                            {
7634
 
                                eCoord cyclePos, cycleDir;
7635
 
                                pSpawn->Spawn(cyclePos, cycleDir);
7636
 
 
7637
 
                                gCycle *newCycle = new gCycle(Grid(), cyclePos, cycleDir, p);
7638
 
                                p->ControlObject(newCycle);
7639
 
                            }
7640
 
                        }
7641
 
                    }
7642
 
                }
7643
 
            }
7644
 
        }
7645
 
 
7646
 
        sg_soccerGoalPlayerEntered << target->Player()->GetUserName() << target->Team()->Name().Filter() << Team()->Name().Filter();
7647
 
        sg_soccerGoalPlayerEntered.write();
7648
 
    }
7649
 
}
7650
 
 
7651
 
int sg_soccerGoalScore = 1;
7652
 
static tSettingItem<int> sg_soccerGoalScoreConf("SOCCER_GOAL_SCORE", sg_soccerGoalScore);
7653
 
 
7654
 
bool sg_soccerBallFirstWin = false;
7655
 
static tSettingItem<bool> sg_soccerBallFirstWinConf("SOCCER_BALL_FIRST_WIN", sg_soccerBallFirstWin);
7656
 
 
7657
 
int sg_soccerBallShotsWin = 0;
7658
 
static tSettingItem<int> sg_soccerBallShotsWinConf("SOCCER_BALL_SHOTS_WIN", sg_soccerBallShotsWin);
7659
 
 
7660
 
void gSoccerZoneHack::OnEnter( gSoccerZoneHack *target, REAL time )
7661
 
{
7662
 
    //  check if the zone entering the goal is actually a soccer ball
7663
 
    if ((GetType() == gSoccer_GOAL) && (target->GetType() == gSoccer_BALL) && target->lastTeamIn_)
7664
 
    {
7665
 
        if (target->lastTeamIn_ == team)
7666
 
        {
7667
 
            sn_ConsoleOut(tOutput("$soccer_goal_self", Team()->GetColoredName()));
7668
 
 
7669
 
            //  time to return ball to home
7670
 
            target->GoHome();
7671
 
        }
7672
 
        else
7673
 
        {
7674
 
            //  increase the number of times the ball entered other team's goal
7675
 
            target->ballShots_++;
7676
 
 
7677
 
            target->lastTeamIn_->AddScore(sg_soccerGoalScore, tOutput("$soccer_goal_score", target->lastTeamIn_->GetColoredName(), Team()->GetColoredName(), sg_soccerGoalScore), tOutput());
7678
 
            if (sg_soccerBallFirstWin && (target->ballShots_ == 1))
7679
 
            {
7680
 
                sg_DeclareWinner(target->lastTeamIn_, tOutput("$soccer_winner"));
7681
 
 
7682
 
                //  ball must vanish after having a winner
7683
 
                target->Collapse();
7684
 
            }
7685
 
            else if ((sg_soccerBallShotsWin > 0) && (target->ballShots_ >= sg_soccerBallShotsWin))
7686
 
            {
7687
 
                eTeam *thisTeam = team;                     //  the team owner of the goal
7688
 
                eTeam *shotTeam = target->lastTeamIn_;      //  the last team to hit the ball
7689
 
 
7690
 
                if (thisTeam && shotTeam)
7691
 
                {
7692
 
                    //  ensure the team score's are compared
7693
 
                    if (shotTeam->Score() < thisTeam->Score())
7694
 
                        sg_DeclareWinner(thisTeam, tOutput("$soccer_winner"));
7695
 
                    else
7696
 
                        sg_DeclareWinner(shotTeam, tOutput("$soccer_winner"));
7697
 
 
7698
 
                    //  ball must vanish after having a winner
7699
 
                    target->Collapse();
7700
 
                }
7701
 
            }
7702
 
            else
7703
 
            {
7704
 
                //  return soccer ball home
7705
 
                target->GoHome();
7706
 
            }
7707
 
        }
7708
 
    }
 
7582
        new_v1 = new_v1*(1+sg_ballCycleBoost*target->GetAcceleration()/100);
 
7583
 
 
7584
        SetPosition(new_p1);
 
7585
        SetVelocity(new_v1);
 
7586
 
 
7587
        RequestSync();
 
7588
 
 
7589
        //  set last player to hit the zone
 
7590
        lastTeamIn_ = target->Team();
 
7591
 
 
7592
        sg_soccerBallPlayerEntered << target->Player()->GetUserName() << target->Team()->Name().Filter();
 
7593
        sg_soccerBallPlayerEntered.write();
 
7594
 
 
7595
    }
 
7596
    else if (team && (zoneType == gSoccer_GOAL))
 
7597
    {
 
7598
        if (sg_soccerGoalKillEnemies)
 
7599
        {
 
7600
            if (target && (team != target->Team()))
 
7601
            {
 
7602
                sn_ConsoleOut(tOutput("$soccer_goal_enemy_entered", target->Player()->GetColoredName(), Team()->GetColoredName()));
 
7603
                target->Kill();
 
7604
            }
 
7605
        }
 
7606
        else
 
7607
        {
 
7608
            if (sg_soccerGoalRespawnAllies && (team == target->Team()))
 
7609
            {
 
7610
                gSpawnPoint *pSpawn = Arena.ClosestSpawnPoint(GetPosition());
 
7611
                if (pSpawn)
 
7612
                {
 
7613
                    for(int i = 0; i < Team()->NumPlayers(); i++)
 
7614
                    {
 
7615
                        ePlayerNetID *p = Team()->Player(i);
 
7616
                        if (p)
 
7617
                        {
 
7618
                            gCycle *cycle = dynamic_cast<gCycle *>(p->Object());
 
7619
                            if (!cycle || (!cycle->Alive()))
 
7620
                            {
 
7621
                                eCoord cyclePos, cycleDir;
 
7622
                                pSpawn->Spawn(cyclePos, cycleDir);
 
7623
 
 
7624
                                gCycle *newCycle = new gCycle(Grid(), cyclePos, cycleDir, p);
 
7625
                                p->ControlObject(newCycle);
 
7626
                            }
 
7627
                        }
 
7628
                    }
 
7629
                }
 
7630
            }
 
7631
        }
 
7632
 
 
7633
        sg_soccerGoalPlayerEntered << target->Player()->GetUserName() << target->Team()->Name().Filter() << Team()->Name().Filter();
 
7634
        sg_soccerGoalPlayerEntered.write();
 
7635
    }
 
7636
}
 
7637
 
 
7638
int sg_soccerGoalScore = 1;
 
7639
static tSettingItem<int> sg_soccerGoalScoreConf("SOCCER_GOAL_SCORE", sg_soccerGoalScore);
 
7640
 
 
7641
bool sg_soccerBallFirstWin = false;
 
7642
static tSettingItem<bool> sg_soccerBallFirstWinConf("SOCCER_BALL_FIRST_WIN", sg_soccerBallFirstWin);
 
7643
 
 
7644
int sg_soccerBallShotsWin = 0;
 
7645
static tSettingItem<int> sg_soccerBallShotsWinConf("SOCCER_BALL_SHOTS_WIN", sg_soccerBallShotsWin);
 
7646
 
 
7647
void gSoccerZoneHack::OnEnter( gSoccerZoneHack *target, REAL time )
 
7648
{
 
7649
    //  check if the zone entering the goal is actually a soccer ball
 
7650
    if ((GetType() == gSoccer_GOAL) && (target->GetType() == gSoccer_BALL) && target->lastTeamIn_)
 
7651
    {
 
7652
        if (target->lastTeamIn_ == team)
 
7653
        {
 
7654
            sn_ConsoleOut(tOutput("$soccer_goal_self", Team()->GetColoredName()));
 
7655
 
 
7656
            //  time to return ball to home
 
7657
            target->GoHome();
 
7658
        }
 
7659
        else
 
7660
        {
 
7661
            //  increase the number of times the ball entered other team's goal
 
7662
            target->ballShots_++;
 
7663
 
 
7664
            target->lastTeamIn_->AddScore(sg_soccerGoalScore, tOutput("$soccer_goal_score", target->lastTeamIn_->GetColoredName(), Team()->GetColoredName(), sg_soccerGoalScore), tOutput());
 
7665
            if (sg_soccerBallFirstWin && (target->ballShots_ == 1))
 
7666
            {
 
7667
                sg_DeclareWinner(target->lastTeamIn_, tOutput("$soccer_winner"));
 
7668
 
 
7669
                //  ball must vanish after having a winner
 
7670
                target->Collapse();
 
7671
            }
 
7672
            else if ((sg_soccerBallShotsWin > 0) && (target->ballShots_ >= sg_soccerBallShotsWin))
 
7673
            {
 
7674
                eTeam *thisTeam = team;                     //  the team owner of the goal
 
7675
                eTeam *shotTeam = target->lastTeamIn_;      //  the last team to hit the ball
 
7676
 
 
7677
                if (thisTeam && shotTeam)
 
7678
                {
 
7679
                    //  ensure the team score's are compared
 
7680
                    if (shotTeam->Score() < thisTeam->Score())
 
7681
                        sg_DeclareWinner(thisTeam, tOutput("$soccer_winner"));
 
7682
                    else
 
7683
                        sg_DeclareWinner(shotTeam, tOutput("$soccer_winner"));
 
7684
 
 
7685
                    //  ball must vanish after having a winner
 
7686
                    target->Collapse();
 
7687
                }
 
7688
            }
 
7689
            else
 
7690
            {
 
7691
                //  return soccer ball home
 
7692
                target->GoHome();
 
7693
            }
 
7694
        }
 
7695
    }
7709
7696
}
7710
7697
 
7711
7698
// *******************************************************************************
7712
7699
// *
7713
7700
// *    OnVanish
7714
7701
// *
7715
 
// *******************************************************************************
 
7702
// *******************************************************************************
7716
7703
 
7717
7704
void gSoccerZoneHack::OnVanish( void )
7718
 
{
7719
 
    //  respawn soccer ball that suddenly disappears
7720
 
    if (zoneType == gSoccer_BALL)
7721
 
    {
7722
 
        GoHome();
7723
 
    }
7724
 
    else
 
7705
{
 
7706
    //  respawn soccer ball that suddenly disappears
 
7707
    if (zoneType == gSoccer_BALL)
 
7708
    {
 
7709
        GoHome();
 
7710
    }
 
7711
    else
7725
7712
        grid->RemoveGameObjectInteresting(this);
7726
 
}
7727
 
 
 
7713
}
 
7714
 
7728
7715
// *******************************************************************************
7729
7716
// *
7730
7717
// *    SpawnSoccer
7731
7718
// *
7732
 
// *******************************************************************************
7733
 
 
7734
 
static void sg_SpawnSoccer(std::istream &s)
7735
 
{
 
7719
// *******************************************************************************
 
7720
 
 
7721
static void sg_SpawnSoccer(std::istream &s)
 
7722
{
7736
7723
    eGrid *grid = eGrid::CurrentGrid();
7737
 
    if(!grid)
7738
 
        return;
7739
 
 
7740
 
    tString params;
7741
 
    params.ReadLine(s, true);
7742
 
 
7743
 
    if (params.Filter() == "")
7744
 
    {
7745
 
        goto usage;
7746
 
        return;
7747
 
    }
7748
 
    else
7749
 
    {
7750
 
        float sizeMultiplier = gArena::SizeMultiplier();
7751
 
        float radius, growth;
7752
 
        tString name, type, team;
7753
 
        std::vector<eCoord> route;
7754
 
        int pos = 0;
7755
 
        gZone *Zone = NULL;
7756
 
 
7757
 
        name = params.ExtractNonBlankSubString(pos);
7758
 
        if (name.ToLower() == "n")
7759
 
        {
7760
 
            name = params.ExtractNonBlankSubString(pos);
7761
 
            type = params.ExtractNonBlankSubString(pos);
7762
 
        }
7763