• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[JASS] Jass problems

Status
Not open for further replies.
Level 3
Joined
Mar 2, 2006
Messages
36
Hi there,
Yesterday i noticed that my custom spell wasn't any good in triggers (well it would work perfectly if it wasn't for the two seconds wait, wich are unfortunally needed), so i have to make it jass, now the thing is i have been reading tutorials and stuff but this stays my first time with jass.

I have a c# knowledge so the syntax in general isn't any problem, but the problem is i don't see the link to triggers in wc III. So I've been tyring to make this thing with local variables because everyone keeps saying that, and i understand why.

But how do i start, do i have to put everything under one function instead of seperate? Becuase i tried to declare variables but then i need to 'take' them in the other functions, but u can't do that with arrays.

Also i can't declaire them in each function becuase that wouldn't help a thing. So do i have to make a main function that call's all seperate ones in a row and declare my variables there?

Anyway it would be nice if sombody could give me a push in the right direction. (these are two triggers btw the second one starts from the comment line //=====ACTIONS======)

EDIT: some quick info about the spell, its a target dummy summoned at the location a player clicks for his spell. It taunts units nearby (not using the taunt ability that seems to bug allot) by taking all units in a range that are enemy of casting unit and ordering them to attack the dummy. Then it waits two seconds and 'explodes' (meaning destroying the barrel of explosives and casting the tauren war stomp) dealing damage and stunning.

thx in advance
Hoplitespear

PS: u can find the triggers at these two links
http://users.telenet.be/hoplitespear/HIVE/main.bmp
http://users.telenet.be/hoplitespear/HIVE/actions.bmp


Code:
function Trig_target_dummy_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00K' ) ) then
        return false
    endif
    return true
endfunction

function Trig_target_dummy_Func004001003 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'o00K' )
endfunction

function Trig_target_dummy_Func004Func006001003 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_TDCaster)) == true )
endfunction

function Trig_target_dummy_Func004Func006Func001C takes nothing returns boolean
    if ( not ( IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == false ) ) then
        return false
    endif
    if ( not ( IsUnitAliveBJ(GetEnumUnit()) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_target_dummy_Func004Func006A takes nothing returns nothing
    if ( Trig_target_dummy_Func004Func006Func001C() ) then
        set udg_TDX = ( udg_TDX + 1 )
        set udg_TDTargets[udg_TDX] = GetEnumUnit()
    else
        call DoNothing(  )
    endif
endfunction

function Trig_target_dummy_Func004A takes nothing returns nothing
    set udg_TDTaunter = GetEnumUnit()
    call AddSpecialEffectLocBJ( GetUnitLoc(udg_TDTaunter), "Abilities\\Spells\\NightElf\\Taunt\\TauntCaster.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call AddSpecialEffectLocBJ( GetUnitLoc(udg_TDTaunter), "Units\\Other\\TNTBarrel\\TNTBarrel.mdl" )
    set udg_bomb = GetLastCreatedEffectBJ()
    call ForGroupBJ( GetUnitsInRangeOfLocMatching(udg_ZapSlamRange, GetUnitLoc(udg_TDCaster), Condition(function Trig_target_dummy_Func004Func006001003)), function Trig_target_dummy_Func004Func006A )
endfunction

function Trig_target_dummy_Actions takes nothing returns nothing
    set udg_TDCaster = GetSpellAbilityUnit()
    set udg_TDX = 0
    set udg_TDY = 0
    call ForGroupBJ( GetUnitsInRangeOfLocMatching(3000.00, GetUnitLoc(udg_TDCaster), Condition(function Trig_target_dummy_Func004001003)), function Trig_target_dummy_Func004A )
    set udg_TDGroup = GetLastCreatedGroup()
    call GroupClear( udg_TDGroup )
    call EnableTrigger( gg_trg_TD_Actions )
endfunction

//===========================================================================
function InitTrig_target_dummy takes nothing returns nothing
    set gg_trg_target_dummy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_target_dummy, EVENT_PLAYER_UNIT_SPELL_FINISH )
    call TriggerAddCondition( gg_trg_target_dummy, Condition( function Trig_target_dummy_Conditions ) )
    call TriggerAddAction( gg_trg_target_dummy, function Trig_target_dummy_Actions )
endfunction


//=================ACTIONS=====================================

function Trig_TD_Actions_Func003C takes nothing returns boolean
    if ( not ( udg_TDY >= udg_TDX ) ) then
        return false
    endif
    return true
endfunction

function Trig_TD_Actions_Actions takes nothing returns nothing
    set udg_TDY = ( udg_TDY + 1 )
    call IssueTargetOrderBJ( udg_TDTargets[udg_TDY], "attack", udg_TDTaunter )
    if ( Trig_TD_Actions_Func003C() ) then
        call CreateNUnitsAtLocFacingLocBJ( 1, 'n003', GetOwningPlayer(udg_TDCaster), GetUnitLoc(udg_TDTaunter), GetUnitLoc(udg_TDTaunter) )
        call SetUnitAbilityLevelSwapped( 'A00M', GetLastCreatedUnit(), GetUnitAbilityLevelSwapped('A00K', udg_TDCaster) )
        set udg_dummy = GetLastCreatedUnit()
        call TriggerSleepAction( 2.00 )
        call IssueImmediateOrderBJ( udg_dummy, "stomp" )
        call DestroyEffectBJ( udg_bomb )
        call ExplodeUnitBJ( udg_TDTaunter )
        call RemoveUnit( udg_dummy )
        call DisableTrigger( gg_trg_TD_Actions )
    else
        call DoNothing(  )
    endif
endfunction

//===========================================================================
function InitTrig_TD_Actions takes nothing returns nothing
    set gg_trg_TD_Actions = CreateTrigger(  )
    call DisableTrigger( gg_trg_TD_Actions )
    call TriggerRegisterTimerEventPeriodic( gg_trg_TD_Actions, 0.10 )
    call TriggerAddAction( gg_trg_TD_Actions, function Trig_TD_Actions_Actions )
endfunction
 
Level 8
Joined
Aug 6, 2008
Messages
451
Locals can make your function Multi Instanceable, even if you use waits.

For example this function:
JASS:
function Trig_TD_Actions_Actions takes nothing returns nothing
    set udg_TDY = ( udg_TDY + 1 )
    call IssueTargetOrderBJ( udg_TDTargets[udg_TDY], "attack", udg_TDTaunter )
    if ( Trig_TD_Actions_Func003C() ) then
        call CreateNUnitsAtLocFacingLocBJ( 1, 'n003', GetOwningPlayer(udg_TDCaster), GetUnitLoc(udg_TDTaunter), GetUnitLoc(udg_TDTaunter) )
        call SetUnitAbilityLevelSwapped( 'A00M', GetLastCreatedUnit(), GetUnitAbilityLevelSwapped('A00K', udg_TDCaster) )
        set udg_dummy = GetLastCreatedUnit()
        call TriggerSleepAction( 2.00 )
        call IssueImmediateOrderBJ( udg_dummy, "stomp" )
        call DestroyEffectBJ( udg_bomb )
        call ExplodeUnitBJ( udg_TDTaunter )
        call RemoveUnit( udg_dummy )
        call DisableTrigger( gg_trg_TD_Actions )
    else
        call DoNothing(  )
    endif
endfunction
could be soemthing like this:
JASS:
function Trig_TD_Actions_Actions takes nothing returns nothing
    // locals must be declared at the top of the function
    local unit dummy
    local real x
    local real y
    local real x2
    local real y2
    local real angle
    // actions:
    set udg_TDY=udg_TDY+1
    call IssueTargetOrder(udg_TDTargets[udg_TDY],"attack",udg_TDTaunter)
    if udg_TDY<udg_TDX then
        set x=GetUnitX(udg_TDCaster)
        set y=GetUnitY(udg_TDCaster)
        set x2=GetUnitX(udg_TDTaunter)
        set y2=GetUnitY(udg_TDTaunter)
        set angle=Atan2(y2-y,x2-x)
        set dummy=CreateUnit(GetOwningPlayer(udg_TDCaster),'n003',x,y,angle)
        call SetUnitAbilityLevel(dummy,'A00M',GetUnitAbilityLevel(udg_TDCaster,'A00K'))
        call TriggerSleepAction( 2.00 )
        call IssueImmediateOrder(dummy, "stomp")
        call DestroyEffect(udg_bomb)
        call ExplodeUnitBJ(udg_TDTaunter)
        call RemoveUnit(udg_dummy)
        call DisableTrigger(gg_trg_TD_Actions)
        set dummy=null // almost forgot this, since I dont null units anymore. I recycle them.
    endif
endfunction

Also, if you are gonna do any Jass, get NewGen. It has loads of neat stuff, like nice function list and syntax highlighter.
 
Level 3
Joined
Mar 2, 2006
Messages
36
Yeah i see what u mean, but my problem is, if i make local variables for each function it won't work right?

For example if i make a variable X in the function 'actions'. But i need to have the SAME value from that variable X in the function 'fill array'. what do i do then? I can't remake a local in the 'fill array' function becuase that wouldn't have the same value like in 'actions'.

Thats where i'm stuck, if this would only be one function i could be done already, just make locals, but i need the same ones in different functions. :s

EDIT: but wait, i see it now, u still use the public variables, but only in that function u put them inside a local. Hmm let me try that out thx m8

EDIT: so i do the same thing for the other functions then? Goh why did i make this so complicated :p BTW for example my special effect (udg_bomb) only gets destroyed in the second trigger so how do can i make it destroy the special effect made for that spell and not the new one that is cast.
 
Last edited:
Level 3
Joined
Mar 2, 2006
Messages
36
Bumb, sry for the bumb *shame* Could anyone take a look and see if they know a way to make this work. So that when the spell is casted at the same time no problems occure.

I would be really gratefull, i've been looking for a few hours now but all this jass is just to new for me. And its kinda urgent.

Thx

EDIT: well i got it fixed, not with jass though just triggers, i removed the wait, just added 2 second cast to the ability so i get the same effect, and i made the special effect of the barrel a dummy unit with locust but with 15 hp, so the war stomp will destroy it, and i added a timer to be sure. Added a timer to the taunter to. So now this skill works perfect even when cast twice at same time.

Thx for the replies though :)
 
Last edited:
Level 7
Joined
Mar 8, 2009
Messages
360
For example if i make a variable X in the function 'actions'. But i need to have the SAME value from that variable X in the function 'fill array'. what do i do then? I can't remake a local in the 'fill array' function becuase that wouldn't have the same value like in 'actions'.


i think you mean something like this

JASS:
function firstFunc takes nothing returns nothing
     local point nameofpoint
     set nameofpoint = GetSpellTargetLoc()
     call otherFunc(nameofpoint)
endfunction

function otherFunc takes point castExplosive returns nothing
     call AddSpecialEffectLocBJ( castExplosive, "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl" )
     //this creates thunderclap on the point declared in firstFunc
endfunction
 
Level 3
Joined
Mar 2, 2006
Messages
36
Yeah thats it, i thought it would be something with takinga variable. But the problem is i had to do it everywhere and it became to complicated. Also u can't do it with arrays :( wich is a shame. But i got it fixed with triggers now. Thx for your reply anyway.
 
Status
Not open for further replies.
Top