• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Take damage from a lightning

Status
Not open for further replies.
Level 9
Joined
Apr 19, 2011
Messages
447
Hi again.

I'm trying to make a spell for a boss of my campaign, and I trying to do it with triggers. When the boss launches the spell, a source of lighning comes from him to a random point of the battle area (Create Lightning Effect), and then begins to move around the area (Move Lightning Effect).
But it's a waste of time if the character doesn't take damage from the lightning.
How can I make the character to receive damage when he touches the lightning? I mean, not only the points when the lightning begins and ends, the entire body of the lighning too.

Please, if it can only be donde with JASS, tell me step by step how to do it, because I don't know anything of JASS. If it can be done with GUI, I prefer it above all.

Thanks for reading.

Regards
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
One option is to compare the angle from the origin of the lightning to the position of units an the angle of the lightning. If the angle difference is small, then the unit is colliding with the lightning. This uses a triangle shaped area can still be accurate enough and it's quite simple solution.

Or you could consider the lightning as a rectangle. Calculate corners of the rectangle derived from the end- and beginning points of the lightning. Then pick all units in range (~length of lightning) and check their coordinates with this:

JASS:
// Returns a boolean that tells whether the point is inside a rectangle.
    // (px , py) = Point to check
    // (cx , cy) = lower left corner of the rect
    // (ax , ay) = upper left corner
    // (bx , by) = lower right corner
    function IsPointInRect takes real px , real py , real cx , real cy , real ax , real ay , real bx , real by returns boolean        
        local real dot1 = (px-cx)*(ax-cx) + (py-cy)*(ay-cy)
        local real dot2 = (ax-cx)*(ax-cx) + (ay-cy)*(ay-cy)
        local real dot3 = (px-cx)*(bx-cx) + (py-cy)*(by-cy)
        local real dot4 = (bx-cx)*(bx-cx) + (by-cy)*(by-cy)
        
        return dot1 >= 0 and dot1 <= dot2 and dot3 >= 0 and dot3 <= dot4
    endfunction

If that returns true, then the units collides with the lightning. With this solution, it's possible that very large models seem to collide with the lightning graphically, but is not colliding due to the center of the unit being far away from the lightning.
 
Last edited:
Level 9
Joined
Apr 19, 2011
Messages
447
Hi.

First of all, I must apologize for the large time I have passed without entering the forum. I have been studying and I hadn't any free time.
I looked your advise...

@TLI_Inferno: What I wanted to do is NOT a lighting ball, it's a line. Anyway, thanks for answering so much.
@D4RK_G4ND4LF: I checked your map, and I have to say that the effect is awesome. Sadly, I fear that I can't understand how that system works. Sorry, I'm still a bit noob, I suppose.
@Maker: I think that your idea is the most appropiate for what I want to do.

Anyway, in all of this time, I have been thinking about this lightning effect. Now I used your ideas, and finally I have been able to create a spell. It's not wonderful, but at least it does something that it's near enough to what I wanted to do.

I used mostly the base idea that Maker gave, so I think that I must give him a +rep.

Thanks for all of your advise.

Regards
 
Level 15
Joined
Mar 8, 2009
Messages
1,649
sorry for invading a thread, but do I get it right and these examples make an effect similar to Diablo III Disintegrate/Ray of Frost?
 
Status
Not open for further replies.
Top