• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Working with Jass

Status
Not open for further replies.
Level 6
Joined
Oct 14, 2010
Messages
58
hi

working in jass arose problem, I did not want to use BJ
I used a local variable

Please tell me what this code is not so

JASS:
function Trig_StartGame_Condition takes nothing returns boolean
    return ( GetPlayerSlotState(ConvertedPlayer(i)) == PLAYER_SLOT_STATE_PLAYING )
endfunction
function Trig_StartGame_Actions takes nothing returns nothing
    local integer i = 1
    set i = 1
    loop
        exitwhen i > 6
        if ( Trig_StartGame_Condition() ) then
        call CreateNUnitsAtLoc( 1, 'H003', ConvertedPlayer(i), udg_ArcherPoint[GetConvertedPlayerId(ConvertedPlayer(GetForLoopIndexA()))], 45.00 )
        set udg_archer[GetConvertedPlayerId(ConvertedPlayer(i))] = GetLastCreatedUnit()
        call UnitAddItemByIdSwapped( 'I001', GetLastCreatedUnit() )
        call SelectUnitForPlayerSingle( GetLastCreatedUnit(), ConvertedPlayer(i) )
        call PanCameraToTimedLocForPlayer( ConvertedPlayer(i), GetUnitLoc(GetLastCreatedUnit()), 0.50 )
        endif
        set i = i + 1
    endloop
    set i = 7
    loop
        exitwhen i > 12
        if ( Trig_StartGame_Condition() ) then
        call CreateNUnitsAtLoc( 1, 'H003', ConvertedPlayer(i), udg_ArcherPoint[GetConvertedPlayerId(ConvertedPlayer(GetForLoopIndexA()))], 225.00 )
        set udg_archer[GetConvertedPlayerId(ConvertedPlayer(i))] = GetLastCreatedUnit()
        call UnitAddItemByIdSwapped( 'I001', GetLastCreatedUnit() )
        call SelectUnitForPlayerSingle( GetLastCreatedUnit(), ConvertedPlayer(i) )
        call PanCameraToTimedLocForPlayer( ConvertedPlayer(i), GetUnitLoc(GetLastCreatedUnit()), 0.50 )
        endif
        set i = i + 1
    endloop
    call DestroyTrigger( GetTriggeringTrigger() )
    endfunction
function InitTrig_StartGame takes nothing returns nothing
    set gg_trg_StartGame = CreateTrigger( )
    call TriggerRegisterTimerEventSingle( gg_trg_StartGame, 1.10 )
    call TriggerAddAction( gg_trg_StartGame, function Trig_StartGame_Actions )
endfunction

thx. I newbie in Jass)
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Hmm as I see you mainly just converted GUI to Jass. But this what you got there, is bad Jass because it's just converted.

Your trigger must look like this ( I hope I did it correctly now^^ )

JASS:
function StartGame takes nothing returns nothing
    local real f = 0.00 // Facing
    local integer i = 0 // For the loop
    local unit u // For the unit ( that is created )
    local real x = GetRectCenterX(udg_ArcherPoint) // WHERE the unit is created (x)
    local real y = GetRectCenterY(udg_ArcherPoint) // WHERE the unit us created (y)
    
    loop
        exitwhen i == 11
        if i <= 4 then
            set f = 45.00
        elseif i > 4 then
            set f = 225.00
        endif
        
        if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
            set u = CreateUnit(Player(i),'H003',x,y,f)
            call UnitAddItem(u,'I001')
            if GetLocalPlayer() == Player(i) then
                call ClearSelection()
                call SelectUnit(u,true)
                call PanCameraToTimed(x,y,0.50)
            endif
            set i = i + 1
            set u = null
        endif
    endloop
endfunction

function InitTrig_StartGame takes nothing returns nothing
    set gg_trg_StartGame = CreateTrigger( )
    call TriggerRegisterTimerEvent(gg_trg_StartGame,1.10,false)
    call TriggerAddAction( gg_trg_StartGame, function Trig_StartGame_Actions )
endfunction

NOTE: Player 1 (RED) is in Jass Player(0) so Player 12 (Brown) is in Jass Player(11)!

Greetings and Peace
Dr. Boom
 
Level 6
Joined
Oct 14, 2010
Messages
58
Wow) Thanks) Do not think that everything is arranged)

With the help of which learned to write in Jass?


and name
JASS:
function ========StartGame======= takes nothing returns nothing
    //actions
function InitTrig_StartGame takes nothing returns nothing
    set gg_trg_StartGame = CreateTrigger( )
    call TriggerRegisterTimerEvent(gg_trg_StartGame,1.10,false)
    call TriggerAddAction( gg_trg_StartGame, function =====Trig_StartGame_Actions====== )
endfunction
its mistake?
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin T_T

YES! f**k it's a mistake ^^ I always forget to change this =D

The master of Jass (for me) when I learned jass ( and he still is for me) is: ap0calypse. He teach me sooooo many things about it!!!!! ( Thanks again to you ap0calypse at this point! )


But also if you learn jass you should use the JNGP and the Jasshelper. The jasshelper ( in the JNPG ) is a useful tool for learning jass.

Btw. I learn vJass now ;) - you should directly start with this - it's very cool and you can do everything! ;)

Greetings and Peace
Dr. Boom
 
Status
Not open for further replies.
Top