• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

aoe spells

Status
Not open for further replies.
Level 2
Joined
Sep 2, 2008
Messages
13
So I've been trying to find ways to make aoe spells damage enemy units only for a while now, and I still haven't found a way using JASS. I'm just making it simple and damaging a 400 AOE around the caster every .5 seconds, but it would always hurt all units in the AOE including the caster.

I have a group, unit, and location for the spell, but I can't find out what to do with the group after I group the units in the area.

I'd love some help. Thanks
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
  • Set temppoint = (Position of *your unit*)
  • Set temprect = Region centered at (temppoint with size 400, 400)
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in temprect and do: Unit - Order *your unit* to damage (Picked Unit) for 400 damage of type chaos
Like this?
 
Level 2
Joined
Sep 2, 2008
Messages
13
So what type of ability should I use to do this?

An example would be Sand King from DotA, where he uses his ult and it damages ENEMY units around him every .5 second or whatever. I'm using Thunder Clap as my ability, but I have no idea how to make it hit enemy units only.

Here's basically what I have for the group:

local unit caster = GetSpellAbilityUnit()
local location caster_loc = GetUnitLoc(caster)
local group targets = CreateGroup()
call GroupEnumUnitsInRangeOfLoc(targets, caster_loc, 400, null)
call UnitDamageTarget(caster, ***, 100 ...........)

I don't know what to use in order to pick every unit from the group.
 
Level 3
Joined
Feb 13, 2008
Messages
65
You are over complicating this, just dont use JASS and do it the normal GUI way, much easier.

Here is how I would do it:

First of all, if you want this to not be passive ( like permanent immolation) do this:
Trigger 1
  • Events-
    • Unit - A unit begins the the effect of an ability
  • Condition -
    • (ability being cast) Equal to PutNameOfAbilityHere
  • Actions
    • Trigger -Turn on Trigger 2
    • Wait however long you want AoE damage to pulse
    • Trigger -Turn off trigger 2

Trigger 2 (initially off)
  • Events-
    • Time - Every 0.5 seconds of game time
  • Conditions
  • Actions
  • Unit Group - Pick Every unit in (Units within 400 yards of (Position of casting unit <gen>) matching (((Matching unit) belongs to enemy of Player /yourcolor/Equal to True.
    • Loop - Actions
      • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 50))



What this does:

You cast the ability, it checks if the ability is the one that you want the AoE effect to go for, then it turns on trigger 2 which is initially off, and it waits for a certain amount of time which you determine, then turns off. Trigger two makes it so that every 0.5 seconds, any enemies of your color within 400 yards of your unit lose 50 health.
 
Level 6
Joined
Sep 5, 2007
Messages
264
I created this awhile back...

JASS:
function Filter_AlwaysTrue takes nothing returns boolean
    return true
endfunction

function DistanceBetweenPointsXY takes real x, real y, real targ_x, real targ_y returns real
    local real dx = targ_x - x
    local real dy = targ_y - y
    return SquareRoot(dx * dx + dy * dy)
endfunction

function DamageArea takes unit attacker, real x, real y, real radius, real damage, real self, real friend, attacktype a_type, damagetype d_type returns nothing
    local group ug = CreateGroup()
    local unit u
    local player player_owner = GetOwningPlayer(attacker)

    local real damage_percent
    local real dist

    local real targ_x
    local real targ_y

    call GroupEnumUnitsInRange(ug, x, y, radius, Condition(function Filter_AlwaysTrue))

    loop
        set u = FirstOfGroup(ug)
        exitwhen u == null

        if (attacker == u) then
            if (self > 0) then
                // Reaction to Self
                set targ_x = GetUnitX(u)
                set targ_y = GetUnitY(u)
                set dist = DistanceBetweenPointsXY(x,y,targ_x,targ_y)
                if (dist < 1) then
                    set damage_percent = damage
                else
                    set damage_percent = (dist / radius) * damage
                endif
                call UnitDamageTarget(attacker, u, damage_percent * self, true, true, a_type, d_type, WEAPON_TYPE_WHOKNOWS)
            endif
        elseif (IsUnitEnemy(u, player_owner)) then
        // Reaction to Enemies
            set targ_x = GetUnitX(u)
            set targ_y = GetUnitY(u)
            set dist = DistanceBetweenPointsXY(x,y,targ_x,targ_y)
            if (dist < 1) then
                set damage_percent = damage
            else
                set damage_percent = (dist / radius) * damage
            endif
            call UnitDamageTarget(attacker, u, damage_percent, true, true, a_type, d_type, WEAPON_TYPE_WHOKNOWS)
        elseif (friend > 0) then
        // Reaction to Friendlies
            set targ_x = GetUnitX(u)
            set targ_y = GetUnitY(u)
            set dist = DistanceBetweenPointsXY(x,y,targ_x,targ_y)
            if (dist < 1) then
                set damage_percent = damage
            else
                set damage_percent = (dist / radius) * damage
            endif
            call UnitDamageTarget(attacker, u, damage_percent * friend, true, true, a_type, d_type, WEAPON_TYPE_WHOKNOWS)
        endif

        call GroupRemoveUnit(ug, u)
        set u = null
    endloop

    set player_owner = null

    call DestroyGroup(ug)
    set ug = null
endfunction

This sounds like what you are after. A JASS way of doing it, all you have to do is call:
DamageArea(attacker, x,y, radius, damage, <% self damage>, <% friendly damage>, attack_type, damage_type)

% self/friendly damage in your case would be 0, no friendly fire with no damage to caster.

Damage given decreases with distance from caster... how far away target is, divided by radius.
EG: radius 400...
distance to a target is 200, that target gets 50% of the damage amount.
distance to another target is 100, that target gets 25% of the damage amount.

But, I can alter this if you want 100% to all victims, irrelevant of distance.

Hope I've been helpful.
 
Last edited:
Level 6
Joined
Sep 5, 2007
Messages
264
Updated code due to leak...

I edited that previous post to update my code, apparently I had a leak in there that I'd didn't know about...

@peekuhchew1:
No problem. I just hope that I've got that code working to its maximum, if not, I can change it.

@Captain_Griffen:
I'm not sure if what I've changed will completely stop that leak, but if I still leak can you give me a brief JASS example of what you meant earlier, and I'll fix it as soon as I read it... Thanx.
 
Status
Not open for further replies.
Top