HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Target point of Area of Effect

07-13-2004, 08:10 AM#1
Panto
Greetings.

I'd like to get the centerpoint of an Area of Effect spell, but
Code:
GetSpellTargetLoc()
doesn't seem to do the trick. Is there another function that I'm missing (I couldn't find anything similar in blizzard.j or common.j, although I'm not the most practiced at looking through them), or is there another way to get the centerpoint of an AoE or get the units that are inside an AoE reticle?

Gettings the units that are damaged by the spell isn't ideal.
07-13-2004, 08:12 AM#2
HexenLordX
Are you looking for the coordinates or are you just going to use it in a trigger?

Theres triggers that include Target Point of Ability Being Cast. You could probably add that in somewhere if you need it.

If you are using functions like that for you trigger, you might wanna try the JASS forum.
07-13-2004, 08:28 AM#3
kagashin
Quote:
Originally Posted by Panto
Greetings.

I'd like to get the centerpoint of an Area of Effect spell, but
Code:
GetSpellTargetLoc()
doesn't seem to do the trick. Is there another function that I'm missing (I couldn't find anything similar in blizzard.j or common.j, although I'm not the most practiced at looking through them), or is there another way to get the centerpoint of an AoE or get the units that are inside an AoE reticle?

Gettings the units that are damaged by the spell isn't ideal.

its target of ability being cast/channeled
07-13-2004, 08:32 AM#4
HexenLordX
Never tried it, but I believe when looking for the target point of an AoE spell you need to use the Target Point of Ability Being Cast, the Target of Ability Being Cast/Channelled refers to an actual target, which unless the ability can target a point and a unit, youll need the target point. Just my thoughts.. I really need to go test these things more, I realize I'm kinda lacking knowledge right now.
07-13-2004, 08:55 AM#5
kagashin
your riight it is target point but all i said was target of ability not target unit well any ways good luck with your map
07-13-2004, 01:47 PM#6
th15
That's strange Panto. I do that all the time in GUI. Maybe it's something with your JASS.
07-13-2004, 03:19 PM#7
Panto
I won't say that it couldn't be, but since the trigger fires and none of the effects go off, I have to think that it's because it doesn't have one of its necessary values. A debug special effect at the point of the "Target point of Spell being Cast" didn't show up at all, so I suspect that's the culprit.

As far as posting in the AI/Jass forum, that's not really the kind of place where you ask simple questions about jass functions. This is the Trigger Haven, which covers both GUI and Jass trigger questions.

At any rate, here's the larger trigger. It's firing off of a dummy spell based on Flamestrike to get the Area-of-Effect reticle.
Code:
function Trig_Ambush_AoE_casters_Conditions takes nothing returns boolean
    if (not(GetSpellAbilityId() == 'ANfs')) then
        return false
    endif
    return true
endfunction

function Trig_Ambush_AoE_casters_Actions takes nothing returns nothing
    local location locCaster = GetUnitLoc(GetSpellAbilityUnit())
    local location locTarget
    local location locSpell = GetSpellTargetLoc()
    local integer intLoop
    local group groupInRange = GetUnitsInRangeOfLocAll(udg_realArAmbushRange[GetUnitAbilityLevelSwapped('ANfs', GetSpellAbilityUnit())], locSpell)
    local group groupTargets
    local group groupCasters
    local unit unitPicker

    call DisplayTimedTextToForce(GetForceOfPlayer(GetOwningPlayer(GetSpellAbilityUnit())), 30, ("Ambush AoE trigger running."))
    call AddSpecialEffectLocBJ(locSpell, "Abilities\\Spells\\Undead\\AntiMagicShell\\AntiMagicShell.mdl" )

    // evaluate nearby units for buffs and ownership
    loop
        set unitPicker = FirstOfGroup(groupInRange)
        exitwhen unitPicker == null
        if ((UnitHasBuffBJ(unitPicker, 'Bena') == false) and (UnitHasBuffBJ(unitPicker, 'Beng') == false) and (IsPlayerInForce(GetOwningPlayer(unitPicker), GetPlayersAllies(GetOwningPlayer(GetSpellAbilityUnit()))) == false)) then
            call GroupAddUnitSimple(unitPicker, groupTargets)
//            call DisplayTimedTextToForce(GetForceOfPlayer(GetOwningPlayer(GetSpellAbilityUnit())), 30, ("Accepted " + GetUnitName(unitPicker)))
        endif
        call GroupRemoveUnitSimple(unitPicker, groupInRange)
    endloop

    // buff some units
    set intLoop = 1
    loop
        set unitPicker = FirstOfGroup(groupTargets)
//        call DisplayTimedTextToForce(GetForceOfPlayer(GetOwningPlayer(GetSpellAbilityUnit())), 30, ("Targeted " + GetUnitName(unitPicker)))
        set locTarget = GetUnitLoc(unitPicker)
        exitwhen unitPicker == null
        exitwhen intLoop > udg_intArAmbushTargets[GetUnitAbilityLevelSwapped('ANfs', GetSpellAbilityUnit())]
        call CreateNUnitsAtLocFacingLocBJ( 1, 'nowl', GetOwningPlayer(GetSpellAbilityUnit()), locCaster, locTarget)
        call IssueTargetOrderBJ(GetLastCreatedUnit(), "ensnare", unitPicker)
        call GroupAddUnitSimple(GetLastCreatedUnit(), groupCasters)
        call RemoveLocation(locTarget)
        call GroupRemoveUnitSimple(unitPicker, groupTargets)
        set intLoop = intLoop + 1
    endloop

    call PolledWait(1.00)

    // cleanup
    loop
        set unitPicker = FirstOfGroup(groupCasters)
        exitwhen unitPicker == null
        call KillUnit(unitPicker)
        call RemoveUnit(unitPicker)
        call GroupRemoveUnitSimple(unitPicker, groupCasters)
    endloop

    call RemoveLocation(locCaster)
    call RemoveLocation(locSpell)
    set locCaster = null
    set locSpell = null
    set locTarget = null
    call DestroyGroup(groupInRange)
    call DestroyGroup(groupTargets)
    call DestroyGroup(groupCasters)
    set groupInRange = null
    set groupTargets = null
    set groupCasters = null
        
endfunction

//===========================================================================
function InitTrig_Ambush_AoE_casters takes nothing returns nothing
    set gg_trg_Ambush_AoE_casters = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Ambush_AoE_casters, EVENT_PLAYER_UNIT_SPELL_FINISH)
    call TriggerAddCondition(gg_trg_Ambush_AoE_casters, Condition(function Trig_Ambush_AoE_casters_Conditions))
    call TriggerAddAction(gg_trg_Ambush_AoE_casters, function Trig_Ambush_AoE_casters_Actions)
endfunction
07-13-2004, 04:27 PM#8
Panto
Thanks to Cubasisian intervention, I have changed to EVENT_PLAYER_UNIT_SPELL_EFFECT instead of EVENT_PLAYER_UNIT_SPELL_FINISH, and now it's getting the location correctly. Somethings still fishy with the trigger, however. It's not... uh... doing anything.
07-13-2004, 11:42 PM#9
th15
Oh yea, I forgot about that, for some reason the game forgets about the target loc before it triggers the "finishes casting" event.

Code:
GetPlayersAllies(GetOwningPlayer(GetSpellAbilityUn  it())))

May your code didnt paste properly, but I'm damned sure that isn't proper syntax :)
07-14-2004, 05:21 AM#10
Panto
Yea, the forum splits up lines that have too many characters, even though it still displays them on the same line.
07-14-2004, 11:37 AM#11
Cubasis
Di Di Da De Doe.

You're forgetting to initiate your group locals to a group. As it is, they are just pointing to some garbage (or NULL), and thus, you can't "Add" a unit to them unless they have a group to add a unit too.

Add: " = CreateGroup()" to the end of the other group local declerations and your triggers should atleast work a tiny bit more. :)

~Cubasis
07-14-2004, 03:58 PM#12
Panto
I think I may forget to do that for every group variable I try to create from here to the end of time. Thanks again, Cub. I'll see what happens.
07-14-2004, 05:28 PM#13
Panto
Well, I'm certainly getting better results. However, it seems to be wrong in:
A) Willing to target units belonging to allies of the owner of the caster
B) Doesn't actually cause the created units to cast the spell
C) Doesn't seem to be escaping the loop when there's no units left in groupTargets, as it should.

EDIT: I take it back, it is escaping the loop, it's just that the exitwhen comes after the debug statement, so it doesn't look like it is escaping according to the print out.

Here's the current code:
Code:
function Trig_Ambush_AoE_casters_Conditions takes nothing returns boolean
    if (not(GetSpellAbilityId() == 'ANfs')) then
        return false
    endif
    return true
endfunction

function Trig_Ambush_AoE_casters_Actions takes nothing returns nothing
    local location locCaster = GetUnitLoc(GetSpellAbilityUnit())
    local location locTarget
    local location locSpell = GetSpellTargetLoc()
    local integer intLoop
    local group groupInRange = GetUnitsInRangeOfLocAll(udg_realArAmbushRange[GetUnitAbilityLevelSwapped('ANfs', GetSpellAbilityUnit())], locSpell)
    local group groupTargets = CreateGroup()
    local group groupCasters = CreateGroup()
    local unit unitPicker

//    call DisplayTimedTextToForce(GetForceOfPlayer(GetOwningPlayer(GetSpellAbilityUnit())), 30, ("Ambush AoE trigger running."))
//    call AddSpecialEffectLocBJ(locSpell, "Abilities\\Spells\\Undead\\AntiMagicShell\\AntiMagicShell.mdl" )
    call DisplayTimedTextToForce(GetForceOfPlayer(GetOwningPlayer(GetSpellAbilityUnit())), 30, "Units in groupInRange: "+I2S(CountUnitsInGroup(groupInRange)))
    call DisplayTimedTextToForce(GetForceOfPlayer(GetOwningPlayer(GetSpellAbilityUnit())), 30, "Range of spell: "+R2S(udg_realArAmbushRange[GetUnitAbilityLevelSwapped('ANfs',GetSpellAbilityUnit())]))


    // evaluate nearby units for buffs and ownership
    loop
        set unitPicker = FirstOfGroup(groupInRange)
        exitwhen unitPicker == null
        if ((UnitHasBuffBJ(unitPicker, 'Bena') == false) and (UnitHasBuffBJ(unitPicker, 'Beng') == false) and (IsPlayerInForce(GetOwningPlayer(unitPicker), GetPlayersAllies(GetOwningPlayer(GetSpellAbilityUnit()))) == false) and (IsUnitType(unitPicker, UNIT_TYPE_MECHANICAL) == false) and (IsUnitDeadBJ(unitPicker) == false)) then
//        if (true) then
            call GroupAddUnitSimple(unitPicker, groupTargets)
            call DisplayTimedTextToForce(GetForceOfPlayer(GetOwningPlayer(GetSpellAbilityUnit())), 30, ("Accepted " + GetUnitName(unitPicker)))
        endif
        call GroupRemoveUnitSimple(unitPicker, groupInRange)
    endloop

    call DisplayTimedTextToForce(GetForceOfPlayer(GetOwningPlayer(GetSpellAbilityUnit())), 30, "Units in groupTargets: "+I2S(CountUnitsInGroup(groupTargets)))

    // buff some units
    set intLoop = 1
    loop
        set unitPicker = FirstOfGroup(groupTargets)
        call DisplayTimedTextToForce(GetForceOfPlayer(GetOwningPlayer(GetSpellAbilityUnit())), 30, ("Targeted: " + GetPlayerName(GetOwningPlayer(unitPicker)) +"'s " + GetUnitName(unitPicker)))
        set locTarget = GetUnitLoc(unitPicker)
        exitwhen unitPicker == null
        exitwhen intLoop > udg_intArAmbushTargets[GetUnitAbilityLevelSwapped('ANfs', GetSpellAbilityUnit())]
        call CreateNUnitsAtLocFacingLocBJ(1, 'nowl', GetOwningPlayer(GetSpellAbilityUnit()), locCaster, locTarget)
//        call DisplayTimedTextToForce(GetForceOfPlayer(GetOwningPlayer(GetSpellAbilityUnit())), 30, ("Caster made: "+GetUnitName(GetLastCreatedUnit())))
        call IssueTargetOrderBJ(GetLastCreatedUnit(), "ensnare", unitPicker)
        call GroupAddUnitSimple(GetLastCreatedUnit(), groupCasters)
        call RemoveLocation(locTarget)
        call GroupRemoveUnitSimple(unitPicker, groupTargets)
        set intLoop = intLoop + 1
    endloop

    call PolledWait(1.00)

    // cleanup
    loop
        set unitPicker = FirstOfGroup(groupCasters)
        exitwhen unitPicker == null
        call KillUnit(unitPicker)
        call RemoveUnit(unitPicker)
        call GroupRemoveUnitSimple(unitPicker, groupCasters)
    endloop

    call RemoveLocation(locCaster)
    call RemoveLocation(locSpell)
    set locCaster = null
    set locSpell = null
    set locTarget = null
    call DestroyGroup(groupInRange)
    call DestroyGroup(groupTargets)
    call DestroyGroup(groupCasters)
    set groupInRange = null
    set groupTargets = null
    set groupCasters = null
        
endfunction

//===========================================================================
function InitTrig_Ambush_AoE_casters takes nothing returns nothing
    set gg_trg_Ambush_AoE_casters = CreateTrigger(  )
//    call TriggerRegisterAnyUnitEventBJ(gg_trg_Ambush_AoE_casters, EVENT_PLAYER_UNIT_SPELL_FINISH)
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Ambush_AoE_casters, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Ambush_AoE_casters, Condition(function Trig_Ambush_AoE_casters_Conditions))
    call TriggerAddAction(gg_trg_Ambush_AoE_casters, function Trig_Ambush_AoE_casters_Actions)
endfunction
And a screenshot of the debug output: