• 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] vJass MUI attempt

Status
Not open for further replies.
Okay thank that let vjass compile, but the script doesn't work:

JASS:
scope fireboltNew
    struct structFirebolt
        real direction
        unit bird
        real distance
        unit target
    endstruct

    globals
        private timer time
        private structFirebolt array sDatabase
        private integer dbIndex=0
    endglobals
    
    function fireboltNewT takes nothing returns nothing
        local integer iLoop=0
        local structFirebolt sCurrent
        local group close=CreateGroup()
        loop
            exitwhen iLoop>=dbIndex
            set sCurrent=sDatabase[iLoop]
            call SetUnitPositionLoc(sCurrent.bird,PolarProjectionBJ(GetUnitLoc(sCurrent.bird),20,sCurrent.direction))
            call SetUnitPositionLoc(sCurrent.bird,PolarProjectionBJ(GetUnitLoc(sCurrent.bird),6,AngleBetweenPoints(GetUnitLoc(sCurrent.bird),GetUnitLoc(sCurrent.target))))
            call GroupEnumUnitsInRangeOfLoc(close,GetUnitLoc(sCurrent.bird),75,null)
            loop
                exitwhen FirstOfGroup(close)==null
                if GetOwningPlayer(FirstOfGroup(close))!=GetOwningPlayer(sCurrent.bird) and IsPlayerAlly(GetOwningPlayer(FirstOfGroup(close)),GetOwningPlayer(sCurrent.bird))!=true then
                    call UnitDamageTarget(sCurrent.bird,FirstOfGroup(close),10,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
                endif
                call GroupRemoveUnit(close,FirstOfGroup(close))
            endloop
            call DestroyGroup(close)
            set sCurrent.distance=sCurrent.distance+20
            if sCurrent.distance>1600 then
                set sDatabase[dbIndex]=sDatabase[iLoop]
                set dbIndex=dbIndex-1
                call KillUnit(sCurrent.bird)
            endif
            set iLoop=iLoop+1
            if dbIndex==0 then
                call DestroyTimer(time)
            endif
        endloop
    endfunction
    
    function fireboltNewC takes nothing returns boolean
        return GetSpellAbilityId()=='A000'
    endfunction
    
    function fireboltNewA takes nothing returns nothing
        local structFirebolt sTemp=structFirebolt.create()
        local location target=PolarProjectionBJ(GetUnitLoc(GetSpellAbilityUnit()),75,GetUnitFacing(GetSpellAbilityUnit()))
        local group getTarget=CreateGroup()
        set sTemp.direction=GetUnitFacing(GetSpellAbilityUnit())
        set sTemp.bird=CreateUnit(GetOwningPlayer(GetSpellAbilityUnit()),'h001',GetLocationX(target),GetLocationY(target),sTemp.direction)
        set sTemp.distance=0
        call GroupEnumUnitsInRangeOfLoc(getTarget,GetSpellTargetLoc(),200,null)
        set sTemp.target=getRandU(getTarget)
        if dbIndex==0 then
            set time=CreateTimer()
            call TimerStart(time,.03,true,function fireboltNewT)
        endif
        set sDatabase[dbIndex]=sTemp
        set dbIndex=dbIndex+1
        call DestroyGroup(getTarget)
    endfunction
    
    function InitTrig_fireboltNew takes nothing returns nothing
        set gg_trg_fireboltNew=CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(gg_trg_fireboltNew,EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(gg_trg_fireboltNew,Condition(function fireboltNewC))
        call TriggerAddAction(gg_trg_firebolt,function fireboltNewA)
    endfunction
endscope

When I cast the spell the unit isn't created. Nothing happens.
 
Replace your function with this..

JASS:
    function fireboltNewA takes nothing returns nothing
        local structFirebolt sTemp=structFirebolt.create()
        local location target=PolarProjectionBJ(GetUnitLoc(GetSpellAbilityUnit()),75,GetUnitFacing(GetSpellAbilityUnit()))
        local group getTarget=CreateGroup()
        call BJDebugMsg("Locals declared")
        set sTemp.direction=GetUnitFacing(GetSpellAbilityUnit())
        set sTemp.bird=CreateUnit(GetOwningPlayer(GetSpellAbilityUnit()),'h001',GetLocationX(target),GetLocationY(target),sTemp.direction)
        set sTemp.distance=0
        call BJDebugMsg("Struct members set")
        call GroupEnumUnitsInRangeOfLoc(getTarget,GetSpellTargetLoc(),200,null)
        set sTemp.target=getRandU(getTarget)
        call BJDebugMsg("Group enumerated")
        if dbIndex==0 then
            set time=CreateTimer()
            call TimerStart(time,.03,true,function fireboltNewT)
        endif
        set sDatabase[dbIndex]=sTemp
        set dbIndex=dbIndex+1
        call BJDebugMsg("end")
        call DestroyGroup(getTarget)
    endfunction

Tell me what messages display.
 
I fixed it.

This was my problem:

JASS:
        call TriggerAddCondition(gg_trg_fireboltNew,Condition(function fireboltNewC))
        call TriggerAddAction(gg_trg_firebolt,function fireboltNewA)

The action was never being called.

The next problem was that the action was being called twice, which turns out was because I used the initializer you said, but because I was using InitTrig, wc3 was initializing it itself.

Thanks for the help. +reps ofc
 
Status
Not open for further replies.
Top