|
最近刚刚开始接触j。。感觉很多时候的确比t来得方便。。
写了一段技能的代码,但是写完以后总是感觉有些地方写得太过复杂了。。。
请教一下各位,具体要怎么改能提升效率?还有排泄方面还有没有遗漏的?谢谢各位了~~
技能很简单。。是单位冲到指定地点并对周围的敌方单位造成伤害并减速的。。
[jass]function Trig_raidConditions takes nothing returns boolean
return ((GetSpellAbilityId() == 'A005'))
endfunction
function raid_damage_Conditions takes nothing returns boolean
local unit source = YDWEGetUnitByString("raid", "source")
local boolean j =((IsUnitDeadBJ(GetFilterUnit()) == false) and (IsUnitAlly(GetFilterUnit(), GetOwningPlayer(source)) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false))
set source = null
return j
endfunction
function raid_clean takes nothing returns nothing
call KillDestructable( GetEnumDestructable() )
endfunction
function raid_damage takes nothing returns nothing
local unit source = YDWEGetUnitByString( "raid", "source")
local real damage = YDWEGetRealByString( "raid", "damage")
//call DisplayTextToPlayer( Player(0), 0, 0, R2S(damage) )
call UnitDamageTarget( source, GetEnumUnit(), damage, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
set source = null
endfunction
function raid_endstage takes nothing returns nothing
local unit source = YDWEGetUnitByString( "raid", "source")
local real level = YDWEGetRealByString( "raid", "level")
local real damage = 50*level+100
local location loc = GetUnitLoc(source)
local group gro = GetUnitsInRangeOfLocMatching(300, loc, Condition(function raid_damage_Conditions))
local effect eff = YDWEGetEffectByString( "raid", "eff")
call YDWESaveRealByString( "raid", "damage", damage)
call SetUnitTimeScalePercent( source, 100.00 )
call SetUnitAnimation( source, "attack" )
call QueueUnitAnimation( source, "stand" )
call SetUnitPathing( source, true )
call PauseUnit( source, false)
call DestroyEffect(eff)
call DestroyEffect( AddSpecialEffectLocBJ( loc, "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" ) )
call ForGroupBJ( gro, function raid_damage )
call CreateNUnitsAtLoc( 1, 'e003', GetOwningPlayer(source), loc , bj_UNIT_FACING )
call UnitApplyTimedLifeBJ( 1, 'BTLF', GetLastCreatedUnit() )
call UnitAddAbility( GetLastCreatedUnit(), 'AHtc' )
call SetUnitAbilityLevel( GetLastCreatedUnit(), 'AHtc', 1 )
call IssueNeutralImmediateOrder( GetOwningPlayer(source), GetLastCreatedUnit(), "thunderclap" )
call YDWEFlushMissionByString("raid")
call RemoveLocation(loc)
set source = null
set gro = null
set eff = null
endfunction
function raid_rush takes nothing returns nothing local string table = I2S(YDWEGetTimerID(GetExpiredTimer()))
local unit source = YDWEGetUnitByString( "raid", "source")
local real angle = YDWEGetRealByString( "raid", "angle")
local real step = YDWEGetRealByString( "raid", "step")
local location loc = GetUnitLoc(source)
local location loc2 = PolarProjectionBJ(loc, step, angle )
local integer record = YDWEGetIntegerByString( "raid", "record")
//call SetUnitAnimation( knight, "walk" )
set record = record + 1
call YDWESaveIntegerByString( "raid", "record", record )
call SetUnitPositionLocFacingBJ( source, loc2, angle )
call EnumDestructablesInCircleBJ( 180, loc2, function raid_clean )
call CreateNUnitsAtLocFacingLocBJ( 1, 'e000', GetOwningPlayer(source), loc, loc2 )
call SetUnitVertexColorBJ( GetLastCreatedUnit(), 20, 20, 100, 80.00 )
//call UnitApplyTimedLifeBJ( 0.05, 'BTLF', GetLastCreatedUnit() )
call YDWETimerRemoveUnit( 0.12, GetLastCreatedUnit() )
//call SetUnitExploded( GetLastCreatedUnit(), true )
if (record>29) then
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
call raid_endstage()
endif
call RemoveLocation(loc)
call RemoveLocation(loc2)
set source = null
endfunction
function Trig_raidActions takes nothing returns nothing
local unit source = GetTriggerUnit()
local effect eff = AddSpecialEffectTarget("Abilities\\Weapons\\ZigguratMissile\\ZigguratMissile.mdl", source, "weapon")
local location loc = GetUnitLoc(source)
local location tar = GetSpellTargetLoc()
local real length = DistanceBetweenPoints(loc, tar)
local real level=I2R(GetUnitAbilityLevel(source, 'A005'))
local real angle = AngleBetweenPoints(loc, tar)
local real step = length/30
local timer t = CreateTimer()
call SetUnitPathing( source, false )
call PauseUnit( source, true)
call YDWESaveUnitByString( "raid", "source", source )
call YDWESaveRealByString( "raid", "angle", angle )
call YDWESaveRealByString( "raid", "level", level )
call YDWESaveRealByString( "raid", "step", step )
call YDWESaveRealByString( "raid", "record", 0 )
call YDWESaveLocationByString( "raid", "loc", loc )
call YDWESaveLocationByString( "raid", "tar", tar )
call YDWESaveEffectByString( "raid", "eff", eff )
call SetUnitTimeScalePercent( source, 200.00 )
call SetUnitAnimation( source, "attack" )
call TimerStart(t,.01,true,function raid_rush)
call RemoveLocation(loc)
call RemoveLocation(tar)
set source = null
set eff = null
set t =null
endfunction
//===========================================================================
function InitTrig_raid takes nothing returns nothing
set gg_trg_raid = CreateTrigger()
#ifdef DEBUG
call YDWESaveTriggerName(gg_trg_raid, "raid")
#endif
call TriggerRegisterAnyUnitEventBJ( gg_trg_raid, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(gg_trg_raid, Condition(function Trig_raidConditions))
call TriggerAddAction(gg_trg_raid, function Trig_raidActions)
endfunction[/jass] |
|