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: 255

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
889
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
889
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
889
> 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
889
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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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