E
EvilShuckle
Guest
So I have this simple question. Hopefully you can explain it in a way that my inexperienced *ss also understands it but here goes.
To understand the basics I've been following these youtube vids by Shaun Spalding. In one of the earlier vids he showed how to make an enemy react when hit by a bullet. A variable health, when hit a flash of white light, and when at 0 health, a small knockback and another sprite to make it look dead. This is all clear to me and I can make (but haven't done because there are no bullets in my game).
However in my game it's about melee attacks. In another guide he explained how to do a melee attack, with hitbox and all, that also hits the opponent. The idea was to use different states.
The one in the player object is:
I don't fully understand it. What does the ds_list_create() do exactly?
In the state attack slash it is used again
It works, after some bug fixing, but exactly what it does I don't know. The same ds_list_create is used. Basically I understand it til 'for (var i = 0; etc'
Now my actual question: In this game he put together the enemy also makes use of a script to go through the whole process of checking whether hit, showing an animation when hit, losing health and eventually crumbling when dead. Problem is, he doesn't explain the script or show it, really. He shows it for like 1 second but isn't complete, and so I don't know how that one worked.
Currently in my game I am using game_restart(); in order to see if it works. Which it does, now. So that's good, only I don't know which code I should add there to make it work. I know how to do the basic stuff after colliding with an object (the bullet), but since the melee attack is just a change in sprite and not in object, I don't know how to make it so that the stuff that'd happen with the bullet (the white flash, losing health, getting knocked back when dead, changing sprite) now happens when the creature gets hit by the melee attack.
The flash of white is a shader that is white. The enemy currently has in the create:
and in draw
Hopefully this is enough information
To understand the basics I've been following these youtube vids by Shaun Spalding. In one of the earlier vids he showed how to make an enemy react when hit by a bullet. A variable health, when hit a flash of white light, and when at 0 health, a small knockback and another sprite to make it look dead. This is all clear to me and I can make (but haven't done because there are no bullets in my game).
However in my game it's about melee attacks. In another guide he explained how to do a melee attack, with hitbox and all, that also hits the opponent. The idea was to use different states.
The one in the player object is:
Code:
hsp = 0;
vsp = 0;
grv = 0.3;
walksp = 4;
hascontrol = true;
state = PLAYERSTATE.FREE;
hitByAttack = ds_list_create();
enum PLAYERSTATE
{
FREE,
ATTACK_SLASH,
ATTACK_COMBO
}
In the state attack slash it is used again
Code:
hsp = 0;
vsp = 0;
if (sprite_index != atkground)
{
sprite_index = atkground;
image_index = 0;
ds_list_clear(hitByAttack);
}
mask_index = atkgroundHB;
var hitByAttackNow = ds_list_create();
var hits = instance_place_list(x,y,skeletonow,hitByAttackNow,false);
if (hits > 0)
{
for (var i = 0; i < hits; i++)
{
var hitID = hitByAttackNow[| i];
if (ds_list_find_index(hitByAttack,hitID) == -1)
{
ds_list_add(hitByAttack,hitID);
with (hitID)
{
game_restart();
}
}
}
}
ds_list_destroy(hitByAttackNow);
mask_index = playerstanding;
if (animation_end())
{
sprite_index = playerstanding
state = PLAYERSTATE.FREE;
}
Now my actual question: In this game he put together the enemy also makes use of a script to go through the whole process of checking whether hit, showing an animation when hit, losing health and eventually crumbling when dead. Problem is, he doesn't explain the script or show it, really. He shows it for like 1 second but isn't complete, and so I don't know how that one worked.
Currently in my game I am using game_restart(); in order to see if it works. Which it does, now. So that's good, only I don't know which code I should add there to make it work. I know how to do the basic stuff after colliding with an object (the bullet), but since the melee attack is just a change in sprite and not in object, I don't know how to make it so that the stuff that'd happen with the bullet (the white flash, losing health, getting knocked back when dead, changing sprite) now happens when the creature gets hit by the melee attack.
The flash of white is a shader that is white. The enemy currently has in the create:
Code:
walksp = 4;
hp = 4;
flash = 0;
Code:
draw_self();
if (flash > 0)
{
flash--;
shader_set(sWhite);
draw_self();
shader_reset();
}