Advertisement
Guest User

Untitled

a guest
Jul 1st, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // KFWeap_Blunt_PowerGloves
  3. //=============================================================================
  4. // Weapon class for melee power gloves weapon.
  5. // This is the Static Strikers
  6. //=============================================================================
  7. // Killing Floor 2
  8. // Copyright (C) 2017 Tripwire Interactive LLC
  9. //=============================================================================
  10.  
  11. class KFWeap_Blunt_Balrog9 extends KFWeap_MeleeBase;
  12.  
  13. const ShootAnim_L = 'Atk_H_L';
  14. const ShootAnim_R = 'Atk_H_R';
  15. const ShootAnim_F = 'Atk_H_F';
  16. const ShootAnim_B = 'Atk_H_B';
  17.  
  18. var bool bWasTimeDilated;
  19.  
  20. /** Explosion actor class to spawn */
  21. var class<KFExplosionActor> ExplosionActor${1}< ${3} >
  22. var() KFGameExplosion ExplosionTemplate;
  23. /** If true, use an alternate set of explosion effects */
  24. var bool    bAltExploEffects;
  25. var KFImpactEffectInfo AltExploEffects;
  26.  
  27. var transient Actor BlastAttachee;
  28.  
  29. /** Spawn location offset to improve cone hit detection */
  30. var transient float BlastSpawnOffset;
  31.  
  32. /** If set, heavy attack button has been released during the attack */
  33. var transient bool bPulverizerFireReleased;
  34.  
  35. var bool bFriendlyFireEnabled;
  36.  
  37. var class<KFExplosionActor> NukeExplosionActor${1}< ${3} >
  38.  
  39. replication
  40. {
  41.     if (bNetInitial)
  42.         bFriendlyFireEnabled;
  43. }
  44.  
  45. simulated event PreBeginPlay()
  46. {
  47.     Super.PreBeginPlay();
  48.  
  49.     /** Initially check whether friendly fire is on or not. */
  50.     if(Role == ROLE_Authority && KFGameInfo(WorldInfo.Game).FriendlyFireScale != 0.f)
  51.     {
  52.         bFriendlyFireEnabled = true;
  53.     }
  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. // for nukes && concussive force
  113. simulated protected function PrepareExplosionTemplate()
  114. {
  115.     local KFPlayerReplicationInfo InstigatorPRI;
  116.     local KFPlayerController KFPC;
  117.     local KFPerk InstigatorPerk;
  118.  
  119.     if (bWasTimeDilated)
  120.     {
  121.         InstigatorPRI = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo);
  122.         if (InstigatorPRI != none)
  123.         {
  124.             if (InstigatorPRI.bNukeActive)
  125.             {
  126.                 ExplosionTemplate = class'KFPerk_Demolitionist'.static.GetNukeExplosionTemplate();
  127.                 ExplosionTemplate.Damage = ExplosionTemplate.Damage * class'KFPerk_Demolitionist'.static.GetNukeDamageModifier();
  128.                 ExplosionTemplate.DamageRadius = ExplosionTemplate.DamageRadius * class'KFPerk_Demolitionist'.static.GetNukeRadiusModifier();
  129.                 ExplosionTemplate.DamageFalloffExponent = ExplosionTemplate.DamageFalloffExponent;
  130.             }
  131.             else if (InstigatorPRI.bConcussiveActive && AltExploEffects != none)
  132.             {
  133.                 ExplosionTemplate.ExplosionEffects = AltExploEffects;
  134.                 ExplosionTemplate.ExplosionSound = class'KFPerk_Demolitionist'.static.GetConcussiveExplosionSound();
  135.             }
  136.         }
  137.     }
  138.     else
  139.     {
  140.         ExplosionTemplate = default.ExplosionTemplate;
  141.         ExplosionTemplate.ExplosionEffects = default.ExplosionTemplate.ExplosionEffects;
  142.         ExplosionTemplate.ExplosionSound = default.ExplosionTemplate.ExplosionSound;
  143.         ExplosionTemplate.Damage = ExplosionTemplate.default.Damage;
  144.         ExplosionTemplate.DamageRadius = ExplosionTemplate.default.DamageRadius;
  145.         ExplosionTemplate.DamageFalloffExponent = ExplosionTemplate.default.DamageFalloffExponent;
  146.     }
  147.  
  148.     // Change the radius and damage based on the perk
  149.     if (Owner.Role == ROLE_Authority)
  150.     {
  151.         KFPC = KFPlayerController(Instigator.Controller);
  152.         if (KFPC != none)
  153.         {
  154.             InstigatorPerk = KFPC.GetPerk();
  155.             ExplosionTemplate.DamageRadius *= InstigatorPerk.GetAoERadiusModifier();
  156.         }
  157.     }
  158. }
  159.  
  160. simulated protected function SetExplosionActorClass()
  161. {
  162.     local KFPlayerReplicationInfo InstigatorPRI;
  163.  
  164.     if (bWasTimeDilated && Instigator != none)
  165.     {
  166.         InstigatorPRI = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo);
  167.         if (InstigatorPRI != none)
  168.         {
  169.             if (InstigatorPRI.bNukeActive)
  170.             {
  171.                 ExplosionActorClass = NukeExplosionActor${1}< ${3} >
  172.                 return;
  173.             }
  174.         }
  175.     }
  176.     ExplosionActorClass = default.ExplosionActor${1}< ${3} >
  177. }
  178.  
  179. /** Called by CustomFire when shotgun blast is fired */
  180. simulated function Rotator GetPulverizerAim( vector StartFireLoc )
  181. {
  182.     local Rotator R;
  183.  
  184.     R = GetAdjustedAim(StartFireLoc);
  185.  
  186.     // Adjust cone fire angle based on swing direction
  187.     switch (MeleeAttackHelper.CurrentAttackDir)
  188.     {
  189.         case DIR_Left:
  190.             R.Yaw += 5461;
  191.             break;
  192.         case DIR_Right:
  193.             R.Yaw -= 5461;
  194.             break;
  195.         case DIR_Forward:
  196.             R.Pitch -= 2048;
  197.             break;
  198.         case DIR_Backward:
  199.             R.Pitch += 2048;
  200.             break;
  201.     }
  202.  
  203.     return R;
  204. }
  205.  
  206. /** Called on the server alongside PulverizerFired */
  207. reliable server private function ServerBeginPulverizerFire(Actor HitActor, optional vector HitLocation)
  208. {
  209.     // Ignore if too far away (something went wrong!)
  210.     if ( VSizeSq2D(HitLocation - Instigator.Location) > Square(500) )
  211.     {
  212.         `log("ServerBeginPulverizerFire outside of range!");
  213.         return;
  214.     }
  215.  
  216.     BlastAttachee = HitActor;
  217.     SendToFiringState(HEAVY_ATK_FIREMODE);
  218. }
  219.  
  220. /** Called when altfire melee attack hits a target and there is ammo left */
  221. simulated function BeginPulverizerFire()
  222. {
  223.     SendToFiringState(HEAVY_ATK_FIREMODE);
  224. }
  225.  
  226. /** Skip calling StillFiring/PendingFire to fix log warning */
  227. simulated function bool ShouldRefire()
  228. {
  229.     if ( CurrentFireMode == HEAVY_ATK_FIREMODE )
  230.         return false;
  231.  
  232.     return Super.ShouldRefire();
  233. }
  234.  
  235. /** Debugging */
  236. `if(`notdefined(ShippingPC))
  237. exec function ToggleWeaponDebug()
  238. {
  239.     bDebug = !bDebug;
  240. }
  241. `endif
  242.  
  243. simulated state MeleeHeavyAttacking
  244. {
  245.     /** Reset bPulverizerFireReleased */
  246.     simulated event BeginState(Name PreviousStateName)
  247.     {
  248.         Super.BeginState(PreviousStateName);
  249.         bPulverizerFireReleased = false;
  250.     }
  251.  
  252.     /** Network: Local Player */
  253.     simulated function NotifyMeleeCollision(Actor HitActor, optional vector HitLocation)
  254.     {
  255.         local KFPawn Victim;
  256.  
  257.         // If fire button is being held down, try firing pulverizer
  258.         if ( Instigator != None && Instigator.IsLocallyControlled() /*&& !bPulverizerFireReleased*/ )
  259.         {
  260.             // only detonate when the pulverizer hits a pawn so that level geometry doesn't get in the way
  261.             if ( HitActor.bWorldGeometry )
  262.             {
  263.                 return;
  264.             }
  265.  
  266.             Victim = KFPawn(HitActor);
  267.             if ( Victim == None ||
  268.                 (!bFriendlyFireEnabled && Victim.GetTeamNum() == Instigator.GetTeamNum()) ||
  269.                 (Victim.bPlayedDeath && `TimeSince(Victim.TimeOfDeath) > 0.f) )
  270.             {
  271.                 return;
  272.             }
  273.  
  274.             if ( AmmoCount[0] >= AmmoCost[CUSTOM_FIREMODE] && !IsTimerActive(nameof(BeginPulverizerFire)) )
  275.             {
  276.                 BlastAttachee = HitActor;
  277.  
  278.                 // need to delay one frame, since this is called from AnimNotify
  279.                 SetTimer(0.001f, false, nameof(BeginPulverizerFire));
  280.  
  281.                 if ( Role < ROLE_Authority )
  282.                 {
  283.                     if( HitActor.bTearOff && Victim != none )
  284.                     {
  285.                         Victim.TakeRadiusDamage(Instigator.Controller, ExplosionTemplate.Damage, ExplosionTemplate.DamageRadius, ExplosionTemplate.MyDamageType,
  286.                             ExplosionTemplate.MomentumTransferScale, Location, true, (Owner != None) ? Owner : self);
  287.                     }
  288.                     else
  289.                     {
  290.                         ServerBeginPulverizerFire(HitActor, HitLocation);
  291.                     }
  292.                 }
  293.             }
  294.         }
  295.     }
  296. }
  297.  
  298. defaultproperties
  299. {
  300.  
  301.     AssociatedPerkClasses(0)=class'KFPerk_Berserker'
  302.  
  303.     // Content
  304.     PackageKey="BALROG9"
  305.     FirstPersonMeshName="WEP_BALROG_MESH.Wep_1stP_Balrog9s_Rig"
  306.     FirstPersonAnimSetNames(0)="wep_1p_static_strikers_anim.wep_1p_static_strikers_anim"
  307.     PickupMeshName="WEP_BALROG_MESH.Wep_3rdP_Balrog9_Pickup"
  308.     AttachmentArchetypeName="WEP_BALROG9_ARCH.Wep_Balrog9_3P"
  309.  
  310.     Begin Object Name=MeleeHelper_0
  311.         MaxHitRange=120 //150 //190
  312.         // Override automatic hitbox creation (advanced)
  313.         HitboxChain.Add((BoneOffset=(Y=+5,Z=250)))
  314.         HitboxChain.Add((BoneOffset=(Y=+5,Z=170)))
  315.         HitboxChain.Add((BoneOffset=(Y=+5,Z=150)))
  316.         HitboxChain.Add((BoneOffset=(Y=-5,Z=130)))
  317.         HitboxChain.Add((BoneOffset=(Y=+5,Z=110)))
  318.         HitboxChain.Add((BoneOffset=(Y=-5,Z=90)))
  319.         HitboxChain.Add((BoneOffset=(Y=+5,Z=70)))
  320.         HitboxChain.Add((BoneOffset=(Y=-5,Z=50)))
  321.         HitboxChain.Add((BoneOffset=(Y=+5,Z=30)))
  322.         HitboxChain.Add((BoneOffset=(Y=-4,Z=250)))
  323.         HitboxChain.Add((BoneOffset=(Y=-4,Z=170)))
  324.         HitboxChain.Add((BoneOffset=(Y=+4,Z=150)))
  325.         HitboxChain.Add((BoneOffset=(Y=-4,Z=130)))
  326.         HitboxChain.Add((BoneOffset=(Y=+4,Z=110)))
  327.         HitboxChain.Add((BoneOffset=(Y=-4,Z=90)))
  328.         HitboxChain.Add((BoneOffset=(Y=+4,Z=70)))
  329.         HitboxChain.Add((BoneOffset=(Y=-4,Z=50)))
  330.         HitboxChain.Add((BoneOffset=(Y=+4,Z=30)))
  331.         HitboxChain.Add((BoneOffset=(Y=-4,Z=10)))
  332.         HitboxChain.Add((BoneOffset=(Y=+3,Z=250)))
  333.         HitboxChain.Add((BoneOffset=(Y=+3,Z=170)))
  334.         HitboxChain.Add((BoneOffset=(Y=+3,Z=150)))
  335.         HitboxChain.Add((BoneOffset=(Y=-3,Z=130)))
  336.         HitboxChain.Add((BoneOffset=(Y=+3,Z=110)))
  337.         HitboxChain.Add((BoneOffset=(Y=-3,Z=90)))
  338.         HitboxChain.Add((BoneOffset=(Y=+3,Z=70)))
  339.         HitboxChain.Add((BoneOffset=(Y=-3,Z=50)))
  340.         HitboxChain.Add((BoneOffset=(Y=+3,Z=30)))
  341.         HitboxChain.Add((BoneOffset=(Z=10)))
  342.         HitboxChain.Add((BoneOffset=(Z=-10)))
  343.         WorldImpactEffects=KFImpactEffectInfo'FX_Impacts_ARCH.Blunted_melee_impact'
  344.  
  345.         // modified combo sequences
  346.         MeleeImpactCamShakeScale=0.035f //0.4
  347.         ChainSequence_F=(DIR_Left, DIR_ForwardRight, DIR_ForwardLeft, DIR_ForwardRight, DIR_ForwardLeft)
  348.         ChainSequence_B=(DIR_BackwardLeft, DIR_Left, DIR_Right, DIR_ForwardRight, DIR_Left, DIR_Right, DIR_Left)
  349.         ChainSequence_L=(DIR_Right, DIR_BackwardRight, DIR_ForwardRight, DIR_ForwardLeft, DIR_Right, DIR_Left)
  350.         ChainSequence_R=(DIR_Left, DIR_BackwardLeft, DIR_ForwardLeft, DIR_ForwardRight, DIR_Left, DIR_Right)
  351.     End Object
  352.  
  353.     // FOV
  354.     //MeshFOV=95
  355.  
  356.     // Zooming/Position
  357.     PlayerViewOffset=(X=20,Y=0,Z=0)
  358.  
  359.     // Inventory
  360.     GroupPriority=110
  361.     InventorySize=8
  362.     WeaponSelectTexture=Texture2D'WEP_UI_BALROG_TEX.UI_BALROG9_TEX'
  363.  
  364.     FireModeIconPaths(DEFAULT_FIREMODE)=Texture2D'ui_firemodes_tex.UI_FireModeSelect_BluntMelee'
  365.     InstantHitDamage(DEFAULT_FIREMODE)=190
  366.     InstantHitDamageTypes(DEFAULT_FIREMODE)=class'KFDT_Bludgeon_Balrog9'
  367.  
  368.     FireModeIconPaths(HEAVY_ATK_FIREMODE)=Texture2D'ui_firemodes_tex.UI_FireModeSelect_BluntMelee'
  369.     InstantHitDamage(HEAVY_ATK_FIREMODE)=350
  370.     InstantHitDamageTypes(HEAVY_ATK_FIREMODE)=class'KFDT_Bludgeon_Balrog9Heavy'
  371.  
  372.     InstantHitDamageTypes(BASH_FIREMODE)=class'KFDT_Bludgeon_Balrog9'
  373.     InstantHitDamage(BASH_FIREMODE)=100
  374.  
  375.     BlastSpawnOffset=-10.f
  376.     // Explosion settings.  Using archetype so that clients can serialize the content
  377.     // without loading the 1st person weapon content (avoid 'Begin Object')!
  378.     ExplosionActorClass=class'KFExplosionActorReplicated'
  379.     ExplosionTemplate=KFGameExplosion'WEP_BALROG9_ARCH.Wep_BALROG9_Explosion'
  380.     AltExploEffects = KFImpactEffectInfo'WEP_RPG7_ARCH.RPG7_Explosion_Concussive_Force' //Leave this alone until we want it
  381.     NukeExplosionActorClass=class'KFExplosion_ReplicatedNuke'
  382.  
  383.     // Block Sounds
  384.     BlockSound=AkEvent'WW_WEP_Bullet_Impacts.Play_Block_MEL_Crovel'
  385.     ParrySound=AkEvent'WW_WEP_Bullet_Impacts.Play_Parry_Metal'
  386.  
  387.     ParryStrength=7
  388.     ParryDamageMitigationPercent=0.50
  389.     BlockDamageMitigation=0.50
  390.  
  391.     // Weapon Upgrade stat boosts
  392.     WeaponUpgrades[1]=(IncrementDamage=1.2f,IncrementWeight=0)
  393.     WeaponUpgrades[2]=(IncrementDamage=1.4f,IncrementWeight=0)
  394. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement