Damage not stacking

In my previous game, I noticed that same instances of an attack, when overlapping the player character, did not stack damage, but instead counted them all as a single attack. My guess is as long as they are constantly overlapping, it counts as the attack actor being on them the entire time and why damage isn't applied again until the character moves and is hit again.

What would be the most efficient way to get attack instances to stack damage? This is also why I was afraid to try out tables, thinking the same thing would happen, and a single column/row applying attack damage for many actors would only count all instances of the actor as the same thing. I hope tables are different and calculate damage from multiple instances separately.

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    You could base it on how long the overlap is happening.

    When overlap/collide
    --every 1 second
    ---change damage to damage + 1

    Besides that i think we will need a little more explanation of what your actually doing or trying to do.
  • FrantoFranto Member Posts: 779
    edited February 2014
    Some projectile attacks in the past build use timer based damage, with a particle affect that appears when ever damage is being applied.



    In effect here:


    However, damage still does not stack, and I would rather not use timer based damage unless its a fire type attack. Timer based damage is especially ineffective with fast moving lasers, even if you set it at apply damage every 0.01 seconds, sometimes the overlap is so fast that no damage is calculated.

    If 20 attacks are on the character, I would like the damage to be all of them combined. I did use a timer in the last builds just so that damage could be applied constantly, but I still want that stacked damage goodness of being foolish enough to get surrounded by 20 projectiles.

    Like right here at this point at 1:47, the player character is surrounded and being fired at with dozens of timer based energy ball attacks. If damage stacked, his HP should have depleted in seconds as a single energy ball's damage is low, instead, it depletes as if a single energy ball is only hitting him.



    Although I didn't mention timer based damage in opening post as the other game I'm working on is trying to stay away from timer based damage and I'm trying to get stacked damage instead. Hoping tables could pull it off somehow and now have a single unit in a table only apply to a single character, but allow for the calculation of various instances of said character separately.
  • FrantoFranto Member Posts: 779
    A boolean that constantly resets in an instant after every hit registers is what I could think of to get attacks to stack, but is there another way?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    One way to resolve this is to have the collision rule on the projectile actor:

    When actor collides with [player actor]
         Change attribute game.playerHealth to game.playerHealth - 1

    That way, even if 30 projectiles all hit the player at the exact same time, each one will run that rule because it will be true for each projectile rather than being triggered by the player actor when the first projectile hits it and then not able to immediately trigger again for each other projectile.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • FrantoFranto Member Posts: 779
    edited February 2014
    @Tatiang: Ah, thanks! I've been putting the damage attributes on the character themselves, I thought it be simpler that way.

    I think in a video tutorial I saw, there was a drawback to just putting the damage behavior on the projectile actors and not the character actors, but I can't remember what it was.

    EDIT: What about for enemies who's HP stat is a self attribute? I think this is what probably stopped me last time.

    EDIT2: This is where your health bar demo would have come in handy for reference of self attributes, but like I mentioned earlier in the thread, the tables are mysteriously gone and any change attributes have been replaced with a behavior having a message about tables.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Normally I would put the damage rule in the main character as well but in this case it makes sense to put it in the enemy actors. The only drawback -- other than having to make a rule in every type of actor -- is that you have to use a game attribute for the character's health. But that's a minor thing.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • FrantoFranto Member Posts: 779
    I see. And also, what is the concept behind the health bar demo? You mentioned it reads by syncing locations. Does the hp actor read self.attributes of the actor they overlap? If I can understand the concept behind something I can find a way to make it happen too. Thanks again for the help.

    Perhaps waiting until GS releases a way for actors to read the self.attributes of other actors or have some behavior that allows for damage to be calculated multiple times based on overlapping actors, etc.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You can use other actors' self attributes if you unlock one of the actors. But that won't work if you are spawning actors and it's also not the method I used in the health bar demo.

    What I did to sync them is to have the spawner actor change a game attribute (integer) to its own self.ID (that I've set manually or just before it spawns) right before it spawns its health bar. The health bar changes its own self.ID to whatever the game attribute value is. That way, the health bar and player/enemy have the same self.ID value. That value is used to look up table information. Each player/enemy and health bar stores and retrieves its data from the row number equal to self.ID. They are always synced. And if, as in my demo, the health bar needs to be positionally synced as well, I just have it look up the player/enemy x and y positions and constrain itself to an offset of them.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • FrantoFranto Member Posts: 779
    @Tatiang: Ah. I see. Thank you for explaining it to me. Using the same self.id on two actors to get the same data from the table.

    Now the part that confused me, was that the table in the demo only had 1 row and 3 columns, no labels. How many rows did you use in your actual table or what did the table you use look like? If what I'm thinking is true, then I would have to limit the enemies to whatever number of rows I choose. Say 25 or so, so I would then have to make that many rows for this to work. A nice solution, the only drawback being the number of enemies on screen are limited to the number of rows you have, but for this game, it won't really matter.

    Thanks again for the help.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    If you look at the rules in my template, you'll see that I create table rows as I spawn new actors. That's the reason the table is empty to begin with. It works the same for 4 actors as it does for 44 or 444. You could make a static table that doesn't grow but then you're limiting yourself to that many actors.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • FrantoFranto Member Posts: 779
    I see, and now I understand. I wasn't aware that was possible. I thought the rows/columns always stayed the same number. No tutorial I've seen mentioned it either, is this an another advantage of tables or its also possible to generate new game attributes during run time as well?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You cannot generate new attributes during runtime. So yes, tables offer this advantage.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • FrantoFranto Member Posts: 779
    Okay, now its a matter of getting use to using the change tables attribute and any other table related expression.

    Thanks again, @Tatiang.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    No tutorial I've seen mentioned it either

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • FrantoFranto Member Posts: 779
    I might have missed it when watching that vid. I learn better from reading than hearing. : < Which is why I like to read the forums. I have to watch a vid several times to get everything.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I might have missed it when watching that vid. I learn better from reading than hearing. : < Which is why I like to read the forums. I have to watch a vid several times to get everything.


    That's understandable. You don't really have to watch that video but it does explain how to use Change Table Value and Add/Remove Row behaviors.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • FrantoFranto Member Posts: 779
    @Tatiang What I meant to say is that I did watch this particular video a few days ago. But since I only watched it once, I didn't get everything on that first viewing. Right now I need written documentation that I can at least print it out and read it when I have 5 minutes of spare time. I don't own a device yet, so watching mobile videos is an impossibility right now.

    I was looking for written documentation of not only how to use tables, but putting tables into action and different examples of how to use them in order to understand what works and what doesn't.

    I still have had yet to implement what you described as I've been away most of the day for the past week. I will end up learning the intricacies of tables anyway once I've recreated your example today or tomorrow. Thank you again for the help.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    There are two pages of written documentation here on tables and writeable tables: http://cookbook.gamesalad.com/tutorials/2/parts/25

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • FrantoFranto Member Posts: 779
    edited February 2014
    @Tatiang Ah, thanks. This will help out.
Sign In or Register to comment.