Advertisement
Guest User

Untitled

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