Spell Black Plague

elmstfreddie

The Finglonger
Reaction score
203
Note - It may appear in the thread selection page to read Black Plaque. No, my spell is not a tooth decaying ability. Please keep in mind it's a PLAGUE with a G :)

Oh damn it's my second spell :O
It works, I like it. :p

Basically Black Plague is a permanent version of Locust Swarm, except you don't receive hp and the locusts' attack slows the enemies.

MUI: Yea
Leaks: No!
JESP: I think so o_O
Import Difficulty: Medium, since there is 1 unit, 2 abilities, and 2 buffs, and 1 imported icon (a passive version of locust swarm)

Description:
Creates swarms of locusts around the hero which damages enemies and impares the enemy's movement.
Level 1 - 10 locusts and 10% slow
Level 2 - 15 locusts and 20% slow
Level 3 - 20 locusts and 30% slow

lol :p

Screenshot:
5zbg7jc.jpg


Trigger:
JASS:
function RandomPositionX takes real CurrentX returns real
    return (CurrentX + (GetRandomReal(1.00,300.00)) * Cos((GetRandomReal(0.00,360.00)) * 180.00/3.14159))
endfunction

function RandomPositionY takes real CurrentY returns real
    return (CurrentY + (GetRandomReal(1.00,300.00)) * Sin((GetRandomReal(0.00,360.00)) * 180.00/3.14159))
endfunction

function FacingOffsetX takes unit Owner returns real
    return GetUnitX(Owner) + 200 * Cos(GetUnitFacing(Owner) * 3.14159/180.00)
endfunction

function FacingOffsetY takes unit Owner returns real
    return GetUnitY(Owner) + 200 * Sin(GetUnitFacing(Owner) * 3.14159/180.00)
endfunction

constant function NumOfLocusts takes integer AbilLevel returns integer
    return 5 + (5 * AbilLevel)
endfunction

constant function LocustId takes nothing returns integer
    return 'u000'
endfunction

constant function AbilId takes nothing returns integer
    return 'A000'
endfunction

constant function SlowId takes nothing returns integer
    return 'A001'
endfunction    

function Trig_AutoLocusts_Conditions takes nothing returns boolean
    return GetLearnedSkill() == AbilId()
endfunction

function Trig_AutoLocusts_Actions takes nothing returns nothing
    local unit Owner = GetTriggerUnit()
    local ability LocustAbility
    local unit array Locust
    local integer index = 0
    local group Locusts = CreateGroup()
    local real dx
    local real dy
    if GetUnitAbilityLevel(Owner,AbilId()) != 1 then
        return
    endif
    loop
        set Locust[index] = CreateUnit(GetOwningPlayer(Owner),LocustId(),GetUnitX(Owner),GetUnitY(Owner),270.00)
        call GroupAddUnit(Locusts,Locust[index])
        exitwhen CountUnitsInGroup(Locusts) >= NumOfLocusts(GetUnitAbilityLevel(Owner,AbilId()))
        set index = index + 1
    endloop
    set index = 0
    loop
        if GetUnitState(Owner,UNIT_STATE_LIFE) <= 0 then
            set index = 0
            loop
                exitwhen index >= NumOfLocusts(GetUnitAbilityLevel(Owner,AbilId()))
                call SetUnitExploded(Locust[index],true)
                call KillUnit(Locust[index])
                call GroupRemoveUnit(Locusts,Locust[index])
                set Locust[index] = null
                set index = index + 1
            endloop
            call DestroyGroup(Locusts)
            loop
                exitwhen GetUnitState(Owner,UNIT_STATE_LIFE) >= 1
                call TriggerSleepAction(0.20)
            endloop
            set Locusts = CreateGroup()
            set index = 0
            loop
                exitwhen (CountUnitsInGroup(Locusts) >= NumOfLocusts(GetUnitAbilityLevel(Owner,AbilId())))
                set Locust[index] = CreateUnit(GetOwningPlayer(Owner),LocustId(),GetUnitX(Owner),GetUnitY(Owner),270.00)
                call GroupAddUnit(Locusts,Locust[index])
                call IssuePointOrder(Locust[index],"smart",RandomPositionX(GetUnitX(Owner)),RandomPositionY(GetUnitY(Owner)))
                set index = index + 1
            endloop
        endif                    
        set index = 0
        loop
            if CountUnitsInGroup(Locusts) < NumOfLocusts(GetUnitAbilityLevel(Owner,AbilId())) then
                set Locust[CountUnitsInGroup(Locusts)] = CreateUnit(GetOwningPlayer(Owner),LocustId(),GetUnitX(Owner),GetUnitY(Owner),270)
                call GroupAddUnit(Locusts,Locust[CountUnitsInGroup(Locusts)])
            endif 
            exitwhen index > NumOfLocusts(GetUnitAbilityLevel(Owner,AbilId()))
            set dx = GetUnitX(Owner) - GetUnitX(Locust[index])
            set dy = GetUnitY(Owner) - GetUnitY(Locust[index])
            if SquareRoot(dx * dx + dy * dy) > 250 then
                call IssuePointOrder(Locust[index],"move",FacingOffsetX(Owner),FacingOffsetY(Owner))
            else 
                call IssuePointOrder(Locust[index],"move",RandomPositionX(GetUnitX(Owner)),RandomPositionY(GetUnitY(Owner)))
            endif
            call SetUnitAbilityLevel(Locust[index],SlowId(),GetUnitAbilityLevel(Owner,AbilId()))
            set index = index + 1
        endloop
        call TriggerSleepAction(0.80)
    endloop
endfunction

function InitTrig_AutoLocusts takes nothing returns nothing
    set gg_trg_AutoLocusts = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_AutoLocusts,EVENT_PLAYER_HERO_SKILL)
    call TriggerAddCondition(gg_trg_AutoLocusts,Condition(function Trig_AutoLocusts_Conditions))
    call TriggerAddAction(gg_trg_AutoLocusts,function Trig_AutoLocusts_Actions)
endfunction


Oh yeah and excuse the ugly testing environment ;)
Let's face it, we all know I suck miserably at terraining.
 

Attachments

  • Auto Locusts.w3x
    28.2 KB · Views: 252

dragonhord

Knowledge is true opinion. - Plato
Reaction score
82
Only thing that bugs me about it is that it isnt as fluid as the normal Locust Swarm ability, other than that I like it, and I dont know how you prevent leaks in JASS so I couldnt verify leaklessness whether I wanted to or not =/. But other than the less fluidity of it, I like it :D .
 

elmstfreddie

The Finglonger
Reaction score
203
Only thing that bugs me about it is that it isnt as fluid as the normal Locust Swarm ability, other than that I like it, and I dont know how you prevent leaks in JASS so I couldnt verify leaklessness whether I wanted to or not =/. But other than the less fluidity of it, I like it :D .

Well, the locusts actually attack (for the slow effect), and attack-move just makes them stand at one guy and kill him miserably... :p
So I had to use either smart or move, basically same effect, for them to attack like normal locust, but I also lost the ability to make it smooth...
 

Squll2

je'ne sais pas
Reaction score
76
i would love it.. but i hate locusts... :p

always dl any JASS spells i see though o_O

offtopic: do admins still bump you up rep when your at 75?
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
I took a look at it.

Liked

The effect on the hero and enemies.
General idea of the ability.
MUI, JESP, etc.

Disliked

The locusts. Their movements were too predictable and set. You basically just told all of them to move to a random point around the hero, all at the same time. It would be nice if it could be a little more random.
 

elmstfreddie

The Finglonger
Reaction score
203
I actually added a 0.01 second wait between there movements, but it looked really funny... Like, a bad kind of funny. It looked stupid. Guys would be ditched then suddenly run after the hero n stuff. So I had to move them at the same time...
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
Also, I noticed that you keep ordering them when the hero is moving. They should probably just follow the hero straight, not dart off-course every second and then come back.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> Well, if you look at the real locust swarm they also drag behind...

Yes, they drag behind, but they stay on a straight course behind the hero. Yours are still pretty choppy.
 

elmstfreddie

The Finglonger
Reaction score
203
Oh. I see what you mean.
I'll brainstorm a fix for that... I can't think of anything off the top of my head. Maybe I'll just have to redo the whole movement part.

Edit > Okay.. I'll just check the distance between the locust and the hero, and if the distance is big then I'll order them to move to the hero's position (so then they dart right to him like the original)
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
If you want my recommendation, do a check to see if the order of the hero is move. If it is, just order the locusts to move to the hero's position. Otherwise, do the random move.
 

elmstfreddie

The Finglonger
Reaction score
203
I considered that before you posted, but then no one ever "moves", they always smart, and if the smart is on a unit then they would dart to the hero and totally annihilate the enemy :p
 

elmstfreddie

The Finglonger
Reaction score
203
Bump + Info On Progress

KK when they get too far they move to your hero now, and it works great, but once in awhile they get stuck or something and bunch up really close to the hero until the hero stops moving :nuts: It doesn't happen ALL the time though, and when it doesn't, it works :p
(this is what happens when I try to make them go to the hero when they too far)

edit > apparently my distance code was horribly flawed..?
Anyways, I fixed it, they follow better now.
 

Sim

Forum Administrator
Staff member
Reaction score
534
It seems to me like the locusts don't really fight. There are 20 locusts turning around me and the units don't get damaged, at least not enough.
 

elmstfreddie

The Finglonger
Reaction score
203
That's sort of on purpose.
I could make them fight better, but I didn't since they are passive and it lasts forever. Not to mention they slow. If they fought more, it would be an uber spell, don't you think :p

If you want I could revamp this so that they all attack and all slow, but then it might get uber unless I make them REALLY weak...
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
I'm about 99.9% sure that this needs more constants, and it definitely needs some comments to explain it.

I'll edit with comments on the code later. :)

EDIT:

You do know this leaks, right? Well, sometimes:
JASS:
    local unit Owner = GetTriggerUnit()
    local ability LocustAbility
    local unit array Locust
    local integer index = 0
    local group Locusts = CreateGroup()
    local real dx
    local real dy
    if GetUnitAbilityLevel(Owner,AbilId()) != 1 then
        return
    endif


Hm... Lets see, all these locals, un-nulled, un-destroyed. Then, oh, a return! That skips the remaining actions!! WooT!

So, it skips the nulling and destroying actions. Add this:
JASS:

    if GetUnitAbilityLevel(Owner,AbilId()) != 1 then
        call DestroyGroup(Locusts)
        set Locusts = null
        set Owner = null
        return
    endif


And, null the variables at the end. Here is an enhanced version:
JASS:
function RandomPositionX takes real CurrentX returns real
    return (CurrentX + (GetRandomReal(1.00,300.00)) * Cos((GetRandomReal(0.00,360.00)) * 180.00/3.14159))
endfunction

function RandomPositionY takes real CurrentY returns real
    return (CurrentY + (GetRandomReal(1.00,300.00)) * Sin((GetRandomReal(0.00,360.00)) * 180.00/3.14159))
endfunction

function FacingOffsetX takes unit Owner returns real
    return GetUnitX(Owner) + 200 * Cos(GetUnitFacing(Owner) * 3.14159/180.00)
endfunction

function FacingOffsetY takes unit Owner returns real
    return GetUnitY(Owner) + 200 * Sin(GetUnitFacing(Owner) * 3.14159/180.00)
endfunction

constant function NumOfLocusts takes integer AbilLevel returns integer
    return 5 + (5 * AbilLevel)
endfunction

constant function LocustId takes nothing returns integer
    return 'u000'
endfunction

constant function AbilId takes nothing returns integer
    return 'A000'
endfunction

constant function SlowId takes nothing returns integer
    return 'A001'
endfunction    

function Trig_AutoLocusts_Conditions takes nothing returns boolean
    return GetLearnedSkill() == AbilId()
endfunction

function Trig_AutoLocusts_Actions takes nothing returns nothing
    local unit Owner = GetTriggerUnit()
    local ability LocustAbility
    local unit array Locust
    local integer index = 0
    local group Locusts = CreateGroup()
    local real dx
    local real dy
    if GetUnitAbilityLevel(Owner,AbilId()) != 1 then
        call DestroyGroup(Locusts)
        set Locusts = null
        set Owner = null
        return
    endif
    loop
        set Locust[index] = CreateUnit(GetOwningPlayer(Owner),LocustId(),GetUnitX(Owner),GetUnitY(Owner),270.00)
        call GroupAddUnit(Locusts,Locust[index])
        exitwhen CountUnitsInGroup(Locusts) >= NumOfLocusts(GetUnitAbilityLevel(Owner,AbilId()))
        set index = index + 1
    endloop
    set index = 0
    loop
        if GetUnitState(Owner,UNIT_STATE_LIFE) <= 0 then
            set index = 0
            loop
                exitwhen index >= NumOfLocusts(GetUnitAbilityLevel(Owner,AbilId()))
                call SetUnitExploded(Locust[index],true)
                call KillUnit(Locust[index])
                call GroupRemoveUnit(Locusts,Locust[index])
                set Locust[index] = null
                set index = index + 1
            endloop
            call DestroyGroup(Locusts)
            loop
                exitwhen GetUnitState(Owner,UNIT_STATE_LIFE) >= 1
                call TriggerSleepAction(0.20)
            endloop
            set Locusts = CreateGroup()
            set index = 0
            loop
                exitwhen (CountUnitsInGroup(Locusts) >= NumOfLocusts(GetUnitAbilityLevel(Owner,AbilId())))
                set Locust[index] = CreateUnit(GetOwningPlayer(Owner),LocustId(),GetUnitX(Owner),GetUnitY(Owner),270.00)
                call GroupAddUnit(Locusts,Locust[index])
                call IssuePointOrder(Locust[index],"smart",RandomPositionX(GetUnitX(Owner)),RandomPositionY(GetUnitY(Owner)))
                set index = index + 1
            endloop
        endif                    
        set index = 0
        loop
            if CountUnitsInGroup(Locusts) < NumOfLocusts(GetUnitAbilityLevel(Owner,AbilId())) then
                set Locust[CountUnitsInGroup(Locusts)] = CreateUnit(GetOwningPlayer(Owner),LocustId(),GetUnitX(Owner),GetUnitY(Owner),270)
                call GroupAddUnit(Locusts,Locust[CountUnitsInGroup(Locusts)])
            endif 
            exitwhen index > NumOfLocusts(GetUnitAbilityLevel(Owner,AbilId()))
            set dx = GetUnitX(Owner) - GetUnitX(Locust[index])
            set dy = GetUnitY(Owner) - GetUnitY(Locust[index])
            if SquareRoot(dx * dx + dy * dy) > 250 then
                call IssuePointOrder(Locust[index],"move",FacingOffsetX(Owner),FacingOffsetY(Owner))
            else 
                call IssuePointOrder(Locust[index],"move",RandomPositionX(GetUnitX(Owner)),RandomPositionY(GetUnitY(Owner)))
            endif
            call SetUnitAbilityLevel(Locust[index],SlowId(),GetUnitAbilityLevel(Owner,AbilId()))
            set index = index + 1
        endloop
        call TriggerSleepAction(0.80)
    endloop
    set LocustAbility = null
    set Owner = null
    set Locusts = null
endfunction

function InitTrig_AutoLocusts takes nothing returns nothing
    set gg_trg_AutoLocusts = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_AutoLocusts,EVENT_PLAYER_HERO_SKILL)
    call TriggerAddCondition(gg_trg_AutoLocusts,Condition(function Trig_AutoLocusts_Conditions))
    call TriggerAddAction(gg_trg_AutoLocusts,function Trig_AutoLocusts_Actions)
endfunction


:D
 

elmstfreddie

The Finglonger
Reaction score
203
Why null? It's passive. I can't null them without stopping the spell.

PS: I am against comments. I am an anti-commenter. lol
Why/where do I need comments exactly???

PPS: Your script wouldn't work anyways. 2 reasons:
1) it would never leave the original loop (hence PASSIVIVITY!)
2) your if/then/else is outside of the loop, and if the event is a unit learns the ability, it proves useless.
 

Steel

Software Engineer
Reaction score
109
Why not just have a timer cycle through each unit, checking around them in a radius of...50? I believe unit's picked in a range returns the closest one as the first. So after it picks the first unit that unit not longer needs to be cycled so skip to the next. You could also trigger the slow this way with a dummy. This would allow you to make the movements of the locust more fluid since they wouldn't have to do anything but move around as an effect.
 

emjlr3

Change can be a good thing
Reaction score
395
set your player to a local

make your functions tha taking nothing globals

exitwhen CountUnitsInGroup(Locusts) - would be faste to just compare it to index here, rather then do this each time

store ability level to a local

life<.405

not real sure what you do later, will look into it mroe later
 

Sim

Forum Administrator
Staff member
Reaction score
534
That's sort of on purpose.
I could make them fight better, but I didn't since they are passive and it lasts forever. Not to mention they slow. If they fought more, it would be an uber spell, don't you think :p

If you want I could revamp this so that they all attack and all slow, but then it might get uber unless I make them REALLY weak...

Add a constant that defines this fighting capability.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top