• 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] Problems with callfourgroup

Status
Not open for further replies.
Level 12
Joined
Mar 23, 2008
Messages
942
I'm very newbie with Jass, so normaly I try to do the spell with gui and them convert to jass when I need to use jass-only codes.

The trigger bellow should summon a sword in front of a gate and them start moving them forward. It is still missing the part where if a unit comes in 80 range of the sword it deals damage: (5 * Level of Gate of Babylon for Sumerian King).
  • Gate move
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units of type Sumerian King) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked unit)) Greater than or equal to 15
            • Then - Actions
              • Unit Group - Pick every unit in (Units of type Gate of Babylon) and do (Actions)
                • Loop - Actions
                  • Set tempunit[0] = (Picked unit)
              • Set tempreal = (Facing of tempunit[0])
              • Unit - Create 1 Sword for (Owner of (Picked unit)) at temppoint facing (Facing of tempunit[0]) degrees
              • Unit Group - Add (Last created unit) to tempgroup
            • Else - Actions
              • Unit - Set the custom value of (Picked unit) to ((Custom value of (Picked unit)) + 1)
      • Unit Group - Pick every unit in tempgroup and do (Actions)
        • Loop - Actions
          • Set temppoint = ((Position of (Picked unit)) offset by 40.00 towards (Facing of (Picked unit)) degrees)
          • Unit - Move (Picked unit) instantly to temppoint
but it looks like that in Jass

JASS:
function Trig_Gate_move_Func001Func001Func001A takes nothing returns nothing
    set udg_tempunit[0] = GetEnumUnit()
    set udg_temppoint = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), GetRandomReal(0, 100.00), ( ( GetUnitFacing(GetEnumUnit()) + ( I2R(GetRandomInt(-1, 1)) * 90.00 ) ) + 1 ))
endfunction

function Trig_Gate_move_Func001Func001C takes nothing returns boolean
    if ( not ( GetUnitUserData(GetEnumUnit()) >= 15 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Gate_move_Func001A takes nothing returns nothing
    if ( Trig_Gate_move_Func001Func001C() ) then
        call ForGroupBJ( GetUnitsOfTypeIdAll('h00N'), function Trig_Gate_move_Func001Func001Func001A )
        set udg_tempreal = GetUnitFacing(udg_tempunit[0])
        call CreateNUnitsAtLoc( 1, 'h00I', GetOwningPlayer(GetEnumUnit()), udg_temppoint, GetUnitFacing(udg_tempunit[0]) )
        call GroupAddUnitSimple( GetLastCreatedUnit(), udg_tempgroup )
    else
        call SetUnitUserData( GetEnumUnit(), ( GetUnitUserData(GetEnumUnit()) + 1 ) )
    endif
endfunction

function Trig_Gate_move_Func002A takes nothing returns nothing
    set udg_temppoint = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), 40.00, GetUnitFacing(GetEnumUnit()))
    call SetUnitPositionLoc( GetEnumUnit(), udg_temppoint )
endfunction

function Trig_Gate_move_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsOfTypeIdAll('H00L'), function Trig_Gate_move_Func001A )
    call ForGroupBJ( udg_tempgroup, function Trig_Gate_move_Func002A )
endfunction

//===========================================================================
function InitTrig_Gate_move takes nothing returns nothing
    set gg_trg_Gate_move = CreateTrigger(  )
    call DisableTrigger( gg_trg_Gate_move )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Gate_move, 0.04 )
    call TriggerAddAction( gg_trg_Gate_move, function Trig_Gate_move_Actions )
endfunction

Someone could help-me putting all the actions in the same function? So I can use locals ^^
Thanks!
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
Here:


JASS:
function Gate_Move takes nothing returns nothing
    local group g = CreateGroup()
    local group g2 = CreateGroup()
    local unit u
    local unit u2
    local player p
    local real x1
    local real y1
    local real x2
    local real y2
    call GroupEnumUnitsOfType(g, GetObjectName('H00L'), null)
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        call GroupRemoveUnit(g, u)
        if GetUnitUserData(u) >= 15 then
            call GroupEnumUnitsOfType(g2, GetObjectName('h00N'), null)
            loop
                set u2 = FirstOfGroup(g2)
                exitwhen u2 == null
                call GroupRemoveUnit(g2, u2)
                set p = GetOwningPlayer(u)
                set x1 = GetUnitX(u)
                set y1 = GetUnitY(u)
                set x2 = x1 + (GetRandomReal(0, 100.) * Cos((GetUnitFacing(u) + (GetRandomReal(-1., 1.) * 90.) + 1.) * bj_DEGTORAD))
                set y2 = y1 + (GetRandomReal(0, 100.) * Sin((GetUnitFacing(u) + (GetRandomReal(-1., 1.) * 90.) + 1.) * bj_DEGTORAD))
                call CreateUnit(p, 'h00I', x2, y2, GetUnitFacing(u))
                set u2 = null
                set p = null
            endloop
            call DestroyGroup(g2)
            set g2 = null
        else
             call SetUnitUserData(u, GetUnitUserData(u) + 1)
        endif
        set u = null
    endloop
    call DestroyGroup(g)
    set g = null
    call GroupEnumUnitsOfType(g, GetObjectName('h00I'), null)
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        call GroupRemoveUnit(g, u)
        set x1 = GetUnitX(u)
        set y1 = GetUnitY(u)
        set x2 = x1 + (40. * Cos(GetUnitFacing(u) * bj_DEGTORAD))
        set y2 = y1 + (40. * Sin(GetUnitFacing(u) * bj_DEGTORAD))
        call SetUnitPosition(u, x2, y2)
        set u = null
    endloop
    call DestroyGroup(g)
    set g = null
endfunction

//===========================================================================
function InitTrig_Gate_move takes nothing returns nothing
    set gg_trg_Gate_move = CreateTrigger( )
    call DisableTrigger( gg_trg_Gate_move )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Gate_move, 0.04 )
    call TriggerAddAction( gg_trg_Gate_move, function Gate_Move )
endfunction

I think this should work
 
Level 12
Joined
Mar 23, 2008
Messages
942
Sorry, its not working :(
(I modified to be able to do damage, still missing the condition to make them vanish after 800 range)

I will try to only make spells that I can effectively trigger, I loose a lot of time trying to do perfect spells...

JASS:
function Range_Conditions takes nothing returns boolean
    return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false
endfunction

function Gate_Move takes nothing returns nothing
    local group g = CreateGroup()
    local group g2 = CreateGroup()
    local group tg = CreateGroup()
    local location pt
    local unit king
    local unit u
    local unit u2
    local unit u3
    local player p
    local real x1
    local real y1
    local real x2
    local real y2
    local boolexpr b = Condition(function Range_Conditions)
    call GroupEnumUnitsOfType(g, GetObjectName('H00L'), null)
    loop
        set u = FirstOfGroup(g)
        set king = u
        exitwhen u == null
        call GroupRemoveUnit(g, u)
        if GetUnitUserData(u) >= 15 then
            call GroupEnumUnitsOfType(g2, GetObjectName('h00N'), null)
            loop
                set u2 = FirstOfGroup(g2)
                exitwhen u2 == null
                call GroupRemoveUnit(g2, u2)
                set p = GetOwningPlayer(u)
                set x1 = GetUnitX(u)
                set y1 = GetUnitY(u)
                set x2 = x1 + (GetRandomReal(0, 100.) * Cos((GetUnitFacing(u) + (GetRandomReal(-1., 1.) * 90.) + 1.) * bj_DEGTORAD))
                set y2 = y1 + (GetRandomReal(0, 100.) * Sin((GetUnitFacing(u) + (GetRandomReal(-1., 1.) * 90.) + 1.) * bj_DEGTORAD))
                call CreateUnit(p, 'h00I', x2, y2, GetUnitFacing(u))
                set u2 = null
                set p = null
            endloop
            call DestroyGroup(g2)
            set g2 = null
        else
             call SetUnitUserData(u, GetUnitUserData(u) + 1)
        endif
        set u = null
    endloop
    call DestroyGroup(g)
    set g = null
    call GroupEnumUnitsOfType(g, GetObjectName('h00I'), null)
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        set pt = GetUnitLoc(u)
        call SetUnitUserData(u, (GetUnitAbilityLevel(king, 'A029')*5))
        set tg = GetUnitsInRangeOfLocMatching(80, pt, b)
        if IsUnitGroupEmptyBJ(tg) == false then
          loop
              set u3 = FirstOfGroup(g)
              exitwhen u3 == null
              if IsUnitEnemy(u3, GetOwningPlayer(king)) then
                call UnitDamageTarget(udg_PlayerHero[GetConvertedPlayerId(GetOwningPlayer(king))], u3, (GetUnitUserData(u)), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
                call RemoveUnit(u)
                set g = null
                set tg = null
                set king = null
                call RemoveLocation(pt)
                set pt = null
              endif
          endloop
        else
        call GroupRemoveUnit(g, u)
        set x1 = GetUnitX(u)
        set y1 = GetUnitY(u)
        set x2 = x1 + (40. * Cos(GetUnitFacing(u) * bj_DEGTORAD))
        set y2 = y1 + (40. * Sin(GetUnitFacing(u) * bj_DEGTORAD))
        call SetUnitPosition(u, x2, y2)
        set u = null
        endif
    endloop
    call DestroyGroup(g)
    set g = null
    set tg = null
    set king = null
    call RemoveLocation(pt)
    set pt = null
endfunction

//===========================================================================
function InitTrig_Gate_move takes nothing returns nothing
    set gg_trg_Gate_move = CreateTrigger( )
    call DisableTrigger( gg_trg_Gate_move )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Gate_move, 0.04 )
    call TriggerAddAction( gg_trg_Gate_move, function Gate_Move )
endfunction

Thanks for your help ^^
(+rep)
 
Status
Not open for further replies.
Top