• 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.

[JASS] Jass spell, need tips

Status
Not open for further replies.
Level 9
Joined
May 27, 2006
Messages
498
The time has come for me too to start learning Jass, but my knowledge of it is... lets say, limited :)
Anyway, im trying to write my first spell in Jass, and thats what i got right now:
JASS:
function Trig_Kni_Conditions takes nothing returns boolean
    if ( GetSpellAbilityId() == 'A000' ) then
        return true
    endif
    return false
endfunction

function Trig_Kni_Actions takes nothing returns nothing
   local location TempPoint
   local location TempPoint2
   local unit Caster = GetTriggerUnit()
   local group Knives
   local integer KniNo
   local integer KniNoMax = 2 + ( 2 * GetUnitAbilityLevelSwapped('A000', Caster ) )
   local boolean KniActivated = false
   local integer Counter = 0
   set TempPoint = GetUnitLoc(Caster)
   set TempPoint2 = PolarProjectionBJ( TempPoint, RandomReal(0, 300), RandomReal(0, 360) )
   if ( CountUnitsInGroup(Knives) < KniNoMax ) then
      call CreateNUnitsAtLoc( 1, 'h000', GetOwningPlayer(Caster), TempPoint, bj_UNIT_FACING )
      call GroupAddUnitSimple( GetLastCreatedUnit(), Knives )
      set KniNo = CountUnitsInGroup(Knives)
   endif
   loop
       exitwhen Counter > 375 // 1 : 0.04 = 25 | 25 * 15(max duration in seconds) = 375
       set TempPoint = GetUnitLoc(Caster)
       set Counter = ( Counter + 1 )
       call TriggerSleepAction(0.04)
   endloop
endfunction

//===========================================================================
function InitTrig_Storm_of_Knives takes nothing returns nothing
    set gg_trg_Storm_of_Knives = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Storm_of_Knives, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Storm_of_Knives, Condition( function Trig_Kni_Conditions ) )
    call TriggerAddAction( gg_trg_Storm_of_Knives, function Trig_Kni_Actions )
endfunction

I got stuck at the loop and the set TempPoint2 action, which is giving me some errors all the time (expecting name, etc). Although i can deal with the action by trying other ways of setting the location, i have no idea how to continue my spell at the loop.
The spell is supposed to create a dummy unit every time the caster uses the ability. The dummy starts to float around the caster, dealing damage to nearby enemy units (done it using Immolation). Up to 8 dummies can be summoned.
Now, the problem is, i have no idea how to let the function spawn new dummies without starting new loop/interrupting the already running one.

Note that im not requesting anyone to do this spell for me, i want tips on what to add/change.
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
You should use a global group which you add your dummies to and then use a separate trigger with a periodic event which picks the units in that group and then moves them around the caster which should be stored in a global variable. Also you shouldn't use "swapped" or "BJ" functions because they're slower than native functions. F.ex. instead of call DestroyEffectBJ(someEffect) you should use call DestroyEffect(someEffect) and "swapped" functions are copies of native function except that the position of the arguments have been swapped. F.ex. GetUnitAbilityLevelSwapped('A000', Caster) should be GetUnitAbilityLevel(Caster, 'A000').
NOTE: It doesn't always help to just remove "BJ" from the function name. Some "BJ" functions are made up from several functions and have just gotten a name which describes what it does and doesn't got a native "brother" which does the same.
 
Status
Not open for further replies.
Top