Dreii | Дата: Понедельник, 09 Января 2012, 02:47:30 | Сообщение # 1 |
10 уровень
Группа: Проверенные
Сообщений: 4991
Награды: 0
Репутация: 603
Блокировки:
| прошу опытных джассеров посоветовать как сократить\улучшить код
Code include "cj_types.j"
constant hashtable Hash=InitHashtable() location Z=Location(0.,0.) int count=0 library shoot { void DET() { timer t=GetExpiredTimer() DestroyEffect(LoadEffectHandle(Hash,GetHandleId(t),0)) DestroyTimer(t) FlushChildHashtable(Hash,GetHandleId(t)) flush locals } void DE(string mn,real x,real y,unit w,string at) { timer t=CreateTimer() if w==null { SaveEffectHandle(Hash,GetHandleId(t),0,AddSpecialEffect(mn,x,y)) else SaveEffectHandle(Hash,GetHandleId(t),0,AddSpecialEffectTarget(mn,w,at)) } TimerStart(t,.7,false,function DET) flush locals } private void KillHash(unit d,timer t,integer id) { RemoveUnit(d) FlushChildHashtable(Hash,id) PauseTimer(t) DestroyTimer(t) } private bool CountDestsEnum () { set count = count+1 return true } private int CountDests(real x, real y, real rad) { rect r = Rect(-rad,-rad,rad,rad) MoveRectTo(r,x,y) count = 0 EnumDestructablesInRect(r,Filter(function CountDestsEnum),null) RemoveRect(r) r = null return count } private real GetlocZ(real x, real y) { MoveLocation(Z,x,y) return GetLocationZ(Z) } private void pad (unit u,integer dmg,string bl) { group g=CreateGroup() unit e float x=GetWidgetX(u) float y=GetWidgetY(u) int i=0 bool array ti float ze,zd=LoadReal(Hash,GetHandleId(u),8),zk player p=GetOwningPlayer(u) int id=LoadInteger(Hash,GetHandleId(u),0) timer t=LoadTimerHandle(Hash,GetHandleId(u),1) GroupEnumUnitsInRange(g,x,y,155.,null) loop set e=FirstOfGroup(g) exitwhen e==null if IsUnitEnemy(e,p) and GetWidgetLife(e)>.405 and LoadBoolean(Hash,GetHandleId(t),GetHandleId(e))== false and IsUnitInvisible(e,p)==false { DestroyEffect(AddSpecialEffectTarget(bl,e,"head")) UnitDamageTarget(u,e,dmg,true,false,ATTACK_TYPE_HERO,DAMAGE_TYPE_FIRE,WEAPON_TYPE_WHOKNOWS) SaveBoolean(Hash,GetHandleId(t),GetHandleId(e),true) KillHash(u,t,id) } GroupRemoveUnit(g,e) endloop DestroyGroup(g) flush locals } private void MoveMissle(unit u, real x, real y, real z) { SetUnitX(u,x) SetUnitY(u,y) SetUnitFlyHeight(u,z,0.) } private struct shoot { real xe real ye real ze unit u int dmg string ef string me string b
public static void movemissletimer() { timer t=GetExpiredTimer() integer id=GetHandleId(t) shoot sh=shoot(LoadInteger(Hash,id,10)) player p=GetOwningPlayer(sh.u) float xd=GetWidgetX(sh.u),yd=GetWidgetY(sh.u),zd=GetUnitFlyHeight(sh.u)+GetlocZ(xd,yd) float xgo=xd-sh.xe float ygo=yd-sh.ye float zgo=(zd-sh.ze)-GetlocZ(xgo,ygo) SaveInteger(Hash,GetHandleId(sh.u),0,id) SaveTimerHandle(Hash,GetHandleId(sh.u),1,t) pad(sh.u,sh.dmg,sh.b) CountDests(xd,yd,75.) if zgo<=0. || count>0 { KillHash(sh.u,t,id) DestroyEffect(AddSpecialEffect(sh.ef,GetWidgetX(sh.u),GetWidgetY(sh.u))) FlushChildHashtable(Hash,id) PauseTimer(t) DestroyTimer(t) else MoveMissle(sh.u,xgo,ygo,zgo) } DE(sh.me,xd,yd,null," ") sh.destroy() flush locals } } public void momi(unit u,real xt,real yt,integer missle,real angle,integer dmg,real dist,string de,string me,string b) { shoot sh=shoot.create() timer t=CreateTimer() int id=GetHandleId(t) float xu=GetWidgetX(u),yu=GetWidgetY(u),zu=GetlocZ(xu,yu),zt=GetlocZ(xt,yt),xd=xu+45.*Cos(angle) float yd=yu+45.*Sin(angle),zd=((zu-GetlocZ(xd,yd))+60)+GetlocZ(xd,yd)+100 unit d=CreateUnit(GetOwningPlayer(u),missle,xd,yd,57.295827*angle) SetUnitFlyHeight(d,zd-GetlocZ(xd,yd),.0) sh.xe=xu-(xu+60.*Cos(angle)) sh.ye=yu-(yu+60.*Sin(angle)) sh.ze=(zd-zt)/(dist/60) sh.u=d sh.dmg=dmg sh.ef=de sh.me=me sh.b=b call SaveInteger(Hash,id,10,sh) UnitAddAbility(d,'Amrf') UnitRemoveAbility(d,'Amrf') TimerStart(t,.05,true,function shoot.movemissletimer) sh.destroy() flush locals } }
Сообщение отредактировал Dreii - Понедельник, 09 Января 2012, 20:07:29 |
|
|
|