Wc3C.net

Wc3C.net (http://www.wc3c.net/forums.php)
-   vJass Spells (http://www.wc3c.net/forumdisplay.php?f=647)
-   -   Live Distortion & Mind Burst (http://www.wc3c.net/showthread.php?t=105524)

JonNny 04-16-2009 10:47 PM

Live Distortion & Mind Burst
 
2 Attachment(s)
Quote:

Originally Posted by Live Distortion
Sends out souls which will steal healthpoints and leave a debuff on the target. When returning they heal the caster depending on the dealt damage.
Rank 1 - sends out 6 souls which deal 40 dmg and heal for 30%
Rank 2 - sends out 9 souls which deal 55 dmg and heal for 40%
Rank 3 - sends out 12 souls which deal 70 dmg and heal for 50%


Quote:

Originally Posted by Mind Burst
Sends out two concentrated essences which will move in the target direction. On hit they deal damage, leave a mana draining debuff and if the target has mana it will also transfer a bit of it directly to the caster. Range Increases per level.
Rank 1 - 50 damage, 55 mana debuff, steals 10 mana directly
Rank 2 - 50 damage, 55 mana debuff, steals 15 mana directly
Rank 3 - 90 damage, 100 mana debuff, steals 20 mana directly



changelog

Update: v1.01
-made functions constant
-improved documention
-removed leaks in the init function
-other minor improvements of the script
-added that missiles grow after stealing hp

Update: v1.02
-changed SetUnitState to SetWidgetLife
-removed all bj_DEGTORAD as wanted

Update: v1.03
-minor bugfix due the remove of bj_DEGTORAD

Update : LD v1.04
-optimizing

+added Mind Burst v1.00

updated LD 1.06 , MB v1.02
-improved general scripting
-added GroupUtils
-made various changes
-reworked cofiguration block

updated LD 1.07 , MB 1.03
-made globals constant
-changed filter and removed NullFilter

updated LD 1.08 , MB 1.04
-removed dynamic dummy usage
-changed other small things

updated LD 1.08b, MB 1.04b
-removed Group Utilities due the patch
-made it 1.24 compatible



Expand Live Distortion code:

Expand Mind Burst code:

TriggerHappy 04-16-2009 11:34 PM

Collapse JASS:
call SetUnitState(data.Caster,UNIT_STATE_LIFE,GetUnitState(data.Caster,UNIT_STATE_LIFE)+PercentageHealPerLevel(data.level) * data.StolenHealth)

Use Get/SetWidgetLife, it's easier to use and it's faster.

Collapse JASS:
            set e = AddSpecialEffectTarget(HealSpecialeffect, data.Caster, "origin")
            call DestroyEffect(e)

Can be inlined.

Also, upload a demo map.

darkwulfv 04-17-2009 04:38 AM

Quote:

Can be inlined.

Not necessarily. If the ability has a death animation that isn't the same as its birth/stand animation, you could get an unwanted (or nonexistant) result.

Or is that code straight out of what he posted? If so, then you're right, it should be inlined.

akolyt0r 04-17-2009 08:41 AM

please use radians everywhere, when you create your essences / in the callback..
And i think aswell that effect should be inlined..

Dark_Dragon 04-17-2009 09:03 AM

Use Get/SetWidgetLife is slower since it must check what it must do item, unit, destructable to who and how to change a life since in c++ we have classes of unit, destructable and item...

setunitstate knows that it will apply something to unit and in fact getwidgetlife and getunitstate are different getunitstate is a constant native...

and inlining means do not call function but use its actions directly and storing value in local and then destroying it is not a problem its of same speed exept you have to null that local effect but i think he did that so no leaks...

JonNny 04-17-2009 11:09 AM

Quote:

Originally Posted by TriggerHappy187
Collapse JASS:
            set e = AddSpecialEffectTarget(HealSpecialeffect, data.Caster, "origin")
            call DestroyEffect(e)

Can be inlined.

Also, upload a demo map.


Updated, fixed various things and also inlined this
There was already a demo map attached

Quote:

Originally Posted by akolyt0r
please use radians everywhere, when you create your essences / in the callback

Do you mean using 0.017453 instead of bj_DEGTORAD) ?

Else, i dont know what is faster. SetWidgetLife or GetUnitState but to be honest i dont care if my script could a nanosecond faster or not...

akolyt0r 04-17-2009 11:24 AM

Quote:

Originally Posted by JonNny
Do you mean using 0.017453 instead of bj_DEGTORAD) ?

no, just use radians directly...
example:
Collapse JASS:
local real angstep = 2*bj_PI / I2R(EssencesAmount) //2*PI (radians) == 360 (degrees)
//...
    loop 
            exitwhen a > EssencesAmount
            // Creating the missiles here
            set angle = angstep * I2R(a)
            set Essences.Data[Essences.Index-1].angle[a] = angle
            set Essences.Data[Essences.Index-1].EssenceDummy[a] = CreateUnit(GetOwningPlayer(caster), DummyID , x + ReleaseDistance * Cos(angle),y + ReleaseDistance * Sin(angle) , angle)
            set Essences.Data[Essences.Index-1].DamagedUnits[a] = CreateGroup()
            set Essences.Data[Essences.Index-1].MissileScale[a] = MissileStartScale
            set a = a + 1
    endloop
of course you have to change the rest of the code (callback function) aswell, to get rid of all those bj_DEGTORAD

JonNny 04-17-2009 11:02 PM

Quote:

Originally Posted by akolyt0r
no, just use radians directly...
example:
Collapse JASS:
local real angstep = 2*bj_PI / I2R(EssencesAmount) //2*PI (radians) == 360 (degrees)
//...
    loop 
            exitwhen a > EssencesAmount
            // Creating the missiles here
            set angle = angstep * I2R(a)
            set Essences.Data[Essences.Index-1].angle[a] = angle
            set Essences.Data[Essences.Index-1].EssenceDummy[a] = CreateUnit(GetOwningPlayer(caster), DummyID , x + ReleaseDistance * Cos(angle),y + ReleaseDistance * Sin(angle) , angle)
            set Essences.Data[Essences.Index-1].DamagedUnits[a] = CreateGroup()
            set Essences.Data[Essences.Index-1].MissileScale[a] = MissileStartScale
            set a = a + 1
    endloop
of course you have to change the rest of the code (callback function) aswell, to get rid of all those bj_DEGTORAD


shouldnt be that hard to change
but is it really that faster ? whats the problem with bj_DEGTORAD?

darkwulfv 04-17-2009 11:23 PM

Using Get/SetWidgetLife may improve speed by nanoseconds or might slow it by nanoseconds, but it'll look a little neater.

akolyt0r 04-18-2009 05:34 AM

Quote:

Originally Posted by JonNny
shouldnt be that hard to change
but is it really that faster ? whats the problem with bj_DEGTORAD?

its faster, and there is no reason what'so ever to use bj_DEGTORAD ...except when working with facing of unit as Get/SetUnitFacing are the only natives that take degrees and not radians...

TriggerHappy 04-19-2009 02:32 AM

Quote:

Originally Posted by Dark_Dragon
Use Get/SetWidgetLife is slower since it must check what it must do item, unit, destructable to who and how to change a life since in c++ we have classes of unit, destructable and item...

setunitstate knows that it will apply something to unit and in fact getwidgetlife and getunitstate are different getunitstate is a constant native...

and inlining means do not call function but use its actions directly and storing value in local and then destroying it is not a problem its of same speed exept you have to null that local effect but i think he did that so no leaks...


Get widget life has been tested, and is faster.

Just because you assume what goes on in the backend, doesn't make it true.

JonNny 04-19-2009 12:50 PM

Hmm... kk
changed SetWhidgedLive and the radians

JonNny 04-23-2009 05:09 PM

bump

updated , fixed some minor things and fixed some thing i forgot to change after removing the bj_DEGTORAD

Is there anything else improveable in this script?

akolyt0r 04-23-2009 07:20 PM

- dont use GroupEnumUnitsInRangeOfLoc, use GroupEnumUnitsInRange instead, so you can get rid of that location.

- And private constant function EssencesRangePerLevel takes real level returns real ... this function should take integer level not real...
- use bj_PI for all places where you use Pi

Optional:
- use TriggerRegisterAnyUnitEvent, you can totally use this BJ !

JonNny 04-24-2009 10:38 AM

:) updated

also added a second spell, originally they were supposed to be Synenergy , ill add some interactivity later


All times are GMT. The time now is 09:36 PM.

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services