1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. The 15th Mini-Mapping Contest came to an end. The Secrets of Warcraft 3 are soon to be revealed! Come and vote in the public poll for your favorite maps.
    Dismiss Notice
  4. The 12th incarnation of the Music Contest is LIVE! The theme is Synthwave. Knight Rider needs a song to listen to on his journey. You should definitely have some fun with this theme!
    Dismiss Notice
  5. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Beacon

Submitted by Ciebron
This bundle is marked as approved. It works and satisfies the submission rules.
Beacon by Ciebron 1.0

I know THW dont accept zinc but i made this spell to try it out and it was great :)

Beacon is a mix between damage and healing
When cast it will check the units around the hero if they are an enemy or ally

If there are mostly friendlys it will heal the ally with lowest hp in range

If there are mostly enemys it will damage the the target with least health

If there are equally ally and enemys it will heal

This spell where mostly made cause i wanted too try zinc
Which i enjoy more then Jass since it more flexible


Enjoy

Code

Code (vJASS):
//! zinc
/***************************************************************************************************/
/* Beacon by 'Ciebron' v1.0 ************************************************************************/
/***************************************************************************************************/
/***************************************************************************************************/
/***************************************************************************************************/
/* Beacon is a mix between damage and healing ******************************************************/
/* When cast it will check the units around the hero if they are an enemy or ally ******************/
/* If there are mostly friendlys it will heal the ally with lowest hp in range *********************/
/* If there are mostly enemys it will damage the the target with least health **********************/
/* If there are equally ally and enemys it will heal ***********************************************/
/***************************************************************************************************/
/* This spell where mostly made cause i wanted too try zinc ****************************************/
/* Which i enjoy more then Jass since it more flexible *********************************************/
/* Enjoy *******************************************************************************************/
/***************************************************************************************************/
    library Beacon requires TimerUtils, Table
    {
   
        private
        {
            /* RawCode of the spell */
            constant integer Abil_Id = 'A000';
           
            /* How many levels the spell have (you need to setup them in the setup function if you add more) */
            constant integer Levels = 3;
           
            /* Effect on the hero when he heals */
            constant string HealSfx = "Abilities\\Spells\\NightElf\\Rejuvenation\\RejuvenationTarget.mdl";
           
            /* Effect on the hero when he damages */
            constant string DmgSfx = "war3mapImported\\GrudgeAura.mdx";
           
            /* Effect on the targets of the heal */
            constant string HealHitSfx = "Abilities\\Spells\\Items\\ResourceItems\\ResourceEffectTarget.mdl";
           
            /* Effect on the targets when it damages */
            constant string DmgHitSfx = "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl";
           
            /* Where on the caster the heal effect will attach */
            constant string HealAttachPoint = "overhead";
           
            /* Where on the caster the dmg effect will attach */
            constant string DmgAttachPoint = "origin";
           
            /* Damagetype it will deal (Duh!) */
            constant damagetype DamageType = DAMAGE_TYPE_MAGIC;
           
            /* AttackType it will deal */
            constant attacktype AttackType = ATTACK_TYPE_MAGIC;
           
           
            /* Dont touch these if you dont know what you are doing */
            real Amount[Levels], Radius[Levels], Interval[Levels];
            integer Count[Levels];
        }
   
        function Setup()
        {
            /* Amount it will heal and damage */
            Amount[1] = 35;
            Amount[2] = 50;
            Amount[3] = 65;
           
            /* The radius it will heal and damage in */
            Radius[1] = 450;
            Radius[2] = 500;
            Radius[3] = 550;
           
            /* How often it will heal or damage */
            Interval[1] = 0.75;
            Interval[2] = 0.65;
            Interval[3] = 0.55;
           
            /* how many times it will damage or heal before it ends */
            Count[1] = 12;
            Count[2] = 15;
            Count[3] = 20;
        }
        /* Below this line its the filterfunction for the units it will effect */
       
        /* This filter check when the spell is cast (when check how many enemys and friendlys there are */
        function Match() -> boolean
        {
            unit f = GetFilterUnit();
            unit t = GetTriggerUnit();
           
            boolean ok = f != t && ! IsUnitType(f,UNIT_TYPE_STRUCTURE);
           
            f = null;
            t = null;
            return ok;
        }
       
        /* This filter check which units too heal */
        function HealMatch() -> boolean
        {
            unit f = GetFilterUnit();
            Data this = Dat;
           
            boolean ok = GetWidgetLife(f) > .305 && IsUnitAlly(f,this.Player) && ! IsUnitType(f,UNIT_TYPE_MAGIC_IMMUNE) && ! IsUnitType(f,UNIT_TYPE_STRUCTURE) && GetWidgetLife(f) != GetUnitState(f,UNIT_STATE_MAX_LIFE);
           
            f = null;
            return ok;
        }
       
        /* This filter check which units too damage */
        function DmgMatch() -> boolean
        {
            unit f = GetFilterUnit();
            Data this = Dat;
           
            boolean ok = GetWidgetLife(f) > .305 && IsUnitEnemy(f,this.Player) && ! IsUnitType(f,UNIT_TYPE_MAGIC_IMMUNE) && ! IsUnitType(f,UNIT_TYPE_STRUCTURE);
           
            f = null;
            return ok;
        }
       
        /***************************************/
        /******* Here does the Setup end *******/
        /***************************************/
       
        private
        {
            boolexpr Bool, HealBool, DmgBool;
            integer Enemy_Count, Friendly_Count;
            player Player_Pass;
            unit TempU, TempLow;
            real TempR, TempRLow;
            Data Dat;
            HandleTable Table;
        }
       
        private struct Data
        {
            unit caster;
           
            integer lvl, count;
                       
            effect Sfx;
           
            player Player;
           
            timer Timer;
           
            static group Grp = CreateGroup();
           
            static method create(unit u) -> thistype
            {
                thistype this = thistype.allocate();
               
                this.caster = u;
                this.Player = GetOwningPlayer(this.caster);
                this.lvl = GetUnitAbilityLevel(this.caster,Abil_Id);
                this.Timer = CreateTimer();
                this.count = Count[this.lvl];

                GroupEnumUnitsInRange(Grp,GetUnitX(this.caster),GetUnitY(this.caster),Radius[this.lvl],Bool);
               
                Player_Pass = this.Player;
                Enemy_Count = 0;
                Friendly_Count = 0;
               
                /* Kinde droped my jaw when i figured out this, so easy to read then ^^ */
                ForGroup(Grp,function()
                {
               
                    if (IsUnitEnemy(GetEnumUnit(),Player_Pass))
                    {
                        Enemy_Count = Enemy_Count + 1;
                    }
                    else
                    {
                        Friendly_Count = Friendly_Count + 1;
                    }
                   
                } );
               
                SetTimerData(this.Timer,this);
               
                if (Friendly_Count >= Enemy_Count)
                {
                    TimerStart(this.Timer,Interval[this.lvl],true,function thistype.HealLoop);
                   
                    this.Sfx = AddSpecialEffectTarget(HealSfx,this.caster,HealAttachPoint);
                }
                else
                {
                    TimerStart(this.Timer,Interval[this.lvl],true,function thistype.DmgLoop);
                   
                    this.Sfx = AddSpecialEffectTarget(DmgSfx,this.caster,DmgAttachPoint);
                }
               
                Table[this.caster] = this;
               
                return this;
            }
           
            static method HealLoop()
            {
                timer Timer = GetExpiredTimer();
                thistype this = GetTimerData(Timer);
               
                Dat = this;
               
                GroupEnumUnitsInRange(Grp,GetUnitX(this.caster),GetUnitY(this.caster),Radius[this.lvl],HealBool);
               
                TempLow = FirstOfGroup(Grp);
                TempRLow = GetWidgetLife(TempLow);
               
                ForGroup(Grp,function()
                {
                    unit Enum = GetEnumUnit();
                   
                    TempR = GetWidgetLife(Enum);
                   
                    if (TempR < TempRLow)
                    {
                        TempRLow = TempR;
                        TempLow = Enum;
                    }
                   
                    Enum = null;
                   
                });
               
                SetWidgetLife(TempLow,GetWidgetLife(TempLow)+Amount[this.lvl]);
                DestroyEffect(AddSpecialEffectTarget(HealHitSfx,TempLow,"origin"));

                this.count = this.count - 1;
               
                if (this.count <= 0)
                {
                    this.destroy();
                }
            }
           
            static method DmgLoop()
            {
                timer Timer = GetExpiredTimer();
                thistype this = GetTimerData(Timer);
               
                Dat = this;
               
                GroupEnumUnitsInRange(Grp,GetUnitX(this.caster),GetUnitY(this.caster),Radius[this.lvl],DmgBool);
               
                TempLow = FirstOfGroup(Grp);
                TempRLow = GetWidgetLife(TempLow);
               
                ForGroup(Grp,function()
                {
                    unit Enum = GetEnumUnit();
                   
                    TempR = GetWidgetLife(Enum);
                   
                    if (TempR < TempRLow)
                    {
                        TempRLow = TempR;
                        TempLow = Enum;
                    }
                   
                    Enum = null;
                   
                });
               
                UnitDamageTarget(this.caster,TempLow,Amount[this.lvl],false,false,AttackType,DamageType,null);
                DestroyEffect(AddSpecialEffectTarget(DmgHitSfx,TempLow,"origin"));

                this.count = this.count - 1;
               
                if (this.count <= 0)
                {
                    this.destroy();
                }
            }
           
            method onDestroy()
            {
                DestroyEffect(this.Sfx);
                PauseTimer(this.Timer);
                DestroyTimer(this.Timer);
               
                Table.flush(this.caster);
            }
        }
       
        function OnCast() -> boolean
        {
            Data this;
            unit caster;
           
            if (GetSpellAbilityId()==Abil_Id)
            {
                caster = GetTriggerUnit();
               
                if (Table.exists(caster))
                {
                    this = Table[caster];
                    this.destroy();
                }
               
                Data.create(caster);
               
                caster = null;
            }
           
            return false;
        }
       
        function onInit()
        {
            trigger trig = CreateTrigger();
           
            TriggerAddCondition(trig,Condition(function OnCast));
            TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_SPELL_EFFECT);
           
            Bool = Filter(function Match);
            DmgBool = Filter(function DmgMatch);
            HealBool = Filter(function HealMatch);
           
            static if(LIBRARY_Table)
            {
                Table = HandleTable.create();
            }
            Setup();
        }
    }
//! endzinc




History


*1.0: First Release



Keywords:
Damage, Heal, Healing, Aoe, Area of effect
Contents

Just another Warcraft III map (Map)

Reviews
Moderator
19:19, 4th Jan 2010 The_Reborn_Devil: The code looks good, but boolean ok = GetWidgetLife(f) > .305 ... should be boolean ok = GetWidgetLife(f) > 0.405 or boolean ok = UnitAlive(f) :D Status: Approved Rating: Useful
  1. 19:19, 4th Jan 2010
    The_Reborn_Devil:
    The code looks good, but
    boolean ok = GetWidgetLife(f) > .305 ...

    should be
    boolean ok = GetWidgetLife(f) > 0.405


    or
    boolean ok = UnitAlive(f)

    :D

    Status: Approved
    Rating: Useful
     
  2. Vengeancekael

    Vengeancekael

    Joined:
    Aug 11, 2009
    Messages:
    5,747
    Resources:
    16
    Tools:
    1
    Maps:
    13
    Spells:
    1
    StarCraft II Resources:
    1
    Resources:
    16
    What's that?
    You mean History.
     
  3. takakenji

    takakenji

    Joined:
    Jul 7, 2008
    Messages:
    3,417
    Resources:
    27
    Models:
    23
    Icons:
    4
    Resources:
    27
    zinc is a new language, i believe its similar to cjass but i know little of it
     
  4. Coolty44

    Coolty44

    Joined:
    Dec 10, 2008
    Messages:
    576
    Resources:
    1
    Spells:
    1
    Resources:
    1
    ZINC stands for Zinc Is Not C, another script made by Vex, I do belive
     
  5. Ciebron

    Ciebron

    Joined:
    Apr 6, 2008
    Messages:
    760
    Resources:
    2
    Spells:
    2
    Resources:
    2
    Correct :)

    Btw if anyone have some idea for the effects. i be glad to hear it. since i think they suck
     
  6. MortAr

    MortAr

    Joined:
    Feb 25, 2009
    Messages:
    1,768
    Resources:
    7
    Icons:
    6
    Packs:
    1
    Resources:
    7
    Since TWH doesn't accept ZINC it won't be approved, then why don't put it in "Triggers & Scripts" and see the comments there?
     
  7. Ciebron

    Ciebron

    Joined:
    Apr 6, 2008
    Messages:
    760
    Resources:
    2
    Spells:
    2
    Resources:
    2
    Didnt think of that but well i've allready done it
     
  8. YourNameHere

    YourNameHere

    Joined:
    Apr 29, 2007
    Messages:
    745
    Resources:
    4
    Maps:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    4
    Convert it to vJass? Iirc JassHelper has a commandline for doing so with .zinc files ore something like that.
     
  9. Element of Water

    Element of Water

    Joined:
    Aug 3, 2008
    Messages:
    2,298
    Resources:
    5
    Spells:
    3
    Tutorials:
    1
    JASS:
    1
    Resources:
    5