|
楼主 |
发表于 2008-2-12 23:46:14
|
显示全部楼层
代码我贴出来吧
[jass]
//需要在WE中创建缓存 GameCache 以及一个触发器 Wind Step (注意中间空格)
function H2I takes handle h returns integer
return h
return 0
endfunction
function H2S takes handle h returns string
return I2S(H2I(h))
endfunction
function I2TG takes integer i returns trigger
return i
return null
endfunction
function I2TM takes integer i returns timer
return i
return null
endfunction
function I2U takes integer i returns unit
return i
return null
endfunction
function I2TA takes integer i returns triggeraction
return i
return null
endfunction
function I2TT takes integer i returns texttag
return i
return null
endfunction
function InitCache takes nothing returns nothing
if udg_GameCache == null then
set udg_GameCache = InitGameCache("windstep.w3v")
endif
endfunction
function TagOnUnitDestroy takes nothing returns nothing
local timer t = GetExpiredTimer()
local texttag ttg = I2TT(GetStoredInteger(udg_GameCache,H2S(t),"ttg"))
local integer i = GetStoredInteger(udg_GameCache,H2S(t),"times")
if i<8 then
call SetTextTagColor(ttg,192,0,0,32*(i+1))
call StoreInteger(udg_GameCache,H2S(t),"times",i+1)
else
call PauseTimer(t)
call DestroyTimer(t)
call DestroyTextTag(ttg)
call FlushStoredMission(udg_GameCache,H2S(t))
endif
set t = null
set ttg = null
endfunction
function TagOnUnit takes string s,unit u returns nothing
local texttag ttg= CreateTextTag()
local timer t = CreateTimer()
call SetTextTagText(ttg,s,0.024)
call SetTextTagColor(ttg,128,0,0,0)
call SetTextTagPos(ttg,GetUnitX(u),GetUnitY(u),128)
call SetTextTagVelocity( ttg, 0.00, 0.15 )
call StoreInteger(udg_GameCache,H2S(t),"ttg",H2I(ttg))
call StoreInteger(udg_GameCache,H2S(t),"times",0)
call TimerStart(t,0.1,true,function TagOnUnitDestroy)
endfunction
//-----------------------------以上是自定义脚本-------------------------------
//*移植的时候请创建一个 Wind Step 得触发器(注意中间的空格)
//*将这部分代码粘贴到自定义文本框中
function WindStepFirstHitCond takes nothing returns boolean
return GetUnitAbilityLevel(GetAttacker(),'A001')>0//移植技能的时候请修改此处的ID
endfunction
function WindStepFirstHitDmg takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local unit target = GetTriggerUnit()
local unit u = GetEventDamageSource()
local real dmg = GetEventDamage()
if dmg>0 and H2I(u)==GetStoredInteger(udg_GameCache,H2S(t),"u") then
call TriggerRemoveAction(t,I2TA(GetStoredInteger(udg_GameCache,H2S(t),"ta")))
call DestroyTrigger(t)
set dmg = I2R( IMaxBJ(IMaxBJ(GetHeroInt(u,true),GetHeroStr(u,true)),GetHeroAgi(u,true)))*3
call UnitDamageTarget(u,target,dmg,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_DEFENSIVE,WEAPON_TYPE_WHOKNOWS)
call TagOnUnit(I2S(R2I(dmg))+"!",target)//显示数值
call UnitRemoveAbility(u,'A001')//移植技能的时候请修改此处的ID
call DestroyEffect(AddSpecialEffectTarget("Abilities\\\\Spells\\\\Orc\\\\FeralSpirit\\\\feralspiritdone.mdl",target,"origin"))
endif
set t=null
set target = null
set u=null
endfunction
function WindStepFirstHit takes nothing returns nothing
local unit u = GetAttacker()
local unit target = GetTriggerUnit()
local trigger t = CreateTrigger()
local triggeraction ta = TriggerAddAction(t,function WindStepFirstHitDmg )
call TriggerRegisterUnitEvent(t,target,EVENT_UNIT_DAMAGED)
call StoreInteger(udg_GameCache,H2S(t),"u",H2I(u))
call StoreInteger(udg_GameCache,H2S(t),"ta",H2I(ta))
set u = null
set target = null
set t = null
set ta = null
endfunction
function WindStepResetReaccable takes nothing returns nothing
local timer tm2 = GetExpiredTimer()
local timer tm = I2TM(GetStoredInteger(udg_GameCache,H2S(tm2),"timer"))
call StoreBoolean(udg_GameCache,H2S(tm),"reaccable",true)
call BJDebugMsg("can reaccable")
endfunction
function WindStepLoop takes nothing returns nothing
local timer tm = GetExpiredTimer()
local string tkey = H2S(tm)
local unit u = I2U(GetStoredInteger(udg_GameCache,tkey,"unit"))
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real oldx=GetStoredReal(udg_GameCache,tkey,"oldx")
local real oldy=GetStoredReal(udg_GameCache,tkey,"oldy")
local real olderx = GetStoredReal(udg_GameCache,tkey,"olderx")
local real oldery = GetStoredReal(udg_GameCache,tkey,"oldery")
local real acc = GetStoredReal(udg_GameCache,tkey,"acc")
local real m = GetStoredReal(udg_GameCache,tkey,"m")
local real times = GetStoredReal(udg_GameCache,tkey,"times")
local real speed = GetStoredReal(udg_GameCache,tkey,"speed")
local real mana = GetUnitState(u,UNIT_STATE_MANA)
local integer buffid = GetStoredInteger(udg_GameCache,tkey,"buffid")
//下面的变量用以完成加速的间隔,当开始加速后,accing设为true accable设为false ,10秒后变为true
local boolean accing = GetStoredBoolean(udg_GameCache,tkey,"accing")
local boolean reaccable= GetStoredBoolean(udg_GameCache,tkey,"reaccable")//是否可以重新加速
local timer tm2=I2TM(GetStoredInteger(udg_GameCache,H2S(u),"tm2"))//用来在10秒后改变accble的计时器
//call BJDebugMsg(R2S(speed))
if GetUnitAbilityLevel(u,buffid)>0 then//判断是否有buff
if x!=oldx or x!=olderx or y!=oldy or y!=oldery then //判断单位是否移动
if mana>=m*speed then //是否有足够的魔法值
if speed +times*acc>= 522 then //是否达到速度极限
call UnitAddAbility(u,'A001')//增加隐身效果 移植技能的时候请修改此处的ID
endif
if accing or reaccable then //如果正在加速,或者允许加速
if times*acc+speed<522 then
call StoreReal(udg_GameCache,tkey,"times",times+1)
endif
call SetUnitMoveSpeed(u,RMinBJ(speed+acc*times,522))//加速
endif
call SetUnitState(u,UNIT_STATE_MANA,mana - m * speed )//消耗魔法
if accing==false then //若此次为满足条件,则说明单位刚刚加速
call StoreBoolean(udg_GameCache,tkey,"accing",true)//保存处于加速的状态
call StoreBoolean(udg_GameCache,tkey,"reaccable",false)
call TimerStart(tm2,10,false,function WindStepResetReaccable)//10秒后才允许再次加速
endif
else
call SetUnitMoveSpeed(u,GetUnitDefaultMoveSpeed(u))//取消减速效果
call UnitRemoveAbility(u,'A001')//取消隐身效果
call StoreBoolean(udg_GameCache,tkey,"accing",false)//不处于加速状态
call IssueImmediateOrder(u,"manashieldoff")//强制关闭魔法
call StoreReal(udg_GameCache,tkey,"times",0)
call PauseTimer(tm)//停止计时
endif
call StoreReal(udg_GameCache,tkey,"oldx",x)
call StoreReal(udg_GameCache,tkey,"oldy",y)
call StoreReal(udg_GameCache,tkey,"olderx",oldx)
call StoreReal(udg_GameCache,tkey,"oldery",oldy)
else
call SetUnitMoveSpeed(u,GetUnitDefaultMoveSpeed(u))//取消加速效果
call StoreBoolean(udg_GameCache,tkey,"accing",false)//更新状态
call StoreReal(udg_GameCache,tkey,"times",0)
endif
else
call SetUnitMoveSpeed(u,GetUnitDefaultMoveSpeed(u))//去除加速
call UnitRemoveAbility(u,'A001')//取消隐身效果,移植技能的时候请修改此处的ID
call StoreReal(udg_GameCache,tkey,"times",0)
call PauseTimer(tm)
call StoreBoolean(udg_GameCache,tkey,"accing",false)//更新状态
endif
endfunction
function IsWindStep takes nothing returns boolean
return GetSpellAbilityId() == 'A000' //移植技能的时候请修改此处的ID
endfunction
function StartWindStep takes nothing returns nothing
local unit u = GetTriggerUnit()
local timer tm = I2TM(GetStoredInteger(udg_GameCache,H2S(u),"timer"))
local string tkey = H2S(tm)
local trigger firsthit = CreateTrigger()
call StoreReal(udg_GameCache,tkey,"oldx",GetUnitX(u))
call StoreReal(udg_GameCache,tkey,"oldy",GetUnitY(u))
call StoreReal(udg_GameCache,tkey,"olderx",GetUnitX(u))
call StoreReal(udg_GameCache,tkey,"oldery",GetUnitY(u))
call StoreReal(udg_GameCache,tkey,"speed",GetUnitMoveSpeed(u))
call StoreReal(udg_GameCache,tkey,"times",0)
call TimerStart(tm,0.05,true,function WindStepLoop)
endfunction
function RegisterWindStepEffect takes unit u returns nothing
//注册风行步效果
//一个单位只需要注册一次,多次也不会有事
//注册后,当单位使用风行步技能时,触发效果
local trigger tg
local trigger firsthit
local timer tm
local timer tm2
local string tkey
local string key = H2S(u)
//请在此修改技能参数
local integer buffid='B000' //魔法效果ID 移植技能的时候请修改此处的ID
local real acc=50 //加速度 码/秒
local real m=0.075 //魔法消耗因子,消耗平均移动速度的0.1倍
call InitCache()
if HaveStoredInteger(udg_GameCache,key,"trigger") then
//已经注册过,则取得计时器句柄
set tkey = I2S(GetStoredInteger(udg_GameCache,key,"timer"))
else
//未注册,创建实例
set tg = CreateTrigger()
set firsthit=CreateTrigger()
set tm = CreateTimer()
set tm2 = CreateTimer()
set tkey = H2S(tm)
call TriggerRegisterUnitEvent(tg,u,EVENT_UNIT_SPELL_EFFECT)
call TriggerAddAction(tg,function StartWindStep)
call TriggerAddCondition(tg,Condition(function IsWindStep))
call TriggerRegisterAnyUnitEventBJ(firsthit,EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(firsthit,Condition(function WindStepFirstHitCond))
call TriggerAddAction(firsthit,function WindStepFirstHit)
call StoreInteger(udg_GameCache,tkey,"unit",H2I(u))
call StoreInteger(udg_GameCache,key,"trigger",H2I(tg))
call StoreInteger(udg_GameCache,key,"firsthit",H2I(tg))
call StoreInteger(udg_GameCache,key,"timer",H2I(tm))
call StoreInteger(udg_GameCache,key,"timer2",H2I(tm2))
call StoreInteger(udg_GameCache,H2S(tm2),"timer",H2I(tm))
endif
//初始化数据
call StoreInteger(udg_GameCache,tkey,"buffid",buffid)
call StoreReal(udg_GameCache,tkey,"acc",acc/20)
call StoreReal(udg_GameCache,tkey,"m",m/200)
call StoreBoolean(udg_GameCache,key,"accing",false)
call StoreBoolean(udg_GameCache,key,"reaccable",true)
endfunction
function Trig_Wind_Step_Actions takes nothing returns nothing
call RegisterWindStepEffect(GetTriggerUnit())
endfunction
function Trig_Wind_Step_Conditions takes nothing returns boolean
return GetLearnedSkill() == 'A000' //移植技能的时候请修改此处的ID
endfunction
//===========================================================================
function InitTrig_Wind_Step takes nothing returns nothing
set gg_trg_Wind_Step = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Wind_Step, EVENT_PLAYER_HERO_SKILL )
call TriggerAddCondition( gg_trg_Wind_Step, Condition( function Trig_Wind_Step_Conditions ) )
call TriggerAddAction( gg_trg_Wind_Step, function Trig_Wind_Step_Actions )
endfunction
[/jass] |
|