• 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 Errors that dont make sence

Status
Not open for further replies.
Level 5
Joined
Jul 17, 2006
Messages
145
Alright, this code here SHOULD work but the syntax checker went retarted when i ran the code through it:

JASS:
function Trig_Captian_Kasiths_Tital_Wave_Knockback_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A02E' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions takes nothing returns nothing
    set udg_Temp_Unit_Group = GetUnitsInRangeOfLocAll(650.00, GetUnitLoc(GetSpellAbilityUnit()))
    set udg_Temp_Unit = GetSpellAbilityUnit()
    call ForGroupBJ( udg_Temp_Unit_Group, function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions2 )
    set udg_Temp_Unit_Group = null
    set udg_Temp_Unit = null
    set udg_Temp_Unit2 = null
    set udg_Temp_Integer = null
endfunction

function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions2 takes nothing returns nothing
    if ( function Trig_Captian_Kasiths_Tital_Wave_Knockback_ActionsCond ) then
        local timer t
        set udg_Temp_Unit2 = GetEnumUnit()
        set udg_Temp_Integer = DistanceBetweenPoints(GetUnitLoc(udg_Temp_Unit), GetUnitLoc(udg_Temp_Unit2))
        call TriggerSleepAction( udg_Temp_Integer )
        set t CreateTimer()
        call TimerStart(t, 0.01, true, function Knockback)
        call TriggerSleepAction( ((GetUnitAbilityLevelSwapped('A02E', udg_Temp_Unit) * 150) + 350) - udg_Temp_Integer)
        call DestroyTimer(t)
        set t = null
    else
    endif
endfunction

function Knockback takes nothing returns nothing
    call SetUnitPositionLoc(udg_Temp_Unit2, PolarProjectionBJ(GetUnitLoc(udg_Temp_Unit), 10, AngleBetweenPoints(GetUnitLoc(udg_Temp_Unit), GetUnitLoc(udg_Temp_Unit2))))
endfunction

function Trig_Captian_Kasiths_Tital_Wave_Knockback_ActionsCond takes nothing returns boolean
    if ( not ( IsPlayerEnemy(GetOwningPlayer(GetEnumUnit()), GetOwningPlayer(GetSpellAbilityUnit())) == true ) ) then
        return false
    endif
    if ( not ( IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == false ) ) then
        return false
    endif
    return true
endfunction

//===========================================================================
function InitTrig_Captian_Kasiths_Tital_Wave_Knockback takes nothing returns nothing
    set gg_trg_Captian_Kasiths_Tital_Wave_Knockback = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Captian_Kasiths_Tital_Wave_Knockback, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Captian_Kasiths_Tital_Wave_Knockback, Condition( function Trig_Captian_Kasiths_Tital_Wave_Knockback_Conditions ) )
    call TriggerAddAction( gg_trg_Captian_Kasiths_Tital_Wave_Knockback, function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions )
endfunction

please put this into warcraft 3 WE and try to enable it, because it should work and yet it dosent for example, one of the errors is:

Line 508: Expected a function name

(Line 508)
call ForGroupBJ( udg_Temp_Unit_Group, function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions2 )

All help would be apprecated, as this is the last known bug stopping me from starting beta testing and eventual releace on my new map version (i normally beta test for about a week to make shure there nothing i missed)
 
Level 8
Joined
Apr 4, 2005
Messages
499
Alright, this code here SHOULD work but the syntax checker went retarted when i ran the code through it:

JASS:
function Trig_Captian_Kasiths_Tital_Wave_Knockback_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A02E' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions takes nothing returns nothing
    set udg_Temp_Unit_Group = GetUnitsInRangeOfLocAll(650.00, GetUnitLoc(GetSpellAbilityUnit()))
    set udg_Temp_Unit = GetSpellAbilityUnit()
    call ForGroupBJ( udg_Temp_Unit_Group, function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions2 )
    set udg_Temp_Unit_Group = null
    set udg_Temp_Unit = null
    set udg_Temp_Unit2 = null
    set udg_Temp_Integer = null
endfunction

[COLOR="Red"]
function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions2 takes nothing returns nothing
    if ( function Trig_Captian_Kasiths_Tital_Wave_Knockback_ActionsCond ) then
        local timer t
        set udg_Temp_Unit2 = GetEnumUnit()
        set udg_Temp_Integer = DistanceBetweenPoints(GetUnitLoc(udg_Temp_Unit), GetUnitLoc(udg_Temp_Unit2))
        call TriggerSleepAction( udg_Temp_Integer )
        set t CreateTimer()
        call TimerStart(t, 0.01, true, function Knockback)
        call TriggerSleepAction( ((GetUnitAbilityLevelSwapped('A02E', udg_Temp_Unit) * 150) + 350) - udg_Temp_Integer)
        call DestroyTimer(t)
        set t = null
    else
    endif
endfunction[/COLOR]

function Knockback takes nothing returns nothing
    call SetUnitPositionLoc(udg_Temp_Unit2, PolarProjectionBJ(GetUnitLoc(udg_Temp_Unit), 10, AngleBetweenPoints(GetUnitLoc(udg_Temp_Unit), GetUnitLoc(udg_Temp_Unit2))))
endfunction

function Trig_Captian_Kasiths_Tital_Wave_Knockback_ActionsCond takes nothing returns boolean
    if ( not ( IsPlayerEnemy(GetOwningPlayer(GetEnumUnit()), GetOwningPlayer(GetSpellAbilityUnit())) == true ) ) then
        return false
    endif
    if ( not ( IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == false ) ) then
        return false
    endif
    return true
endfunction

//===========================================================================
function InitTrig_Captian_Kasiths_Tital_Wave_Knockback takes nothing returns nothing
    set gg_trg_Captian_Kasiths_Tital_Wave_Knockback = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Captian_Kasiths_Tital_Wave_Knockback, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Captian_Kasiths_Tital_Wave_Knockback, Condition( function Trig_Captian_Kasiths_Tital_Wave_Knockback_Conditions ) )
    call TriggerAddAction( gg_trg_Captian_Kasiths_Tital_Wave_Knockback, function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions )
endfunction

please put this into warcraft 3 WE and try to enable it, because it should work and yet it dosent for example, one of the errors is:



All help would be apprecated, as this is the last known bug stopping me from starting beta testing and eventual releace on my new map version (i normally beta test for about a week to make shure there nothing i missed)

To me it looks like the sentenceblock marked with blue is wrong, coz you ain't using the else function or endif. I've never tried jass before, but in C that would be a bug.
 
Level 7
Joined
Nov 12, 2005
Messages
299
> the italic text should not be there I think.
Nope, it has to be there. The ForGroup and ForGroupBJ functions take a code statement which is actually something like "function -function name-".
 
Level 1
Joined
Nov 11, 2006
Messages
1
what im seeing is in this line:
JASS:
set t CreateTimer()
it should be:
JASS:
set t = CreateTimer()

btw never listen to the line it says in WE. see if that works.
 

Oblivion

O

Oblivion

You need to declare the function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions2 before you can call it from other functions. In the code you posted, your Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions is trying to call it before it is actually defined.

In JASS, function names are recognized starting at the top of the code, and moving down. So you have to define a function first, before you can call it later in the code.

My suggested fix: cut the Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions2 function and paste it above the Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions function. :smile:

EDIT: I'm fixing the code now and will post it once it is fixed.

EDIT2: I can't fully validate your script because I don't have all your variables, but here is a version of the code with some things fixed:

JASS:
function Trig_Captian_Kasiths_Tital_Wave_Knockback_ActionsCond takes nothing returns boolean
    if ( not ( IsPlayerEnemy(GetOwningPlayer(GetEnumUnit()), GetOwningPlayer(GetSpellAbilityUnit())) == true ) ) then
        return false
    endif
    if ( not ( IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == false ) ) then
        return false
    endif
    return true
endfunction

function Knockback takes nothing returns nothing
    call SetUnitPositionLoc(udg_Temp_Unit2, PolarProjectionBJ(GetUnitLoc(udg_Temp_Unit), 10, AngleBetweenPoints(GetUnitLoc(udg_Temp_Unit), GetUnitLoc(udg_Temp_Unit2))))
endfunction

function Trig_Captian_Kasiths_Tital_Wave_Knockback_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A02E' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions2 takes nothing returns nothing
    local timer t
    if ( Trig_Captian_Kasiths_Tital_Wave_Knockback_ActionsCond() ) then
        set udg_Temp_Unit2 = GetEnumUnit()
        set udg_Temp_Integer = DistanceBetweenPoints(GetUnitLoc(udg_Temp_Unit), GetUnitLoc(udg_Temp_Unit2))
        call TriggerSleepAction( udg_Temp_Integer )
        set t = CreateTimer()
        call TimerStart(t, 0.01, true, function Knockback)
        call TriggerSleepAction( ((GetUnitAbilityLevelSwapped('A02E', udg_Temp_Unit) * 150) + 350) - udg_Temp_Integer)
        call DestroyTimer(t)
        set t = null
    else
    endif
endfunction

function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions takes nothing returns nothing
    set udg_Temp_Unit_Group = GetUnitsInRangeOfLocAll(650.00, GetUnitLoc(GetSpellAbilityUnit()))
    set udg_Temp_Unit = GetSpellAbilityUnit()
    call ForGroupBJ( udg_Temp_Unit_Group, function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions2 )
    set udg_Temp_Unit_Group = null
    set udg_Temp_Unit = null
    set udg_Temp_Unit2 = null
    set udg_Temp_Integer = null
endfunction



//===========================================================================
function InitTrig_Captian_Kasiths_Tital_Wave_Knockback takes nothing returns nothing
    set gg_trg_Captian_Kasiths_Tital_Wave_Knockback = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Captian_Kasiths_Tital_Wave_Knockback, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Captian_Kasiths_Tital_Wave_Knockback, Condition( function Trig_Captian_Kasiths_Tital_Wave_Knockback_Conditions ) )
    call TriggerAddAction( gg_trg_Captian_Kasiths_Tital_Wave_Knockback, function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions )
endfunction
 
Last edited by a moderator:
Level 2
Joined
Oct 2, 2006
Messages
24
:eekani: What did u do!?!? this aint JASS this is GUI converted.

This looks like it'll lagg bad!

Ill rewrite it for u in JASS. Expect it today or tommorrow

Something u might wanna know:

JASS get slower when the names of functions and vars get longer(i heard that)

U use a lot of BJ's and they mostly suck

Instead of working with locations u should use points since thats faster

Seeing u used getanyuniteventBJ i take it u want the spell to be MUI(able to cast it twice at the same time) if thats so u should use Katana's handle system. Globals ruin MUI.

If u dont want it to be MUI or if it doenst have to be dont use getanyunitevent.

Thats it for now

Keep an i out for my replie
 
Level 2
Joined
Oct 2, 2006
Messages
24
Well, i took a look at your trigger and rewrote a lot of it. Near the end i realized that what u try to do is impossible
I have added comments so u can see what i did and learn from that.

I chanced a lot.

The fact is that the trigger is impossible without Katana's handle system
You can't fire the same trigger multiple times for different units when using globals.






JASS:
function Trig_Captian_Kasiths_Tital_Wave_Knockback_unitfilter takes nothing returns boolean
    return (IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()),GetOwningPlayer(GetSpellAbilityUnit()))) and not(IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE))
endfunction

function Knockback takes nothing returns nothing
    local unit targ  // Here lies the problem. U want to call the same function for several units 
                    // at the same time. Thats impossible with global variables. 
                    // u need Katana's handle system for that. I suggest u get it at wc3sear.ch
    local unit cast // <== cast = udg_Temp_Unit
    local real angle = AngleBetweenPoints(Location(GetUnitX(cast),GetUnitY(cast)),Location(GetUnitX(targ),GetUnitY(targ)))
    local real newx = GetUnitX(targ) + 10 * Cos(angle * bj_DEGTORAD)  // instead of calling a function Polarprojection u can do the math 
    local real newy = GetUnitY(targ) + 10 * Sin(angle * bj_DEGTORAD)  // yourself. Calling a function takes proces time and costs time, 
    call SetUnitPosition(targ,newx,newy)                              // produces lagg. 
     
endfunction

function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions2 takes nothing returns nothing
    local timer t = CreateTimer()      // local MUST be declared before any other statement in the function. When declaring a local u can give it a value aswell.
    local real r
    local real r2 = X + DistanceBetweenPoints(Location(GetUnitX(cast),GetUnitY(cast)),Location(GetUnitX(targ),GetUnitY(targ)))
                    // X should be the distance that u want the targets to be knocked away
    local unit cast // cast = udg_Temp_Unit
    local unit targ = GetEnumUnit() // udg_Temp_Unit2 a global shouldnt be needed here
     // set udg_Temp_Integer = DistanceBetweenPoints(GetUnitLoc(udg_Temp_Unit), GetUnitLoc(udg_Temp_Unit2)) 
     // when the distance is lets say 300, the wait will be 300 seconds. I dont think u want that       
     // call TriggerSleepAction( udg_Temp_Integer )  i dont see why u want to wait here
        call TimerStart(t, 0.04, true, function Knockback)   // a 0.04 interval is fast enough for the eye and produces less lagg
     // call TriggerSleepAction( ((GetUnitAbilityLevelSwapped('A02E', udg_Temp_Unit) * 150) + 350) - udg_Temp_Integer)
               
loop // TriggerSleepAction seems to lagg when the wait is long so its faster to wait several short periods. 
        call TriggerSleepAction(0.1) // no matter how short u tell it to wait it won't be shorter then 0.27
        set r = DistanceBetweenPoints(Location(GetUnitX(cast),GetUnitY(cast)),Location(GetUnitX(targ),GetUnitY(targ)))
        exitwhen r >= ? // ? should be equal to or greater then the distance u want to target to be knockedback 
endloop                 // else your out of the game with one blow!
        call DestroyTimer(t)    
        set t = null
        set targ = null
endfunction

function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions takes nothing returns nothing
    // if place the if here the rest wont fire if the ability used wasnt 'A02e' 
if ( GetSpellAbilityId() == 'A02E' ) then   // u can declare the condiction like this. Is faster then calling another function.   
    set udg_Temp_Unit = GetSpellAbilityUnit()
    set udg_Temp_Unit_Group = GetUnitsInRangeOfLocMatching(650,Location(GetUnitX(udg_Temp_Unit),GetUnitY(udg_Temp_Unit)),Filter(function Trig_Captian_Kasiths_Tital_Wave_Knockback_unitfilter))    
    call ForGroup( udg_Temp_Unit_Group, function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions2 )     
    call DestroyGroup(udg_Temp_Unit_Group)
endif    
    set udg_Temp_Unit_Group = null    
    set udg_Temp_Unit = null 
    set udg_Temp_Unit2 = null    
    set udg_Temp_Integer = null 
endfunction
           
function InitTrig_Captian_Kasiths_Tital_Wave_Knockback takes nothing returns nothing
    set gg_trg_Captian_Kasiths_Tital_Wave_Knockback = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Captian_Kasiths_Tital_Wave_Knockback, EVENT_PLAYER_UNIT_SPELL_EFFECT )    
    call TriggerAddAction( gg_trg_Captian_Kasiths_Tital_Wave_Knockback, function Trig_Captian_Kasiths_Tital_Wave_Knockback_Actions )
endfunction

       // if u make the trigger run everytime the spell is cast, but before the effect takes place
       // (so no mana is deducted or cooldown is fired) u can abuse the spell easily.
       // so i changed that
 
Status
Not open for further replies.
Top