[vJASS] Re`ammin's Child

sojocu4
Registered users
Registered users
Posts: 13
Joined: Sat Nov 30, 2019 1:30 am
Reputation: 0
Location: Perrelos,Carcar City,Cebu,Philippines,Asia,Earth,Milkyway
Contact:
Philippines

[vJASS] Re`ammin's Child

#1

Post by sojocu4 » Sun Jan 12, 2020 7:10 pm

Re'ammin's Child

Credits
Models
-Vexorian
Requires
-dummy.mdx
Changelogs
v1.0.0
-release
v1.0.1
-Reduce Lightning Create/Destroy
-Conflexing Index XD

Code: Select all

native UnitAlive takes unit id returns boolean//Remove this if you already had one
//! zinc
    library ReAmminsChild
    /*-----------------------------------------------------------------------------------/
    /-    v1.0.2
    /-       JC Helas
    /-
    /-   Description:
    /-       Releases sa tons of lightning ball that will spread
    /-       above and attack near enemy.
    /-
    /-   How to Import:
    /-       1. Goto File>Preferences>General
    /-       2. Mark check the "Automatically create unknown varaibles while pasting data.
    /-       3. Copy the imported dummy.mdx and the custom locust object
    /-       4. Then copy the folder and paste on your map.
    /-
    /-    The spell does not require any libraries.
    /-
    /-----------------------------------------------------------------------------------*/
    {
        private
        {
            /*- Determine the ability ID of Re'ammin's Child -*/
            constant integer SPELL_ID = 'A000'                                            ;
            /*- Determine the dummy id -*/
            constant integer DUM_ID   = 'u000'                                            ;
            /*- Determine the base amount of balls -*/
            constant integer BALL_AMT = 13                                                ;
            /*- Determine the addtional amount of balls  per level -*/
            constant integer BALL_AMTL= 2                                                 ;
            /*- Determine the base duration of balls -*/
            constant real BALL_DUR    = 10.0                                              ;
            /*- Determine the addtional duration of balls per level -*/
            constant real BALL_DURLVL = 5.0                                               ;
            /*- Determine the base attack interval of balls -*/
            constant real BALL_INTER  = 1.25                                              ;
            /*- Determine the deductional attack interval of balls per level -*/
            constant real BALL_INTERLV= 0.125                                             ;
            /*- Determine the minimum damage of balls -*/
            constant real DAMAGE_MIN  = 30.0                                              ;
            /*- Determine the maximum damage of balls -*/
            constant real DAMAGE_MAX  = 75.0                                              ;
            /*- Determine the additonal damage of ball by caster int percent -*/
            constant real DAMAGE_INT  = 15.0                                              ;
            /*- Determine the duration of lightnings -*/
            constant real LIGHTNING_D = 0.25                                              ;
            /*- Determine the affect of area per lightning strike as well as the drop impact -*/
            constant real DAMAGE_AOE  = 100.0                                             ;
            /*- Determine the search target of each balls -*/
            constant real SEARCH_AOE  = 300.0                                             ;
            /*- Determine the speed of balls to there distination -*/
            constant real SPEED       = 5.0                                               ;
            /*- Determine the speed  of dropping balls -*/
            constant real SPEED_DROP  = 15.0                                              ;
            /*- Determine the maximum distance of some balls may traveled -*/
            constant real DISTANCE    = 300.0                                             ;
            /*- Determine the minimum height of each ball may post -*/
            constant real MIN_Z       = 100.0                                             ;
            /*- Determine the maximum height of each ball may post -*/
            constant real MAX_Z       = 700.0                                             ;
            /*- Determine the starting size of balls -*/
            constant real MIN_SIZE    = 0.10                                              ;
            /*- Determine the maximum size of balls -*/
            constant real MAX_SIZE    = 2.0                                               ;
            /*- Determine the starting distance of ball to caster -*/
            constant real SUMMON_DIST = 50.0                                              ;
            /*- Determine the attack type of each damage -*/
            constant attacktype A_TYPE= ATTACK_TYPE_MAGIC                                 ;
            /*- Determine the damage type of each damage -*/
            constant damagetype D_TYPE= DAMAGE_TYPE_NORMAL                                ;
            /*- Determine the owner of dummies -*/
            constant player DUM_OWNER = Player(PLAYER_NEUTRAL_PASSIVE)                    ;
            /*- Determine the model attachment of ball model to dummy -*/
            constant string BALL_ATCH = "origin"                                          ;
            /*- Determine the model of balls -*/
            constant string BALL_MODEL= "Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl";
            /*- Determine the effect for the caster upon using the spell -*/
            constant string CASTER_FX = "Abilities\\Spells\\Orc\\Purge\\PurgeBuffTarget.mdl";
            /*- Determine the lightning scar effect -*/
            constant string GROUND_FX = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl";
            /*- Determine the type of lightning -*/
            constant string LIGHTNING = "CLPB"                                            ;
            
            struct data
            {
                player owner;
                unit caster,dummy;
                real angle,rate,speed,dur,interval,inte,dx,dy,dist,z,dmgint;
                effect fx;
                lightning l;
            }
            
            struct lightningdata
            {
                lightning l;
                real d;
            }
            
            constant real periodic=0.031250;
            constant group grp=CreateGroup();
            constant timer tmr=CreateTimer();
            integer ix=0;
            integer ic[];
            data link=0;
            
            constant timer ltmr=CreateTimer();
            integer lix=0;
            integer lic[];
            
            //! textmacro Destroy takes NAME,IX,IC,THIS,TMR
            function Destroy$NAME$(integer i) -> integer
            {
                $THIS$ this=$IC$[i];
                $THIS$.destroy(this);
                $IC$[i]=$IC$[$IX$];
                $IX$=$IX$-1;
                if($IX$==0)
                {
                    PauseTimer($TMR$);
                }
                return i-1;
            }
            //! endtextmacro
            //! textmacro Create takes NAME,IX,IC,THIS,TMR,CODE
            function Create$NAME$() -> $THIS$
            {
                $THIS$ this=$THIS$.create();
                $IX$+=1;
                $IC$[$IX$]=this;
                if($IX$==1)
                {
                    TimerStart($TMR$,periodic,true,$CODE$);
                }
                return this;
            }
            //! endtextmacro
            
            function onFilter(unit t,player p) -> boolean
            {
                return UnitAlive(t) &&
                !IsUnitType(t,UNIT_TYPE_MAGIC_IMMUNE) &&
                !IsUnitType(t,UNIT_TYPE_STRUCTURE) &&
                !IsUnitAlly(t,p);
            }
            //! runtextmacro Destroy("Light","lix","lic","lightningdata","ltmr")
            function onLightningLoop()
            {
                integer i=1;
                real r;
                lightningdata this;
                while(i<=lix)
                {
                    this=lic[i];
                    this.d=this.d-periodic;
                    if(this.d>0)
                    {
                        r=(1.0/LIGHTNING_D)*this.d;
                        SetLightningColor(this.l,r,r,r,r);
                    }
                    else
                    {
                        i=DestroyLight(i);
                    }
                    i+=1;
                }
            }
            //! runtextmacro Create("Light","lix","lic","lightningdata","ltmr","function onLightningLoop")
            function onLightning(lightning l,real d)
            {
                lightningdata this=CreateLight();
                this.l=l;
                this.d=d;
            }
            //! runtextmacro Destroy("Data","ix","ic","data","tmr")
            function onLoop()
            {
                data this;
                integer i=1;
                real x,y,s,sin;
                unit t;
                while(i<=ix)
                {
                    this=ic[i];
                    x=this.dx;
                    y=this.dy;
                    if(this.rate<100.0)
                    {
                        this.rate=this.rate+this.speed;
                        sin=Sin(((90.0/100.0)*this.rate)*bj_DEGTORAD);
                        s=(sin*MAX_SIZE);
                        x=x+(sin*this.dist)*Cos(this.angle*bj_DEGTORAD);
                        y=y+(sin*this.dist)*Sin(this.angle*bj_DEGTORAD);
                        SetUnitFlyHeight(this.dummy,sin*this.z,0.0);
                        SetUnitScale(this.dummy,s,s,s);
                        SetUnitX(this.dummy,x);
                        SetUnitY(this.dummy,y);
                    }
                    else
                    {
                        this.dur=this.dur-periodic;
                        if(this.dur>0.0)
                        {
                            this.inte=this.inte-periodic;
                            if(this.inte<=0)
                            {
                                this.inte=this.interval;
                                link=this;
                                GroupEnumUnitsInRange(grp,x,y,SEARCH_AOE,Filter(function()
                                {
                                    unit t=GetFilterUnit();
                                    real x,y;
                                    if(onFilter(t,link.owner))
                                    {
                                        x=GetUnitX(t);y=GetUnitY(t);
                                        UnitDamagePoint(link.caster,0.0,DAMAGE_AOE,x,y,GetRandomReal(DAMAGE_MIN,DAMAGE_MAX)+link.dmgint,true,true,A_TYPE,D_TYPE,null);
                                        DestroyEffect(AddSpecialEffect(GROUND_FX,x,y));
                                        MoveLightningEx(link.l,false,GetUnitX(link.dummy),GetUnitY(link.dummy),GetUnitFlyHeight(link.dummy),x,y,GetUnitFlyHeight(t));
                                        onLightning(link.l,LIGHTNING_D);
                                        GroupClear(grp);
                                    }
                                }));
                                GroupClear(grp);
                            }
                        }
                        else
                        {
                            this.z=this.z-SPEED_DROP;
                            SetUnitFlyHeight(this.dummy,this.z,0.0);
                            if(this.z<=0.0)
                            {
                                x=GetUnitX(this.dummy);y=GetUnitY(this.dummy);
                                link=this;
                                GroupEnumUnitsInRange(grp,x,y,DAMAGE_AOE,Filter(function()
                                {
                                    unit t=GetFilterUnit();
                                    if(onFilter(t,link.owner))
                                    {
                                        UnitDamageTarget(link.caster,t,GetRandomReal(DAMAGE_MIN,DAMAGE_MAX)+link.dmgint,true,true,A_TYPE,D_TYPE,null);
                                    }
                                }));
                                DestroyEffect(AddSpecialEffect(GROUND_FX,x,y));
                                GroupClear(grp);
                                DestroyEffect(this.fx);
                                DestroyLightning(this.l);
                                KillUnit(this.dummy);
                                this.caster=null;
                                this.dummy=null;
                                this.owner=null;
                                i=DestroyData(i);
                            }
                        }
                    }
                    i+=1;
                }
            }
            //! runtextmacro Create("Data","ix","ic","data","tmr","function onLoop")
            function onCast() -> boolean
            {
                unit u;
                player p;
                real x1,y1,x2,y2,a,d,inter,dmg;
                integer i,lvl;
                data this;
                if(GetSpellAbilityId()==SPELL_ID)
                {
                    u=GetTriggerUnit();
                    p=GetOwningPlayer(u);
                    lvl=GetUnitAbilityLevel(u,SPELL_ID);
                    i=BALL_AMT+(BALL_AMTL*lvl);
                    d=BALL_DUR+(BALL_DURLVL*lvl);
                    inter=BALL_INTER-(BALL_INTERLV*lvl);
                    if(IsUnitType(u,UNIT_TYPE_HERO))
                    {
                        dmg=(GetHeroInt(u,true)/100.0)*DAMAGE_INT;
                    }
                    else
                    {
                        dmg=DAMAGE_INT;
                    }
                    x1=GetUnitX(u);
                    y1=GetUnitY(u);
                    DestroyEffect(AddSpecialEffectTarget(CASTER_FX,u,BALL_ATCH));
                    a=360.0/i;
                    while(i>0)
                    {
                        x2=x1+SUMMON_DIST*Cos((a*i)*bj_DEGTORAD);
                        y2=y1+SUMMON_DIST*Sin((a*i)*bj_DEGTORAD);
                        this=CreateData();
                        this.dx=x2;
                        this.dy=y2;
                        this.dur=d;
                        this.rate=0.0;
                        this.dmgint=dmg;
                        this.interval=inter;
                        this.inte=GetRandomReal(0.125,inter);
                        this.speed=(100.0/DISTANCE)*SPEED;
                        this.angle=a*i;
                        this.caster=u;
                        this.owner=p;
                        this.dummy=CreateUnit(DUM_OWNER,DUM_ID,x2,y2,a*i);
                        this.fx=AddSpecialEffectTarget(BALL_MODEL,this.dummy,BALL_ATCH);
                        this.l=AddLightningEx(LIGHTNING,false,0,0,0,0,0,0);
                        SetLightningColor(this.l,1,1,1,0);
                        SetUnitScale(this.dummy,MIN_SIZE,MIN_SIZE,MIN_SIZE);
                        UnitAddAbility(this.dummy,'Amrf');UnitRemoveAbility(this.dummy,'Amrf');
                        this.dist=GetRandomReal(1.0,DISTANCE);
                        this.z=GetRandomReal(MIN_Z,MAX_Z);
                        i-=1;
                    }
                    u=null;
                }
                return false;
            }
            
            function onInit()
            {
                trigger t=CreateTrigger();
                integer i=0;
                while(i<=11)
                {
                    TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null);
                    i+=1;
                }
                TriggerAddCondition(t,Filter(function onCast));
                t=null;
            }
        }
    }
    
//! endzinc
You do not have the required permissions to view the files attached to this post.

Return to “No Target”

×