| 01-29-2009, 11:14 AM | #1 | ||
Well ...its a System to create Novas (you all know them). Since xe has no module to achieve this easily i made this (for guys who dont have/dont want to have xe in their map, i added 2 other versions. however i would recommend the xe version). It uses one timer for all instances and it is pretty flexible, see attached map for more info.
JASS://////////////////////////////////////////////////////// //* * * * * * * * * * * * * * * * * * * * * * * * * * * //* NoVa System v1.1 //* by Akolyt0r //* //* requires xebasic and xefx by Vexorian //* //* its HIGHLY recommended to read the Documentation //* AND to check out the Examples included in this Map //* (especially when you dont have a clue what that //* extending stuff is all about). //* //* Credits: //* Vexorian for dummy.mdx and xe //* Anitarf, (Zerzax), ... for feedback/ help //* //* * * * * * * * * * * * * * * * * * * * * * * * * * * //////////////////////////////////////////////////////// library NovaSys requires xebasic, xefx globals // for more info to these, check out the documentation public constant integer MAX_WAVES = 50 public constant real DEFAULT_HEIGHT = 65 public constant real DEFAULT_CSIZE = 50 //================================================= //////// END CONFIGURATION /////////////// ////// Do Not Edit Below //////////// //// Unless you know ////////// // what ur doing //////// private constant real PI2 = bj_PI*2 endglobals private interface eventHandler method onUnitHit takes unit hitTarget returns nothing defaults nothing method onTimerLoop takes nothing returns nothing defaults nothing endinterface struct Nova extends eventHandler real csize=DEFAULT_CSIZE readonly real elapsed //private membervariables private real spd = 500 // default speed private real dur = 1.0 // default duration private xefx array missile[MAX_WAVES] private group alreadyHit private real angoffset = 0 private real cx private real cy private boolean active=false private integer waves private static Nova instance private static code timerCallback private static boolexpr enumFilter private static timer T private static group g private static Nova array V private static integer N=0 debug private boolean speedset=false static method create takes real x, real y, string fxpath, integer waves returns Nova local Nova this=Nova.allocate() local integer i=0 set this.cx = x set this.cy = y if this.alreadyHit==null then set this.alreadyHit = CreateGroup() endif set this.elapsed = 0 set this.active = true set this.V[this.N] = this set this.N = this.N+1 set this.waves = waves loop exitwhen i==waves set this.missile[i]=xefx.create(this.cx,this.cy,i*PI2/waves) set this.missile[i].z=DEFAULT_HEIGHT set this.missile[i].fxpath=fxpath set i=i+1 endloop if(.N==1) then call TimerStart(.T, XE_ANIMATION_PERIOD, true, .timerCallback ) endif return this endmethod //SET operators method operator speed= takes real speed returns nothing set this.spd = speed debug set this.speedset = true endmethod method operator radius= takes real rad returns nothing debug if not this.speedset then debug call BJDebugMsg(SCOPE_PREFIX+": Setup speed BEFORE you set radius (unless you WANT default speed)") debug endif set this.dur = rad/this.spd endmethod method operator duration= takes real dur returns nothing set this.dur = dur endmethod method operator angOffset= takes real angOffset returns nothing set this.angoffset = angOffset endmethod method operator x= takes real x returns nothing set this.cx = x endmethod method operator y= takes real y returns nothing set this.cy = y endmethod method operator z= takes real z returns nothing local integer j=0 loop exitwhen j==this.waves set this.missile[j].z=z set j=j+1 endloop endmethod method operator zangle= takes real zangle returns nothing local integer j=0 loop exitwhen j==this.waves set this.missile[j].zangle=zangle set j=j+1 endloop endmethod method operator scale= takes real s returns nothing local integer j=0 loop exitwhen j==this.waves set this.missile[j].scale=s set j=j+1 endloop endmethod //GET operators method operator speed takes nothing returns real return this.spd endmethod method operator radius takes nothing returns real return this.spd*this.dur endmethod method operator duration takes nothing returns real return this.dur endmethod method operator angOffset takes nothing returns real return this.angoffset endmethod method operator x takes nothing returns real return this.cx endmethod method operator y takes nothing returns real return this.cy endmethod method operator z takes nothing returns real return this.missile[0].z endmethod method operator zangle takes nothing returns real return this.missile[0].zangle endmethod private method onDestroy takes nothing returns nothing local integer j=0 call GroupClear(.alreadyHit) loop exitwhen j==this.waves call this.missile[j].destroy() set j=j+1 endloop endmethod method terminate takes nothing returns nothing set .active = false endmethod private static method NovaTimerCallback takes nothing returns nothing local integer i = 0 local integer c = 0 local integer j local real ang local real step local real aod local Nova this loop exitwhen i == .N set this=.V[i] set this.elapsed=this.elapsed+XE_ANIMATION_PERIOD if (this.active==false) then call this.destroy() else set j=0 if(this.elapsed>this.dur)then set this.active=false else set aod = .angoffset set Nova.instance=this call GroupEnumUnitsInRange(Nova.g,this.cx,this.cy,this.elapsed*this.spd+this.csize+XE_MAX_COLLISION_SIZE,.enumFilter) if( this.onTimerLoop.exists and this.active ) then call this.onTimerLoop() endif set step=XE_ANIMATION_PERIOD*this.spd set aod = (.angoffset-aod)/(XE_ANIMATION_PERIOD*bj_PI) loop exitwhen j==this.waves set ang=j*PI2/this.waves + this.angoffset set this.missile[j].x= this.cx + this.spd*this.elapsed*Cos(ang) set this.missile[j].y= this.cy + this.spd*this.elapsed*Sin(ang) set this.missile[j].xyangle = ang + aod set j=j+1 endloop endif set .V[c]=this set c=c+1 endif set i=i+1 endloop set .N=c if(c==0) then call PauseTimer(.T) endif endmethod private static method NovaEffectCallback takes nothing returns boolean local Nova this=.instance local unit u=GetFilterUnit() if GetUnitTypeId(u)!=XE_DUMMY_UNITID and GetWidgetLife(u) > 0. then if IsUnitInRangeXY(u,this.cx,this.cy,this.csize+this.elapsed*this.spd) and IsUnitInGroup(u,this.alreadyHit)==false then call GroupAddUnit(this.alreadyHit,u) call this.onUnitHit(u) endif endif set u=null return false endmethod static method onInit takes nothing returns nothing set Nova.g=CreateGroup() set Nova.T=CreateTimer() set Nova.enumFilter=Condition(function Nova.NovaEffectCallback) set Nova.timerCallback=function Nova.NovaTimerCallback endmethod endstruct endlibrary
|
| 02-02-2009, 11:07 PM | #2 |
Has someone already looked into this ? Any criticism / comments ? |
| 02-03-2009, 11:46 AM | #3 |
I dont see any reason to submit systems based of an other system that can do this without any major modifications. ofc you will need to type some chars, if you want some nova, create projectiles directed via polars. |
| 02-03-2009, 12:31 PM | #4 | |||
Quote:
Thats not true, this Nova system is pretty much independent, using xefx only makes it more comfortable for the user. So it totally NOT based on xefx. Well maybe its based on xebasic ...LOL According to you, many Systems in the Database would be senseless...since the same somehow applies to them. Quote:
Quote:
And btw there is already a Nova System in the Database, but its not up-to-date anymore (uses kattanas handle vars) and its pretty damn slow. |
| 03-13-2009, 02:19 PM | #5 |
this piece has been much too long on page 2 of the "submit ressource"-Forum ... |
| 04-11-2009, 11:45 AM | #6 |
The "xebasic only" version is silly, if someone has xebasic in their map importing xefx is a piece of cake. The create method has a long argument list, you should shorten that. The caster parameter is not needed, users can include it in their own nova code when they exted your Nova struct if they want to. speed and radius parameters (I think it should be speed and duration, though) could be moved to a separate "launch" or "explode" or whatever method. You should add methods/method operators that allow the user to move (and get) the nova's center. Then, you should calculate the xefx positions based on the center of the nova and the time elapsed rather than the xefx's last position. Likewise, get and set operators for current nova size and speed are needed. You create one xefx too many. |
| 04-11-2009, 12:20 PM | #7 | ||||
Quote:
Quote:
Quote:
Operator for speed is already useful, so i will implement it ... Quote:
|
| 04-11-2009, 03:07 PM | #8 | ||||
Quote:
Quote:
As for the position suggestion, it's simply a lot cooler if you can make a moving Nova. A rotating Nova, too (although this is just eyecandy, it doesn't affect gameplay). I'd also suggest implementing other xefx features, like flash, recolor, etc... If you're going to use xefx, then really use it. Quote:
Quote:
Also, there's no mention of a way to prematurely terminate the Nova (for example, could be used in a channeling spell). |
| 04-11-2009, 03:28 PM | #9 | ||||
Quote:
Quote:
Quote:
hmm ...seems like i will have to drop further development of the no-xe version and everything will be fine.... Quote:
|
| 04-11-2009, 04:30 PM | #10 | |
Quote:
|
| 04-11-2009, 04:41 PM | #11 |
already dropped the .rad struct member ... i have implemented speed, radius and duration operators now since i dont have a speed-parameter now and no .rad struct member, i had to add some debug messages for the radius operator though, since it wont work properly when speed hasnt been set before ... EDIT: what i got so far:// havent testet a moving nova yet // rotation works ! library NovaSys requires xebasic, xefx globals // for more info to these, check out the documentation private constant integer MAX_WAVES = 50 private constant real DEFAULT_HEIGHT = 65 private constant real DEFAULT_CSIZE = 50 //================================================= //////// END CONFIGURATION /////////////// ////// Do Not Edit Below //////////// //// Unless you know ////////// // what ur doing //////// private constant real PI2 = bj_PI*2 endglobals private interface eventHandler method onUnitHit takes unit hitTarget returns nothing defaults nothing method onTimerLoop takes nothing returns nothing defaults nothing endinterface struct Nova extends eventHandler //public membervariables real csize=DEFAULT_CSIZE //private membervariables private real spd = 500 // default speed private real dur = 1.0 // default duration private xefx array missile[MAX_WAVES] private group alreadyHit private real elapsed private real angoffset = 0 private real cx private real cy private boolean active=false private integer waves private static Nova instance private static code timerCallback private static boolexpr enumFilter private static timer T private static group g private static Nova array V private static integer N=0 debug private boolean speedset=false static method create takes real x, real y, string fxpath, integer waves returns Nova local Nova this=Nova.allocate() local integer i=0 set this.cx = x set this.cy = y if this.alreadyHit==null then set this.alreadyHit = CreateGroup() endif set this.elapsed = 0 set this.active = true set this.V[this.N] = this set this.N = this.N+1 set this.waves = waves loop exitwhen i==waves set this.missile[i]=xefx.create(this.cx,this.cy,i*PI2/waves) set this.missile[i].z=DEFAULT_HEIGHT set this.missile[i].fxpath=fxpath set i=i+1 endloop if(.N==1) then call TimerStart(.T, XE_ANIMATION_PERIOD, true, .timerCallback ) endif return this endmethod //SET operators method operator speed= takes real speed returns nothing set this.spd = speed debug set this.speedset = true endmethod method operator radius= takes real rad returns nothing debug if not this.speedset then debug call BJDebugMsg(SCOPE_PREFIX+": Setup speed BEFORE you set radius (unless you WANT default speed)") debug endif set this.dur = rad/this.spd endmethod method operator duration= takes real dur returns nothing set this.dur = dur endmethod method operator angOffset= takes real angOffset returns nothing set this.angoffset = angOffset endmethod method operator x= takes real x returns nothing set this.cx = x endmethod method operator y= takes real y returns nothing set this.cy = y endmethod method operator scale= takes real s returns nothing local integer j=0 loop exitwhen j==this.waves set this.missile[j].scale=s set j=j+1 endloop endmethod method operator z= takes real z returns nothing local integer j=0 loop exitwhen j==this.waves set this.missile[j].z=z set j=j+1 endloop endmethod //GET operators method operator speed takes nothing returns real return this.spd endmethod method operator radius takes nothing returns real return this.spd*this.dur endmethod method operator duration takes nothing returns real return this.dur endmethod method operator angOffset takes nothing returns real return this.angoffset endmethod method operator x takes nothing returns real return this.cx endmethod method operator y takes nothing returns real return this.cy endmethod method operator z takes nothing returns real return this.missile[0].z endmethod private method onDestroy takes nothing returns nothing local integer j=0 call GroupClear(.alreadyHit) loop exitwhen j==this.waves call this.missile[j].destroy() set j=j+1 endloop endmethod method terminate takes nothing returns nothing set .active = false endmethod private static method NovaTimerCallback takes nothing returns nothing local integer i = 0 local integer c = 0 local integer j local real ang local real step local Nova this loop exitwhen i == .N set this=.V[i] set this.elapsed=this.elapsed+XE_ANIMATION_PERIOD if (this.active==false) then call this.destroy() else set j=0 loop exitwhen j==this.waves set step=XE_ANIMATION_PERIOD*this.spd set ang=j*PI2/this.waves + this.angoffset set this.missile[j].x= this.cx + this.spd*this.elapsed*Cos(ang) //this.missile[j].x+step*Cos(ang) set this.missile[j].y= this.cy + this.spd*this.elapsed*Sin(ang) //this.missile[j].y+step*Sin(ang) set this.missile[j].xyangle = ang set j=j+1 endloop if(this.elapsed>this.dur)then set this.active=false else set Nova.instance=this call GroupEnumUnitsInRange(Nova.g,this.cx,this.cy,this.elapsed*this.spd+this.csize+XE_MAX_COLLISION_SIZE,.enumFilter) if( this.onTimerLoop.exists and this.active ) then call this.onTimerLoop() endif endif set .V[c]=this set c=c+1 endif set i=i+1 endloop set .N=c if(c==0) then call PauseTimer(.T) endif endmethod private static method NovaEffectCallback takes nothing returns boolean local Nova this=.instance local unit u=GetFilterUnit() if GetUnitTypeId(u)!=XE_DUMMY_UNITID and GetWidgetLife(u) > 0. then if IsUnitInRangeXY(u,this.cx,this.cy,this.csize+this.elapsed*this.spd) and IsUnitInGroup(u,this.alreadyHit)==false then call GroupAddUnit(this.alreadyHit,u) call this.onUnitHit(u) endif endif set u=null return false endmethod static method onInit takes nothing returns nothing set Nova.g=CreateGroup() set Nova.T=CreateTimer() set Nova.enumFilter=Condition(function Nova.NovaEffectCallback) set Nova.timerCallback=function Nova.NovaTimerCallback endmethod endstruct endlibrary |
| 04-12-2009, 11:56 AM | #12 |
updated... TestMap now contains an additional Nova-Ability aswell (rotation ftw). I got a issues.. with this however... when the user does not use .angOffset for rotation, but for something else (who knows what "the user" could have in mind ...). The facing of the missiles will fuck up :( ... seems like i will have to add a boolean operator isRotation (default= true). |
| 06-08-2009, 10:30 PM | #13 |
Due to the long amount of spells in the submit forum. I decided to start the 'one day one spell' program. Everyday I pick the spell at the last page of the submit a resource forum. After 24 hours I will either approve or graveyard it so I hope akolyt0r is active enough the next 24 hours to do changes if I find things that are flawed with this spell. Edit: First impressions. Demomap Fire nova's effects are way too massive, good thing it is just as system sample, else it would have been a blocker. edit 2: Code: All right, that was easy, approved. |
| 06-09-2009, 03:52 AM | #14 | |
Quote:
1: Huh, i only get a fps-drop of 1 fps ... or did you mean it looks too "massive" ? 2: Cool ;) 3: I noticed i should update xe in the demomap ... |
| 06-09-2009, 03:59 AM | #15 | |
Quote:
|
