• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Scaling Ability Damage on Chain Lightning?

Status
Not open for further replies.
Level 4
Joined
Jul 14, 2012
Messages
100
So I made a spell based off of Chain Lightning and I want all targets hit to take bonus damage based off the caster's Intelligence, but all I can seem to do in trigger editor is damage the target unit. Is there a way to make all the struck targets take the bonus damage(which I would want to be full. My ability only hits 3 targets at all levels and damages each for full damage, unlike the original Chain Lightning).

This is what I have, and it only does bonus damage to the first unit:

  • Sartura Chain Poison
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Chained Poision
    • Actions
      • Unit - Cause (Casting unit) to damage (Target unit of ability being cast), dealing (2.00 x (Real((Intelligence of (Casting unit) (Include bonuses))))) damage of attack type Spells and damage type Normal
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,195
There is no way to detect the bounce targets as far as I am aware. A damage detection system can detect the damage they cause, however one does not know if that damage is from other abilities or attacking.

The most common solution is to trigger the entire chain lightning from scratch. Do note that in WC3 Chain Lightning has no problems bouncing between the same two units, it just cannot bounce to the last bounced unit. It also has a missile that determines how long a bounce lasts, simulating this might not be required.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Noone knows how the next target of the bounce is determined.

However, if you are going to make this from scratch, I have something that you might like.
I thought that the "Get random unit from <group>" was not random enough so I made this function:
JASS:
    globals
        unit bf_pickedUnit
    endglobals
    function GroupGetRandomUnit takes group g returns unit
        local unit FoG
        local group swap = CreateGroup()
        local integer count = 0
        local integer random
        set bf_pickedUnit = null
        
        loop
            set FoG = FirstOfGroup(g)
            exitwhen FoG == null
            call GroupRemoveUnit(g, FoG)
            
            set count = count +1
            call GroupAddUnit(swap, FoG)
        endloop
        
        set random = GetRandomInt(0, count)
        set count = 0
        
        loop
            set FoG = FirstOfGroup(swap)
            exitwhen FoG == null
            call GroupRemoveUnit(swap, FoG)
            call GroupAddUnit(g, FoG)
            
            set count = count +1
            if count == random then
                set bf_pickedUnit = FoG
            endif
        endloop
        
        call DestroyGroup(swap)
        set swap = null
        return bf_pickedUnit
    endfunction

When using this in GUI, you might want to use some global variables for it.
 
Level 4
Joined
Jul 14, 2012
Messages
100
Oh man that is like foreign language to me. Do you think you could explain some of things in there, Wietlol? I've never used global variables before and that looks like a really complicated ability to make. I've only made simple abilities using triggers before.

What are the "local" lines? And for the "call" does it mean more triggers have to be involved? I've never used jass before other than some destroy temp variables if that even counts heh.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Basically because it is not really random.
But that doesnt matter.
The method I gave is equal as random as GetRandomInt().

What you have to do is indeed create a single target ability.
Then you deal damage to that unit.
Then you pick every units in range of that target and filter out all allies, structures and dead units.
Then you remove the old target from that group as well.
Then you use this method using a custom script to get a total random unit.
Then that unit becomes the new target.
Then you do it again.

You should make it inside a loop.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Basically because it is not really random.
But that doesnt matter.
The method I gave is equal as random as GetRandomInt().

What you have to do is indeed create a single target ability.
Then you deal damage to that unit.
Then you pick every units in range of that target and filter out all allies, structures and dead units.
Then you remove the old target from that group as well.
Then you use this method using a custom script to get a total random unit.
Then that unit becomes the new target.
Then you do it again.

You should make it inside a loop.

The BJ function for getting a random unit in a group is random. Is there another function you are talking about that doesn't work properly? The only thing that would break the random in the BJ function is if the built in random integer function was not random enough.
 
Status
Not open for further replies.
Top