Need help with my vJass trigger!

Regga-Voska

New Member
Reaction score
0
Hi, I am new to vJass, as you can see...
JASS:
//Move and rotate the picked unit, make the owner of the picked unit face the same angle as the picked unit and also pan the camera to the units location.
function Trig_Execute_Player_Reds_Unit_Functions_Func002Func005A takes nothing returns nothing
    call SetCameraFieldForPlayer( GetOwningPlayer(GetEnumUnit()), CAMERA_FIELD_ROTATION, GetUnitFacing(GetEnumUnit()), 0.10 )
    call PanCameraToTimedLocForPlayer( GetOwningPlayer(GetEnumUnit()), udg_Temp_Point_Red, 0.10 )
endfunction

function Trig_Execute_Player_Reds_Unit_Functions_Func002A takes nothing returns nothing
    set udg_Temp_Point_Red = GetUnitLoc(GetEnumUnit())
    set udg_Temp_Point_Red_Two = PolarProjectionBJ(udg_Temp_Point_Red, udg_Move_Red, ( GetUnitFacing(GetEnumUnit()) + udg_Rotation_Red ))
    call SetUnitPositionLoc( GetEnumUnit(), udg_Temp_Point_Red_Two )
    call SetUnitFacingTimed( GetEnumUnit(), ( GetUnitFacing(GetEnumUnit()) + ( udg_Rotation_Red + udg_Bonus_Rotation[1] ) ), 0 )
    call ForGroupBJ( udg_Temp_Group_Red, function Trig_Execute_Player_Reds_Unit_Functions_Func002Func005A )
    call RemoveLocation (udg_Temp_Point_Red)
    call RemoveLocation (udg_Temp_Point_Red_Two)
endfunction

function Trig_Execute_Player_Reds_Unit_Functions_Actions takes nothing returns nothing
    set udg_Temp_Group_Red = GetUnitsOfPlayerAndTypeId(Player(0), 'h000')
    call ForGroupBJ( udg_Temp_Group_Red, function Trig_Execute_Player_Reds_Unit_Functions_Func002A )
    call DestroyGroup (udg_Temp_Group_Red)
endfunction

//Periodic Event "Every 0.02 second"
function InitTrig_Execute_Player_Reds_Unit_Functions takes nothing returns nothing
    set gg_trg_Execute_Player_Reds_Unit_Functions = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Execute_Player_Reds_Unit_Functions, 0.02 )
    call TriggerAddAction( gg_trg_Execute_Player_Reds_Unit_Functions, function Trig_Execute_Player_Reds_Unit_Functions_Actions )
endfunction
//Done
But I got a few errors called Undeclared Variables, and may I ask you guys how to fix them?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Try this:
JASS:
scope Name initializer Init

    globals
        private group Red = CreateGroup()
        private constant integer MoveRed = 100
        private constant integer RotationRed = 100
        private integer array BonusRotation
    endglobals
    
    private function RedGroup takes nothing returns nothing
        local unit eu = GetEnumUnit()
        local real x = GetUnitX(eu)
        local real y = GetUnitY(eu)
        local real x2 = x + MoveRed * Cos(RotationRed * bj_DEGTORAD)
        local real y2 = y + MoveRed * Sin(RotationRed * bj_DEGTORAD)
        
        call SetUnitX(eu, x2)
        call SetUnitY(eu, y2)
        call SetUnitFacingTimed(eu, GetUnitFacing(eu) + (RotationRed + BonusRotation[1]), 0)
        if(GetLocalPlayer() == GetOwningPlayer(eu)) then
            call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(eu), 0.10)
        endif
        if(GetLocalPlayer() == GetOwningPlayer(eu)) then
            call PanCameraToTimed(x, y, 0.10)
        endif
        call GroupRemoveUnit(Red, eu)
        set eu = null
    endfunction
    
    private function Actions takes nothing returns nothing
        set bj_groupEnumTypeId = 'h000'
        call GroupEnumUnitsOfPlayer(Red, Player(0), filterGetUnitsOfPlayerAndTypeId)
        call ForGroup(Red, function RedGroup)
    endfunction


//====================================================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()   //Create the trigger
        
        call TriggerRegisterTimerEvent(t, 0.02, true)   //0.02 periodic event
        call TriggerAddAction(t, function Actions)   //Actions for your trigger
    endfunction

endscope
 

Regga-Voska

New Member
Reaction score
0
Try this:
JASS:
scope Name initializer Init

    globals
        private group Red = CreateGroup()
        private constant integer MoveRed = 100
        private constant integer RotationRed = 100
        private integer array BonusRotation
    endglobals
    
    private function RedGroup takes nothing returns nothing
        local unit eu = GetEnumUnit()
        local real x = GetUnitX(eu)
        local real y = GetUnitY(eu)
        local real x2 = x + MoveRed * Cos(RotationRed * bj_DEGTORAD)
        local real y2 = y + MoveRed * Sin(RotationRed * bj_DEGTORAD)
        
        call SetUnitX(eu, x2)
        call SetUnitY(eu, y2)
        call SetUnitFacingTimed(eu, GetUnitFacing(eu) + (RotationRed + BonusRotation[1]), 0)
        if(GetLocalPlayer() == GetOwningPlayer(eu)) then
            call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(eu), 0.10)
        endif
        if(GetLocalPlayer() == GetOwningPlayer(eu)) then
            call PanCameraToTimed(x, y, 0.10)
        endif
        call GroupRemoveUnit(Red, eu)
        set eu = null
    endfunction
    
    private function Actions takes nothing returns nothing
        set bj_groupEnumTypeId = 'h000'
        call GroupEnumUnitsOfPlayer(Red, Player(0), filterGetUnitsOfPlayerAndTypeId)
        call ForGroup(Red, function RedGroup)
    endfunction


//====================================================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()   //Create the trigger
        
        call TriggerRegisterTimerEvent(t, 0.02, true)   //0.02 periodic event
        call TriggerAddAction(t, function Actions)   //Actions for your trigger
    endfunction

endscope

Thank you one hundred and twenty five thousand times!
But, I guess I can't just Copy/Paste and replace my current trigger.
Am I correct? Because when I did that all my older errors disappeared BUT it came 53 new errors such as Statement outside of function, Syntax Error, Missing line break etc.
 

Regga-Voska

New Member
Reaction score
0
You can place that into any trigger.
You just need NewGen (You should have it if you're doing vJASS :confused: ) .

That's exactly the same thing I downloaded a few hours ago. And i guess it's working correctly for me.
(When i trying to run the map, the Wc3 intro screen comes up, but the map where never loaded)
And all my variables will/needs to be affected by other triggers.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Could you post a screenshot of the errors or show me some lines that error?

EDIT: Also, make sure to have vJASS Syntax active.
 

Regga-Voska

New Member
Reaction score
0
Could you post a screenshot of the errors or show me some lines that error?

EDIT: Also, make sure to have vJASS Syntax active.

errors.jpg

There you go....
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I just copied the code into a new trigger and it worked fine.

Make a new trigger,
Convert it to custom text;
Then replace everything that's there with the code:
JASS:
scope Name initializer Init

    globals
        private group Red = CreateGroup()
        private constant integer MoveRed = 100
        private constant integer RotationRed = 100
        private integer array BonusRotation
    endglobals
    
    private function RedGroup takes nothing returns nothing
        local unit eu = GetEnumUnit()
        local real x = GetUnitX(eu)
        local real y = GetUnitY(eu)
        local real x2 = x + MoveRed * Cos(RotationRed * bj_DEGTORAD)
        local real y2 = y + MoveRed * Sin(RotationRed * bj_DEGTORAD)
        
        call SetUnitX(eu, x2)
        call SetUnitY(eu, y2)
        call SetUnitFacingTimed(eu, GetUnitFacing(eu) + (RotationRed + BonusRotation[1]), 0)
        if(GetLocalPlayer() == GetOwningPlayer(eu)) then
            call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(eu), 0.10)
        endif
        if(GetLocalPlayer() == GetOwningPlayer(eu)) then
            call PanCameraToTimed(x, y, 0.10)
        endif
        call GroupRemoveUnit(Red, eu)
        set eu = null
    endfunction
    
    private function Actions takes nothing returns nothing
        set bj_groupEnumTypeId = 'h000'
        call GroupEnumUnitsOfPlayer(Red, Player(0), filterGetUnitsOfPlayerAndTypeId)
        call ForGroup(Red, function RedGroup)
    endfunction


//====================================================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()   //Create the trigger
        
        call TriggerRegisterTimerEvent(t, 0.02, true)   //0.02 periodic event
        call TriggerAddAction(t, function Actions)   //Actions for your trigger
    endfunction

endscope
 

GooS

Azrael
Reaction score
154
I started the editor by pressing the Icon called NewGen WE.exe

vJASS requires you to actually save the map before testing it, otherwise it will just go to the wc3 main menu.

Also, the syntax checker is outdated (?) and does not work with vJASS, save is your only option of compiling.

Save before test map, always.
Even the slightest nudge in the code and you will have to re-compile the code.
Hope that works.

//==GooS
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Ahh yeah.
Don't use the "Syntax Check" button.
Just Save (CTRL + S) the map and if nothing comes up you're good!
 

Regga-Voska

New Member
Reaction score
0
Huh?

Okey, now the unit moves. But not when I want it to...
(It moves constantly)

EDIT: And it only moves right. It should move forward. (The angle of the unit)
I will give you an example, when the unit looks right, he should move right. When the unit looks left, it should move left etc.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top