and so on.
These points are so I can use another function to call upon spawning the units at the right spawn point and keep spawning them there, as well as terminate them when the worm dies.
Actions
Variable - Set NydusPoint Placed 2 = (Random integer between 0 and 8)
General - If (Conditions) then do (Actions) else do (Actions)
If
NydusPoint Placed 2 == NydusPoint Placed 1
Then
Trigger - Run Nydus Build 2 (Ignore Conditions, Don't Wait until it finishes)
Else
is basically the version I was using for placing 3 worms up at once with 3 seperate triggers for each, I was wondering if anyone would have an idea to generate these ids and call upon them later rather then doing a huge nested if then else on map initialization to generate the points id's, or if anyone has a better idea to spawn the worms and continously spawn units from them until the worm dies.
Actions
Variable - Set NydusPoint Placed 2 = (Random integer between 0 and 8)
General - If (Conditions) then do (Actions) else do (Actions)
If
NydusPoint Placed 2 == NydusPoint Placed 1
Then
Trigger - Run Nydus Build 2 (Ignore Conditions, Don't Wait until it finishes)
Else
is the trigger I used to spawn the units.
Actions
Variable - Set NydusPoint Placed 2 = (Random integer between 0 and 8)
General - If (Conditions) then do (Actions) else do (Actions)
If
NydusPoint Placed 2 == NydusPoint Placed 1
Then
Trigger - Run Nydus Build 2 (Ignore Conditions, Don't Wait until it finishes)
Else
Is the trigger I use to determine when the worm dies.
EDIT:
Forgot to add, the reason for the amount of points is that Im implementing a difficulty system and have 4 scales of difficulty, so with 3 instances of randomly spawning the worms I want to spawn 1 per difficulty level, so difficulty 4 will have 4 worms at once each time for 3 times.
So difficulty 1 spawn (1, 2, 3) worms, Difficulty 2 (2, 4, 6), etc.
The idea behind the random zone is to affect replayability, so that it isn't "ok, boss time, worm spawns here, worm there."
if he is trying to get a radnom point with each nydus point then he doesn't want nydus 1 and nydus 2 being = so he will rerun the trigger to get a new random variable and check the same conditions. Thats what I get from it.
What I am trying to acclomplish is to have 20 preset points and at the start of the game have each of these points assigned to the variables of Nydusplaced (1-20). The reason for this is that I want to place up to 4 Nydus worms at a time in these points randomly, and by assigning them to integer variables and comparing them when they are assigned is the only way I could work out how to make sure I would not have any doubles at any time (run the trigger and have 2 worms spawn on the single point). This also helps since I could set waves to spawn from that worm when it was placed and kill the spawn when the worm dies without interrupting any others.
To clarify a bit more, I have a unit moving from point A to point B, inbetween those points are 3 zones, when he reaches one of the zones he stops, does a cast animation and then a number of worms (depending on difficulty) spawn at one of the random points. And so on.
I had it set to 9 worm points total and the three casts, and had them working out the points each time he hit the zones.
But with modifying the number of worms per difficulty rating I needed to add more worms and to make sure that I wouldnt get doubles I pushed the number of spawn points to 20 (to allow up to 6 difficulty rating rather then the 4 I am working with now).
I also have changed the randomisation of the points to be at map init rather then per cast, so as to cut down on lag ingame.
So I have set up a nested if-then-else on map init getting those points, but am worried I am going about this the wrong way.
I have thought about it since and think I might break the points down from a flat 20 randomisation to 3 seperate points of 6 (might make 1 extra point and make it an even 7 per trigger) but would like some advice if anyone has a better idea on how to do this.
Basically:
You have another array which checks whether the specified nydus point is already in use.
In your trigger you repeat the RandomInt() action as often as you need to to get a point which is not in use already. Then you mark this point as used and spawn your Nydus worm.
Next time you run this trigger it cannot randomize the same number again, because it's marked as being used already.
I see thank you, I was thinking an array but wasn’t sure if it would work.
Question though, I have 2 other triggers at the moment which calls upon the data of the point, one to initiate waves coming from the worm and one to stop the waves when the worm dies.
I should be able to call upon the point generated from here with those right?
I’m not at my sc2 computer at the moment but if I remember right it is
(spawn units) action unit create unit at nyduspoint placed 1 unit move
(worm dies) event unit dies at nyduspoint placed 1 condition triggering unit = nydus worm unit action stop all instances of nydus spawn units 1
each of these are tripled (1 for each cast) I could put the create / move units one into the spawn zone to cut the triggers down without too much hassle / it loking too bad. Mainly worried about the death one. And stopping the units spawning once the worm dies. which is why im asking here, since I know im doing something wrong or at least in a roundabout way when theres a much more efficient way to do them. It’s been a few years since I played with anything like this. :( But I thank you very much for the help. :)
*The text type wants to break on me and not show up right using wikicreole or cursewiki so had to post this in textile :(
Ok I have had a play with it and in order to spawn 4 worms at once and get a continuous stream from each of the worms separately I need to create 4 triggers for spawns, as well as 4 triggers for when the worms die. But this is a whole lot better then the way I was doing it originally. I thank you again for the help :)
Dunno if you figured your own way to do something like this i just figured Id put up something like the way I would do it.
Globals
NydusPoint[0-5](type:point) this arrays points need to be set to specific point values or terran editor place points. if you want to create events based off things in relation to these points you must place the points in the terrain editor and then in another trigger set the arrays values = to those points. Keep in mind if you move the points the events for other triggers do not seem to adjust to the new points position..... this may have been corrected in a patch but i havent seen it.
MaxArrayIndex(type:integer)= 5 max index value on your point array
NydusPointActive[0-5](type:boolean)
Spawn Timer Trigger
events
Periodic 20 seconds
actions
Random Spawn Function(-1)
Random Spawn Function(Type:Action Return:none)
parameters
ForcePointIndex(type:integer) this is so you can pass a specific index to create nydus at
variables
TempRan (type:integer) = no point
i (type:integer) = 0
ii (type:integer) = 0
ValidRandom (type:boolean) = false
AvailablePoints(type:integer array[0-5]) = 0 This would need to be the same size as your point array
NumAvailablePoints(type:integer) = 0
actions
If (ForcePointIndex = -1) AND (NydusPointActive[ForcePointIndex] = false)
Create Unit NydusCanal at NydusSpawn[ForcePointIndex]
set NydusPointActive[ForcePointIndex] = true
else
Do while (ValidRandom = false)
For i 0 - MaxArrayIndex
if (NydusPointActive[i] = false)
set NumAvailablePoints = NumAvailablePoints + 1
set AvailablePoints[ii] = i
set ii = ii + 1
else
Do Nothing
Switch NumAvailablePoints
if = 0
set ValidRandom = true Do nothing because all points are active, but set the ValidRandom to true so it exits the loop
if = 1 only one point is active so force it
Create Unit NydusCanal at NydusSpawn[AvailablePoints[0]]
set NydusPointActive[AvailablePoints[0]] = true
set ValidRandom = true
else general this is what the switch does if the other listed conditions are not met
Set TempRan = random integer between 0 - (NumAvailablePoints -1) using -1 here becuase NumAvailablePoints is not zero based
if NydusPointActive[AvailablePoints[TempRan]] = true
this is aninvalid point do nothing
else
Create Unit NydusCanal at NydusSpawn[AvailablePoints[TempRan]]
set NydusPointActive[AvailablePoints[TempRan]] = true
set ValidRandom = true
Deactivate Spawn Points
events
NydusCanal dies(not sure if you can specify type in the event other wise use all units)
conditions
type of unit = nyduscanal
variables
TempDistance(type:real)
TempClosestPoint(Type:real array[0-1]) = 0 for determining point nydus belongs to index:0 is the point index, index:1 is the distance
i (type:integer)
actions
set TempClosestPoint[0] = 0
set TempClosestPoint[1] = Distance from position of triggering unit to NydusPoint[0]
for i = 1 to MaxArrayIndex
Set TempDistance = Distance from position of triggering unit to NydusPoint[i]
if TempDistance < TempClosestPoint[1]
TempClosestPoint[0] = i
TempClosestPoint[1] = TempDistance
set NydusPointActive[TempClosestPoint[0]] = false
Spawn Units At Active Points Trigger
Events
Periodic .5 seconds
variables
i (type:integer)
actions
For i = 0 - MaxArrayIndex
if NydusPointActive[TempRan] = true
Creat 1 zergling at point offset with angle from point position of NydusSpawn[i]
I'm still having some trouble, this time its with the death of the worm.
Using the methods of yourself and @s3rius: I have been able to get the worms to spawn when I want from where I want and for them each to have a separate stream of units spawning from them. And the ridiculous amount of variables I would have had to have has been cut to nearly none.
But when the worm dies with @s3rius: method there is no way to account for which point died so as to shut off the boolean. And with your method @SouLCarveRR: for some reason I keep getting an error.
I have managed to work out that the error is coming from the condition in if TempDistance < TempClosestPoint[i - 1]
It is being flagged as an error in the GE and doesn't compile into the game.
Any insight as to where I might have gone wrong with it will be appreciated. I already appreciate all the help everyone has given so far :)
EDIT
For some reason its not flagging it as a error anymore, but it is still giving the error while in game. Attached a screenshot of the trigger for easier reference.
Found it .... my bad I miss typed something... haha you followed my code pretty good
if TempDistance < TempClosestPoint[i - 1]
shoud be
if TempDistance < TempClosestPoint[1]
no minus operations
I edited to code in my previous post to reflect this change. Supprised you didnt catch this since you found the line lol.
Though I dont think this would have caused an error. It would have caused this to always fail at what its meant to do.
you have (set NydusPointActive[TempClosestPoint[0]] = false ) in the else statement.... should be on the same level as the if not inside the if
If you still get the error at this point..... take a screen shot of the error in game. Also I would set up some text out puts specifically to see the distance values of Temp distance and the ClosestPoint Array
BTW on a scale of 1-10 ... 10 being good. How well did you understand my logic for all of that. Anything I could do bettter explain more? I did all that off the top of my head before bed last night took about an hour to work through.
Oh I feel like a fool lol. I tried every combination around that I could think of EXCEPT •if TempDistance < TempClosestPoint[1] . I had it with [i] and it didn't give an error, oh well thats tiredness and working out how things work.
on a scale of 1-10 id say I understood your logic there at about an 8.5ish, I managed to see how everything went along pretty well but I'd say I just got confused and frustrated with the total procedure and then worried about it not working and ruining the whole shebang lol. For all off the top of your head it was pretty spot on.
I didn't understand what you meant with the spawn timer trigger.
NydusPointActive[0-5](type:boolean) Spawn Timer Trigger
events
Periodic 20 seconds
actions
Random Spawn Function(-1) Random Spawn Function(Type:Action Return:none)
parameters
ForcePointIndex(type:integer) this is so you can pass a specific index to create nydus at
variables
TempRan (type:integer) = no point
i (type:integer)
actions
If ForcePointIndex = -1
Set TempRan = random integer between 0 - MaxArrayIndex
else
Set TempRan = ForcePointIndex
if NydusPointActive[TempRan] = true
'this is aninvalid point do nothing
else
Create Unit NydusCanal at NydusSpawn[TempRan]
set NydusPointActive[TempRan] = true
But it could just be the way that it came up on here, but I managed to nut it out with the post that @s3rius: had made and your help as well, So I had them all spawning when I wanted and the units spawning from them when they spawned, so it all came together up until the worm dies. But I'll change that bit when I get home and post an update on here, it should fix it now that I look at it. Setting triggers you're not sure of when tired = not always following logically lol.
Thank you again for the help :)
Ah the Spawn Timer Trigger is for if you wanted to periodically spawn the random nydus cannals. But from your screen shots I see that you want them to spawn when something gets close to the points from the looks of it.
On that "Spawn Worm" trigger you have a screen shot of..... isnt that an infinite loop you have there?
I initially thought it would be infinite as well, but it only runs until it recieves a false then it continues on with the rest of the trigger.
I am also setting a size based spawn on it depending on the difficulty so I'm just setting a integer to difficulty and making it repeat the whole procedure difficulty times. Tested this last night and when on difficulty 1 it only ever spawns 1 worm per pass, and 4 for difficulty 4. Having a second trigger for a second area to do the same thing also doesn't produce any erratic results.
Update, I tried that and am now having another problem. I am not having an error message now but I am getting a weird problem. The problem I am having is that when one worm dies it sets off a lot of the others that are still some distance away for some reason. I also had to make an origin point (Nydus[0]) because when I killed the worm at point 1 the stop command didn't run.The duplication effect was happening when the origin point was set to Nydus[1] as well.
I set up a scoreboard to tell me the distance values that are being returned and the boolean value too, to see which ones are being shut off when it runs.
Below is the code as stands for the death trigger and I'll attach a picture with the distances and which ones are changing.
Also are some pictures for when A worm dies, with attached values for Tempclosestpoint[0] Tempclosestpoint[1] and Temp distance.
I only done 3 of the worms and their values after resetting it and killing them, To try and diagnose the problem.
Worm Death
Events
Unit - Any Unit dies
Local Variables
i = 1 <Integer>
TempDistance = 0.0 <Real>
TempClosestPoint = 0.0 <Real[1]>
Conditions
(Unit type of (Triggering unit)) == Nydus Worm (Canal)
Actions
Variable - Set TempClosestPoint[0] = 0.0
Variable - Set TempClosestPoint[1] = (Distance between (Position of (Triggering unit)) and NydusPoints[0])
General - For each integer i from 1 to MaxArrayIndex with increment 1, do (Actions)
Actions
Variable - Set TempDistance = (Distance between (Position of (Triggering unit)) and NydusPoints[i])
General - If (Conditions) then do (Actions) else do (Actions)
If
TempDistance < TempClosestPoint[1]
Then
Variable - Set TempClosestPoint[0] = (Real(i))
Variable - Set TempClosestPoint[1] = TempDistance
Else
Variable - Set Nydus Points in use[(Integer(TempClosestPoint[0]))] = false
The weird thing is that its not stopping ones near the same value in distance, but ones from all over the spectrum.
EDIT
I reduced the max array and active nodes to 5 and when node 5 died it stopped all of them, they had the same distances as in the shots. Thought it might produce different results if I shrunk the active nodes but to no avail.
I initially thought it would be infinite as well, but it only runs until
it recieves a false then it continues on with the rest of the trigger.
I am also setting a size based spawn on it depending on the difficulty
so I'm just setting a integer to difficulty and making it repeat the
whole procedure difficulty times. Tested this last night and when on
difficulty 1 it only ever spawns 1 worm per pass, and 4 for difficulty
4. Having a second trigger for a second area to do the same thing also
doesn't produce any erratic results.
It returns false if it loops too many times... this is a byproduct of infinite looping in SC2....
Rollback Post to RevisionRollBack
Skype
KageNinpo = SN
My Libraries
DialogLeaderboard & TeamSort
My Projects
SPACEWAR Tribute
Infinite TD
Well Id like to help more but you have kinda gone away from the way I would do it.
Your "Spawn Worm" trigger doesnt look logical to me.
and the debug message look like something isnt happening correctly ... if you have other aspects of your map to work on you can go to those. And upload your current map for me to take a look at. Gonna be kinda busy this week end but i could try and take a look. I would need to debug your triggers quite a bit and possibly rework them a little.
Variable - Set Nydus Points in use[(Integer(TempClosestPoint[0]))] = false
this should not be in the ELSE side of the last if like i said in my previous post. Other wise it wont work correctly
Rollback Post to RevisionRollBack
Skype
KageNinpo = SN
My Libraries
DialogLeaderboard & TeamSort
My Projects
SPACEWAR Tribute
Infinite TD
Quote@soulcarverr
Variable - Set Nydus Points in use[(Integer(TempClosestPoint[0]))] = false
this should not be in the ELSE side of the last if like i said in my previous post. Other wise it wont work correctly
/quote
Yep, I've moved it to the same line as the if and not in the else, else is just blank at the moment. Just when copied to text it placed it in a line.
If
TempDistance < TempClosestPoint[1]
Then
Variable - Set TempClosestPoint[0] = (Real(i))
Variable - Set TempClosestPoint[1] = TempDistance
Else
Variable - Set Nydus Points in use[(Integer(TempClosestPoint[0]))] = false
I'd like to use your one to randomly spawn units, it just honestly confused the crap outta me.
Although looking at it again I think I have a better idea of whats going on, but would like some clarification on it if you don't mind to see if I am following it right.
The spawn timer runs the spawn trigger and sets the forcepointindex to -1
•parameters
•ForcePointIndex(type:integer) this is so you can pass a specific index to create nydus at
•variables
•TempRan (type:integer) = no point
•i (type:integer)
•actions
•If ForcePointIndex = -1
•Set TempRan = random integer between 0 - MaxArrayIndex
•else
•Set TempRan = ForcePointIndex
•if NydusPointActive[TempRan] = true
•'this is aninvalid point do nothing
•else
•Create Unit NydusCanal at NydusSpawn[TempRan]
•set NydusPointActive[TempRan] = true
So if I set this in a seperate trigger to call upon when the worms are supposed to be spawned (unit enters my region) instead of the timer and have it set the global variable forcepointunit to -1 then the first if will repeat until it recieves a different number (once at max) then it'll continue on. The only problem I saw with this is was that if I made it spawn 4 at once by setting forcepoint to -1 after the fact and putting it inside a repeat 4 times function is that if it came up against a point that already had a worm there it would do nothing, I could be very wrong though. But as it appears to me if I get point 2 on the first run it'll spawn a worm there, then if I return 2 again it will continue on and then just not do anything, so my 2 worms just became one only.
I suppose I could set the trigger to call upon itself if the point returns true and set the difficulty part inside the actual region trigger instead though, since it would have the same effect and not cause infinite loops then. Not at my computer again (quick look at the forum before work :)) but I'll give it a try when I get home, unless I lost some logic in what I just explained.
Ok first of all you said your using points ... not regions... if your using regions to spawn the nydus worms I would use a completely different method that doesnt random them. Because well if your having units enter a region to spawn nydus at that region then its not really random right?
The way that trigger is written is that if it randoms a point in use it would basically do nothing. I could change it to handle that ... Ill take a shot at changing the trigger above.
Ok I edited my above trigger for picking the point to spawn at. It will continue to loop looking for a valid random point
ValidRandom (type:boolean) = false
several draw backs are
If every point is active it will infinite loop till the sc2 engine determines to kill it (which it does in some occasions)
I have found the random function to be lacking in sc2 where the resault dont always seem to be very random so it may need to loop for longer then you would think it would if you say have 75% of the point already active.
You could add another check in the trigger to make it check to see what points are actually active then save those points to a new array that holds the index of the points that are not active and then random a value from those. This would also allow you to determine if there are any points that are not active. But I dont really feel like coding that for you .... it wouldnt be to complicated just more typing then I really feel like at the moment.
Its not a good idea to use recursive function calling in SC2 I dont think the script engine would care for it a whole lot. well... in the case of where it would call itself 1000 times I dont think it would like it .. but you never know when your randoming stuff how long it will take for a random point to be valid.
Ive done quite a bit of this kinda stuff in my "Infite TD" map where I create random TD paths for 14 different players every time the game starts and every 10 levels I recreate the radom paths. But I verify that none of the points I randomly generate are too close to an existing point.
Ok I'll give a better explenation of what I am trying to attempt, basically it is a TD map and this function is for the boss spawns, the path is set for everythign to travel on except the units spawned at the nydus which will just head to the end zone in the best path possible form where they are. I have 3 regions along the normal unit path that have the unit enters region & unit = boss wave condtions, when these are met the boss does a cast animation and spawns x amount of worms at x points on the map.
So the condition to set off the worm spawn is differnt from the actual create worms one. The worms are being created at points (I figured it would be easier to control the whole process with points for the worms, but I am seeing now its nowhere near as easy as I had hoped lol) and the regions are just for the condtion to run the placement.
One of the reasons I am trying to get this working preoperly is so I can set up another wave to do the same thing that you said you ahve in your infiite TD map, where it will generate a random pathing different to the normal one, but I will be setting this up for a few specific waves only. Still have a lot of work to go on the map but trigger wise its almost done to a runnable point, which will just leave me data editing and a few other things that I want to add in (which I can see causing more problems too lol) but HOPEFULLY when I'm finished it will be fun and have a good replay factor. Could be though that theres too much to manage at once, but I can just tweak numbers for people to have enough time to mange it all.
Im rewriting it right now.... gonna take a bit of time... but it should calc random points better and if say you have only 1 that would be valid... it will just automatically spawn that one.
Alright I re-wrote it.
You can force a specific point by passing a valid point number or have it random by passing -1
It will make a list of the points that are unused and use this list to random from the unused points
if there are 0 unused points it will do nothing
if there is 1 unused point it will force it to activate that point with out randoming
It may be hard to read because the page is forcing it to line wrap which makes reading some of the variables names are to read if you se [adfasadfas] that basically belongs to the previous line keep and eye on it.
Its unfortunate that I cant turn off the line wrap when writing code. Its a pain in the ass to read once it starts to line wrap
Well that trigger is vastly more complicated now hope you can figure it out.
Is the trigger I use to determine when the worm dies. EDIT: Forgot to add, the reason for the amount of points is that Im implementing a difficulty system and have 4 scales of difficulty, so with 3 instances of randomly spawning the worms I want to spawn 1 per difficulty level, so difficulty 4 will have 4 worms at once each time for 3 times. So difficulty 1 spawn (1, 2, 3) worms, Difficulty 2 (2, 4, 6), etc. The idea behind the random zone is to affect replayability, so that it isn't "ok, boss time, worm spawns here, worm there."
Could you explain why you're comparing NydusPoint 2 to NydusPoint 1 and only run the trigger when they're equal?
@s3rius: Go
if he is trying to get a radnom point with each nydus point then he doesn't want nydus 1 and nydus 2 being = so he will rerun the trigger to get a new random variable and check the same conditions. Thats what I get from it.
@s3rius: Go
What I am trying to acclomplish is to have 20 preset points and at the start of the game have each of these points assigned to the variables of Nydusplaced (1-20). The reason for this is that I want to place up to 4 Nydus worms at a time in these points randomly, and by assigning them to integer variables and comparing them when they are assigned is the only way I could work out how to make sure I would not have any doubles at any time (run the trigger and have 2 worms spawn on the single point). This also helps since I could set waves to spawn from that worm when it was placed and kill the spawn when the worm dies without interrupting any others. To clarify a bit more, I have a unit moving from point A to point B, inbetween those points are 3 zones, when he reaches one of the zones he stops, does a cast animation and then a number of worms (depending on difficulty) spawn at one of the random points. And so on. I had it set to 9 worm points total and the three casts, and had them working out the points each time he hit the zones. But with modifying the number of worms per difficulty rating I needed to add more worms and to make sure that I wouldnt get doubles I pushed the number of spawn points to 20 (to allow up to 6 difficulty rating rather then the 4 I am working with now). I also have changed the randomisation of the points to be at map init rather then per cast, so as to cut down on lag ingame. So I have set up a nested if-then-else on map init getting those points, but am worried I am going about this the wrong way. I have thought about it since and think I might break the points down from a flat 20 randomisation to 3 seperate points of 6 (might make 1 extra point and make it an even 7 per trigger) but would like some advice if anyone has a better idea on how to do this.
@nevjmac: Go
Pretty much nail on the head mate.
Sorry for not being more clear guys. :(
Basically:
You have another array which checks whether the specified nydus point is already in use.
In your trigger you repeat the RandomInt() action as often as you need to to get a point which is not in use already. Then you mark this point as used and spawn your Nydus worm.
Next time you run this trigger it cannot randomize the same number again, because it's marked as being used already.
@s3Rius
I see thank you, I was thinking an array but wasn’t sure if it would work.
Question though, I have 2 other triggers at the moment which calls upon the data of the point, one to initiate waves coming from the worm and one to stop the waves when the worm dies.
I should be able to call upon the point generated from here with those right?
I’m not at my sc2 computer at the moment but if I remember right it is
(spawn units)
action
unit create unit at nyduspoint placed 1
unit move
(worm dies)
event
unit dies at nyduspoint placed 1
condition
triggering unit = nydus worm unit
action
stop all instances of nydus spawn units 1
each of these are tripled (1 for each cast)
I could put the create / move units one into the spawn zone to cut the triggers down without too much hassle / it loking too bad. Mainly worried about the death one. And stopping the units spawning once the worm dies.
which is why im asking here, since I know im doing something wrong or at least in a roundabout way when theres a much more efficient way to do them.
It’s been a few years since I played with anything like this. :( But I thank you very much for the help. :)
*The text type wants to break on me and not show up right using wikicreole or cursewiki so had to post this in textile :(
Ok I have had a play with it and in order to spawn 4 worms at once and get a continuous stream from each of the worms separately I need to create 4 triggers for spawns, as well as 4 triggers for when the worms die. But this is a whole lot better then the way I was doing it originally. I thank you again for the help :)
Dunno if you figured your own way to do something like this i just figured Id put up something like the way I would do it.
Globals
Spawn Timer Trigger
Random Spawn Function(Type:Action Return:none)
Deactivate Spawn Points
Spawn Units At Active Points Trigger
@SouLCarveRR:
I'm still having some trouble, this time its with the death of the worm. Using the methods of yourself and @s3rius: I have been able to get the worms to spawn when I want from where I want and for them each to have a separate stream of units spawning from them. And the ridiculous amount of variables I would have had to have has been cut to nearly none. But when the worm dies with @s3rius: method there is no way to account for which point died so as to shut off the boolean. And with your method @SouLCarveRR: for some reason I keep getting an error. I have managed to work out that the error is coming from the condition in if TempDistance < TempClosestPoint[i - 1]
It is being flagged as an error in the GE and doesn't compile into the game.
Any insight as to where I might have gone wrong with it will be appreciated. I already appreciate all the help everyone has given so far :)
Found it .... my bad I miss typed something... haha you followed my code pretty good
shoud be
no minus operations
I edited to code in my previous post to reflect this change. Supprised you didnt catch this since you found the line lol.
Though I dont think this would have caused an error. It would have caused this to always fail at what its meant to do.
you have (set NydusPointActive[TempClosestPoint[0]] = false ) in the else statement.... should be on the same level as the if not inside the if
If you still get the error at this point..... take a screen shot of the error in game. Also I would set up some text out puts specifically to see the distance values of Temp distance and the ClosestPoint Array
BTW on a scale of 1-10 ... 10 being good. How well did you understand my logic for all of that. Anything I could do bettter explain more? I did all that off the top of my head before bed last night took about an hour to work through.
@SouLCarveRR: Go
Oh I feel like a fool lol. I tried every combination around that I could think of EXCEPT •if TempDistance < TempClosestPoint[1] . I had it with [i] and it didn't give an error, oh well thats tiredness and working out how things work.
on a scale of 1-10 id say I understood your logic there at about an 8.5ish, I managed to see how everything went along pretty well but I'd say I just got confused and frustrated with the total procedure and then worried about it not working and ruining the whole shebang lol. For all off the top of your head it was pretty spot on.
I didn't understand what you meant with the spawn timer trigger.
But it could just be the way that it came up on here, but I managed to nut it out with the post that @s3rius: had made and your help as well, So I had them all spawning when I wanted and the units spawning from them when they spawned, so it all came together up until the worm dies. But I'll change that bit when I get home and post an update on here, it should fix it now that I look at it. Setting triggers you're not sure of when tired = not always following logically lol. Thank you again for the help :)
Ah the Spawn Timer Trigger is for if you wanted to periodically spawn the random nydus cannals. But from your screen shots I see that you want them to spawn when something gets close to the points from the looks of it.
On that "Spawn Worm" trigger you have a screen shot of..... isnt that an infinite loop you have there?
@SouLCarveRR: Go
I initially thought it would be infinite as well, but it only runs until it recieves a false then it continues on with the rest of the trigger.
I am also setting a size based spawn on it depending on the difficulty so I'm just setting a integer to difficulty and making it repeat the whole procedure difficulty times. Tested this last night and when on difficulty 1 it only ever spawns 1 worm per pass, and 4 for difficulty 4. Having a second trigger for a second area to do the same thing also doesn't produce any erratic results.
Update, I tried that and am now having another problem. I am not having an error message now but I am getting a weird problem. The problem I am having is that when one worm dies it sets off a lot of the others that are still some distance away for some reason. I also had to make an origin point (Nydus[0]) because when I killed the worm at point 1 the stop command didn't run.The duplication effect was happening when the origin point was set to Nydus[1] as well.
I set up a scoreboard to tell me the distance values that are being returned and the boolean value too, to see which ones are being shut off when it runs.
Below is the code as stands for the death trigger and I'll attach a picture with the distances and which ones are changing.
Also are some pictures for when A worm dies, with attached values for Tempclosestpoint[0] Tempclosestpoint[1] and Temp distance.
I only done 3 of the worms and their values after resetting it and killing them, To try and diagnose the problem.
Worm Death
Events
Unit - Any Unit dies
Local Variables
i = 1 <Integer>
TempDistance = 0.0 <Real>
TempClosestPoint = 0.0 <Real[1]>
Conditions
(Unit type of (Triggering unit)) == Nydus Worm (Canal)
Actions
Variable - Set TempClosestPoint[0] = 0.0
Variable - Set TempClosestPoint[1] = (Distance between (Position of (Triggering unit)) and NydusPoints[0])
General - For each integer i from 1 to MaxArrayIndex with increment 1, do (Actions)
Actions
Variable - Set TempDistance = (Distance between (Position of (Triggering unit)) and NydusPoints[i])
General - If (Conditions) then do (Actions) else do (Actions)
If
TempDistance < TempClosestPoint[1]
Then
Variable - Set TempClosestPoint[0] = (Real(i))
Variable - Set TempClosestPoint[1] = TempDistance
Else
Variable - Set Nydus Points in use[(Integer(TempClosestPoint[0]))] = false
The weird thing is that its not stopping ones near the same value in distance, but ones from all over the spectrum.
EDIT
I reduced the max array and active nodes to 5 and when node 5 died it stopped all of them, they had the same distances as in the shots. Thought it might produce different results if I shrunk the active nodes but to no avail.
It returns false if it loops too many times... this is a byproduct of infinite looping in SC2....
Well Id like to help more but you have kinda gone away from the way I would do it.
Your "Spawn Worm" trigger doesnt look logical to me.
and the debug message look like something isnt happening correctly ... if you have other aspects of your map to work on you can go to those. And upload your current map for me to take a look at. Gonna be kinda busy this week end but i could try and take a look. I would need to debug your triggers quite a bit and possibly rework them a little.
Variable - Set Nydus Points in use[(Integer(TempClosestPoint[0]))] = false
this should not be in the ELSE side of the last if like i said in my previous post. Other wise it wont work correctly
Quote@soulcarverr
Variable - Set Nydus Points in use[(Integer(TempClosestPoint[0]))] = false
this should not be in the ELSE side of the last if like i said in my previous post. Other wise it wont work correctly
/quote
Yep, I've moved it to the same line as the if and not in the else, else is just blank at the moment. Just when copied to text it placed it in a line.
If
TempDistance < TempClosestPoint[1]
Then
Variable - Set TempClosestPoint[0] = (Real(i))
Variable - Set TempClosestPoint[1] = TempDistance
Else
Variable - Set Nydus Points in use[(Integer(TempClosestPoint[0]))] = false
I'd like to use your one to randomly spawn units, it just honestly confused the crap outta me.
Although looking at it again I think I have a better idea of whats going on, but would like some clarification on it if you don't mind to see if I am following it right.
The spawn timer runs the spawn trigger and sets the forcepointindex to -1
•parameters
•ForcePointIndex(type:integer) this is so you can pass a specific index to create nydus at
•variables
•TempRan (type:integer) = no point
•i (type:integer)
•actions
•If ForcePointIndex = -1
•Set TempRan = random integer between 0 - MaxArrayIndex
•else
•Set TempRan = ForcePointIndex
•if NydusPointActive[TempRan] = true
•'this is aninvalid point do nothing
•else
•Create Unit NydusCanal at NydusSpawn[TempRan]
•set NydusPointActive[TempRan] = true
So if I set this in a seperate trigger to call upon when the worms are supposed to be spawned (unit enters my region) instead of the timer and have it set the global variable forcepointunit to -1 then the first if will repeat until it recieves a different number (once at max) then it'll continue on. The only problem I saw with this is was that if I made it spawn 4 at once by setting forcepoint to -1 after the fact and putting it inside a repeat 4 times function is that if it came up against a point that already had a worm there it would do nothing, I could be very wrong though. But as it appears to me if I get point 2 on the first run it'll spawn a worm there, then if I return 2 again it will continue on and then just not do anything, so my 2 worms just became one only.
I suppose I could set the trigger to call upon itself if the point returns true and set the difficulty part inside the actual region trigger instead though, since it would have the same effect and not cause infinite loops then. Not at my computer again (quick look at the forum before work :)) but I'll give it a try when I get home, unless I lost some logic in what I just explained.
Oh I also thank you again for the help mate :)
Ok first of all you said your using points ... not regions... if your using regions to spawn the nydus worms I would use a completely different method that doesnt random them. Because well if your having units enter a region to spawn nydus at that region then its not really random right?
The way that trigger is written is that if it randoms a point in use it would basically do nothing. I could change it to handle that ... Ill take a shot at changing the trigger above.
Ok I edited my above trigger for picking the point to spawn at. It will continue to loop looking for a valid random point
several draw backs are
Its not a good idea to use recursive function calling in SC2 I dont think the script engine would care for it a whole lot. well... in the case of where it would call itself 1000 times I dont think it would like it .. but you never know when your randoming stuff how long it will take for a random point to be valid.
Ive done quite a bit of this kinda stuff in my "Infite TD" map where I create random TD paths for 14 different players every time the game starts and every 10 levels I recreate the radom paths. But I verify that none of the points I randomly generate are too close to an existing point.
@SouLCarveRR: Go
Ok I'll give a better explenation of what I am trying to attempt, basically it is a TD map and this function is for the boss spawns, the path is set for everythign to travel on except the units spawned at the nydus which will just head to the end zone in the best path possible form where they are. I have 3 regions along the normal unit path that have the unit enters region & unit = boss wave condtions, when these are met the boss does a cast animation and spawns x amount of worms at x points on the map.
So the condition to set off the worm spawn is differnt from the actual create worms one. The worms are being created at points (I figured it would be easier to control the whole process with points for the worms, but I am seeing now its nowhere near as easy as I had hoped lol) and the regions are just for the condtion to run the placement.
One of the reasons I am trying to get this working preoperly is so I can set up another wave to do the same thing that you said you ahve in your infiite TD map, where it will generate a random pathing different to the normal one, but I will be setting this up for a few specific waves only. Still have a lot of work to go on the map but trigger wise its almost done to a runnable point, which will just leave me data editing and a few other things that I want to add in (which I can see causing more problems too lol) but HOPEFULLY when I'm finished it will be fun and have a good replay factor. Could be though that theres too much to manage at once, but I can just tweak numbers for people to have enough time to mange it all.
@fosere: Go
Im rewriting it right now.... gonna take a bit of time... but it should calc random points better and if say you have only 1 that would be valid... it will just automatically spawn that one.
Alright I re-wrote it.
It may be hard to read because the page is forcing it to line wrap which makes reading some of the variables names are to read if you se [adfasadfas] that basically belongs to the previous line keep and eye on it.
Its unfortunate that I cant turn off the line wrap when writing code. Its a pain in the ass to read once it starts to line wrap
Well that trigger is vastly more complicated now hope you can figure it out.