• 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] Help me fix this...

Status
Not open for further replies.
Level 4
Joined
Mar 11, 2007
Messages
63
Ok heres my code:

JASS:
//===========================================================================
//                            NAME OF SPELL
//===========================================================================
function Pushback takes unit CastingUnit,unit PickedUnit returns nothing
  local real ud=0.00
  local real ua=0.00

  set ud=(DistanceBetweenUnits(CastingUnit,PickedUnit)+40)
  set ua=AngleBetweenUnits(CastingUnit,PickedUnit)
  call SetUnitPositionLoc(GetEnumUnit(),PolarProjectionBJ(GetUnitLoc(CastingUnit),ud,ua))
endfunction

function Trig_Spell_Trigger_Actions takes nothing returns nothing
  local unit cu=GetSpellAbilityUnit()
  local real tr=0.00

  if (GetSpellAbilityId()=='A000') then 
    loop
      set tr=tr+1.00
      exitwhen tr>100.00
      call ForGroupBJ(GetUnitsInRangeOfLocAll(300,GetUnitLoc(cu)),Pushback(cu,GetEnumUnit()))
      call TriggerSleepAction(2.00)
    endloop
  endif  
endfunction

//===========================================================================
function InitTrig_Spell_Trigger takes nothing returns nothing
    set gg_trg_Spell_Trigger = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Spell_Trigger, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddAction( gg_trg_Spell_Trigger, function Trig_Spell_Trigger_Actions )
endfunction

When I save this, I get an error that has something to do with 'TriggerSleepAction' being invalid (void).
 
I think "DistanceBetweenUnits" and "AngleBetweenUnits" are custom functions, because they dont exist.

And i dont see any problems with "TriggerSleepActions".

i'm not sure, but can the code callback have arguments?
JASS:
Pushback(cu,GetEnumUnit())

You're leaking a group and many locations
( GetUnitLoc() )
( GetUnitsInRangeOfLocAll () )

and change ForGroupBJ to ForGroup
 
Level 4
Joined
Mar 11, 2007
Messages
63
yes those two are custom variables.

I was unsure about that callback thing, I don't think I can just move it below the trigger... Anyway I can fix it?

Hmm, Thanks. My problem with 'triggersleepaction' still doesnt work but you helped me fix the leaks +rep.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Waits
Delays the rate that a loop is carried out from instantly to the length of the total waits in the loop.
Aborts all function calls for both the caller and the owner function if used with pick units or any other simlar function.
Non polled waits get OUS in multiplayer making the wait duration longer to catch up, ruining your spell if it rellies on good timing.

Overall, waits are not reliable, much rather use timers for spells.
Waits are ok for core functions, but any spell or combat system should not use them.
 
Level 4
Joined
Mar 11, 2007
Messages
63
I dont want a timer because I want the spell to wait 0.01 seconds between every time the picked unit is pushed away from the caster. Here are the problems Im having in detail:

  • When I try to save with the waits in the function, the debugger disables my code.
  • When I take the waits out and then save, the map crashes.
  • When I use the spell while playing the map, with the waits in but with out saving and disabling the code, it crashes.
  • In JASSCraft, when I run a syntax check, it tells me the ForGroupBJ function doesnt work, unless I use 'function PushBack()' with no parameters. In WE, I dont get the same problem...
  • However, JASSCraft didn't say there was anything wrong with 'TriggerSleepAction' being used in that way...
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
YOU FOOL, WE syntax is SHIT!!!! it reports the wrong lines for almost all errors.


The fault is

JASS:
      call ForGroupBJ(GetUnitsInRangeOfLocAll(300,GetUnitLoc(cu)),Pushback(cu,GetEnumUnit()))

You are calling a function when it wants just a function NAME. You can not pass stuff to the function that it loops for each unit.

Also that call leaks.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
YOU FOOL, WE syntax is SHIT!!!! it reports the wrong lines for almost all errors.
Win. That one's going down in the books ><
In JASSCraft, when I run a syntax check, it tells me the ForGroupBJ function doesnt work, unless I use 'function PushBack()' with no parameters. In WE, I dont get the same problem...
A code callback has to look like

function SomeFunction

And no, it cannot have parameters.

That's what'll be generating your error.
 
Level 5
Joined
Feb 16, 2006
Messages
151
You can not pass stuff to the function that it loops for each unit.
Not quite.
You must not have parameters, but ForGroup/Force do get stuff like GetTriggerUnit, GetSpellTargetUnit...
All you have to do is to have write those in the callback function.
And your so called "Picked Unit" is GetEnumUnit.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Or you could use handlevars to transfer unit specific values and junk, but you can not PASS values to functions called by the loop through something. YOu can get values in their functions but you can not hand them values without using globals or handle vars or simlar systems.
 
Level 4
Joined
Mar 11, 2007
Messages
63
THanks for all the help. I lost track of the last few posts because im new at this... I didnt get it working so im going to try a GUI approach for this trigger and come back to it when i understand more. oh also... +rep all round.
 
Status
Not open for further replies.
Top