Oh Hey It Works... Never mind.
So today I wanted to make the dodge roll effect the damage the player takes. The red text below shows what I had to make this possible. Clearly this wasn't that hard, thanks to my amazing organization of code. Another thing to note about this is its another simple use for my "dodging" variable.
if dodging = false
{
if (obj_player.blocking = false) and !(obj_player.armour > 0)
{
audio_play_sound(sou_player_attack_hit,1,false)
instance_create(x,y,obj_blood_1)
instance_destroy();
}
if (obj_player.blocking = false) and (obj_player.armour > 0)
{
audio_play_sound(sou_metal_clash,1,false)
audio_sound_pitch(sou_metal_clash,random_range(0.8,1))
instance_create(x,y,obj_blood_1)
instance_destroy();
}
if (obj_player.blocking = true)
{
audio_play_sound(sou_player_shield_thud,1,false)
instance_destroy();
}
}
So the result of this code was little bit unexpected. Currently if you are dodging and are hit by an enemy the game will crash. This is probably just and easy fix and instead of having "if dodging = false" inside the hitbox object, I need it inside the player object. It completely slipped my mind that the process of being hit is actually inside the player object, and that this object only tells the player when to be hit so to speak. So the damage doesn't actually occur in the code above. Which I would have noticed if I read it first.
So now I have completely relocated the code into the correct section. As you can see below there is still blood being created, that is because the code that controls that is in the original place I put the code. So I will fix that. But the health is no longer effected when the player is rolling, sadly I didn't make my GIF big enough to show that, so your just going to have to trust me on this one.
Below is the changed code, green text is footnotes within the code, red is the new code, and black is everything else.
///Damage Changes (Armour,Blocking)
// NO ARMOUR, NOT BLOCKING
if dodging = false
{
if (blocking = false) and (dodge = false) and (armour = 0)
{
player1health -= random_range(10,20)
alarm[1] = 3;
image_blend = c_red;
obj_room_view.ashake = 20;
random_bleed = (random_range(5,30))
bleeding = true;
}
//HAS ARMOUR
if (blocking = false) and (dodge = false) and (armour > 0)
{
armour -= random_range(10,30)
player1health -= random_range(1,5)
alarm[1] = 3;
image_blend = c_red;
obj_room_view.ashake = 5;
}
//IS BLOCKING HAS NO ARMOUR
if (blocking = true) and (dodge = false) and (armour = 0)
player1health -= random_range(1,5)
{
if (blocking = true) and (dodge = false)
{image_blend = c_red}
alarm[1] = 3;
obj_room_view.ashake = 5;
}
//IS BLOCKING HAS ARMOUR
if (blocking = true) and (dodge = false) and (armour >0)
player1health -= random_range(1,1)
{
if (blocking = true) and (dodge = false)
{image_blend = c_red}
alarm[1] = 3;
obj_room_view.ashake = 5;
}
}
Tomorrow I will fix the blood appearing when the player isn't actually taking damage, and I will also attempt to make a cool-down for the dodge roll.
No comments:
Post a Comment