Rable's Recent Forum Activity

  • Hi,

    I would like to know how I can exclude numbers from a "choose" expression based on what happens in my game. Here is what I want to achieve :

    I have 4 characters and I want an effect to apply to one of them at random. Very easily I wrote

    set Value to floor(random(4))

    Value = 0 --> apply to character 1

    Value = 1 --> apply to character 2

    etc...

    Now I would like to apply the effect only to characters who are alive. Here it gets more complicated. I really can't find a way to do this efficiently.

    I planned to use "choose" but then I need a way to exclude the values corresponding to a dead character...

    Any idea how I can achieve this?

    Thanks a lot!

  • Haha! Thanks anyway!

  • Indeed, and looking into this template I was able to figure out the problem : the event I used was "on key pressed", while it should have been "key is down". So it was logical that the jump sustain couldn't be taken into account.

    Thanks a lot for your help!

  • Hi,

    I'm working on a platformer, and would like to use simulate control "jump" with another key (object > simulate platform pressing jump)

    But I'm using the jump sustain property, and with the simulated control, only the small jump can be played, while using the up arrow I can make higher jumps.

    Any idea how I can make the jump sustain to work with simulated controls?

  • Hi,

    I tried to implement a more complete Save/Load system into my game, using the system actions "Save" and "Load". I was previously using Webstorage with good result, but as I am developping a much more complete desktop version, I would like to change the way the game saves.

    Up to now, I have very mitigated success with the Save/Load system actions. the game loads at the right place, but when I launch a level afterward, enemies are not attacking... for the complete game!

    This is a bug I never have when playing the game normally, so I wonder how this could happen and how I can resolve it.

    I checked this tutorial, which states that the only things that are not saved are :

    • Input state (i.e. mouse position, or whether the player was holding keys or touches)
    • AJAX requests
    • WebSocket connections
    • The XML object
    • User Media video or audio feeds
    • Facebook login
    • WebStorage state
    • CocoonJS/Windows 8 state
    • Any in-app purchases on any platform
    • Anything with the 'No Save' behavior

    But I don't think my problem could be related to any of these. I tried to save my game at different times, on 3 different layouts and it wasn't better. I thought it could be due to Save not getting the groups in the right state (activated/deactivated) so I copied my "group management" group (putting each group correct at the beginning of a layout) before loading the game, but it didn't change anything (thus I suppose each group state is loaded).

    I save and load on the same computer and same game version (I just play 2 minutes, then try to load)

    Could it be due to the fact that I was previewing the game inside Construct 2?

    Any idea of what I may do wrong?

  • Problem fixed! Indeed "Global" was set to yes. I've set it to No, and it fixed everything!

    Thanks a lot!

  • Hi everyone,

    I'm experiencing a very weird "bug" (though probably a mistake on my part) with an object. Here is the simplified situation :

    I have a layout1 and a layout2. and I have to pass from one to another. When doing so, one object does not disappear. Always the same object, and only this one.

    Concretely, this object appears on the layout 2, but is never created, spawned or something else on layout 1. Still, when switching from layout 2 to layout 1, the object stays there, at the same size and same position than it was on layout 2. I tried to create multiple instances of this object on layout 2 and they all appear on layout 1.

    Even more surprising, if I destroy this object at the start of layout 1 (which was my only solution), it is also destroyed on layout 2 !

    I already had the same problem with the same object when going from layout 0 to layout 1.

    EDIT : I foud a solution to my problem : I destroy Object 1 at the start of Layout 1, and destroy it also at the start of layout 2, then recreates a new object just afterwards. But this sounds like a workaround. Does someone have an explanation of what's happening?

  • nimos100

    It worked out! Thanks a lot, it really helps + I learned a lot!

    Instance variable in families is definitely something I will use in the future.

  • nimos100

    Thanks for the reply!

    [quote:32bvka2k]If you just need to select a random enemy on the your combat screen you can use "Pick random instance" from the system tab, and then you of course just choose the family as being the object.

    Yes it could work, but there is one subtility : there are (up to) 3 enemies on the front line, and up to 3 enemies in the back line. So I'm selecting a number between 0 an 2 and the ally attacks the line of enemies corresponding to this number. If the enemy on the first row of this line is already dead, the ally attacks the back line enemy of this same row instead. Now if I'm selecting an instance at random, the allies won't attack enemies on the back line before every enemies on the front line are dead, and that's a problem.

    I probably misexplained myself, as I never need to select an enemy type at random. This will be based on the current level. However what I need to do is to select one given instance of an enemy type, based upon a predefined instance variable which is equal to 0, 1 or 2 (the "number" variable, which defines the row number, so that the ally could attack the back line enemy sharing this number with the front line enemy, if the front line enemy is dead).

    So it can't be an instance at random, I'm afraid.

  • I'm already facing a problem actually. I need to select one of the enemies at random, so after selecting the enemy family just as you stated, how could I do that?

    In my code I made

    pick enemy where enemy.number=randomValue (targetArcher in my code)

    so that I select only one instance at random

    but as now it could be any sort of enemy (as I'm just selecting a family's UID), I don't see how to do that...

    The idea would be to pick fam_enemies where fam_enemies.UID = Param(0) and then check the "number" instance variable of each instances of the selected object type to select the correct instance. Is it possible to do this, given it could be any enemy type?

    I think that if there is a solution to this, it should work perfectly!

    Thanks again!

  • nimos100

    Hi and thanks a lot for your help.

    I really believe your solution should work in my game, and I'm ready to pass a few hours or days optimizing this part of the code, I'm sure it will be worth it + mastering it is time well spent.

    If I understand correctly, the code you are describing couldn't work without using families, right?

    Thanks again! I'll try your solution today!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi,

    I'd like to update some of my game's code so that it could be more efficient and easy to deal with.

    Here is the result I want :

    In Healer Quest, each level is the same layout and same event sheet, but sees you fighting different enemies. I would like all the 4 player's characters to automatically attack enemies at random based on the current level (selecting a valid target).

    There are enemies on the first line and enemies on the second line, and of course they should attack enemies on the front line first (refer to my signature for a visual clue, even though there is only first line enemies in the picture).

    Here is how I did it :

    For each playable character, I made a huge list of all levels (more than 100) and the code looks like this :

    (...)

    Level = 32 (you are fighting rats (1st line enemies) and bats (second line enemies))

    Rat is visible

    Pick random rat instance and deal damage to it

    Else Bat is visible

    Pick random Bat instance and deal damage to it

    Level = 33 (you are fighting thieves (1st line enemies) and knifeThrowers (second line enemies))

    thief is visible

    Pick random thief instance and deal damage to it

    Else knifeThrower is visible

    Pick random knifeThrower instance and deal damage to it

    (...)

    What I would like to change :

    Right now, if I want to change something in the way damage is dealt to monsters, I need to update more than 800 events! And I will need to update this code many times in the following months... So I'm looking for a solution to avoid this.

    I hoped I would be able to do this with functions, but if I'm correct, it appears that functions doesn't allow to define a certain object to which the function should be applied.

    Is there any simpler way to deal with that part of the code?

    Thanks in advance for any ideas!

Rable's avatar

Rable

Member since 6 Aug, 2014

None one is following Rable yet!

Connect with Rable

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

15/44
How to earn trophies