Dash Damage

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
Yes I read Emijr's tutorial but I didn't quite get it, I was hoping for an alternate way. Can someone give me a code which could damage units that are within 250 range that are enemies? I don't need a special effect, the flames in my dash will be fine. Thanks in advanced.
 

substance

New Member
Reaction score
34
To damage units in a AOE you have to:

1. Create a group.
2. Put all the enemy units in whatever radius in that group.
3. Loop through all the units in that group and damage them individually.

1. Simple:
JASS:
local group g = CreateGroup()

2. To get all the units within a certain area you'd use
JASS:
GroupEnumUnitsInRange (whichGroup, x, y, radius, filter)
This function will get all the units in a certain radius of the specified location(x,y) and then run them through a filter. Units that pass through the filter will be put into the specified group. A filter is just a boolean expresion (that links to a function) that lets the unit pass through only if it meets whatever requirments you specify (ie. if the unit is a enemy unit of whatever unit). An example to put all enemy units in a 300 radius of the casting unit would look something like this (**note that 'GetEnumUnit()' is the unit that is currently going through the filter)
JASS:
function FILTER takes nothing returns boolean
 if IsUnitAlly(GetEnumUnit(),GetOwningPlayer(My_Global_Unit)) == true then
    return true
 else
    return false
 endif
endfunction 

function EXAMPLE takes nothing returns nothing
 local group g = CreateGroup()
 local boolexp myfilter = Condition(function FILTER)

    set My_Global_Unit = GetTriggerUnit()
    call GroupEnumUnitsInRange (g, GetUnitX(My_Global_Unit), GetUnitY(My_Global_Unit), 300, myfilter)
endfunction

3. To loop through a group and, for example, kill each unit in that group you would do something like this
JASS:
local unit f
loop
   set f = FirstOfGroup(f)
   exitwhen f ==null
   call KillUnit(f)
   call GroupRemoveUnit(g,f)
endloop
So basically how that works is you set 'f' to the first unit in a group, then you kill 'f' and remove 'f' from the group. It will keep looping through this untill f is null, meaning there are no more units in that group.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
How would I do this with damage though? I don't want to kill my unit, I just want it to deal damage.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
JASS:
//Group Adding
    call GroupEnumUnitsInRange(filtergroup, X, Y, 100.0, filter)
    
  //Functions
    if GetHandleReal(dashtimer, "dist") >= 0.0 then
      call SetHandleReal(dashtimer, "dist", GetHandleReal(dashtimer, "dist") - FW_Move_Distance())
      call SetUnitPosition(caster, PolarX, PolarY)
      loop
        set enemy = FirstOfGroup(filtergroup)
        exitwhen enemy==null
        call SetUnitState(enemy, UNIT_STATE_LIFE, GetUnitState(enemy, UNIT_STATE_LIFE) - 100.00)
        call GroupRemoveUnit(filtergroup, enemy)
      endloop

*Note: This is only a PART of my script

Okay, when I do this, the damage works but it damages multiple time, doing 300-400 damage. How do I prevent this?
 

substance

New Member
Reaction score
34
How would I do this with damage though? I don't want to kill my unit, I just want it to deal damage.
If you dont already have JassCraft or TESH go download it, they have lists of all the functions so you dont have to make a post everytime you need a native.
*Note: This is only a PART of my script

Okay, when I do this, the damage works but it damages multiple time, doing 300-400 damage. How do I prevent this?

I dont see anything quickly over-looking. Post your whole script. Also, you can use debug messages to help troubleshoot. (call BJDebugMsg("whatever"))
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
My script is fine, it's just that whenever I do it, it damages it multiple times, I think it's cus of this:

U = My unit
"-" = 100 range
E = Enemy

U - E (100 range, dashing TOWARDS him) <------He's within 100 range, so he takes damage
UE (0 range, RIGHT NEXT to him) <-------He's next to him, he takes damage
E - U (100 range, dashing AWAY)------He's passed him, he STILL takes damage.

So when he's within 100 range, he takes damage, then he moves 75.0 range closer, and he's still within 100 range so he takes the damage again. How do I prevent them from suffering from multiple amount of damage?
 

substance

New Member
Reaction score
34
Hmm, 2 group?

What I mean is once you damage a unit you put that unit in another group (DamagedUnitsGroup) and when you go to damage units again you check if that unit is in the 'DamagedUnitsGroup' and if he is, you skip him. Example:
JASS:
      loop
        set enemy = FirstOfGroup(filtergroup)
        exitwhen enemy==null
        if not IsUnitInGroup(enemy,damagedunits) then
           call SetUnitState(enemy, UNIT_STATE_LIFE, GetUnitState(enemy, UNIT_STATE_LIFE) - 100.00)
           call GroupAddUnit(damagedunits,enemy)
        else
        endif
        call GroupRemoveUnit(filtergroup, enemy)
      endloop


That's just one idea, there might be a better way.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
Okay, I see what you mean, but now, is it possible to attach a group to a handle so I can use it for later? Because I need to be able to destroy the group to remove the memory leak. Also, do I have to set a group = null after destroying it?
 

Tinki3

Special Member
Reaction score
418
>do I have to set a group = null after destroying it?

Yes, you do. Unless you want it to leak.

>I need to be able to destroy the group to remove the memory leak

No need to do that if you aren't going to set the unit group before-hand.
You just need to add the picked units to the global group, and remove them
after the caster has finished using the spell.

You'd want some method like this WarLuvr:
JASS:
local real d = &lt;Distance travelled by caster&gt;
if d &lt; MaxDistance then
    loop
        set p = FirstOfGroup(g)
        exitwhen p == null
        call GroupRemoveUnit(g, p)
        if IsUnitInGroup(p, udg_DamagedUnits) != true then
            call GroupAddUnit(udg_DamagedUnits, p)
            //Damage target, do whatever
        endif
    endloop
else
    call GroupClear(g)
    //Pause + Destroy timer, flush handle locals
endif
..
//Null + Destroy variables
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
I do NOT want to use Global Variables, I officially hate them.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
Is there any way I can do this without using global variables because I am unable to store Groups into a handle.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
It's saying that it's an "Invalid Argument Type" within the handle...so I assume this is because of the group. Apparently I can't store the group.
 

emjlr3

Change can be a good thing
Reaction score
395
so let me get this straight

your making a JASS spell, and it is obvious you do not really know JASS, much at all, other then copying form my tutorial

you hate globals, which are great actually

you cant alter handle vars to allow you to store a group

you cant simply add a group to my spell, and not damage people you add to it

and you do not even simply know how to deal damage in JASS

?? do I paint an accurate picture?

go back to square one, learn JASS, practice simple things, the nre-read my tut and try again, if you still cannot get it, id suggest quitting WC3 modding, but that is just me...
 

substance

New Member
Reaction score
34
lol, I think what emjlr3 is trying to say is that you should get a better understanding of the basics before you hop into advanced spell making and coming on here asking for help.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
It's saying that it's an "Invalid Argument Type" within the handle...so I assume this is because of the group. Apparently I can't store the group.

JASS:
type group              extends     handle


What does that say? A group is a handle. Just use:
JASS:
SetHandleHandle(fdgfsfjlkdj)


Btw... Handles aren't that great, learn 2 correctly download JASS NewGen so you can take advantage of their structs and globals... I believe that NewGen is the actual world editor that everyone needs. :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!
  • The Helper The Helper:
    Happy Wednesday!
    +1

      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