|
发表于 2015-2-6 20:38:14
|
显示全部楼层
本帖最后由 RoyalFlare 于 2015-2-6 20:42 编辑
1.20e GameCache+ReturnBug环境使用
1.24e的话就更换为HashTable来存储数据就好了
- globals
- gamecache udg_Titans_Cache=null
- endglobals
- function H2I takes handle H returns integer
- return H
- return 0
- endfunction
- function I2U takes integer I returns unit
- return I
- return null
- endfunction
- function H2S takes handle H returns string
- return I2S(H2I(H))
- return null
- endfunction
- function FlushEx takes string MissionKey returns nothing
- call FlushStoredMission(udg_Titans_Cache,MissionKey)
- endfunction
- function SaveInteger takes string MissionKey,string Key,integer Value returns nothing
- call StoreInteger(udg_Titans_Cache,MissionKey,Key,Value)
- endfunction
- function SaveReal takes string MissionKey,string Key,real Value returns nothing
- call StoreReal(udg_Titans_Cache,MissionKey,Key,Value)
- endfunction
- function SaveBoolean takes string MissionKey,string Key,boolean Value returns nothing
- call StoreBoolean(udg_Titans_Cache,MissionKey,Key,Value)
- endfunction
- function GetInteger takes string MissionKey,string Key returns integer
- return GetStoredInteger(udg_Titans_Cache,MissionKey,Key)
- endfunction
- function GetReal takes string MissionKey,string Key returns real
- return GetStoredReal(udg_Titans_Cache,MissionKey,Key)
- endfunction
- function GetBoolean takes string MissionKey,string Key returns boolean
- return GetStoredBoolean(udg_Titans_Cache,MissionKey,Key)
- endfunction
- function WhirlCutDamageEstimate takes nothing returns boolean
- local unit Unia=I2U(GetInteger("WhirlCut","Hero"))
- local unit Unib=I2U(GetInteger("WhirlCutDamageUnit","Unit"+H2S(GetFilterUnit())))
- local real Damage=GetReal("WhirlCut","Damage")
- local player Plaa=GetOwningPlayer(Unia)
- local boolean Booa=IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE)==false
- local boolean Boob=IsUnitType(GetFilterUnit(),UNIT_TYPE_ANCIENT)==false
- local boolean Booc=IsUnitType(GetFilterUnit(),UNIT_TYPE_SAPPER)==false
- local boolean Bood=GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)>0
- local boolean Booe=IsUnitHidden(GetFilterUnit())==false
- local boolean Boof=GetUnitAbilityLevel(GetFilterUnit(),'Avul')==0
- local boolean Boog=IsUnitType(GetFilterUnit(),UNIT_TYPE_ETHEREAL)==false
- local boolean Booh=IsUnitType(GetFilterUnit(),UNIT_TYPE_MECHANICAL)==false
- local boolean Booi=IsUnitAlly(GetFilterUnit(),Plaa)==false
- local boolean Booj=GetFilterUnit()!=Unib
- if Booa and Boob and Booc and Bood and Booe and Boof and Boog and Booh and Booi and Booj then
- call UnitDamageTarget(Unia,GetFilterUnit(),Damage,true,false,ATTACK_TYPE_HERO,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_METAL_MEDIUM_SLICE)
- call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl",GetFilterUnit(),"chest"))
- call SaveInteger("WhirlCutDamageUnit","Unit"+H2S(GetFilterUnit()),H2I(GetFilterUnit()))
- endif
- set Plaa=null
- set Unia=null
- set Unib=null
- return false
- endfunction
- function WhirlCutRun takes nothing returns nothing
- local real Distance
- local real Face
- local real Speed
- local real Track=GetReal("WhirlCut","Track")
- local unit Unia=I2U(GetInteger("WhirlCut","Unit"))
- local unit Unib=I2U(GetInteger("WhirlCut","Hero"))
- local boolean Return=GetBoolean("WhirlCut","Return")
- local real Ax
- local real Ay
- local real Bx
- local real By
- local group Groa
- local boolexpr Booa
- if Return then
- set Ax=GetUnitX(Unib)
- set Ay=GetUnitY(Unib)
- set Bx=GetUnitX(Unia)
- set By=GetUnitY(Unia)
- set Distance=SquareRoot(((Bx-Ax)*(Bx-Ax))+((By-Ay)*(By-Ay)))
- set Face=(180/3.14159)*Atan2(Ay-By,Ax-Bx)
- if Distance>=30 then
- set Speed=Track/30
- set Track=Track+Speed
- call SetUnitX(Unia,GetUnitX(Unia)+Speed*Cos(Face*3.14159/180))
- call SetUnitY(Unia,GetUnitY(Unia)+Speed*Sin(Face*3.14159/180))
- set Groa=CreateGroup()
- set Booa=Condition(function WhirlCutDamageEstimate)
- call GroupEnumUnitsInRange(Groa,GetUnitX(Unia),GetUnitY(Unia),80,Booa)
- call DestroyGroup(Groa)
- call DestroyBoolExpr(Booa)
- set Groa=null
- set Booa=null
- if Speed<15 then
- call SaveReal("WhirlCut","Track",Track)
- endif
- else
- call RemoveUnit(Unia)
- call FlushEx("WhirlCut")
- call FlushEx("WhirlCutDamageUnit")
- call PauseTimer(GetExpiredTimer())
- call DestroyTimer(GetExpiredTimer())
- endif
- else
- set Distance=GetReal("WhirlCut","Distance")
- set Face=GetReal("WhirlCut","Face")
- if Track<=Distance-30 then
- set Speed=(Distance-Track)/30
- set Track=Track+Speed
- call SetUnitX(Unia,GetUnitX(Unia)+Speed*Cos(Face*3.14159/180))
- call SetUnitY(Unia,GetUnitY(Unia)+Speed*Sin(Face*3.14159/180))
- set Groa=CreateGroup()
- set Booa=Condition(function WhirlCutDamageEstimate)
- call GroupEnumUnitsInRange(Groa,GetUnitX(Unia),GetUnitY(Unia),80,Booa)
- call DestroyGroup(Groa)
- call DestroyBoolExpr(Booa)
- set Groa=null
- set Booa=null
- call SaveReal("WhirlCut","Track",Track)
- else
- call SaveBoolean("WhirlCut","Return",true)
- call SaveReal("WhirlCut","Track",((Distance-Track)/30)+90)
- call FlushEx("WhirlCutDamageUnit")
- endif
- endif
- set Unia=null
- set Unib=null
- endfunction
- function WhirlCut takes unit Unia,real x,real y returns nothing
- local real Ax=GetUnitX(Unia)
- local real Ay=GetUnitY(Unia)
- local real Bx=x
- local real By=y
- local real Face=(180/3.14159)*Atan2(By-Ay,Bx-Ax)
- local real Distance=SquareRoot(((Bx-Ax)*(Bx-Ax))+((By-Ay)*(By-Ay)))
- local real Damage=(GetUnitAbilityLevel(Unia,'A08I')*30)+50
- local timer Tima=CreateTimer()
- if Distance<(GetUnitAbilityLevel(Unia,'A08I')*100)+400 then
- set Distance=(GetUnitAbilityLevel(Unia,'A08I')*100)+400
- endif
- call SaveReal("WhirlCut","Distance",Distance)
- call SaveReal("WhirlCut","Track",0)
- call SaveReal("WhirlCut","Face",Face)
- call SaveReal("WhirlCut","Damage",Damage)
- call SaveInteger("WhirlCut","Unit",H2I(CreateUnit(GetOwningPlayer(Unia),'u00W',Ax,Ay,Face)))
- call SaveInteger("WhirlCut","Hero",H2I(Unia))
- call SaveBoolean("WhirlCut","Return",false)
- call TimerStart(Tima,0.01,true,function WhirlCutRun)
- endfunction
- function InitTrig_WhirlCut takes nothing returns nothing
- endfunction
复制代码
调用方法如下:
- function SpellShadowHunterEstimate takes nothing returns boolean
- local location Loca
- if GetTriggerEventId()==EVENT_UNIT_SPELL_EFFECT then
- if GetSpellAbilityId()=='A08I' then
- set Loca=GetSpellTargetLoc()
- call WhirlCut(GetTriggerUnit(),GetLocationX(Loca),GetLocationY(Loca))
- call RemoveLocation(Loca)
- set Loca=null
- else
- endif
- return false
- endfunction
- function SpellShadowHunter takes unit Unia returns nothing
- local trigger Tria=CreateTrigger()
- call TriggerRegisterUnitEvent(Tria,Unia,EVENT_UNIT_SPELL_EFFECT)
- call TriggerAddCondition(Tria,Condition(function SpellShadowHunterEstimate))
- set Tria=null
- endfunction
- function InitTrig_SpellShadowHunter takes nothing returns nothing
- endfunction
复制代码 |
|