Hi,
So, this is certainly possible, but I would like to do it without constant calls to check units within regions and so forth.
Imagine a road leading from one edge of the map to the other.
Imagine a continous stream of Hydralisks, with 1000 life. All Hydralisks are on plain Move (so no attack) command from one end to the other.
Imagine 10 marines standing Hold Position in the middle, with 1000 life.
They are hostile towards eachother.
When a Hydralisks walks in to range of an idle marine, a few things happen:
This marine attacks the Hydralisk
The Hydralisk attacks the marine
This marine registers that it should hold this Hydralisk until either it or he dies. So the Hydralisk has been "arrested"/tagged.
All other marines may fire at will, but remain idle so they can arrest their own Hydralisk when possible.
After a while, 10 Marines will stand there fighting 10 Hydralisks to the death while any other Hydralisks will simply walk past.
And I want to do this mostly without the Data editor, at least for the Hydralisk.
The Marine can be modified if needed.
So, my thought was to:
Give all units that spawn on the map a UnitSetCustomValue id=1...N
When a marine TriggerAddEventUnitAcquiredTarget:
Check if any other marines are attacking this target
If so, do not set any customvalue on the marine, but attack the Hydralisk
If not, set a custom value arrested=hydraId, AND set custom value on hydralisk, arrester=marineId
When a Hydralisk dies:
Check if any Marine on the map has set arrested to this Hydras ID. And if so, clear the field (-1).
When a Marine dies:
Put Hydralisk back on Move command.
Now the problem is when a marine is attacking a Hydralisk that is not arrested by him and a new Hydra walks in to range, we do not know about it.
We could, if we used a Region with unit enters, loop through all marines and hydras and cross-check to see who is targetting who.
But imagine this going on 5-10 places on the map, 24/7.
Is that too expensive?
How else should I do this?
Am I just fixated on performance, will it not have any impact at all doing these region checks?
i would use an transient autocast ability which is only active while the marine has no target (through triggers). so once you set the custom value of a marine, you add a behaviour to disable the autocast ability. the ability might issue order to attack it's target right away (might also disable itself right away but then you have to prevent double attack with markers).
transient autocast ability = create a new ability with effect-target and check the flag transient, autocast and autocast on at start. set the arc to 360 and set the target filters accordingly (visible, ground, enemy). now the ability is able to cast even when your unit is doing something else currently.
create 2 new buffs, call it targetbuff and casterbuff
now create a new "issue order", "set" and 2 "apply behaviour" effects. the issue order orders the caster unit to attack the target unit, check the flag alternate. the fst apply behaviour applies targetbuff to the target, the 2nd casterbuff to the caster. the caster behaviour disables the autocast ability. now add all effects to the set effect and then add the set effect to the ability.
now you need an effect for your targetbuff behaviour which removes the caster behaviour on death. create a new remove behaviour effect. set amount to 1 and target to CasterUnit, the buff to your caster buff. add this to the deathresponse of your targetbuff (dont forget to set propability to 1).
do the same for the casterbuff (not sure if removing the buff will work here, so once the marine dies you have to remove the targetbuff from the target with triggers if the effect wont work. not sure if behaviours save the target unit of the ability which casted it, maybe outer-target, you have to test it).
once all this is done you have to create validators for your autocast ability. make one validator to validate the targetbuff on the target, must be 0 or less and one validator for the caster buff on the caster, only when both are 0 the autocast shall work. add the validators to the set effect ( or to the autocast validators on the ability).
now autocast is only casted if the marine is not arresting a unit already and only if the target is not being arrested by any other unit. attacking is not affected unless a unit comes into autocast range, then the target is switched to the target of the autocast.
after you have done all this and it wont work do some tests:
are you able to manually cast the autocast ability? (disable autocast)
are both buffs applied?
are both buffs removed on death of one of the units?
does your ability have a default button?
are you able to cast your ability while moving?
is the removeBuff effect running at all on death?
one of my longest posts, just for you, might have been faster to just create that all for you but you wanted more detail and i dont do both :D
I have attached my map below, it does not work - all marines attack the same target and the buff is only applied sometimes.
I have to go out a bit now but will take a look again when I get back.
The main problem for me is the Data editor is sooooooo laggy. When I click something it takes literally 5+ seconds before anything happens.
When you start the map up, click one of the beacons, select "Barracks", and then place the beacon on the road somewhere close to the barracks. That will create 3 marines, and they will respawn with 1000 HP.
Zerglings are spawned with randomly 500-1000 hp.
They can not be targetted at the moment you need to change that in the Library custom code section.
Everything is in one big bulk of code at the moment because that is easier for me to work with. Once things are more stable I will separate the UI code and the code per tower, etc.
fromUnit - marine u - null for any unit. you can filter friendly units inside trigger function.
There's a small chance that it can be better to attach multiple events with unitref set to the unit you want to track. However i think in this particular map, units you want to track will consist 90% of the total units on the map.. so no point.
When trigger hits you do the same logic you've proposed - custom values for filtering etc. If unit is matched and "arrested" you temporaily destroy the trigger for tracking.
You also need a trigger for UnitDies, global one or created on the run using unitrefs. So you'll know when marine/arrested unit dies.
If marine survives you gotta recreate the trigger for UnitRange.
So basically the main difference is using EventUnitRange instead of EventAcquiredTarget.
Quote:
The main problem for me is the Data editor is sooooooo laggy. When I click something it takes literally 5+ seconds before anything happens.
Yeah data editor is pretty slow. Though the 5 seconds you mention is way too much. Even for maps with full campaign depedencies it shouldn't be so slow. Unless you have shit hardware :p
Aside from the topic, you should stop writing galaxy code in editor. Don't you feel annoyed by poor syntax highlight and lack of basic features? You seem to have experience with coding so you must know that working with a proper editor (autocomplete etc.) makes you much more effiecent and saves your nerves :P
The 5-15 seconds lag when changing things in the Data editor is because I run SC2+Editor through WINE on Linux and the editor is very badly made.
If I have everything in the Data view set to text-mode with list lists of properties and values, it doesn't lag at all, but since I am so inexperienced with it I can never find anything then.
I tried running a virtual machine (both vmware and virtualbox) just for the editor, and that helped a great deal but it's very backwards.
Thank you, I do code in Atom actually and copy+paste to SC2Editor when testing it :-)
I've looked at the other ways of doing it like importing script files with the Import manager and whatever, but my main question then is how I would execute a syntax check of my code without starting up the map?
And also when I hit Save in Atom, would GalaxyEdit automatically update the imports? How do you test the map efficiently?
It is really valuable now because the Galaxy syntax is so fucking weird and I keep forgetting things like implicit casts from fixed/int, variables can't be named "do", or start with _, and all this other crap. So when I copy from Atom and paste in the custom script section there and Ctrl+S for Save in SC2Edit, that checks my code every time.
Haha, i suspected that you might be using linux wine combo. I do myself so i feel your pain actually :) Though it's sometimes not that bad. Filtering entries seems to be the worst..
And yeah editor runs better through VM for me too. But it's just too annyoing to keep switching.. I do it only for longer data work.
So firstly save map in unpacked format. In editor it's called (.SC2 components) in save dialog.
This way you won't have to deal with manual imports and can write scripts directly through the filesystem by just saving to the map directory. Inside a trigger editor just include those scripts in custom blocks.
Syntax check can be run through trigger editor, there's an option for it somewhere in the menu. Shorcut is CTRL+F11 (or F12 - not sure). It will check all the scripts, also those included from the filesystem. If everything is allright you will hear a cool beep :p If no, window with details will popup.
There's no need to re-opening map, editor will refresh files from filesystem on demand. Not the core files though (terrain, data .xml's etc.) as those will always be overwritten during the save.
And that's it. I also keep SC2 open when working. So when i re-run it loads map faster.
Excellent, that is very valuable, thank you. Then I will change over to this method immediately.
Just in case you haven't tried it, vmware runs it a lot smoother than virtualbox. Of course, vmware isn't free.
Haha, i suspected that you might be using linux wine combo. I do myself so i feel your pain actually :) Though it's sometimes not that bad. Filtering entries seems to be the worst..
And yeah editor runs better through VM for me too. But it's just too annyoing to keep switching.. I do it only for longer data work.
So firstly save map in unpacked format. In editor it's called (.SC2 components) in save dialog.
This way you won't have to deal with manual imports and can write scripts directly through the filesystem by just saving to the map directory. Inside a trigger editor just include those scripts in custom blocks.
Syntax check can be run through trigger editor, there's an option for it somewhere in the menu. Shorcut is CTRL+F11 (or F12 - not sure). It will check all the scripts, also those included from the filesystem. If everything is allright you will hear a cool beep :p If no, window with details will popup.
There's no need to re-opening map, editor will refresh files from filesystem on demand. Not the core files though (terrain, data .xml's etc.) as those will always be overwritten during the save.
And that's it. I also keep SC2 open when working. So when i re-run it loads map faster.
If I could pay you $1 for every minute this might save me you would be a very rich man. Why is this kind of thing never stated anywhere? anything useful I've learned about the editor I've just randomly stumbled upon in forums by accident.
Quote:
Don't you feel annoyed by poor syntax highlight and lack of basic features? You seem to have experience with coding so you must know that working with a proper editor (autocomplete etc.) makes you much more effiecent and saves your nerves :P
Actually the only thing I miss is a search function. There's no way to find what you're actually looking for unless you go into Data->view script and the ctrl-f to find it there and then figure out where that is in the code.
Half my project was written in GUI though because I couldn't figure out how to write galaxy script. It was only by accident that I right clicked the bottom left panel of the editor and wondered what all the options were that popped up. This kind of information needs to be the very first thing that comes in any introduction to the editor /rant
It was still not working properly, they would not change targets, so I started changing properties on the Ability that made sense.
I changed "Ability: Acquire Attackers" to enabled, "Ability: Auto Cast Range" to attack range.
And that seems to have fixed it!
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hi, So, this is certainly possible, but I would like to do it without constant calls to check units within regions and so forth.
They are hostile towards eachother.
When a Hydralisks walks in to range of an idle marine, a few things happen:
After a while, 10 Marines will stand there fighting 10 Hydralisks to the death while any other Hydralisks will simply walk past.
And I want to do this mostly without the Data editor, at least for the Hydralisk. The Marine can be modified if needed.
So, my thought was to:
Now the problem is when a marine is attacking a Hydralisk that is not arrested by him and a new Hydra walks in to range, we do not know about it. We could, if we used a Region with unit enters, loop through all marines and hydras and cross-check to see who is targetting who. But imagine this going on 5-10 places on the map, 24/7.
Is that too expensive? How else should I do this? Am I just fixated on performance, will it not have any impact at all doing these region checks?
Thank you :-)
i would use an transient autocast ability which is only active while the marine has no target (through triggers). so once you set the custom value of a marine, you add a behaviour to disable the autocast ability. the ability might issue order to attack it's target right away (might also disable itself right away but then you have to prevent double attack with markers).
Thank you!
I understand 25% of your post. Can someone link me to a relevant tutorial or show me more in detail how this would work?
hmm that's not good.
i try to explain in more detail:
transient autocast ability = create a new ability with effect-target and check the flag transient, autocast and autocast on at start. set the arc to 360 and set the target filters accordingly (visible, ground, enemy). now the ability is able to cast even when your unit is doing something else currently.
create 2 new buffs, call it targetbuff and casterbuff
now create a new "issue order", "set" and 2 "apply behaviour" effects. the issue order orders the caster unit to attack the target unit, check the flag alternate. the fst apply behaviour applies targetbuff to the target, the 2nd casterbuff to the caster. the caster behaviour disables the autocast ability. now add all effects to the set effect and then add the set effect to the ability.
now you need an effect for your targetbuff behaviour which removes the caster behaviour on death. create a new remove behaviour effect. set amount to 1 and target to CasterUnit, the buff to your caster buff. add this to the deathresponse of your targetbuff (dont forget to set propability to 1).
do the same for the casterbuff (not sure if removing the buff will work here, so once the marine dies you have to remove the targetbuff from the target with triggers if the effect wont work. not sure if behaviours save the target unit of the ability which casted it, maybe outer-target, you have to test it).
once all this is done you have to create validators for your autocast ability. make one validator to validate the targetbuff on the target, must be 0 or less and one validator for the caster buff on the caster, only when both are 0 the autocast shall work. add the validators to the set effect ( or to the autocast validators on the ability).
now autocast is only casted if the marine is not arresting a unit already and only if the target is not being arrested by any other unit. attacking is not affected unless a unit comes into autocast range, then the target is switched to the target of the autocast.
after you have done all this and it wont work do some tests:
are you able to manually cast the autocast ability? (disable autocast)
are both buffs applied?
are both buffs removed on death of one of the units?
does your ability have a default button?
are you able to cast your ability while moving?
is the removeBuff effect running at all on death?
one of my longest posts, just for you, might have been faster to just create that all for you but you wanted more detail and i dont do both :D
Thank you for the very long post :-)
I have attached my map below, it does not work - all marines attack the same target and the buff is only applied sometimes. I have to go out a bit now but will take a look again when I get back.
The main problem for me is the Data editor is sooooooo laggy. When I click something it takes literally 5+ seconds before anything happens.
When you start the map up, click one of the beacons, select "Barracks", and then place the beacon on the road somewhere close to the barracks. That will create 3 marines, and they will respawn with 1000 HP.
Zerglings are spawned with randomly 500-1000 hp. They can not be targetted at the moment you need to change that in the Library custom code section. Everything is in one big bulk of code at the moment because that is easier for me to work with. Once things are more stable I will separate the UI code and the code per tower, etc.
I'm unsure about data solution as this is not my area of my experience.
But if you ask for galaxy solution, here's idea: Every created marine shall have its own trigger for arresting units. As event provider use:
fromUnit - marine
u - null for any unit. you can filter friendly units inside trigger function.
There's a small chance that it can be better to attach multiple events with unitref set to the unit you want to track. However i think in this particular map, units you want to track will consist 90% of the total units on the map.. so no point.
When trigger hits you do the same logic you've proposed - custom values for filtering etc. If unit is matched and "arrested" you temporaily destroy the trigger for tracking.
You also need a trigger for UnitDies, global one or created on the run using unitrefs. So you'll know when marine/arrested unit dies.
If marine survives you gotta recreate the trigger for UnitRange.
So basically the main difference is using EventUnitRange instead of EventAcquiredTarget.
Yeah data editor is pretty slow. Though the 5 seconds you mention is way too much. Even for maps with full campaign depedencies it shouldn't be so slow. Unless you have shit hardware :p
Aside from the topic, you should stop writing galaxy code in editor. Don't you feel annoyed by poor syntax highlight and lack of basic features? You seem to have experience with coding so you must know that working with a proper editor (autocomplete etc.) makes you much more effiecent and saves your nerves :P
There's atom package for galaxy (syntax highlight + snippets for native functions). I don't use it myself but i'm sure it's good.
http://www.sc2mapster.com/forums/development/galaxy-scripting-and-trigger-lib/76710-atom-galaxy-language-package/
To use sc2 editor in good workflow with external editor few more things are needed though. I could describe it in details if you are interested.
The 5-15 seconds lag when changing things in the Data editor is because I run SC2+Editor through WINE on Linux and the editor is very badly made. If I have everything in the Data view set to text-mode with list lists of properties and values, it doesn't lag at all, but since I am so inexperienced with it I can never find anything then.
I tried running a virtual machine (both vmware and virtualbox) just for the editor, and that helped a great deal but it's very backwards.
Thank you, I do code in Atom actually and copy+paste to SC2Editor when testing it :-)
I've looked at the other ways of doing it like importing script files with the Import manager and whatever, but my main question then is how I would execute a syntax check of my code without starting up the map? And also when I hit Save in Atom, would GalaxyEdit automatically update the imports? How do you test the map efficiently?
It is really valuable now because the Galaxy syntax is so fucking weird and I keep forgetting things like implicit casts from fixed/int, variables can't be named "do", or start with _, and all this other crap. So when I copy from Atom and paste in the custom script section there and Ctrl+S for Save in SC2Edit, that checks my code every time.
Haha, i suspected that you might be using linux wine combo. I do myself so i feel your pain actually :) Though it's sometimes not that bad. Filtering entries seems to be the worst..
And yeah editor runs better through VM for me too. But it's just too annyoing to keep switching.. I do it only for longer data work.
So firstly save map in unpacked format. In editor it's called (.SC2 components) in save dialog.
This way you won't have to deal with manual imports and can write scripts directly through the filesystem by just saving to the map directory. Inside a trigger editor just include those scripts in custom blocks.
Syntax check can be run through trigger editor, there's an option for it somewhere in the menu. Shorcut is CTRL+F11 (or F12 - not sure). It will check all the scripts, also those included from the filesystem. If everything is allright you will hear a cool beep :p If no, window with details will popup.
There's no need to re-opening map, editor will refresh files from filesystem on demand. Not the core files though (terrain, data .xml's etc.) as those will always be overwritten during the save.
And that's it. I also keep SC2 open when working. So when i re-run it loads map faster.
Excellent, that is very valuable, thank you. Then I will change over to this method immediately. Just in case you haven't tried it, vmware runs it a lot smoother than virtualbox. Of course, vmware isn't free.
If I could pay you $1 for every minute this might save me you would be a very rich man. Why is this kind of thing never stated anywhere? anything useful I've learned about the editor I've just randomly stumbled upon in forums by accident.
Actually the only thing I miss is a search function. There's no way to find what you're actually looking for unless you go into Data->view script and the ctrl-f to find it there and then figure out where that is in the code.
Half my project was written in GUI though because I couldn't figure out how to write galaxy script. It was only by accident that I right clicked the bottom left panel of the editor and wondered what all the options were that popped up. This kind of information needs to be the very first thing that comes in any introduction to the editor /rant
i opened the map. you didnt test as i said, you didnt try to manually cast the ability, otherwise you would have noticed:
there is no default button for the ability
no range set for the ability
issue order not set to caster unit
remove buff was not set to target
all you have to do now is to remove the target buff if the marines dies because removeTarget doesnt work
No, you are right, I didn't test it like you said.
I said in the reply I had to go out for a while and have not done any work in the editor since then.
I am going to now :-)
Oh thank you, this is excellent :-)
It was still not working properly, they would not change targets, so I started changing properties on the Ability that made sense. I changed "Ability: Acquire Attackers" to enabled, "Ability: Auto Cast Range" to attack range.
And that seems to have fixed it!