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.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top