Swing sword animation with button/ABS with eventing

I'm working on a game that when the player hit a button, either a key or the mouse, their sword is swung to hit an enemy. The sword would be it's own sprite that would connect to the player but I don't want it to be active all the time, just when they swing it to hit an enemy on the map. Think Legend of Zelda type games.

I'd want the sword to deal damage when it touches the enemy, so the plugin would have to work with events like that etc.

EDIT: I've decided to go the eventing route as usual. I'd love some tips on how to do this. I know I'd need to make use of variables etc. If anyone has made a system like this before out of events I'd love to hear from you.
This sounds like a simple form of what's sometimes called an "ABS" (Action Battle System). ABS plugins tend to be quite complex and have a bit of a learning curve (i.e. "you've been warned" xP). I haven't tried any myself, but I understand there's a few out there, e.g. QABS: https://forums.rpgmakerweb.com/index.php?threads/qplugins-latest-qabs.73023/ 🙂

Alternatively you could try to rig something using events, with or without the help of plugins (e.g. Yanfly's Button Common Events and Self Variables). I imagine it would be doable but challenging. 😅
@caethyril Thanks! Do you know which ABS plugin is the easiest? I really only want it for the simple stuff.

Or if you have tips on eventing this that would be even better. I usually prefer eventing to plugins anyway since I don't script.
Do you know which ABS plugin is the easiest
there are no easy ABS at all - even the simplest ABS will require some knowledge and configuration from you.

And there aren't that many ABS at all - because each ABS takes the programmer years to write.

You can only go through the plugin forum on this board searching for anything with ABS in its title and hope that it was completed (several are unsupported ruins due to the programmer leaving the community) and is something you can understand.
You can only go through the plugin forum on this board searching for anything with ABS in its title and hope that it was completed (several are unsupported ruins due to the programmer leaving the community) and is something you can understand.

Sounds like I'll be trying my hardest to try to event it then. I've been searching the forum and most people have either found some ABS plugins and had issues with them working with other plugins or the posts are so old the ABSs aren't even out yet. Thanks for the clarification.

If anyone has some eventing knowledge related to ABS systems that would be more helpful then.
eventing knowledge related to ABS
eventing an ABS is possible - the biggest restriction on an evented ABS would only be the fact that special attacks or magic is almost impossible to event, but simple attacks are relativly easy.
the enemies would be set to move on the player and on event touch do something like harming him
the player would have a chance to attack first - the way with the button could either be done with a plugin or with a parallel process

and then you'll use control variable commands and get location info to see if there is an event in attack range and direction to the player and if yes modify that event.

You'll need scripts to manipulate an events self-switches, or you would be limited to a very low number of enemies per map if you want to control them by preselected general switches.

You might also want to think about a plugin that gives you the ability to copy, clone and control events.
@Andar Thanks this is really helpful! I didn't even think about the get location info. This leads me in the right direction to start.
Use Screencoordinates for Hit detection of player sword, dont use Map coordinates.
Because if enemy moves fast, the mapcoordinate will change before the event starts moving to the next tile.
that can cause a swordslash visibly to hit enemy, but the mechanic isnt counting it as one. this creates frustrating moments.
Screencoordinates solve this fully.

This isnt very good and just the Basics, but maybe it helps. To create a Hitbox.
Sadly i have no working Demo at the moment, only all the code scattered around.
Thanks to Caethyril for Help with the Hit Box.
Spoiler: Early ABS Swordslash
Common Event 1:
Is button W pressed? If yes activate Switch for Common Event 2.

Common Event 2:
Code:
◆Control Variables:#0004 Sword Damage = Random 1..150 //Random Damage
◆Control Variables:#0001 Sword Slash X = 0
◆Control Variables:#0002 Sword Slash Y = 0
◆If:Player is facing Down
  ◆Show Animation:Player, <3> Slash Down
  ◆Control Variables:#0002 Sword Slash Y = 48
  ◆
:End
◆If:Player is facing Left
  ◆Show Animation:Player, <3> Slash Left
  ◆Control Variables:#0001 Sword Slash X = -48
  ◆
:End
◆If:Player is facing Right
  ◆Show Animation:Player, <3> Slash Right
  ◆Control Variables:#0001 Sword Slash X = 48
  ◆
:End
◆If:Player is facing Up
  ◆Show Animation:Player, <3> Slash Up
  ◆Control Variables:#0002 Sword Slash Y = -48
  ◆
:End
◆Script:var hitDist = 0;  // just for readability
:      :for (var a = 3; a <= 100; a++) { // Events 3 to 100 can be Hit by Sword
:      :  if (!!$gameMap.event(a)) {   // check that event exists
:      :    hitDist = Math.hypot($gameMap.event(a).screenX() - ($gamePlayer.screenX() + $gameVariables.value(1))   ,   
:      :                         $gameMap.event(a).screenY() - ($gamePlayer.screenY() + $gameVariables.value(2)) );
:      :    if (hitDist <= 30) {  // in range?
:      :
:      :        $gameSelfSwitches.setValue([$gameMap.mapId(), a, 'A'], true) //Hit Event got self switch A on when hit, so you can do some magic or prevent it from attacking
:      :        this.setSelfVariableValue($gameMap.mapId(), a, 46,this.getSelfVariableValue($gameMap.mapId(), a, 46) + $gameVariables.value(4)) // boom damage dealt, include a Death Eventpage with var46 as pagecondition and the Max HP until dead, self var plugin is awesome for this.
:      :      } } }
◆Loop
  ◆If:Button [Pagedown] is pressed down // You pressed the slash, now release it to end the event in case you kept holding that button
    ◆Wait:1 frame
    ◆
  :Else
    ◆Break Loop
    ◆
  :End
  ◆
:Repeat Above
◆Wait:2 frames
◆Control Switches:#0002 CE_Sword_Slash = OFF

I included Yanflys Self Variables Script. I made Game Variable 46 pointer to Event Self Variable. Self HP = Var46.

Original thread: https://forums.rpgmakerweb.com/threads/swing-sword-animation-with-button-abs-with-eventing.109459/