How do I have a minion do a task?

0 favourites
  • 11 posts
  • Trying to get a minion to chop down a tree. Clicking on the tree marks it to be chopped down. The tree has 50 hp. The loop crashes the browser no matter what conditions I put in. No idea what I'm doing wrong.

    www -dot- cazualnoob -dot- com/web-games/ (second game file)

  • You can't use a while loop - that is what is causing the crash. Just flag that "arrived" occurred, and move the 1-second code to the top event level, and check if the "arrived" flag is true.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Wow, thanks. I was over-complicating that a lot.

    So, can characters effect and/or be affected by a background tilemap? Like slow down characters going through mud? Or would I need to make sprites for that?

  • So, can characters effect and/or be affected by a background tilemap? Like slow down characters going through mud? Or would I need to make sprites for that?

    You should be able to using:

    [quote:283teqi9]Tilemap conditions

    Compare tile at

    Compare the tile ID at a position in the tilemap.

    https://www.scirra.com/manual/172/tilemap

    Although, that could add in a lot of checks every tick

  • www -dot- cazualnoob -dot- com/web-games/ (second game file)

    well... my little minion will only chop 3 or 4 trees then I can't make him do anymore - no idea why.

  • www -dot- cazualnoob -dot- com/web-games/ (second game file)

    well... my little minion will only chop 3 or 4 trees then I can't make him do anymore - no idea why.

    Long story short, I'm pretty sure it is the "trigger only once" on the chop=1 condition. So if you click two trees they will both have chop=1 and once one tree is chopped the event won't fire again.

    And just to note, this isn't me complaining but for your benefit on getting help in the future—your project is pretty messy. A lot of disabled events and events that do nothing. It is asking a lot to post your whole capx and ask for people to read through it all. Try putting events in groups, using comments, and using the bookmark on the events you want people to trouble shoot. Just saying it took a while for me to even find the part to trouble shoot and I almost said screw it. (but I didn't )

  • > www -dot- cazualnoob -dot- com/web-games/ (second game file)

    >

    > well... my little minion will only chop 3 or 4 trees then I can't make him do anymore - no idea why.

    >

    Long story short, I'm pretty sure it is the "trigger only once" on the chop=1 condition. So if you click two trees they will both have chop=1 and once one tree is chopped the event won't fire again.

    And just to note, this isn't me complaining but for your benefit on getting help in the future—your project is pretty messy. A lot of disabled events and events that do nothing. It is asking a lot to post your whole capx and ask for people to read through it all. Try putting events in groups, using comments, and using the bookmark on the events you want people to trouble shoot. Just saying it took a while for me to even find the part to trouble shoot and I almost said screw it. (but I didn't )

    Yea, it's a mess. I'm saving some code for later which is why it's disabled. I didn't think it would be a problem finding the section I was working on, but I'll figure out the bookmarking feature and use it from now on.

    Still have no idea what I'm doing, but I'm sure I'm going to have to change all those sprites into tilemaps and figure out a way to limit the ones marked. Then figure out a way to, like you said, take out the trigger once to make him find the closest marked tree, chop it down, then find the next marked closest tree.

    It's gunna take me a lot of time to figure it out.

  • I marked 2 groups "Tree" and "Chop".

    First problem I can't figure out is why when you click a tree the second time it doesn't unmark it for chopping down. ... well now it doesn't change the tile to the tree with the x on it anymore...

    Second problem is I can't get him to chop down the tree that he's next to.

    I don't really want to limit how many he can cut down. I just want him to go to the closest one and stay there until it's down then find the next closest one that is marked.

    I uploaded the capx file to my server - same spot if anyone wants to check it out.

  • ...I just want him to go to the closest one and stay there until it's down then find the next closest one that is marked...

    That would have been good to know when giving advice on your previous comments. I figured you still wanted it to be point and click so gave advice on that.

    Either way, I would make the minion into a state-machine. Something like idle->find->move->arrived->chopped->idle. You would have an instance variable for "state".

    So:

    if state=idle then set state to find and find path to closest tree

    on path found set state to move and move along path.

    on arrived set state to chopping and set timer

    on timer destroy tree, add to wood variable, and set state to idle

    (thus, since idle again would find closest tree and start the cycle over again)

    So with those events I left out arrived but depends on circumstances of what you need. Shouldn't really be too hard if you understand state-machines and can get that cycle down

  • Thanks for your advice, it worked like a charm. I'm starting to get a lot better idea of how construct 2 flows. If you want to see it in action, I uploaded the capx.

    In the sake of the forum and future searchers:

  • Nice! Glad you picked up on it and it works, good job!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)