Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
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 |
//============================================================================= // BubbleSpawner.uc // $Author: Mfox $ // $Date: 8/05/02 12:35p $ // $Revision: 5 $ //============================================================================= class BubbleSpawner extends Effects; //============================================================================= // Spawns bubbles. Can spawn groups of 1 or more bubbles with a mechanism for // controlling the number of bubbles to spawn and the time between groups of // bubbles and between each bubble. Can be active initially, or as the result // of a trigger. // // These are spawned using the BubbleSpawner's location and rotation by default. // If the Owner is set, bubbles are spawned relative to the Owner's "mouth" and // using the Owner's rotation if the Owner is a Pawn, otherwise the Owner's // location and rotation are used as is. // // Defaults are set up so class spawns nice bubbles for pawn hit underwater. var() int MinBubbles; // min # bubbles to spawn var() int MaxBubbles; // max # bubbles to spawn var() float OffsetMinX; // shift final X (along rotation axis) coordinate - this value var() float OffsetMaxX; // shift final X (along rotation axis) coordinate + this value var() float OffsetMinY; // shift final Y (perpendicular to rotation axis) coordinate - this value var() float OffsetMaxY; // shift final Y (along rotation axis) coordinate + this value var() float OffsetMinZ; // shift final Z coordinate - this value var() float OffsetMaxZ; // shift final Z coordinate + this value var() bool bTrigger; // if set, bubbles spawned on trigger, otherwise spawned on creation var() bool bContinuous; // once started, keep spawning bubbles forever var() float TimeBetweenGroups; // time delay between spawning groups of bubbles var() float TimeBetweenBubbles; // time delay between spawning each bubble var() bool bDestroy; // whether to destroy BubbleSpawner when first group of bubbles spawned var private vector BaseLocation; var private Rotator BaseRotation; var private float NextGroupTime; var private float NextBubbleTime; var private int BubbleIndex; var private int NumBubbles; //============================================================================= event PostBeginPlay() { Super.PostBeginPlay(); if( bTrigger ) { // trigger will enable tick Disable( 'Tick' ); } // set up base location SetupSpawnBubbles(); } //============================================================================= event Tick( float DeltaTime ) { Super.Tick( DeltaTime ); if( Level.TimeSeconds > NextGroupTime ) { // currently spawning a group of bubbles if( Level.TimeSeconds > NextBubbleTime ) { if( BubbleIndex == 0 ) { NumBubbles = MinBubbles + Rand( MaxBubbles-MinBubbles+1 ); } // spawn a bubble SpawnBubble(); // delay before spawning next bubble NextBubbleTime = Level.TimeSeconds + TimeBetweenBubbles; BubbleIndex++; if( BubbleIndex == NumBubbles ) { // done spawning group of bubbles BubbleIndex = 0; NextGroupTime = Level.TimeSeconds + TimeBetweenGroups; if( !bContinuous ) { Disable( 'Tick' ); } if( bDestroy ) { Destroy(); } } } } } //============================================================================= function SetupSpawnBubbles() { if( Pawn(Owner) != None ) { // spawn bubbles relative to Pawn's mouth (exact location is a guess) BaseLocation = Owner.Location + Owner.CollisionRadius*vector(Owner.Rotation) + Pawn(Owner).EyeHeight * vect(0,0,1); BaseRotation = Owner.Rotation; } else if( Owner != None ) { // spawn bubbles relative to Owner's location, rotation BaseLocation = Owner.Location; BaseRotation = Owner.Rotation; } else { // spawn bubbles relative to location, rotation BaseLocation = Location; BaseRotation = Rotation; } } //============================================================================= function SpawnBubble() { local vector SpawnLocation; local vector XVector, YVector; local U2Bubble Bubble; // x "axis" is along rotation XVector = vector(BaseRotation); XVector.Z = 0; // y "axis" is perpendicular to x "axis" YVector = class'util'.static.PerpendicularXY( XVector ); SpawnLocation = BaseLocation + RandRange(OffsetMinX, OffsetMaxX)*XVector + RandRange(OffsetMinY, OffsetMaxY)*YVector + RandRange(OffsetMinZ, OffsetMaxZ)*vect(0,0,1); Bubble = Spawn( class'U2Bubble',,, SpawnLocation ); if( Bubble != None ) { Bubble.SetDrawScale( FRand()*0.08+0.03 ); } } //============================================================================= function Trigger( Actor Other, Pawn EventInstigator, optional name EventName ) { Enable( 'Tick' ); } //============================================================================= defaultproperties { MinBubbles=1 MaxBubbles=8 OffsetMaxX=5.000000 OffsetMinY=-5.000000 OffsetMaxY=5.000000 OffsetMinZ=-5.000000 OffsetMaxZ=10.000000 TimeBetweenGroups=5.000000 TimeBetweenBubbles=0.100000 bDestroy=true bHidden=true bDirectional=true UseReticleOnEvents(0)="UseReticleText" UseReticleOnEvents(1)="UseReticleCorners" UseReticleOnEvents(2)="UseReticleTopBars" ProximityReticleOnEvents(0)="ProximityReticleCorners" ProximityReticleOnEvents(1)="ProximityReticleTopBars" } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |