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 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 |
//======================================================== // class : VegetationGenerator // file : VegetationGenerator.uc // author : Raven // game : The Chosen One // description : Spawn Vegetation (plants) in the effect area // version : 1.1 //======================================================== // version history: // 1.1 // - added few optimalizations // 1.0 // - CutVegetation and VegetationVisibility // - Bush Sound // 0.9 // - Most of the var's is now in struct // - Many new options // 0.8 // - first version :) //======================================================== class UIVegetationGenerator extends Actor; //==================================================================================================== #exec TEXTURE IMPORT NAME=VegetationGenerator FILE="Textures\Icons\VegetationGen.bmp" GROUP=Icons LODSET=2 //==================================================================================================== // main var's //==================================================================================================== enum EPlayType { PT_Loop, PT_Play }; struct SPlants { var() class<UIFlora> PlantClass; // gras to spawn var() float VegetationScale; // Vegetation scale var() float VegetationScaleVariance; // Vegetation scale variance var() bool bUseCustomGlow; // should we use custom glow var() float VegetationGlow; // scale glow var() float VegetationGlowVariance; // scale glow variance var() bool bUseCustomAmbientGlow; // should we use custom Ambient Glow var() byte VegetationAmbientGlow; // ambient glow var() bool bUnlitVegetation; // gras should be unlit? var() bool bRandomRotation; // use random rotation var() bool bUseCustomRotation; // use custom rotation (cant be used with random rotation) var() rotator CustomRotation; // custom rotation var() bool CullVegetation; // planst will be hidden if we are too far from them (VegetationVisibilityRadius) var() float CullRadius; // radius in which Vegetation will be visible var() float CullHeight; // radius in which Vegetation will be visible var() bool PlayBushSound; // playing bush sound var() sound BushSound1; // bush sound var() sound BushSound2; // bush sound var() sound BushSound3; // bush sound var() float BushSoundVolume; var() bool bAlignToGround; // aligns plant to ground var() bool bOverrideEffectArea; // uses effectarea defined in template var() vector EffectArea; // area in which we will spawn Vegetation var() bool bOverrideIntensity; // intensity per template :) var() int VegetationIntensity; // how many plants we have to spawn var() bool bOverrideBushSettings; // oberrides bush settings var() vector SpawnOffset; // spawn offset var() bool bUsePhysicsPostAlign; // set PHYS_Falling in order to fix location var() mesh CustomMesh; // ustom mesh var() bool bUseCustomCollision; // should use custom collision var() float CustomCollisionRadius; // custom collision radius var() float CustomCollisionHeight; // custom collision height var() texture CustomTexture; // custom texture var() texture CustomMultiSkins[8]; // custom multi skins :) var() int MultiskinsNum; // number of multiskins :) var() bool bUseAnim; // should animation be used var() EPlayType PlayType; // play type var() float PlayRate; // play rate var() float PlayTween; // play tween var() name AnimName; // animation name var() bool bOverrideRenderStake; var() ERenderStyle PlantRenderStyle; }; var() SPlants Plants[16]; // plants :) var() int VegetationIntensity; // how many plants we have to spawn var() int NumberOfErrors; // how much Vegetation can be spawned outside geometry before script stops var() vector EffectArea; // area in which we will spawn Vegetation var() int NumPlants; var() enum Select { SELECT_Linear, // cyclically iterate through Plants SELECT_Random // randomly pick a particle from Plants } SelectionMethod; var(Advanced) bool bDebug; var int ChosenTemplate; // current template //==================================================================================================== // pick up random meshes //==================================================================================================== simulated function int PickTemplate() { if (NumPlants <= 0) return 0; if (SelectionMethod == SELECT_Random) return Rand(NumPlants); if (SelectionMethod == SELECT_Linear) { if (ChosenTemplate == NumPlants-1) ChosenTemplate=0; else ChosenTemplate++; return ChosenTemplate; } return 0; } //==================================================================================================== // we need to do everythig when game begins, and after this delete generator form the game //==================================================================================================== simulated function PostBeginPlay() { local int i, j, k; local int ChosenPlant, TIntensity; if (NumPlants <=0) Destroy(); j=0; for (k=0; k<NumPlants; k++) { ChosenPlant=PickTemplate(); if (Plants[ChosenPlant].bOverrideIntensity) TIntensity=Plants[ChosenPlant].VegetationIntensity; else TIntensity = VegetationIntensity; i=0; while (i<TIntensity) { if (j>NumberOfErrors) //when too much Vegetation is spawned outside geometry { Destroy(); //we need to be destroyed, because we may occur critical error } SpawnPlant(ChosenPlant, j); i++; } } Destroy(); //this actor should be destroyed, beacouse it is no longer used } //==================================================================================================== // spawns plant //==================================================================================================== simulated function SpawnPlant(int ChosenPlant, out int j) { local int i, RD; local UIFlora SpawnedVegetation; local vector TempLoc, RealLoc; local rotator NewRot; local float GS; local Actor HitActor; local Vector HitNormal,HitLocation, StartTrace, EndTrace; //Pick up new location if (Plants[ChosenPlant].bOverrideEffectArea) { TempLoc.X = Location.X + (1 - FRand() * 2) * Plants[ChosenPlant].EffectArea.X; TempLoc.Y = Location.Y + (1 - FRand() * 2) * Plants[ChosenPlant].EffectArea.Y; TempLoc.Z = Location.Z; //Z doesnt need to be changed } else { TempLoc.X = Location.X + (1 - FRand() * 2) * EffectArea.X; TempLoc.Y = Location.Y + (1 - FRand() * 2) * EffectArea.Y; TempLoc.Z = Location.Z; //Z doesnt need to be changed } //trace for ground StartTrace = TempLoc; EndTrace = StartTrace; EndTrace.Z = EndTrace.Z - 300; HitActor = Trace(HitLocation, HitNormal, EndTrace, StartTrace, false); TempLoc.Z=HitLocation.Z; TempLoc+=Plants[ChosenPlant].SpawnOffset; SpawnedVegetation = spawn(Plants[ChosenPlant].PlantClass,,,TempLoc,); // RealLoc=SpawnedVegetation.Location; // RealLoc.Z+=SpawnedVegetation.CollisionHeight; // SpawnedVegetation.SetLocation(RealLoc); if (SpawnedVegetation != none) //if Vegetation exists in the game { if (Plants[ChosenPlant].bAlignToGround) { SpawnedVegetation.SetRotation(rotator(HitNormal)); } GS=Plants[ChosenPlant].VegetationScale + (1-FRand()*2) * Plants[ChosenPlant].VegetationScaleVariance; SpawnedVegetation.bUnlit=Plants[ChosenPlant].bUnlitVegetation; if (!Plants[ChosenPlant].bUsePhysicsPostAlign && Plants[ChosenPlant].bAlignToGround) { RealLoc.Z=HitLocation.Z; RealLoc.Z-=SpawnedVegetation.CollisionHeight; } if (GS != SpawnedVegetation.DrawScale && Plants[ChosenPlant].bAlignToGround) { RealLoc=SpawnedVegetation.Location; if (SpawnedVegetation.DrawScale < GS) { RealLoc.Z+=SpawnedVegetation.CollisionHeight*abs(GS-SpawnedVegetation.DrawScale); } else { RealLoc.Z-=SpawnedVegetation.CollisionHeight/GS; } SpawnedVegetation.SetLocation(RealLoc); } SpawnedVegetation.DrawScale=GS; if (Plants[ChosenPlant].bUseCustomCollision) SpawnedVegetation.SetCollisionSize(Plants[ChosenPlant].CustomCollisionRadius*GS, Plants[ChosenPlant].CustomCollisionHeight*GS); else SpawnedVegetation.SetCollisionSize(SpawnedVegetation.default.CollisionRadius*GS, SpawnedVegetation.default.CollisionHeight*GS); if (Plants[ChosenPlant].bUsePhysicsPostAlign) SpawnedVegetation.SetPhysics(PHYS_Falling); if (Plants[ChosenPlant].bUseCustomGlow) SpawnedVegetation.ScaleGlow=Plants[ChosenPlant].VegetationGlow+(1-FRand()*2)*Plants[ChosenPlant].VegetationGlowVariance; if (Plants[ChosenPlant].bUseCustomAmbientGlow) SpawnedVegetation.AmbientGlow=Plants[ChosenPlant].VegetationAmbientGlow; if (Plants[ChosenPlant].bRandomRotation) { RD=Rand(5); switch (RD) { case 0: //45� NewRot=SpawnedVegetation.Rotation; NewRot.Yaw=8192; SpawnedVegetation.SetRotation(NewRot); break; case 1: //90� NewRot=SpawnedVegetation.Rotation; NewRot.Yaw=16384; SpawnedVegetation.SetRotation(NewRot); break; case 2: //180� NewRot=SpawnedVegetation.Rotation; NewRot.Yaw=32768; SpawnedVegetation.SetRotation(NewRot); break; case 3: //270� NewRot=SpawnedVegetation.Rotation; NewRot.Yaw=49152; SpawnedVegetation.SetRotation(NewRot); break; case 4: //360� NewRot=SpawnedVegetation.Rotation; NewRot.Yaw=65536; SpawnedVegetation.SetRotation(NewRot); break; } } if (Plants[ChosenPlant].bUseCustomRotation) { SpawnedVegetation.SetRotation(SpawnedVegetation.Rotation+Plants[ChosenPlant].CustomRotation); } if (Plants[ChosenPlant].CullVegetation) { SpawnedVegetation.VisibilityRadius=Plants[ChosenPlant].CullRadius; SpawnedVegetation.VisibilityHeight=Plants[ChosenPlant].CullHeight; } if (Plants[ChosenPlant].CustomMesh != none) SpawnedVegetation.Mesh=Plants[ChosenPlant].CustomMesh; if (Plants[ChosenPlant].CustomTexture != none) { SpawnedVegetation.Texture=Plants[ChosenPlant].CustomTexture; SpawnedVegetation.Skin=Plants[ChosenPlant].CustomTexture; } if (Plants[ChosenPlant].MultiskinsNum > 0 && Plants[ChosenPlant].MultiskinsNum < 8) { for (i=0; i<Plants[ChosenPlant].MultiskinsNum; i++) SpawnedVegetation.MultiSkins[i]=Plants[ChosenPlant].CustomMultiSkins[i]; } if (Plants[ChosenPlant].bOverrideBushSettings) { SpawnedVegetation.bBushSound=Plants[ChosenPlant].PlayBushSound; if (Plants[ChosenPlant].BushSound1 != none) SpawnedVegetation.SSound1=Plants[ChosenPlant].BushSound1; if (Plants[ChosenPlant].BushSound2 != none) SpawnedVegetation.SSound2=Plants[ChosenPlant].BushSound2; if (Plants[ChosenPlant].BushSound2 != none) SpawnedVegetation.SSound3=Plants[ChosenPlant].BushSound3; if (Plants[ChosenPlant].BushSoundVolume > 0) SpawnedVegetation.SSoundVolume=Plants[ChosenPlant].BushSoundVolume; } if (Plants[ChosenPlant].bUseAnim && SpawnedVegetation.HasAnim(Plants[ChosenPlant].AnimName)) { if (Plants[ChosenPlant].PlayType == PT_Loop) SpawnedVegetation.LoopAnim(Plants[ChosenPlant].AnimName, Plants[ChosenPlant].PlayRate, Plants[ChosenPlant].PlayTween); else SpawnedVegetation.PlayAnim(Plants[ChosenPlant].AnimName, Plants[ChosenPlant].PlayRate, Plants[ChosenPlant].PlayTween); } if (Plants[ChosenPlant].bOverrideRenderStake) { SpawnedVegetation.Style=Plants[ChosenPlant].PlantRenderStyle; } } else { if (bDebug) log("Error: Vegetation no. "$ChosenPlant$" ("$Plants[ChosenPlant].PlantClass$") from "$self$" can not be spawned - wrong location.",'VegetationGenerator'); j++; } } //==================================================================================================== defaultproperties { Plants(0)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(1)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(2)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(3)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(4)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(5)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(6)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(7)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(8)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(9)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(10)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(11)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(12)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(13)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(14)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) Plants(15)=(VegetationScale=1.000000,VegetationScaleVariance=0.200000,bUseCustomRotation=True,CustomRotation=(Pitch=-16384),PlayBushSound=True,BushSound1=Sound'UnrealShare.shrub.shrub1',BushSound2=Sound'UnrealShare.shrub.shrub2',BushSound3=Sound'UnrealShare.shrub.shrub3',BushSoundVolume=64.000000,bAlignToGround=True,VegetationIntensity=5) VegetationIntensity=5 NumberOfErrors=15 EffectArea=(X=256.000000,Y=256.000000) bHidden=True bNoDelete=True RemoteRole=ROLE_SimulatedProxy Style=STY_Masked Texture=Texture'UnrealShare.Icons.VegetationGenerator' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |