mGm_Lizard

mGmTransBeacon.uc

Jul 30th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Daschinia's Modified Translocator Beacon
  3. //=============================================================================
  4. class mGmTransBeacon extends TranslocatorBeacon;
  5.  
  6. var bool bCanHitOwner, bHitWater;
  7. var bool bDamaged;
  8. var bool bNoAI;
  9. var xEmitter Trail;
  10. var xEmitter Flare;
  11. var Actor TranslocationTarget;  // for AI
  12. var int Disruption;
  13. var int DisruptionThreshold;
  14. var Pawn Disruptor;
  15. var TransBeaconSparks Sparks;
  16. var class<TransTrail> TransTrail${1}< ${3} >
  17. var class<TransFlareBlue> TransFlare${1}< ${3} >
  18.  
  19. replication
  20. {
  21.     reliable if ( Role == ROLE_Authority )
  22.         Disruption;
  23. }
  24.  
  25. simulated function Destroyed()
  26. {
  27.     if ( Trail != None )
  28.         Trail.mRegen = false;
  29.     if ( Flare != None )
  30.     {
  31.         Flare.mRegen = false;
  32.         Flare.Destroy();
  33.     }
  34.     if ( Sparks != None )
  35.         Sparks.Destroy();
  36.     Super.Destroyed();
  37. }
  38.  
  39. event EncroachedBy( actor Other )
  40. {
  41.     if ( Mover(Other) != None )
  42.         Destroy();
  43. }
  44.  
  45. simulated function bool Disrupted()
  46. {
  47.     return ( Disruption > DisruptionThreshold );
  48. }
  49.  
  50. simulated function PostBeginPlay()
  51. {
  52.     local Rotator r;
  53.     local int diff;
  54.  
  55.     Super.PostBeginPlay();
  56.  
  57.     if ( Role == ROLE_Authority )
  58.     {
  59.         R = Rotation;
  60.         if ( AimUp() )
  61.         {
  62.             R.Pitch = R.Pitch & 65535;
  63.             if ( R.Pitch > 32768 )
  64.                 diff = 65536 - R.Pitch;
  65.             else
  66.                 diff = R.Pitch;
  67.             R.Pitch = R.Pitch + (32768 - diff)/8;
  68.         }
  69.         Velocity = Speed * Vector(R);
  70.         R.Yaw = Rotation.Yaw;
  71.         R.Pitch = 0;
  72.         R.Roll = 0;
  73.         SetRotation(R);
  74.         bCanHitOwner = false;
  75.     }
  76.     Trail = Spawn(TransTrailClass, self,, Location, Rotation);
  77.     SetTimer(0.3,false);
  78. }
  79.  
  80. function bool AimUp()
  81. {
  82.     if ( xPlayer(Instigator.Controller) == None )
  83.         return false;
  84.  
  85.     return xPlayer(Instigator.Controller).bHighBeaconTrajectory;
  86. }
  87.  
  88. simulated function PhysicsVolumeChange( PhysicsVolume Volume )
  89. {
  90. }
  91.  
  92. simulated function Landed( vector HitNormal )
  93. {
  94.     HitWall( HitNormal, None );
  95. }
  96.  
  97. function BlowUp(vector HitLocation)
  98. {
  99.     HurtRadius(Damage, DamageRadius, MyDamageType, MomentumTransfer, HitLocation );
  100.     MakeNoise(1.0);
  101. }
  102.  
  103. simulated function Explode(vector HitLocation, vector HitNormal)
  104. {
  105.     local PlayerController PC;
  106.  
  107.     PlaySound(sound'WeaponSounds.BExplosion3',,2.5*TransientSoundVolume);
  108.     if ( EffectIsRelevant(Location,false) )
  109.     {
  110.         Spawn(class'NewExplosionA',,,HitLocation + HitNormal*20,rotator(HitNormal));
  111.         PC = Level.GetLocalPlayerController();
  112.         if ( (PC.ViewTarget != None) && VSize(PC.ViewTarget.Location - Location) < 5000 )
  113.             Spawn(class'ExplosionCrap',,, HitLocation + HitNormal*20, rotator(HitNormal));
  114.     }
  115.     BlowUp(HitLocation);
  116.     Destroy();
  117. }
  118.  
  119. simulated function ProcessTouch( actor Other, vector HitLocation )
  120. {
  121.     local vector Vel2D;
  122.  
  123.     if ( Other == Instigator && Physics == PHYS_None )
  124.         //Destroy();
  125.         Explode(HitLocation, -Normal(Velocity));
  126.     else if ( (Other != Instigator) || bCanHitOwner )
  127.     {
  128.         if ( (Pawn(Other) != None))// && (Vehicle(Other) == None) )
  129.         {
  130.             Explode(HitLocation,-Normal(Velocity));
  131.             Vel2D = Velocity;
  132.             Vel2D.Z = 0;
  133.             if ( VSize(Vel2D) < 200 )
  134.                 return;
  135.         }
  136.         HitWall( -Normal(Velocity), Other );
  137.         //HitWall( Normal(HitLocation-Other.Location), Other ); // causes problems with actors using large staticmeshes
  138.     }
  139. }
  140.  
  141. simulated function HitWall( vector HitNormal, actor Wall )
  142. {
  143.     local CTFBase B;
  144.  
  145.     bCanHitOwner = true;
  146.  
  147.     Velocity = 0.3*(( Velocity dot HitNormal ) * HitNormal * (-2.0) + Velocity);   // Reflect off Wall w/damping
  148.     Speed = VSize(Velocity);
  149.  
  150.     if ( Speed < 100 )
  151.     {
  152.         ForEach TouchingActors(class'CTFBase', B)
  153.             break;
  154.  
  155.         if ( B != None )
  156.         {
  157.             Speed = VSize(Velocity);
  158.             if ( Speed < 100 )
  159.             {
  160.                 Speed = 90;
  161.                 Velocity = 90 * Normal(Velocity);
  162.             }
  163.             Disruption += 5;
  164.             if ( Disruptor == None )
  165.                 Disruptor = Instigator;
  166.         }
  167.     }
  168.  
  169.  
  170.     if ( Speed < 20 && Wall.bWorldGeometry && (HitNormal.Z >= 0.7) )
  171.     {
  172.         if ( Level.NetMode != NM_DedicatedServer )
  173.             PlaySound(ImpactSound, SLOT_Misc );
  174.         bBounce = false;
  175.         Explode(Location, HitNormal);
  176.         return;
  177.         SetPhysics(PHYS_None);
  178.  
  179.         if (Trail != None)
  180.             Trail.mRegen = false;
  181.  
  182.         if ( (Level.NetMode != NM_DedicatedServer) && (Flare == None) )
  183.         {
  184.             Flare = Spawn(TransFlareClass, self,, Location - vect(0,0,5), rot(16384,0,0));
  185.             Flare.SetBase(self);
  186.         }
  187.     }
  188. }
  189.  
  190. // poll for disruption
  191. simulated function Timer()
  192. {
  193.     if ( Level.NetMode == NM_DedicatedServer )
  194.         return;
  195.  
  196.     if ( !Disrupted() )
  197.     {
  198.         SetTimer(0.3, false);
  199.         return;
  200.     }
  201.  
  202.     // create the disrupted effect
  203.     if (Sparks == None)
  204.     {
  205.         Sparks = Spawn(class'TransBeaconSparks',,,Location+vect(0,0,5),Rotator(vect(0,0,1)));
  206.         Sparks.SetBase(self);
  207.     }
  208.  
  209.     if (Flare != None)
  210.         Flare.Destroy();
  211. }
  212.  
  213. function TakeDamage(int Damage, Pawn EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType)
  214. {
  215.     if ( Level.Game.bTeamGame && (EventInstigator != None)
  216.         && (EventInstigator.PlayerReplicationInfo != None)
  217.         && ((Instigator == None) || (EventInstigator.PlayerReplicationInfo.Team == Instigator.PlayerReplicationInfo.Team)) )
  218.     {
  219.         return;
  220.     }
  221.     else
  222.     {
  223.         Disruption += Damage;
  224.         Disruptor = EventInstigator;
  225.     }
  226. }
  227.  
  228. function BotTranslocate();
  229.  
  230. // AI Interface
  231. function SetTranslocationTarget(actor T)
  232. {
  233.     TranslocationTarget = T;
  234.     GotoState('MonitoringThrow');
  235. }
  236.  
  237. function bool IsMonitoring(actor A)
  238. {
  239.     return false;
  240. }
  241.  
  242. function EndMonitoring();
  243.  
  244. State MonitoringThrow
  245. {
  246.     function bool IsMonitoring(actor A)
  247.     {
  248.         return ( A == TranslocationTarget );
  249.     }
  250.  
  251.     function Destroyed()
  252.     {
  253.         local Bot B;
  254.  
  255.         B = Bot(Instigator.Controller);
  256.         if ( B != None )
  257.         {
  258.             B.TranslocationTarget = None;
  259.             B.RealTranslocationTarget = None;
  260.             B.bPreparingMove = false;
  261.             B.SwitchToBestWeapon();
  262.         }
  263.         Global.Destroyed();
  264.     }
  265.  
  266.     function EndMonitoring()
  267.     {
  268.         GotoState('');
  269.     }
  270.  
  271.     function EndState()
  272.     {
  273.         local Bot B;
  274.  
  275.         B = Bot(Instigator.Controller);
  276.         if ( (B != None) && !bNoAI )
  277.         {
  278.             B.TranslocationTarget = None;
  279.             B.RealTranslocationTarget = None;
  280.             B.bPreparingMove = false;
  281.             B.SwitchToBestWeapon();
  282.         }
  283.     }
  284.  
  285.     simulated function HitWall( vector HitNormal, actor Wall )
  286.     {
  287.         Global.HitWall(HitNormal,Wall);
  288.         if ( (GameObject(TranslocationTarget) != None) && (HitNormal.Z > 0.7)
  289.                 && (VSize(Location - TranslocationTarget.Location) < FMin(400, VSize(Instigator.Location - TranslocationTarget.Location))) )
  290.         {
  291.             Instigator.Controller.MoveTarget = TranslocationTarget;
  292.             BotTranslocate();
  293.             return;
  294.         }
  295.  
  296.         if ( Physics == PHYS_None )
  297.         {
  298.             if ( (Bot(Instigator.Controller) != None) && Bot(Instigator.Controller).bPreparingMove )
  299.             {
  300.                 Bot(Instigator.Controller).MoveTimer = -1;
  301.                 if ( (JumpSpot(TranslocationTarget) != None) && (Instigator.Controller.MoveTarget == TranslocationTarget) )
  302.                     JumpSpot(TranslocationTarget).FearCost += 900;
  303.             }
  304.             EndMonitoring();
  305.         }
  306.     }
  307.  
  308.     function BotTranslocate()
  309.     {
  310.         if ( TransLauncher(Instigator.Weapon) != None )
  311.             Instigator.Weapon.GetFireMode(1).DoFireEffect();
  312.         EndMonitoring();
  313.     }
  314.  
  315.     function Touch(Actor Other)
  316.     {
  317.         local Pawn P;
  318.  
  319.         P = Pawn(Other);
  320.         if ( (P == None) || (P == Instigator) )
  321.             return;
  322.         ProcessTouch( Other, Location );
  323.         if ( (Bot(P.Controller) == None) || Level.Game.IsOnTeam(P.Controller,Instigator.PlayerReplicationInfo.Team.TeamIndex) )
  324.         {
  325.             EndMonitoring();
  326.             return;
  327.         }
  328.         if ( Bot(P.Controller).ProficientWithWeapon() && (2 + FRand() * 8 < Bot(P.Controller).Skill) )
  329.             BotTranslocate();
  330.     }
  331.  
  332.     // FIXME - consider making this a timer or projectile latent function instead of using tick?
  333.     function Tick(float DeltaTime)
  334.     {
  335.         local vector Dist, Dir, HitLocation, HitNormal;
  336.         local float ZDiff, Dist2D;
  337.         local actor HitActor;
  338.  
  339.         if ( (TranslocationTarget == None) || (Instigator.Controller == None)
  340.             || !Bot(Instigator.Controller).Squad.AllowTranslocationBy(Bot(Instigator.Controller))
  341.             || ((GameObject(Instigator.Controller.MoveTarget) != None) && (Instigator.Controller.MoveTarget != TranslocationTarget))
  342.             || ((TranslocationTarget != Instigator.Controller.MoveTarget)
  343.                 && (TranslocationTarget != Instigator.Controller.RouteGoal)
  344.                 && (TranslocationTarget != Instigator.Controller.RouteCache[0])
  345.                 && (TranslocationTarget != Instigator.Controller.RouteCache[1])
  346.                 && (TranslocationTarget != Instigator.Controller.RouteCache[2])
  347.                 && (TranslocationTarget != Instigator.Controller.RouteCache[3])) )
  348.         {
  349.             EndMonitoring();
  350.             return;
  351.         }
  352.  
  353.         Dist = Location - TranslocationTarget.Location;
  354.         ZDiff = Dist.Z;
  355.         Dist.Z = 0;
  356.         Dir = TranslocationTarget.Location - Instigator.Location;
  357.         Dir.Z = 0;
  358.         Dist2D = VSize(Dist);
  359.         if ( Dist2D < TranslocationTarget.CollisionRadius )
  360.         {
  361.             if ( ZDiff > -0.9 * TranslocationTarget.CollisionHeight )
  362.             {
  363.                 Instigator.Controller.MoveTarget = TranslocationTarget;
  364.                 BotTranslocate();
  365.             }
  366.             return;
  367.         }
  368.         Dir = TranslocationTarget.Location - Instigator.Location;
  369.         Dir.Z = 0;
  370.         if ( (Dist Dot Dir) > 0 )
  371.         {
  372.             if ( (Bot(Instigator.Controller) != None) && Bot(Instigator.Controller).bPreparingMove )
  373.                 {
  374.                     Bot(Instigator.Controller).MoveTimer = -1;
  375.                     if ( (JumpSpot(TranslocationTarget) != None) && (Instigator.Controller.MoveTarget == TranslocationTarget) )
  376.                     JumpSpot(TranslocationTarget).FearCost += 400;
  377.             }
  378.             else if ( (GameObject(TranslocationTarget) != None) && (ZDiff > 0) && (Dist2D < FMin(400, VSize(Instigator.Location - TranslocationTarget.Location) - 250)) )
  379.             {
  380.                 // if safe underneath, then translocate
  381.                 HitActor = Trace(HitLocation, HitNormal, Location - vect(0,0,100), Location, false);
  382.                 if ( (HitActor != None) && (HitNormal.Z > 0.7) )
  383.                 {
  384.                     Instigator.Controller.MoveTarget = TranslocationTarget;
  385.                     BotTranslocate();
  386.                     return;
  387.                 }
  388.             }
  389.             EndMonitoring();
  390.             return;
  391.         }
  392.     }
  393. }
  394. // END AI interface
  395.  
  396. defaultproperties
  397. {
  398.     ExplosionDecal=class'RocketMark'
  399.     MyDamageType=class'DamTypeTeleFrag'
  400.     Speed=4000
  401.     MaxSpeed=6000
  402.     Damage=300
  403.     DamageRadius=200
  404.     MomentumTransfer=50000
  405.     ImpactSound=Sound'WeaponSounds.P1GrenFloor1'
  406.     Physics=PHYS_Falling
  407.     DrawType=DT_StaticMesh
  408.     StaticMesh=StaticMesh'WeaponStaticMesh.NewTranslocatorPuck'
  409.     DrawScale=0.35
  410.     AmbientGlow=64
  411.     bUnlit=false
  412.     bBounce=true
  413.     bNetTemporary=false
  414.     bUpdateSimulatedPosition=true
  415.     NetUpdateFrequency=8
  416.     AmbientSound=Sound'WeaponSounds.Redeemer_Flight'
  417.  
  418.     CollisionRadius=10.000000
  419.     CollisionHeight=10.00000
  420.     PrePivot=(X=0.0,Y=0.0,Z=25.0)
  421.     SoundRadius=7
  422.     SoundVolume=250
  423.     SoundPitch=128
  424.     bProjTarget=true
  425.     Disruption=0
  426.     DisruptionThreshold=65
  427.     bNetNotify=true
  428.     bOnlyDirtyReplication=true
  429.     bOwnerNoSee=true
  430.  
  431.     TransTrailClass=class'TransTrail'
  432.     TransFlareClass=class'TransFlareRed'
  433. }
Advertisement
Add Comment
Please, Sign In to add comment