• 🏆 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!

[JASS] My spell wont work

Status
Not open for further replies.
Level 4
Joined
Jul 9, 2008
Messages
88
Hello, this is my first spell after reading some JASS tuts but it wont work at all. What am I doing wrong?
The point of the spell is to get the units in range and summon a unit that is the same type as the picked unit in range (dont know if i worded that right).
But the spell is almost completely unresponsive.
JASS:
function SummonSpell_Condition takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction
function SummonSpell_Actions takes nothing returns nothing
    local unit temp //the target
    local location target_loc = GetUnitLoc(temp) //the target location
    local integer i = 0 //my loop integer
    local group enemies = CreateGroup() //the selected group in range
    local unit caster = GetTriggerUnit() //the caster, of course
    local location start_position = GetUnitLoc( caster ) //obviously the caster location
    local unit S_created    //My Summoned Unit
    call GroupEnumUnitsInRangeOfLoc(enemies, start_position, 1000.0, null)
    loop
        exitwhen i > 10
        set temp = FirstOfGroup(enemies)
        if IsUnitEnemy(temp, GetTriggerPlayer()) then
            call SetUnitFacingToFaceLocTimed(caster, target_loc, 0.20)
            set S_created = CreateUnitAtLoc(GetTriggerPlayer() , GetUnitTypeId(temp), target_loc, 0.00)
            call SetUnitTimeScale(S_created, 25.0)
            call SetUnitVertexColor(S_created, 255, 0, 0, 30)
            call SetUnitAnimation( caster, "attack" )
            set i = i - 1
        endif
        call GroupRemoveUnit(enemies, temp)
    endloop
endfunction
function InitTrig_SummonSpell takes nothing returns nothing
 set gg_trg_SummonSpell = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_SummonSpell, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_SummonSpell, Condition(function SummonSpell_Condition))
    call TriggerAddAction(gg_trg_SummonSpell, function SummonSpell_Actions)
endfunction
 
Last edited:
Level 4
Joined
Jul 9, 2008
Messages
88
I see thanks +rep
i think its funny how stupid i am - I was frustrated from getting no reply and 20 minutes after the post I find out i didnt post the code >.>

I have another question for you. I have another spell, one I based off a tutorial. Everytime I run my summonSpell thing it calls the other spell instead. Plus the spell is still unresponsive when I disable the other spell for testing.
Whats wrong?
 
Last edited:
Level 16
Joined
Mar 3, 2006
Messages
1,564
@ EOW: HYPOCRITE !!! Why ?

----------

Change the last function 'InitTrig_SummonSpell' to

JASS:
function InitTrig_SummonSpell takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function SummonSpell_Condition))
    call TriggerAddAction(t, function SummonSpell_Actions)
endfunction

<< EDIT >>

Also in
JASS:
call GroupEnumUnitsInRangeOfLoc(enemies, start_position, 1000.0, null)
use boolexpr instead of null.
 
@ EOW: HYPOCRITE !!! Why ?

----------

Change the last function 'InitTrig_SummonSpell' to

JASS:
function InitTrig_SummonSpell takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function SummonSpell_Condition))
    call TriggerAddAction(t, function SummonSpell_Actions)
endfunction
<< EDIT >>

Also in
JASS:
call GroupEnumUnitsInRangeOfLoc(enemies, start_position, 1000.0, null)
use boolexpr instead of null.
Hypocrite because you double-posted after saying "Hint: you must wait 48 hours before bumping a thread". How hypocritical can you get?
 
Status
Not open for further replies.
Top