R0J0hound's Recent Forum Activity

  • Is it the same thing?

    That example was after me plating an Onet game just long enough to infer some rules. Best I could tell matches consisted of adjacent tiles or tiles connected with a path with at most two bends. There are probably simpler and more understandable ways to do it.

    I know the common way to make games now a days is to find a tutorial or find/buy a template. But usually you can get pretty far just by making a list of the rules of a game and figuring out how to do each of those.

  • Are you using the latest version of C3 on windows? I’ve had c3p files fail to load in older versions of c3 if they were saved in newer versions. It helpfully points out that the file was saved in a newer version or just gives that error. Even reloading c3 sometimes fixes it.

  • There’s nothing in that file.

    All a ray cast does is check for collision between two points. Quick test works fine.

  • Are you specifying what objects are an obstacle for the Los behavior?

  • Where is the imagepoint? If the origin is one one side and the imagepoint is on the other then casting from self.x, self.y to self.imagepointx(1), self.imagepointy(1) should do it.

    Or if you really want to use sin/cos you could do self.x, self.y to self.x+cos(self.angle), self.y+sin(self.angle)

    I’m only commenting on the math. Other than that the logic seems fine at a glance.

  • Add another condition to the event: green overlaps enemy?

  • Does it rely on a library being loaded first or is that the script entirely?

    Scripts in construct run in “strict mode” which is more restrictive with what you can do in js. Presumably without strict mode assigning a value to an undefined identifier will just create a new variable, but I haven’t tested.

    construct.net/en/make-games/manuals/construct-3/scripting/using-scripting/javascript-construct

    Some random thoughts at least. I don’t mind js but haven’t used it much within construct because it adds an extra layer of complexity sometimes.

  • If you just want to pick the closest enemy then:

    Enemy: pick closest to (player.x, player.y)

    Or if you want to pick all the enemies within a certain distance of the player:

    System: pick by comparison: enemy: distance(enemy.x,enemy.y,player.x,player.y)<100

    I personally wouldn’t want to touch any code that ai generates. Mainly because debugging is hard and time consuming. I find it easier to try to understand what I code as I go so I’m able to fix things as I go. I have no way of verifying how correct, robust or bug free a piece of ai code is without dissecting it which sounds like an annoying waste of time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I haven’t used the LOS behavior too much so I’m not able to reason about how to use it off the top of my head.

    You can do it without line of sight. Basically set the box to full width and if it overlaps a wall make it shorter till it isn’t. Here’s a rough example of that.

    Every tick
    — box: set position to player
    — box: set angle to player.angle+180
    — box: set width to 200
    
    While
    Box overlaps wall
    — box: set width to self.width-10
    
    Every tick
    — camera: set position to player
    — camera: set angle to player.angle
    — camera: move forwards -box.width pixels

    Only fail case you may or may not have to deal with is if the player is in the wall then it could cause an infinite loop. Quick fix is to use a repeat instead of a while so it would at least not freeze.

    It’s rough since it changes width 10px at a time. You can make the step shorter but that will increase the loop length. A more efficient method would be to start with big steps and refine it with smaller steps.

    Ideally if you used raycasting you could cast a ray and get the xy where it hits. Then if the distance from that point to the player is less than the default camera distance then use that instead.

    I would like to note that I purely do this for fun. I'm not a professional and have no obligation spend time to help on this forum.

    So to summarize, you have 8 global variables and you'd like to display them sorted high to low, and when you display it you want it to show the variable name with the score.

    To sort you need to get the list of values into some kind of array. That could be comma separated text, an array object or just just use multiple instances of a sprite. In the end they are all arrays just represented in different ways. I guess the main tricky part is sorting the values and knowing what variables the values came from. Anyways here are three different approaches, some of which were already covered, in one way or another, by the other helpful users on this site.

    Method 1. Text based array

    The first is to use a text variable to represent the array. list="01234567". This is the most compact way I could think of. 0 for the first global, 1 for the second and so on. Next to sort we'd have to implement our own sorting algorithm. Simplest and most compact would be bubble sort. Basically it compares two global variables from two adjacent indexes from the list and swaps the indices if needed.

    With this approach the expression chooseindex(index, p1,p2,p3...) is our friend to reduce the amount of events needed to access different globals with less events. Since it's text based the swap operation looks a bit ugly. Well in general all the expressions look busy with this approach.

    The main con with this is having to modify it if you change the number of globals you're sorting.

    dropbox.com/scl/fi/dn5oe5gwq0f9ltblvkazd/sortGlobals.c3p

    --- Three events long with an additional variable.

    Method 2: using the array object

    The second idea is to just populate an array with the global variables and sort that.

    We can recall the variable names by setting the array size to (8,2,1) and setting array.at(i,0) to the value, and (i,1) to the name or index. The sort only looks at values at y=0 and the other y's get swapped along. Anyway, it's easy enough and straightforward to use if you're not trying to avoid the array object at all costs. Most people with previous programming experience like this way.

    One con is the array sort action only sorts low to high. It's not the end of the world though. One fix is to just loop over the array in reverse like in the example, or setting the array with negative values before sorting, and negating them again when displaying.

    dropbox.com/scl/fi/4dz5bwz9ct7ex4anabvo0/sortArray.c3p

    --- Four events long with the array object

    Method 3: Using instances as an array

    With this you create a sprite type, and create enough instances for all the values. Then in events you populate the instance variables from the globals and use for each ordered to display it.

    This is where Construct really shines. It is simpler and looks much cleaner than the other two ideas. You just have to have the instances created beforehand to avoid picking pitfalls.

    dropbox.com/scl/fi/0t4vk3me4xkum6p41lz7l/sortInstanceVariables.c3p

    ---Two events long with an object type and enough instances

  • Not it would only add health when enemy health changes. Guess you probably would want a check to make sure the old health is higher otherwise the difference would be negative.

    Other than that, no, there are no such conditions other than saving the old health and checking if it’s different than the current health.

  • I mean you could first store the calculated damage in a variable and then subtract it from the health.

    By 40 do you mean you have the events you’ve shown duplicated 40 times with individual tweaks for different attacks?

    That just means there will be busywork for any change you go with. Personally I’d try to utilize a function to use less duplicated code.

    I guess a two event hack would be to add a variable to the monsters for their old health and do something like this:

    Every tick

    — monsters: set oldHealth to self.health

    … all existing events …

    For each monster

    — player: add 0.05*(monster.health-monster.old health) to health

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 155 followers

Connect with R0J0hound