Great idea for a trigger action for regions

Give us your feedback about the Level Editor! Or have an idea? Post it here!

Great idea for a trigger action for regions

Postby The Acrobat AHK » 24 October 2020, 05:44

I am producing a singleplayer map where the objective is to shoot enemies that appear randomly on the map. I managed to get the triggers to move a movable to a specific region and put an enemy on top of it, but I can't find an action that would make this region move randomly across the map.

I believe that it is possible to use the variables so that something like this happens, but it would be a lot of work, I realize that it would be very useful if only this function existed, since it is possible to move characters in random places within a region, why not move regions randomly within regions?

Possible name for the action mentioned above:
Move region 'A' to a random position within region 'B'.

:roll: :thank:

The Acrobat AHK
 
Posts: 2
Joined: 17 February 2015, 15:47

Re: Great idea for a trigger action for regions

Postby jeje52 » 24 October 2020, 07:46

Here's the variable solution

region x = random(0 - map width) + left border x
region y = random(0 - map height) + top border y

Spoiler: Show More
Set value of variable 'A' to random integer number in range 0..B-1 //B is map width
Add value 'B' to value of variable 'A' //B is left border x
Set X position of 'A' region left-top corner point to value of variable 'B' //B is whatever variable you had in the previous 2 actions
Set value of variable 'A' to random integer number in range 0..B-1 //B is map height
Add value 'B' to value of variable 'A' //B is top border y
Set Y position of 'A' region left-top corner point to value of variable 'B' //B is whatever variable you had in the previous 2 actions
User avatar
jeje52
Civil Security Lite [100]
 
Posts: 142
Joined: 13 April 2018, 19:52

Re: Great idea for a trigger action for regions

Postby The Acrobat AHK » 24 October 2020, 15:20

Thank you very much for the reply, it was complete and quick. It will be a little bit of work, but it's worth it. It was a long time ago that I had the idea of making this map but at the time there were no variables, I see that I was lucky to get a solution, thank you so much, now I feel that I can complete this project :)

The Acrobat AHK
 
Posts: 2
Joined: 17 February 2015, 15:47

Re: Great idea for a trigger action for regions

Postby That one that » 25 October 2020, 02:30

While I was trying to understand your instructions, I got a little confused in some parts:

How do I set the interval? Should I put in every position he can take?

For example, if I want to define the X positions of the variable 'A' in a space of 30 squares wide, taking into account that each pixel equals + 10X, I must add "0, 300-10" or "0, 10, 30 ... 300 "?

Another question is about the value 'B', this value is the result of the variable 'A'. Should I create another variable that takes the value of the variable "A '?

I realized that the initial position of the region influences the range, correct me if I am mistaken, if the region is at a point x = 60 and I want it to move 1 pixel at a time between 30 squares, then its 0 point starts from 60 and goes up to 360, right? And in the interval it would be like {60, 70, 80 ... 360}. Forgive me for typing so much. (- .- ")>

That one that
 
Posts: 2
Joined: 24 October 2020, 04:20

Re: Great idea for a trigger action for regions

Postby jeje52 » 25 October 2020, 19:48

That one that wrote:How do I set the interval? Should I put in every position he can take?

For example, if I want to define the X positions of the variable 'A' in a space of 30 squares wide, taking into account that each pixel equals + 10X, I must add "0, 300-10" or "0, 10, 30 ... 300 "?

Wouldn't 30 squares be 3000 units? In that case, you would put 3000 in 'B'. If you want it to move per pixel instead of unit, put 300 in 'B' and multiply it by 10, though it wouldn't make any noticeable difference.

That one that wrote:Another question is about the value 'B', this value is the result of the variable 'A'. Should I create another variable that takes the value of the variable "A '?

You can use the same variable for everything.

That one that wrote:I realized that the initial position of the region influences the range, correct me if I am mistaken, if the region is at a point x = 60 and I want it to move 1 pixel at a time between 30 squares, then its 0 point starts from 60 and goes up to 360, right? And in the interval it would be like {60, 70, 80 ... 360}.

Where the region is originally doesn't matter. You could have it anywhere and it would still go to a random location within the bounds you've set (map left border x, map width, map top border y, map height).
User avatar
jeje52
Civil Security Lite [100]
 
Posts: 142
Joined: 13 April 2018, 19:52

Re: Great idea for a trigger action for regions

Postby That one that » 26 October 2020, 05:35

I refer to the pixel as the smallest square visible in the map customization grid, and the square, those that are formed by 10x10 pixels.

If I wanted to define a region to move randomly within a 30x30 pixel square, following its instructions:

1) create a trigger and choose the action "Set the value of variable 'A' to a random integer in the range 0..B-1"

In Parameter A, I must put the name of the variable.
Now in parameter B, how should I put the information in it?

0 <= Variable A <= 30?
or
0.30?

As for the second instruction, it says that I have to assign this random value to my variable, in which case I must use the action "Add the value 'B' to the value of the variable 'A' " next:

Parameter A (Variable): Variable A
Parameter B (Value to be Assigned): Variable A

Is this right?

In summary, my doubts are:

1) How is the information written in parameter B to define the range of values ​​that the variable will assume?

2) How do I add the value that the previous trigger action achieved for variable A? Should I use the action of adding value B to variable A and placing Variable A in both parameters?

I'm sorry for the confusion back there, I hope I was clear this time :s

That one that
 
Posts: 2
Joined: 24 October 2020, 04:20

Re: Great idea for a trigger action for regions

Postby jeje52 » 26 October 2020, 15:11

Spoiler: Show More
That one that wrote:I refer to the pixel as the smallest square visible in the map customization grid, and the square, those that are formed by 10x10 pixels.

If I wanted to define a region to move randomly within a 30x30 pixel square, following its instructions:

1) create a trigger and choose the action "Set the value of variable 'A' to a random integer in the range 0..B-1"

In Parameter A, I must put the name of the variable.
Now in parameter B, how should I put the information in it?

0 <= Variable A <= 30?
or
0.30?

As for the second instruction, it says that I have to assign this random value to my variable, in which case I must use the action "Add the value 'B' to the value of the variable 'A' " next:

Parameter A (Variable): Variable A
Parameter B (Value to be Assigned): Variable A

Is this right?

In summary, my doubts are:

1) How is the information written in parameter B to define the range of values ​​that the variable will assume?

2) How do I add the value that the previous trigger action achieved for variable A? Should I use the action of adding value B to variable A and placing Variable A in both parameters?

I'm sorry for the confusion back there, I hope I was clear this time :s

So let's say you have a map that is 30 squares wide, and the x coordinate of the left side of the map is 200, it would go like this:

Set value of variable 'A' to random integer number in range 0..B-1
Parameter A: SomeVariableName
Parameter B: 3000

Add value 'B' to value of variable 'A'
Parameter A: SomeVariableName
Parameter B: 200

In action 1, parameter B has to be a single integer number. As 30 squares is 300 pixels and that is 3000 "units", we would use 3000 in the parameter. The reason it has to be in "units" is so that the region will be moved to the correct location, as the game doesn't think in squares or pixels. Basically, unit=1, pixel=10, square=100. The region can of course go into decimal places, such as x=0.5, but the trigger action by itself doesn't do decimal numbers.

in action 2, we are simply adding a number to the variable value which we got from the previous action. Adding the map's left border x coordinate to the random value is necessary because without it, the region would be moved to a random point between 0-3000, instead or the 200-3200 we would want in this example. 0-3000 may end up being outside the map.

Hope that clears it up at least to some extent.
User avatar
jeje52
Civil Security Lite [100]
 
Posts: 142
Joined: 13 April 2018, 19:52


Return to Level Editor

Who is online

Users browsing this forum: No registered users



cron