Hey guys, im trying to figure out how to make this work... heres the scenario...
-i have a unit (unit A) that will run around, then a region that follows the unit (unit is centered in the region with the region moving with the unit)
-then i want it to create units (units B) that fills up the region completely
-now when unit A moves, i want it so that Units B die once the region moves away from it...
trying to explain this the best i can...so to recap,
you move a unit, then the region follows the unit.
units are spawned and fills up the region
the units that are spawned will never move... they just stay where they are spawned
so when the region moves, i want the units that are no longer in the region to be removed from the map
keep in mind the original unit is always moving around, so this will be an endless loop to create and fill the region while destroying any unit that is left out of the region.
or....
is there a way to create a region, and fill it with units... then make the entire region and all of the units inside it all move as a solid piece?
The action Attach Region to Unit will make a region follow an unit. That's easy.
I don't think you can "fill" a region with units. You can try using Create Unit in Random Point in Region multiple times. I don't know if it will show an error or something is the point is already occupied (there are workarounds for this anyway).
Is hard to understand what you wanna do, if the unit that spawns the other units is not flying he could never move as the units will keep spawning around him, blocking the way.
For example what you wanna do, rough code:
While-Conditions--{Someendgameconditionorwhenyouwannatostopdoingtheregionstuff}-Actions--Wait1gametimesecond{putthetimeyouwannawaitforcheckingtheregion}--While---Conditions----(Numberofliveunitsin(UnitsinRegion"Type of Unit You'll Spawn"))<=X{putanumberyouthinkwillfilltheregioncompletely---Actions----Create1"Type of Unit You'll Spawn"forplayerXinRandomPointinRegion.--{EndofCreateUnitsWhile}--SelectEachUnitinAllMap"Type of Unit You'll Spawn"AndDoActions---If(SelectedUnitinRegion)==false)----DeleteSelectedUnit{EndofRepeatingWhile}
Each second the first while will repeat, doing two things: 1) Create units in random position on the region until there are X units there. 2) Select each unit in the map and delete them if they are not in the region.
I don't think you can "fill" a region with units. You can try using Create Unit in Random Point in Region multiple times. I don't know if it will show an error or something is the point is already occupied (there are workarounds for this anyway).
It won't give an error, the unit will simply be created as close to the position as possible.
As for the spawning locations, instead of randomly filling the region until x number of units, you could use this method (if the region is rectangular). Make that into a function with the region, unit type to be created and possibly the offset between units as parameters
Making the entire unit group move as one could also be possible. Once you have the units spawned, issue orders to them, mimicking the main units order with an offset relative to their position in the region. This, however, would break badly as soon as they collide with anything. Depending on your map, I'd try the spawn and remove way first.
The only problem is that his method will not work on a larger map because of the large amount of units, so this was my idea around that problem. So i need the entire region filled 100% of the time.
the only problem i have doing what you suggest frodo, is that when i do -Select Each Unit in All Map "Type of Unit You'll Spawn" And Do Actions, i cannot select my unit since it is not on the map yet.
yeah im having same problem with my diablo style map. ive comeup with a lousy workaroun of making my background of units in said area one while said area 2 doesnt spawn its background until you complete X amount of quests. but id love to see a better workaround u need to be constantly creating and destroying units for the background for the idea you have. i thought of it but i couldnt figure it out. what kind of heros are you going for? i'm debating on weather or not to import different models
Maybe moving units is less consuming that creating and destroying them. Without regions, if you can spam units in the hero position and they recolocate around him, you could move them to the hero position again each second or couple of seconds. Easier to code, and probably will generate less lag.
When I have free time, I'll try to do a test with this. One of my future possible project is a Diablo clone, so is well worth my time.
There are still a few things to deal with here, but the here are the basics how I would do it.
Move your HT, type "spawn" and "kill" in the chat to run the triggers.
Thoughts...
I'm ordering the units to a position relative to where it was when the new order was issued. This means that is they somehow get off course, they will not be able to correct themselves. If this turns out to be an issue you could de-spawn the units each time a move order is issued and recreate them on the correct position (run the kill and spawn triggers followed by the move orders each time). Since your units apparently are invisible, the kill/spawn won't be seen, so this might be what you want to do anyway to avoid random issues later on.
A unit will be spawned on top of the main unit. I chose observers to avoid collisions in my test enviroment. If needed, you could add a condition to the spawn that checks for the "middle spawn" and skip that unit.
There are some orders that will cause the follow move orders to misfire. An example is follow orders, the sub units will move to the initial position, but not follow further. Another is if the main unit auto aquires a target and runs off to attack, the move trigger will not fire.
Running a trigger each 0.5 seconds or so that de-spawns and respawn the units instead of the move order trigger could be a better choice, especially if the units are not seen since it would look quite odd otherwise.
awesome push in the right direction. its possible for me to just have the trigger run every lets say .5 and only make my hero (the templar in this instance) be the unit that moves since i cant make the observers move as a whole it that would be the best choice. now just to do this for 5 heros at same time =) can you spawn the units in multiple regions with one trigger? and the kill trigger would kill any unit for player X outside of the regions? maybe i could merge the regions then have them attach to unit.. right? hmmm lolz thanks btw any further advice is appreciated =)
well i have my original working.. my map has zones ie the starting zone then a level 1-5 zone etc. so i can trigger it through regions to spawn my units i use for movement in the backround(lowerd supply depot with opacity at 0). so like on the ramp to zone 1 i put a squar region then i put another 2 rectangular ones inside at opposite ends of the square one, one on the starting zone side and one on the level 1-5 zone side, one says into "zone name" and vise versa it will display a message with name of the sone you are in such as wow. so then i made a trigger that runs when you enter the square one and checks which region your in inside the square telling it which way you came from sort of. it was my best idea and i get to keep the huge map. i know it kinda fails if you have each of 5 players in different regions but.. the whole point of my rpg is to play it in sequence as a group.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hey guys, im trying to figure out how to make this work... heres the scenario...
-i have a unit (unit A) that will run around, then a region that follows the unit (unit is centered in the region with the region moving with the unit) -then i want it to create units (units B) that fills up the region completely -now when unit A moves, i want it so that Units B die once the region moves away from it...
trying to explain this the best i can...so to recap,
you move a unit, then the region follows the unit. units are spawned and fills up the region the units that are spawned will never move... they just stay where they are spawned so when the region moves, i want the units that are no longer in the region to be removed from the map keep in mind the original unit is always moving around, so this will be an endless loop to create and fill the region while destroying any unit that is left out of the region.
or....
is there a way to create a region, and fill it with units... then make the entire region and all of the units inside it all move as a solid piece?
The action Attach Region to Unit will make a region follow an unit. That's easy.
I don't think you can "fill" a region with units. You can try using Create Unit in Random Point in Region multiple times. I don't know if it will show an error or something is the point is already occupied (there are workarounds for this anyway).
Is hard to understand what you wanna do, if the unit that spawns the other units is not flying he could never move as the units will keep spawning around him, blocking the way.
For example what you wanna do, rough code:
Each second the first while will repeat, doing two things: 1) Create units in random position on the region until there are X units there. 2) Select each unit in the map and delete them if they are not in the region.
It won't give an error, the unit will simply be created as close to the position as possible.
As for the spawning locations, instead of randomly filling the region until x number of units, you could use this method (if the region is rectangular). Make that into a function with the region, unit type to be created and possibly the offset between units as parameters
Making the entire unit group move as one could also be possible. Once you have the units spawned, issue orders to them, mimicking the main units order with an offset relative to their position in the region. This, however, would break badly as soon as they collide with anything. Depending on your map, I'd try the spawn and remove way first.
I should have mentioned this earlier to give you a better idea why i am doing this...
I have a 256x256 map, I am using OneTwo's method of movement that he calls the diablo movement, http://www.youtube.com/onetwosc#p/c/1CA0C5AF4637AB86
The only problem is that his method will not work on a larger map because of the large amount of units, so this was my idea around that problem. So i need the entire region filled 100% of the time.
the only problem i have doing what you suggest frodo, is that when i do -Select Each Unit in All Map "Type of Unit You'll Spawn" And Do Actions, i cannot select my unit since it is not on the map yet.
Doesn't matter davidg121, that code will keep doing that check every second or whatever. If at the start there is no units, will do nothing.
That code "must" work. I'll take a look at the OneTwo tutorial for a better understanding.
yeah im having same problem with my diablo style map. ive comeup with a lousy workaroun of making my background of units in said area one while said area 2 doesnt spawn its background until you complete X amount of quests. but id love to see a better workaround u need to be constantly creating and destroying units for the background for the idea you have. i thought of it but i couldnt figure it out. what kind of heros are you going for? i'm debating on weather or not to import different models
Maybe moving units is less consuming that creating and destroying them. Without regions, if you can spam units in the hero position and they recolocate around him, you could move them to the hero position again each second or couple of seconds. Easier to code, and probably will generate less lag.
When I have free time, I'll try to do a test with this. One of my future possible project is a Diablo clone, so is well worth my time.
There are still a few things to deal with here, but the here are the basics how I would do it.
Move your HT, type "spawn" and "kill" in the chat to run the triggers.
Thoughts...
I'm ordering the units to a position relative to where it was when the new order was issued. This means that is they somehow get off course, they will not be able to correct themselves. If this turns out to be an issue you could de-spawn the units each time a move order is issued and recreate them on the correct position (run the kill and spawn triggers followed by the move orders each time). Since your units apparently are invisible, the kill/spawn won't be seen, so this might be what you want to do anyway to avoid random issues later on.
A unit will be spawned on top of the main unit. I chose observers to avoid collisions in my test enviroment. If needed, you could add a condition to the spawn that checks for the "middle spawn" and skip that unit.
There are some orders that will cause the follow move orders to misfire. An example is follow orders, the sub units will move to the initial position, but not follow further. Another is if the main unit auto aquires a target and runs off to attack, the move trigger will not fire.
Running a trigger each 0.5 seconds or so that de-spawns and respawn the units instead of the move order trigger could be a better choice, especially if the units are not seen since it would look quite odd otherwise.
Hope it helps!
awesome push in the right direction. its possible for me to just have the trigger run every lets say .5 and only make my hero (the templar in this instance) be the unit that moves since i cant make the observers move as a whole it that would be the best choice. now just to do this for 5 heros at same time =) can you spawn the units in multiple regions with one trigger? and the kill trigger would kill any unit for player X outside of the regions? maybe i could merge the regions then have them attach to unit.. right? hmmm lolz thanks btw any further advice is appreciated =)
ok problem how do i kill the units outside of my region in entire map for player. i know theres a way.. maybe ill find it lolz. i hope.
well i have my original working.. my map has zones ie the starting zone then a level 1-5 zone etc. so i can trigger it through regions to spawn my units i use for movement in the backround(lowerd supply depot with opacity at 0). so like on the ramp to zone 1 i put a squar region then i put another 2 rectangular ones inside at opposite ends of the square one, one on the starting zone side and one on the level 1-5 zone side, one says into "zone name" and vise versa it will display a message with name of the sone you are in such as wow. so then i made a trigger that runs when you enter the square one and checks which region your in inside the square telling it which way you came from sort of. it was my best idea and i get to keep the huge map. i know it kinda fails if you have each of 5 players in different regions but.. the whole point of my rpg is to play it in sequence as a group.