Core.Object | +--Engine.Actor | +--Engine.Keypoint | +--RuneI.ProjectileGenerator
float
AttackRadius
DelayMax
DelayMin
class
ProjectileClass
bool
bInitiallyActive
bLeadPlayer
bTrackPlayer
void
LaunchProjectile()
Trigger(Actor other, Pawn eventInstigator)
BeginState()
00001 //============================================================================= 00002 // ProjectileGenerator. 00003 //============================================================================= 00004 class ProjectileGenerator expands Keypoint; 00005 00006 var() bool bTrackPlayer; 00007 var() bool bLeadPlayer; 00008 var() bool bInitiallyActive; 00009 var() class<Projectile> ProjectileClass; 00010 var() float DelayMin; 00011 var() float DelayMax; 00012 var() float AttackRadius; 00013 00014 // INSTANCE VARIABLES --------------------------------------------------------- 00015 00016 // FUNCTIONS ------------------------------------------------------------------ 00017 00018 // STATES --------------------------------------------------------------------- 00019 00020 auto state Waiting 00021 { 00022 function BeginState() 00023 { 00024 if (bInitiallyActive) 00025 { 00026 bInitiallyActive = false; 00027 Trigger(self, None); 00028 } 00029 } 00030 00031 function Trigger(actor other, pawn eventInstigator) 00032 { 00033 GotoState('FireProjectiles'); 00034 } 00035 } 00036 00037 00038 state FireProjectiles 00039 { 00040 function Trigger(actor other, pawn eventInstigator) 00041 { 00042 GotoState('Waiting'); 00043 } 00044 00045 function LaunchProjectile() 00046 { 00047 local PlayerPawn P; 00048 local projectile proj; 00049 local vector vec, jitter; 00050 local rotator rot; 00051 00052 if(bTrackPlayer) 00053 { 00054 // Find the first player in a given radius 00055 foreach VisibleActors(class'PlayerPawn', P, AttackRadius, Location) 00056 { // Grab the first player visible 00057 if(P.Health > 0) 00058 break; 00059 } 00060 00061 if(P == None) 00062 return; // No player found, so don't launch a projectile 00063 00064 // Compute a slight bit of jitter for the projectile direction 00065 jitter = VRand() * 25; 00066 00067 // Lead the player 00068 if(bLeadPlayer) 00069 { 00070 jitter.X += P.Velocity.X * 0.6; 00071 jitter.Y += P.Velocity.Y * 0.6; 00072 } 00073 00074 // Compute the vector to the player 00075 vec = Normal((P.Location + jitter) - Location); 00076 rot = rotator(vec); 00077 } 00078 else 00079 { 00080 rot = Rotation; 00081 vec = vector(rot); 00082 } 00083 00084 proj = Spawn(ProjectileClass, self,, Location, rot); 00085 00086 if(proj != None) 00087 proj.Velocity = vec * proj.Speed; 00088 } 00089 00090 begin: 00091 LaunchProjectile(); 00092 Sleep(RandRange(DelayMin, DelayMax)); 00093 Goto('begin'); 00094 } 00095 00096 defaultproperties 00097 { 00098 bTrackPlayer=True 00099 bLeadPlayer=True 00100 bInitiallyActive=True 00101 DelayMin=1.000000 00102 DelayMax=1.000000 00103 AttackRadius=2000.000000 00104 bStatic=False 00105 bDirectional=True 00106 CollisionRadius=32.000000 00107 CollisionHeight=8.000000 00108 }