Advertisement
Guest User

SCUBAGear.uc

a guest
Mar 31st, 2018
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // SCUBAGear.
  3. //=============================================================================
  4. class SCUBAGear extends Pickup;
  5.  
  6. #exec OBJ LOAD FILE=Detail.utx
  7.  
  8. #exec AUDIO IMPORT FILE="Sounds\Pickups\scubada1.wav" NAME="Scubada1" GROUP="Pickups"
  9. #exec AUDIO IMPORT FILE="Sounds\Pickups\scubal1.wav" NAME="Scubal1" GROUP="Pickups"
  10. #exec AUDIO IMPORT FILE="Sounds\Pickups\scubal2.wav" NAME="Scubal2" GROUP="Pickups"
  11.  
  12. #exec TEXTURE IMPORT NAME=I_Scuba FILE=Textures\Hud\i_scuba.pcx GROUP="Icons" MIPS=OFF
  13.  
  14. #exec MESH IMPORT MESH=Scuba ANIVFILE=Models\Scuba_a.3d DATAFILE=Models\Scuba_d.3d X=0 Y=0 Z=0 LODSTYLE=8 MLOD=1
  15.  
  16. // 71 Vertices, 131 Triangles
  17. #exec MESH LODPARAMS MESH=Scuba STRENGTH=0.5 MINVERTS=36 MORPH=0.3 ZDISP=1200.0
  18. #exec MESH ORIGIN MESH=Scuba X=0 Y=-400 Z=-100 YAW=64
  19. #exec MESH SEQUENCE MESH=Scuba SEQ=All    STARTFRAME=0  NUMFRAMES=1
  20. #exec TEXTURE IMPORT NAME=ASC1 FILE=Models\scuba.pcx GROUP="Skins" DETAIL=Metal
  21. #exec MESHMAP SCALE MESHMAP=Scuba X=0.04 Y=0.04 Z=0.08
  22. #exec MESHMAP SETTEXTURE MESHMAP=Scuba NUM=1 TEXTURE=ASC1 TLOD=10
  23.  
  24. var vector X,Y,Z;
  25. var Actor EffectsActor;
  26.  
  27. function inventory PrioritizeArmor( int Damage, name DamageType, vector HitLocation )
  28. {
  29.     if (DamageType == 'Breathe')
  30.     {
  31.         if (Pawn(Owner)!=None && IsInState('activated')
  32.                 && !Pawn(Owner).FootRegion.Zone.bPainZone) Pawn(Owner).PainTime=12;
  33.         GotoState('Deactivated');
  34.     }
  35.     else if (DamageType == 'Drowned' && Damage==0)
  36.         GoToState('Activated');
  37.     if (DamageType == 'Drowned')
  38.     {
  39.         NextArmor = None;
  40.         Return Self;
  41.     }
  42.     return Super.PrioritizeArmor(Damage, DamageType, HitLocation);
  43. }
  44.  
  45. function UsedUp()
  46. {
  47.     local Pawn OwnerPawn;
  48.  
  49.     OwnerPawn = Pawn(Owner);
  50.     if (OwnerPawn != none && 0 < OwnerPawn.PainTime && OwnerPawn.PainTime < 15 &&
  51.         !OwnerPawn.FootRegion.Zone.bPainZone && OwnerPawn.HeadRegion.Zone.bWaterZone)
  52.     {
  53.         OwnerPawn.PainTime = 15;
  54.     }
  55.     DisableInventoryEffects();
  56.     Super.UsedUp();
  57. }
  58.  
  59. function bool UseSpecialEffectsActor()
  60. {
  61.     return Class == class'SCUBAGear';
  62. }
  63.  
  64. function EnableInventoryEffects()
  65. {
  66.     local Triggers SoundActor;
  67.  
  68.     if (!UseSpecialEffectsActor())
  69.         EffectsActor = Owner;
  70.     else if (EffectsActor == none || EffectsActor.bDeleteMe)
  71.     {
  72.         // trying to find a sound source of other scuba gear
  73.         foreach Owner.ChildActors(class'Triggers', SoundActor)
  74.             if (SoundActor.Tag == 'SCUBAGear_EffectsActor')
  75.             {
  76.                 EffectsActor = SoundActor; // EffectsActor is shared between different scuba gears
  77.                 SetScubaAmbientSound();
  78.                 return;
  79.             }
  80.  
  81.         EffectsActor = Spawn(class'Triggers', Owner, 'SCUBAGear_EffectsActor', Owner.Location);
  82.         if (EffectsActor != none)
  83.         {
  84.             EffectsActor.SetPhysics(PHYS_Trailer);
  85.             EffectsActor.RemoteRole = ROLE_SimulatedProxy;
  86.             EffectsActor.SoundVolume = Owner.default.SoundVolume;
  87.         }
  88.         else
  89.             EffectsActor = Owner;
  90.     }
  91.  
  92.     SetScubaAmbientSound();
  93. }
  94.  
  95. function SetScubaAmbientSound()
  96. {
  97.     if (EffectsActor == none || Pawn(Owner) == none)
  98.         return;
  99.     if (EffectsActor != Owner && (Owner.AmbientSound == ActivateSound || Owner.AmbientSound == RespawnSound))
  100.         EffectsActor.AmbientSound = none;
  101.     else if (Pawn(Owner).HeadRegion.Zone.bWaterZone)
  102.         EffectsActor.AmbientSound = ActivateSound;
  103.     else
  104.         EffectsActor.AmbientSound = RespawnSound;
  105. }
  106.  
  107. function DisableInventoryEffects()
  108. {
  109.     if (Owner != none && (!UseSpecialEffectsActor() || EffectsActor == Owner))
  110.         Owner.AmbientSound = none;
  111.     if (EffectsActor != none && EffectsActor != Owner)
  112.         EffectsActor.Destroy();
  113.     EffectsActor = none;
  114. }
  115.  
  116. state Sleeping
  117. {
  118.     ignores Touch;
  119.  
  120. Begin:
  121.     Sleep(ReSpawnTime);
  122.     if (RespawnSound != sound'UnrealShare.Pickups.Scubal2')
  123.         PlaySound(RespawnSound);
  124.     Sleep(Level.Game.PlaySpawnEffect(self));
  125.     GoToState('Pickup');
  126. }
  127.  
  128. state Activated
  129. {
  130.     function EndState()
  131.     {
  132.         if (Owner != none)
  133.             Owner.PlaySound(DeactivateSound);
  134.         DisableInventoryEffects();
  135.         bActive = false;
  136.     }
  137.     function Timer()
  138.     {
  139.         local float LocalTime;
  140.         local Bubble1 b;
  141.         local Pawn OwnerPawn;
  142.  
  143.         OwnerPawn = Pawn(Owner);
  144.         if (OwnerPawn == none)
  145.         {
  146.             UsedUp();
  147.             return;
  148.         }
  149.         Charge -= 1;
  150.         if (Charge<-0)
  151.         {
  152.             UsedUp();
  153.             return;
  154.         }
  155.         if (UseSpecialEffectsActor())
  156.             EnableInventoryEffects();
  157.         LocalTime += 0.1;
  158.         LocalTime = LocalTime - int(LocalTime);
  159.         if (OwnerPawn.HeadRegion.Zone.bWaterZone && !OwnerPawn.FootRegion.Zone.bPainZone)
  160.         {
  161.             if (0 < OwnerPawn.PainTime && OwnerPawn.PainTime < OwnerPawn.UnderWaterTime)
  162.             {
  163.                 OwnerPawn.PainTime = FMin(OwnerPawn.PainTime + 0.1, OwnerPawn.UnderWaterTime);
  164.                 if (OwnerPawn.PainTime < 1)
  165.                 {
  166.                     Charge -= (1 - OwnerPawn.PainTime) * 10;
  167.                     OwnerPawn.PainTime = 1;
  168.                 }
  169.             }
  170.  
  171.             if (FRand()<LocalTime)
  172.             {
  173.                 GetAxes(OwnerPawn.ViewRotation,X,Y,Z);
  174.                 b = Spawn(class'Bubble1', Owner, '', OwnerPawn.Location
  175.                           + 20.0 * X - (FRand()*6+5) * Y - (FRand()*6+5) * Z );
  176.                 if ( b != None )
  177.                     b.DrawScale = FRand()*0.1+0.05;
  178.             }
  179.             if (FRand()<LocalTime)
  180.             {
  181.                 GetAxes(OwnerPawn.ViewRotation,X,Y,Z);
  182.                 b = Spawn(class'Bubble1', Owner, '', OwnerPawn.Location
  183.                           + 20.0 * X + (FRand()*6+5) * Y - (FRand()*6+5) * Z );
  184.                 if ( b != None )
  185.                     b.DrawScale = FRand()*0.1+0.05;
  186.             }
  187.         }
  188.     }
  189. Begin:
  190.     if (Owner == none)
  191.         GotoState('');
  192.     SetTimer(0.1, true);
  193.     EnableInventoryEffects();
  194. }
  195.  
  196. state DeActivated
  197. {
  198. Begin:
  199.  
  200. }
  201.  
  202. defaultproperties
  203. {
  204.     bActivatable=True
  205.     bDisplayableInv=True
  206.     PickupMessage="You picked up the SCUBA gear"
  207.     RespawnTime=20.000000
  208.     PickupViewMesh=LodMesh'UnrealShare.Scuba'
  209.     Charge=1200
  210.     PickupSound=Sound'UnrealShare.Pickups.GenPickSnd'
  211.     ActivateSound=Sound'UnrealShare.Pickups.Scubal1'
  212.     DeActivateSound=Sound'UnrealShare.Pickups.Scubada1'
  213.     RespawnSound=Sound'UnrealShare.Pickups.Scubal2'
  214.     Icon=Texture'UnrealShare.Icons.I_Scuba'
  215.     RemoteRole=ROLE_DumbProxy
  216.     Mesh=LodMesh'UnrealShare.Scuba'
  217.     SoundRadius=16
  218.     CollisionRadius=18.000000
  219.     CollisionHeight=15.000000
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement