1 - 本演示需1.24b以上魔兽版本
2 - 为方便WEER移植已经写好注释
3 - 支持多人同时释放
4 - 需JassHelper插件支持(YDWE)
5 - 仅供学习与娱乐
[通魔作坊]dota技能 - 投掷 .w3x
(167 KB, 下载次数: 239)
[jass]
//! zinc
library ThrowingOfKu requires TimerUtils{
private{
constant string SPELL_UNIT_ID = "thunderclap" ; //伤害技能命令串
constant real SELECT_RANGE = 275 ; //抓取单位的范围
constant real UNIT_LIVE_TIME = 1.00 ; //马甲生命周期
constant real HEIGHT_MAX = 750.00 ; //顶点高度
constant integer COUNT_MAX = 40 ; //高度/距离变幻速度
constant string TEXT = "|cffffcc00没有可投掷的单位|r" ;
// 上面的常量参数按个人需要自行修改
constant integer SPELL_ID = 'A000' ; //投掷技能ID
constant integer SPELL_ID2 = 'A001' ; //雷霆一击技能ID
constant integer UNITID_ID = 'ewsp' ; //马甲ID
// 上面的常量参数必须要修改
}
private struct Throwing{
private{
unit Hero,u,u2;
timer t ;
real h,ang,Dis;
integer count,Level;
}
private static method SpellThroingTimer(){
real ang,s,h;
unit u;
Throwing data = Throwing(GetTimerData(GetExpiredTimer()));
ang = Atan2(GetUnitY(data.u)-GetUnitY(data.u2),GetUnitX(data.u)-GetUnitX(data.u2));
s = data.Dis / I2R(COUNT_MAX);
SetUnitX(data.u2,GetUnitX(data.u2)+s*Cos(ang));
SetUnitY(data.u2,GetUnitY(data.u2)+s*Sin(ang));
h = (((-4*HEIGHT_MAX)/(Pow(data.Dis,2.00)))*Pow(((I2R(data.count)*s)-(data.Dis/2.00)),2.00))+HEIGHT_MAX;
SetUnitFlyHeight(data.u2,h,0);
data.count -= 1 ;
if (data.count < 0) {
u = CreateUnit(GetOwningPlayer(data.Hero),UNITID_ID,GetUnitX(data.u2),GetUnitY(data.u2),0);
SetUnitAbilityLevel(u,SPELL_ID2,data.Level);
IssueImmediateOrder( u, SPELL_UNIT_ID );
UnitApplyTimedLife( u, 'BHwe', UNIT_LIVE_TIME );
SetUnitFlyHeight(data.u2,GetUnitDefaultFlyHeight(data.u2),0);
ReleaseTimer(data.t);
data.deallocate();
}
}
private static method SpellThrowing(unit Hero,unit u){
Throwing data = Throwing.allocate();
real x1= GetUnitX(u),y1= GetUnitY(u),x2,y2;
group g = CreateGroup(),g2 = CreateGroup();
unit u2 = null,Majia;
GroupEnumUnitsInRange(g,GetUnitX(Hero),GetUnitY(Hero),SELECT_RANGE,null);
do{
u2 = FirstOfGroup(g);
if(GetUnitState(u2, UNIT_STATE_LIFE) > 0 && u2!=Hero&&GetUnitTypeId(u2)!=UNITID_ID ){
GroupAddUnit(g2,u2);
}
GroupRemoveUnit(g,u2);
}while( u2 != null );
if (IsUnitGroupEmptyBJ(g2) != true) {
u2 = /*GroupPickRandomUnit*/FirstOfGroup(g2);
UnitAddAbility(u2, 'Amrf' );
UnitRemoveAbility(u2, 'Amrf' );
x2 = GetUnitX(Hero);
y2 = GetUnitY(Hero);
data.Dis = SquareRoot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
data.count = COUNT_MAX;
data.Hero = Hero;
data.u = u ;
data.u2 = u2;
data.t = NewTimer();
//! textmacro LevelIf takes number
if (GetUnitAbilityLevel(Hero, SPELL_ID) == $number$ ){
data.Level = $number$;
}
//! endtextmacro
//! runtextmacro LevelIf("1")
//! runtextmacro LevelIf("2")
//! runtextmacro LevelIf("3")
//! runtextmacro LevelIf("4")
SetTimerData(data.t,integer(data));
TimerStart(data.t,0.03,true,function Throwing.SpellThroingTimer);
}
else {
IssueImmediateOrder(Hero, "stop" );
DisplayTimedTextToPlayer( GetOwningPlayer(Hero), 0.50, 0.00, 2.00,TEXT);
}
DestroyGroup(g);
DestroyGroup(g2);
u2 = null;
g = null;
}
private static method Start() -> boolean{
if (GetSpellAbilityId() == SPELL_ID){
Throwing.SpellThrowing(GetTriggerUnit(),GetSpellTargetUnit());
}
return false;
}
private static method onInit() {
trigger t = CreateTrigger();
TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT );
TriggerAddCondition( t, Condition( function Throwing.Start ) );
t = null;
}
}
}
//! endzinc
[/jass] |