So I'm trying to make units not attack if building is on the way. Tried comparing pathing cost with distance between points but it didnt work... any ideas?
Your question seems a bit ambiguous. Are you trying to actually prevent attacking, or are you trying to fix an issue with pathing?
It sounds like the latter, so one trick I've seen people use is to create a dummy unit at the starting point, make it invisible, then issue a move command to the desired end point to find the most optimal route for the unit to take while avoiding obstacles. If you then wanted to have a unit attack in the same pattern, you could periodically save the location of your dummy unit then issue a series of attack orders to your playable unit to those respective saved locations.
I imagine the best way to do this is to turn your buildings into line of sight blockers, which can be done by modifying the unit's footprint in the data editor. Very quick step by step: open the unit's footprint, select the placement apply and placement check layers, click define sets, and check block vision.
If you need a more thorough explanation, just search around for "block line of sight" and you'll get a lot of results.
Plus that'll only work for missile attacks and not for something like the marine's gun. I had thought about mentioning OneTwo's fire diablo spell tutorial until I remembered that.
this solves your issue, just add a validator to your first effect. there are more post here on sc2mapster about this. i attached a map for space marines, where they couldn'T attack if another space marines is infront of the unit. too lazy to search so here is the link to the validator you will need..
Unit just attacks without dealing damage, which is not what i'm looking for. I'd like my unit to move to target until there is nothing on the way so it can attack freely.
[edit]
I found a solution to this problem. Funny enough it's your very post! And there is the map. Perhaps this is one you tried to share with me?
So I'm trying to make units not attack if building is on the way. Tried comparing pathing cost with distance between points but it didnt work... any ideas?
Your question seems a bit ambiguous. Are you trying to actually prevent attacking, or are you trying to fix an issue with pathing?
It sounds like the latter, so one trick I've seen people use is to create a dummy unit at the starting point, make it invisible, then issue a move command to the desired end point to find the most optimal route for the unit to take while avoiding obstacles. If you then wanted to have a unit attack in the same pattern, you could periodically save the location of your dummy unit then issue a series of attack orders to your playable unit to those respective saved locations.
I'm trying to make realistic map where units can't shoot when there are buildings between them and target.
I imagine the best way to do this is to turn your buildings into line of sight blockers, which can be done by modifying the unit's footprint in the data editor. Very quick step by step: open the unit's footprint, select the placement apply and placement check layers, click define sets, and check block vision.
If you need a more thorough explanation, just search around for "block line of sight" and you'll get a lot of results.
Thanks, that was second thing i was going to do. But they still can shoot through if other unit sees enemy.
maybe give the missiles a behavior that checks if they are within say .1 range of a building, if so have the missile die.
unfortunately this will not stop the units from attempting to attack across buildings and will only apply to units with missile attacks.
@joey101d: Go
Plus that'll only work for missile attacks and not for something like the marine's gun. I had thought about mentioning OneTwo's fire diablo spell tutorial until I remembered that.
this solves your issue, just add a validator to your first effect. there are more post here on sc2mapster about this. i attached a map for space marines, where they couldn'T attack if another space marines is infront of the unit. too lazy to search so here is the link to the validator you will need..
http://www.sc2mapster.com/forums/development/data/75775-solved-validate-if-a-unit-is-between-caster-and-target/
Unit just attacks without dealing damage, which is not what i'm looking for. I'd like my unit to move to target until there is nothing on the way so it can attack freely. [edit] I found a solution to this problem. Funny enough it's your very post! And there is the map. Perhaps this is one you tried to share with me?
http://www.sc2mapster.com/forums/development/data/77180-prevent-units-from-shooting-over-each-other-picture/#p9