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

[Trigger] Help me make this MUI

Status
Not open for further replies.

SpasMaster

Hosted Project: SC
Level 24
Joined
Jan 29, 2010
Messages
1,994
Hello, Hive!

I am working on a Castle Fight based project. (For those who are not familiar: Castle Fight is a game where you create buildings at your base which spawn mobs that automatically attack the enemy Castle. The idea is to overrun and outsmart your enemy with strategy. Units cannot be controlled.)
So I wanted to create this unit called Warlock. What it should do is:
1.) Get in melee range and cast its spell which does aoe damage.
2.) Move back a bit and hold position until the spell is ready to be cast again (CD is 12 secs)
3.) Return to its automatic path towards the enemy castle.

All of this should be done automatically since the player has no control over the unit. Alright, so I started working on this and I cannot make the whole thing MUI, so this is what I need help with. Here is how I proceeded with coding this, you can read step by step and follow the triggers:
1.) The Warlock has an auto-cast "Parasite" dummy which casts the AoE.
2.) Chamber of Darkness is a dummy spell which simply gives him a visual effect to let the player know he has the ability ready. When he casts the spell (1.), it gets removed.
3.) The If/Then/Else conditions order the Warlock to move back to his base for a bit, until ordered to hold position. The order (as you can see in the trigger) is not move, but is instead Serpent Ward based, because the move command is let's say... disabled in this map, to make the units uncontrollable.
4.) Next, after a 5,50 seconds wait (Non-MUI right there) he has to stop. He stops by casting that same Serpent Ward dummy spell. That same Serpent Ward spell summons an invisible dummy unit with expiration time of 6 seconds.
5.) Moving to second trigger. When the dummy unit expires, the Warlock is issued an order to once more attack-move to the enemy base and receives back his visual dummy ability - Chamber of Darkness to let the player know his spell is ready.
[trigger=""]Chamber of Darkness
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Parasite (Warlock)
Actions
Set Warlock = (Triggering unit)
Unit - Remove Chamber of Darkness from (Triggering unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
(Owner of (Triggering unit)) Equal to Player 2 (Blue)
(Owner of (Triggering unit)) Equal to Player 3 (Teal)
(Owner of (Triggering unit)) Equal to Player 4 (Purple)
Then - Actions
Set AttackPoint_Green = (Center of Castle West <gen>)
Unit - Order (Triggering unit) to Orc Shadow Hunter - Serpent Ward AttackPoint_Green
Custom script: call RemoveLocation (udg_AttackPoint_Green)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Owner of (Triggering unit)) Equal to Player 7 (Green)
(Owner of (Triggering unit)) Equal to Player 8 (Pink)
(Owner of (Triggering unit)) Equal to Player 9 (Gray)
(Owner of (Triggering unit)) Equal to Player 10 (Light Blue)
Then - Actions
Set AttackPoint_Red = (Center of Castle East <gen>)
Unit - Order (Triggering unit) to Orc Shadow Hunter - Serpent Ward AttackPoint_Red
Custom script: call RemoveLocation (udg_AttackPoint_Red)
Else - Actions
Wait 5.50 game-time seconds
Set WarlockStop_Point = (Position of (Triggering unit))
Unit - Order Warlock to Orc Shadow Hunter - Serpent Ward WarlockStop_Point
Custom script: call RemoveLocation (udg_WarlockStop_Point)
[/trigger]

[trigger=""]Chamber of Darkness 2
Events
Unit - A unit Dies
Conditions
(Unit-type of (Triggering unit)) Equal to Dummy (Warlock)
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
(Owner of (Triggering unit)) Equal to Player 2 (Blue)
(Owner of (Triggering unit)) Equal to Player 3 (Teal)
(Owner of (Triggering unit)) Equal to Player 4 (Purple)
Then - Actions
Set AttackPoint_Red = (Center of Castle East <gen>)
Unit - Order (Triggering unit) to Move To AttackPoint_Red
Custom script: call RemoveLocation (udg_AttackPoint_Red)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Owner of (Triggering unit)) Equal to Player 7 (Green)
(Owner of (Triggering unit)) Equal to Player 8 (Pink)
(Owner of (Triggering unit)) Equal to Player 9 (Gray)
(Owner of (Triggering unit)) Equal to Player 10 (Light Blue)
Then - Actions
Set AttackPoint_Green = (Center of Castle West <gen>)
Unit - Order (Triggering unit) to Move To AttackPoint_Green
Custom script: call RemoveLocation (udg_AttackPoint_Green)
Else - Actions
Unit - Add Chamber of Darkness to (Triggering unit)
[/trigger]


All of this may sound complex, so I'll try to sum up what I am trying to accomplish here.
-Warlock goes in melee range, casts his Parasite spell.
-He is ordered to move back for 5,5 seconds and then Hold Position.
-He stays like that for 6 more seconds.
-By that time his spell is recharged and he goes back against the enemy once more.

All of that should be MUI. Thanks in advance.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Are the paths the units take straight lines? If that is the case, you can calculate where they should stop (5.5 * their move speed towards their own castle). Tell them to cast the serpent ward spell at that location. This will cause them to walk there and then stop. You don't need to keep track of the time.

Have you tested this trigger? It seems that the second one will not work properly. The dummy dies and then you tell the triggering unit (the dead dummy) to move to the enemy castle and add the ability. This will basically do nothing.

Instead, you could have the serpent ward spell have a casting time of 6 seconds so they just stand there casting it for that time. When they "start the effect of " that ability, it will be 6 seconds later. Have the dummy unit spawned by the serpent ward spell just die instantly or choose a spell that doesn't spawn a unit.
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,267
The second trigger seems kinda wierd to me, as adding the ability to the dummy which is the triggering unit, not the warlock itself (That's how its look like, unless the dummy is the warlock). Is that your intention? Or is the dummy handled in a different trigger you are not showing?


About making MUI with waits:


Add
  • Custom script: local unit udg_Warlock
as the very first action, before
  • Set Warlock = (Triggering unit)
At the very end of your trigger add this to prevent local unit mem leak

  • Custom script: set udg_Warlock = null
That should make chamber of darkness trigger MUI, even with the wait. This is a neat trick that makes the global variable local variable within the trigger.

locals must be declared at very top always and must be nulled at the end of the triggers (except reals and integers).
 
Level 13
Joined
Mar 29, 2012
Messages
542
You need to associate the warlock to its dummy.
Use a Unit Indexer system. Maybe Bribe's, just a c&p installation.

You need an array variable.
  • When you create the dummy, store the caster into that variable with the custom value of the dummy as the array.
  • At the second trigger, use that variable as the (Triggering unit).
 

SpasMaster

Hosted Project: SC
Level 24
Joined
Jan 29, 2010
Messages
1,994
Are the paths the units take straight lines? If that is the case, you can calculate where they should stop (5.5 * their move speed towards their own castle). Tell them to cast the serpent ward spell at that location. This will cause them to walk there and then stop. You don't need to keep track of the time.
Yes, they are. Can you elaborate a bit more on how to make this?
186388-albums6678-picture99827.png

Have you tested this trigger? It seems that the second one will not work properly. The dummy dies and then you tell the triggering unit (the dead dummy) to move to the enemy castle and add the ability. This will basically do nothing.
Yes, sorry, my bad. I did the triggers in a rush, just so I can post them here. I have updated them below.
Instead, you could have the serpent ward spell have a casting time of 6 seconds so they just stand there casting it for that time. When they "start the effect of " that ability, it will be 6 seconds later. Have the dummy unit spawned by the serpent ward spell just die instantly or choose a spell that doesn't spawn a unit.
Did that.
About making MUI with waits:


Add
  • Custom script: local unit udg_Warlock
as the very first action, before
  • Set Warlock = (Triggering unit)
At the very end of your trigger add this to prevent local unit mem leak

  • Custom script: set udg_Warlock = null
That should make chamber of darkness trigger MUI, even with the wait. This is a neat trick that makes the global variable local variable within the trigger.

locals must be declared at very top always and must be nulled at the end of the triggers (except reals and integers).
Did all that.
You need to associate the warlock to its dummy.
Use a Unit Indexer system. Maybe Bribe's, just a c&p installation.

You need an array variable.
  • When you create the dummy, store the caster into that variable with the custom value of the dummy as the array.
  • At the second trigger, use that variable as the (Triggering unit).
Hmm.. isn't a whole system a bit too much for one spell only? I guess I will need it again in the future. But currently I only need to get this going. Can we try to do it without an indexing system?

EDIT: I made it work like that:
[trigger=""]Chamber of Darkness
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Parasite (Warlock)
Actions
Custom script: local unit udg_Warlock
Set Warlock = (Triggering unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
(Owner of (Triggering unit)) Equal to Player 2 (Blue)
(Owner of (Triggering unit)) Equal to Player 3 (Teal)
(Owner of (Triggering unit)) Equal to Player 4 (Purple)
Then - Actions
Set WarlockMove_PointRed = (Center of Castle West <gen>)
Unit - Order (Triggering unit) to Orc Shadow Hunter - Serpent Ward WarlockMove_PointRed
Custom script: call RemoveLocation (udg_WarlockMove_PointRed)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Owner of (Triggering unit)) Equal to Player 7 (Green)
(Owner of (Triggering unit)) Equal to Player 8 (Pink)
(Owner of (Triggering unit)) Equal to Player 9 (Gray)
(Owner of (Triggering unit)) Equal to Player 10 (Light Blue)
Then - Actions
Set WarlockMove_PointGreen = (Center of Castle East <gen>)
Unit - Order (Triggering unit) to Orc Shadow Hunter - Serpent Ward WarlockMove_PointGreen
Custom script: call RemoveLocation (udg_WarlockMove_PointGreen)
Else - Actions
Unit - Remove Chamber of Darkness from (Triggering unit)
Wait 5.50 game-time seconds
Set WarlockStop_Point = (Position of (Triggering unit))
Unit - Order Warlock to Orc Shadow Hunter - Serpent Ward WarlockStop_Point
Custom script: call RemoveLocation (udg_WarlockStop_Point)
Custom script: set udg_Warlock = null
[/trigger]
[trigger=""]Chamber of Darkness 2
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Warlock Move
(Level of Chamber of Darkness for (Triggering unit)) Equal to 0
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
(Owner of (Triggering unit)) Equal to Player 2 (Blue)
(Owner of (Triggering unit)) Equal to Player 3 (Teal)
(Owner of (Triggering unit)) Equal to Player 4 (Purple)
Then - Actions
Set AttackPoint_Red = (Center of Castle East <gen>)
Unit - Order (Triggering unit) to Attack-Move To AttackPoint_Red
Custom script: call RemoveLocation (udg_AttackPoint_Red)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Owner of (Triggering unit)) Equal to Player 7 (Green)
(Owner of (Triggering unit)) Equal to Player 8 (Pink)
(Owner of (Triggering unit)) Equal to Player 9 (Gray)
(Owner of (Triggering unit)) Equal to Player 10 (Light Blue)
Then - Actions
Set AttackPoint_Green = (Center of Castle West <gen>)
Unit - Order (Triggering unit) to Attack-Move To AttackPoint_Green
Custom script: call RemoveLocation (udg_AttackPoint_Green)
Else - Actions
Unit - Add Chamber of Darkness to (Triggering unit)
[/trigger]
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,243
*There is no point to shadow the global. Triggering unit works like a local variable and it is MUI.
*No need to have separate variables for the points
*No need to have so many OR conditions

And these you can do yourself:
*You might not need to test if the player number is over 5
*I recommend setting the repeatedly used points, castle west and east to variables at map initialization and then never removing them

[trigger=""]Chamber of Darkness
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Parasite (Warlock)
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player number of (Triggering Player)) < 5
Then - Actions
Set Point = (Center of Castle West <gen>)
Unit - Order (Triggering unit) to Orc Shadow Hunter - Serpent Ward Point
Custom script: call RemoveLocation (udg_Point)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player number of (Triggering Player)) > 5
Then - Actions
Set Point = (Center of Castle East <gen>)
Unit - Order (Triggering unit) to Orc Shadow Hunter - Serpent Ward Point
Custom script: call RemoveLocation (udg_Point)
Else - Actions
Unit - Remove Chamber of Darkness from (Triggering unit)
Wait 5.50 game-time seconds
Set Point = (Position of (Triggering unit))
Unit - Order Warlock to Orc Shadow Hunter - Serpent Ward Point
Custom script: call RemoveLocation (udg_WarlockStop_Point)
[/trigger]
 
Status
Not open for further replies.
Top