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
590
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
590
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
590
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
590
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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • 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 Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top