Messed up delayed cleaving attack

SanKakU

Member
Reaction score
21
ok cool...just making sure i understood what you were going for, i had a feeling it was like that...at any rate i don't think i'll be much help here since i don't understand structs and methods...sorry.
 

Rainther

I guess I should write something of value here...
Reaction score
61
JASS:
    call GroupAddUnit(dat.damaged, dat.target)

should be used in function A, not H if I'm correct. You should only need to declare it once.
 

Faust

You can change this now in User CP.
Reaction score
123
But you are incorrect.

Declare what once?

Hello?

It damages a couple of units, and not only one.
 

Rainther

I guess I should write something of value here...
Reaction score
61
You damage a unit and all other units around this unit will become damaged one at a time 3 times in a second, or does it work any other way? If so you should only need to declare the damaged unit once into the group of units who won't get affected.

If I'm totally wrong here then I guess I should crawl out my cave a lil' more often.
 

SanKakU

Member
Reaction score
21
don't you need a real of a distance to the target? that is probably what you're missing since i don't see it anywhere.

like for example. you hit first target, he gets hurt by the lightning next, then you say he won't go to another unit nearby for such and such distance away...well why don't you put that there? maybe that's why creeps very far away are getting attacked? didn't you say that happens? you must put in the min and max distance reals or something like that in there somewhere...like i said above i don't understand methods and structs but i know the only real you're using is for damage...haha.
 

Faust

You can change this now in User CP.
Reaction score
123
You damage a unit and all other units around this unit will become damaged one at a time 3 times in a second, or does it work any other way? If so you should only need to declare the damaged unit once into the group of units who won't get affected.

If I'm totally wrong here then I guess I should crawl out my cave a lil' more often.

I don't really understand what do you mean... Your first sentence is correct.
When the Thane attacks a unit, it sets the dat.target as the first target. Next, the handler function is ran. In that function, first the dat.target is damaged, THEN dat.target is assigned another value (the next enemy unit).

don't you need a real of a distance to the target? that is probably what you're missing since i don't see it anywhere.

like for example. you hit first target, he gets hurt by the lightning next, then you say he won't go to another unit nearby for such and such distance away...well why don't you put that there? maybe that's why creeps very far away are getting attacked? didn't you say that happens? you must put in the min and max distance reals or something like that in there somewhere...like i said above i don't understand methods and structs but i know the only real you're using is for damage...haha.

JASS:
call GroupEnumUnitsInRange(g, GetUnitX(dat.target), GetUnitY(dat.target), 500, Condition(function C2))

What do you think '500' stands for?
 

Rainther

I guess I should write something of value here...
Reaction score
61
If UnitDamageTarget activates your Event, doesn't that give you a terrible unending loop of the trigger? The trigger hurts an enemy and the trigger gets reactived as if he hurted this person with an attack, though it was by triggers
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
He disables the trigger before running the damage, then enables it again. So no, it wouldn't create an endless loop.
 

Rainther

I guess I should write something of value here...
Reaction score
61
You're right. Silly me forgot to check that. I'd assume that the problem mightr lie somewhere with how the unit groups works. I've encountered wierd responds with own stuff and solved it just by changing how groups will be created, added etc.
 

Romek

Super Moderator
Reaction score
963
Could we get the current code?
I'm guessing it's been updated a few times. :p
 

Faust

You can change this now in User CP.
Reaction score
123
Not it has not, actually. I really really am lost here :\

JASS:
scope StormStrike initializer I

globals
    private group G
endglobals

private struct StormStrike
    real damage
    unit attacker
    trigger t 
    unit target
    timer clock = CreateTimer()
    group damaged = CreateGroup()

    method onDestroy takes nothing returns nothing
        call GroupClear(.damaged)
        call DestroyGroup(.damaged)
        call PauseTimer(.clock)
        call ClearTimerStructA(.clock)
        call DestroyTimer(.clock)
    endmethod
endstruct

private function C takes nothing returns boolean
    return GetUnitAbilityLevel(GetEventDamageSource(), 'A01I') > 0
endfunction

private function C2 takes nothing returns boolean
    if IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), udg_Player) and GetUnitAbilityLevel(GetFilterUnit(), 'Aloc') == 0 and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitInGroup(GetFilterUnit(), G) != true then
     return true
    else
     return false
    endif
endfunction

private function H takes nothing returns nothing
    local StormStrike dat = GetTimerStructA(GetExpiredTimer())
    local group g = CreateGroup()
    local unit u
    call GroupAddUnit(dat.damaged, dat.target)
    call BJDebugMsg(GetUnitName(dat.target) + " is damaged for " + R2S(dat.damage))
    call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl", dat.target, "chest"))
    call DisableTrigger(dat.t)
    call UnitDamageTarget(dat.attacker, dat.target, dat.damage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
    call EnableTrigger(dat.t)
    set udg_Player = GetOwningPlayer(dat.attacker)
    set G = dat.damaged
    call GroupEnumUnitsInRange(g, GetUnitX(dat.target), GetUnitY(dat.target), 500, Condition(function C2))
    set u = FirstOfGroup(g)
    call BJDebugMsg(GetUnitName(u) + " is u")
    if u == null then
     call BJDebugMsg("Destroying")
     call dat.destroy()
    endif
    call DestroyGroup(g)
    set g = null
    set u = null
endfunction

private function A takes nothing returns nothing
    local StormStrike dat = StormStrike.create()
    set dat.attacker = GetEventDamageSource()
    set dat.target = GetTriggerUnit()
    set dat.damage = GetEventDamage()
    set dat.t = GetTriggeringTrigger()
    call BJDebugMsg(GetUnitName(dat.attacker) + GetUnitName(dat.target) + R2S(dat.damage))
    call SetTimerStructA(dat.clock, dat)
    call TimerStart(dat.clock, 0.33, true, function H)
endfunction

//===========================================================================
private function I takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitDamaged(t)
    call TriggerAddCondition(t, Condition(function C))
    call TriggerAddAction(t, function A)
endfunction

endscope
 

13lade619

is now a game developer :)
Reaction score
399
oh, i see the problem now.. it isnt your fault exactly..

just wait.. i'll explain.


look at this:
JASS:
    local group g = CreateGroup()
    local unit u
    call GroupAddUnit(dat.damaged, dat.target)


JASS:
    call GroupEnumUnitsInRange(g, GetUnitX(dat.target), GetUnitY(dat.target), 500, Condition(function C2))
    set u = FirstOfGroup(g)


see that?

the add 'target' first to the group... to technically it is ALWAYS FirstOfGroup(g).
and because you dont loop through the group 'properly'.. you always get the same unit over and over again.

using a simpler method through a simple loop with waits is the best solution.

JASS:
loop
    set u = FirstOfGroup(g)
    call GroupRemoveUnit(g,u)
    exitwhen u==null
    
    // your actions...
   
    call TriggerSleepAction(.33)
endloop
 

Faust

You can change this now in User CP.
Reaction score
123
JASS:
scope StormStrike initializer I

globals
    private group G
endglobals

private function C takes nothing returns boolean
    return GetUnitAbilityLevel(GetEventDamageSource(), 'A01I') > 0
endfunction

private function C2 takes nothing returns boolean
    if IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), udg_Player) and GetUnitAbilityLevel(GetFilterUnit(), 'Aloc') == 0 and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitInGroup(GetFilterUnit(), G) != true then
     return true
    else
     return false
    endif
endfunction

private function A takes nothing returns nothing
    local unit target = GetTriggerUnit()
    local unit attacker = GetEventDamageSource()
    local real damage = GetEventDamage()
    local group g = CreateGroup()
    local group gd = CreateGroup()
    call GroupAddUnit(gd, target)
    call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl", target, "chest"))
    call DisableTrigger(GetTriggeringTrigger())
    call UnitDamageTarget(attacker, target, damage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
    call EnableTrigger(GetTriggeringTrigger())
    loop
    exitwhen target == null
     set G = gd
     set udg_Player = GetOwningPlayer(attacker)
     call GroupEnumUnitsInRange(g, GetUnitX(target), GetUnitY(target), 500, Condition(function C2))
     set target = FirstOfGroup(g)
     call GroupAddUnit(gd, target)
     call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl", target, "chest"))
     call DisableTrigger(GetTriggeringTrigger())
     call UnitDamageTarget(attacker, target, damage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
     call EnableTrigger(GetTriggeringTrigger())
     call TriggerSleepAction(.33)
    endloop
    set target = null
    set attacker = null
    call DestroyGroup(g)
    call DestroyGroup(gd)
    set g = null
    set gd = null
endfunction

//===========================================================================
private function I takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitDamaged(t)
    call TriggerAddCondition(t, Condition(function C))
    call TriggerAddAction(t, function A)
endfunction

endscope


Works, thank you !
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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