If any enemy unit is standing close to the Zealot and attacking it, the Zealot receives only 50% of the damage.
So if the Zealot is close to a group of Hydras, the Zealot receives less damage from the closest Hydras. The Zealot receives full damage from the Hydras further away.
So as long as Zealots are close to enemy units, they receive less damage from the nearby enemies.
You need to give each unit you want to use two weapons. One weapon only works at melee range, and the other one only works at a certain range.
The hydralisk has this already. The damage is the same, but depending on the range, the unit will either fire projectiles, or use its arms to attack melee enemies.
The big problem, of course, is that it requires a lot of work. You need to duplicate each weapon and need to change the actor events of the unit's actor to use animations for the new weapon as well. But otherwise it's doable.
PS: You can hide weapons, so the game only shows the weapon with the ranged attack, but not the melee range weapon. There should be an option for this in the weapon flag.
Looks like you need to apply a buff to the hydralisks with a damage response on attacker that applies a damage response on defender to the caster with a very short duration.
Another route is to use a switch effects with range validators on each case. You can set as many ranges as you likes for a fully dynamic damage amounts. I like to use a switch because you might decide you want other amounts of damage applied.
On the Impact effect of the Hydralisk missile, use a Switch Effect instead of the default damage amount. For your needs you only need to types of damage effects the standard full amount and the 50% amount. Then setup a range validator on the 50% amount that checks the distance of the target from the caster.
For the full amount of damage you can put the default hydra damage effect on the Default Field in the Switch effect.
Let's use the Zealot as an example.
If any enemy unit is standing close to the Zealot and attacking it, the Zealot receives only 50% of the damage.
So if the Zealot is close to a group of Hydras, the Zealot receives less damage from the closest Hydras. The Zealot receives full damage from the Hydras further away.
So as long as Zealots are close to enemy units, they receive less damage from the nearby enemies.
Any ideas how to build this?
You need to give each unit you want to use two weapons. One weapon only works at melee range, and the other one only works at a certain range.
The hydralisk has this already. The damage is the same, but depending on the range, the unit will either fire projectiles, or use its arms to attack melee enemies.
The big problem, of course, is that it requires a lot of work. You need to duplicate each weapon and need to change the actor events of the unit's actor to use animations for the new weapon as well. But otherwise it's doable.
PS: You can hide weapons, so the game only shows the weapon with the ranged attack, but not the melee range weapon. There should be an option for this in the weapon flag.
Looks like you need to apply a buff to the hydralisks with a damage response on attacker that applies a damage response on defender to the caster with a very short duration.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
Another route is to use a switch effects with range validators on each case. You can set as many ranges as you likes for a fully dynamic damage amounts. I like to use a switch because you might decide you want other amounts of damage applied.
On the Impact effect of the Hydralisk missile, use a Switch Effect instead of the default damage amount. For your needs you only need to types of damage effects the standard full amount and the 50% amount. Then setup a range validator on the 50% amount that checks the distance of the target from the caster.
For the full amount of damage you can put the default hydra damage effect on the Default Field in the Switch effect.
Thanks for all suggestions!