| 07-27-2008, 10:15 AM | #1 | |
A little spell I've made. It's my first time using the global struct thingy, so tell me if it's done wrongly. Code; JASS:scope xxarm private keyword xa globals private constant integer raw = 'A000' // The raw code of the spell private constant integer met = 'h001' // The raw code of the meteor unit private constant real damage = 100 // The damage from each meteor private constant real aoe = 650 // The AoE of the spell private constant real duration = 10 // The duration of the spell private constant damagetype dtype = DAMAGE_TYPE_FIRE // The damagetype of the spell private integer xi=0 //Don't touch private xa array xz //Don't touch endglobals private struct xa timer xt trigger xst trigger xxdt unit xc player xo real xcx real xcy real xx real xy real xf rect xr integer xin private method onDestroy takes nothing returns nothing call DestroyTimer(.xt) call DestroyTrigger(.xst) call DestroyTrigger(.xxdt) call RemoveRect(.xr) set.xt=null set.xr=null set.xst=null set.xxdt=null endmethod endstruct private constant function xco takes nothing returns boolean return GetSpellAbilityId() == raw endfunction private function xeds takes nothing returns boolean call xz[xi].destroy() return false endfunction private function xxflt takes nothing returns boolean return IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(xz[xi].xc))==true endfunction private function xxdam takes nothing returns nothing call UnitDamageTarget(xz[xi].xc,GetEnumUnit(),damage,false,true,ATTACK_TYPE_NORMAL,dtype,null) endfunction private function xxdea takes nothing returns boolean local unit u=GetDyingUnit() local real x=GetUnitX(u) local real y=GetUnitY(u) local group g=CreateGroup() call GroupEnumUnitsInRange(g,x,y,100,Filter(function xxflt)) call ForGroup(g,function xxdam) return false endfunction private function xcre takes nothing returns nothing local unit d set xz[xi].xf=GetRandomReal(0,360) set xz[xi].xx=GetRandomReal(GetRectMinX(xz[xi].xr),GetRectMaxX(xz[xi].xr)) set xz[xi].xy=GetRandomReal(GetRectMinY(xz[xi].xr),GetRectMaxY(xz[xi].xr)) set d=CreateUnit(xz[xi].xo,met,xz[xi].xx,xz[xi].xy,xz[xi].xf) call UnitApplyTimedLife(d,'BTLF',1) call TriggerRegisterUnitEvent(xz[xi].xxdt,d,EVENT_UNIT_DEATH) call TriggerAddCondition(xz[xi].xxdt,Condition(function xxdea)) set d=null set xz[xi].xin=xz[xi].xin+1 if(xz[xi].xin>=duration*2)then call DestroyTimer(xz[xi].xt) call xz[xi].destroy() set xi=xi-1 endif endfunction private function xac takes nothing returns nothing set xi=xi+1 if(xi==8192)then set xi=1 endif debug call BJDebugMsg(I2S(xi)) set xz[xi]=xa.create() set xz[xi].xt=CreateTimer() set xz[xi].xst=CreateTrigger() set xz[xi].xxdt=CreateTrigger() set xz[xi].xc=GetTriggerUnit() set xz[xi].xcx=GetUnitX(xz[xi].xc) set xz[xi].xcy=GetUnitY(xz[xi].xc) set xz[xi].xin=0 set xz[xi].xo=GetOwningPlayer(xz[xi].xc) set xz[xi].xr=Rect(xz[xi].xcx-aoe*0.5,xz[xi].xcy-aoe*0.5,xz[xi].xcx+aoe*0.5,xz[xi].xcy+aoe*0.5) call TimerStart(xz[xi].xt,.5,true,function xcre) call TriggerRegisterUnitEvent(xz[xi].xst,xz[xi].xc,EVENT_UNIT_ISSUED_ORDER) call TriggerRegisterUnitEvent(xz[xi].xst,xz[xi].xc,EVENT_UNIT_ISSUED_POINT_ORDER) call TriggerRegisterUnitEvent(xz[xi].xst,xz[xi].xc,EVENT_UNIT_ISSUED_TARGET_ORDER) call TriggerAddCondition(xz[xi].xst,Condition(function xeds)) endfunction //=========================================================================== function InitTrig_Armageddon takes nothing returns nothing local trigger t=CreateTrigger() call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT) call TriggerAddCondition(t,Condition(function xco)) call TriggerAddAction(t,function xac) endfunction endscope Screenshot;
|
| 07-28-2008, 01:17 AM | #2 |
Because you're in learning process and it's not still suitable as a submission, I'll move it to the T&S section. EDIT: About your code, you're abusing too much of dynamic triggers: JASS:call TriggerRegisterUnitEvent(xz[xi].xst,xz[xi].xc,EVENT_UNIT_ISSUED_ORDER) call TriggerRegisterUnitEvent(xz[xi].xst,xz[xi].xc,EVENT_UNIT_ISSUED_POINT_ORDER) call TriggerRegisterUnitEvent(xz[xi].xst,xz[xi].xc,EVENT_UNIT_ISSUED_TARGET_ORDER) As I can see, you use them to detect if the caster has stopped casting the spell. You can do this thing without these triggers with a periodic timer which check if the casting order has changed. Your variable and function names.... makes people run away.... try to make your code clear. |
| 07-28-2008, 07:57 PM | #3 | |
Quote:
Check the folder on the hard drive where Warcraft is installed. There you'll find a folder called Screenshots. For instance: C:\Games\Warcraft III\Screenshots |
| 07-29-2008, 07:41 AM | #4 |
So many 'x's. Why? |
