» Uncategorized Posts

set_attack

Changes the character’s state to the specified attack.

ArgumentTypeDescription
state:realThe attack to set

Example, called from attack_update.gml:

// allows the player to cancel the endlag of a successful parry into Nspecial (but not other specials):
if (state == PS_PARRY && window == 2 && perfect_dodged && special_pressed) {
if !(up_down || down_down || left_down || right_down) {
set_attack( AT_NSPECIAL );
}
}

set_state

Changes the character’s state.

For attack states use set_attack( state )  Reference→
ArgumentTypeDescription
state:realThe state to set

Example, called from attack_update.gml:

// this attack cancels into pratfall when you press the dodge button:
if (window == 3 && shield_pressed){
set_state( PS_PRATFALL );
}

get_state_name

Returns a string of the player’s state.

ArgumentTypeDescription
state_index:realThe state index to get the name of

Example, called from debug_draw.gml:

// draws the player's state:
draw_debug_text( x, y, "state: " + get_state_name( state ));

attack_end

Resets can_hit properties for all hitbox groups for the current attack. Can be used for looping attack windows, so that the hitboxes can hit again.

Example, called from attack_update.gml:

if (window == 3 && window_timer == 1 && attack_down){
window = 2;
window_timer = 0;
attack_end(); //refreshes window 2's hitbox
}

random_func_2

Generates a random value between 0 and high_value, not including high_value. If called on the same frame with the same index, this function will always return the same value (making it replay-safe).

ArgumentTypeDescription
index:realIndex of the function call, must be between 0 and 200
high_value:realThe high end of the range from which the random number will be selected
floored:realIf the number returned should only be a whole number

Example, called from update.gml:

// creates 5 articles
// and sets their hsp and vsp to random whole numbers between 5 and 10:

for (var i = 0; i < 5; i++) {
var this_article = instance_create( x, y, "obj_article1" );
this_article.hsp = spr_dir * (5 + random_func_2( 2 * i, 6, true ) );
this_article.vsp = -5 - random_func_2( 2 * i + 1, 6, true );
}

Note that the first argument of each separate function call is different, otherwise they would return the same number!