|
我不太懂J.现在处于用T写好触发,再转J.然后替换全局变量为局部变量.
有个很大的疑问.
就是我发现.我在函数的action动作中声明局部变量后.接下来如果有循环动作,或者IF/THEN之类的分隔型动作的时候----我之前在函数开头声明的局部变量会无效....情况不一而论,结果都是不能用.....我自己想不明白.特地请教一下.
下面是个例子: local location array xhd 这个局部变量出问题.... |
function Trig____________________001______________u_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A09S' ) ) then
return false
endif
return true
endfunction
function Trig____________________001______________u_Actions takes nothing returns nothing
local integer array dian
local location array xhd
local location dian2
local unit danwei
set danwei = GetTriggerUnit()
set dian2= GetUnitLoc(danwei)
set dian[0] = ( GetHeroStr(GetSpellAbilityUnit(), true) + ( GetHeroAgi(GetSpellAbilityUnit(), true) + GetHeroInt(GetSpellAbilityUnit(), true) ) )
set dian[1] = GetUnitLevel(GetSpellAbilityUnit())
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 10
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set xhd[0] = PolarProjectionBJ(dian, 600.00, ( 36.00 * I2R(GetForLoopIndexA()) ))
call CreateNUnitsAtLoc( 1, 'e006', GetOwningPlayer(danwei), xhd[0], ( 36.00 * I2R(GetForLoopIndexA()) ) )
call UnitApplyTimedLifeBJ( 3.00, 'BHwe', GetLastCreatedUnit() )
call RemoveLocation( xhd[0] )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
call TriggerSleepAction( 2.00 )
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 10
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set xhd[1] = PolarProjectionBJ(dian, 500.00, ( 36.00 * I2R(GetForLoopIndexA()) ))
call CreateNUnitsAtLoc( 1, 'e007', GetOwningPlayer(danwei), xhd[1], ( 36.00 * I2R(GetForLoopIndexA()) ) )
call UnitApplyTimedLifeBJ( 3.00, 'BHwe', GetLastCreatedUnit() )
call RemoveLocation( xhd[1] )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set xhd[2] = PolarProjectionBJ(dian, -300.00, GetUnitFacing(danwei))
call CreateNUnitsAtLoc( 1, 'e008', GetOwningPlayer(danwei), xhd[2], GetUnitFacing(danwei) )
call UnitApplyTimedLifeBJ( 3.00, 'BHwe', GetLastCreatedUnit() )
call RemoveLocation( xhd[2] )
call TriggerSleepAction( 1.00 )
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 30
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set xhd[3] = PolarProjectionBJ(dian, ( 60.00 * I2R(GetForLoopIndexA()) ), GetUnitFacing(danwei))
call AddSpecialEffectLocBJ( xhd[3], "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl" )
call UnitDamagePointLoc( GetSpellAbilityUnit(), 0, 500, xhd[3], I2R(( dian[0] * dian[1] )), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL )
call RemoveLocation( xhd[3] )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 30
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set xhd[4] = PolarProjectionBJ(dian, ( 60.00 * I2R(GetForLoopIndexA()) ), ( GetUnitFacing(danwei) - 45.00 ))
call AddSpecialEffectLocBJ( xhd[4], "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl" )
call UnitDamagePointLoc( GetSpellAbilityUnit(), 0, 500, xhd[4], I2R(( dian[0] * dian[1] )), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL )
call RemoveLocation( xhd[4] )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 30
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set xhd[5] = PolarProjectionBJ(dian, ( 60.00 * I2R(GetForLoopIndexA()) ), ( GetUnitFacing(danwei) + 45.00 ))
call AddSpecialEffectLocBJ( xhd[5], "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl" )
call UnitDamagePointLoc( GetSpellAbilityUnit(), 0, 500, xhd[5], I2R(( dian[0] * dian[1] )), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL )
call RemoveLocation( xhd[5] )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
call RemoveLocation( dian2)
endfunction
//===========================================================================
function InitTrig____________________001______________u takes nothing returns nothing
set gg_trg____________________001______________u = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg____________________001______________u, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg____________________001______________u, Condition( function Trig____________________001______________u_Conditions ) )
call TriggerAddAction( gg_trg____________________001______________u, function Trig____________________001______________u_Actions )
endfunction |
|