Unconnected's Forum Posts

  • I actually came up with a solution.

    I would have to make a new instance variable for selected targets UID and two for target values.

    When a target enters the Line of Sight of the targeting object it will calculate what is needed and set the targets UID and current targets value to the instance variables.

    If there is another target it will Calculate that as well.

    If the new calculated target value is lower than the current one then it will be replaced and the UID will be replaced as well.

    If the targeting object looses the target or the the target is destroyed then the three variables will be reset.

    I'm still hoping for a more simple solution though...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • https://www.scirra.com/manual/124/system-conditions

    I looked at it and I still have the same issue.

    I am not knowing how to look for the lowest variable value from the family objects.

    Do this:

    Compare

    6,7,3,8

    Select 3.

    Not This

    Check for 1.

    6,7,3,8

    Check for 2.

    6,7,3,8

    Check for 3.

    6,7,3,8

    Select 3.

    To get the value I need, I have to divide two variables.

    The max hp the objects has/ the current amount of hp.

    200/100 is 0.5

    The results range from 0.0001 to 1000.

    I would like this to only have to calculate when an object is targeted.

    Having it calculate every X seconds causes a lot of useless calculations.

    I think the only way to do this without setting up to many variables is by using an Array.

    I can use the objects UID to track in an Array and do the math required as needed.

    This will only return one value at a time, but I can set that value to a single instance variable.

    This is better than creating X amount of variables in case X amount of objects are in Line of Sight.

    I am hoping there is a more simple solution then this.

    The question still remains, how do I select the lowest variable without checking every single possible value.

  • You do not have permission to view this post

  • I'm not sure how I didn't know about those.

    I will have to read up on those.

    I'm not fully ready to implement it just yet.

    If it doesn't work I will be back at a later time, but it seems like it would work.

    I didn't expect a reply so fast.

    Thank you.

  • I have a Family that has rules.

    The Family roams around freely and they select goals depending on instance variables.

    I am using Line of Sight and don't have much experience with it.

    If one NPC sees two or more enemies at once. (like a herd).

    How do I have it select the lower level or the weakest one?

    I know I would use conditions to compare variables, but I am not sure how to check the variable of the objects within the Line of Sight.

    Is there an option for that and I am just missing it?

  • Oh wow. That is helpful. I wouldn't have thought of adding a negative to an expression.

    -1 * -1 = 1

    and

    -1 * 1 = -1

    Using abs() or -abs() keeps things simple, and adds a small bit of insurance.

    I would use abs() or -abs() over *-1.

  • This post was still helpful even today. I was trying to figure out how to use UID to keep track of an object.

  • I meant I have a pattern of organized objects and each objects has two values to store.

    There will be more than one pattern...

    Pattern 1

    x1,y1

    x2,y2

    x3,y3

    x4,y4

    x5,y5

    Pattern 2

    x1,y1

    x2,y2

    x3,y3

    x4,y4

    x5,y5

    Each x and y would have it's own value.

    Thanks I will look into that.

  • No. Abs means Absolute Value. There is no opposite for that, that I am aware of.

    Multiplying by -1 seems good for that.

  • In order to turn negatives into positives you can use absolute value.

    abs(-20)

    or

    abs(20)

    will give 20.

  • Useful link.

    Knowing how Collision cells work is good.

  • I'm not 100% sure what you mean by compare X and compare Y?

    I think I would have to compare X and Y on all sides of the object that way.

  • Collision would probably be better for random uncontrollable cases. I suppose if the situation is specific then it would be better to use Distance.

    How would I use Line of Sight? That is only to see if an object can be 'seen'.

  • Games are variable based. If the engine doesn't have a system expression for it then you need to add variables.

    You can then change the variables with simple math using events. If you change a variable the events that have that variable will still work the same way.

    You would want to create a Global Variable called "ClickPoints" and have it set to 1.

    If you have a score then you want to create a Global Variable called "Score".

    If the goal of the game is to destroy objects by clicking, then when that object is destroyed you want to put in an event that will go something like this.

    When the object is destroyed

    Add "ClickPoints" to "Score"

    Every time an object is destroyed it will increase the "Score" variable by how much "ClickPoints" is set to.

    1 will add 1 to Score.

    2 will add 2 to Score.

    This allows you to give the player an upgrade by only changing a variable. It will only change if the conditions you gave it are met.

    You can change the value of "ClickPoints" by using events.

    Add 1 to "ClickPoints"

    or

    Set "ClickPoints" to 2

    You said an upgrade that gives points.

    You can do this with timer, but it will allow people to just wait for points.

    You can also do this by giving extra points every 5 objects destroyed.

    You would have to create a Global variable for that too. "ExtraPoints".

    You will want to create a Global variable that turns this on and off. "ExPointsEnable"

    When the player clicks to upgrade, then you can set "ExPointsEnable" to "On"

    (You can set Variables to Text. On/Off)

    If you want to use time to give extra points then:

    If "ExpointsEnable" is equal to "On"

    Then every X Seconds

    Add "ExtraPoints" to "Score"

    This will give the player extra points every X Seconds. If "ExPointsEnable" is not equal to "On" then it will not add points.

    if you want to give extra points for every 5 objects destroyed:

    You have to add another variable. "GiveExPoints"

    This keeps track of how many objects have been destroyed.

    If "ExpointsEnable" is equal to "On"

    If object is destroyed add 1 to "GiveExPoints"

    If "GiveExPoints" = 5

    Add "ExtraPoints" to "Score"

    Set "GiveExPoints" to 0

    This will give the player extra points every time 5 objects is destroyed.

    If you want you can make a Variable to replace the 5.

    This will allow you to change the 5 to any other number by just changing the value of that Variable.

    By doing this you can easily change how many objects the player has to destroy before getting extra points.

    Change the Variable to 6 or even 20. It will only give the player extra points when "GiveExPoints" equals 6 or 20.

    Everything you do is about manipulating variable values to make them do what you want. It usually involves simple math, but it can get complicated at times. If a variable doesn't meet a condition you made it won't trigger an event.

    If for some reason the player doesn't destroy 5 objects then the extra points won't be added to the score. If the value of "ExPointsEnable" never gets set to "On" then the player never gets the upgrade.

    Upgrades are usually just a variable change.

    The examples are in Pseudocode.. Meaning I simplified them.

    You would use the "System" option for most of them when adding events.

    From there you can pick these first as Conditions:

    Compare two values

    Compare variable

    Every X Seconds

    After pick a Condition you can add an Action:

    Add to

    Set Value

    Subtract From

    That should cover most of it.

  • The way it is structured is important. It should almost always be the top level event.

    It just seems like Distance would be easier for most cases and would be easier on the system.