Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

ROEngine.ROArtillerySpawner


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
//=============================================================================
// ROArtillerySpawner
//=============================================================================
// A helper class for the ROArtilleryShell. Handles spawning the individual
// Artillery rounds and the logic associated with that.
//=============================================================================
// Red Orchestra Source
// Copyright (C) 2003-2004 John Gibson
//=============================================================================

class ROArtillerySpawner extends Actor;

//=============================================================================
// Variables
//=============================================================================

var int SpawnCounter;
var int SalvoCounter;
var int OwningTeam;
var int SalvoAmount;
var int BatterySize;
var int StrikeDelay;
var int SpreadAmount;

var Controller	InstigatorController; // The controller that spawned this
var ROArtilleryShell LastSpawnedShell;// The last shell spawned by this arty spawner
var vector OriginalArtyLocation;      // Stores the location of the place the arty was originally called on

//=============================================================================
// Functions
//=============================================================================

function PostBeginPlay()
{
	local int StrikeTemp;
	local ROLevelInfo LI;

	Super.PostBeginPlay();

	InstigatorController = Controller(Owner);

    OwningTeam = InstigatorController.GetTeamNum();

	LI = ROTeamGame(Level.Game).LevelInfo;

     BatterySize=LI.GetBatterySize(OwningTeam);
     SalvoAmount=LI.GetSalvoAmount(OwningTeam);
     SpreadAmount=LI.GetSpreadAmount(OwningTeam);
     StrikeTemp=LI.GetStrikeDelay(OwningTeam); // Delay

    // Save artillery strike position to GRI
    ROGameReplicationInfo(Level.Game.GameReplicationInfo).ArtyStrikeLocation[OwningTeam] = location;

	if (FRand() < 0.5)
	{
	 	StrikeDelay =  StrikeTemp +  (StrikeTemp * (Frand() * 0.15));
	}
	else
	{
	 	StrikeDelay =  StrikeTemp -  (StrikeTemp * (Frand() * 0.15));
	}

	SetTimer(StrikeDelay, false);
}

function Destroyed()
{
    // Remove arty location from GRI
    ROGameReplicationInfo(Level.Game.GameReplicationInfo).ArtyStrikeLocation[OwningTeam] = vect(0,0,0);
    LastSpawnedShell = none;
    super.Destroyed();
}

// Cancel the strike. Are we using this? Ramm
function CallOffStrike()
{
   Destroy();
}

function timer()
{
	local vector AimVec;
	local ROVolumeTest RVT;
	local ROPlayer ROP;
	//local int OwningTeam, SalvoSize;

    // Hack: Lets find a better way to prevent arty from spilling to the next round.
    // Also kill the arty strike if the commander switches teams or leaves the server
    if ( (!ROTeamGame(Level.Game).IsInState('RoundInPlay'))
        || InstigatorController == none || InstigatorController.GetTeamNum() != OwningTeam )
    {
        if( LastSpawnedShell != none && !LastSpawnedShell.bDeleteMe )
        {
            LastSpawnedShell.Destroy();
        }

        Destroy();
        return;
    }

    RVT = Spawn(class'ROVolumeTest',self,,OriginalArtyLocation);

    // If the place this arty is falling has become a NoArtyVolume after the
    // strike was called, cancel the strike.
    if ((RVT != none && RVT.IsInNoArtyVolume()))
    {
        ROP = ROPlayer(InstigatorController);

        if ( ROP != none )
        {
            ROP.ReceiveLocalizedMessage(class'ROArtilleryMsg', 5);
        }

        RVT.Destroy();

        if( LastSpawnedShell != none && !LastSpawnedShell.bDeleteMe )
        {
            LastSpawnedShell.Destroy();
        }

        Destroy();
        return;
    }

    RVT.Destroy();



	if( SpawnCounter <= BatterySize)
	{
	    AimVec = vect(0,0,0);
	    AimVec.X += Rand(SpreadAmount);// was 500
	    if (Frand() > 0.5)
	    {
           AimVec.X *= -1;
	    }

	    AimVec.Y += Rand(SpreadAmount);
	    if (Frand() > 0.5)
	    {
           AimVec.Y *= -1;
	    }


        LastSpawnedShell = Spawn(class 'ROArtilleryShell',InstigatorController,, Location + AimVec, rotator(PhysicsVolume.Gravity));

        SpawnCounter++;
        SetTimer(FRand() * 1.5, false);
        return;
    }

    if( SalvoCounter < SalvoAmount )
    {
        SalvoCounter++;
        SpawnCounter = 0;
        SetTimer(Max(Rand(20),10), false);// Time between salvos
    }
    else
    {
    		Destroy();   // Hope this doesn't F anything up
    }
}

defaultproperties
{
     DrawType=DT_None
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fri 13-10-2023 03:17:28.000 - Creation time: Fri 13-10-2023 03:19:06.591 - Created with UnCodeX