How best do I store information for different kinds of attack animations?

0 favourites
  • 6 posts
From the Asset Store
This music pack covers differents situations for visual novels, anime games and many more!
  • So bear with me here, this is more a question of a best practices, and it's also going to get into the weeds a bit. I'll outline the issue, then outline the options I know of, along with their pro's and con's. Please read the whole post if you have a suggestion.

    I'm making an action RPG. Prototyping is going really well! Because the sprites are very simple 2D pixel art, attack animations utilize paper-dolling techniques where I overlay a weapon sprite animation on top of or underneath the player. This function extends to all humanoid enemies as well. Because I want the player to be able to play as and/or recruit any of the creatures they come across, player objects and enemy objects are functionally the same. This is also helpful for/required for other gameplay elements. Players and enemies are all grouped under the same Family I'll refer to from here as "Character Family".

    So far this has worked really great! Originally I was pinning the weapon sprite to the Character Family sprite, and then storing the information for the attacks (range, frames where collision detection is necessary to register hits, knockback values, etc) inside those weapon sprites.

    Then I hit my snag: This only works for Character Family sprites that use weapons. I have plans for other Character Family sprites (creatures for instance) to not use weapons, and instead call attack animations from their sprite sheet. I can't store all the information for those attacks in an object that they won't have pinned to them.

    Here are the options I have come up with so far:

    1. Store all the instance variables for the weapons inside the Character Family instead, and update them when appropriate. This is going to heavily bloat my Character Family instance variables, so I'd like to avoid it. Right now human players only have 2 attack animations per weapon, but enemies without weapons could potentially have more, which adds up quickly considering how many values each attack needs to store.
    2. Create "dummy" weapon objects for creatures. The brute force method for doing this would be to create invisible dummy weapons for each creature, but I could easily modify this to instead point to one weapon per enemy attack. It's inelegant but it does keep things relatively well organized.
    3. Store attack information in an array. This is the obvious one, but it too has some setbacks I can't get around. Specifically, I am trying to automate as much of this work as possible, and as such having been using families and functions a LOT. But if I want to attach an array to an objects container, I can't do so within a family, so I can't reference it easily (unless I can and I just don't know how).

    Any help here would be appreciated, and I'll try to explain everything else around this better if needed.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm working on a project that have a very similar system. If I understood it right you just want to have one family with the "body" objects (enemies and players) and a family for "weapon" objetcs. Since it looks like you already know what you're doing I don't have a lot to comment than that I'm working in a pretty similar way.

    * I have a family with all the "body" variable. (hp, mp, stats in general + other variables to aux;

    * I have a family with the "weapon" objects. They have variables like the damage they'll cause, knockback, etc... Weapon object have animations exactly like body object in frame and animation quantity and names;

    * Than every body instance is overlayed with an weapon object for each kinda of weapon I have in game and synced with respective body animation;

    * Than I have this spritesheet with data that says when certain weapon animation and frame are active to detect colision

    And that's pretty much it. That last event sheet makes it really easy to add new weapons in game, so I don't have to hard code every new weapon in game. Also having no weapon works exactly like having a weapon, except the weapon animation for "no weapon" is empty :p

  • That is very similar to the setup I am looking at relixes. In your case, what do you plan to do for enemies that have no weapon associated with them? This is of course assuming you plan on adding enemies like that.

  • In fact I do not have enemies carry weapons. I actually don't use the weapon system and ended up just using the "no_weapon" weapon for the player :p

    BUT it was coded with enemies having weapons in mind. So in the body family I have a variable caled "body_team".

    So I have enemies and heroes being on diferent teams so each one can only aply damage to the oposite team. Is that what you're looking for?

    -- edit

    jwilkins

    I guess I miss read what you said. You want enemies with no weapons to have diferent atack animations when having no weapon?

    In that case the anemies with no weapons would just have diferent animations but would use the same weapon overlay for the no_weapon kind of weapon.

    If you want diferent enemies to have diferent atack types and colisions I would just equip the enemy with a "diferent kind of no weapon". You could add weapons like: no_weapon_punch, no_weapon_punch2, no_weapon_kick, etc...

    With every "no_weapon" kinda of weapon with diferent colisions and animations... Yeah, I guess that's pretty much it, thats how I would do things. Have you ever player little figther? They have a system that is pretty similar to the one we're talking about. I recommend you to check it out, it's a pretty cool game/system.

  • Hmm, I think I see what you are doing. I hadn't thought to use the dictionary object, that thing is much easier to organize than arrays, maybe that is the best way to go about this. Thanks for the food for thought!

  • jwilkins

    I like the blank weapon idea - I don't think it is inelegant at all.

    I also use arrays a lot. While it is true you can't make a family into a container to have an array object automatically created and picked, you can manually do it.

    create an instance variable on the family called WeaponArrayUID. Then whenever a character is created, create a WeaponArray object as well and save the UID with the character.

    then you have to make sure you pick the array by UID when you are dealing with a character, but you will have as much storage as you need.

    you would also have to manually destroy the array when you kill the character, but you probably have to do that to anything pinned to the character anyway...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)