• 🏆 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!

local unit

Status
Not open for further replies.
Level 4
Joined
Aug 18, 2013
Messages
71
Hi guys, I'm new with jass. like this being converted gui, and I'm adding something to it for improvised functionality.

What I added was "local unit u = GetDyingUnit()" but i get errors saying expected a statement on this line etc. I have several years of c++/java coding experience so I understand that my syntax is incorrect. but this is what other people i've looked at on the forums use. Any help?

Code:
function Trig_ReviveHerotest_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_ReviveHerotest_Func010C takes nothing returns boolean
    if ( not ( IsPlayerAlly(GetOwningPlayer(GetDyingUnit()), Player(9)) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_ReviveHerotest_Actions takes nothing returns nothing
    set udg_DeathTimeWait[GetConvertedPlayerId(GetOwningPlayer(GetDyingUnit()))] = ( I2R(GetHeroLevel(GetDyingUnit())) * 1.50 )
    set udg_DeathTimeWait[GetConvertedPlayerId(GetOwningPlayer(GetDyingUnit()))] = ( udg_DeathTimeWait[GetConvertedPlayerId(GetOwningPlayer(GetDyingUnit()))] + 15.00 )
    local unit u = GetDyingUnit()
    call StartTimerBJ( udg_DeathTimer[GetConvertedPlayerId(GetOwningPlayer(GetDyingUnit()))], false, udg_DeathTimeWait[GetConvertedPlayerId(GetOwningPlayer(GetDyingUnit()))] )
    call CreateTimerDialogBJ( udg_DeathTimer[R2I(udg_DeathTimeWait[GetConvertedPlayerId(GetOwningPlayer(GetDyingUnit()))])], "TRIGSTR_2145" )
    call TimerDialogDisplayForPlayerBJ( true, udg_DeathTimer_Window[GetConvertedPlayerId(GetOwningPlayer(GetDyingUnit()))], GetOwningPlayer(GetDyingUnit()) )
    call PolledWait( udg_DeathTimeWait[R2I(udg_DeathTimeWait[GetConvertedPlayerId(GetOwningPlayer(GetDyingUnit()))])] )
    call TimerDialogDisplayForPlayerBJ( false, udg_DeathTimer_Window[GetConvertedPlayerId(GetOwningPlayer(u))], GetOwningPlayer(u) )
    call DestroyTimerDialogBJ( udg_DeathTimer_Window[GetConvertedPlayerId(GetOwningPlayer(u))] )
    if ( Trig_ReviveHerotest_Func010C() ) then
        call ReviveHeroLoc( GetDyingUnit(), GetRectCenter(gg_rct_LightSidePool), true )
        call PanCameraToTimedLocForPlayer( GetOwningPlayer(GetDyingUnit()), GetRectCenter(gg_rct_LightSidePool), 0.00 )
    else
        call ReviveHeroLoc( GetDyingUnit(), GetRectCenter(gg_rct_DarkSidePool), true )
        call PanCameraToTimedLocForPlayer( GetOwningPlayer(GetDyingUnit()), GetRectCenter(gg_rct_DarkSidePool), 0.00 )
    endif
    set u = null
endfunction

//===========================================================================
function InitTrig_ReviveHerotest takes nothing returns nothing
    set gg_trg_ReviveHerotest = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ReviveHerotest, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_ReviveHerotest, Condition( function Trig_ReviveHerotest_Conditions ) )
    call TriggerAddAction( gg_trg_ReviveHerotest, function Trig_ReviveHerotest_Actions )
endfunction

for those wondering why i added local unit var, i'm assuming this will make it MUI for each player. I didnt want the wait to mess up the getdyingunit() function in GUI
 
Level 4
Joined
Aug 18, 2013
Messages
71
You can use GetTriggerUnit() instead of GetDyingUnit(), in GUI, GetTriggerUnit() is equal to
  • Unit - Triggering Unit

this wouldn't solve the issue of MUI would it?
triggering unit would change over the wait time wouldn't it?

My main issue is that the script "local unit u = GetDyingUnit()" isnt working
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
So will GetDyingUnit(), also GetTriggerUnit() is (assumed?) faster than the former.

As for the syntax error, put the local declaration on top of the set operations, that will do it.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Depends, do you want to instantiate (create) a group or do you want to reference (store) an already existing group.

local group gTemp = CreateGroup()
local group gTemp = groupVariable

Do remember that groupVariable must be declared before it can be used.
 
Level 9
Joined
Nov 19, 2011
Messages
516
JASS:
function Trig_AccidSET_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A038' ) ) then
        return false
    endif
    return true
endfunction

function Trig_AccidSET_Actions takes nothing returns nothing

local group UG_TMP = CreateGroup()

    call ForGroupBJ( GetUnitsInRectAll(RectFromCenterSizeBJ(GetUnitLoc(GetTriggerUnit()), 900.00, 900.00)), call GroupAddUnitSimple( GetEnumUnit(), UG_TMP ) )
    call GroupAddGroup( UG_TMP, udg_UG_Accid )
    call TriggerSleepAction( ( I2R(GetUnitAbilityLevelSwapped('A038', GetTriggerUnit())) * 6.00 ) )
    call GroupRemoveGroup( UG_TMP, udg_UG_Accid )
endfunction

//===========================================================================
function InitTrig_AccidSET takes nothing returns nothing
    set gg_trg_AccidSET = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_AccidSET, EVENT_PLAYER_UNIT_SPELL_FINISH )
    call TriggerAddCondition( gg_trg_AccidSET, Condition( function Trig_AccidSET_Conditions ) )
    call TriggerAddAction( gg_trg_AccidSET, function Trig_AccidSET_Actions )
endfunction

I need script that will put some group into another, and remove it after few sec. However it can be triggered more than once, so I thought about local group.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
In my understanding of your post, you need a copy group snippet, right? Try looking for one on the snippets forum.
 
Status
Not open for further replies.
Top