|
朋友要的.就给优化了一下.应该是没有泄露什么的..只有2个单位放...两个计时器..木有点..
应该是效率上可以过得去了..
代码如下:
[jass]
//! zinc
library xxx
{
constant boolean MODE =TRUE; //为TURE时,可以跟随英雄移动,为FALSE时 不能
跟随英雄移动.
constant integer ABILITY_ID = 'A004'; //触发技能ID
constant integer ORDER = 852580; //命令ID
constant real GAP=0.02; //施放间隔
constant real DURATION=5; //持续时间
constant integer TYPE_DUMMY= 'e001'; //马甲类型
//以上是常量.以下是变量
real ax,ay,bx,by,ang;
timer at,bt;
unit u,au,bu;
// real x = source + dist * Cos(angle * 0.017);
function act3()
{DestroyTimer(GetExpiredTimer());
DestroyTimer(at);
debug BJDebugMsg("Act3");
}
function act2()
{ real aax,aay,bax,bay,ang_a,ang_b,x,y;
if (MODE)
{x=GetUnitX(u);
y=GetUnitY(u);
SetUnitX(au,x);
SetUnitY(au,y);
SetUnitX(bu,x);
SetUnitY(bu,y);
ax=GetUnitX(au);ay=GetUnitY(au);
bx=GetUnitX(bu);by=GetUnitY(bu);
ang+=10;
if (ang>=180)
{
ang =10;
}
ang_a=ang;
ang_b=ang_a+180;
}
else
{
ang=GetUnitFacing(u)+90;
SetUnitFacing(u,ang);
ang_a=ang;
if (ang>=180)
{ang_b=ang_a-180;} else {
ang_b=ang+180;}
}
debug BJDebugMsg(R2S(ang_b));
SetUnitFacing(au,ang_a);
SetUnitFacing(bu,ang_b);
aax=ax+300*Cos(ang_a*0.017);
aay=ay+300*Sin(ang_a*0.017);
bax=bx+300*Cos(ang_b*0.017);
bay=by+300*Sin(ang_b*0.017);
IssuePointOrderById(au,ORDER,aax,aay);
IssuePointOrderById(bu,ORDER,bax,bay);
if (IsUnitType(u,UNIT_TYPE_DEAD)==TRUE )
{DestroyTimer(bt);
DestroyTimer(at);
}
}
function Act()
{debug BJDebugMsg("Act");
at=CreateTimer();bt=CreateTimer();
u=GetTriggerUnit();
ang=GetUnitFacing(u);
//获得了角度
au=CreateUnit(GetTriggerPlayer(),TYPE_DUMMY,GetUnitX(u),GetUnitY(u),ang);
ax=GetUnitX(au);ay=GetUnitY(au);
bu=CreateUnit(GetTriggerPlayer(),TYPE_DUMMY,GetUnitX(u),GetUnitY(u),ang+180);
bx=GetUnitX(bu);by=GetUnitY(bu);
UnitApplyTimedLife(au,'bhwe',DURATION);
UnitApplyTimedLife(bu,'bhwe',DURATION);
TimerStart(at,GAP,true, function act2);
TimerStart(bt,DURATION,false, function act3);
}
function Cond()->boolean
{
debug BJDebugMsg("条件触发了");
return GetSpellAbilityId()== ABILITY_ID && IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO)==TRUE;
}
function onInit()
{ trigger t=CreateTrigger();
//TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT);
TriggerRegisterUnitEvent( t, gg_unit_N000_0002, EVENT_UNIT_SPELL_EFFECT );
TriggerAddCondition(t,Condition( function Cond));
TriggerAddAction(t, function Act);
t=null;
debug BJDebugMsg("初始化了");
}
}
//! endzinc
[/jass]
螺旋桨 优化zinc.7z
(27 KB, 下载次数: 51)
|
评分
-
查看全部评分
|