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

U2Weapons.projectileRocketGuide


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
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
//=============================================================================
// projectileRocketGuide.uc
// $Author: Mfox $
// $Date: 9/03/02 10:04p $
// $Revision: 12 $
//=============================================================================
class projectileRocketGuide extends Projectile;

var int OrigSeed; //the seed that gets replicated
var int CurrSeed; //the seed that actually changes and is updated

var() float MiniRocketDelay;
var() int MiniRocketCount;

var float TimePassed; //the amount of time passed so far

var bool bGotRotation, bGotSeed;

// a hack, but arrays of bools do not work.
// and we need to have optimized networking
var struct ERocketStatus {
	var bool R0;
	var bool R1;
	var bool R2;
	var bool R3;
} RocketStatus;

var projectileMiniRocket Rockets[4];
var Actor PaintedTargets[4];

event Replication()
{
	Super.Replication();
	DOREP('RocketStatus');
	if( bNetInitial )
	{
		DOREP('TimePassed');
		DOREP('OrigSeed');
	}
}

simulated event PostBeginPlay()
{
	Super.PostBeginPlay();
	if( Role==ROLE_Authority )
	{
		Velocity = Vector(Rotation) * Speed;
		while( OrigSeed == 0 )
			OrigSeed = Rand(MaxInt);
		CurrSeed = OrigSeed;
	}
}

//AddTimer( 'SpawnRocketTimer', MiniRocketDelay );

simulated function PostRecvVelocity()
{
	Super.PostRecvVelocity(); //set the rotation for us
	bGotRotation = true;
	CheckConditions();
}
simulated function PostRecvOrigSeed()
{
	CurrSeed = OrigSeed;
	bGotSeed = true;
	CheckConditions();
}
simulated function CheckConditions()
{
	if( bGotRotation && bGotSeed )
		SetupInitData();
}

simulated function SetupInitData()
{
	//mjl-tbd: spawn them in sequence
//	SpawnRocket();
//	SpawnRocket();
//	SpawnRocket();
//	SpawnRocket();
	SpawnRocketTimer();		// Fix MJL: Does this break replication?
}

simulated event Tick( float DeltaTime )
{
	Super.Tick(DeltaTime);
	TimePassed += DeltaTime; // cannot use LifeSpan here, since LifeSpan destroys the object at LifeSpan == 0
}

simulated function SpawnRocket()
{
	local projectileMiniRocket r;
	r = Spawn( class'projectileMiniRocket', Self,, Location, Rotation );
	Rockets[--MiniRocketCount] = r;

	if( !r.SetTarget(PaintedTargets[MiniRocketCount]) )
	{
		r.SetupData(CurrSeed);
		r.SetCorrectLocation();
	}

	if( MiniRocketCount == 0 )
		RocketStatus.R0 = true;
	else
	if( MiniRocketCount == 1 )
		RocketStatus.R1 = true;
	else
	if( MiniRocketCount == 2 )
		RocketStatus.R2 = true;
	else
	if( MiniRocketCount == 3 )
		RocketStatus.R3 = true;
}

simulated function SpawnRocketTimer()
{
	SpawnRocket();
	
	if( MiniRocketCount>0 )
		AddTimer( 'SpawnRocketTimer', MiniRocketDelay );
}

simulated function SubRocketDestroyed( projectileMiniRocket r )
{
	if( Rockets[0] == r )
	{
		RocketStatus.R0 = false;
		Rockets[0] = None;
	}
	else
	if( Rockets[1] == r )
	{
		RocketStatus.R1 = false;
		Rockets[1] = None;
	}
	else
	if( Rockets[2] == r )
	{
		RocketStatus.R2 = false;
		Rockets[2] = None;
	}
	else
	if( Rockets[3] == r )
	{
		RocketStatus.R3 = false;
		Rockets[3] = None;
	}


	//!!ARL (mdf) fix for AddTimer being called on destroyed actor above?
	// make sure done spawning all rockets?
	if( MiniRocketCount<=0 && !( RocketStatus.R0 || RocketStatus.R1 || RocketStatus.R2 || RocketStatus.R3 ) )
	//if( !( RocketStatus.R0 || RocketStatus.R1 || RocketStatus.R2 || RocketStatus.R3 ) )
		Destroy();
}

simulated function PostRecvRocketStatus()
{
	if( Rockets[0] != None && !RocketStatus.R0 )
		Rockets[0].Destroy();
	else
	if( Rockets[1] != None && !RocketStatus.R1 )
		Rockets[1].Destroy();
	else
	if( Rockets[2] != None && !RocketStatus.R2 )
		Rockets[2].Destroy();
	else
	if( Rockets[3] != None && !RocketStatus.R3 )
		Rockets[3].Destroy();
}

simulated event Destroyed()
{
	local int i;
	Super.Destroyed();
	for(i=0;i<ArrayCount(Rockets);i++)
		if( Rockets[i] != None && !Rockets[i].bDeleteMe )
			Rockets[i].Destroy();
	RemoveAllTimers();	//just in case.
}

simulated function ProcessTouch(Actor Other, Vector HitLocation) {}

defaultproperties
{
	MiniRocketDelay=0.120000
	MiniRocketCount=4
	speed=2000.000000
	MaxSpeed=1200.000000
	bHidden=true
	bHiddenRelevant=true
	bNetTemporary=false
	LifeSpan=12.000000
	DrawScale=3.000000
	bAllowClipping=true
     UseReticleOnEvents(0)="UseReticleText"
     UseReticleOnEvents(1)="UseReticleCorners"
     UseReticleOnEvents(2)="UseReticleTopBars"
     ProximityReticleOnEvents(0)="ProximityReticleCorners"
     ProximityReticleOnEvents(1)="ProximityReticleTopBars"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: sk 3-1-2016 10:38:42.000 - Creation time: sk 3-1-2016 10:48:41.241 - Created with UnCodeX