• 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] Jass conversion gone wrong!

Status
Not open for further replies.
Ok so I made a custom spell for all the heroes in my game, there is a trigger for each one, but for some reason it wouldnt let me use a array as a variable for some of the stuff or it would friek out and glitch like mad. So I converted it to JASS and tried to make local variables. But now its not working at all.
JASS:
function Trig_Sting_01_Conditions takes nothing returns boolean    if ( not ( GetUnitTypeId(GetSpellAbilityUnit()) == 'H000' ) ) then        return false    endif    if ( not ( GetSpellAbilityId() == 'AEsh' ) ) then        return false    endif    return trueendfunctionfunction Trig_Sting_01_Func013A takes nothing returns nothing    call SetUnitAnimation( GetEnumUnit(), "attack" )endfunctionfunction Trig_Sting_01_Func020A takes nothing returns nothing    call RemoveUnit( GetEnumUnit() )endfunctionfunction Trig_Sting_01_Actions takes nothing returns nothing    local unit sngCast = GetSpellAbilityUnit()    local unit sngTarg = GetSpellTargetUnit()    local location sngPoint = GetUnitLoc(sngTarg)    local group StingGroup    local effect array Effects    call PauseUnitBJ( true, sngCast )    call PauseUnitBJ( true, sngTarg )    call IssueImmediateOrderBJ( sngCast, "stop" )    call IssueImmediateOrderBJ( sngTarg, "stop" )    call SetUnitFacingToFaceUnitTimed( sngTarg, sngCast, 1.00 )    call SetUnitAnimation( sngCast, "spell" )    set bj_forLoopAIndex = 1    set bj_forLoopAIndexEnd = 10    loop        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd        call AddSpecialEffectLocBJ( PolarProjectionBJ(sngPoint, 100.00, ( 36.00 * I2R(GetForLoopIndexA()) )), "war3mapImported\\ZombifyTargetBlue.mdx" )        set Effects[GetForLoopIndexA()] = GetLastCreatedEffectBJ()        call CreateNUnitsAtLocFacingLocBJ( 1, 'h005', Player(PLAYER_NEUTRAL_PASSIVE), PolarProjectionBJ(sngPoint, 100.00, ( 36.00 * I2R(GetForLoopIndexA()) )), sngPoint )        call SetUnitColor( GetLastCreatedUnit(), udg_CustColor[1] )        call SetUnitVertexColorBJ( GetLastCreatedUnit(), 100, 100, 100, 50.00 )        call GroupAddUnitSimple( GetLastCreatedUnit(), StingGroup )        call TriggerSleepAction( 0.30 )        call DestroyEffectBJ( Effects[GetForLoopIndexA()] )        set bj_forLoopAIndex = bj_forLoopAIndex + 1    endloop    call TriggerSleepAction( 1.00 )    call ForGroupBJ( StingGroup , function Trig_Sting_01_Func013A )    call TriggerSleepAction( 0.43 )    call UnitDamageTargetBJ( sngCast, sngTarg, ( 400.00 + ( 100.00 * I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(), sngCast)) ) ), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )    call TriggerSleepAction( 0.57 )    set bj_forLoopAIndex = 1    set bj_forLoopAIndexEnd = 10    loop        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd        call AddSpecialEffectLocBJ( PolarProjectionBJ(sngPoint, 100.00, ( 36.00 * I2R(GetForLoopIndexA()) )), "war3mapImported\\ZombifyTargetBlue.mdx" )        set Effects[( GetForLoopIndexA() + 10 )] = GetLastCreatedEffectBJ()        set bj_forLoopAIndex = bj_forLoopAIndex + 1    endloop    call TriggerSleepAction( 0.30 )    set bj_forLoopAIndex = 1    set bj_forLoopAIndexEnd = 20    loop        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd        call DestroyEffectBJ( Effects[GetForLoopIndexA()] )        set bj_forLoopAIndex = bj_forLoopAIndex + 1    endloop    call ForGroupBJ( StingGroup , function Trig_Sting_01_Func020A )    call PauseUnitBJ( false, sngCast )    call PauseUnitBJ( false, sngTarg )    set bj_forLoopAIndex = 1    set bj_forLoopAIndexEnd = 20    loop        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd        set Effects[GetForLoopIndexA()] = null        set bj_forLoopAIndex = bj_forLoopAIndex + 1    endloop    set sngCast = null    set sngTarg = null    set sngPoint = nullendfunction//===========================================================================function InitTrig_Sting_01 takes nothing returns nothing    set gg_trg_Sting_01 = CreateTrigger(  )    call TriggerRegisterAnyUnitEventBJ( gg_trg_Sting_01, EVENT_PLAYER_UNIT_SPELL_EFFECT )    call TriggerAddCondition( gg_trg_Sting_01, Condition( function Trig_Sting_01_Conditions ) )    call TriggerAddAction( gg_trg_Sting_01, function Trig_Sting_01_Actions )endfunction
 
Level 6
Joined
Jul 22, 2008
Messages
243
That's like, really hard to read :(
Try to repost the script in a more readable state
 
Last edited:
Level 13
Joined
Jul 3, 2008
Messages
1,098
he has writed

function Trig_Sting_01_Conditions takes nothing returns boolean if ( not ( GetUnitTypeId(GetSpellAbilityUnit()) == 'H000' ) ) then return false endif if ( not ( GetSpellAbilityId() == 'AEsh' ) ) then return false endif return trueendfunctionfunction Trig_Sting_01_Func013A takes nothing returns nothing call SetUnitAnimation( GetEnumUnit(), "attack" )endfunctionfunction Trig_Sting_01_Func020A takes nothing returns nothing call RemoveUnit( GetEnumUnit() )endfunctionfunction Trig_Sting_01_Actions takes nothing returns nothing local unit sngCast = GetSpellAbilityUnit() local unit sngTarg = GetSpellTargetUnit() local location sngPoint = GetUnitLoc(sngTarg) local group StingGroup local effect array Effects call PauseUnitBJ( true, sngCast ) call PauseUnitBJ( true, sngTarg ) call IssueImmediateOrderBJ( sngCast, "stop" ) call IssueImmediateOrderBJ( sngTarg, "stop" ) call SetUnitFacingToFaceUnitTimed( sngTarg, sngCast, 1.00 ) call SetUnitAnimation( sngCast, "spell" ) set bj_forLoopAIndex = 1 set bj_forLoopAIndexEnd = 10 loop exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd call AddSpecialEffectLocBJ( PolarProjectionBJ(sngPoint, 100.00, ( 36.00 * I2R(GetForLoopIndexA()) )), "war3mapImported\\ZombifyTargetBlue.mdx" ) set Effects[GetForLoopIndexA()] = GetLastCreatedEffectBJ() call CreateNUnitsAtLocFacingLocBJ( 1, 'h005', Player(PLAYER_NEUTRAL_PASSIVE), PolarProjectionBJ(sngPoint, 100.00, ( 36.00 * I2R(GetForLoopIndexA()) )), sngPoint ) call SetUnitColor( GetLastCreatedUnit(), udg_CustColor[1] ) call SetUnitVertexColorBJ( GetLastCreatedUnit(), 100, 100, 100, 50.00 ) call GroupAddUnitSimple( GetLastCreatedUnit(), StingGroup ) call TriggerSleepAction( 0.30 ) call DestroyEffectBJ( Effects[GetForLoopIndexA()] ) set bj_forLoopAIndex = bj_forLoopAIndex + 1 endloop call TriggerSleepAction( 1.00 ) call ForGroupBJ( StingGroup , function Trig_Sting_01_Func013A ) call TriggerSleepAction( 0.43 ) call UnitDamageTargetBJ( sngCast, sngTarg, ( 400.00 + ( 100.00 * I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(), sngCast)) ) ), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL ) call TriggerSleepAction( 0.57 ) set bj_forLoopAIndex = 1 set bj_forLoopAIndexEnd = 10 loop exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd call AddSpecialEffectLocBJ( PolarProjectionBJ(sngPoint, 100.00, ( 36.00 * I2R(GetForLoopIndexA()) )), "war3mapImported\\ZombifyTargetBlue.mdx" ) set Effects[( GetForLoopIndexA() + 10 )] = GetLastCreatedEffectBJ() set bj_forLoopAIndex = bj_forLoopAIndex + 1 endloop call TriggerSleepAction( 0.30 ) set bj_forLoopAIndex = 1 set bj_forLoopAIndexEnd = 20 loop exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd call DestroyEffectBJ( Effects[GetForLoopIndexA()] ) set bj_forLoopAIndex = bj_forLoopAIndex + 1 endloop call ForGroupBJ( StingGroup , function Trig_Sting_01_Func020A ) call PauseUnitBJ( false, sngCast ) call PauseUnitBJ( false, sngTarg ) set bj_forLoopAIndex = 1 set bj_forLoopAIndexEnd = 20 loop exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd set Effects[GetForLoopIndexA()] = null set bj_forLoopAIndex = bj_forLoopAIndex + 1 endloop set sngCast = null set sngTarg = null set sngPoint = nullendfunction//===========================================================================function InitTrig_Sting_01 takes nothing returns nothing set gg_trg_Sting_01 = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Sting_01, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Sting_01, Condition( function Trig_Sting_01_Conditions ) ) call TriggerAddAction( gg_trg_Sting_01, function Trig_Sting_01_Actions )endfunction
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Putting the entire script on one line does not help execution. And numerion, that's even less readable than his is.

EDIT: I spaced the text, fixed the condition, and converted a few BJs to natives, but before there's any point doing any more work on it, what exactly do you need again? Here's the script, by the way.

JASS:
function Trig_Sting_01_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'H000' and GetSpellAbilityId() == 'AEsh'
endfunction

function Trig_Sting_01_Func013A takes nothing returns nothing
    call SetUnitAnimation( GetEnumUnit(), "attack" )
endfunction

function Trig_Sting_01_Func020A takes nothing returns nothing
    call RemoveUnit(GetEnumUnit())
endfunction

function Trig_Sting_01_Actions takes nothing returns nothing
    local unit sngCast = GetTriggerUnit()
    local unit sngTarg = GetSpellTargetUnit()
    local location sngPoint = GetUnitLoc(sngTarg)
    local group StingGroup
    local effect array Effects
    call PauseUnit(sngCast,true)
    call PauseUnit(sngTarg,true)
    call IssueImmediateOrder(sngCast,"stop")
    call IssueImmediateOrder(sngTarg,"stop")
    call SetUnitFacingToFaceUnitTimed(sngTarg,sngCast,1.00)
    call SetUnitAnimation(sngCast,"spell")
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 10
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call AddSpecialEffectLocBJ( PolarProjectionBJ(sngPoint, 100.00, ( 36.00 * I2R(GetForLoopIndexA()) )), "war3mapImported\\ZombifyTargetBlue.mdx" )
        set Effects[GetForLoopIndexA()] = GetLastCreatedEffectBJ()
        call CreateNUnitsAtLocFacingLocBJ( 1, 'h005', Player(PLAYER_NEUTRAL_PASSIVE), PolarProjectionBJ(sngPoint, 100.00, ( 36.00 * I2R(GetForLoopIndexA()) )), sngPoint )
        call SetUnitColor( GetLastCreatedUnit(), udg_CustColor[1] )
        call SetUnitVertexColorBJ( GetLastCreatedUnit(), 100, 100, 100, 50.00 )
        call GroupAddUnitSimple( GetLastCreatedUnit(), StingGroup )
        call TriggerSleepAction( 0.30 )
        call DestroyEffectBJ( Effects[GetForLoopIndexA()] )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call TriggerSleepAction(1.)
    call ForGroupBJ( StingGroup , function Trig_Sting_01_Func013A )
    call TriggerSleepAction(.43)
    call UnitDamageTarget(sngCast,sngTarg,(400. + (100.*GetUnitAbilityLevel(sngCast,GetSpellAbilityId()))),true,false,ATTACK_TYPE_HERO,DAMAGE_TYPE_NORMAL,null)
    call TriggerSleepAction(.57)
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 10
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call AddSpecialEffectLocBJ( PolarProjectionBJ(sngPoint, 100.00, ( 36.00 * I2R(GetForLoopIndexA()) )), "war3mapImported\\ZombifyTargetBlue.mdx" )
        set Effects[( GetForLoopIndexA() + 10 )] = GetLastCreatedEffectBJ()
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call TriggerSleepAction( 0.30 )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 20
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call DestroyEffectBJ( Effects[GetForLoopIndexA()] )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call ForGroupBJ( StingGroup , function Trig_Sting_01_Func020A )
    call PauseUnit(sngCast,false)
    call PauseUnit(sngTarg,false)
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 20
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set Effects[GetForLoopIndexA()] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set sngCast = null
    set sngTarg = null
    set sngPoint = null
endfunction
//===========================================================================
function InitTrig_Sting_01 takes nothing returns nothing
    set gg_trg_Sting_01 = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Sting_01,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Sting_01,Condition(function Trig_Sting_01_Conditions))
    call TriggerAddAction(gg_trg_Sting_01,function Trig_Sting_01_Actions)
endfunction
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Sigh... Don't spam numerion, cause that's even less readable than what big dub posted.

JASS:
function Trig_Sting_01_Conditions takes nothing returns boolean 
    if ( not ( GetUnitTypeId(GetSpellAbilityUnit()) == 'H000' ) ) then 
        return false 
    endif 
    if ( not ( GetSpellAbilityId() == 'AEsh' ) ) then 
        return false 
    endif 
    return true
endfunction

function Trig_Sting_01_Func013A takes nothing returns nothing 
    call SetUnitAnimation( GetEnumUnit(), "attack" )
endfunction

function Trig_Sting_01_Func020A takes nothing returns nothing 
    call RemoveUnit( GetEnumUnit() )
endfunction

function Trig_Sting_01_Actions takes nothing returns nothing 
    local unit sngCast = GetSpellAbilityUnit() 
    local unit sngTarg = GetSpellTargetUnit() 
    local location sngPoint = GetUnitLoc(sngTarg) 
    local group StingGroup 
    local effect array Effects 
    call PauseUnitBJ( true, sngCast ) 
    call PauseUnitBJ( true, sngTarg ) 
    call IssueImmediateOrderBJ( sngCast, "stop" ) 
    call IssueImmediateOrderBJ( sngTarg, "stop" )
    call SetUnitFacingToFaceUnitTimed( sngTarg, sngCast, 1.00 ) 
    call SetUnitAnimation( sngCast, "spell" ) 
    set bj_forLoopAIndex = 1 
    set bj_forLoopAIndexEnd = 10 
    loop 
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd 
        call AddSpecialEffectLocBJ( PolarProjectionBJ(sngPoint, 100.00, ( 36.00 * I2R(GetForLoopIndexA()) )), "war3mapImported\\ZombifyTargetBlue.mdx" )
        set Effects[GetForLoopIndexA()] = GetLastCreatedEffectBJ() 
        call CreateNUnitsAtLocFacingLocBJ( 1, 'h005', Player(PLAYER_NEUTRAL_PASSIVE), PolarProjectionBJ(sngPoint, 100.00, ( 36.00 * I2R(GetForLoopIndexA()) )), sngPoint ) 
        call SetUnitColor( GetLastCreatedUnit(), udg_CustColor[1] ) 
        call SetUnitVertexColorBJ( GetLastCreatedUnit(), 100, 100, 100, 50.00 ) 
        call GroupAddUnitSimple( GetLastCreatedUnit(), StingGroup ) 
        call TriggerSleepAction( 0.30 ) 
        call DestroyEffectBJ( Effects[GetForLoopIndexA()] ) 
        set bj_forLoopAIndex = bj_forLoopAIndex + 1 
    endloop 
    call TriggerSleepAction( 1.00 ) 
    call ForGroupBJ( StingGroup , function Trig_Sting_01_Func013A ) 
    call TriggerSleepAction( 0.43 ) 
    call UnitDamageTargetBJ( sngCast, sngTarg, ( 400.00 + ( 100.00 * I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(), sngCast)) ) ), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL ) 
    call TriggerSleepAction( 0.57 ) 
    set bj_forLoopAIndex = 1 
    set bj_forLoopAIndexEnd = 10 
    loop 
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd 
        call AddSpecialEffectLocBJ( PolarProjectionBJ(sngPoint, 100.00, ( 36.00 * I2R(GetForLoopIndexA()) )), "war3mapImported\\ZombifyTargetBlue.mdx" )
        set Effects[( GetForLoopIndexA() + 10 )] = GetLastCreatedEffectBJ() 
        set bj_forLoopAIndex = bj_forLoopAIndex + 1 
    endloop 
    call TriggerSleepAction( 0.30 ) 
    set bj_forLoopAIndex = 1 
    set bj_forLoopAIndexEnd = 20 
    loop 
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd 
        call DestroyEffectBJ( Effects[GetForLoopIndexA()] ) 
        set bj_forLoopAIndex = bj_forLoopAIndex + 1 
    endloop 
    call ForGroupBJ( StingGroup , function Trig_Sting_01_Func020A ) 
    call PauseUnitBJ( false, sngCast ) 
    call PauseUnitBJ( false, sngTarg ) 
    set bj_forLoopAIndex = 1 
    set bj_forLoopAIndexEnd = 20 
    loop 
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd 
        set Effects[GetForLoopIndexA()] = null 
        set bj_forLoopAIndex = bj_forLoopAIndex + 1 
    endloop 
    set sngCast = null 
    set sngTarg = null 
    set sngPoint = null
endfunction

//===========================================================================
function InitTrig_Sting_01 takes nothing returns nothing 
    set gg_trg_Sting_01 = CreateTrigger( ) 
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Sting_01, EVENT_PLAYER_UNIT_SPELL_EFFECT ) 
    call TriggerAddCondition( gg_trg_Sting_01, Condition( function Trig_Sting_01_Conditions ) ) 
    call TriggerAddAction( gg_trg_Sting_01, function Trig_Sting_01_Actions )
endfunction
 
That seems to have worked. But now it is having trouble accessing a global variable.
JASS:
udg_CustColor[GetConvertedPlayerId(GetOwningPlayer(sngCast))]
this is to change the units color to owning player's color, which can change hence the variable,
this always just comes up as red.
when I put in
JASS:
udg_CustColor[1]
or
JASS:
udg_CustColor[2]
it works and makes it red or blue.
but
JASS:
udg_CustColor[GetConvertedPlayerId(GetOwningPlayer(sngCast))]
makes it red.
 
Status
Not open for further replies.
Top