RuneI
Class LightningPowerupBall

source: c:\runehov\RuneI\Classes\LightningPowerupBall.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Projectile
         |
         +--RuneI.LightningPowerupBall
Direct Known Subclasses:None

class LightningPowerupBall
extends Engine.Projectile

//============================================================================= // LightningPowerupBall. //=============================================================================
Variables
 Electricity Electricity[3]
 float ScaleSpeed
 float Time
 int ZapDamage
 float ZapRadius


Function Summary
 
simulated
ClearZapList()
 
simulated
Explode(vector HitLocation, vector HitNormal)
 
simulated
HitWall(vector HitNormal, Actor Wall)
 void IssueZapDamage(Actor A)
     
//===================================================================
//
// IssueZapDamage
//
// Server-side joint damage function
//===================================================================
 
simulated
Landed(vector HitNormal, Actor HitActor)
 
simulated
PostBeginPlay()
 
simulated
SetZapTarget(int index, Actor A)
 
simulated
Tick(float DeltaTime)
 
simulated
Timer()



Source Code


00001	//=============================================================================
00002	// LightningPowerupBall.
00003	//=============================================================================
00004	class LightningPowerupBall expands Projectile;
00005	
00006	var(Sounds) Sound LightningFireSound[3];
00007	var float Time;
00008	var float ZapRadius;
00009	var Electricity Electricity[3];
00010	var int ZapDamage;
00011	var float ScaleSpeed;
00012	
00013	simulated function PostBeginPlay()
00014	{
00015		local int i;
00016	
00017		Super.PostBeginPlay(); 
00018	
00019		SetTimer(0.25, true);
00020	
00021		for(i = 0; i < ArrayCount(Electricity); i++)
00022		{
00023			Electricity[i] = Spawn(class'Electricity', Owner,, Location);
00024			Electricity[i].SetBase(self);
00025			Electricity[i].Target = None;
00026			Electricity[i].RemoteRole = ROLE_None;
00027		}
00028	}
00029	
00030	simulated function ClearZapList()
00031	{
00032		local int i;
00033	
00034		for(i = 0; i < ArrayCount(Electricity); i++)
00035		{
00036			Electricity[i].Target = None;
00037			Electricity[i].TargetJointIndex = 0;
00038			Electricity[i].bHidden = true;
00039		}
00040	}
00041	
00042	//===================================================================
00043	//
00044	// IssueZapDamage
00045	//
00046	// Server-side joint damage function
00047	//===================================================================
00048	function IssueZapDamage(Actor A)
00049	{
00050		A.JointDamaged(ZapDamage, Pawn(Owner), A.Location, vect(0,0,0), MyDamageType, 0);
00051	}
00052	
00053	simulated function SetZapTarget(int index, actor A)
00054	{
00055		if(index < 0 || index >= ArrayCount(Electricity))
00056			return;
00057	
00058		Electricity[index].bHidden = false;
00059		Electricity[index].Target = A;
00060		if(A.Skeletal != None)
00061		{ // Jump the electricity around on random joints
00062			Electricity[index].TargetJointIndex = Rand(A.NumJoints());
00063		}
00064	
00065		// Damage this actor that is being zapped
00066		if(Rand(3) > 1)
00067		{
00068			PlaySound(LightningFireSound[Rand(3)], SLOT_Interface);
00069		}
00070		
00071		IssueZapDamage(A);
00072	}
00073	
00074	simulated function Timer()
00075	{
00076		local actor A;
00077		local int count;
00078	
00079		// Clear list of actors being currently zapped
00080		ClearZapList();
00081	
00082		// Then look for all possible targets in a given radius
00083		count = 0;
00084		foreach VisibleActors(class'Actor', A, ZapRadius, Location)
00085		{
00086			if(A == self || A == Owner || A.Owner == Owner)
00087				continue;
00088	
00089			if (ScriptPawn(A)!=None && ScriptPawn(A).bIsBoss)
00090				continue;
00091	
00092			if(A.IsA('Pawn') || A.IsA('Mover') || A.IsA('Polyobj') || A.IsA('Carcass')
00093				|| (A.IsA('DecorationRune') && DecorationRune(A).bDestroyable))
00094			{
00095				SetZapTarget(count, A);		
00096				count++;
00097			}
00098		}
00099	}
00100	
00101	simulated function Tick(float DeltaTime)
00102	{
00103		ScaleGlow += DeltaTime * ScaleSpeed;
00104		if(ScaleGlow > 2.0)
00105		{
00106			ScaleGlow = 2.0;
00107			ScaleSpeed = -ScaleSpeed;
00108		}
00109		else if(ScaleGlow < 0.5)
00110		{
00111			ScaleGlow = 0.5;
00112			ScaleSpeed = -ScaleSpeed;
00113		}
00114	
00115		Time -= DeltaTime;
00116		if(Time <= 0)
00117			Explode(Location, vect(0, 0, 1));
00118	}
00119	
00120	simulated function HitWall(vector HitNormal, actor Wall)
00121	{ // Bounce!
00122		Velocity = Velocity - 2 * HitNormal * (Velocity Dot HitNormal);
00123	}
00124	
00125	simulated function Landed(vector HitNormal, actor HitActor)
00126	{
00127		HitWall(HitNormal, HitActor);
00128	}
00129	
00130	simulated function Explode(vector HitLocation, vector HitNormal)
00131	{	
00132		local int i;
00133	
00134		for(i = 0; i < ArrayCount(Electricity); i++)
00135		{
00136			if(Electricity[i] != None)
00137				Electricity[i].Destroy();
00138		}
00139	
00140		Destroy();
00141	}
00142	
00143	defaultproperties
00144	{
00145	     LightningFireSound(0)=Sound'WeaponsSnd.PowerUps.aelec01'
00146	     LightningFireSound(1)=Sound'WeaponsSnd.PowerUps.aelec02'
00147	     LightningFireSound(2)=Sound'WeaponsSnd.PowerUps.aelec03'
00148	     Time=3.000000
00149	     ZapRadius=350.000000
00150	     ZapDamage=3
00151	     ScaleSpeed=1.000000
00152	     MaxSpeed=100.000000
00153	     Damage=20.000000
00154	     MyDamageType=magic
00155	     RemoteRole=ROLE_SimulatedProxy
00156	     DrawType=DT_Sprite
00157	     Style=STY_Translucent
00158	     Texture=FireTexture'RuneFX2.lightningstart'
00159	     DrawScale=0.500000
00160	     ScaleGlow=0.500000
00161	     AmbientGlow=50
00162	     SpriteProjForward=5.000000
00163	     CollisionRadius=20.000000
00164	     CollisionHeight=20.000000
00165	     bCollideActors=False
00166	     bBounce=True
00167	}

End Source Code