Multi attack key

W

Wild_West

Guest
So I decided against actually making my character's attacks a series of just 1 then 2 then 3 in favor of just having a few different slashing animations that all are done with the 'A' key, in addition to a stabing attack, and a hammer drop kinda animation.

The spear and hammer are fine, trouble is with the 3 slashes.
I tried to make it as compact as I could all commands in one script, no args and just call it in the player step event.

But I guess since I'm using so many 'A' key commands in one script it can't execute since when I shortened it to one attack for 'A' of curse that worked fine.

So anybody have an idea how I can make it so pressing 'A' results in choosing from 1 of the 3 slash animations I have?

This is the working code as of now.


///perform_attack_basic();

if(keyboard_check_pressed(ord("A") ) ) and not(keyboard_check(vk_up) )
{ slash_value = choose(1,2,3); }

if(keyboard_check_pressed(ord("A") ) ) and not(move_left)
or(keyboard_check_pressed(ord("A") ) ) and not(move_right)
and(slash_value = 1)
{
sprite_index = slash1
image_speed = 0.2;
}
//create the damaging object
if(sprite_index = slash1) and (image_index = round(1) )
{
instance_create(x,y,Rslash1_dmg);
}
//-------------------------------------------------------------

if(keyboard_check_pressed(ord("A") ) ) and not(move_left)
or(keyboard_check_pressed(ord("A") ) ) and not(move_right)
and(slash_value = 2)
{
sprite_index = slash2
image_speed = 0.2;
}
//create the damaging object
if(sprite_index = slash2) and (image_index = round(3) )
{
instance_create(x,y,Rslash2_dmg);
}
//----------------------------------------------------------------

if(keyboard_check_pressed(ord("A") ) ) and not(move_left)
or(keyboard_check_pressed(ord("A") ) ) and not(move_right)
and(slash_value = 3)
{
sprite_index = slash3;
image_speed = 0.2;
}
//create the damaging object
if(sprite_index = slash3) and (image_index = round(3) )
{
instance_create(x,y,Rslash3_dmg);
}
//------------------------------------------------------------------

//Overhead attack Variation
if(keyboard_check(vk_up) + keyboard_check_pressed(ord("A") ) ) and not(move_left)
or(keyboard_check(vk_up) + keyboard_check_pressed(ord("A") ) ) and not(move_right)
{
image_index = overhead;
image_speed = 0.2;
}
//create the damaging object
if(sprite_index = overhead) and (image_index = round(2) )
{
instance_create(x,y,Roverhead_dmg);
}
 
D

DevNorway

Guest
You should first insert this as a code.
If you want a combo attack, that can easily be done by creating an array, then adding 1 it when attacking
 
W

Wild_West

Guest
You should first insert this as a code.
If you want a combo attack, that can easily be done by creating an array, then adding 1 it when attacking
It is actually already in a script along with the other attacks.
I had it as a combo setup before but changed my mind and decided to go with just being able to use the attacks however.
So rather than a choose do you think the array approach would work in one script?
 
D

DevNorway

Guest
I'm just simplifying it first. Don't mind this post. :p
Code:
///perform_attack_basic();

if(keyboard_check_pressed(ord("A") ) ) and not(keyboard_check(vk_up) )
{ slash_value = choose(1,2,3); }

if(keyboard_check_pressed(ord("A") ) ) and not(move_left)
or(keyboard_check_pressed(ord("A") ) ) and not(move_right)
and(slash_value = 1)
{
sprite_index = slash1
image_speed = 0.2;
}
//create the damaging object
if(sprite_index = slash1) and (image_index = round(1) )
{
instance_create(x,y,Rslash1_dmg);
}
//-------------------------------------------------------------

if(keyboard_check_pressed(ord("A") ) ) and not(move_left)
or(keyboard_check_pressed(ord("A") ) ) and not(move_right)
and(slash_value = 2)
{
sprite_index = slash2
image_speed = 0.2;
}
//create the damaging object
if(sprite_index = slash2) and (image_index = round(3) )
{
instance_create(x,y,Rslash2_dmg);
}
//----------------------------------------------------------------

if(keyboard_check_pressed(ord("A") ) ) and not(move_left)
or(keyboard_check_pressed(ord("A") ) ) and not(move_right)
and(slash_value = 3)
{
sprite_index = slash3;
image_speed = 0.2;
}
//create the damaging object
if(sprite_index = slash3) and (image_index = round(3) )
{
instance_create(x,y,Rslash3_dmg);
}
//------------------------------------------------------------------

//Overhead attack Variation
if(keyboard_check(vk_up) + keyboard_check_pressed(ord("A") ) ) and not(move_left)
or(keyboard_check(vk_up) + keyboard_check_pressed(ord("A") ) ) and not(move_right)
{
image_index = overhead;
image_speed = 0.2;
}
//create the damaging object
if(sprite_index = overhead) and (image_index = round(2) )
{
instance_create(x,y,Roverhead_dmg);
}
 
D

DevNorway

Guest
Code:
//Variable
attackbutton = keyboard_check_pressed(ord("A"))

//Slash value
if attackbutton && !keyboard_check(vk_up) {
    slash_value = choose(1,2,3);
}

//Attack
if attackbutton {
    if !move_left || move_right {
        if slash_value = 1 {
            //do slash1
        }
        if slash_value = 2 {
            //do slash2
        }
        if slash_value = 3 {
            //do slash3
        }
    }
}
Most of the code could be simplifyed if you would like to implement this.
 
W

Wild_West

Guest
Code:
//Variable
attackbutton = keyboard_check_pressed(ord("A"))

//Slash value
if attackbutton && !keyboard_check(vk_up) {
    slash_value = choose(1,2,3);
}

//Attack
if attackbutton {
    if !move_left || move_right {
        if slash_value = 1 {
            //do slash1
        }
        if slash_value = 2 {
            //do slash2
        }
        if slash_value = 3 {
            //do slash3
        }
    }
}
Most of the code could be simplifyed if you would like to implement this.
Actually I got my answer, I mean it might be a little clumsy I haven't tested it during real time enemy encounters yet but I'm just gonna map all 3 basic slashes to a combination of 'A' and the next closest keys 'Z' , 'S' and 'Q', and then I'll put the hammer and stabbing attacks at 'X' and 'W'.
But I'll give your simplified edit in there as well. Thanks for your time.
 
Top