| 03-13-2010, 12:25 AM | #1 |
Can anyone remake this creep agro system? Iv tried to make sense of it but got lost maybe an experienced Jasser can tackle it? The hardcoded AI of all units (non-neutral) is if the unit is idle (not executing an order), it will attack the closest enemy in its acquisition range (which is not the same as vision range) and continue to attack/persuade until the enemy dies, the unit dies or it gets out of the acquisition range for some time. (There are some other conditions I will not dilate on.) Besides that, there's hardcoded "Call for Help Range" (600), which makes an idle unit attack the enemy if an ally in the range is attacked. This by itself wouldn't make harrasing the opponent more difficult, because allied creeps are occupied fighting the enemy creeps. This is where triggers come in. Everytime a hero (except Bloodstone dummy hero) enters the game, and the hero doesn't have "HeroAIManager" as true, then set "HeroAIManager" for "Hero" as true, create a group of units "Defenders"-"Hero" (empty), save it to the cache and create two new triggers called "OnAttackOrder" and "OnAttacked". The first one is called when "Hero" is ordered to attack (rightclick or "A") a visible enemy non-illusion hero. The second trigger ("OnAttacked") is called when "Hero" is attacked, the attacker is an enemy and the unit saved in cache as "Attacker"-"Hero" is null, dead or the attacker. Then create a new timer called "DefendTimer"-"Hero" and save it to the game cache. "OnAttackOrder" * call function (1) with X = the attacked hero and Y = "Hero" "OnAttacked" * call function (1) with X = "Hero" and Y = the attacker (1) * save Y as "Attacker"-X * count all non-Balista, non-Meat Wagon units that are enemy to Y and their owning player is Player 0 (Sentinel) or Player 6 (Scourge), in 500 AoE from Y and save them to group "g" * order all units in "g" to attack Y, add them to group "Defenders"-X and start "DefendTimer"-X with an expiry time of 2 seconds * when the timer is up, set "Attacker"-X to null and order all units in "g" to attack ground on their next waypoint (there are 5 waypoints and they determine the pathing of creeps to the Tree/Throne, one waypoint is approximately in the middle of each line and other are by the Tree and the Throne) * finally, empty group "Defenders"-X To sum up: * creep aggro lasts for 2 seconds * the attacker gets aggro from all enemy creeps in 500 AoE from him, so you can order an attack command across the map (to a different line for example) and still get aggroed * you get aggro even if you don't click on the enemy, but attack him by autoattack or attack ground command (this is where trigger "OnAttacked" comes in) * trigger "OnAttacked" applies to enemy creeps and neutrals as well (can help with creep pulling) |
