HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trigger based AOE targets

07-30-2007, 09:57 PM#1
TurtleGlove
Hey, I'm making a "Corpse Explosion" spell and it works perfectly, except for the fact that it also damages allies. I have it built in GUI and it's based off of raise dead. You cast raise dead, and triggers create the explosion effect and have the spell caster deal damage in a circular area around the target of the ability being cast. The only problem with it is it deals damage to the caster and allied units also. I've tried assigning units to a group, and then dealing damage to that group, but I couldn't get it to work, if this method does work could someone help me figure out what I did wrong? Also, if there is a way to set which units are damaged in the "Unit- Cause unit to deal damage in an area" trigger, where is it?
07-30-2007, 10:22 PM#2
moyack
If you use the function "Unit- Cause unit to deal damage in an area", you can't control which units will receive damage or not. You have to catch the units via group units.
07-30-2007, 10:23 PM#3
Naakaloh
It's been a while since I've done anything in GUI, but can't you do something like.

Trigger:
Actions
Collapse Unit Group - Pick every unit in (Units within [SomeDistance] of [SomePoint] matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)) and do (Actions)
Collapse Loop - Actions
Do Damage and Stuff
07-30-2007, 11:22 PM#4
TurtleGlove
Hmmm. . . alright, lets see, I'm havin' some trouble assigning just enemies to the group now, any suggestions? Also, I'm not completely new to JASS and I'd be very greatful if you posted a JASS solution, I could definately learn from that.

Off topic, but how do you post triggers like Naakaloh?
07-30-2007, 11:53 PM#5
TheSecretArts
the [trigger] tags
07-31-2007, 12:20 AM#6
Naakaloh
Here's just a simple example of how you might want to damage a group of enemy non-magic-immune units at a given point( x and y) within a given range.

JASS Example

Collapse JASS:
// This is the list of conditions for choosing targets when you enumerate them
// if it returns false the unit is not enumerated.  I used bj_lastReplacedUnit, 
// as the source of the spell, you can use whatever global you want there.
function TargetConditions takes nothing returns boolean

// This checks to see if the unit is an ally of whichever unit you assigned to
// your global that represents the spell's source
    if(IsUnitAlly(GetFilterUnit(), GetOwningPlayer(bj_lastReplacedUnit)))then
        return false
    endif

// This checks to see if the unit is immune to magic
    if(IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE))then
        return false
    endif

    return true

endfunction

// This function actually does the damage; I just used a ForGroup iteration
// Another popular method is a FirstOfGroup iteration, but this should work fine.
// The difference is that ForGroup requires a callback while the FirstOfGroup
// looping can be done inside a function.
function DamageEnumUnit takes nothing returns nothing
    local unit u = GetEnumUnit()

    call UnitDamageTarget(bj_lastReplacedUnit, u, [Damage amount], ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, null)

    set u = null
endfunction

// This is where you will enumerate the group.  Probably a main function.
function Stuff takes nothing returns nothing
    local boolexpr bx = Condition(function TargetConditions)
    local group g = CreateGroup()
    local real x = [The x value at the center of your area]
    local real y = [The y value at the center of your area]
    local real range = [The radius of the circle in which units are enumerated]

    set bj_lastReplacedUnit = [The source of the spell or damage]
    call GroupEnumUnitsInRange( x, y, range, bx)
    call ForGroup(g, function DamageEnumUnit)

// Cleaning Up the Handles
    call DestroyBoolExpr(bx)
    call DestroyGroup(g)
    set g = null
    set bx = null
endfunction

07-31-2007, 12:34 AM#7
TurtleGlove
Hmm, I see what you mean. Could you use GetUnitLoc(GetSpellTargetUnit()) for the x and y instead? or is it something like GetUnitLoc(GetSpellTargetUnit(X)) and GetUnitLoc(GetSpellTargetUnit(Y))? Also, you could use GetUnitAbilityLevelSwapped to create formulas for radius and damage correct?

~Thanks by the way TheSecretarts
07-31-2007, 12:44 AM#8
Naakaloh
Well, I would suggest something like GetLocationX(whichLocation) or GetUnitX(whichUnit)
Edit: And, yes, formulas would be easy to do. For example this returns 50, 75, 100 for levels 1, 2, 3, respectively.

Collapse JASS:
function GetDamageByLevel takes integer level returns real

    return level*25 + 25

endfunction
07-31-2007, 12:55 AM#9
TurtleGlove
How would you define the location or unit's x and y values if the effects have to take place at the target of the ability? "level" requires designation somewhere earlier in the script correct? Or does JASS automatically know you're talking about the ability used to trigger the trigger in the first place?

Man, I really need to spend some serious time learning JASS it would be so helpful.

Thanks Naakaloh, even though I've not solved my quandry yet. . .
07-31-2007, 01:06 AM#10
Naakaloh
Sorry, I didn't realize I was discussing things you wouldn't get. Note, the variable names are arbitrary, and the ellipses are just denoting that this is a segment of the function.

You would get the casting unit or target unit or location like this:
Collapse JASS:
...
local unit source = GetSpellAbilityUnit()
local unit targetunit = GetSpellAbilityTarget()
local location targetloc = GetSpellTargetLoc()
...
In most cases, GetTriggerUnit() will also work for the casting unit.

You would get the level by declaring an integer and then assigning the level to it like this
Collapse JASS:
...
local integer level = GetUnitAbilityLevel( source, [AbilityCode])
...
The ability code is the four character code associated with the ability, if you need to know what it is you can hit Ctrl+D in the object editor to see it in the ability tree on the left.
07-31-2007, 02:15 AM#11
TurtleGlove
Yea, I should have flat out said I'm horrible with JASS. I've only fiddled with JASS and wrote maybe two line triggers before, thanks for sticking with me on this one, I'ma compile what you've added to my knowledge, remake the spell, and then come back with any further questions. Expect to hear from me soon with tales of my failure
07-31-2007, 06:52 AM#12
Jazradel
This is a way to do it in GUI if you care.
Trigger:
Unit Group - Pick every unit in (Units within 512.00 of (Target point of ability being cast) matching (((Picked unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)) and do (Actions)
Collapse Loop - Actions
Unit - Cause (Triggering unit) to damage (Picked unit), dealing 500.00 damage of attack type Spells and damage type Normal
07-31-2007, 10:42 PM#13
TurtleGlove
Zomg, awesome. I'ma still try to make it in JASS to expand my knowledge but if it doesn't work, GUI is where I'm gonna end up, thanks man.
07-31-2007, 11:45 PM#14
Naakaloh
That's basically what I suggested first... though, I don't think Picked Unit works in the filter (the "matching" part), I think you'd have to use Matching Unit
08-01-2007, 06:15 AM#15
Pyrogasm
No, you use Picked Unit.