• 🏆 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] Difficult-to-identify error

Status
Not open for further replies.
Level 8
Joined
Aug 13, 2009
Messages
466
Lo, I has problem.

This trigger seems to be causing 390 compile errors (most of them irrational as is the blizzard parser's wont :( ). The trigger was converted from GUI then heavily modified and triggers when a spell is cast, then checks if that spell is the correct one as usual.

Most of the trigger was written using a (presumably) rather old version of PJASS (in the JassCraft program), and the trigger uses Daelin's Geometrical checks to see if a unit is within a rectangle or not. There may be issues with how I generate the points/coordinates; I haven't even been able to test this due to the trigger not working.

Uncertain areas include how I use the filter function for my pick, and certain local var declarations.

JassCraft gives errors on:

Line 90: local integer sfxcount = 0 <cannot convert real to integer>

Line 93: call GroupEnumUnitsOfType(dashgroup,'E000', Filter(function dash_filter)) <cannot convert integer to string>

(I've checked different values for this, I may have the wrong one)

Line 127: call TriggerRegisterAnyUnitEventBJ( gg_trg_DragonDash_RectFunc, EVENT_PLAYER_UNIT_SPELL_EFFECT ) <Undeclared variable: gg_trg_DragonDash_RectFunc>

The full trigger plus map header dependencies is:

JASS:
function GetAngleBetweenPoints takes real x1, real y1, real x2, real y2 returns real
    return bj_RADTODEG * Atan2(y2 - y1, x2 - x1)
endfunction

function PolarProjectionX takes real x, real distance, real angle returns real
    return x+distance*Cos(angle * bj_DEGTORAD)
endfunction

function PolarProjectionY takes real y, real distance, real angle returns real
    return y+distance*Sin(angle * bj_DEGTORAD)
endfunction


function IsPointInTriangle takes real x1, real y1, real x2, real y2, real x3, real y3, real x, real y returns boolean
    local real calc1 = (y-y1)*(x2-x1) - (x-x1)*(y2-y1)
    local real calc2 = (y-y3)*(x1-x3) - (x-x3)*(y1-y3)
    local real calc3 = (y-y2)*(x3-x2) - (x-x2)*(y3-y2)
    return (calc1*calc2>0) and (calc3*calc2>0)
endfunction


function IsPointInRectangle takes real x1, real y1, real x2, real y2, real x3, real y3, real x4, real y4, real x, real y returns boolean
    return IsPointInTriangle(x1,y1,x2,y2,x3,y3,x,y) or IsPointInTriangle(x4,y4,x2,y2,x3,y3,x,y) or IsPointInTriangle(x1,y1,x4,y4,x3,y3,x,y) or IsPointInTriangle(x1,y1,x2,y2,x4,y4,x,y)
endfunction


function IsPointInCircle takes real xC, real yC, real radius, real x, real y returns boolean
    local real xx = xC-x
    local real yy = yC-y
    return xx*xx + yy*yy<=radius*radius
endfunction


function IsPointInCircleSector takes real xC, real yC, real radius, real x, real y, real angleA, real angleB returns boolean
    local real angle = GetAngleBetweenPoints(xC,yC,x,y)
    local real aux

    if angleA>angleB then
        set aux=angleA
        set angleA=angleB
        set angleB=aux
    endif

    return IsPointInCircle(xC,yC,radius,x,y) and angle>=angleA and angle<=angleB
endfunction


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

function Trig_DragonDash_Copy_Func002C takes nothing returns boolean
    if ( not ( DistanceBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetSpellTargetLoc()) >= 100.00 ) ) then
        return false
    endif
    return true
endfunction

function dash_filter takes nothing returns boolean
if (IsUnitDeadBJ(GetFilterUnit()) == true)then
return false
endif
return true
endfunction

function Trig_DragonDash_Copy_Actions takes nothing returns nothing
        local group dashgroup = CreateGroup()
        local unit dashtrig = GetTriggerUnit()
        local unit dashed = null
        local location dashcastloc = GetUnitLoc(dashtrig)
        local location dashcasttarget = GetSpellTargetLoc()
        local real Dashdirection = AngleBetweenPoints(dashcastloc, dashcasttarget)
        local real dashdistance = DistanceBetweenPoints(dashcastloc, dashcasttarget)
        local real x = GetLocationX(dashcastloc)
        local real x1 = GetLocationX(dashcastloc) + 75 * Cos((Dashdirection-90)* bj_DEGTORAD)
        local real x2 = GetLocationX(dashcastloc) + 75 * Cos((Dashdirection+90)* bj_DEGTORAD)
        local real x3 = x1 + dashdistance * Cos(Dashdirection * bj_DEGTORAD)
        local real x4 = x2 + dashdistance * Cos(Dashdirection * bj_DEGTORAD)
        local real y = GetLocationY(dashcastloc)
        local real y1 = GetLocationY(dashcastloc) + 75 * Sin((Dashdirection-90)* bj_DEGTORAD)
        local real y2 = GetLocationY(dashcastloc) + 75 * Sin((Dashdirection+90)* bj_DEGTORAD)
        local real y3 = y1+ dashdistance * Sin(Dashdirection * bj_DEGTORAD)
        local real y4 = y2 + dashdistance * Sin(Dashdirection * bj_DEGTORAD)
        local real dashedX = 0
        local real dashedY = 0
        local integer sfxmax = dashdistance / 100
        local integer sfxcount = 0
        // This is a rather riotous mass of locals, but it is needed to use the IsUnitInRectangle function. I hope I did it right.
        if (Trig_DragonDash_Copy_Func002C()) then
        call GroupEnumUnitsOfType(dashgroup,'E000', Filter(function dash_filter))
        loop
        set dashed = FirstOfGroup(dashgroup)
        exitwhen dashed == null
        set dashedX = GetUnitX(dashed)
        set dashedY = GetUnitY(dashed)
        if ( IsPointInRectangle(x1, y1, x2, y2, x3, y3, x4, y4, dashedX, dashedY))then
        call UnitDamageTarget(dashtrig, dashed, 1.00, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNKNOWN, WEAPON_TYPE_WHOKNOWS)
        endif
        call GroupRemoveUnit(dashgroup, dashed)
        endloop
        // sfx loop
        loop
        call AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl",x + (100.00*I2R(sfxcount)) * Cos(Dashdirection*bj_DEGTORAD), y + (100.00*I2R(sfxcount)) * Sin(Dashdirection*bj_DEGTORAD))
        call DestroyEffect(GetLastCreatedEffectBJ())
        set sfxcount = sfxcount + 1 
        exitwhen sfxmax == sfxcount
        endloop
        else
        //-------------Error Sound-----------------
        if (GetLocalPlayer()==(GetOwningPlayer(GetTriggerUnit()))) then
        // Will eventually .mp3 this sound (hopefully)
        call PlaySoundBJ( gg_snd_Error )
        endif
        call DisplayTextToForce( GetForceOfPlayer(GetOwningPlayer(GetTriggerUnit())), "TRIGSTR_374" )
        // This refreshes the skill's cooldown
        call UnitRemoveAbilityBJ( 'A004', GetTriggerUnit() )
        call UnitAddAbilityBJ( 'A004', GetTriggerUnit() )
    endif
endfunction

//===========================================================================
function InitTrig_DragonDash_RectFunc takes nothing returns nothing
    set gg_trg_DragonDash_RectFunc = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_DragonDash_RectFunc, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_DragonDash_RectFunc, Condition( function Trig_DragonDash_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_DragonDash_RectFunc, function Trig_DragonDash_Copy_Actions )
endfunction

Help plix? *casts Eyes of the Puppy*
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
You need to do this:

local integer sfxmax = R2I(dashdistance / 100)


As for the other error, GroupEnumUnitsOfType function indeed takes a string as an argument, not an integer. So you have to type the unit name here, which I believe is the type, not the proper name. For example: "Paladin", "Blood Mage", "Peasant"...

Though I'm not sure if that function works properly.
 
Level 8
Joined
Aug 13, 2009
Messages
466
Thanks for the help - the function now runs - but unfortunately, it woudl appear the damage is not being dealt due to no untis being enumerated. It has something to do with the unit string expected, I think...

The GroupEnumUnitsOfType function appears to be very loopy. I set up this trigger to test it, placing some demon hunters on the map and additionally having masses of demonhunter based units there:

JASS:
function DEBFILT takes nothing returns boolean
return true
endfunction

function Trig_EnumTest_Actions takes nothing returns nothing
   local group lol = CreateGroup()
   local unit DEBUNIT
   call DisplayTextToForce(GetPlayersAll(), "ENUMTEST RUNNING")
   call GroupEnumUnitsOfType(lol, "Ninja", Filter(function DEBFILT))
loop
   set DEBUNIT = FirstOfGroup(lol)
   exitwhen DEBUNIT == null
   call DisplayTextToForce(GetPlayersAll(), GetUnitName(DEBUNIT))
   call GroupRemoveUnit(lol, DEBUNIT)   
endloop
endfunction

//===========================================================================
function InitTrig_EnumTest takes nothing returns nothing
    set gg_trg_EnumTest = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_EnumTest, Player(0), "-et", true )
    call TriggerAddAction( gg_trg_EnumTest, function Trig_EnumTest_Actions )
endfunction

The first message is displayed, but the rest are not, when having no real demonhutners on the map. Any idea of what string is expected or what I'm doing wrong? I realize I could pick a less weird function, but I'd rather avoid If's three deep, and I hate rewriting triggers :).

Tried: "E000", "Edem" (CTRL+D code for unit, along with E000), "herodemonhunter", "HeroDemonHunter", "Demon Hunter", "Demon_Hunter", "demon_hunter"

EDIT: "demonhunter" works o_O

EDIT2: Wow, trigger was an infinite loop. "demonhunter" doesn't seem to work for the ninja though, and neither does "ninja". Perhaps capitalization is needed...

EDIT3: The mystery thinkens. "Ninja" does not work.

EDIT4; I think this name stuff is something hardcoded, which will likely not even exist for custom units. I will switch to a different function.
 
Last edited:
Status
Not open for further replies.
Top