mGm_Lizard

mGmTransRecall.uc

Jul 30th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class mGmTransRecall extends WeaponFire;
  2.  
  3. var() Sound TransFailedSound;
  4. var bool bGibMe;
  5. var Material TransMaterials[2];
  6.  
  7. simulated function PlayFiring()
  8. {
  9.     if ( mGmTransLauncher(Weapon).bBeaconDeployed )
  10.     {
  11.         Weapon.PlayAnim(FireAnim, FireAnimRate, TweenTime);
  12.     }
  13. }
  14.  
  15. simulated function bool AllowFire()
  16. {
  17.     local bool success;
  18.    
  19.     success = ( mGmTransLauncher(Weapon).AmmoChargeF >= 1.0 );
  20.  
  21.     if (!success && (Weapon.Role == ROLE_Authority) && (mGmTransLauncher(Weapon).TransBeacon != None) )
  22.     {
  23.         if( PlayerController(Instigator.Controller) != None )
  24.             PlayerController(Instigator.Controller).ClientPlaySound(TransFailedSound);
  25.     }
  26.     return success;
  27. }
  28.  
  29. function bool AttemptTranslocation(vector dest, DasTransBeacon TransBeacon)
  30. {
  31.     local vector OldLocation, HitLocation, HitNormal;
  32.     local actor HitActor;
  33.    
  34.     OldLocation = Instigator.Location;
  35.     if ( !TranslocSucceeded(dest,TransBeacon) )
  36.         return false;
  37.     HitActor = Weapon.Trace(HitLocation,HitNormal,Instigator.Location, dest, false);
  38.     if ( HitActor == None || !HitActor.bBlockActors || !HitActor.bBlockNonZeroExtentTraces )
  39.         return true;
  40.     Instigator.SetLocation(OldLocation);
  41.     return false;
  42. }
  43.  
  44. function bool TranslocSucceeded(vector dest, DasTransBeacon TransBeacon)
  45. {
  46.     local vector newdest;
  47.    
  48.     if ( Instigator.SetLocation(dest) || BotTranslocation() )
  49.         return true;
  50.     if ( TransBeacon.Physics != PHYS_None )
  51.     {
  52.         newdest = TransBeacon.Location - Instigator.CollisionRadius * Normal(TransBeacon.Velocity);
  53.         if ( Instigator.SetLocation(newdest) )
  54.             return true;
  55.     }
  56.     if ( (dest != Transbeacon.Location) && Instigator.SetLocation(TransBeacon.Location) )
  57.         return true;
  58.    
  59.     newdest = dest + Instigator.CollisionRadius * vect(1,1,0);
  60.     if ( Instigator.SetLocation(newdest) )
  61.         return true;
  62.     newdest = dest + Instigator.CollisionRadius * vect(1,-1,0);
  63.     if ( Instigator.SetLocation(newdest) )
  64.         return true;
  65.     newdest = dest + Instigator.CollisionRadius * vect(-1,1,0);
  66.     if ( Instigator.SetLocation(newdest) )
  67.         return true;
  68.     newdest = dest + Instigator.CollisionRadius * vect(-1,-1,0);
  69.     if ( Instigator.SetLocation(newdest) )
  70.         return true;
  71.    
  72.     return false;
  73. }
  74.  
  75. function Translocate()
  76. {
  77.     local DasTransBeacon TransBeacon;
  78.     local Actor HitActor;
  79.     local Vector HitNormal,HitLocation,dest,Vel2D;
  80.     local Vector PrevLocation,Diff, NewDest;
  81.     local xPawn XP;
  82.     local controller C;
  83.     local bool bFailedTransloc;
  84.     local int EffectNum;
  85.     local float DiffZ;
  86.    
  87.    
  88.     if ( (Instigator == None) || (mGmTransLauncher(Weapon) == None) )
  89.         return;
  90.     TransBeacon = mGmTransLauncher(Weapon).TransBeacon;
  91.    
  92.     // gib if the translocator is disrupted
  93.     if ( TransBeacon.Disrupted() )
  94.     {
  95.         UnrealMPGameInfo(Level.Game).SpecialEvent(Instigator.PlayerReplicationInfo,"translocate_gib");
  96.         bGibMe = true; // delay gib to avoid destroying player and weapons right away in the middle of all this
  97.         return;
  98.     }
  99.  
  100.     dest = TransBeacon.Location;
  101.     if ( TransBeacon.Physics == PHYS_None )
  102.         dest += vect(0,0,1) * Instigator.CollisionHeight;
  103.     else
  104.         dest += vect(0,0,0.5) * Instigator.CollisionHeight;
  105.     HitActor = Weapon.Trace(HitLocation,HitNormal,dest,TransBeacon.Location,true);
  106.     if ( HitActor != None )
  107.         dest = TransBeacon.Location;    
  108.    
  109.     TransBeacon.SetCollision(false, false, false);    
  110.    
  111.     if (Instigator.PlayerReplicationInfo.HasFlag != None)
  112.     {
  113.         Instigator.PlayerReplicationInfo.HasFlag.Drop(0.5 * Instigator.Velocity);
  114.     }
  115.    
  116.     PrevLocation = Instigator.Location;
  117.    
  118.     // verify won't telefrag teammate or recently spawned player
  119.     for ( C=Level.ControllerList; C!=None; C=C.NextController )
  120.         if ( (C.Pawn != None) && (C.Pawn != Instigator) )
  121.         {
  122.             Diff = Dest - C.Pawn.Location;
  123.             DiffZ = Diff.Z;
  124.             Diff.Z = 0;
  125.             if ( (Abs(DiffZ) < C.Pawn.CollisionHeight + 2 * Instigator.CollisionHeight)
  126.                 && (VSize(Diff) < C.Pawn.CollisionRadius + Instigator.CollisionRadius + 8) )
  127.             {
  128.                 if ( (C.SameTeamAs(Instigator.Controller) || (Level.TimeSeconds - C.Pawn.SpawnTime < DeathMatch(Level.Game).SpawnProtectionTime)) )
  129.                 {
  130.                     bFailedTransloc = true;
  131.                     break;
  132.                 }
  133.                 else
  134.                 {
  135.                     if ( DiffZ > 1.5 * C.Pawn.CollisionHeight )
  136.                     {
  137.                         NewDest = Dest;
  138.                         NewDest.Z += 0.7 * C.Pawn.CollisionHeight;
  139.                     }
  140.                     else
  141.                         NewDest = Dest + 0.5 * C.Pawn.CollisionRadius * Normal(Diff);
  142.                     if ( Weapon.FastTrace(NewDest ,dest) )
  143.                         Dest = NewDest;
  144.                 }
  145.             }
  146.         }
  147.  
  148.     if ( !bFailedTransloc && AttemptTranslocation(dest,TransBeacon) )
  149.     {
  150.         mGmTransLauncher(Weapon).ReduceAmmo();
  151.  
  152.         // spawn out
  153.         XP = xPawn(Instigator);
  154.         if( XP != None )
  155.             XP.DoTranslocateOut(PrevLocation);
  156.  
  157.         // bound XY velocity to prevent cheats
  158.         Vel2D = Instigator.Velocity;
  159.         Vel2D.Z = 0;
  160.         Vel2D = Normal(Vel2D) * FMin(Instigator.GroundSpeed,VSize(Vel2D));
  161.         Vel2D.Z = Instigator.Velocity.Z;
  162.         Instigator.Velocity = Vel2D;
  163.        
  164.         if ( Instigator.PlayerReplicationInfo.Team != None )
  165.             EffectNum = Instigator.PlayerReplicationInfo.Team.TeamIndex;
  166.            
  167.         Instigator.SetOverlayMaterial( TransMaterials[EffectNum], 1.0, false );
  168.         Instigator.PlayTeleportEffect( false, false);
  169.  
  170.         if ( !Instigator.PhysicsVolume.bWaterVolume )
  171.         {
  172.             if ( Bot(Instigator.Controller) != None )
  173.             {
  174.                 Instigator.Velocity.X = 0;
  175.                 Instigator.Velocity.Y = 0;
  176.                 Instigator.Velocity.Z = -150;
  177.                 Instigator.Acceleration = vect(0,0,0);
  178.             }
  179.             Instigator.SetPhysics(PHYS_Falling);
  180.         }
  181.         if ( UnrealTeamInfo(Instigator.PlayerReplicationInfo.Team)!= None )
  182.             UnrealTeamInfo(Instigator.PlayerReplicationInfo.Team).AI.CallForBall(Instigator);  // for bombing run
  183.        
  184.     }
  185.     else if( PlayerController(Instigator.Controller) != None )
  186.             PlayerController(Instigator.Controller).ClientPlaySound(TransFailedSound);
  187.  
  188.     TransBeacon.Destroy();
  189.     mGmTransLauncher(Weapon).TransBeacon = None;
  190.     mGmTransLauncher(Weapon).ViewPlayer();
  191. }
  192.  
  193. function ModeDoFire()
  194. {
  195.     local DasTransBeacon TransBeacon;
  196.  
  197.     Super.ModeDoFire();
  198.  
  199.     if ( Weapon.Role == ROLE_Authority && bGibMe)
  200.     {
  201.         TransBeacon = mGmTransLauncher(Weapon).TransBeacon;
  202.         mGmTransLauncher(Weapon).TransBeacon = None;
  203.         mGmTransLauncher(Weapon).ViewPlayer();
  204.         Instigator.GibbedBy(TransBeacon.Disruptor);
  205.         TransBeacon.Destroy();
  206.         bGibMe = false;
  207.     }
  208. }
  209.  
  210. function DoFireEffect()
  211. {
  212.     if (mGmTransLauncher(Weapon).TransBeacon != None)
  213.     {
  214.         Translocate();
  215.     }
  216. }
  217.  
  218. // AI Interface
  219. function bool BotTranslocation()
  220. {
  221.     local Bot B;
  222.  
  223.     B = Bot(Instigator.Controller);
  224.     if ( (B == None) || !B.bPreparingMove || (B.RealTranslocationTarget == None) )
  225.         return false;
  226.  
  227.     // if bot failed to translocate, event though beacon was in target cylinder,
  228.     // try at center of cylinder
  229.     return ( Instigator.SetLocation(B.RealTranslocationTarget.Location) );
  230. }
  231. // END AI interface
  232.  
  233. defaultproperties
  234. {
  235.     TransMaterials(0)=Material'PlayerTransRed'
  236.     TransMaterials(1)=Material'PlayerTrans'
  237.     AmmoClass=None
  238.     AmmoPerFire=0
  239.     FireAnim=Recall
  240.     FireRate=0.25
  241.     bWaitForRelease=false
  242.     bModeExclusive=false
  243.     TransFailedSound=Sound'WeaponSounds.BSeekLost1'
  244.  
  245.     BotRefireRate=0.3
  246. }
Advertisement
Add Comment
Please, Sign In to add comment