Gui chain lightning

This is where all discussion of WC3 mapmaking should be held. This forum exists particularly for mapmaking needs. If you have a question on how something works or have need for some code review, this is the place to put it.
Post Reply
User avatar
Oxygen
Grandmaster of Grammar
Posts: 1281
Joined: Thu Jan 17, 2008 6:14 pm

Gui chain lightning

Post by Oxygen » Wed Sep 22, 2010 6:23 pm

Hello, you all probably know that I'm the worst triggered of all time. I'm trying to make a GUI chain lightning that would allow the chain to bounce on the same target multiple times. My plan was to, initially:

Create a dummy on spell cast, which would cast a first chain.
At this dummy's chain target, another dummy would cast chain on the closest target

This is where I block

Other info: Max 5 bounces

How else should I proceed THAT IS SIMPLE ENOUGH for me to understand?

Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Re: Gui chain lightning

Post by Greenspawn » Thu Sep 23, 2010 10:48 pm

When the closest target takes damage, create another dummy to cast on the new closest target. Repeat until 5 chains have been cast.
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

User avatar
Oxygen
Grandmaster of Grammar
Posts: 1281
Joined: Thu Jan 17, 2008 6:14 pm

Re: Gui chain lightning

Post by Oxygen » Sun Sep 26, 2010 1:14 pm

how do you call "closest target"?

User avatar
Fledermaus
Keeper of the Keys
Posts: 354
Joined: Fri Feb 01, 2008 9:55 am
Location: New Zealand
Contact:

Re: Gui chain lightning

Post by Fledermaus » Sun Sep 26, 2010 9:26 pm

You write your own function in jass ^^

Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Re: Gui chain lightning

Post by Greenspawn » Fri Oct 01, 2010 1:24 am

Do something like this. Check how many units are within some range (let's say 600) of the unit that got hit. If a unit is outside this area, it cannot be hit. If there is more than one unit, check all the distances from the new source unit to the units in range. Find the unit with the smallest distance, and that's the new target.
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

Soul_Reaver
Revenent of the Replies
Posts: 332
Joined: Thu Feb 14, 2008 3:27 pm
Location: Hungary
Contact:

Re: Gui chain lightning

Post by Soul_Reaver » Tue Jan 04, 2011 12:14 pm

I won't write triggers for you as this thread is a bit old and you might not be interested in this at all by now. But if you do insist, I'll of course try to help you out with triggers as well.

You can get the closest unit by setting all units that match the given conditions within maximum range of your target to a Temporary Group (TempGroup) and then create a Temporary Unit (TempUnit) and a Temporary Real. (TempReal)
You set TempReal to maximum range and then pick all units within your TempGroup. For each unit, you check if the unit is closer to the target then the actual TempReal. If it is, you set TempReal to the distance between the target and picked unit and set TempUnit to picked unit.

So, let's say I have three units within 1000 of my hero, 200, 300, 500 range away. I set TempReal to 1000.
If I pick all of them, it checks one of them. For example, it checks the unit that is 300 range away first. Since 300 is less than 1000, it will set the new TempReal to 300 and registers this unit as TempUnit.
Then, it checks another one, for example the unit that is 500 range away. Since 500 is more than 300 (which is your current TempReal) it won't do anything.
Then, it checks the unit that is 200 away. Since 200 is less then 300, it will set TempReal to 200 and register this unit as TempUnit.
Then, you can use TempUnit for whatever you wish and the clear it for the next use.

I hope it helps.

As for the chain lightning, use registration. Register your caster as Lightning_Owner and set Lightning_Bounces_Left to 5. Get a target per the method described above, create the dummy you wanted, do a single hit chain lightning on it, save your target as Lightning_Current_Target and then start a timer for the next bounce. When it finishes, get another unit near Lightning_Current_Target, set Bounces_Left to Bounces Left - 1. Repeat until you run out of bounces or can't pick a new target.

Post Reply

Return to “Custom Map Creation”