Tuesday, 17 June 2014

Prototype - Critical Damage System

What I really like in games is critical strikes. I'm always playing rogue or some character with big crit chance and attack speed. I won't do the same here but there are couple of things that can be done:
  • If you hit enemy really near weak point there will be chance for critical damage,
  • If you get critical damage game should be able to show you this,
  • You should know how much damage are you dealing, 
Thanks to that more advanced players will be able to kill an enemy with one shoot. 

Change AnyDamge to PointDamage.
In your MainAI_Pawn replace AnyDamage to Point Damage. Do the same in SpiderPawn.

Go to Pistol_Projectile and change AnyDamage to PointDamage. Direction can be set like here:
Open MainAI_Pawn and create new Scene component - name it "Heart". There is one thing weir with components you aren't able to change them in classes that extend this actor. So open SpiderPawn and create Scene component, name it HeartSpider

Still in SpiderPawn go to Begin Play event and set Heart to HeartSpider
Go to MainAI_Pawn and to PointDamage Event. We will need to check how far from Heart we shoot. 
You can make variables to be able to quickly balance critital damage multiply and distance from heart.

Now create new blueprint, extend from Actor and name it EnemyText. Add couple of variables:
  • Text - float, (editable and expose on spawn)
  • Alpha - float, 
  • WasCrit - bool, (editable and expose on spawn)
  • GoingBack - bool,
  • Lifetime - float - default: 3
For now we will leave this blueprint because we need to add something into MyHud. So open MyHud blueprint and add two variables: TextColor(LinearColor) and EnemyTexts - this should be EnemText type and should be array. That's all for hud now.

Go back to EnemyText and create Tick Event. We will animate this actor - it will move up.
That's all here. Now move into MainAI_Pawn and PointDamage event. We would need to spawn this actor when we shoot to the enemy. 
And after spawning we need to manage EnemTexts array in HUD. So here's the rest part of Spawning Enemy Text:
Everything is ready to draw it on Hud.

Open MyHud and go to Draw Function. Create Sequence and add this to your blueprint. It will draw damage from enemies:
That's all! Now when you shoot your enemy you will see floating damage text there.

Critical Damage Projectile and Camera
Create a copy of MyProjectile name it "CriticalProjectile" and change couple of things:
  • Add spring arm as we did in Steer Gun,
  • Add camera and assign it to spring arm,
  • Change projectile speed - from 2000 to 3000,
  • Remove the mesh,
  • Add audio component with sound above,
Go to Graph and remove everything. Leave EventHit only and:

Now go to MainAI_Pawn and add sequence when we know that there will be critical strike. (before spawning EnemyText)
It's enough for prototype but it will need to be polished a lot later.

Final Result
In next post I will add laser scope to the weapons so it will be easier to aim.

No comments:

Post a Comment