Juryiel's Forum Posts

  • That's a neat idea though about clicking, I didn't think about it. I'll give it a try if I can't get the RTS behavior to behave correctly. Haven't worked on it in a while since I was stumped and have been working on a different part of the game.

  • I'm using the RTS behavior's "Move To Object" where the Object is the picked player.

  • So I'm trying to design a movement system using RTS behavior. The enemies are not very good at navigating around objects. What I mean is, if they are chasing the player, and the player is moving close to irregularly shaped walls, they will get stuck. I solved this problem by disabling collisions for the enemies and setting them to avoid wall objects. What this does is that although they will avoid walls, if they do get too close to an irregularly shaped wall edge, they will go through it. I know I'm not explaining this right but it works well and looks fine.

    Problem is, if I disable collisions I can't click on them :( Is there some way for me to accomplish that?

    Alternatively, is there a way to prevent enemies from getting stuck on irregularly shaped solid objects with collisions enabled? I tried messing around with the box size to no avail. Some way to maybe get them to slightly push off a solid object on collision?

    I also tried to use the On collision with "Solid" and Is overlapping "Solid" and then use a Push out, since the walls are solid but that didn't work. The conditions never triggered even when the enemies were stuck, though I'm not sure why. The 'walls' are one gigantic sprite that covers the entire level, and the 'open' areas that enemies and players can walk on are transparencies in that sprite, if that has something to do with it.

    Thanks!

    EDIT: Just to clarify, it's not that the space for the enemies is tight. It's wide open. The only reason they get stuck is because I have them chase me around, and I drag them across protrusions on the irregularly shaped walls.

  • Hmm the map function is giving me an IndexError :(

    EDIT: Nevermind, forgot to make the array global

  • Ok, I'll just transfer the {"NPCHatelist",str(SOL.Enemy1spawn.UID)} contents to a standard Array I suppose, then run the code on the array.

    Thanks guys :)

  • Here's my second attempt (actually using S and not arrays), but it fails on a syntax error on the first line. I guess I'm not using S correctly in python:

    AggroSortArrayPy = map(lambda k:S.n{"NPCHatelist",str(SOL.Enemy1spawn.UID,k), range(S.sule({"NPCHatelist",str(SOL.Enemy1spawn.UID)})))
    
    AggroOrderPy=sorted(range(len(AggroSortArrayPy)), key=lambda k: AggroSortArrayPy[k])

    EDIT: Updated it to use map function instead of loop. Still don't know how to properly access my S stuctures in python, let me know if someone does while I try to figure it out :)

  • On a related note, can I access Construct arrays in python in a standard way or do I have to assign their values to a python array?

    E.g. if I have an array SortArray in construct, can I do this:

    sorted(range(len(SortArray)), key=lambda k: SortArray[k])

    to get the indices of the sort, or will this fail? (For one, COnstruct arrays are 1 based and python are 0 based etc).

  • Does that work? I think I'm misunderstanding the algorithm. It seemed to me that it is based on having the array into which you insert a value already sorted.

    E.g. if I have these values 4 8 9 3 5

    If I have an empty array A into which these will be placed, then when I loop through, A = 4, and sorted since only 4 is there. Then on the next loop, A = [4 8] and sorted. THen when I try to put in 9, again, it's going into a sorted array A = [4 8 9] and so on and so on.

    With your suggestion, every value goes into a jumbled array, on the first iteration, A = [-1 8 9 3 5] = [8 9 3 5] and I'm trying ot put 4 into this unsorted array. This is why I'm confused. I can't tell whether the algorithm will work the same in both situations. My thought is that I need to have another Array B, and then do something like loop through all values of A, and sort them over in B (then copy B to A).

    Since you're busy and the python algorithm is good (I looked it up it compares favorably to most others) I think I'll go ahead and use that since it's really easy to use. Thanks for showing me how and figuring out what sort it is :)

  • Yeah I read the comments, and even though I sort of get the theory, I guess I was just (still am) confused as to how I would use this in a static array, I'll try to for a bit more to figure it out, and then I'll probably resort to python :) Thanks!

  • I cannot for the life of me figure out that example haha. I'm not sure which of those events I actually need. Seems some are resizing arrays, and I'm not sure if that's part of the sort. And I'm not quite sure what the 'ScoreCard' is doing. The array being sorted is pPoints right? Seems to me this searches for a spot to insert the value rather than sorting a bunch of values, right? But what if I have a pre-existing array with values already in it that I need to sort? Do I need to create another array and pull values from the first array to the second array one by one in order to sort?

    If this isn't too much to ask, do you think you can maybe show me an example of this that just accepts an existing array and sorts it? Is it possible to make it general so that you can somehow pass the array to a sorting function, and have it sorted, or is this not possible? E.g. if you put all the arrays in a family, then call the function on that family and pick the array by name.

    Maybe events is not the right approach for this. Is this something that can be done simply in python so I can copy-paste it? :P

  • Thanks for the reply!

    I'll take a look at Verve when I get home from work. If your algorithm is faster I'll try to implement it as a general function, since I may later need it to sort something else of larger size. Best to futureproof stuff I implement as much as possible :) Just out of curiosity, what is a time-stable algorithm?

  • So I need to implement a method to sort an array. The array itself is pretty small (only 6 values) but I need to sort many of these per frame, up to possibly 50 or more per frame. A couple of quesitons:

    1. Is this a situation where the type of sort would make a difference?

    2. Are there any examples of good sorting algorithms implemented with events floating around? I'd appreciate one, as I find coding with Events very unintuitive when it comes to this sort of stuff, unless it's the most basic of algorithms.

  • As an update for anyone else who might be facing the same issue, it does indeed appear to be a bug with how the Overlapping at Offset event picks the second object to compare (it seems to pick all of them).

    R0J0hound provided a fix, where the System Condition "Is overlapping (advanced)" is used. To "rig" the 'offset' part (since that condition doesn't support offsets), the NonPlayer is first moved to each comparison point, then the overlapping comparison is made using the "Is overlapping (advanced)" system condition, and then the NonPlayer is moved back to his position, simulating the "Overlapping at Offset". Since this is all done in the same frame, the moving of the NonPlayer is never drawn on screen.

    Thanks for the help!

  • Could you do something simple like have the enemy always have a movement component toward the center of the platform and then a separate movement component perpendicular to that? The math might be a bit unintuitive if you want to get consistent movement speed along the edge of the platform, but should be simple enough. I think there's Actions in the Custom Movement behavior that will allow you to turn an enemy to face toward an object all the time, etc.

    Alternatively, maybe you can use the platformer behavior to set gravity direction be toward the center of the platform, which is the same as above but might save you some time doing calculations.

    I can try to put it together later today when I get home, since it seems like a fun problem to solve.

    Also, check out this plugin, maybe it can do what you want:

    scirra.com/forum/path-movement-behavior_topic39306.html

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The class ID seems correct. I didn't do your example, but I in my cap I set the class ID in the properties box and not using the events. Furthermore, I have a variety of functions that use ClassID and they all work correctly, picking the right players and reporting the correct ClassIDs. It sounds to me that you're saying that the bug is a result of setting ClassID at runtime, which I'm not doing. If that's incorrect let me know and I can try your example.

    I will be PMing you a cap shortly. You want to look at the SystemFunctions event sheet, specifically the groups "General Enemy Functions" and "Line of Sight Functions". You will also see a cone of all the spots checked for LOS at runtime. It only comes up randomly every second at a random NonPlayer. You can move individual players by selecting them with a mouse and clicking (RTS behavior). If you use the arrow keys they both move.

    If you move a player into the LOS cone and an LOS check occurs, the enemy should start chasing the player. This might not work correctly since I haven't tested the other parts of the code that deal with enemy actions, so using it for debugging might not be reliable, so that's why I have the DebugText to use instead.