• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to kill your own ward via a spell?

Status
Not open for further replies.
Level 3
Joined
Apr 1, 2009
Messages
30
My hero places landmines (wards) on the ground, and with an ability he blows them all up at once.

That was the plan anyway but I cant seem to make it work. The landmines themselves have the AoE damage when killed ability, I just want the ability to actually kill them without using any triggers if possible, as Im quite nooby with everything still.

Thanks
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

At all I don't remember a way without any triggers, but anyhow the trigger is very simple:

  • Ability
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type Goblin Land Mine) and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
JASS:
function GroupActions takes nothing returns nothing
    if GetUnitTypeId(GetEnumUnit()) == 'H000' then //Rawcode of the mines
        call KillUnit(GetEnumUnit())
    endif
endfunction

function Actions takes nothing returns nothing
    local group g = CreateGroup()
    
    if GetSpellAbilityId() == 'A000' then //Rawcode of the ability
        call GroupEnumUnitsInRange(g,GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),100000.,null)
        call ForGroup(g,function GroupActions)
    endif
    call DestroyGroup(g)
endfunction

//===========================================================================
function InitTrig_AbilityJass takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        exitwhen i == 16
        call TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
        set i = i + 1
    endloop
    call TriggerAddAction(t,function Actions)
endfunction
 
Level 3
Joined
Apr 1, 2009
Messages
30
I guess thats alright, but then I have another question. Whenever I made a trigger for a unit, the trigger stopped working when I removed the unit from the map (meaning the unit is still in the object editor but not physically on the map).
Do I need to have all the units I make triggers for on the map at all times?
 
Level 20
Joined
Oct 21, 2006
Messages
3,231
I guess thats alright, but then I have another question. Whenever I made a trigger for a unit, the trigger stopped working when I removed the unit from the map (meaning the unit is still in the object editor but not physically on the map).
Do I need to have all the units I make triggers for on the map at all times?

It should not stop working.

Unless you made it so that specific unit casts something. But you gonna make it now UNIT CASTS A SPELL and use a condition WHAT SPELL. So the trigger runs every time when ANY UNIT casts a spell that matches with the condition you used. Not sure what ya meen...
 
Level 3
Joined
Apr 1, 2009
Messages
30
Thats what I meant sheep, thanks

But I dont seem to find this:

Unit Group - Pick every unit in (Units of type Goblin Land Mine) and do (Actions)
Loop - Actions
Unit - Kill (Picked unit)

Can you go step for step through that? I cant find the "and do (Actions)" or "Loop - Actions" thing
 
Last edited:

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Moin moin =)

JASS:
function GroupActions takes nothing returns nothing
    if GetUnitTypeId(GetEnumUnit()) == 'H000' then //Rawcode of the mines
        call KillUnit(GetEnumUnit())
    endif
endfunction

function Actions takes nothing returns nothing
    local group g = CreateGroup()
    
    if GetSpellAbilityId() == 'A000' then //Rawcode of the ability
        call GroupEnumUnitsInRange(g,GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),100000.,null)
        call ForGroup(g,function GroupActions)
    endif
    call DestroyGroup(g)
endfunction

//===========================================================================
function InitTrig_AbilityJass takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        exitwhen i == 16
        call TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
        set i = i + 1
    endloop
    call TriggerAddAction(t,function Actions)
endfunction

Seeing as how relaxing it is to adjust JASS code to the best possible way:

JASS:
constant function AbilityJASS_SpellRawcode takes nothing returns integer
    return 'A000'
endfunction

constant function AbilityJASS_MineRawcode takes nothing returns integer
    return 'H000'
endfunction

constant function AbilityJASS_MaxWardRange takes nothing returns real
    return 700.0
endfunction

function AbilityJASS_GroupEnum takes nothing returns boolean
    if GetUnitTypeId(GetFilterUnit()) == AbilityJASS_MineRawcode() then
        call KillUnit(GetFilterUnit())
    endif
    return false
endfunction

function AbilityJASS_OnCast takes nothing returns boolean
    if GetSpellAbilityId() == AbilityJASS_SpellRawcode() then
        call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), AbilityJASS_MaxWardRange(), Filter(function AbilityJASS_GroupEnum))
    endif
    return false
endfunction

//===========================================================================
function InitTrig_AbilityJASS takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function AbilityJASS_OnCast))
    set t = null
endfunction
 
Last edited:
Level 16
Joined
May 1, 2008
Messages
1,605
Seeing as how relaxing it is to adjust JASS code to the best possible way:

JASS:
constant function AbilityJASS_SpellRawcode takes nothing returns integer
    return 'A000'
endfunction

constant function AbilityJASS_MineRawcode takes nothing returns integer
    return 'H000'
endfunction

constant function AbilityJASS_MaxWardRange takes nothing returns real
    return 700.0
endfunction

function AbilityJASS_GroupEnum takes nothing returns boolean
    if GetUnitTypeId(GetFilterUnit()) == AbilityJASS_MineRawcode() then
        call KillUnit(GetFilterUnit())
    endif
    return false
endfunction

function AbilityJASS_OnCast takes nothing returns boolean
    if GetSpellAbilityId() == AbilityJASS_SpellRawcode() then
        call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), AbilityJASS_MaxWardRange(), Filter(function AbilityJASS_GroupEnum))
    endif
    return false
endfunction

//===========================================================================
function InitTrig_AbilityJASS takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEvent(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function AbilityJASS_OnCast))
    set t = null
endfunction

Challenge? ^^
 
Status
Not open for further replies.
Top