Laurent's Recent Forum Activity

  • Hi R0J0hound

    Thank you so much for this.

    Going through your code is the best way to learn a lot of Construct subtilities.

    Everything looks as I wanted to. I'll have to adapt the attack part to my gameplay with attacking occuring as soon as Player and Enemy are in the same hex. Then two things can happen : 1) player is killed -> game over 2) Enemy is killed -> enemy destroyed and game goes on.

    I thing I'll try a simple collision test between Player sprite and Enemy's to trigger Attack routine function and not trigger Attack when Occupied =2 (that I'll keep to allow player and enemy to be both in a same hex). And btw, it's more Battle function than Attack function, since it doesn't matter who attack who, Battle function acts the same when two adversaries are in contact.

    I'll let you what I come up with.

    Thank you again !

  • Yes, I was thinking moving one at the time could also be great for the game atmosphere. So, when an enemy moves, Player hexagon have to be considered as non occupied/obstacles so it could be entered and then trigger the Attack routine (this routine in my game would be a complete module with choice for weapon). When attack is resolved, 1) Player is killed, game ends, 2) Enemy is defeated, game goes back to next enemy moves and Attack routine may occur again if it enters Players' hex.

    To let Player enter Enemy hex, Enemies' hex have to be considered non occupied/obstacles. When Players enters, Attack routine is triggered as above and if Player wins, he is allowed to move using his remaining points to move and why not attack another enemy if in range.

    And I want to thank you again for your attention ;)

  • Thank you R0J0hound, that's amazing.

    The game logic is perfect and a lot for me to learn from.

    I managed to create an attack routine but it appears that when Player or a given Enemy attacks, other Enemies continue to act simultaneously. Is there a way to pause their action while attack routine is processed ?

    You wrote that :

    * pathfinder was updated so it can step onto occupied tiles, but won't go past it. Had to temporarily disable the occupied var of the starting tile to do it.

    Do you mean that pathfinding considers occupied tiles but don't allow player or enemy to step in ? Actually, that's precisely the gameplay I was looking for because my planned attack routine was to take place when player and enemy are in the same hexagon. Hexagon state occupation in the game could be : empty, occupied with player, occupied with one enemy, occupied by player and one enemy (in this last case, other enemies wait for their turn outside the player hexagon for the attack to end and can only enter if the enemy inside is defeated).

    There is also something I noticed :

    - When I add a 5th Enemy on the board, when it enters player's avaible hexs, this enemy's hex don't have any number. It has no consequences but it's odd.

  • Hi R0J0hound

    Incredible !

    Looks exactly how I was trying to achieve.

    Stuff I have to adapt :

    - Allow enemy to enter player hexagon so that they can fight

    - Allow Player to enter Enemy hexagon, for the same reason

    - Allow Player to move only X hexagons (maxmove)

    - Make enemies move only when Player has used all its maxmove or if End Turn button is clicked.

    I went through your code and came out with this

    https://www.dropbox.com/s/wkzy10rnl7gj6jo/MoveHexChangeFromRojo.c3p?dl=0

    I added :

    - Player can move 5 hex maximum (variable can be adjusted)

    - Player and Enemies move with Move to for smoother translation.

    - I also managed to turn your debug routine to display reachable hexagons.

    - Player moves only when click on hexagon within reaching distance

    Problems so far

    - Reaching distance sometimes fails to work properly when enemies are closed to the player. Some hexagons appear reachable as they are actually not. One of the enemies instance, the last instance (instance #3 when 4 enemies), makes the hexagon it's on funny : this hex has not O written on it as the others (see screencap) and I guess that is the reason why reachable hexagon map around it gets wrong.

    Things I wasn't able to add :

    - I didn't manage to allow player to enter enemy hex and enemies to enter player's hex.

    - also, when the player only moves a number of hex below its max, enemues start to move. Before enemies move, I wanted to let the player move few hex then few more util it's moving points are exhausted but didn't succeed.

    If you have any idea on how to fix this, I'd be grateful.

  • dop2000

    That's it ! With a slight detail added :

    "And only when the first instance reached the target position, then the next instance should : "

    - first be able to regenerate its pathfinding obstacle map since all solids instances are now steady

    - start moving along found path,

  • Could it be possible to use an iteration ? Not a loop but something like :

    1 - Trigger sprite instances movement routine - instances are solid.

    2 - set X=0

    3 - pick instance X and set other instances to Solid

    4 - regenerate pathfinding obstacle for instance X and find path

    5 - move along path

    6 - on pathfinding arrive set X=X+1, set all instances to Not Solid and go back to 3

    7 - when x=count instance, end routine

  • Thanks dop2000 !

    I was wondering, will this solution based on time and wait will work with Pathfinding that need time to process (calculate path/move along path). Won't it jump to the next instance before Pathfinding processes ?

    My point is to make instances move one after the other so they each calculate their path according to other instances solid location so they don't ovelap.

    I guess what I would need is trigger next instance action (here Pathfinding) once the previous instance finished its move and has sent its new position so that next instance path path could embed the said position to its obstacle map.

  • Hello RedJesterStudios

    I'm working on a similar system in which multiple instance move one after the other and I'm interested by your approach but don't understand it very much.

    Would you post a file or a screen cast to make it clearer ?

    Thank you!

  • I have N (number changes runtime according to spawning/destroy instance) instances of the same sprites in my game and I would like to make them act one after the other and not simultneously.

    What is best ? For each or for 1 to N loop ?

    Is loop the best solution ?

  • Hi R0J0hound

    That's a very interesting approach. It's far from my needs though.

    I took another look at my problem and I think I found out a direction to dig : I forgot that when obstacles move, pathfinding need to refresh the obstacle map. I made some tests and it looks encouraging.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think there is something I miss with my code.

    Each enemy is made out of two sprites combined in a container :

    - the enemy sprite itself

    - an associated EnemyPath sprite that holds the pathfinding behaviour.

    They both have the same UID number.

    The EnemyPath move along found path, and when it overlaps a hexagon, the Enemy sprite is put on the hexagon position.

    What I think I miss is that in my routine, for each Enemy Sprite with a given UID, the EnemyPath sprite with the matching UID has to be used.

    And I guess that this is where the mess is.

    Anyone to have a look ?

  • That sounds promising !

    Would it still have the turn based style and have the possibility to include for each instance a max number of moves by turn ? Both are important for my game

Laurent's avatar

Laurent

Early Adopter

Member since 18 Jan, 2012

Twitter
Laurent has 1 followers

Trophy Case

  • 12-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

17/44
How to earn trophies