1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. The poll for our 11th Music Contest is up! Help us choose the most awesome cinematic tracks by casting a vote!
    Dismiss Notice
  3. Melee Mapping contest #3 - Poll is up! Vote for the best 4v4 melee maps!
    Dismiss Notice
  4. The 30th edition of the Modeling Contest is finally up! The Portable Buildings need your attention, so come along and have a blast!
    Dismiss Notice
  5. The Aftermath has been revealed for the 19th Terraining Contest! Be sure to check out the Results and see what came out of it.
    Dismiss Notice

Spell - Water Explosion 2.0

Submitted by Dark_Dragon
This bundle is marked as approved. It works and satisfies the submission rules.
Spell: Water Explosion - Creates water explosions around caster dealing x damage, depending on spells level.

Changelog


Version 1.1 - Added non-selection trigger for dummy's.

Version 1.2 - Paused timer before destroying it and nulled handle variables.

Version 1.3 - Now Fully MUI and code optimized a bit.

Version 1.3b - Fix whit leeks.

Version 1.3c - Only nulled a bit of variables.

Version 1.3d - In filter function replaced local variable to function GetFilterUnit() as I guess it is a bit of leek when using a variable.

Version 1.4 - Many important fixes, first timer activation area affection fix + first cast lag fix.

Version 1.5 - Uber update which gives this spell mass speed update jass->vjass ofc i don't mean its faster because of vjass it can only be slower in vjass if you don't know how it compiles it in jass however i do know and i can say this is the last update of this spell. Note this spell has no leaks and is completely fast as much as possible!

Version 1.6 Final - Last update improved speed decreased code size and make spell more configurable. It was by request of nerovesper to make it more configurable but i did increase speed a lot more and make code less in size. Its now at top speed and its last update i made for this spell.

Version 1.7 - Was a must update to make it 1.24 compatible! as well code is decreased and fast, using JNGPS.

Version 2.0 - Water Explosion Remasterd
- Totally recoded in zinc
- Fixed bug when units enter "water effect" area just after damage is dealt
- Caster now deals damage
- Fixed bug when caster did not deal damage, thats why dummy was used
Seems like UnitDamageTarget might not deal damage when unit casts/channels spell
- Primarely this is all fixed by adding timed area damage and g_once group which makes sure that units are damaged only once
- Now uses mini library




Code
Code (vJASS):
// -------------------------------------------------------------------------
//                 *** Spell: Water Explosion
//                 *** Autor: Dark Dragon
//
//
// * Requires: JNGP/JassHelper to compile
//
// -------------------------------------------------------------------------
//                      *** Installation ***
//
// * Copy this trigger and DD Library to your map
// * Change '/*' and '*/' to '//' below, then save your map, reopen it and change '//' back to '/*' and '*/' respectively
// * Add water explosion to unit you want and edit below spell data to your needs
// * Enjoy!
// -------------------------------------------------------------------------


// ============================================================================================
// Change me from /* to // and then back to /* after saving and reopening the map
    // |
    // ˇ
      /*
     
// Credits: PurgeandFire for lua tutorial
//! externalblock extension=lua ObjectMerger $FILENAME$
     //! i -- ===================================================
     
     //! i WATER_EXPLOSION_ABIL_ID               = "WTex"
   
     //! i -- ===================================================
   
     //! i setobjecttype("abilities")
     //! i createobject("AHtc", WATER_EXPLOSION_ABIL_ID)
     //! i makechange(current,"anam", "Water Explosion")
     //! i makechange(current,"alev", "5")
     //! i makechange(current,"abpx", "3")
     //! i makechange(current,"arpx", "3")
     //! i makechange(current,"aart", "ReplaceableTextures\\CommandButtons\\BTNCrushingWave.blp")
     //! i makechange(current,"arar", "ReplaceableTextures\\CommandButtons\\BTNCrushingWave.blp")
     //! i makechange(current,"ahky", "W")
     //! i makechange(current,"arhk", "W")
     //! i makechange(current,"acat", nil)
     //! i makechange(current,"aret", "Learn |cff1a8cd0W|rater Explosion - [|cff0080c0Level "..string.char(37).."d|r]")
     //! i makechange(current,"arut", "|cff008040Deals damage in area around caster.|r|n|n|cff0080ffLevel 1|r -|cff80ffff Each explosion deals 70 damage, up to max 500 damage, in 470 aoe|r. |n|cff0080ffLevel 2|r - |cff80ffffEach explosion deals 100 damage, up to max 850 damage, in 470 aoe|r. |cff80ffff|n|r|cff0080ffLevel 3|r -|cff80ffff Each explosion deals 140 damage, up to max 1100 damage, in 610 aoe|r.|cff80ffff|n|r|cff0080ffLevel 4|r -|cff80ffff Each explosion deals 190 damage, up to max 1500 damage, in 610 aoe|r.|cff80ffff|n|r|cff0080ffLevel 5|r -|cff80ffff Each explosion deals 260 damage, up to max 1600 damage, in 610 aoe|r.")
     
     
     //! i local i = 0
     //! i local dmg = { "70", "100", "140", "190", "260" }
     //! i local maxdmg = { "500", "850", "1100", "1500", "1600" }
     //! i local aoe = { "470", "470", "610", "610", "610" }
     //! i for i=1, 5 do
        //! i local si = tostring(i)
        //! i makechange(current,"Htc1",si,"0.")
        //! i makechange(current,"aare",si,"0.")
        //! i makechange(current,"Htc3",si,"0.")
        //! i makechange(current,"Htc4",si,"0.")
        //! i makechange(current,"abuf",si,nil)
        //! i makechange(current,"ahdu",si,".01")
        //! i makechange(current,"adur",si,".01")
        //! i makechange(current,"amcs",si,tostring(100 + 25*i))
        //! i makechange(current,"atp1",si,"|cff1a8cd0W|rater Explosion - [|cffffcc00Level "..si.."|r]")
        //! i makechange(current,"aub1",si,"|cff1a8cd0Deals "..dmg[i].." damage per explosion, up to max "..maxdmg[i].." damage, in "..aoe[i].." aoe.|r")
       
     //! i end
//! endexternalblock

       */

    // ^
    // |
// Change me from */ to // and then back to */ after saving and reopening the map
// ============================================================================================


// -------------------------------------------------------------------------
//                  *** Main WaterExplosion library ***
//! zinc

library WaterExplosion requires DDLib
{

    //********************************************************************************
    //                        Edit following to your wish
    //********************************************************************************

   
    constant integer            WEX_RAWCODE                     = 'WTex';    // Water Explosion
    constant real               EXPLOSION_DELAY                 = .5;        // How often explosions are created (in seconds)
    constant real               EXPLOSION_TIMED_SCAN            = .1;        // Timed scan for units to be damaged
    constant integer            EXPLOSION_TIMED_SCAN_N          = 6;         // How many times to scan for damage deal, explosion duration is thous "EXPLOSION_TIMED_SCAN*EXPLOSION_TIMED_SCAN_N" seconds, this fixes the bug of caster not dealing damage too, no need for dummy
    constant integer            WATER_SHOOTS                    = 2;         // How much water shoots will happen, water sfx shoots
    constant real               INITIAL_EXPLOSION_OFFSET        = 50.;       // Extra offset to NEXT_EXPLOSION_OFFSET, on first water explosion
    constant real               NEXT_EXPLOSION_OFFSET           = 140.;      // How far does each next cycle explosion occure
    constant real               WATER_EXPLOSION_DENSITY         = 160.;      // Smaller numbers mean that explosions are closer together, it means how much of perimiter does it use
    //constant real             EXPLOSION_ENHANCE_PERC          = 120.;      // This is correction of units being picked in percentage of NEXT_EXPLOSION_OFFSET, it means it will alternate area in which units are damaged
    constant boolean            DUMMY_DAMAGE                    = false;     // Does dummy or caster deal damage?
    constant boolean            USE_TEXTTAG                     = true;      // Enable or disable damage display
   
    constant integer            PROJECTILE_N                    = 12;        // Missiles max number
    constant real               PROJECTILE_SIZE                 = 1.3;       // Missiles size
    constant real               PROJECTILE_SPEED                = 750.;      // Missiles speed
    constant real               PROJECTILE_ARC                  = 300.;      // Missiles max reached z
    constant real               PROJECTILE_RANGE                = 575.;      // Missiles max travel distance
    constant real               PROJECTILE_INIT_Z               = 0.;        // Missiles offset z
       
        // This are constant defined effects
    constant string             EXPLOSION_DAMAGE_EFFECT         = "Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveDamage.mdl";
    constant string             WATER_EXPLOSION_EFFECT          = "Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl";
    constant string             MISSILE_EFFECT                  = "Abilities\\Weapons\\WaterElementalMissile\\WaterElementalMissile.mdl";
   
    private keyword waterexp;
   
    // *** Amount of damage dealed per level, if you use more or less than 3 levels, just delete or add additional lines in function below
    function WaterDamage(integer level) -> real {
        real damage[];
       
        // -----------------------------------------
        // *** edit this variables to your will
        damage[1] = 70.;
        damage[2] = 100.;
        damage[3] = 140.;
        damage[4] = 190.;
        damage[5] = 260.;
        // -----------------------------------------
       
        return damage[level];
    }
   
    // *** area of effect, that is max radius that spell will effect
    function WaterAoE(integer level) -> real {
        real aoe[];
       
        // -----------------------------------------
        // *** edit this variables to your will
        // you can use your custom aoe, but this uses n water explosions formula.
        //                                                         ˇˇ
        aoe[1] = INITIAL_EXPLOSION_OFFSET + NEXT_EXPLOSION_OFFSET*(3.);
        aoe[2] = INITIAL_EXPLOSION_OFFSET + NEXT_EXPLOSION_OFFSET*(3.);
        aoe[3] = INITIAL_EXPLOSION_OFFSET + NEXT_EXPLOSION_OFFSET*(4.);
        aoe[4] = INITIAL_EXPLOSION_OFFSET + NEXT_EXPLOSION_OFFSET*(4.);
        aoe[5] = INITIAL_EXPLOSION_OFFSET + NEXT_EXPLOSION_OFFSET*(4.);
        //                                                         ^^
        // -----------------------------------------
       
        return aoe[level];
    }
   
    function WaterMaxDamage(integer level) -> real {
        real max_damage[];
       
        // -----------------------------------------
        // *** edit this variables to your will
        // the max damage spell can deal per cast, use value of -1. to make spell have no limit of damage
        // 
        max_damage[1] = 500.;
        max_damage[2] = 850.;
        max_damage[3] = 1100.;
        max_damage[4] = 1500.;
        max_damage[5] = 1600.;
        //                                                           ^^
        // -----------------------------------------
       
        return max_damage[level];
       
    }
   
    // *** Filtrate units to be damaged
    function DamageFilter(unit filterUnit, player casterOwner) -> boolean {
            return  !IsUnitType(filterUnit, UNIT_TYPE_DEAD)                 &&
                    IsUnitEnemy(filterUnit, casterOwner)                    &&
                    !IsUnitType(filterUnit, UNIT_TYPE_STRUCTURE)            &&
                    !IsUnitType(filterUnit, UNIT_TYPE_MAGIC_IMMUNE)         &&
                    !IsUnitType(filterUnit, UNIT_TYPE_ANCIENT)              &&
                    !IsUnitType(filterUnit, UNIT_TYPE_FLYING)               &&
                    !DDIsUnitWard(filterUnit)                               &&
                    !DDIsUnitInvulnerable(filterUnit);
    }
   
    // ==============================================================================================================
    // *
    // *                            *** Non-Editable code below ***
    // *
    // ==============================================================================================================
   
    // -------------------------------------------
    // * Timed damage data
    struct timdamage {
        real x, y;
        real r;
        unit u;
        real aoe;
        real damage, max_dmg;
        p_real cdmg;
        integer n = 0;
        group g_once;
       
        method destroy() {
            u = null;
            DDRecycleGroup(g_once);
            deallocate();
        }
       
        method DamageTarget(unit target) {
            // *** Alternate the damage? ***
            if (max_dmg != -1.) {
                damage = RMinBJ(damage, max_dmg-cdmg[0]);
                if (GetWidgetLife(target) < damage)
                    damage = GetWidgetLife(target);
                cdmg[0] += damage;
               
                if (cdmg[0] > max_dmg) cdmg[0] = max_dmg;
            }
           
            static if (USE_TEXTTAG)
                if (GetWidgetLife(target) > damage)
                    DDNewTextTagUnit(target, "+"+I2S(R2I(damage)), 4., 10., 90., 88., 20.);
                else
                    DDNewTextTagUnit(target, "+"+I2S(R2I(GetWidgetLife(target))), 4., 10., 90., 88., 20.);
           
            DestroyEffect( AddSpecialEffectTarget(EXPLOSION_DAMAGE_EFFECT, target, "head") );
            UnitDamageTarget(u, target, damage, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_COLD, WEAPON_TYPE_WHOKNOWS);
        }
    }
   
    // ---------------------------------------------------------------------------------------------------------------------
    // *** every x seconds scans if there are units which where not damaged, but explosion animation is still there
    function DamageAoEPeriod(real x, real y, real radius, real aoe, unit damager, real dmg, real max_dmg, p_real pdmg) {
        timdamage td = timdamage.create();
       
        td.x = x;
        td.y = y;
        td.r = radius;
        td.u = damager;
        td.damage = dmg;
        td.aoe = aoe;
        td.max_dmg = max_dmg;
        td.g_once = DDLoadGroup();
        td.cdmg = pdmg;
       
        DDStartTimInst(EXPLOSION_TIMED_SCAN, true, td, function() {
            timdamage td = DDTimData();
            integer i;
           
            // ----------------------------------------------
            // *** fill temp memory with units
            DDGroupFillMemArea(td.x, td.y, RMinBJ(td.r, td.aoe), td, function() -> boolean {
                timdamage td = DDMemUnitData();
                // Target unit has to be between target radius and radius - explosion offset
                return Pw_2(GetUnitX(GetFilterUnit())-td.x) + Pw_2(GetUnitY(GetFilterUnit())-td.y) >= Pw_2(td.r-NEXT_EXPLOSION_OFFSET)          &&
                        !IsUnitInGroup(GetFilterUnit(), td.g_once)                                                                              &&
                        DamageFilter(GetFilterUnit(), GetOwningPlayer(td.u));
            });
           
            // *** Damage enum units ***
            for(i=0; i < DDMemUnitN(); i+=1) {
                // *** Effect and damage to enum units ***
                //BJDebugMsg(GetUnitName(DDMemUnit(i)));
                GroupAddUnit(td.g_once, DDMemUnit(i));
                td.DamageTarget(DDMemUnit(i));
            }
           
            // *** quit scan?
            if (td.n == EXPLOSION_TIMED_SCAN_N || td.cdmg[0] == td.max_dmg) {
                td.destroy();
                DDQuitTim();
            }
           
            //*** Next scan increase ***
            td.n += 1;
        });
    }
   
    //===============================================
    // Do not edit bellow if you don't know jass
    //===============================================
   
    // *** Group of missiles
    type nexus          extends xeffect[PROJECTILE_N];
   
    //--------------------------------------------------
    // *** WaterExplosion main struct ***
    struct waterexp {
        // Objects
        unit        caster;
        unit        dummy;
        integer     level;
        integer     shoots;
        real        radius;
        p_real      pdmg;
        real        max_dmg;
        player      owner;
        real        x, y;
        group       g_once;
       
       
        // ------------------------------------------
        //              # Methodes
        // ------------------------------------------
       
        // ------------------------------------------
        //     *** Write constructor ***
        static method create() -> waterexp {
            waterexp this = allocate();
           
            // *** Assign members ***
            this.caster         = GetTriggerUnit();
            this.owner          = GetOwningPlayer(this.caster);
            this.level          = GetUnitAbilityLevel(this.caster, WEX_RAWCODE);
            this.radius         = INITIAL_EXPLOSION_OFFSET;
            this.x              = GetUnitX(this.caster);
            this.y              = GetUnitY(this.caster);
            this.shoots         = 0;
            this.pdmg           = New_pReal(0.);
            this.max_dmg        = WaterMaxDamage(level);
           
            static if (DUMMY_DAMAGE) {
                this.dummy = DDLoadDummy();
                SetUnitOwner(dummy, owner, false);
            }
           
            return (this);
        }
       
       
       
        // ------------------------------------------
        //     *** Write destructor ***
        method destroy() {
            DDStartTim(EXPLOSION_TIMED_SCAN*EXPLOSION_TIMED_SCAN_N, false, this, function() {
                thistype this = DDTimData();
               
                static if (DUMMY_DAMAGE)
                    DDRecycleDummy(this.dummy);
               
                static if (USE_TEXTTAG)
                    DDNewTextTagUnit(caster, I2S(R2I(pdmg[0]))+" damage dealt!", 5., 27., 84., 10., 20.);
               
                this.pdmg.destroy();
                this.caster = null;
                deallocate();
               
                DDQuitTim();
            });
           
        }
    }

    //===========================================================================
   
    // *** Calculates missile z motion, default elliptical motion
    function MissileZ(real range) -> real {
        return SquareRoot( Pw_2(PROJECTILE_ARC) * (1. - Pw_2( -1. + (2.*range/PROJECTILE_RANGE) )) );
    }
   
    //===========================================================================
    //               **** Init water expl ****
    //===========================================================================
    function onInit() {
        trigger t = CreateTrigger();
        TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT);
        TriggerAddCondition(t, Condition(function() -> boolean {
            // Main Condition
            if (GetSpellAbilityId() != WEX_RAWCODE)
                // *** Skip remainig code
                return false;
           
            //ClearTextMessages();
            // *** Condition passed
            DDStartTimInst(EXPLOSION_DELAY, true, waterexp.create(), function() {
                // -------------------------------------
                // *** locals ***
                waterexp we = DDTimData();
                integer i, max_i;
                real rad;
                p_integer pi;
                p_real pr;
                // -------------------------------------
               
                // ================================================================================================
                //                          *** Load water shoots ***
                // ================================================================================================
                if ( we.shoots < WATER_SHOOTS ) {
                    // *** Allocate dynamic array ***
                    pi                  = p_integer.create();
                    pi[0]               = nexus.create(); // Missiles
                    pi[1]               = p_real.create(); // ptr
                    p_real(pi[1])[0]    = 0.; // Missile range/distance
                   
                    // *** Increase shoots ***
                    we.shoots += 1;
                   
                    // *** Add enum graphics ***
                    for(i=0; i < nexus.size; i+=1) {
                        // *** Do calcs ***
                        rad = i*(2.*bj_PI/PROJECTILE_N);
                        // *** Add missiles ***
                        nexus(pi[0])[i] = xeffect.create(MISSILE_EFFECT, we.x + we.radius * Cos(rad), we.y + we.radius * Sin(rad), rad*bj_RADTODEG, PROJECTILE_SIZE);
                    }
                   
                    // ------------------------------------------------------------
                    // *** Missile motion
                    DDStartTim(DD_INTERVAL, true, pi, function() {
                        p_integer pi = DDTimData();
                        nexus n = pi[0];
                        real range, wz;
                        integer i;
                       
                        // *** vars change apply ***
                        p_real(pi[1])[0] += DD_INTERVAL*PROJECTILE_SPEED;
                        range = p_real(pi[1])[0];
                       
                        // *** check if we still have a way to go ***
                        if (range < PROJECTILE_RANGE) {
                            // *** Do the loop and move missiles
                            for(i=0; i < nexus.size; i+=1) {
                                wz = n[i].WZ;
                                n[i].X += DD_INTERVAL*PROJECTILE_SPEED * Cos(i*(2.*bj_PI/PROJECTILE_N));
                                n[i].Y += DD_INTERVAL*PROJECTILE_SPEED * Sin(i*(2.*bj_PI/PROJECTILE_N));
                                n[i].Z = (wz-n[i].WZ) + PROJECTILE_INIT_Z + MissileZ(range);
                            }
                           
                        } else {
                            // *** Clear missiles and end motion ***
                            for(i=0; i < nexus.size; i+=1)
                                n[i].destroy();
                            n.destroy();
                            p_real(pi[1]).destroy();
                            pi.destroy();
                            DDQuitTim();
                        }
                    });
                }
                // ================================================================================================
                //                          *** End Water Shoots ***
                // ================================================================================================
               
               
                // ================================================================================================
                //                          *** Start Damage and explosions ***
                // ================================================================================================
               
                // ***
                // *** Increase distance
                // ***
                we.radius += NEXT_EXPLOSION_OFFSET;
                max_i = R2I(2.*we.radius*bj_PI / WATER_EXPLOSION_DENSITY);
               
                // -------------------------------------------
                // Loop ( loads water explosion effects )
                for(i=0; i < max_i; i+=1) {
                    rad = (i * 2.*bj_PI) / max_i;
                    DestroyEffect( AddSpecialEffect(WATER_EXPLOSION_EFFECT,
                                                    we.x + we.radius * Cos( rad ),
                                                    we.y + we.radius * Sin( rad )) );
                }
                // *** Start periodic scan for damage
                static if (DUMMY_DAMAGE)
                    DamageAoEPeriod(we.x, we.y, we.radius, WaterAoE(we.level), we.dummy, WaterDamage(we.level), we.max_dmg, we.pdmg);
                else
                    DamageAoEPeriod(we.x, we.y, we.radius, WaterAoE(we.level), we.caster, WaterDamage(we.level), we.max_dmg, we.pdmg);
               
                // ===========================================
                // * End when distance is out of area
                if (we.radius+1. >= WaterAoE(we.level)) {
                    we.destroy();
                    DDQuitTim();
                }
               
                // ===============================
                // ---- End main timer ------
                // ===============================
            });
           
            return false; // End Trigger condition
        }));
       
        // End onInit
    }

}

//! endzinc

 


If you have any future questions ask here.
Have Fun!

~Dark Dragon


Keywords:
Water, Explosion, Spells, any, other, DD, wave, nova
Contents

Spell - Water Explosion (Map)

Reviews
Moderator
Diablo-dk: [Approved] The spell is MUI and works fine ingame.
  1. Diablo-dk: [Approved]
    The spell is MUI and works fine ingame.
     
  2. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    588
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    I used constant functions all ready so I don't understand what should I do more, if you think that when I use globals whit no array that its not MUI that is not true because if you look better this variables are used in instant actions. Not sure is it fully MUI but MPI is for sure that is enough if its a hero spell right?

    Now I know I am not so good but I am still learning jass and how to code a good spell or anything, ty for teaching me about PauseTimer did not know it must be used before destroying it.
     
  3. Diablo-dk

    Diablo-dk

    Joined:
    Nov 10, 2004
    Messages:
    369
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    According to the rules, a JASS spell must be fully MUI. Take a look at KaTTaNa's local handle variables system, which is great at making MUI Jass spells. http://www.wc3jass.com/viewtopic.php?t=224

    I didn't say it had anything about the spell being MUI. It was a suggestion, so you don't have to follow it, since i do understand why you used globals.

    Make the spell fully MUI and null the handle variables, then i'll approve it. (If you don't know what nulling handle variables means, search for a jass tutorial. I'm sure you can find an answer there)
     
  4. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    588
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    ok I will try this

    Edit: Ok its updated now its MUI whit no handle local variables system as no one could find the problem
     
  5. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    Simple improvements

    The first, I noticed you used degrees for the angle, as this makes it very easy to write the code, it is almost always more efficient to use radians, I studied your code a bit, and every single time WE needs to loop, it needs to make those unnecessary bj_DEGTORAD calculations

    The second, your system to retrieve timer data is good, but I don't see anywhere that you nulled/cleared the timer data global for finished timers, your system would be very good, but it will keep looping through all of your un-used timers every time you retrieve the data, which you do every time the timer expires, almost like putting a loop inside a loop

    Either get a different system that doesn't need to loop, or just make sure you clear + null the variables so the system doesn't need to loop through 200 expired timers your not even using

    These are both pretty minor, but will definitely improve your code


    [For the timer data system, if you'd like a guage on how mcuh better a loopless system would be, those systems only loop once, so if your system only looped once it would be slightly more efficient (less if/thens), but every time it needs to loop, it becomes that many more times slower, in other words if you have 50 timers stored in the data, your system would be 50x slower than a loopless(give or take 5x due to if/thens)]
     
  6. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    588
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    Hi Herman!

    Well its nice you got a look in a spell so lets start to explain things out ^^.

    1. Using bj_DEGTORAD is much faster then any other conversion as its a global already calculated constant in blizzard.j Its always much better to use constants as they are very fast.

    2. There is only one timer per cast which gets destroyed very fast, as function ClearUserTimerData( timer whichTimer, boolean destroy ) so I don't need to do manual destroy. Note that only one timer loops the spell function, and gets soon destroyed.

    3. The system of timer data which you say are lot, well as I explained there are timers equal to instant spell casting times. So if 3 players cast spell at same time there will be 3 timers (3 loops) btw jass if/then is fast GUI one creates function which is slow but in jass thats not a problem.

    4. Thanks for commenting!

    Edit: Lol sorry when I started to make this spell I made it MPI and then I waste my time on why Handle Locals dont work for me, in that time I forget to make ClearTimerData, thanks now its fixed.
     
  7. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    What I ment with the DEGTORAD, was that you should use the RADTODEG function, and just calculate in radians (one of the things that will cost you more time, but will improve your code)

    If you don't need/want to do that (or don't know how) it's ok, its a pretty minor thing, should be kept in mind for big systems though

    Yeah, I wasn't sure about the timers getting destroyed, it would only be slower if the timers were not removed, but I *think* you said you did

    The timer thing is very very efficient way of doing if everything is used properly (I might even switch over to it, because I only ever put handlevars on timers)

    Great job !!! :D
     
  8. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    588
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    You were right as I sad I did not destroy timers before I mean I did but did not clear the stored data on timer that was a leak but now its fixed. Only one thing about RADTODEG and DEGTORAD this are not the functions they are global constant variables and its same to say:

    set var = 2*3
    or
    set var = 2 * bj_DEGTORAD

    look:

    constant real bj_DEGTORAD = bj_PI / 180.
    constant real bj_RADTODEG = 180. / bj_PI

    where bj_PI is:

    constant real bj_PI = 3.14159

    So only for your info, it does not matter which one you use they are the same its like you use:

    set var = 2/4
    set var2 = 4/2

    it does not rely matter, note I only tried to explain you, this is for sure same thing as you can find them in blizzard.j dont tread this as function for conversion this is only a constant global variable.

    I guess I explained it well, once more ty for comment.
     
  9. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    sorry I keep referring to it as a function, but yeah I udnerstand what you mean by the calculations, what I'm saying is inside your actual code you need to constantly flip between radians and degrees, because most of the functions take measurements in radians or return in radians

    Although there are a select few that take degrees (like unit facing)
     
  10. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    588
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    Well I guess I explained it well so you now understand that its same do you want to work in RAD or DEG just 1 deg = PI / 180. or 180 deg = PI just what you like to work whit its your same but as its simple to work whit deg so I used deg. If you like more RAD then DEG you can always work in RAD, I just wanted to tell you its same about speed.
     
  11. eWs.Azure

    eWs.Azure

    Joined:
    Apr 1, 2008
    Messages:
    23
    Resources:
    0
    Resources:
    0
    looks awesome :D very nice done
     
  12. Sacredmage

    Sacredmage

    Joined:
    Sep 30, 2007
    Messages:
    20
    Resources:
    0
    Resources:
    0
    you have to make the dummies unattackable, the mobs attacked the water beams that fly out when you cast it...
     
  13. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    588
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    they are used for attack effect and cant be untouchable but they are soon removed and there selection hight is 2^11 which cant be seen, and I guess I did something more but not sure: nothing you need to worry!
     
  14. Dragzor

    Dragzor

    Joined:
    May 11, 2008
    Messages:
    1
    Resources:
    0
    Resources:
    0
    How The Fuck U Make This Work
     
  15. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    588
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    Hmm...
    1) Plz turn off the caps lock
    2) You need to tell me exactly what is wrong!
    - Like do you have problems importing it in your map or you want to make spell like that and you don't know how, or is it something else like you don't know JASS or something.

    If so then just copy trigger in your map as well as units and ability. Now check which raw codes are used in your map for units and abilities and then simple edit code when you see 'e000' - this is a raw code edit it to match your map.

    Good luck, if you cant make it work I may be able to import it for you, if you send me your map.
     
  16. DushanS94

    DushanS94

    Joined:
    May 26, 2008
    Messages:
    6
    Resources:
    0
    Resources:
    0
    Hey can someone import this spell into my map and send it to me because i am either stupid or something else is wrong, because i did everything the script asks even the custom raw codes, and when I save the map i get tons of PJass errors + i cant open the map in Frozen Throne. Please help me, this spell is very important for my map, of course both Dark_Dragon and the person who helps me will get full credit. :)
     
  17. Kazemaru

    Kazemaru

    Joined:
    May 27, 2008
    Messages:
    55
    Resources:
    0
    Resources:
    0
    Hi! I saw your spell and it was awesome! But i need help to one spell: I want to make &quot;Posession&quot; (banshees 3lvl ulti) Spell like but I want that Unit/Hero who casted Posession has able to come out from Controlled unit/hero and Controlled unit will come back to its original team. Can you please make that spell? please =)
     
  18. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    588
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    Kazemaru here is the spell you requested: http://www.hiveworkshop.com/resources_new/spells/1422
     
  19. Dethekkus

    Dethekkus

    Joined:
    May 26, 2008
    Messages:
    28
    Resources:
    0
    Resources:
    0
    Looks good.