Skip to content

Commit

Permalink
Added code to allow the player to button-mash.
Browse files Browse the repository at this point in the history
Now when the player presses the attack button, the next attack in the
chain continues even if they pressed it early.
  • Loading branch information
Autofire committed May 23, 2016
1 parent 3b8bda6 commit 00c0f84
Showing 1 changed file with 58 additions and 34 deletions.
92 changes: 58 additions & 34 deletions data/objects/pivot/pivot_playable.cfg
Expand Up @@ -83,23 +83,23 @@ properties: {
cANIM_SUFFIXES[cCURRENT_ANIM_SUFFIX],
'none')",
cANIM_NUMBER: "int ::
cANIM_NUM: "int ::
CharToInt(string <- animation[size(animation) - number_offset])
where number_offset = if(cANIM_TYPE = 'none', 1, 2)
",
cANIM_NAME: "string :: animation[ : _anim_name_size]
where _anim_name_size =
if(cANIM_NUMBER = null and cANIM_TYPE = 'none',
if(cANIM_NUM = null and cANIM_TYPE = 'none',
size(animation), // Return the full name if no suffixes
cANIM_NUMBER != null and cANIM_TYPE != 'none',
cANIM_NUM != null and cANIM_TYPE != 'none',
size(animation) - 2, // Trim both letter and number suffix
size(animation) - 1 // Trim either letter or number suffix
)
",
// Overloaded from hittable.cfg
cMINOR_ATTACK_NUM: "if(cANIM_NUMBER = null, 1, cANIM_NUMBER)",
cMINOR_ATTACK_NUM: "if(cANIM_NUM = null, 1, cANIM_NUM)",
/*******************
* ANIMATION BOOLS *
Expand All @@ -125,28 +125,23 @@ properties: {
cCAN_TURN: "bool :: bool(not cIN_SWORD_ANIM)",
cIS_LAST_SLASH: "(
sword + (cANIM_NUMBER + 1) not in available_animations
sword + (cANIM_NUM + 1) not in available_animations
)",
cREQUEST_SWORD_ATTACK: "
if(cIN_CONTROLLABLE_ANIM,
if(cIN_END_ANIM and not cIS_LAST_SLASH,
vREQUEST_SWORD_ATTACK: "
if(cIN_CONTROLLABLE_ANIM,
if(not cIS_LAST_SLASH,
// This runs if we are continuing a sword combo.
// This if statement checks if there is a start anim available.
// If there isn't, just run the normal one.
if(sword + (cANIM_NUMBER + 1) + 'S' in available_animations,
animation(sword + (cANIM_NUMBER + 1) + 'S'),
animation(sword + (cANIM_NUMBER + 1))
),
// This runs if we are continuing a sword combo.
set(animation, NextAnimationInChain(sword, cANIM_NUM)),
// This runs if we aren't in the middle of a sword combo
[animation(sword + '1'),
add(major_attack_num, 1)]
// This runs if we aren't in the middle of a sword combo
[set(animation, NextAnimationInChain(sword, 0)),
add(major_attack_num, 1)]

) // end-if (cIN_END_ANIM...
)",
) // end-if (cIN_END_ANIM...
)
",
/******************
* VOID CONSTANTS *
Expand Down Expand Up @@ -203,9 +198,32 @@ properties: {
// Overloading (from hittable) because we want to flinch in air
HandleFlinch: "def(obj hittable collide_with) -> commands
execute(me,
if(final_damage_amount(collide_with, collide_with.cATTACK_DAMAGE) >= cFLINCH_THRESHOLD,
if(final_damage_amount(collide_with,
collide_with.cATTACK_DAMAGE) >= cFLINCH_THRESHOLD,
cause_flinch(collide_with))
)",
/******************************************************
* NextAnimationInChain
* Given the base name of an animation and the current
* animation number, this function will check if there
* is there is another animation in a chain, where the
* animations are formatted as <name><num><type>. If
* There is one that ends in 'S', this function will
* return that one. Otherwise, it will try without the
* 'S'. If all else fails, it will return fallbackAnim.
******************************************************/
NextAnimationInChain: "def(string animName, // Name of the animation
int animNum, // CURRENT anim number
string fallbackAnim = 'stand') -> string

if(animName + (animNum + 1) + 'S' in available_animations,
animName + (animNum + 1) + 'S', // Return
animName + (animNum + 1) in available_animations,
animName + (animNum + 1), // Return
fallbackAnim // Return
)
",
},
#ANIMATION HANDLES#
Expand Down Expand Up @@ -273,25 +291,31 @@ on_ctrl_tongue: "fire_event('ctrl_sword')",
on_ctrl_sword: "[
set(cycleOfLastSwordInput, cycle),
cREQUEST_SWORD_ATTACK
vREQUEST_SWORD_ATTACK
]",
on_end_sword_anim: "[
if(animation + 'E' in available_animations,
if(tVALID_SWORD_ATTACK_REQUEST,
cREQUEST_SWORD_ATTACK,
animation(animation + 'E')
) where tVALID_SWORD_ATTACK_REQUEST = not cIS_LAST_SLASH and tRECENT_SWORD_REQUEST
where tRECENT_SWORD_REQUEST = me.cycle - cycleOfLastSwordInput < cSOONEST_SWORD_REQUEST,
// If the player has given a recent enough attack input, continue the
// chain. The idea is that button mashing WILL let you slash slightly
// faster by skipping the first end animation frame.
if( not cIS_LAST_SLASH and tRECENT_SWORD_REQUEST,
set(animation, NextAnimationInChain(sword, cANIM_NUM)),

// else if
// Attempt to transition into an end animation.
animation + 'E' in available_animations,
animation(animation + 'E'),

// If we're in a start animation, attempt to switch into the slash that
// comes right afterward.
cANIM_TYPE = 'Start' and
(cANIM_NAME + FilterNull(cANIM_NUMBER)) in available_animations,
animation(cANIM_NAME + FilterNull(cANIM_NUMBER)),
(cANIM_NAME + FilterNull(cANIM_NUM)) in available_animations,
animation(cANIM_NAME + FilterNull(cANIM_NUM)),
// else
// If the player is done attacking, start standing.
animation('stand')
)
) where tRECENT_SWORD_REQUEST =
me.cycle - cycleOfLastSwordInput < cSOONEST_SWORD_REQUEST,
]",
// Bombs //
Expand Down

0 comments on commit 00c0f84

Please sign in to comment.