Jass Convertion Help

Status
Not open for further replies.
Level 4
Joined
Mar 6, 2007
Messages
73
Im currently learning JASS and i just convert one of my GUI trigger into JASS. I wanna know how I can change it to make it MUI and clear useless stuff (I can see some but I dunno how to). I had an array in GUI to simulate MUI and i know its useless if I can use locals. Plz help.

JASS:
function Trig_Multi_Lightning_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A05Z'
endfunction

function Trig_Multi_Lightning_1 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_MultiLightningCaster[udg_randomML])) == true )
endfunction

function Trig_Multi_Lightning_2 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

function Trig_Multi_Lightning_3 takes nothing returns boolean
    return GetBooleanAnd( Trig_Multi_Lightning_1(), Trig_Multi_Lightning_2() )
endfunction

function Trig_Multi_Lightning_Actions takes nothing returns nothing
    set udg_randomML = GetRandomInt(1, 1000)
    set udg_MultiLightningCaster[udg_randomML] = GetSpellAbilityUnit()
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 10
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call CreateNUnitsAtLoc( 1, 'h00A', GetOwningPlayer(udg_MultiLightningCaster[udg_randomML]), GetUnitLoc(udg_MultiLightningCaster[udg_randomML]), bj_UNIT_FACING )
        call UnitApplyTimedLifeBJ( 2.00, 'BTLF', GetLastCreatedUnit() )
        call UnitAddAbilityBJ( 'A05Y', GetLastCreatedUnit() )
        call SetUnitAbilityLevelSwapped( 'A05Y', GetLastCreatedUnit(), GetRandomInt(1, 100) )
        call IssueTargetOrderBJ( GetLastCreatedUnit(), "chainlightning", GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(( 100.00 * I2R(GetForLoopIndexA()) ), GetUnitLoc(udg_MultiLightningCaster[udg_randomML]), Condition(function Trig_Multi_Lightning_3))) )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//=====================================
function InitTrig_Multi_Lightning takes nothing returns nothing
    local trigger t
    set t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Multi_Lightning, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Multi_Lightning, Condition( function Trig_Multi_Lightning_Conditions ) )
    call TriggerAddAction( gg_trg_Multi_Lightning, function Trig_Multi_Lightning_Actions )
    set t = null
    call DestroyTrigger(t)
endfunction
 
Last edited:
Level 10
Joined
Sep 6, 2007
Messages
440
Simple Go to Advanced Mode by clicking edit. Then click the green button with 1 and 0. Then cut and paste your code inside the jass tags. Like this
" function C&P takes string returns nothing
endfunction
"
to
JASS:
function C&P takes string returns nothing
 endfunction
In your case this is how it goes,
JASS:
function Trig_Multi_Lightning_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A05Z'
endfunction

function Trig_Multi_Lightning_1 takes nothing returns boolean
return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_MultiLightningCaster[udg_randomML])) == true )
endfunction

function Trig_Multi_Lightning_2 takes nothing returns boolean
return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

function Trig_Multi_Lightning_3 takes nothing returns boolean
return GetBooleanAnd( Trig_Multi_Lightning_1(), Trig_Multi_Lightning_2() )
endfunction

function Trig_Multi_Lightning_Actions takes nothing returns nothing
set udg_randomML = GetRandomInt(1, 1000)
set udg_MultiLightningCaster[udg_randomML] = GetSpellAbilityUnit()
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 10
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
call CreateNUnitsAtLoc( 1, 'h00A', GetOwningPlayer(udg_MultiLightningCaster[udg_randomML]), GetUnitLoc(udg_MultiLightningCaster[udg_randomML]), bj_UNIT_FACING )
call UnitApplyTimedLifeBJ( 2.00, 'BTLF', GetLastCreatedUnit() )
call UnitAddAbilityBJ( 'A05Y', GetLastCreatedUnit() )
call SetUnitAbilityLevelSwapped( 'A05Y', GetLastCreatedUnit(), GetRandomInt(1, 100) )
call IssueTargetOrderBJ( GetLastCreatedUnit(), "chainlightning", GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(( 100.00 * I2R(GetForLoopIndexA()) ), GetUnitLoc(udg_MultiLightningCaster[udg_randomML]), Condition(function Trig_Multi_Lightning_3))) )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
endfunction

//=====================================
function InitTrig_Multi_Lightning takes nothing returns nothing
local trigger t
set t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Multi_Lightning, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Multi_Lightning, Condition( function Trig_Multi_Lightning_Conditions ) )
call TriggerAddAction( gg_trg_Multi_Lightning, function Trig_Multi_Lightning_Actions )
set t = null
call DestroyTrigger(t)
endfunction
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
P.S. : i Dont know how to make JASS tag. If some1 can tell me I'll edit it to be ezier to read. Thx

Use your mind. Its not like the list of all tags is there for nothing, now is it ?
Either use it or type (hard to think of :S) [jass][/code]


Now about the code, didn't really get what its supposed to do because of those random integers that seem really odd but this should do the work (I think ?).

JASS:
function Trig_Multi_Lightning_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A05Z'
endfunction

function Filtering takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.4
endfunction
function Trig_Multi_Lightning_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit dummy
    locla unit target
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local group g = CreateGroup()
    local integer count = 1
    local integer countmax = 10
    call GroupEnumUnitsInRange(g, x, y, 512, Filter(function Filtering)
    loop
        exitwhen count > countmax
        set dummy = CreateUnit(GetOwningPlayer(u), 'h00A', x, y, 0 )
        call UnitApplyTimedLife( 2.00, 'BTLF', dummy )
        call UnitAddAbility( 'A05Y', dummy )
        call SetUnitAbilityLevel( dummy ,'A05Y', GetRandomInt(1, 100) )
        set target = GroupPickRandomUnit(g)
        call IssueTargetOrder( dummy, "chainlightning", target )
        set target = null
        set dummy = null
        set count = count + 1
    endloop
    set u = null
    call DestroyGroup(g)
    set g = null
endfunction

//=====================================
function InitTrig_Multi_Lightning takes nothing returns nothing
    local trigger t
    set t = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Multi_Lightning, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Multi_Lightning, Condition( function Trig_Multi_Lightning_Conditions ) )
    call TriggerAddAction( gg_trg_Multi_Lightning, function Trig_Multi_Lightning_Actions )
    set t = null
    call DestroyTrigger(t)
endfunction
 
Level 4
Joined
Mar 6, 2007
Messages
73
Thx for the jass tags and the random integer was an array to try simulate a MUI spell. It worked but Im trying to turn in Jass. I got a problem that Im not able to fix in your code : At line : call UnitAddAbility( 'A05Y', dummy ) theres the error : Invalid argument type (unit). How do i fix this?
 
Last edited:
Status
Not open for further replies.
Top