Problemas at spawinig objects from a IA [Boss battle]

0 favourites
  • 2 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • Hi guys!

    It's my second time asking your help (I have to warn you, my english is Tarzan-like)

    Well, my problem is in a boss battle that I'm doing. In some parte of the battle, I need that the boss spawns a determined number of shots (BossFinalWeapon in the capx - image), for example, when boss is in state 3 (Estado 3 in the images), it should spawn ONLY 3 shots, then wait 1 sec and then spawn another 2 shots (and so on, in total are 15 shots, as you can see in the image). The problem is. sometimes the instructions works just fine, but in others, the boss spawns like 6 or more shots at same time, making a mess. I tried everything, using variables controlling the number of shots, using cooldown, etc... As this is a random issue (the possibilities this happening are like 60/40) I don't find the proper way to solve it, beacuse it's completely random. I don't know how to control it and neither know what is causing it. I attach the image with the events in construct 2.

    The image

    Thanks in advance, cheers!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I would think about re-organizing your code according to Object Oriented principles... chiefly modularity.

    i.e.

    Make a function that spawns a boss bullet a specific number of times. You can randomly generate the angle and image spawn point within certain bounds (it looks like your angle in bounded 230-310 deg). Then you can simply call that function and input a specific number of times that you want the boss to fire.

    In this function, use trigger once and a for loop with an input parameter for the loop number, something like:

    local variable randomImagePoint = -1;
    local variable randomAngle = -1;
    
    Function bossSuperAttack (Number_Of_Shots)
      trigger once
      for loopindex: 0 :: Number_Of_Shots
         randomImagePoint = round(random(6));
         randomAngle = round(random(81)) + 230;
         Spawn BossFinalWeapon on Layer 4 (image point randomImagePoint);
         Set angle to randomAngle;
         Wait 1 sec;
    [/code:297gb12x]
    
    Then when you want the boss to fire four shots (on a certain condition) you simply call bossSuperAttack(4).
    
    If you don't want the attack to come from different points each firing, simply move the random assignment up one level to the function, rather than inside the loop (like the above shows).
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)