I dont think theres a built in event for this specifically, but im not 100% positive. You could of course keep track of every unit manually and detect when a unit has a new owner, but thats not very elegant. You could probably make a "custom event" yourself to do it, as shown here: http://rileystarcraft.blogspot.com/2010/06/tutorial-create-custom-trigger-hooks.html However, if you are using triggers to change unit ownership, wouldnt it be much easier to put your code there, or are you doing it some other way or something?
Yeah you dont explain very well at all exactly what you mean by connect the dots. Is the user supposed to pick 2 dots to connect, and need to draw lines between them and only "unlock" when a door outline is made, or what? Either way, seems like it could be done pretty easily to me.
You can do this purely in the data editor too, its really simple and does what you want. And since this is so simple you really should use the data editor instead of a trigger so you have one less trigger running and hurting performance, this way is more efficient. I assume you already have your ability set up somewhere with a button that you click in game?
Then just go to data editor, go to the"Effects" data type tab, right-click the top-left list box and choose "Add Object...". Name it like "Add Minerals" and click the suggest button, then in the "Effect Type:" drop down box, choose "Modify Player" and click OK. Now make sure you have table view selected (menu View->Show Table View, its just easier) and select the newly created "Add Minerals" effect on the left if it isnt already. Now look at the table on the right, find the "Effect - Resources" field, double click the cell next to it, choose Minerals, and type the value you want in the box below, and hit OK. Now go to the "Abilities" data type tab and select your ability. Make sure its of the type "Effect - Instant", if it isnt, double click it and you can change the ability type. Now double click next to the "Effect - Effect" field, click the green button to add a new entry, find "Add Minerals" in the list, hit ok, and should be all set to go.
Seems like alot, but thats only because I explained every step. Takes like 10 seconds.
I figured out a crude work around for disabling purchasing items from a shop if your heroes inventory is full. This works with one player, might need to be modified for multiple heroes/players slightly, im sure some other people can improve on this greatly.
I created a Hero Inventory Full Buff that utilizes a Search Area effect that applies the buff onto nearby neutral structure/etc (the shop), use filter to filter out everything but the shops. So thats a Behavior buff, a search area effect, and an apply behavior effect so far. Then I made a requirement InventoryNotFull that does (!CountBehavior(HeroInventoryFullBuff,CompleteOnlyAtUnit)). Then change the shop item commands to use this requirement. So when the heros inventory is full, he gets the inventory full buff, which scans small area around him and applies it also to any shops, when you try to use the shop with inventory full, it requires itself to NOT have the buff so you cant buy anything. Clear an inventory space and the buff goes away. Then I made a trigger:
I had empty slots < 6 because I was using Bifuu's hero tutorial map and it has 5 slots that regular items cant be put into so. Also I was still fooling around with how exactly to apply and remove the buff from the shop and stuff since I couldnt figure out how to have the shop check the hero for the buff instead of itself. But anyways, like I said, this works like a charm for 1 hero/1 player, besides the removing from the shop every 2 seconds that is. Put a low period on the search area effect. Using this way each player and hero would have to have their own buff type so they could be distinguished, unless a slightly more clever way of distinguishing when the hero has the buff is made, but I dont want to spend the time heh. The function to get inventory items is:
UnitInventoryCount(unitUnit,intCountType);WhereUnitisthehero,andCountTypeisanintegerofoneofthefollowing:c_unitInventoryCountCarried=0;// Number of carried itemsc_unitInventoryCountEmpty=1;// Number of item slots openc_unitInventoryCountTotal=2;// I assume this is total number of inventory slots
This should work. Just change the loop increment to how many you want spawned, the variable x controls how much resources it gets, and the point/offsets determine position, etc.
I havent been able to reproduce your problem lol. All of my < and > show up correctly, even inside of a colored tag. I used UI - Display text to display a text variable that i set to some random letters and <> and tags and it comes out perfectly fine. Even a regular string does too. Not sure why it isnt working for you, perhaps its the way you are doing it or the functions you are using? Also you could try StringToText("bl<a>h") and see if that works for you.
Seems like your best bet to me would be to write a custom function to procedurally generate all the regions for you since you know where they need to be. You could have a 2 dimensional region array to store the intersections and write a loop that loops from 0 to 12, (or 0 to 11 depending on how exactly youre defining the intersections, basically however many there are) then another loop inside that one that loops the same. Then in the innermost loop calculate the new region position based on say i and j (the loop counters), then use something like convert rectangle to region based on those variables and a hard coded width/height and set the Regions[i][j] = to that region. Now you have 144 regions with a few lines of code and can use them in your triggers. Also if you didnt mind using circles you could make it slightly simpler and make the array points instead of regions and store a single point for each intersection then use the trigger unit enters within X of point[][].
Not sure exactly how you would set up the triggers in a nice way using the array, since i havent played around with triggers much yet, but im sure there is a solution like above where you could write a minimal amount of code to handle it all, im not sure.
Wouldnt this be much more efficient and work better?
Make a global variable BeaconUnit of type Unit. Set it to the beacon you want to use this for. Create a trigger like before, but instead of Any Unit, use BeaconUnit, and in actions set the variable. Then copy that trigger to a new one, and change "Selected" to "Deselected" and change the boolean from true to false, done. Not sure if this works, but seems like it would and be exactly what you want, without running a trigger for EVERY unit selected too.
Have you tested this outside of that trigger? For example, create a new trigger with only that in it, or change that trigger and wait for a unit to die, but use the hard coded player number instead: Leaderboard - Minimize Leaderboard for (Player group(1)) and see if that still minimizes for all players? If it does then it would seem its the minimize function itself, but if not then its your trigger thats to blame.
I would imagine you should be able to. I havent tried to decrypt what youre trying to do from the mess above too much so im not sure exactly on the problem, but it seems to me that this block of text:
is part of the first if..then..else statement and that is why its being triggered for everyone because its being told to.
That what it seems like anyways. Either way, my advice to you is to disable that large trigger, make a new one to use, and strip it down to only what the problem is so you can better see what is happening, then come back with that so its not cluttered with the rest of your stuff. Also you can look at the script code perhaps to get a more clean look at the logic.
Edit: Also you could add in some debugging messages in places to see how the code is being run, for example, by the leaderboard minimize action, put a UI Display message action for example that spits out some variables, like the owner of triggering unit, etc, that way you can see where the problem is.
Deku, I think something such as this is what you are looking for, quite simple really (make sure you play around with events/actions, search for functions youre looking for, etc.)
Make a global variable say PlayerUnits of type Unit, make it an array of size 15 (1 for each possible player, doesnt matter how many players you actually are going to have):
PlayerUnits=NoUnit<Unit[15]>
In your trigger where you spawn the unit for a player, make an action that adds that unit to the variable, something like:
Im not sure if this next part works exactly, but it would be something very similar if not. Make a new trigger, Player Unit Dies or whatever. Make the event:
Thanks. I just tried playing around with some action definitions, but I didn't foresee it stalling the trigger until the actions were complete. Is there any way to continue a trigger without waiting until action definition finishes?
Perhaps try making the action definition its own "thread". Click the action definition its in the list of checkbox options (create thread). Not sure if this will do the trick, but may.
0
@Fullachain: Go
I dont think theres a built in event for this specifically, but im not 100% positive. You could of course keep track of every unit manually and detect when a unit has a new owner, but thats not very elegant. You could probably make a "custom event" yourself to do it, as shown here: http://rileystarcraft.blogspot.com/2010/06/tutorial-create-custom-trigger-hooks.html However, if you are using triggers to change unit ownership, wouldnt it be much easier to put your code there, or are you doing it some other way or something?
0
@ctccromer: Go
Yeah you dont explain very well at all exactly what you mean by connect the dots. Is the user supposed to pick 2 dots to connect, and need to draw lines between them and only "unlock" when a door outline is made, or what? Either way, seems like it could be done pretty easily to me.
0
@LeetBox: Go
You can do this purely in the data editor too, its really simple and does what you want. And since this is so simple you really should use the data editor instead of a trigger so you have one less trigger running and hurting performance, this way is more efficient. I assume you already have your ability set up somewhere with a button that you click in game?
Then just go to data editor, go to the"Effects" data type tab, right-click the top-left list box and choose "Add Object...". Name it like "Add Minerals" and click the suggest button, then in the "Effect Type:" drop down box, choose "Modify Player" and click OK. Now make sure you have table view selected (menu View->Show Table View, its just easier) and select the newly created "Add Minerals" effect on the left if it isnt already. Now look at the table on the right, find the "Effect - Resources" field, double click the cell next to it, choose Minerals, and type the value you want in the box below, and hit OK. Now go to the "Abilities" data type tab and select your ability. Make sure its of the type "Effect - Instant", if it isnt, double click it and you can change the ability type. Now double click next to the "Effect - Effect" field, click the green button to add a new entry, find "Add Minerals" in the list, hit ok, and should be all set to go.
Seems like alot, but thats only because I explained every step. Takes like 10 seconds.
0
@Jinxxx123: Go
I figured out a crude work around for disabling purchasing items from a shop if your heroes inventory is full. This works with one player, might need to be modified for multiple heroes/players slightly, im sure some other people can improve on this greatly.
I created a Hero Inventory Full Buff that utilizes a Search Area effect that applies the buff onto nearby neutral structure/etc (the shop), use filter to filter out everything but the shops. So thats a Behavior buff, a search area effect, and an apply behavior effect so far. Then I made a requirement InventoryNotFull that does (!CountBehavior(HeroInventoryFullBuff,CompleteOnlyAtUnit)). Then change the shop item commands to use this requirement. So when the heros inventory is full, he gets the inventory full buff, which scans small area around him and applies it also to any shops, when you try to use the shop with inventory full, it requires itself to NOT have the buff so you cant buy anything. Clear an inventory space and the buff goes away. Then I made a trigger:
Global vars:
Trigger:
I had empty slots < 6 because I was using Bifuu's hero tutorial map and it has 5 slots that regular items cant be put into so. Also I was still fooling around with how exactly to apply and remove the buff from the shop and stuff since I couldnt figure out how to have the shop check the hero for the buff instead of itself. But anyways, like I said, this works like a charm for 1 hero/1 player, besides the removing from the shop every 2 seconds that is. Put a low period on the search area effect. Using this way each player and hero would have to have their own buff type so they could be distinguished, unless a slightly more clever way of distinguishing when the hero has the buff is made, but I dont want to spend the time heh. The function to get inventory items is:
Hope this helps some of you to improve on this.
0
@RobertMinson: Go
This should work. Just change the loop increment to how many you want spawned, the variable x controls how much resources it gets, and the point/offsets determine position, etc.
0
@Thalassicus: Go
I havent been able to reproduce your problem lol. All of my < and > show up correctly, even inside of a colored tag. I used UI - Display text to display a text variable that i set to some random letters and <> and tags and it comes out perfectly fine. Even a regular string does too. Not sure why it isnt working for you, perhaps its the way you are doing it or the functions you are using? Also you could try StringToText("bl<a>h") and see if that works for you.
0
@kaji2: Go
Seems like your best bet to me would be to write a custom function to procedurally generate all the regions for you since you know where they need to be. You could have a 2 dimensional region array to store the intersections and write a loop that loops from 0 to 12, (or 0 to 11 depending on how exactly youre defining the intersections, basically however many there are) then another loop inside that one that loops the same. Then in the innermost loop calculate the new region position based on say i and j (the loop counters), then use something like convert rectangle to region based on those variables and a hard coded width/height and set the Regions[i][j] = to that region. Now you have 144 regions with a few lines of code and can use them in your triggers. Also if you didnt mind using circles you could make it slightly simpler and make the array points instead of regions and store a single point for each intersection then use the trigger unit enters within X of point[][].
Not sure exactly how you would set up the triggers in a nice way using the array, since i havent played around with triggers much yet, but im sure there is a solution like above where you could write a minimal amount of code to handle it all, im not sure.
0
@Quickshot14: Go
Wouldnt this be much more efficient and work better?
Make a global variable BeaconUnit of type Unit. Set it to the beacon you want to use this for. Create a trigger like before, but instead of Any Unit, use BeaconUnit, and in actions set the variable. Then copy that trigger to a new one, and change "Selected" to "Deselected" and change the boolean from true to false, done. Not sure if this works, but seems like it would and be exactly what you want, without running a trigger for EVERY unit selected too.
0
@Zero0018: Go
Have you tested this outside of that trigger? For example, create a new trigger with only that in it, or change that trigger and wait for a unit to die, but use the hard coded player number instead: Leaderboard - Minimize Leaderboard for (Player group(1)) and see if that still minimizes for all players? If it does then it would seem its the minimize function itself, but if not then its your trigger thats to blame.
0
I would imagine you should be able to. I havent tried to decrypt what youre trying to do from the mess above too much so im not sure exactly on the problem, but it seems to me that this block of text:
is part of the first if..then..else statement and that is why its being triggered for everyone because its being told to.
That what it seems like anyways. Either way, my advice to you is to disable that large trigger, make a new one to use, and strip it down to only what the problem is so you can better see what is happening, then come back with that so its not cluttered with the rest of your stuff. Also you can look at the script code perhaps to get a more clean look at the logic.
Edit: Also you could add in some debugging messages in places to see how the code is being run, for example, by the leaderboard minimize action, put a UI Display message action for example that spits out some variables, like the owner of triggering unit, etc, that way you can see where the problem is.
0
@Dekuleaf: Go
Deku, I think something such as this is what you are looking for, quite simple really (make sure you play around with events/actions, search for functions youre looking for, etc.)
Make a global variable say PlayerUnits of type Unit, make it an array of size 15 (1 for each possible player, doesnt matter how many players you actually are going to have):
In your trigger where you spawn the unit for a player, make an action that adds that unit to the variable, something like:
Im not sure if this next part works exactly, but it would be something very similar if not. Make a new trigger, Player Unit Dies or whatever. Make the event:
Now in the actions, respawn the unit.
0
Perhaps try making the action definition its own "thread". Click the action definition its in the list of checkbox options (create thread). Not sure if this will do the trick, but may.