Post 17: Finishing Stealth and More

Todays update is much like the christmas update in that I did a lot of improvements and implementing so I’ll just list them in order with a brief run down on what got done and how I did it. At the end of this page will be a video showing the current state of game as of today.

Finishing Stealth Killing

I left stealth kills at a point of working but with a couple of bugs that I was able to fix and get this working pretty well.

  1. Press [F] after sneaking up on the player and then engaging in normal combat; This was fixed by tapping into a function that I made previously to determine if a character was ready. When assassinating a target, it’s safe to say that all the targets should be unsuspecting and thus be NOT ready for an attack. I took advantage of this by calling the ‘Is Ready’ function and conditioned the pop up text and assassination function on a negative result.
  2. Being able to spam the assassination animation, never hitting the enemy target; This was fixed, again by using the ‘Is Ready’ function – setting is negative at the beginning of the assassination and setting it positive at the end. To make sure the animation played through, I put a delay on that matched the length.

Not too bad to deal with. I mentioned in the last post that I want to put in custom animations and perhaps a zoom to the front side of the assassination, but for now that will do.

Charged Attacks

Putting in charged attacks isn’t nessesary something that will make it into the end game, however seeing as I had already seperated out my attacks into a three animation combo, I thought it may be a feature that I could put in and take out later if I’m not that keen on it. The way I see it, it can be broken down into the following components:

Player starts charge >>> Prompt when charged >>> Player releases the charge >>> Full combo animations play.

Potentially over simplifying, but that’s more or less it. I implemented it like the following.

  1. The left mouse pressed / released function allowed me to determine when to start and release the charge. At the end of the  ‘On Pressed’ function I put in bool to establish when the attack was charged. For the sake of future proofing, I also put in a ‘Charging’ Bool at the beginning too (checked), with a ‘Charging’ (unchecked) before the checked “Charged”. This could be used for interruptions and what not, but not necessary right now.
  2. To prompt the player that the attack is finished charging I modified the material for the sword to include an emissive color (Red) that was attached to a multiplier. That multiplier is used to manipulate the emissive level, when charged the multiplier is put up to 50x and when released, 0.
  3. The player releasing the charge was implemented in the ‘On Release’ part of the Left Mouse Input function. Normal attacks are already based out of here so I used a branch that called for ‘IsCharged’, with a true condition leading to the charged attack sequence and a false leading to a normal attack.
  4. I setup a combined combo animation montage that I originally had split off the individual attacks from. After prepping it with hit notifiers, sounds and input enablers / disablers, I put a call into the ‘On Released’ function.

Weapon Data

The thought occurred when doing the assassination stuff that I am probably going to want more than one weapon in the game and so I went about making sure that I setup the weapon I have so that it may have children (it’s a boy?) which can share calls to variable properties such as damage, durability, animations and the like that can differ between items. I accomplished this by ensuring the following:

  1. The existing sword blueprint became a master blueprint.
  2. Any weapon actually used would be a child of that weapon blueprint.
  3. All changes that affect all melee weapons will be done to the master
  4. All weapon specific changes will be made to the children.
  5. The characters will have the child weapons attached to them, not the master.
  6. All references in the Master Character / Player Character / Enemy Character BP’s should refer to children in the weapon slots, not the master.

This now gives me the potential to substitute in different weapons / customise the weapons that each character has, as well as create new ones with individualised animations / meshes / damage profiles. Very good for future proofing. 

Changing Weapons

Speaking of multiple weapons, this part is about implementing a way for the player (and other characters for that matter) to change between two different weapons, with an unarmed mode in there two. So three possible states at this point. What I envision happening is something like below:

Player Start (Unarmed) >>> Pushes Button to equip:

[1] = Weapon 1 equip (Put back weapon 2, if equipped) – Animation transition

[2] = Weapon 2 (Put back weapon 1, if equipped) – Animation transition

[0] = Put back whatever weapon is equipped – Animation transition

This is of course a simplified version of what is going to happen, but it outlines it well.

This actually became quite fiddly and I had a lot of issues getting it right, with some outstanding bugs that will be delt with later in the dev process.

I started in the ‘Toggle Equip’ function and basically used a triple set of ‘Select’ functions that would sort out:

  1. What the character currently has equipped
  2. What the character is wanting to equip.
  3. The weapon slots that the weapons would equipped to (hand and 2x back slots) and actually equipping them / playing the animations needed.
  4. A variable that the weapon number is set to.

When the [1], [2] or [0] key is pushed the ‘Toggle Equip’ function looks for what weapon is equipped, uses the requested weapon number, puts the old weapon away and equips the new one.

As mentioned above, I needed to create a second weapon slot and filled it with a second weapon, a hammer in this case. These can be defined by a custom mesh and custom details that I mentioned implementing in the ‘Weapon Data’ section above.

There are some bugs when first equipping a weapon and some null returns which I will fix at a later point.

AI Patrolling

So with the possibility of NPC battles being implemented in the game, I thought I’d work on how they battle each other. What I wanted to achieve:

  1. Warring factions that would treat each other like enemies.
  2. An auto patrol function that would kick in before and after combat.

This was achieved by creating a patrol function that would be fitted in with the auto attack function. The trick was that it was the negative branch option of when the NPC’s scan for enemies. The end of the function would then link to a reset of the whole function so the NPC’s would be able to go into auto attack mode when they detected an enemy.

Seeing as this was in response to a negative return on an enemy being close, I implemented a call to pick a random spot in radius and go to that spot. Finally a delay to allow the character to get to that spot and a lead to the output (resetting, as mentioned above).

Block Breaking Spartan Kick

Yip, that’s right. I’m putting in the Spartan kick. What better way to show power and break a blocking enemy than by kicking them in the chest?

The best place to implement this is with a dedicated input, so I ended setting up an input for ‘G’ on the keyboard. In the master character blueprint I setup a call to an animation and also a hit call in the animation montage itself. This way there will be a hit check which I can then break the block with.

I created a ‘Can Block’ bool as well in the interface as I want the characters to be able to attack without being blocked. Potentially with a charge?

I put in a call the block function that I’d previously made, with a negative state change on the condition that:

a) The target is blocking

b) The attacker can be blocked.

This now allows the player to forcibly unblock an NPC. I’ve left the ‘Can Block’ bool true for now as I will need to implement a separation of attack types.

Handling Multiple Enemies

One of the issues at the moment is that once an NPC is focused on attacking another character, they won’t stop; even if a different character attacks them. I quickly implemented a change of target by taking in the source of a hit, when it happens, and replacing the current Attack Target with the source.

This worked well enough, but I added a condition to the beginning of this that would only change the target if it was not the same as the current target that occupies the variable.

Blocking Window Extension

In games such as Assassin Creed, there’s a subtle, but effective slow down when the NPC’s attack the player. This allows for a variation of abilities and reactionary times and is something that I wanted to put in the game. Once again this was fairly simple and involved a couple of steps

  1. I created a function that called on the “Global Anim Rate”, decreasing it to 1/10 scale of it’s normal size, putting in a delay of 0.1 seconds and then restoring the scale back to 1.
  2. I implemented this directly after the attack animation montage calls.

Final Notes

Finally, there were a couple of tweaks and little features such as Dash Trails (a copy of the sword trails) and some fixes to the dodging mechanics. I thought I might note down some existing bugs.

  1. When I tap the attack button and release really quickly the animation is almost paused half way through and the player can no longer attack.
  2. Same for blocking.
  3. The NPC’s still come far too close.
  4. The NPC’s attack range on the charge is HUGE.