I want to make it so when the dice roll on a specific number, if you have a building built next to a certain "Tile" it will add the amount of building you built next to it, to a variable. so this is the code i'm using:
Quote:
Global Variable(s):
Resource radius = 9.8
Ore 0
Events
Dialog - Any Dialog Item is used by Player Any Player with event type Clicked
Local Variables
Tile Point = Point 012- <Point>
internal number = 0 <Integer>
Conditions
Actions
Trigger - Wait for Rolling to execute, and Wait until it completes
General - If (Conditions) then do (Actions) else do (Actions)
If
(Used dialog item) == Rolling Button
Build Tiles[internal number] == 1
Numbers Overlay Int[internal number] == (Dice 1 + Dice 2)
Then
Variable - Modify Ore[0]: + (Number of Living units in (Settlement units in (Region(Tile Point, Resource radius)) owned by player 1 matching (No Value), with at most Any Amount))
Variable - Modify Ore[0]: + ((Number of Living units in (city units in (Region(Tile Point, Resource radius)) owned by player 1 matching (No Value), with at most Any Amount)) * 2)
Variable - Modify Ore[1]: + (Number of Living units in (Settlement units in (Region(Tile Point, Resource radius)) owned by player 2 matching (No Value), with at most Any Amount))
Variable - Modify Ore[1]: + ((Number of Living units in (city units in (Region(Tile Point, Resource radius)) owned by player 2 matching (No Value), with at most Any Amount)) * 2)
Variable - Modify Ore[2]: + (Number of Living units in (Settlement units in (Region(Tile Point, Resource radius)) owned by player 3 matching (No Value), with at most Any Amount))
Variable - Modify Ore[2]: + ((Number of Living units in (city units in (Region(Tile Point, Resource radius)) owned by player 3 matching (No Value), with at most Any Amount)) * 2)
Variable - Modify Ore[3]: + (Number of Living units in (Settlement units in (Region(Tile Point, Resource radius)) owned by player 4 matching (No Value), with at most Any Amount))
Variable - Modify Ore[3]: + ((Number of Living units in (city units in (Region(Tile Point, Resource radius)) owned by player 4 matching (No Value), with at most Any Amount)) * 2)
Else
so far, i have like 66 triggers, just like this and am going to make 44 more. Each trigger is for a specific tile, and each tile spot needs 5 or 6 triggers for each or the random tiles that i generate at each point. so everytime i roll i have over a hundered triggers trying to calculate, just FYI incase that is why it's so funky.
but my problem is that when i change the radius of the region it creates from 9 to 10, at 9 it won't sense that theres a unit present in the radius, but if it's 10, it will shoot across the map to try and pick a unit, so a tile acroos the map from where my city is will give me some ore.
I hope this was clear enough. I didn't know how i should put the trigger into the forum, or how i could ask why it was happening.
I ended up just taking a screenshot and posting it with this, because the preview wasn't letting the format show up. so here. Can anybody help? or also think of a better way to do what i want it to do?
Ok, I didn't understand exactly what you try to achieve.
But just reading that you already have 33 triggers and plan to create 44 more whilst they do almost the same thing makes me want to stop you! :D
Could you please explain carefully what you try to do. Explain it in a context and what it should look like ingame for the players. Sometimes its better to remake something complelty but having it put together in a single trigger (or only few ones).
Just imagine what would happen if you want to change/add something ? You would need to do this damn often!
Same as Rushhour... I can't figure what you're trying to do. So much triggers is a no-go, you should seriously find another way to do it. You can't edit that much triggers and expect it to work fluently.
So far, from what I've seen on the screenshot, it looks like you're trying to count how much cities and settlements a player is controlling, and increase his income depending on how much cities/settlements are within the ressources radius... Am I right?
If you would like help with this I could help you write one trigger that handles all of this.
but my problem is that when i change the radius of the region it creates from 9 to 10, at 9 it won't sense that theres a unit present in the radius, but if it's 10, it will shoot across the map to try and pick a unit, so a tile acroos the map from where my city is will give me some ore.
that makes no sense really at all.
are you using tiled regions or what? be more descriptive.
Rollback Post to RevisionRollBack
Skype
KageNinpo = SN
My Libraries
DialogLeaderboard & TeamSort
My Projects
SPACEWAR Tribute
Infinite TD
Same as Rushhour... I can't figure what you're trying to do. So much triggers is a no-go, you should seriously find another way to do it. You can't edit that much triggers and expect it to work fluently.
So far, from what I've seen on the screenshot, it looks like you're trying to count how much cities and settlements a player is controlling, and increase his income depending on how much cities/settlements are within the ressources radius... Am I right?
I tried making all these triggers in one trigger, but always got caugt up in how it was going to work. because each tile spot has so many variables that if it goes this way then do this. and so on. I atatched a couple picks of what is going on in my map.
In the first pic, the red points are where the random Tiles spawn, and where the random numbers above the tiles spawn. The green Points are where i spawn a circle so that i can tell the settlements to only build on those units. and i have the city units only build on the settlement units.
In the second pick, The roll button randomly generates a number (actualy 2 numbers, each from 1 to 6, to simulate 2 dice rolling corectly) that number gets displayed in a dialog (blue circle). after that i want each tile with the number that was just rolled above it (numbers above tiles are text tags, but i put them into a variable with an aray of 22, for each tile) to give its resources to the player that built next to it. and if you build more next to the tile, you will get more.
The Destructable rocks are placeholders for the Sheep and Wheat tiles. I'm not done Making those tiles yet.
So, if any of you ever played Settlers of Catan. I'm trying to remake that board game.
If you would like help with this I could help you write one trigger that handles all of this. but my problem is that when i change the radius of the region it creates from 9 to 10, at 9 it won't sense that theres a unit present in the radius, but if it's 10, it will shoot across the map to try and pick a unit, so a tile acroos the map from where my city is will give me some ore.
that makes no sense really at all.
are you using tiled regions or what? be more descriptive.
I would love help. I got stumped and now nothing is working. but what was happening is ether no tiles would give me any resources, or basically all of them would, and woudn't just stay with the units i built next to them.
Ok, I didn't understand exactly what you try to achieve.
But just reading that you already have 33 triggers and plan to create 44 more whilst they do almost the same thing makes me want to stop you! :D
Could you please explain carefully what you try to do. Explain it in a context and what it should look like ingame for the players. Sometimes its better to remake something complelty but having it put together in a single trigger (or only few ones).
Just imagine what would happen if you want to change/add something ? You would need to do this damn often!
LoL, i figured this out the hard way. Thats why i tried to make one of the numbers in each trigger a variable. but i still had to go through them all to change it to the variable, just that once, so i could change the one variable and it would change all of them. needless to say, It sucked.
@canichols2: Yep, it can be very frustrating copy pasting values or whatever over and over. That's why I wrote everything in custom script in WC3. And that's why I love global constants, arrays and actions in the new editor :D
Ok, to your map. It is very hard for someone not familiar with your map to understand at one single view how you set up things, so to really help you, we would need to view your map or give us more details and screenshot of your triggers. For example: What changes from Ore0 to Ore1 ?
I could think of a setup like the following:
Tile numbers are saved in an integer array (one index for one tile)
So you would know only need to loop through all indexes of this array to check if the tile's number is equal to the rolled number.
A problem follows: You don't know where the tile is. Solution idea:
Save the position (either the point or the coordinates) in an array variable. You would need to do this at map initialization.
TilePoint[4] would now have saved the point for tile 4. To get the number (texttag text) of this tile you would need to use TileNumber[4].
So you would now basically loop through all tiles with a ForLoop and using the variable "loopTile" (remember to save max amount of tiles to not run out of array bounds).
Inside the loop you would check if the TileNumber[loopTile] is equal to the rolled number.
If it is true, then you would need to do your searches around TilePoint[loopTile]. If this search finds valid units/buildings of a player nearby it would add resources. (I am not sure how and how many you add though)
Edit: In case you didn't understand what I was trying to explain: In game it would result in the following:
An 8 is rolled. Now each players gets resources (somehow) who built next to a tile with the number 8.
That's it. All you would then need to do would be one big initialization trigger which sets up the points. And of course you would need to save and update TileNumber[x] like you probably already do now.
That sounds like how I was trying to do it. only I don't understand how to use or how a loop works. what i was trying to do was pick each int. from 0 to 21 and do actions. then when i came to a place i needed one of the 22 diferent tiles, i could say Tile[picked int] but then i didn't understand how to use that to get wether or not the the tile at that point is an Ore tile or if it's number is 8 or not. or any combonation of that. so maybe if you could explain how to use the loop thing, it would work better.
Thanks for the pictures... I'm having a guess here but I think there is something reaaaaaaaaaally easy you can do. I guess your hexagonal tiles are either units or (at least) actors. And same goes for the spheres on each corner. There is a function "Unit Group - Closest unit to Point" which allows you to... well... pick the closest unit to a point (O RLY?).
If you manage to pick the custom tile this way (which, obviously, is the closest "unit" to the red point it is on), you might also be able to retrieve the 6 points around your tile using a similar method. Then, a simple check with "If Then Else" can add ressources to each owner of a city/settlement on these 6 points. The main issue is that I haven't found yet how it can work if your tile is not a unit. There doesn't seem to be any way to "Convert Actor to Unit", which would be ideal. Basically, if this method work you should be able to do it in, let's say... one trigger. Neat huh? :D
@canichols2: Oh you should really try to get used to loops and arrays, they make a lot stuff so much easier. Play around with a ForEachInteger loop. It basically does the same like "PickEachInteger". Each has a disadvantage: PickEachInteger can't be nested (that means you can't have a "PickEachInteger" inside a "PickEachInteger" loop); ForEachInteger creates big amounts of code if nested since it implements to actions twice,...!
But for the start, just get used to it.
Create an integer array named "TileNumber" of size 10.
In an initialization trigger do:
ForEachInteger( loopInt, from: 0 to 10, increment 1) do:
Variable: Set TileNumber[loopInt]=loopInt
UI: DisplayText (convert integer to text( loopInt)
So you set the tile number to 1,2,3,4,5,... and also display these numbers. The loop just takes the variable "loopInt" and after one iterration it increases it by "increment". So the first time the functions are called it would work like:
Set TileNumber[0]=0
Ui DisplayText -> 0
(next loop)
Set TileNumber[1]=1
Ui DisplayText -> 1
...
I love loops now. that made it so i could take my hunred or so triggers down to a triger that only took like 1 action, after some if then stuff. That was AMAZING!!!!
I Love You, in a way that's not gay. but i LOVE YOU. I can't believe that worked. That is what i hated about pick each integer is that you could only use one per trigger/whatever. that was soo cool.
Hrmmmm. how come if i don't hit the enter key twice, my THANK YOU!!!!!'s turn out like this
It's nice to hear I could help! And nice to see your THANK YOU :D
Additonally I can show you how to create your own "ForEachInteger" loop which doesn't include all actions twice (like the loop that blizzard gave us does). This is (only) important if you nest loops and have a lot of actions/functions/whatever inside them. But I will first be able to show you in several hours when I'm back from work ;P
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I want to make it so when the dice roll on a specific number, if you have a building built next to a certain "Tile" it will add the amount of building you built next to it, to a variable. so this is the code i'm using:
so far, i have like 66 triggers, just like this and am going to make 44 more. Each trigger is for a specific tile, and each tile spot needs 5 or 6 triggers for each or the random tiles that i generate at each point. so everytime i roll i have over a hundered triggers trying to calculate, just FYI incase that is why it's so funky.
but my problem is that when i change the radius of the region it creates from 9 to 10, at 9 it won't sense that theres a unit present in the radius, but if it's 10, it will shoot across the map to try and pick a unit, so a tile acroos the map from where my city is will give me some ore.
I hope this was clear enough. I didn't know how i should put the trigger into the forum, or how i could ask why it was happening.
I ended up just taking a screenshot and posting it with this, because the preview wasn't letting the format show up. so here. Can anybody help? or also think of a better way to do what i want it to do?
Ok, I didn't understand exactly what you try to achieve.
But just reading that you already have 33 triggers and plan to create 44 more whilst they do almost the same thing makes me want to stop you! :D
Could you please explain carefully what you try to do. Explain it in a context and what it should look like ingame for the players. Sometimes its better to remake something complelty but having it put together in a single trigger (or only few ones).
Just imagine what would happen if you want to change/add something ? You would need to do this damn often!
Same as Rushhour... I can't figure what you're trying to do. So much triggers is a no-go, you should seriously find another way to do it. You can't edit that much triggers and expect it to work fluently.
So far, from what I've seen on the screenshot, it looks like you're trying to count how much cities and settlements a player is controlling, and increase his income depending on how much cities/settlements are within the ressources radius... Am I right?
If you would like help with this I could help you write one trigger that handles all of this.
but my problem is that when i change the radius of the region it creates from 9 to 10, at 9 it won't sense that theres a unit present in the radius, but if it's 10, it will shoot across the map to try and pick a unit, so a tile acroos the map from where my city is will give me some ore.
that makes no sense really at all.
are you using tiled regions or what? be more descriptive.
I tried making all these triggers in one trigger, but always got caugt up in how it was going to work. because each tile spot has so many variables that if it goes this way then do this. and so on. I atatched a couple picks of what is going on in my map.
In the first pic, the red points are where the random Tiles spawn, and where the random numbers above the tiles spawn. The green Points are where i spawn a circle so that i can tell the settlements to only build on those units. and i have the city units only build on the settlement units.
In the second pick, The roll button randomly generates a number (actualy 2 numbers, each from 1 to 6, to simulate 2 dice rolling corectly) that number gets displayed in a dialog (blue circle). after that i want each tile with the number that was just rolled above it (numbers above tiles are text tags, but i put them into a variable with an aray of 22, for each tile) to give its resources to the player that built next to it. and if you build more next to the tile, you will get more.
The Destructable rocks are placeholders for the Sheep and Wheat tiles. I'm not done Making those tiles yet.
So, if any of you ever played Settlers of Catan. I'm trying to remake that board game.
I would love help. I got stumped and now nothing is working. but what was happening is ether no tiles would give me any resources, or basically all of them would, and woudn't just stay with the units i built next to them.
LoL, i figured this out the hard way. Thats why i tried to make one of the numbers in each trigger a variable. but i still had to go through them all to change it to the variable, just that once, so i could change the one variable and it would change all of them. needless to say, It sucked.
@canichols2: Yep, it can be very frustrating copy pasting values or whatever over and over. That's why I wrote everything in custom script in WC3. And that's why I love global constants, arrays and actions in the new editor :D
Ok, to your map. It is very hard for someone not familiar with your map to understand at one single view how you set up things, so to really help you, we would need to view your map or give us more details and screenshot of your triggers. For example: What changes from Ore0 to Ore1 ?
I could think of a setup like the following:
Tile numbers are saved in an integer array (one index for one tile)
So you would know only need to loop through all indexes of this array to check if the tile's number is equal to the rolled number.
A problem follows: You don't know where the tile is. Solution idea:
Save the position (either the point or the coordinates) in an array variable. You would need to do this at map initialization.
TilePoint[4] would now have saved the point for tile 4. To get the number (texttag text) of this tile you would need to use TileNumber[4].
So you would now basically loop through all tiles with a ForLoop and using the variable "loopTile" (remember to save max amount of tiles to not run out of array bounds).
Inside the loop you would check if the TileNumber[loopTile] is equal to the rolled number.
If it is true, then you would need to do your searches around TilePoint[loopTile]. If this search finds valid units/buildings of a player nearby it would add resources. (I am not sure how and how many you add though)
Edit: In case you didn't understand what I was trying to explain: In game it would result in the following:
An 8 is rolled. Now each players gets resources (somehow) who built next to a tile with the number 8.
That's it. All you would then need to do would be one big initialization trigger which sets up the points. And of course you would need to save and update TileNumber[x] like you probably already do now.
Tell me if I got anything totally wrong.
@Rushhour: Go
That sounds like how I was trying to do it. only I don't understand how to use or how a loop works. what i was trying to do was pick each int. from 0 to 21 and do actions. then when i came to a place i needed one of the 22 diferent tiles, i could say Tile[picked int] but then i didn't understand how to use that to get wether or not the the tile at that point is an Ore tile or if it's number is 8 or not. or any combonation of that. so maybe if you could explain how to use the loop thing, it would work better.
Thanks for the pictures... I'm having a guess here but I think there is something reaaaaaaaaaally easy you can do. I guess your hexagonal tiles are either units or (at least) actors. And same goes for the spheres on each corner. There is a function "Unit Group - Closest unit to Point" which allows you to... well... pick the closest unit to a point (O RLY?).
If you manage to pick the custom tile this way (which, obviously, is the closest "unit" to the red point it is on), you might also be able to retrieve the 6 points around your tile using a similar method. Then, a simple check with "If Then Else" can add ressources to each owner of a city/settlement on these 6 points. The main issue is that I haven't found yet how it can work if your tile is not a unit. There doesn't seem to be any way to "Convert Actor to Unit", which would be ideal. Basically, if this method work you should be able to do it in, let's say... one trigger. Neat huh? :D
@canichols2: Oh you should really try to get used to loops and arrays, they make a lot stuff so much easier. Play around with a ForEachInteger loop. It basically does the same like "PickEachInteger". Each has a disadvantage: PickEachInteger can't be nested (that means you can't have a "PickEachInteger" inside a "PickEachInteger" loop); ForEachInteger creates big amounts of code if nested since it implements to actions twice,...!
But for the start, just get used to it.
Create an integer array named "TileNumber" of size 10.
In an initialization trigger do:
ForEachInteger( loopInt, from: 0 to 10, increment 1) do:
Variable: Set TileNumber[loopInt]=loopInt
UI: DisplayText (convert integer to text( loopInt)
So you set the tile number to 1,2,3,4,5,... and also display these numbers. The loop just takes the variable "loopInt" and after one iterration it increases it by "increment". So the first time the functions are called it would work like:
Set TileNumber[0]=0
Ui DisplayText -> 0
(next loop)
Set TileNumber[1]=1
Ui DisplayText -> 1
...
If you get familiar with this, we can go on ;)
@Rushhour: Go
THANK YOU!!!!
THANK YOU!!!!
THANK YOU!!!!
THANK YOU!!!!
I love loops now. that made it so i could take my hunred or so triggers down to a triger that only took like 1 action, after some if then stuff. That was AMAZING!!!! I Love You, in a way that's not gay. but i LOVE YOU. I can't believe that worked. That is what i hated about pick each integer is that you could only use one per trigger/whatever. that was soo cool.
Hrmmmm. how come if i don't hit the enter key twice, my THANK YOU!!!!!'s turn out like this
THANK YOU!!!! THANK YOU!!!! THANK YOU!!!! THANK YOU!!!!
haha you made me laugh xD
It's nice to hear I could help! And nice to see your THANK YOU :D
Additonally I can show you how to create your own "ForEachInteger" loop which doesn't include all actions twice (like the loop that blizzard gave us does). This is (only) important if you nest loops and have a lot of actions/functions/whatever inside them. But I will first be able to show you in several hours when I'm back from work ;P