Im making a game that uses Squadrons. A squadron is a group of units. When the units are created, I save them in a unit group array called squadrons. It's a 2 dimensional array, first array holds the player, second holds the uniqe ID of the squadron, 15 is max. But when I'm trying to acces one of these squadron through a Pick each Integer it dosent work. It says trough a debug message that it works, but it dosent select the squadron!
Link Removed: http://www.mediafire.com/download.php?6bszrh7c5r9r671
You're using a For Each loop and the Picked Integer function. The Picked Integer function only works when you use a Pick Each Integer loop. Change Picked Integer to the variable "ID".
You're using a For Each loop and the Picked Integer function. The Picked Integer function only works when you use a Pick Each Integer loop. Change Picked Integer to the variable "ID".
I made the quick little fix and I get these warnings:
[6/15/20128:30:53AM]Warning:EmptytriggerelementreferenceremovedfromFunctionCall'If Then Else'[6/15/20128:30:53AM]Warning:Orphanedtriggersub-functioncallremoved:FunctionCall'For Each Integer'(FunctionCall,5D031359,Lib:0)[6/15/20128:30:53AM]Warning:InvalidtriggerelementreferenceremovedfromFunctionCall'Return'(ParameterValue,EDFD975B,Lib:0)[6/15/20128:30:53AM]Warning:Invalidsub-functiontypereferenceremovedfromFunctionCall'Return'(Sub-FunctionType,00000004,Lib:Ntve)[6/15/20128:30:53AM]Warning:InvalidtriggerelementreferenceremovedfromFunctionCall'Unit In Unit Group'(ParameterValue,5F6813E6,Lib:0)[6/15/20128:30:53AM]Warning:InvalidtriggerelementreferenceremovedfromFunctionCall'Unit In Unit Group'(ParameterValue,F4D369DC,Lib:0)
It's easier if you select the functions inside the trigger, right click and select "Copy As Text." Then paste them in a reply here, wrapping them in code tags. Like this (replacing the 0 with an o):
General-ForeachintegerIDfrom1to15withincrement1,do(Actions)ActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(UnitisinSquadrons[(Triggeringplayer)][ID])==TrueThenGeneral-ReturnIDVariable-SetNotFound=FalseDebug-Display"SquadronID Found"asdebugoutputusingType1,andDodisplayitinthegamewindowGeneral-SkipremainingactionsElseGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfNotFound==TrueThenGeneral-Return0Variable-SetNotFound=FalseDebug-Display"Warning: Squadron ID Could not be f..."asdebugoutputusingType1,andDodisplayitinthegamewindowElseGeneral-Return0
I know it saves the variable(displays through a debug message) but I never get this message:
Debug - Display "SquadronID Found" as debug output using Type 1, and Do display it in the game window
So something there must be wrong :(
EDIT: I fixed the error, but it still dosent work :(
What's is with the return action (these are for functions not triggers). I think you looking to set a local variable instead. (sorry wasn't looking at map)
Get ID of Squadron
Options: Function
Return Type: Integer
Parameters
Unit = No Unit <Unit>
Grammar Text: Get ID of Squadron the Unit is in!
Hint Text: (None)
Custom Script Code
Local Variables
ID = 0 <Integer>
NotFound = True <Boolean>
Actions
General - For each integer ID from 1 to 15 with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Unit is in Squadrons[(Triggering player)][ID]) == True
Then
General - Return (Picked integer)
Variable - Set NotFound = False
Debug - Display "SquadronID Found" as debug output using Type 1, and Do display it in the game window
General - Skip remaining actions
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
NotFound == True
Then
General - Return 0
Variable - Set NotFound = False
Debug - Display "Warning: Squadron ID Could not be f..." as debug output using Type 1, and Do display it in the game window
Else
General - Return 0
I see more issues. You can't return "picked integer" with a "for each" loop. Set it to the variable instead. Also you can cut down the second half as the if then is not needed - just put it all in the end return. Your action order is messed up too. The return has to be the last thing as it auto skips everything after. In the first loop put the return ID as the 4th action and the return 0 in the last section at the very end.
Well i rechecked your map from post 5 and all the issues i found are still there. The only thing you fixed was the first picked integer in the loop. There's a second thats wrong too as well as the order is the same if not worse. Please repost the text from the trigger here from the actual recent map.
Okay, thats a bit better. So far the biggest issue i found is that in the "create squad" your is modifying the wrong variable. Its using a local instead of the global so that the group always puts itself into the first one and then restarts. It also uses last created units but you do not have any parameter or anything at all to say which units. I suspect you will also run into the issue if you do use last created units with a parameter that you'll run into the issue that your last unit was 1 leader and not the group. You will need to add these to a local group variable then have that as the parameter.
I have to say your triggering is very messy and its not always too clear what your trying to accomplish. Also in the "get ID from squad" why are you setting a varialbe to false but very actually using it. And again you do not need the skip remain actions after the ruturn action.
Hmmmm... Thx for everything. :) It finally worked.
But there are a few bugs:
- When I select one marine, wait and then select him again, the whole Squad will be deselected and onyl him will be selected.
- The marine running from the Squadron Command is buggy. When I select him, he will select the others in the squadron. When I later select another marine, everyone except the Marine from the Squadron Cmd is selected.
It must be a easier way to do this, like making all units run from the building.
Downloaded your map from post #13. Mistakes I found:
You are modifying a parameter 'squadroncount' +1 and not your variable, like you should be
You should never, never, EVER, use "triggering player" inside an action definition. Don't do it. Make a player paramater and put the triggering player in there when you call the action def (you did this in both the action def and the function def)
You don't need a 'skip remaining actions' after a return (Skip remaining actions actually just returns a null value).
You never actually add your squadron units into your squadron group, yet you try to locate a squadron ID based off whether or not they're in your group
Your squadronID global variable holds no purpose
After I made the changes listed above, it worked. I attached the fixed map below.
Hey! I got a problem/question!
Im making a game that uses Squadrons. A squadron is a group of units. When the units are created, I save them in a unit group array called squadrons. It's a 2 dimensional array, first array holds the player, second holds the uniqe ID of the squadron, 15 is max. But when I'm trying to acces one of these squadron through a Pick each Integer it dosent work. It says trough a debug message that it works, but it dosent select the squadron! Link Removed: http://www.mediafire.com/download.php?6bszrh7c5r9r671
I didn't look at it too much, but this is definitely a problem:
You're using a For Each loop and the Picked Integer function. The Picked Integer function only works when you use a Pick Each Integer loop. Change Picked Integer to the variable "ID".
@BasharTeg: Go
I made the quick little fix and I get these warnings:
Please post your updated trigger so I may take a look.
@BasharTeg: Go
Here it is
It's easier if you select the functions inside the trigger, right click and select "Copy As Text." Then paste them in a reply here, wrapping them in code tags. Like this (replacing the 0 with an o):
@BasharTeg: Go
I know, I did it whit the error messages :P
Anyways here is the Get ID function:
And here is the Selection trigger:
I know it saves the variable(displays through a debug message) but I never get this message: Debug - Display "SquadronID Found" as debug output using Type 1, and Do display it in the game window So something there must be wrong :(
EDIT: I fixed the error, but it still dosent work :(
@AwesomeGod: Go
Hello, This is my new account(I am AwesomeGod)
I'll look into you map and get back to you.
What's is with the return action (these are for functions not triggers). I think you looking to set a local variable instead. (sorry wasn't looking at map)
Get ID of Squadron Options: Function Return Type: Integer Parameters Unit = No Unit <Unit> Grammar Text: Get ID of Squadron the Unit is in! Hint Text: (None) Custom Script Code Local Variables ID = 0 <Integer> NotFound = True <Boolean> Actions General - For each integer ID from 1 to 15 with increment 1, do (Actions) Actions General - If (Conditions) then do (Actions) else do (Actions) If (Unit is in Squadrons[(Triggering player)][ID]) == True Then General - Return (Picked integer) Variable - Set NotFound = False Debug - Display "SquadronID Found" as debug output using Type 1, and Do display it in the game window General - Skip remaining actions Else General - If (Conditions) then do (Actions) else do (Actions) If NotFound == True Then General - Return 0 Variable - Set NotFound = False Debug - Display "Warning: Squadron ID Could not be f..." as debug output using Type 1, and Do display it in the game window Else General - Return 0
I see more issues. You can't return "picked integer" with a "for each" loop. Set it to the variable instead. Also you can cut down the second half as the if then is not needed - just put it all in the end return. Your action order is messed up too. The return has to be the last thing as it auto skips everything after. In the first loop put the return ID as the 4th action and the return 0 in the last section at the very end.
@hobbidude:
Actually I fixed those issues in the updated map here:
http://www.sc2mapster.com/forums/development/triggers/38282-trigger-problem/#p5
Thx anyway!
Well i rechecked your map from post 5 and all the issues i found are still there. The only thing you fixed was the first picked integer in the loop. There's a second thats wrong too as well as the order is the same if not worse. Please repost the text from the trigger here from the actual recent map.
@hobbidude:
Sorry, I was tierd when I wrote that. I fixed the stuff and heres the updated map(it still dosent work)
Okay, thats a bit better. So far the biggest issue i found is that in the "create squad" your is modifying the wrong variable. Its using a local instead of the global so that the group always puts itself into the first one and then restarts. It also uses last created units but you do not have any parameter or anything at all to say which units. I suspect you will also run into the issue if you do use last created units with a parameter that you'll run into the issue that your last unit was 1 leader and not the group. You will need to add these to a local group variable then have that as the parameter.
I have to say your triggering is very messy and its not always too clear what your trying to accomplish. Also in the "get ID from squad" why are you setting a varialbe to false but very actually using it. And again you do not need the skip remain actions after the ruturn action.
@hobbidude:
Hmmmm... Thx for everything. :) It finally worked.
But there are a few bugs:
- When I select one marine, wait and then select him again, the whole Squad will be deselected and onyl him will be selected.
- The marine running from the Squadron Command is buggy. When I select him, he will select the others in the squadron. When I later select another marine, everyone except the Marine from the Squadron Cmd is selected.
It must be a easier way to do this, like making all units run from the building.
Edit- And you figured it out without me... :P
Downloaded your map from post #13. Mistakes I found:
After I made the changes listed above, it worked. I attached the fixed map below.
@zeldarules28:
Thx Anyway :D