Snippet UnitDamageArea() + Jump Spell

PurgeandFire

zxcvmkgdfg
Reaction score
509
UnitDamageArea() - v4

Well, the Jump spell is just an addition. :p I just literally whipped it up fast and it was just as an example.

Note: Yes, the jump spell is not part of the submission.

Import Difficulty: It is a snippet... o_O 1/10

MUI: Yes, the snippet is MUI. As well as the spell. :p

GUI/JASS/vJASS: Snippet - JASS (Spell - vJASS)

Systems Used: None (Spell uses HSAS v.3.6)

Now here is proof that this works and damages units:
jj5w4usif3yactcu5glx.jpg


As you can see, the unit was damaged. :p

The jump spell is a simple jump, so here is the description of my thing:

Description/Purpose:

Enums units in a target area, and allows you to damage them for a certain amount. This has the same features as the UnitDamagePoint except there aren't the booleans for "ranged" and "attack" and it allows you to specify a boolexpr. I'm not positive but I think that if you specify null it will use the safe filter to avoid leaking. But you should probably just directly use the safe filter if you don't want to filter units out.

Why did I make this?
Captain Griffen said:
UnitDamagePointLoc is a big no no (as for that matter is UnitDamagePoint). It causes desyncs on Macs, and is totally customizable. Change it to enuming a group and damaging each one and it'll not desync on Macs, and become a customizable spell.

So this is the simple enum process to avoid desyncs to all those mac users out thar!

JASS:
function FiltSafe takes nothing returns boolean
    return true
endfunction

function UnitDamageArea takes unit u, real x, real y, real radius, real damage, attacktype at, damagetype dt, weapontype wt, boolexpr boo returns nothing
    local group g  = CreateGroup()
    local unit dum
    local boolexpr b

    if boo == null then
        set b = Condition(function FiltSafe)
    else
        set b = boo
    endif
    
    call GroupEnumUnitsInRange(g,x,y,radius,b)
    
    loop
        set dum = FirstOfGroup(g)
        exitwhen dum == null
        call UnitDamageTarget(u,dum,damage,true,false,at,dt,wt)
        call GroupRemoveUnit(g,dum)
    endloop
    
    call DestroyGroup(g)
    set g   = null
    set b   = null
endfunction 

function UnitDamageAreaLoc takes unit u, location l, real radius, real damage, attacktype at, damagetype dt, weapontype wt returns nothing
    call UnitDamageArea(u,GetLocationX(l),GetLocationY(l),radius,damage,at,dt,wt,Condition(function FiltSafe))
endfunction


Enjoy!

Changelog (Like I really need one, it is just a snippet :p):
Code:
 v1 - Initial posting
 v2 - UnitDamageAreaLoc() is for GUI users... [you can't specify a boolexpr]
 v3 - Allow you to null the boolexpr value to damage all units in that area. (Not sure if it leaks, but it shouldn't [it should fix the boolexpr null problem])
 v4 - Cleaned the code a bit. Oddly it reduced the size like 11 kbs or so...
 v5 - Even though it is just an example, I updated the spell code for a divide by 0 error, and now you can change the arch effect by typing either: yellow, blue, red, green, purple, fx, or light.
 

Kenny

Back for now.
Reaction score
202
Smart idea, i had a similar AoE damage function because i hated using one for each spell, but then again so may a lot of people. None-the-less, this seems clean, it is no doubt useful and it will save people a fair bit of time. Good work :D.

PS: When i was making mine, i asked about nulling the FirstOfGroup() unit after the loop has exited, and some one said it was not necessary as the loop exits when the unit is nulled. Ill try to find the thread if you need proof.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
@Kenny: Thanks, and yes I'm pretty sure it doesn't need to be nulled. (Hence the "exitwhen bla == null"... :p But I forgot and did it by mistake, I might update it later.

@Flare: Yup, exactly like that. It just doesn't have the "attack" and "ranged" parameters, and it allows a boolexpr. :)
 

ZiggyMcjoney

Data editor?! AAAHHHHH!
Reaction score
95
Hrm, so this can damage an area matching conditions as well?

If it can, that's awesome :p.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Yes, for example:
JASS:
function Filt takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit())) and GetWidgetLife(GetFilterUnit())>0
endfunction

function Test takes nothing returns nothing
    call UnitDamageArea(u,x,y,500,25,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL,null,Condition(function Filt))
endfunction


In this example, you can damage units in an area, that are an enemy of "Triggering Unit" and that have a life greater than 0. [= they are alive]

I'm not positive but if you specify null, it should create a safe filter to avoid leaking. (This will damage all units in an area without any conditions)
 

ZiggyMcjoney

Data editor?! AAAHHHHH!
Reaction score
95
Thats cool, and easy to understand too.

I'd rep you but I can't give you any more rep right now >.<.
 

thewrongvine

The Evolved Panda Commandant
Reaction score
506
wow... I wish I could actually understand what the code is. ^_^

In the screenshot, when the MK... well, that flashy lights thing, is that like an effect while hes in the air?
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
wow... I wish I could actually understand what the code is. ^_^

In the screenshot, when the MK... well, that flashy lights thing, is that like an effect while hes in the air?

Yes, it is a trailing effect that is in the shape of an arc. (Follows the path of the Mountain King)

I thought it looked awesome so I just decided to add it. :p

The code is simply grouping... :D
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
If you try to jump where you stand, you get a divide by 0 message and if you do it a whole bunch it lags like crazy.
Also, when you do it right where you stand, you can't move and you can cast it again but all you do is the effect and stay where you were.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
If you try to jump where you stand, you get a divide by 0 message and if you do it a whole bunch it lags like crazy.
Also, when you do it right where you stand, you can't move and you can cast it again but all you do is the effect and stay where you were.

Well, yeah. Because you'll be executing a bunch of functions and creating too much effects for your comp to handle. :p Besides, it is just an example. xD

But I will fix it anyway by showing an error and not doing anything when you use your own coordinate.

And I was testing different fx for the models, so I added just some triggers to change it. You can type "yellow","green","blue","red","purple","fx", and "light" to change the effect.

I'll upload in a second.
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
Heh. Another bug.
Add something that checks if the spell target is within the map. I was able to jump around outside the map.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Heh. Another bug.
Add something that checks if the spell target is within the map. I was able to jump around outside the map.

Exactly. :p

I know that bug, I was just to lazy to fix it. And it is kind of fun to jump in an out of the map. Eh, w/e. I'll get around to it maybe tomorrow.
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
Heh. Want me to post up a piece that will do it?
I just need to make sure the variable that is where the caster goes is "l".
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
Oh, structs are a bit beyond me.
Ehh, I suggested it, up to you. :)
 
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