| 03-14-2009, 01:02 PM | #1 | ||
Description: This little library allows the user to schedule effects and destroy them after some time with only one line. There are some more things you can do to delayed effects and I suggest you look at the code to understand this library. I developed this library for my Phoenix Form spell, which is why the testmap matches the Phoenix Form one. In particular I used DelFX to time the flamestrike effects and simulate the burning effect of immolation. This library uses Vexorian's TimerUtils library and vJass syntax.
Library-Code + Credits:// API: // // >>CreateDelayedEffect(whichEffect, X, Y, Delay, Timeout) // - whichEffect is of type string and contains the path of the // effect-to-be-spawned // - X and Y indicate where the effect should be spawned // - Delay is of type real and indicates how long to wait before spawning the // effect // - Timeout is of type real and indicates how long to wait before destroying // the effect after it has been created // // >>CreateDelayedEffectZ(whichEffect, X, Y, Z, Delay, Timeout) // - whichEffect: see above // - X, Y and Z indicate where to spawn the effect // - Delay: see above // - Timeout: see above // // >>CreateDelayedEffectTarget(whichEffect, Target, AttachmentPoint, Delay, Timeout) // - whichEffect: see above // - Target is of type widget and indicates on which widget the effect should // be spawned // - AttachmentPoint is of type string and holds the attachment point where // the effect should be spawned on target widget // - Delay: see above // - Timeout: see above // // CREDITS: // - Vexorian (JassHelper; TimerUtils) // - Anitarf (Suggestions) // - KaTTaNa (AddSpecialEffectZ function @ wc3jass.com) // - PitzerMike (JassNewGenPack) // - Pipedream (Grimoire) // - SFilip (TESH) library DelFX uses TimerUtils private struct DELFX private effect fx private string path private boolean target private widget tar private string attpt private real x private real y private real z private timer t private real timeout private method onDestroy takes nothing returns nothing if .fx!=null then call DestroyEffect(.fx) set .fx=null endif set .tar=null call ReleaseTimer(.t) endmethod private static method Release takes nothing returns nothing call DELFX.destroy(GetTimerData(GetExpiredTimer())) endmethod private static method Callback takes nothing returns nothing local DELFX s=GetTimerData(GetExpiredTimer()) local destructable d debug if s.fx==null then if s.target then set s.fx=AddSpecialEffectTarget(s.path, s.tar, s.attpt) elseif s.z==0 then set s.fx=AddSpecialEffect(s.path, s.x, s.y) else set d=CreateDestructableZ('OTip', s.x, s.y, s.z, 0,1.,0) set s.fx=AddSpecialEffect(s.path, s.x, s.y) call RemoveDestructable(d) set d=null endif call TimerStart(s.t, s.timeout, false, function DELFX.Release) debug else debug call BJDebugMsg("DELFX["+I2S(s)+"].Callback: Effect already spawned!") debug endif endmethod static method Create takes string path, boolean target, widget tar, string attpt, real x, real y, real z, real delay, real timeout returns DELFX local DELFX s=DELFX.allocate() set s.t=NewTimer() call SetTimerData(s.t, s) set s.path=path set s.target=target set s.tar=tar set s.attpt=attpt set s.x=x set s.y=y set s.z=z set s.timeout=timeout call TimerStart(s.t, delay, false, function DELFX.Callback) return s endmethod endstruct // The functions below have been explained above. function CreateDelayedEffect takes string path, real x, real y, real delay, real timeout returns nothing call DELFX.Create(path, false, null, "", x, y, 0, delay, timeout) endfunction function CreateDelayedEffectZ takes string path, real x, real y, real z, real delay, real timeout returns nothing call DELFX.Create(path, false, null, "", x, y, z, delay, timeout) endfunction function CreateDelayedEffectTarget takes string path, widget target, string attachmentpoint, real delay, real timeout returns nothing call DELFX.Create(path, true, target, attachmentpoint, 0, 0, 0, delay, timeout) endfunction endlibrary |
| 03-15-2009, 09:48 AM | #2 |
JASS:set d=CreateDestructableZ('OTip', s.x, s.y, s.z, 0,1.,0) set s.fx=AddSpecialEffect(s.path, s.x, s.y) call RemoveDestructable(d) set d=null create some units at map intialization and after use them for the attaching (don't forget to recycle them ;) ) |
| 03-15-2009, 10:42 AM | #3 |
i dont like the operators for the attaching .. really not needed... at all ..just remove the private in front of Data and your done... JASS:
method RegisterOnDestroy takes OnDELFXDestroy func returns nothing
set .onspawntrig=func //shouldnt that be ondestroytrig ? lovely CNP error ;)
endmethod
|
| 03-15-2009, 11:48 AM | #4 |
@Toadcop: I dont see a reason to recreate something Vexorian has already created (xefx). Besides, could you explain to me why exactly (ab)using that destructable bug is that evil? @akolyt0r: Those attaching operators will get inlined. Theres no speed penalty. Thanks for catching that bug...it should be .ondestroytrig, indeed. |
| 03-15-2009, 12:02 PM | #5 |
i know ...but you will have to remember 2 method names that way ... The sense of methods (and operators) is generally ...to make the life for the user easier ... Your two methods dont make it easier ..... your two methods dont achieve that goal... why not just remove that "private" in front of Data, you could still keep your methods if you like them so much ... |
| 03-15-2009, 12:29 PM | #6 | |
Quote:
|
| 03-15-2009, 01:20 PM | #7 |
native SetUnitLookAt takes unit whichUnit, string whichBone, unit lookAtTarget, real offsetX, real offsetY, real offsetZ returns nothing
That makes a unit face another unit instantly. Though i have no clue how to use it. |
| 03-15-2009, 02:34 PM | #8 |
No, it doesn't. Plus it is quite glitched. It moves the a certain bone in the unit's model, but it doesn't do it exactly instantly, a lot of fx models don't have bones. I guess you could make a whole new dummy unit model, but it wouldn't look right, this is the reason the dummy unit model has moved on from just a bone to a lot of animations. |
| 03-15-2009, 02:42 PM | #9 | |
Quote:
|
| 03-17-2009, 11:14 PM | #10 | |
Quote:
i don't see the point of this quote... well sometimes you simply have limited field of view or something. in case... he could allocate dedicated dummys which will allways have the needed facing ? or he could allocate dummys and split them into 45 degree step and pick the needed one and turn it so the turn ill be less than 45 degrees and visualy (with right unit setups) almost not visible. etc and etc. also it's possible to do timeouts on recycle and to reset the facing to the basic one or fill the a group with less dummys (from the other one with more free dummys. the sense is to have enought "pre-turned" units in group) the are allways solutions. you just need no to go the usual way. and as for me i don't bother about the minor visual glicht AND NO GAMER EITHER. the problem with dynamic unit creating the placing alorithms (pathing) is really slow and takes alot time. for comparison it's ~50 times slower than to store a value in gamecache (constant strings) and it's only the placing story not the alocation of new unit instance. aka it takes even more (i don't know how much exactly more so i will not write not proved info) |
| 03-18-2009, 05:07 PM | #11 |
How about a xe-version? Like, a xedelfx library using xefx via delegate? |
| 04-13-2009, 02:27 AM | #12 | |
I liked what I saw up until this point: Quote:
As for the second sentence, that's no way to write proper documentation. |
| 04-13-2009, 03:35 AM | #13 |
Version 1.4.0 Since those two sentences have been removed, give this another try. Edit: Version 1.4.1 |
| 04-18-2009, 12:07 PM | #14 |
Aside from creating effects with a z height, what can DelFX do that Timed Effects can't? |
| 04-18-2009, 12:20 PM | #15 | |
Quote:
SetUnitLookAt works as long as you use it once instead of spamming it. Been doing it to recycle dummy units with attached effects in my physics engine for a long time. |
