Griggsby's Forum Posts

  • You do not have permission to view this post

  • Loopindex+1 instead of loopindex

    Thanks it worked

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So instead of starting at 0 the index would start at 1.

    Tagged:

  • When you find the target you should then apply effects in the same action, you can use one tidy function that applies status X from attacker X to target X, you can send both through the function as parameters. Sending UID through ensures you are picking the right target and it shows up in logging, it's good for minimizing bugs and gives you some control within the loops.

    Absolute legend man. It worked thanks for the help. Hopefully when my game is ever finished and you try it out I can send you some nice in game rewards. Thanks again.

  • Is this because you are using a for each for the attack and then a for each for the status effect underneath? I guess it wouldn't find the instance if it was destroyed before the second event, but you could have them as one event. Status effect can be a function, you can pass the UID of the player through it so you know it is being applied to correct instance and if it was destroyed then function wouldn't do anything.

    Oh wait youre right I have been using a for each to determine who to attack and another for each to determine the same target for the status affect. The reason for putting them seperate is due to the sheer number of different status affects and attack targets and all the monster there will be in the game.

  • Is this because you are using a for each for the attack and then a for each for the status effect underneath? I guess it wouldn't find the instance if it was destroyed before the second event, but you could have them as one event. Status effect can be a function, you can pass the UID of the player through it so you know it is being applied to correct instance and if it was destroyed then function wouldn't do anything.

    for each is just to find out who has the smallest health. Status affect is a function. The status affect function is where all this occurs. I havent tried UID yet. I'll try that and get back to you.

  • Ok I think I understand the problem you're describing but the point of the for each is to run through each instance to check which ones match the conditions and you can pick them, saying they must be 0 and 1 doesn't make a ton of sense. What are you trying to achieve with the loop or what data are you unable to gather?

    So what im trying to do is have the enemy monsters target the player monsters to inflict a status affect.

    Enemies target whoever has the least amount of health and is alive. Sometimes these status affects activate at the same time the enemy monster attacks. If the attack so happens to kill the player monster at the same time, the status affect that was meant meant for the inital target moves to the next player with the least health.

    what im trying to do is even though the initial target dies, the status affect should NOT jump next in line and should instead disappear with the player monster that just died.

  • If I'm understanding it correctly you need descending from high to low?

    what im trying to do is have the monster with the least amount of health to have the smallest loop index number. If i did your way then the monster with the most amount of health left would have the smallest loop index number.

  • So I have a family consisting of 10 monsters with the Variables "IsTargetnumber" and "currenthealth". The Event goes "For each monster ordered by monster.currenthealth ascending"(so from low to high) perform action Stop Loop and set "IsTargetnumber" to loop index. The condition I have is:

    "monster.currenthealth must be greater than 0" (currently on 2 monsters have more than 0 health)

    The problem is regardless of my condition, the monsters with 0 health are still part of the loop index which becomes ( 0-9 because there are 10 monsters in total). But instead I a want a loop index of ( 0 and 1 because i want only 2 monsters included, the 2 monsters whos health are greater than 0)

  • First off, my condolences for your 13,000 events and resolve to attempt this feat. If you were familiar with the math, you might have realized that there are 3,628,800 possible combinations of 10 positions. So you're lucky in that you seem to have hit a limitation so early...

    To determine turn order for 10 objects, the simplest way would be to use instance variables. If you had an instance variable for speed, and an instance variable for turn order, you could use the system "For Each (ordered)" to sort them by speed, and then assign each one a number from 0 to 9.

    > + System: For each Sprite order by Sprite.speed descending
    -> Sprite: Set turnorder to LoopIndex
    

    What you would do now that they can be identified by their turn order is up to you. For example, you could keep track of the current turn in a separate global variable, and only allow the sprite with turnorder that matches the current turn to act.

    Tried this out and i finally got it to work thanks for the help man.

  • > i dont understand how loops work. I also dont understand what u meant by set turn order to loopindex.

    You absolutely need to study loops, arrays, dictionaries, functions, families and other basic concepts in C3 before starting a big project like this. It may take you a couple of days or event weeks, but will save you months of fruitless efforts in the future!

    In this case you can determine turn order even without loops. I assume you have 10 different sprites for players? You have to add them all into a family and define all instance variables on the family. You'll need "Speed" and "HasMoved" instance variables. On start of each turn pick players that haven't moved yet, and then pick the player with the highest speed among them.

    > PlayersFamily HasMoved=0
    PlayersFamily Pick with highest Speed 
    

    That's it! You saved yourself 12999 events!

    so Im currently trying this method and the condition isnt working as intended past turn 1. so the first time i run it it does work. the fastest player (in this case P1) gets their turn then i assign a variable indicating they got a turn. I run the event again this time with a condition to not include whoever had the first turn but the event still includes P1 because their spd is still the fastest. What am i missing here?

  • Sorry im just a little slow. I kinda understand now. I'll test it out and get back to you thanks for the help.

  • The problem with that is how do I make something that picks the fastest speed for me?

  • Now Im just not sure how the events would work. So would i do a "for each" for every character? For example (object:player1, expression:player1.speed, order:by descending) then the same for players 2-10? Then set their turn order instance variable to loopindex?

  • I thought of this before but couldnt get it to work because i dont understand how loops work. I also dont understand what u meant by set turn order to loopindex. But everything else you mentioned like the speed and turn order variables I do understand.