When using an array of regions....
To respond to to events at the regions you make a Trigger specifically for handling the events
As I work on this tutorial. I will be adding more chunks of code that make use of the actuall "region array" The Goal of this is that you can have an Integer Value and that integer value represents a region.
Global Variables
NumRegions (type = integer) this variable is used to help loop through your region arrays. It should be set to equal how many total regions you have in your "RegionArray"
RegionArray[0-4] (this would be a global variable of the type "region")
RegionOwnerShip[0-4] (type Integer) (set the variable base to 0 assuming player 0 does not exist, other wise use -1 as the variables base to represent the value of "no one owns this region)
- I want to convert the RegionOwnerShip In to a larger data grid that holds alot of region specific information that can be customized for stuff like region value, region name, region part of larger region(for countries like in risk), hmm it could hold stuff like ,current poplation (for stuff like civilization), and lots of other stuff like that.
Trigger RegionArraySetup
Trigger RegionArraySetup
Event
Time elaspsed 1 second
Action
RegionArray[0] = Region1
RegionArray[1] = Region2
RegionArray[2] = Region3
RegionArray[3] = Region4
RegionArray[4] = Region5
Trigger Region Handler
Trigger Region Handler
Events
Unit enters Region1
Unit enters Region2
Unit enters Region3
Unit enters Region4
Unit enters Region5
Conitions
Player controller of (owner of (triggering unit)) = User
Action
Switch (triggering region)
if (Region1)
DoRegionStuff(0,Owner of (triggering unit)) (this is a function/ action created for doing a specific task. The switch needs to be hard coded for the regions actuall name and then passed a hard coded integer to a seperate function with the hard coded value of that regions index in the array
if (Region2)
DoRegionStuff(1,Owner of (triggering unit))
if (Region3)
DoRegionStuff(2,Owner of (triggering unit))
if (Region4)
DoRegionStuff(3,Owner of (triggering unit))
if (Region5)
DoRegionStuff(4,Owner of (triggering unit))
Function DoRegionStuff
Function DoRegionStuff
Parameters
RegionIndex
PlayerIndex
Actions
If RegionOwnerShip[RegionIndex] = 0 ( zero represent that no Player has control of this region) Then
RegionOwnerShip[RegionIndex] = PlayerIndex
Trigger RemoveRegionOwnership
Trigger RemoveRegionOwnership
Events
Unit leaves Region1
Unit leaves Region2
Unit leaves Region3
Unit leaves Region4
Unit leaves Region5
Conditions
If UnitType of (triggering unit) != missile ( add conditions so it will not run full trigger for the types of units you dont want setting off the trigger on death)
Actions
If Number of units in UnitGroup( Convert Units in region(triggering region) owned by Player(owner of triggering Unit) matching conditions - this is where you set it to not count missiles and dead units and stuff like that.) < 1 Then
Switch (triggering region)
if (Region1)
RegionOwnerShip[0] = 0
if (Region2)
RegionOwnerShip[1] = 0
if (Region3)
RegionOwnerShip[2] = 0
if (Region4)
RegionOwnerShip[3] = 0
if (Region5)
RegionOwnerShip[4] = 0
Trigger GivePlayersResources
Trigger GivePlayersResources
Events
Timer Periodic every 20 seconds Real-Time
Variables
RegionValue (type integer, base value "20" or how ever much minerals you want to give a player for each region they control)
TempOwnedRegions (type = integer)
i (type integer)
Action
Pick each player in player Group ( All Players)
set variable (TempOwnedRegions) = 0
If
Conditions
controller of (picked player) = user
status of (picked player) != has left game
Then
For each integer "i" from 0 to NumRegions - 1, increment +1 (it is NumRegions - 1 to account for the fact that arrays are 0 based)
IF
Conditions
RegionOwnerShip[i] = picked player
Then
TempOwnedRegions = TempOwnedRegions + 1
Give Picked player resources "minerals" (TempOwnedRegions * RegionValue)
Summary
Dunno what to say for a summy. I use this kinda region logic quite a bit.
dont know what he did, im learning too but the region handler thing works nice, i was about to make 64 identical triggers, when i can juse use 1 big one!
If going down this route, I think data tables might be worth a look.
I can't go down it, I have 100 regions.
I just discovered that 'Unit Enters/Leaves Triggering Region' doesn't work either. I have no idea how I'm going to approach my design now :s
(by that I mean, if you specifiy a region it's OK, but you can't have the event tell you which region triggered the event, even if it's supposed to work, it doesn't, tested for 30 mins trying to get roudn it)
Why are you declaring and setting a region array if you don't use it anywhere else, and instead you are using an ugly switch ... ? :)
Actually vjeux if you actually looked through the code there its used when ...... Giving control of a region ,removing control of a region. It can be used for alot of other things then I show here. As I work on this tutorial. I will be adding more chunks of code that make use of the actuall "region array" The Goal of this is that you can have an Integer Value of "1" and that integer value represents a region.
You use it so you can loop through your regions for more complicated operations...
You say switches are ugly ...... I believe they are a gift from the gods..... definatley betther then 50 if statements... and with if statements you have to break out of the operation so that you dont set off other if statements. A switch will only run one of the possibilites where as a set of 50 ifs.... depending on the conditions set .... more then 1 of those ifs could pass as true. I use switches alot because they allow me to come back later and add fairly complicated logic with out having to worry about how it will effect the rest of my code.
This logic Is intended to be scaleable with out having to create more Triggers.... It does require more events on the triggers though but that is unavoidable with the way Events work.
If going down this route, I think data tables might be worth a look.
I can't go down it, I have 100 regions.
I just discovered that 'Unit Enters/Leaves Triggering Region' doesn't work either. I have no idea how I'm going to approach my design now :s
(by that I mean, if you specifiy a region it's OK, but you can't have the event tell you which region triggered the event, even if it's supposed to work, it doesn't, tested for 30 mins trying to get roudn it)
I will be adding a second dataset that would be a "data table". Mainly for holding region specific information.
This logic Carries over to as many regions as you want.
The switch statement that checks the "triggering region" vs the actuall regions, should work. If it doesnt post the code you are using so I can see what you have.
dont know what he did, im learning too but the region handler thing works nice, i was about to make 64 identical triggers, when i can juse use 1 big one!
Quote from DJSplendid:
I just discovered that 'Unit Enters/Leaves Triggering Region' doesn't work either. I have no idea how I'm going to approach my design now :s
(by that I mean, if you specifiy a region it's OK, but you can't have the event tell you which region triggered the event, even if it's supposed to work, it doesn't, tested for 30 mins trying to get roudn it)
Quote from SouLCarveRR:
The switch statement that checks the "triggering region" vs the actuall regions, should work. If it doesnt post the code you are using so I can see what you have. Quote from davyswin: Go
I'll rephrase. If anyone creates a trigger with the event "Unit enters triggering region" it does not behave in the way I expected, it does not implement a 'this()' or self-reference in any way (ie. for the region that threw the event). So when deeper in your trigger you use the "triggering region" fetch, the value comes through as null/useless.
In other words, there's no provision for: "HEY, IM REGION X AND I JUST HAD A THINGY PENETRATE MY BOUNDARIES"
I find this a bit shit.
...which is pretty much the same as switch-case in Galaxy, so at least performance-wise they won't differ :)
But it's possible to use triggering region in the switch:
Switch is much better suited if you have a lot of regions that do vastly different actions.
For some reason it wouldnt let me use "triggering region" as the switch value........ Maybe my dependancies are messed up.... I hate messing with the dependancies...
Yeah I am trying to write this so its extremely customizable. Ill put up the map when its ready. It will Include Cities of some kinda that have different "stats".
Quote from DJSplendid:
I just discovered that 'Unit Enters/Leaves Triggering Region' doesn't work either. I have no idea how I'm going to approach my design now :s
(by that I mean, if you specifiy a region it's OK, but you can't have the event tell you which region triggered the event, even if it's supposed to work, it doesn't, tested for 30 mins trying to get roudn it)
Quote from SouLCarveRR:
The switch statement that checks the "triggering region" vs the actuall regions, should work. If it doesnt post the code you are using so I can see what you have. Quote from davyswin: Go
I'll rephrase. If anyone creates a trigger with the event "Unit enters triggering region" it does not behave in the way I expected, it does not implement a 'this()' or self-reference in any way (ie. for the region that threw the event). So when deeper in your trigger you use the "triggering region" fetch, the value comes through as null/useless.
In other words, there's no provision for: "HEY, IM REGION X AND I JUST HAD A THINGY PENETRATE MY BOUNDARIES"
I find this a bit shit.
This is mainly do becase regions area from my understanding an array of points or I think they are.
But yeah this is why you see that I have an event for every region I want this code to run against.
I kinda code It as if it were a "listener" anyways so this feels kinda normal to me.... Like as if i was programming is ... M3 or asm i think its called what ever the scripting language for Flash is. God learning that was a terrible experience.
Im find it exteremly difficult to find a Splat actor that has a enough density for me to use to shade an area by increasing its scale and then tinting it... any ides on a model I should look at.
That or if you know of a way to force a normal model to be 2d and conform to the shape of the terrain.
Can I convert a Region Variable into and Interger Variable.
I saw you're comment in another post.
I read you're tutorial but it does not answer this.
Thanks in advance.
EDIT, So sorry, You're tutorial covers exactly that...
Can I convert a Region Variable into and Interger Variable. I saw you're
comment in another post. I read you're tutorial but it does not answer
this. Thanks in advance.
EDIT, So sorry, You're tutorial covers exactly that...
No you cant really. The region variable is actually set to be a specific region?
Rollback Post to RevisionRollBack
Skype
KageNinpo = SN
My Libraries
DialogLeaderboard & TeamSort
My Projects
SPACEWAR Tribute
Infinite TD
I'm not sure if this is useful for this example, but every region that you create gets assigned an integer ID by the editor, and there's a function that returns the region for the ID that you pass in:
region RegionFromId(int id)
This function doesn't show up in the trigger editor for some reason, but it is one of the native galaxy functions. A lot of the campaign scripts use it. I haven't found an easy way to determine the ID of a region, though. I believe they get indexed starting at 1 in the order that you create them, so if you don't rename the regions, the ID should be the same as the number in the region name "Region 001".
[Region Arrays] Events, Ownership, Resources
When using an array of regions.... To respond to to events at the regions you make a Trigger specifically for handling the events
As I work on this tutorial. I will be adding more chunks of code that make use of the actuall "region array" The Goal of this is that you can have an Integer Value and that integer value represents a region.
Global Variables
- I want to convert the RegionOwnerShip In to a larger data grid that holds alot of region specific information that can be customized for stuff like region value, region name, region part of larger region(for countries like in risk), hmm it could hold stuff like ,current poplation (for stuff like civilization), and lots of other stuff like that.
Trigger RegionArraySetup
Trigger Region Handler
Function DoRegionStuff
Trigger RemoveRegionOwnership
Trigger GivePlayersResources
Summary
Dunno what to say for a summy. I use this kinda region logic quite a bit.
Why are you declaring and setting a region array if you don't use it anywhere else, and instead you are using an ugly switch ... ? :)
dont know what he did, im learning too but the region handler thing works nice, i was about to make 64 identical triggers, when i can juse use 1 big one!
Actually vjeux if you actually looked through the code there its used when ...... Giving control of a region ,removing control of a region. It can be used for alot of other things then I show here. As I work on this tutorial. I will be adding more chunks of code that make use of the actuall "region array" The Goal of this is that you can have an Integer Value of "1" and that integer value represents a region.
@SouLCarveRR: Go
OK for some reason im not seeing the ... triggering region function ... not sure why.... gonna make it work then edit the post
I cant seem to set the switch to handle the triggering region value.... looks like im gonna rewite it so i fine it by looping
...which is pretty much the same as switch-case in Galaxy, so at least performance-wise they won't differ :)
But it's possible to use triggering region in the switch:
Switch is much better suited if you have a lot of regions that do vastly different actions.
For some reason it wouldnt let me use "triggering region" as the switch value........ Maybe my dependancies are messed up.... I hate messing with the dependancies...
Yeah I am trying to write this so its extremely customizable. Ill put up the map when its ready. It will Include Cities of some kinda that have different "stats".
This is mainly do becase regions area from my understanding an array of points or I think they are.
But yeah this is why you see that I have an event for every region I want this code to run against.
I kinda code It as if it were a "listener" anyways so this feels kinda normal to me.... Like as if i was programming is ... M3 or asm i think its called what ever the scripting language for Flash is. God learning that was a terrible experience.
@SouLCarveRR: Go
Im find it exteremly difficult to find a Splat actor that has a enough density for me to use to shade an area by increasing its scale and then tinting it... any ides on a model I should look at.
That or if you know of a way to force a normal model to be 2d and conform to the shape of the terrain.
Can I convert a Region Variable into and Interger Variable. I saw you're comment in another post. I read you're tutorial but it does not answer this. Thanks in advance.
EDIT, So sorry, You're tutorial covers exactly that...
No you cant really. The region variable is actually set to be a specific region?
I'm not sure if this is useful for this example, but every region that you create gets assigned an integer ID by the editor, and there's a function that returns the region for the ID that you pass in:
region RegionFromId(int id)
This function doesn't show up in the trigger editor for some reason, but it is one of the native galaxy functions. A lot of the campaign scripts use it. I haven't found an easy way to determine the ID of a region, though. I believe they get indexed starting at 1 in the order that you create them, so if you don't rename the regions, the ID should be the same as the number in the region name "Region 001".