[Solved] continuous lightning effect, chained - how to? Ideas?

Hi, i want to have a unit that channels a lightning effect continuously onto another unit, and i want to daisy chain multiple units.
Things I tried:
1. chain lightning's lightning is temporary (no-no)
2. spirit links's lightning is temporary (no-no)
3. lightning effect with triggers always puts them on ground level, and there isi not option to chain height or offset
(i want attachment point of unit <-> attachment point of unit)
4. Drain life/mana has a bug- cannot target friend or enemy unit
5. no abilities, just attack with projectile - i set attack cooldown to 0.10. turns out it wasnt not enough to make it look smooth, but i cant go lower or the game is hardcoded to have lower limit for attack speed. Also a unit has fields for projectile launch position X Y Z but for impact has only Z :/
6. Aerial shackles is continuous channel, but stuns the target so i cant daisy chain them

Any ideas how to achieve this?
 
Last edited:
3. lightning effect with triggers always puts them on ground level, and there isi not option to chain height or offset
This is the only way as far as I know. But you need to use custom script/JASS to call version of "Move Lightning" function which also allows you to set Z-coordinates: Doc - MoveLightningEx
I don't think there is any way to attach lightning to unit's attachment points.
 
I made a simple GUI lightning system here which should be easy to follow:

Here's a lightning related spell that I made (not using the above system), it shows how to handle the "Get best target" logic:
 
Last edited:
This is the only way as far as I know. But you need to use custom script/JASS to call version of "Move Lightning" function which also allows you to set Z-coordinates: Doc - MoveLightningEx
I don't think there is any way to attach lightning to unit's attachment points.
Thanks, this worked. And I made a useful function that anyone can use to generate ligtning between two units. It considers their facing angle.

JASS:
function Move_Lightning takes unit source, unit target, lightning lt returns nothing

    // =====================================================
    // World position variables (do not modify)
    // =====================================================
    local real x_source
    local real y_source
    local real x_target
    local real y_target

    local real facing_source
    local real facing_target

    local real cosA
    local real sinA

    local real final_x1
    local real final_y1
    local real final_x2
    local real final_y2

    // =====================================================
    // >>>>>>>>>>>>>>> UNIT-DEPENDENT VALUES <<<<<<<<<<<<<<
    // These MUST be adjusted depending on the model size,
    // animation, and where you want the lightning attached.
    // =====================================================

    local real x1 = 160.00
    // Forward offset from SOURCE unit.
    // Increase = further in front of unit.
    // Decrease = closer to body.
    // Negative = behind the unit.

    local real y1 = -20.00
    // Sideways offset from SOURCE unit.
    // Positive = left side.
    // Negative = right side.
    // Adjust to match hand / weapon position.

    local real z1  = 300.00
     local real z2  = 300.00
    // Height of lightning attachment.
    // Increase for tall models.
    // Decrease for smaller units.
    // This often requires visual testing per unit type.

    local real x2 = 160.00
    // Forward offset from TARGET unit.
    // Same logic as x1 but for target.

    local real y2 = -20.00
    // Sideways offset from TARGET unit.
    // Same logic as y1 but for target.

    // =====================================================
    // Get source position and rotate offsets by facing
    // =====================================================

    set x_source = GetUnitX(source)
    set y_source = GetUnitY(source)
    set facing_source = GetUnitFacing(source) * bj_DEGTORAD

    set cosA = Cos(facing_source)
    set sinA = Sin(facing_source)

    set final_x1 = x_source + x1 * cosA - y1 * sinA
    set final_y1 = y_source + x1 * sinA + y1 * cosA

    // =====================================================
    // Get target position and rotate offsets by facing
    // =====================================================

    set x_target = GetUnitX(target)
    set y_target = GetUnitY(target)
    set facing_target = GetUnitFacing(target) * bj_DEGTORAD

    set cosA = Cos(facing_target)
    set sinA = Sin(facing_target)

    set final_x2 = x_target + x2 * cosA - y2 * sinA
    set final_y2 = y_target + x2 * sinA + y2 * cosA

    // =====================================================
    // Move the lightning
    // =====================================================

    call MoveLightningEx(lt, false, final_x1, final_y1, z1, final_x2, final_y2, z2)

endfunction
  • test
    • Events
      • Player - Player 1 (Red) types a chat message containing test as An exact match
    • Conditions
    • Actions
      • Lightning - Create a Drain Mana lightning effect from source (Position of Beam Statue 0103 <gen>) to target (Position of Beam Statue 0105 <gen>)
      • Set LCounter = (LCounter + 1)
      • Set Ls[LCounter] = (Last created lightning effect)
      • -------- ------------------------ --------
      • Set TempUnit = Beam Statue 0103 <gen>
      • Set TempUnit2 = Beam Statue 0105 <gen>
      • -------- ------------------------ --------
      • Custom script: call Move_Lightning(udg_TempUnit, udg_TempUnit2, udg_Ls[udg_LCounter])




Untitled.png
 
Last edited:
Back
Top