| 07-21-2009, 11:12 AM | #1 |
Hello, is there a way to let local variables span more than one event/condition/action? This is the trigger broken into 3 parts, so the local variables do not work. I do not want them to be global variables, because I would like more than one instance of this trigger running at a time. JASS:function Trig_Absorb_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A000' ) ) then return false endif return true endfunction function Trig_Absorb_Actions takes nothing returns nothing local unit array UNIT local location array TEMP set UNIT[1] = GetSpellAbilityUnit() set UNIT[2] = GetSpellTargetUnit() set TEMP[1] = GetUnitLoc(UNIT[1]) set TEMP[2] = GetUnitLoc(UNIT[2]) call CreateNUnitsAtLocFacingLocBJ( 1, 'h000', Player(0), TEMP[1], TEMP[2] ) set UNIT[3] = GetLastCreatedUnit() call IssuePointOrderLocBJ( UNIT[3], "move", TEMP[2] ) call EnableTrigger( gg_trg_Absorb2 ) endfunction //=========================================================================== function InitTrig_Absorb takes nothing returns nothing set gg_trg_Absorb = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Absorb, EVENT_PLAYER_UNIT_SPELL_CAST ) call TriggerAddCondition( gg_trg_Absorb, Condition( function Trig_Absorb_Conditions ) ) call TriggerAddAction( gg_trg_Absorb, function Trig_Absorb_Actions ) endfunction JASS:function Trig_Absorb2_Actions takes nothing returns nothing set TEMP[2] = GetUnitLoc(UNIT[2]) call IssuePointOrderLocBJ( UNIT[3], "move", TEMP[2] ) endfunction //=========================================================================== function InitTrig_Absorb2 takes nothing returns nothing set gg_trg_Absorb2 = CreateTrigger( ) call DisableTrigger( gg_trg_Absorb2 ) call TriggerRegisterTimerEventPeriodic( gg_trg_Absorb2, 0.10 ) call TriggerAddAction( gg_trg_Absorb2, function Trig_Timer_Actions ) endfunction JASS:function Trig_Absorb3_Conditions takes nothing returns boolean if ( not ( GetTriggerUnit() == UNIT[3] ) ) then return false endif return true endfunction function Trig_Absorb3_Actions takes nothing returns nothing call KillUnit( UNIT[3] ) call UnitDamageTargetBJ( UNIT[2], UNIT[1], ( ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, UNIT[1], true)) / 10.00 ) * ( I2R(GetUnitAbilityLevelSwapped(A000, UNIT[1])) * -10.00 ) ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL ) call DisableTrigger( gg_trg_Absorb2 ) set bj_forLoopAIndex = 1 set bj_forLoopAIndexEnd = 2 loop exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd call RemoveLocation(TEMP[GetForLoopIndexA()]) set bj_forLoopAIndex = bj_forLoopAIndex + 1 endloop endfunction //=========================================================================== function InitTrig_Absorb3 takes nothing returns nothing set gg_trg_Absorb3 = CreateTrigger( ) call TriggerRegisterUnitInRangeSimple( gg_trg_Absorb3, 10.00, UNIT[2] ) call TriggerAddCondition( gg_trg_Absorb3, Condition( function Trig_Absorb3_Conditions ) ) call TriggerAddAction( gg_trg_Absorb3, function Trig_Absorb3_Actions ) endfunction How do I make this work? |
| 07-21-2009, 11:51 AM | #2 |
Either you download JNPG and start using vJass; with it you can declare globals freely like so: JASS:globals unit array UNIT location array TEMP endglobals function Trig_Absorb_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A000' ) ) then return false endif return true endfunction function Trig_Absorb_Actions takes nothing returns nothing set UNIT[1] = GetSpellAbilityUnit() set UNIT[2] = GetSpellTargetUnit() set TEMP[1] = GetUnitLoc(UNIT[1]) set TEMP[2] = GetUnitLoc(UNIT[2]) call CreateNUnitsAtLocFacingLocBJ( 1, 'h000', Player(0), TEMP[1], TEMP[2] ) set UNIT[3] = GetLastCreatedUnit() call IssuePointOrderLocBJ( UNIT[3], "move", TEMP[2] ) call EnableTrigger( gg_trg_Absorb2 ) endfunction //=========================================================================== function InitTrig_Absorb takes nothing returns nothing set gg_trg_Absorb = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Absorb, EVENT_PLAYER_UNIT_SPELL_CAST ) call TriggerAddCondition( gg_trg_Absorb, Condition( function Trig_Absorb_Conditions ) ) call TriggerAddAction( gg_trg_Absorb, function Trig_Absorb_Actions ) endfunction Or you access the GUI way of making globals, and make the globals there (and use them this way): JASS:function Trig_Absorb_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A000' ) ) then return false endif return true endfunction function Trig_Absorb_Actions takes nothing returns nothing set udg_UNIT[1] = GetSpellAbilityUnit() set udg_UNIT[2] = GetSpellTargetUnit() set udg_TEMP[1] = GetUnitLoc(UNIT[1]) set udg_TEMP[2] = GetUnitLoc(UNIT[2]) call CreateNUnitsAtLocFacingLocBJ( 1, 'h000', Player(0), TEMP[1], TEMP[2] ) set udg_UNIT[3] = GetLastCreatedUnit() call IssuePointOrderLocBJ( UNIT[3], "move", TEMP[2] ) call EnableTrigger( gg_trg_Absorb2 ) endfunction //=========================================================================== function InitTrig_Absorb takes nothing returns nothing set gg_trg_Absorb = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Absorb, EVENT_PLAYER_UNIT_SPELL_CAST ) call TriggerAddCondition( gg_trg_Absorb, Condition( function Trig_Absorb_Conditions ) ) call TriggerAddAction( gg_trg_Absorb, function Trig_Absorb_Actions ) endfunction (Note the udg_ preffix before the globals) |
| 07-21-2009, 12:30 PM | #3 | |
Quote:
If you're (Lquiz) are using a unit indexing system, which I doubt, then it would be easy to make MUI with global arrays (storing the data in the units index). Or even structs if you're that way inclined. |
| 07-21-2009, 12:44 PM | #4 |
ok, here is what you should do: 1. currently you're coding in standard jass. standard jass is old, and has been "replaced" by the by far better vJass. download the jass new gen pack, it includes vJass. then, go into your jngp(jass new gen pack) folder, open up the jassnewgenreadme.html and check out the vJass manual. that will tell you ALOT. 2. get familiar with unit indexing. 3. explore the new world of vJass to its depths 8) |
