• 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.

Some variable questions and Unit Groups

Status
Not open for further replies.
Level 2
Joined
Jul 7, 2005
Messages
10
This is my first time making a Trigger Enhanced ablity and I was making a Ability bsed on StarFall that turned all units or effected or killed by this ability will spawn a Skeleton Warrior.

here's How My ability Initiates (Trigger #1).

Event:
Unit - A unit begins Casting an Ability.
Condition:
Ability being Cast = to "Name of the Ability"
Casting Unit = "Name of the Caster"
Action:
Unit Group - Pick Every Unit within 1000 of Position of Casting Unit and Add Picked Unit to "Unit Group01"
Set "Caster" = Casting Unit

Here's the Effect(Trigger #2):

Event:
-Unit - A unit dies
Condition:
-Dying Unit is in "Unit Group01"
-Dying Unit is within 1000 of Position "Caster" <-(A varaible)
-Dying Unit belongs to the Enemy of the Owner of "Caster".
Action:
-Make Dying Unit explode on Death
-Remove Dying Unit from "Group01"
-Create 1 Skeleton Warrior for Owner of "Caster" at Position of Dying unit faving Default Building Facing Degrees
-Add 30 Seconds to Generic Experation Timer for Last create unit.

If the Caster dies or stops casting (Trigger #3):

Event:
Unit - A Unit finishes casting an ability.
Condition:
Casting Unit equals to "Name of caster"
Ability being Cast Equal to "Name of Ability"
Actions:
Set "Caster" = No Unit
Unit Group - Remove All units from "Group01"

The Ability works perfectly...but I've only tested it with 1 player casting it. My question is, do I need a set of Variables and Triggers for Each Player so they dont share the same Unit group and Caster Variable? if Someone could help it, it would be great.
 
Level 2
Joined
Jul 7, 2005
Messages
10
I'm Sorry, I dont quite understand. You mean use Array for BOTH the group variables and the Caster variable, or just the one of them? And...as for the Loop...i'm not sure what that is. Im sorry, i've never used triggered before in WC III...im more used to the simple StarCraft Triggers o_o
 
Level 7
Joined
Feb 15, 2005
Messages
183
I am not sure how advanced you want to get with your triggers, but for what you are asking, You want local variables. You will have to make some custom scripts. But what the local variables do, is create new variables for each instance of your trigger ONLY not for other triggers. This will be a problem when trying to carry over those variables across the 3 triggers.

The easiest way to do it with the way your spell is setup is to use arrays for your variables. If you arn't very familiar with arrays. take a look at the tut i wrote about them. Its not that great, but maybe it will help.

http://www.wc3sear.ch/viewtopic.php?t=11576
 
Level 2
Joined
Jul 7, 2005
Messages
10
Thanks for the previous help, but since this spell effect is controlled by 3 triggers, i had to make a set of triggers for everyone, even using the array. I did try to make 1 single set that controls it for all players, but it didnt work. It went like this.

Event:
-A Unit begins casting an ability.

Condition:
-Ability being Cast = to "Soul Consumption"
-Unit-Casting Unit = to "Necromancer"

Action:
If,Then,Else Multiple functions:

If:
-Owner of Casting Unit = to player 1
Then:
-Unit Group-Pick Every unit withing 1000 of Casting unit and add them to "SpellGroup"[1]
-Set "SpellCaster"[1] = to Casting Unit
Else:
Do nothing
-Owner of Casting Unit = to player 2
Then:
-Unit Group-Pick Every unit withing 1000 of Casting unit and add them to "SpellGroup"[2]
-Set "SpellCaster"[1] = to Casting Unit
Else:
Do nothing
-Owner of Casting Unit = to player 3
Then:
-Unit Group-Pick Every unit withing 1000 of Casting unit and add them to "SpellGroup"[3]
-Set "SpellCaster"[1] = to Casting Unit
Else:
-Do nothing

and so on for 12 players....

Here's the original Effects trigger:

Event:
A Unit dies

Condition:
-Dying Unit is a structure = to false
-Dying Unit is an ancient = to false
-Dying Unit is Mechanical = to false

Actions:
If, Then, Else Multiple Functions:

If:
-Dying Unit is in unit group "SpellGroup"[1]
Then:
-Use Special effect "Raise Dead" at the origin of Dying Unit.
-Create 1 Skeleton Warrior for player 1 at the position of dying unit facing default building angle.
-Add 30 seconds to generic experation timer for last created unit.
Else:
-Do nothing

If:
-Dying Unit is in unit group "SpellGroup"[2]
Then:
-Use Special effect "Raise Dead" at the origin of Dying Unit.
-Create 1 Skeleton Warrior for player 2 at the position of dying unit facing default building angle.
-Add 30 seconds to generic experation timer for last created unit.
Else:
-Do nothing

If:
-Dying Unit is in unit group "SpellGroup"[3]
Then:
-Use Special effect "Raise Dead" at the origin of Dying Unit.
-Create 1 Skeleton Warrior for player 3 at the position of dying unit facing default building angle.
-Add 30 seconds to generic experation timer for last created unit.
Else:
-Do nothing

and so on...

this didnt work for some reason. Maybe because i put "Else- do nothing" at the end.

I changed all the triggers so there is 1 set for each player, though still using the same arrayed varaibles. However, there is one thing that i cant get to work.

I have a action that adds all only enemy units to my spellgroup so that only they are effected.

it does like this.
Pick Every Unit withing 1000 of casting unit and add them to SpellGroup[1] matching the condition that the "PICKED unit" is the enemy of player 1.

this added ALL the units in the area regardless of their allegiance.

I changed it to:
Pick Every Unit withing 1000 of casting unit and add them to SpellGroup[1] matching the condition that the "MATCHING unit" is the enemy of player 1.

but then it would not work, i think it didnt add ANY units. Am I doing something wrong?

To better explain, here is what the triggers looks like. (there is one for each player)
------------------------------------------------------
Initialization Trigger:
Event:
-A Unit beings casting an ability.
Conditions:
-Ability Being Cast = to Soul Consumption
-Unit-Casting Unit = to Necromancer.
Actions:
-Set SpellCaster[1] = to casting unit
-Pick Every Unit within 1000 of Casting Unit and add "picked unit" matching the the "Picked Unit" is an enemy of player 1 and do actions:
--Loop:
---Add Picked Add "Picked Unit" to SpellGroup[1]
---Make Picked Unit explode on death.

(I later changed all the PICKED UNIT to MATCHING UNIT, but then the spell would not work)
------------------------------------------------------
Effect Trigger:
Event:
-A unit dies

Conditions:
-Dying Unit is a Structure = false
-Dying Unit is a Mechanical = false
-Dying Unit is an Ancient = false
-Dying Unit is in unit group "SpellGroup"[1]
-Dying Unit is within 1000 of "SpellCaster"[1]

Actions:
-Use Special Effect of Raise dead at position of dying unit (doesnt work for some reason).
-Create 1 skeleton warrior for player 1 facing 1+1 degrees.
-Add 30 seconds to Raised Dead experation timer for last created unit.
-Remove Dying Unit from SpellGroup[1]
-Remove Dying Unit from SpellGroup[2]
-Remove Dying Unit from SpellGroup[3]
-and so on...
------------------------------------------------------
Cut Short Trigger:
Event:
-A Unit Dies
Condition:
-Dying Unit = SpellCaster[1]
Action:
-Unit Group-remove all units in SpellGroup[1]

(I assumed that this will take them all out of the group and stop the effect if they died, but it didnt)
------------------------------------------------------
Finished Trigger:
Event:
-A Unit finishes casting an ability
Condition:
-Ability Being cast = Soul Consumption
Action:
-Unit Group-remove all units in SpellGroup[1]

(I assumed that this will take them all out of the group and stop the effect if they died. I'm not so sure about this one yet.)
------------------------------------------------------

If someone can tell me the reason why my triggers isnt work as well as it should and/or give me some hints and tips about how to make these triggersm it would be much appreciated.
 
Status
Not open for further replies.
Top