Advertisement
Guest User

Untitled

a guest
Jul 5th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // KFWeap_Blunt_BALROG9
  3. //=============================================================================
  4.  
  5. class KFWeap_Blunt_Balrog9 extends KFWeap_MeleeBase;
  6.  
  7. var bool bWasTimeDilated;
  8.  
  9. /** Explosion actor class to spawn */
  10. var class<KFExplosionActor> ExplosionActor${1}< ${3} >
  11. var() KFGameExplosion ExplosionTemplate;
  12. /** If true, use an alternate set of explosion effects */
  13. var bool    bAltExploEffects;
  14. var KFImpactEffectInfo AltExploEffects;
  15.  
  16. var transient Actor BlastAttachee;
  17.  
  18. /** Spawn location offset to improve cone hit detection */
  19. var transient float BlastSpawnOffset;
  20.  
  21. /** If set, heavy attack button has been released during the attack */
  22. var transient bool bPulverizerFireReleased;
  23.  
  24. var bool bFriendlyFireEnabled;
  25.  
  26. var class<KFExplosionActor> NukeExplosionActor${1}< ${3} >
  27.  
  28. replication
  29. {
  30.     if (bNetInitial)
  31.         bFriendlyFireEnabled;
  32. }
  33.  
  34. simulated event PreBeginPlay()
  35. {
  36.     Super.PreBeginPlay();
  37.  
  38.     /** Initially check whether friendly fire is on or not. */
  39.     if(Role == ROLE_Authority && KFGameInfo(WorldInfo.Game).FriendlyFireScale != 0.f)
  40.     {
  41.         bFriendlyFireEnabled = true;
  42.     }
  43. }
  44.  
  45. /** Pulverizer should be able to interrupt its reload state with any melee attack */
  46. simulated function bool CanOverrideMagReload(byte FireModeNum)
  47. {
  48.     return FireModeNum != RELOAD_FIREMODE;
  49. }
  50.  
  51. /** Explosion Actor version */
  52. simulated function CustomFire()
  53. {
  54.     local KFExplosionActor ExploActor;
  55.     local vector SpawnLoc;
  56.     local rotator SpawnRot;
  57.  
  58.     if ( Instigator.Role < ROLE_Authority )
  59.     {
  60.         return;
  61.     }
  62.  
  63.     // On local player or server, we cache off our time dilation setting here
  64.     if (WorldInfo.NetMode == NM_ListenServer || WorldInfo.NetMode == NM_DedicatedServer || Instigator.Controller != None)
  65.     {
  66.         bWasTimeDilated = WorldInfo.TimeDilation < 1.f;
  67.     }
  68.  
  69.     PrepareExplosionTemplate();
  70.     SetExplosionActorClass();
  71.  
  72.     SpawnLoc = Instigator.GetWeaponStartTraceLocation();
  73.     SpawnRot = GetPulverizerAim(SpawnLoc);
  74.  
  75.     // nudge backwards to give a wider code near the player
  76.     SpawnLoc += vector(SpawnRot) * BlastSpawnOffset;
  77.  
  78.     // explode using the given template
  79.     ExploActor = Spawn(ExplosionActorClass, self,, SpawnLoc, SpawnRot,, true);
  80.     if (ExploActor != None)
  81.     {
  82.         ExploActor.InstigatorController = Instigator.Controller;
  83.         ExploActor.Instigator = Instigator;
  84.  
  85.         // Force the actor we collided with to get hit again (when DirectionalExplosionAngleDeg is small)
  86.         // This is only necessary on server since GetEffectCheckRadius() will be zero on client
  87.         ExploActor.Attachee = BlastAttachee;
  88.         ExplosionTemplate.bFullDamageToAttachee = true;
  89.  
  90.         // enable muzzle location sync
  91.         ExploActor.bReplicateInstigator = true;
  92.         ExploActor.SetSyncToMuzzleLocation(true);
  93.  
  94.         ExploActor.Explode(ExplosionTemplate, vector(SpawnRot));
  95.     }
  96.  
  97.     // tell remote clients that we fired, to trigger effects in third person
  98.     IncrementFlashCount();
  99.  
  100.     if ( bDebug )
  101.     {
  102.         DrawDebugCone(SpawnLoc, vector(SpawnRot), ExplosionTemplate.DamageRadius, ExplosionTemplate.DirectionalExplosionAngleDeg * DegToRad,
  103.             ExplosionTemplate.DirectionalExplosionAngleDeg * DegToRad, 16, MakeColor(64,64,255,0), TRUE);
  104.     }
  105. }
  106.  
  107. // for nukes && concussive force
  108. simulated protected function PrepareExplosionTemplate()
  109. {
  110.     local KFPlayerReplicationInfo InstigatorPRI;
  111.     local KFPlayerController KFPC;
  112.     local KFPerk InstigatorPerk;
  113.  
  114.     if (bWasTimeDilated)
  115.     {
  116.         InstigatorPRI = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo);
  117.         if (InstigatorPRI != none)
  118.         {
  119.             if (InstigatorPRI.bNukeActive)
  120.             {
  121.                 ExplosionTemplate = class'KFPerk_Demolitionist'.static.GetNukeExplosionTemplate();
  122.                 ExplosionTemplate.Damage = ExplosionTemplate.Damage * class'KFPerk_Demolitionist'.static.GetNukeDamageModifier();
  123.                 ExplosionTemplate.DamageRadius = ExplosionTemplate.DamageRadius * class'KFPerk_Demolitionist'.static.GetNukeRadiusModifier();
  124.                 ExplosionTemplate.DamageFalloffExponent = ExplosionTemplate.DamageFalloffExponent;
  125.             }
  126.             else if (InstigatorPRI.bConcussiveActive && AltExploEffects != none)
  127.             {
  128.                 ExplosionTemplate.ExplosionEffects = AltExploEffects;
  129.                 ExplosionTemplate.ExplosionSound = class'KFPerk_Demolitionist'.static.GetConcussiveExplosionSound();
  130.             }
  131.         }
  132.     }
  133.     else
  134.     {
  135.         ExplosionTemplate = default.ExplosionTemplate;
  136.         ExplosionTemplate.ExplosionEffects = default.ExplosionTemplate.ExplosionEffects;
  137.         ExplosionTemplate.ExplosionSound = default.ExplosionTemplate.ExplosionSound;
  138.         ExplosionTemplate.Damage = ExplosionTemplate.default.Damage;
  139.         ExplosionTemplate.DamageRadius = ExplosionTemplate.default.DamageRadius;
  140.         ExplosionTemplate.DamageFalloffExponent = ExplosionTemplate.default.DamageFalloffExponent;
  141.     }
  142.  
  143.     // Change the radius and damage based on the perk
  144.     if (Owner.Role == ROLE_Authority)
  145.     {
  146.         KFPC = KFPlayerController(Instigator.Controller);
  147.         if (KFPC != none)
  148.         {
  149.             InstigatorPerk = KFPC.GetPerk();
  150.             ExplosionTemplate.DamageRadius *= InstigatorPerk.GetAoERadiusModifier();
  151.         }
  152.     }
  153. }
  154.  
  155. simulated protected function SetExplosionActorClass()
  156. {
  157.     local KFPlayerReplicationInfo InstigatorPRI;
  158.  
  159.     if (bWasTimeDilated && Instigator != none)
  160.     {
  161.         InstigatorPRI = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo);
  162.         if (InstigatorPRI != none)
  163.         {
  164.             if (InstigatorPRI.bNukeActive)
  165.             {
  166.                 ExplosionActorClass = NukeExplosionActor${1}< ${3} >
  167.                 return;
  168.             }
  169.         }
  170.     }
  171.     ExplosionActorClass = default.ExplosionActor${1}< ${3} >
  172. }
  173.  
  174. /** Called by CustomFire when shotgun blast is fired */
  175. simulated function Rotator GetPulverizerAim( vector StartFireLoc )
  176. {
  177.     local Rotator R;
  178.  
  179.     R = GetAdjustedAim(StartFireLoc);
  180.  
  181.     // Adjust cone fire angle based on swing direction
  182.     switch (MeleeAttackHelper.CurrentAttackDir)
  183.     {
  184.         case DIR_Left:
  185.             R.Yaw += 5461;
  186.             break;
  187.         case DIR_Right:
  188.             R.Yaw -= 5461;
  189.             break;
  190.         case DIR_Forward:
  191.             R.Pitch -= 2048;
  192.             break;
  193.         case DIR_Backward:
  194.             R.Pitch += 2048;
  195.             break;
  196.     }
  197.  
  198.     return R;
  199. }
  200.  
  201. /** Called on the server alongside PulverizerFired */
  202. reliable server private function ServerBeginPulverizerFire(Actor HitActor, optional vector HitLocation)
  203. {
  204.     // Ignore if too far away (something went wrong!)
  205.     if ( VSizeSq2D(HitLocation - Instigator.Location) > Square(500) )
  206.     {
  207.         `log("ServerBeginPulverizerFire outside of range!");
  208.         return;
  209.     }
  210.  
  211.     BlastAttachee = HitActor;
  212.     SendToFiringState(CUSTOM_FIREMODE);
  213. }
  214.  
  215. /** Called when altfire melee attack hits a target and there is ammo left */
  216. simulated function BeginPulverizerFire()
  217. {
  218.     SendToFiringState(CUSTOM_FIREMODE);
  219. }
  220.  
  221. /** Skip calling StillFiring/PendingFire to fix log warning */
  222. simulated function bool ShouldRefire()
  223. {
  224.     if ( CurrentFireMode == CUSTOM_FIREMODE )
  225.         return false;
  226.  
  227.     return Super.ShouldRefire();
  228. }
  229.  
  230. /** Override to allow for two different states associated with RELOAD_FIREMODE */
  231. simulated function SendToFiringState(byte FireModeNum)
  232. {
  233.     // Ammo needs to be synchronized on client/server for this to work!
  234.     if ( FireModeNum == RELOAD_FIREMODE && !Super(KFWeapon).CanReload() )
  235.     {
  236.         SetCurrentFireMode(FireModeNum);
  237.         GotoState('WeaponUpkeep');
  238.         return;
  239.     }
  240.  
  241.     Super.SendToFiringState(FireModeNum);
  242. }
  243.  
  244. /** Always allow reload and choose the correct state in SendToFiringState() */
  245. simulated function bool CanReload(optional byte FireModeNum)
  246. {
  247.     return true;
  248. }
  249.  
  250. /** Debugging */
  251. `if(`notdefined(ShippingPC))
  252. exec function ToggleWeaponDebug()
  253. {
  254.     bDebug = !bDebug;
  255. }
  256. `endif
  257.  
  258. /*********************************************************************************************
  259.  * State MeleeHeavyAttacking
  260.  * This is the alt-fire Melee State.
  261.  *********************************************************************************************/
  262.  
  263. simulated state MeleeHeavyAttacking
  264. {
  265.     /** Reset bPulverizerFireReleased */
  266.     simulated event BeginState(Name PreviousStateName)
  267.     {
  268.         Super.BeginState(PreviousStateName);
  269.         bPulverizerFireReleased = false;
  270.     }
  271.  
  272.     /** Set bPulverizerFireReleased to ignore NotifyMeleeCollision */
  273.     simulated function StopFire(byte FireModeNum)
  274.     {
  275.         Super.StopFire(FireModeNum);
  276.         bPulverizerFireReleased = true;
  277.     }
  278.  
  279.     /** Network: Local Player */
  280.     simulated function NotifyMeleeCollision(Actor HitActor, optional vector HitLocation)
  281.     {
  282.         local KFPawn Victim;
  283.  
  284.         // If fire button is being held down, try firing pulverizer
  285.         if ( Instigator != None && Instigator.IsLocallyControlled() /*&& !bPulverizerFireReleased*/ )
  286.         {
  287.             // only detonate when the pulverizer hits a pawn so that level geometry doesn't get in the way
  288.             if ( HitActor.bWorldGeometry )
  289.             {
  290.                 return;
  291.             }
  292.  
  293.             Victim = KFPawn(HitActor);
  294.             if ( Victim == None ||
  295.                 (!bFriendlyFireEnabled && Victim.GetTeamNum() == Instigator.GetTeamNum()) ||
  296.                 (Victim.bPlayedDeath && `TimeSince(Victim.TimeOfDeath) > 0.f) )
  297.             {
  298.                 return;
  299.             }
  300.  
  301.             if ( AmmoCount[0] >= AmmoCost[CUSTOM_FIREMODE] && !IsTimerActive(nameof(BeginPulverizerFire)) )
  302.             {
  303.                 BlastAttachee = HitActor;
  304.  
  305.                 // need to delay one frame, since this is called from AnimNotify
  306.                 SetTimer(0.001f, false, nameof(BeginPulverizerFire));
  307.  
  308.                 if ( Role < ROLE_Authority )
  309.                 {
  310.                     if( HitActor.bTearOff && Victim != none )
  311.                     {
  312.                         Victim.TakeRadiusDamage(Instigator.Controller, ExplosionTemplate.Damage, ExplosionTemplate.DamageRadius, ExplosionTemplate.MyDamageType,
  313.                             ExplosionTemplate.MomentumTransferScale, Location, true, (Owner != None) ? Owner : self);
  314.                     }
  315.                     else
  316.                     {
  317.                         ServerBeginPulverizerFire(HitActor, HitLocation);
  318.                     }
  319.                 }
  320.             }
  321.         }
  322.     }
  323. }
  324.  
  325. defaultproperties
  326. {
  327.  
  328.     AssociatedPerkClasses(0)=class'KFPerk_Berserker'
  329.  
  330.     // Content
  331.     PackageKey="BALROG9"
  332.     FirstPersonMeshName="WEP_BALROG_MESH.Wep_1stP_Balrog9s_Rig"
  333.     FirstPersonAnimSetNames(0)="wep_1p_static_strikers_anim.wep_1p_static_strikers_anim"
  334.     PickupMeshName="WEP_BALROG_MESH.Wep_3rdP_Balrog9_Pickup"
  335.     AttachmentArchetypeName="WEP_BALROG9_ARCH.Wep_Balrog9_3P"
  336.  
  337.     Begin Object Name=MeleeHelper_0
  338.         MaxHitRange=120 //150 //190
  339.         // Override automatic hitbox creation (advanced)
  340.         HitboxChain.Add((BoneOffset=(Y=+5,Z=250)))
  341.         HitboxChain.Add((BoneOffset=(Y=+5,Z=170)))
  342.         HitboxChain.Add((BoneOffset=(Y=+5,Z=150)))
  343.         HitboxChain.Add((BoneOffset=(Y=-5,Z=130)))
  344.         HitboxChain.Add((BoneOffset=(Y=+5,Z=110)))
  345.         HitboxChain.Add((BoneOffset=(Y=-5,Z=90)))
  346.         HitboxChain.Add((BoneOffset=(Y=+5,Z=70)))
  347.         HitboxChain.Add((BoneOffset=(Y=-5,Z=50)))
  348.         HitboxChain.Add((BoneOffset=(Y=+5,Z=30)))
  349.         HitboxChain.Add((BoneOffset=(Y=-4,Z=250)))
  350.         HitboxChain.Add((BoneOffset=(Y=-4,Z=170)))
  351.         HitboxChain.Add((BoneOffset=(Y=+4,Z=150)))
  352.         HitboxChain.Add((BoneOffset=(Y=-4,Z=130)))
  353.         HitboxChain.Add((BoneOffset=(Y=+4,Z=110)))
  354.         HitboxChain.Add((BoneOffset=(Y=-4,Z=90)))
  355.         HitboxChain.Add((BoneOffset=(Y=+4,Z=70)))
  356.         HitboxChain.Add((BoneOffset=(Y=-4,Z=50)))
  357.         HitboxChain.Add((BoneOffset=(Y=+4,Z=30)))
  358.         HitboxChain.Add((BoneOffset=(Y=-4,Z=10)))
  359.         HitboxChain.Add((BoneOffset=(Y=+3,Z=250)))
  360.         HitboxChain.Add((BoneOffset=(Y=+3,Z=170)))
  361.         HitboxChain.Add((BoneOffset=(Y=+3,Z=150)))
  362.         HitboxChain.Add((BoneOffset=(Y=-3,Z=130)))
  363.         HitboxChain.Add((BoneOffset=(Y=+3,Z=110)))
  364.         HitboxChain.Add((BoneOffset=(Y=-3,Z=90)))
  365.         HitboxChain.Add((BoneOffset=(Y=+3,Z=70)))
  366.         HitboxChain.Add((BoneOffset=(Y=-3,Z=50)))
  367.         HitboxChain.Add((BoneOffset=(Y=+3,Z=30)))
  368.         HitboxChain.Add((BoneOffset=(Z=10)))
  369.         HitboxChain.Add((BoneOffset=(Z=-10)))
  370.         WorldImpactEffects=KFImpactEffectInfo'FX_Impacts_ARCH.Blunted_melee_impact'
  371.  
  372.         // modified combo sequences
  373.         MeleeImpactCamShakeScale=0.035f //0.4
  374.         ChainSequence_F=(DIR_Left, DIR_ForwardRight, DIR_ForwardLeft, DIR_ForwardRight, DIR_ForwardLeft)
  375.         ChainSequence_B=(DIR_BackwardLeft, DIR_Left, DIR_Right, DIR_ForwardRight, DIR_Left, DIR_Right, DIR_Left)
  376.         ChainSequence_L=(DIR_Right, DIR_BackwardRight, DIR_ForwardRight, DIR_ForwardLeft, DIR_Right, DIR_Left)
  377.         ChainSequence_R=(DIR_Left, DIR_BackwardLeft, DIR_ForwardLeft, DIR_ForwardRight, DIR_Left, DIR_Right)
  378.     End Object
  379.  
  380.     // Zooming/Position
  381.     PlayerViewOffset=(X=20,Y=0,Z=0)
  382.  
  383.     // Inventory
  384.     GroupPriority=150
  385.     InventorySize=8
  386.     WeaponSelectTexture=Texture2D'WEP_UI_BALROG_TEX.UI_BALROG9_TEX'
  387.  
  388.     FireModeIconPaths(DEFAULT_FIREMODE)=Texture2D'ui_firemodes_tex.UI_FireModeSelect_BluntMelee'
  389.     InstantHitDamage(DEFAULT_FIREMODE)=190
  390.     InstantHitDamageTypes(DEFAULT_FIREMODE)=class'KFDT_Bludgeon_Balrog9'
  391.  
  392.     // Trigger explosion as Heavy Attack
  393.     FireModeIconPaths(HEAVY_ATK_FIREMODE)=Texture2D'ui_firemodes_tex.UI_FireModeSelect_BluntMelee'
  394.     InstantHitDamage(HEAVY_ATK_FIREMODE)=350
  395.     InstantHitDamageTypes(HEAVY_ATK_FIREMODE)=class'KFDT_Bludgeon_Balrog9Heavy'
  396.  
  397.     InstantHitDamageTypes(BASH_FIREMODE)=class'KFDT_Bludgeon_Balrog9'
  398.     InstantHitDamage(BASH_FIREMODE)=140
  399.  
  400.     // Trigger explosion
  401.     FireModeIconPaths(CUSTOM_FIREMODE)=Texture2D'ui_firemodes_tex.UI_FireModeSelect_ShotgunSingle'
  402.     FiringStatesArray(CUSTOM_FIREMODE)=WeaponSingleFiring
  403.     WeaponFireTypes(CUSTOM_FIREMODE)=EWFT_Custom
  404.     FireInterval(CUSTOM_FIREMODE)=1.0f
  405.     AmmoCost(CUSTOM_FIREMODE)=0
  406.  
  407.     BlastSpawnOffset=-10.f
  408.  
  409.     // Explosion settings.  Using archetype so that clients can serialize the content
  410.     // without loading the 1st person weapon content (avoid 'Begin Object')!
  411.     ExplosionActorClass=class'KFExplosionActorReplicated'
  412.     ExplosionTemplate=KFGameExplosion'WEP_BALROG9_ARCH.Wep_BALROG9_Explosion'
  413.     AltExploEffects = KFImpactEffectInfo'WEP_RPG7_ARCH.RPG7_Explosion_Concussive_Force' //Leave this alone until we want it
  414.  
  415.     NukeExplosionActorClass=class'KFExplosion_ReplicatedNuke'
  416.  
  417.     // RELOAD
  418.     FiringStatesArray(RELOAD_FIREMODE)=Reloading
  419.  
  420.     // Fire Effects
  421.     WeaponFireSnd(CUSTOM_FIREMODE)=(DefaultCue=AkEvent'WW_WEP_MEL_Pulverizer.Play_WEP_MEL_Pulverizer_Fire_3P', FirstPersonCue=AkEvent'WW_WEP_MEL_Pulverizer.Play_WEP_MEL_Pulverizer_Fire_1P')
  422.  
  423.     // Block Effects
  424.     BlockSound=AkEvent'WW_WEP_Bullet_Impacts.Play_Block_MEL_Hammer'
  425.     ParrySound=AkEvent'WW_WEP_Bullet_Impacts.Play_Parry_Wood'
  426.  
  427.     // Trader
  428.     ParryStrength=7
  429.     ParryDamageMitigationPercent=0.50
  430.     BlockDamageMitigation=0.50
  431.  
  432.     // Weapon Upgrade stat boosts
  433.     WeaponUpgrades[1]=(IncrementDamage=1.2f,IncrementWeight=0)
  434.     WeaponUpgrades[2]=(IncrementDamage=1.4f,IncrementWeight=0)
  435. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement