How do I get an average value or a sum total value of every picked object's local variable?

0 favourites
  • 3 posts
From the Asset Store
"Easy Local Notifications" enhances games with customizable local notifications.
  • Example :

    Multiple enemies are damaging a wall and they have different damage values as fast as the project is selecting more than one enemy , the damage values are absolutely not what they should be.

    is there an expression for that or any workaround?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Just to make sure its clear what my problem is :

    Lets just say there are 3 enemies , enemy1,enemy2,enemy3.

    enemy1 does 4 units of damage to the wall per second , enemy2 does 1/sec , enemy3 does 2/sec

    now if I use my closest to working method of just using overlap detection with a few pixel of outer boundary added to said enemies , with PickedCount * Enemy.DMG , then the game is just gonna multiply the first attacking enemies damage with how much enemies are currently attacking , so if all three enemies are damaging the wall this would result in 12 dmg/sec , while what I need is 4+1+2 = 7dmg/sec

  • I think the only option is to loop through all instances with "For each":

    local variable averageDamage=0
    local variable sumDamage=0
    
    Enemy isAttacking=true
    	For each Enemy : add Enemy.dmg to sumDamage
    
     Set averageDamage to (sumDamage/Enemy.pickedCount)
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)