• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Blink Strike! Help Me!

Status
Not open for further replies.
Level 4
Joined
Mar 18, 2007
Messages
31
I need some help making a spell base for me spell
Can any one make any suggestions?
:infl_thumbs_up:

This is the Trigger.....
Event:
Unit - A unit Starts the effect of an ability
Conditions:
(Ability being cast) Equal to Spiritual Rage
Actions:
For each (Integer A) from 1 to ((Level of Spiritual Rage for (Triggering unit)) x 5), do (Actions)
Loop - Actions
Set SpiritualRageTarget = (Random unit from (Units within 512.00 of (Position of (Triggering unit)) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpiritualRageTarget Equal to No unit
Then - Actions
Skip remaining actions
Else - Actions
Lightning - Create a lightning effect Magic Leash (Position of (Triggering unit)) (Position of SpiritualRageTarget)
Unit - Move (Triggering unit) instantly to (Position of SpiritualRageTarget)
Unit - Make (Triggering unit) face SpiritualRageTarget over 0.00 seconds
Animation - Play (Triggering unit)'s attack animation
Unit - Order (Triggering unit) to damage SpiritualRageTarget for (((Power(3.00, (Real((Level of Spiritual Rage for (Triggering unit)))))) x (10.00 x (Random real number between 1.00 and 3.00))) + 1.00) using attack type Chaos and damage type Normal.
Wait 0.25 seconds
Lightning - Destroy (Last created lightning effect)
Set SpiritualRageTarget = No unit
Unit Group - Destroy unit group (Last created unit group)

or U could Call this Ominislash
 
Last edited:
Level 11
Joined
Oct 13, 2005
Messages
233
From the looks of things, the ability is able to hit the same unit multiple times. You are also using TriggerSleepAction (wait) inside of a loop and referring to "last created lightning effect". To fix that, I would suggest having an array you could set each lightning effect to and destroy them all at the end of the trigger. But that would then make the hero strike each unit instantly. Since this isn't JASS, I can't suggest using timers so you'll probably have to stick with the wait situation (though I do still suggest using a variable to hold the lightning effect) Just use the local variable trick in GUI, set the variable to the lightning, wait, and then destroy it. I've also heard that PolledWait(wait game-time seconds, I think) is more accurate than TriggerSleepAction(wait).

As for the first problem, hitting the same unit multiple times. My suggestion is to put all enemies in range inside a group and then pick the units to be attacked from that group. When the unit is attacked, you then remove that unit from the group so it can't be hit again. You will need to destroy the group at the end of the trigger, so "skip remaining actions" will cause a leak because the group wouldn't have been removed. Instead, destroy the group before skipping the remaining actions.

Also, what's the point of the "Unit Group - Destroy unit group(Last created unit group)"? It won't destroy the group you're currently creating and picking units from every loop because the GetUnitsInRangeOfLocMatching function doesn't set bj_lastCreatedGroup variable to the value it returns. Therefore you're still leaking and you might also be destroying other groups created in other triggers.

If anything wasn't clear, please say so.
 
Level 4
Joined
Mar 18, 2007
Messages
31
As for the first problem, hitting the same unit multiple times. My suggestion is to put all enemies in range inside a group and then pick the units to be attacked from that group. When the unit is attacked, you then remove that unit from the group so it can't be hit again. You will need to destroy the group at the end of the trigger, so "skip remaining actions" will cause a leak because the group wouldn't have been removed. Instead, destroy the group before skipping the remaining actions.

I dont get this srry but im new to making trigger spells
 
Level 11
Joined
Oct 13, 2005
Messages
233
With the current code that you have, it's possible for you to attack the same unit multiple times (unless you want that). To fix this, create a unit group that contains all enemy units that could possibly be hit (in your case, units within 512 range of the caster that are enemies and alive). You will then need a variable to store this group. (This should all be done outside of the loop) Now, inside the loop you should pick a random unit from this group you've just created. You then do all your usual actions and at the end of the loop, remove the picked unit from the group. This will make it so the unit cannot be picked again.

Now for the second part. Unless you don't care about memory leaks, you'll need to call DestroyGroup on the group after the loop. Now, I see in your code there's the line "Skip remaining actions". That line ends the trigger, so the loop won't be able to completely finish and so the group won't be destroyed. To fix that, simply destroy the group before skipping the remaining actions.

Hopefully that clears things up.
 
Level 11
Joined
Jul 12, 2005
Messages
764
Do you need suggestions only to improve the code, or do you have problems with it? Cause i don't really see anything that would not work.

wyrmlord, 'wait' is not a problem here, as it is not a 'Pick units..' loop, only a simple one. Also, this "Polled wait is better than Wait" is only a rumor, i have proved it in a test map, it's somewhere on the forum in a thread as an attachment.

Bookskill, to improve the trigger:
1. Instead of this:
If - Conditions
SpiritualRageTarget Equal to No unit
Then - Actions
Skip remaining actions
Else - Actions
<do the actions here>

Use this:

If - Conditions
SpiritualRageTarget NOT Equal to No unit
Then - Actions
<do the actions here>
Else - Actions

2. Store the lightning effect into a variable, and destroy that one, as 'Last created lightning' loses its references after a Wait.

3. Learn how to remove leaks, and eliminate them. At this point, i see 4 point, and 1 group leak inside the loop. (25-75 in total per each cast)
 
Status
Not open for further replies.
Top