mGm_Lizard

mGmTransLauncher.uc

Jul 30th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Daschinia's Modified Translocator Launcher
  3. //=============================================================================
  4. class mGmTransLauncher extends TransLauncher
  5.     config(mGmTrans)
  6.     HideDropDown;
  7.  
  8. #EXEC OBJ LOAD FILE=InterfaceContent.utx
  9.  
  10. var mGmTransBeacon TransBeacon;
  11. var() float     MaxCamDist;
  12. var() float AmmoChargeF;
  13. var int RepAmmo;
  14. var() float AmmoChargeMax;
  15. var() float AmmoChargeRate;
  16. var globalconfig bool bPrevWeaponSwitch;
  17. var xBombFlag Bomb;
  18. var bool bDrained;
  19. var bool bBeaconDeployed; // meaningful for client
  20. var bool bTeamSet;
  21. var byte ViewBeaconVolume;
  22. var float PreDrainAmmo;
  23. var rotator TranslocRot;
  24. var float TranslocScale, OldTime;
  25.  
  26. replication
  27. {
  28.     reliable if ( bNetOwner && (ROLE==ROLE_Authority) )
  29.         TransBeacon,RepAmmo;
  30. }
  31.  
  32. function FireHack(byte Mode)
  33. {
  34.     local Actor TTarget;
  35.     local vector TTargetLoc;
  36.  
  37.     if ( Mode == 0 )
  38.     {
  39.         if ( TransBeacon != None )
  40.         {
  41.             // this shouldn't happen
  42.             TransBeacon.bNoAI = true;
  43.             TransBeacon.Destroy();
  44.             TransBeacon = None;
  45.         }
  46.         TTarget = Bot(Instigator.Controller).TranslocationTarget;
  47.         if ( TTarget == None )
  48.             return;
  49.         // hack in translocator firing here
  50.         FireMode[0].PlayFiring();
  51.         FireMode[0].FlashMuzzleFlash();
  52.         FireMode[0].StartMuzzleSmoke();
  53.         IncrementFlashCount(0);
  54.         ProjectileFire(FireMode[0]).SpawnProjectile(Instigator.Location,Rot(0,0,0));
  55.         // find correct initial velocity
  56.         TTargetLoc = TTarget.Location;
  57.         if ( JumpSpot(TTarget) != None )
  58.         {
  59.             TTargetLoc.Z += JumpSpot(TTarget).TranslocZOffset;
  60.             if ( (Instigator.Anchor != None) && Instigator.ReachedDestination(Instigator.Anchor) )
  61.             {
  62.                 // start from same point as in test
  63.                 Transbeacon.SetLocation(TransBeacon.Location + Instigator.Anchor.Location + (Instigator.CollisionHeight - Instigator.Anchor.CollisionHeight) * vect(0,0,1)- Instigator.Location);
  64.             }
  65.         }
  66.         else if ( TTarget.Velocity != vect(0,0,0) )
  67.         {
  68.             TTargetLoc += 0.3 * TTarget.Velocity;
  69.             TTargetLoc.Z = 0.5 * (TTargetLoc.Z + TTarget.Location.Z);
  70.         }
  71.         else if ( (Instigator.Physics == PHYS_Falling)
  72.                     && (Instigator.Location.Z < TTarget.Location.Z)
  73.                     && (Instigator.PhysicsVolume.Gravity.Z > -800) )
  74.             TTargetLoc.Z += 128;
  75.  
  76.         TransBeacon.Velocity = Bot(Instigator.Controller).AdjustToss(TransBeacon.Speed, TransBeacon.Location, TTargetLoc,false);
  77.         TransBeacon.SetTranslocationTarget(Bot(Instigator.Controller).RealTranslocationTarget);
  78.     }
  79. }
  80.  
  81. function class<DamageType> GetDamageType()
  82. {
  83.     return class'DamTypeTelefrag';
  84. }
  85.  
  86. function bool ConsumeAmmo(int mode, float load, optional bool bAmountNeededIsMax)
  87. {
  88.     return true;
  89. }
  90.  
  91. function ReduceAmmo()
  92. {
  93.     enable('Tick');
  94.     bDrained = false;
  95.     AmmoChargeF -= 1;
  96.     RepAmmo -= 1;
  97.     if ( Bot(Instigator.Controller) != None )
  98.         Bot(Instigator.Controller).TranslocFreq = 3 + FMax(Bot(Instigator.Controller).TranslocFreq,Level.TimeSeconds);
  99. }
  100.  
  101. simulated function GetAmmoCount(out float MaxAmmoPrimary, out float CurAmmoPrimary)
  102. {
  103.     MaxAmmoPrimary = AmmoChargeMax;
  104.     CurAmmoPrimary = FMax(0,AmmoChargeF);
  105. }
  106.  
  107. function GiveAmmo(int m, WeaponPickup WP, bool bJustSpawned)
  108. {
  109.     Super.GiveAmmo(m, WP,bJustSpawned);
  110.     AmmoChargeF = Default.AmmoChargeF;
  111.     RepAmmo = int(AmmoChargeF);
  112. }
  113.  
  114. function DrainCharges()
  115. {
  116.     enable('Tick');
  117.     PreDrainAmmo = AmmoChargeF;
  118.     AmmoChargeF = -1;
  119.     RepAmmo = -1;
  120.     bDrained = true;
  121.     if ( Bot(Instigator.Controller) != None )
  122.         Bot(Instigator.Controller).NextTranslocTime = Level.TimeSeconds + 3.5;
  123. }
  124.  
  125. simulated function bool StartFire(int Mode)
  126. {
  127.     if ( !bPrevWeaponSwitch || (Mode == 1) || (Instigator.Controller.bAltFire == 0) || (PlayerController(Instigator.Controller) == None) )
  128.         return Super.StartFire(Mode);
  129.     if ( (OldWeapon != None) && OldWeapon.HasAmmo() )
  130.         Instigator.PendingWeapon = OldWeapon;
  131.     ClientStopFire(0);
  132.     Instigator.Controller.StopFiring();
  133.     PutDown();
  134.     return false;
  135. }
  136.  
  137. simulated function Tick(float dt)
  138. {
  139.     if (Role == ROLE_Authority)
  140.     {
  141.         if ( AmmoChargeF >= AmmoChargeMax )
  142.         {
  143.             if ( RepAmmo != int(AmmoChargeF) ) // condition to avoid unnecessary bNetDirty of ammo
  144.                 RepAmmo = int(AmmoChargeF);
  145.             disable('Tick');
  146.             return;
  147.         }
  148.         AmmoChargeF += dt*AmmoChargeRate;
  149.         AmmoChargeF = FMin(AmmoChargeF, AmmoChargeMax);
  150.         if ( AmmoChargeF >= 1.5 )
  151.             bDrained = false;
  152.         else if ( bDrained )
  153.         {
  154.             if ( (Bomb == None) && ( Level.Game.IsA('xBombingRun') ) )
  155.                 Bomb = xBombFlag(UnrealMPGameInfo(Level.Game).GetGameObject('xBombFlag'));
  156.             if ( (Bomb != None) && (Bomb.Holder != None) )
  157.             {
  158.                 bDrained = false;
  159.                 AmmoChargeF = 1.5;
  160.                 if ( Bot(Instigator.Controller) != None )
  161.                     Bot(Instigator.Controller).NextTranslocTime = Level.TimeSeconds - 1;
  162.             }
  163.         }
  164.         if ( RepAmmo != int(AmmoChargeF) ) // condition to avoid unnecessary bNetDirty of ammo
  165.             RepAmmo = int(AmmoChargeF);
  166.     }
  167.     else
  168.     {
  169.         // client simulation of the charge bar
  170.         AmmoChargeF = FMin(RepAmmo + AmmoChargeF - int(AmmoChargeF)+dt*AmmoChargeRate, AmmoChargeMax);
  171.     }
  172. }
  173.  
  174. simulated function DoAutoSwitch()
  175. {
  176. }
  177.  
  178. simulated function ViewPlayer()
  179. {
  180.     if ( (PlayerController(Instigator.Controller) != None) && (PlayerController(Instigator.Controller).ViewTarget == TransBeacon) )
  181.     {
  182.         PlayerController(Instigator.Controller).ClientSetViewTarget( Instigator );
  183.         PlayerController(Instigator.Controller).SetViewTarget( Instigator );
  184.         if ( TransBeacon != None )
  185.         {
  186.             Transbeacon.SetRotation(PlayerController(Instigator.Controller).Rotation);
  187.             Transbeacon.SoundVolume = Transbeacon.default.SoundVolume;
  188.         }
  189.     }
  190. }
  191.  
  192. simulated function ViewCamera()
  193. {
  194.     if ( TransBeacon!=None )
  195.     {
  196.         if ( Instigator.Controller.IsA('PlayerController') )
  197.         {
  198.             PlayerController(Instigator.Controller).SetViewTarget(TransBeacon);
  199.             PlayerController(Instigator.Controller).ClientSetViewTarget(TransBeacon);
  200.             PlayerController(Instigator.Controller).SetRotation( TransBeacon.Rotation );
  201.             Transbeacon.SoundVolume = ViewBeaconVolume;
  202.         }
  203.     }
  204. }
  205.  
  206. simulated function Reselect()
  207. {
  208.     if ( (TransBeacon == None) || (Instigator.Controller.IsA('PlayerController') && (PlayerController(Instigator.Controller).ViewTarget == TransBeacon)) )
  209.         ViewPlayer();
  210.     else
  211.         ViewCamera();
  212. }
  213.  
  214. simulated event RenderOverlays( Canvas Canvas )
  215. {
  216.     local float tileScaleX, tileScaleY, dist, clr;
  217.     local float NewTranslocScale;
  218.  
  219.     if ( (PlayerController(Instigator.Controller) != None) && (PlayerController(Instigator.Controller).ViewTarget == TransBeacon) )
  220.     {
  221.         tileScaleX = Canvas.SizeX / 640.0f;
  222.         tileScaleY = Canvas.SizeY / 480.0f;
  223.  
  224.         Canvas.DrawColor.R = 255;
  225.         Canvas.DrawColor.G = 255;
  226.         Canvas.DrawColor.B = 255;
  227.         Canvas.DrawColor.A = 255;
  228.  
  229.         Canvas.Style = 255;
  230.         Canvas.SetPos(0,0);
  231.         Canvas.DrawTile( Material'TransCamFB', Canvas.SizeX, Canvas.SizeY, 0.0, 0.0, 512, 512 ); // !! hardcoded size
  232.         Canvas.SetPos(0,0);
  233.  
  234.         if ( !Level.IsSoftwareRendering() )
  235.         {
  236.             dist = VSize(TransBeacon.Location - Instigator.Location);
  237.             if ( dist > MaxCamDist )
  238.             {
  239.                 clr = 255.0;
  240.             }
  241.             else
  242.             {
  243.                 clr = (dist / MaxCamDist);
  244.                 clr *= 255.0;
  245.             }
  246.             clr = Clamp( clr, 20.0, 255.0 );
  247.             Canvas.DrawColor.R = clr;
  248.             Canvas.DrawColor.G = clr;
  249.             Canvas.DrawColor.B = clr;
  250.             Canvas.DrawColor.A = 255;
  251.             Canvas.DrawTile( Material'ScreenNoiseFB', Canvas.SizeX, Canvas.SizeY, 0.0, 0.0, 512, 512 ); // !! hardcoded size
  252.         }
  253.     }
  254.     else
  255.     {
  256.         if ( TransBeacon == None )
  257.             NewTranslocScale = 1;
  258.         else
  259.             NewTranslocScale = 0;
  260.  
  261.         if ( NewTranslocScale != TranslocScale )
  262.         {
  263.             TranslocScale = NewTranslocScale;
  264.             SetBoneScale(0,TranslocScale,'Beacon');
  265.         }
  266.         if ( TranslocScale != 0 )
  267.         {
  268.             TranslocRot.Yaw += 120000 * (Level.TimeSeconds - OldTime);
  269.             OldTime = Level.TimeSeconds;
  270.             SetBoneRotation('Beacon',TranslocRot,0);
  271.         }
  272.         if ( !bTeamSet && (Instigator.PlayerReplicationInfo != None) && (Instigator.PlayerReplicationInfo.Team != None) )
  273.         {
  274.             bTeamSet = true;
  275.             if ( Instigator.PlayerReplicationInfo.Team.TeamIndex == 1 )
  276.                 Skins[1] = Material'WeaponSkins.NEWTranslocatorBlue';
  277.         }
  278.         Super.RenderOverlays(Canvas);
  279.     }
  280. }
  281.  
  282. simulated function bool PutDown()
  283. {
  284.     ViewPlayer();
  285.     return Super.PutDown();
  286. }
  287.  
  288. simulated function Destroyed()
  289. {
  290.     if (TransBeacon != None)
  291.         TransBeacon.Destroy();
  292.     Super.Destroyed();
  293. }
  294.  
  295. simulated function float ChargeBar()
  296. {
  297.     return AmmoChargeF - int(AmmoChargeF);
  298. }
  299.  
  300. defaultproperties
  301. {
  302.     ItemName="DasTranslocator"
  303.     Description="Explodes for fun and giggles."
  304.     IconMaterial=Material'HudContent.Generic.HUD'
  305.     IconCoords=(X1=0,Y1=0,X2=2,Y2=2)
  306.  
  307.     TranslocScale=+1.0
  308.     bPrevWeaponSwitch=true
  309.     bShowChargingBar=true
  310.     bCanThrow=false
  311.     AmmoChargeF=6.0f
  312.     RepAmmo=6
  313.     AmmoChargeMax=6.0f
  314.     AmmoChargeRate=0.5f
  315.     FireModeClass(0)=mGmTransFire
  316.     FireModeClass(1)=mGmTransRecall
  317.     InventoryGroup=10
  318.     Mesh=mesh'NewWeapons2004.NewTransLauncher_1st'
  319.     BobDamping=1.8
  320.     PickupClass=class'mGmTransPickup'
  321.     EffectOffset=(X=100.0,Y=30.0,Z=-19.0)
  322.     AttachmentClass=class'TransAttachment'
  323.     DisplayFOV=60.0
  324.     ViewBeaconVolume=40
  325.  
  326.     IdleAnimRate=0.25
  327.     PutDownAnim=PutDown
  328.     SelectAnim=Select
  329.  
  330.     DrawScale=0.8
  331.     PlayerViewOffset=(X=28.5,Y=12,Z=-12)
  332.     SmallViewOffset=(X=38,Y=16,Z=-16)
  333.     PlayerViewPivot=(Pitch=1000,Roll=0,Yaw=400)
  334.     MaxCamDist=4000.0
  335.     SelectSound=Sound'WeaponSounds.Translocator_change'
  336.     SelectForce="Translocator_change"
  337.     CenteredOffsetY=0
  338.  
  339.     HudColor=(r=0,g=0,b=255,a=255)
  340.     AIRating=-1.0
  341.     CurrentRating=-1.0
  342.  
  343.     Priority=1
  344.     CustomCrosshair=2
  345.     CustomCrosshairTextureName="Crosshairs.Hud.Crosshair_Cross3"
  346.     CustomCrosshairColor=(r=0,g=0,b=255,a=255)
  347.     CustomCrosshairScale=1.0
  348.  
  349.     CenteredRoll=0
  350. //Create mGm trans skin
  351.     Skins(0)=FinalBlend'EpicParticles.NewTransLaunBoltFB'
  352.     Skins(1)=Material'WeaponSkins.NEWTranslocatorTEX'
  353.     Skins(2)=Material'WeaponSkins.NEWTranslocatorPUCK'
  354.     Skins(3)=FinalBlend'WeaponSkins.NEWTransGlassFB'
  355.  
  356. }
Advertisement
Add Comment
Please, Sign In to add comment