• 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] Need help reducing trigger size

Status
Not open for further replies.
Level 2
Joined
Apr 18, 2007
Messages
12
I was wondering if this trigger could be reduced down a bit.


  • FireStone
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Fire Stone
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • 133-Eevee 0098 <gen> Equal to (Triggering unit)
        • Then - Actions
          • Set Items[0] = (Item carried by (Triggering unit) in slot 1)
          • Set Items[1] = (Item carried by (Triggering unit) in slot 2)
          • Set Items[2] = (Item carried by (Triggering unit) in slot 3)
          • Set Items[3] = (Item carried by (Triggering unit) in slot 4)
          • Set Items[4] = (Item carried by (Triggering unit) in slot 5)
          • Set Items[5] = (Item carried by (Triggering unit) in slot 6)
          • Unit - Remove (Triggering unit) from the game
          • Set Temp_Point = (Position of (Triggering unit))
          • Unit - Create 1 136-Flareon for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
          • Custom script: call RemoveLocation (udg_Temp_Point)
          • Hero - Set (Last created unit) Hero-level to (Hero level of (Triggering unit)), Show level-up graphics
          • Hero - Give Items[0] to (Last created unit)
          • Hero - Give Items[1] to (Last created unit)
          • Hero - Give Items[2] to (Last created unit)
          • Hero - Give Items[3] to (Last created unit)
          • Hero - Give Items[4] to (Last created unit)
          • Hero - Give Items[5] to (Last created unit)
          • Item - Remove (Item being manipulated)
          • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • 037-Vulpix 0029 <gen> Equal to (Triggering unit)
        • Then - Actions
          • Set Items[0] = (Item carried by (Triggering unit) in slot 1)
          • Set Items[1] = (Item carried by (Triggering unit) in slot 2)
          • Set Items[2] = (Item carried by (Triggering unit) in slot 3)
          • Set Items[3] = (Item carried by (Triggering unit) in slot 4)
          • Set Items[4] = (Item carried by (Triggering unit) in slot 5)
          • Set Items[5] = (Item carried by (Triggering unit) in slot 6)
          • Unit - Remove (Triggering unit) from the game
          • Set Temp_Point = (Position of (Triggering unit))
          • Unit - Create 1 038-Ninetails for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
          • Custom script: call RemoveLocation (udg_Temp_Point)
          • Hero - Set (Last created unit) Hero-level to (Hero level of (Triggering unit)), Show level-up graphics
          • Hero - Give Items[0] to (Last created unit)
          • Hero - Give Items[1] to (Last created unit)
          • Hero - Give Items[2] to (Last created unit)
          • Hero - Give Items[3] to (Last created unit)
          • Hero - Give Items[4] to (Last created unit)
          • Hero - Give Items[5] to (Last created unit)
          • Item - Remove (Item being manipulated)
          • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • 058-Growlithe 0140 <gen> Equal to (Triggering unit)
        • Then - Actions
          • Set Items[0] = (Item carried by (Triggering unit) in slot 1)
          • Set Items[1] = (Item carried by (Triggering unit) in slot 2)
          • Set Items[2] = (Item carried by (Triggering unit) in slot 3)
          • Set Items[3] = (Item carried by (Triggering unit) in slot 4)
          • Set Items[4] = (Item carried by (Triggering unit) in slot 5)
          • Set Items[5] = (Item carried by (Triggering unit) in slot 6)
          • Unit - Remove (Triggering unit) from the game
          • Set Temp_Point = (Position of (Triggering unit))
          • Unit - Create 1 059-Arcanine for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
          • Custom script: call RemoveLocation (udg_Temp_Point)
          • Hero - Set (Last created unit) Hero-level to (Hero level of (Triggering unit)), Show level-up graphics
          • Hero - Give Items[0] to (Last created unit)
          • Hero - Give Items[1] to (Last created unit)
          • Hero - Give Items[2] to (Last created unit)
          • Hero - Give Items[3] to (Last created unit)
          • Hero - Give Items[4] to (Last created unit)
          • Hero - Give Items[5] to (Last created unit)
          • Item - Remove (Item being manipulated)
          • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
        • Else - Actions
 
Level 5
Joined
Nov 14, 2004
Messages
159
you could use "for Integer A, 1 to 6"

like change

  • Set Items[0] = (Item carried by (Triggering unit) in slot 1)
  • Set Items[1] = (Item carried by (Triggering unit) in slot 2)
  • Set Items[2] = (Item carried by (Triggering unit) in slot 3)
  • Set Items[3] = (Item carried by (Triggering unit) in slot 4)
  • Set Items[4] = (Item carried by (Triggering unit) in slot 5)
  • Set Items[5] = (Item carried by (Triggering unit) in slot 6)
to

  • For each (Integer A) from 1 to 6, do (Set Items[((Integer A) - 1)] = (Item carried by (Triggering unit) in slot (Integer A)))
 
Level 2
Joined
Apr 18, 2007
Messages
12
ah thanks, is there a possible way for me to reduce the whole thing down a little bit more? And how would I do the give items back to the unit the same way?
 
Level 2
Joined
Apr 18, 2007
Messages
12
k, thanks a lot. Could this be reduced down some more?And improved?

  • FireStone
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Fire Stone
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • 133-Eevee 0098 <gen> Equal to (Triggering unit)
        • Then - Actions
          • For each (Integer A) from 1 to 6, do (Set Items[((Integer A) - 1)] = (Item carried by (Triggering unit) in slot (Integer A)))
          • Unit - Remove (Triggering unit) from the game
          • Set Temp_Point = (Position of (Triggering unit))
          • Unit - Create 1 136-Flareon for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
          • Custom script: call RemoveLocation (udg_Temp_Point)
          • Hero - Set (Last created unit) Hero-level to (Hero level of (Triggering unit)), Show level-up graphics
          • For each (Integer A) from 1 to 6, do (Hero - Give Items[((Integer A) - 1)] to (Last created unit))
          • Item - Remove (Item being manipulated)
          • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • 037-Vulpix 0029 <gen> Equal to (Triggering unit)
        • Then - Actions
          • For each (Integer A) from 1 to 6, do (Set Items[((Integer A) - 1)] = (Item carried by (Triggering unit) in slot (Integer A)))
          • Unit - Remove (Triggering unit) from the game
          • Set Temp_Point = (Position of (Triggering unit))
          • Unit - Create 1 038-Ninetails for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
          • Custom script: call RemoveLocation (udg_Temp_Point)
          • Hero - Set (Last created unit) Hero-level to (Hero level of (Triggering unit)), Show level-up graphics
          • For each (Integer A) from 1 to 6, do (Hero - Give Items[((Integer A) - 1)] to (Last created unit))
          • Item - Remove (Item being manipulated)
          • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • 058-Growlithe 0140 <gen> Equal to (Triggering unit)
        • Then - Actions
          • For each (Integer A) from 1 to 6, do (Set Items[((Integer A) - 1)] = (Item carried by (Triggering unit) in slot (Integer A)))
          • Unit - Remove (Triggering unit) from the game
          • Set Temp_Point = (Position of (Triggering unit))
          • Unit - Create 1 059-Arcanine for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
          • Custom script: call RemoveLocation (udg_Temp_Point)
          • Hero - Set (Last created unit) Hero-level to (Hero level of (Triggering unit)), Show level-up graphics
          • For each (Integer A) from 1 to 6, do (Hero - Give Items[((Integer A) - 1)] to (Last created unit))
          • Item - Remove (Item being manipulated)
          • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
        • Else - Actions
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
For full efficency you will have to use JASS, since GUI makes unescary scripts for the dumbest things like if actions. If you do not really care about efficenty, then do not really try to make it more efficent since it can never be as efficent as pure JASS can (in size).
 
Level 11
Joined
Oct 13, 2005
Messages
233
You're doing a lot of the same actions that is unnecessary. You're replicating all the code inside each if/then/else block where only 1 line of code is different for each block which is creating the hero. You should do all the pre-creating hero actions before the if/then statements. Then after those statements you do the remaining actions.
 
Level 11
Joined
Jul 12, 2005
Messages
764
Yeah, wyrmlord is right.
He means sthg like this:
  • FireStone
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Fire Stone
    • Actions
      • For each (Integer A) from 1 to 6, do (Set Items[((Integer A) - 1)] = (Item carried by (Triggering unit) in slot (Integer A)))
      • Unit - Remove (Triggering unit) from the game
      • Set Temp_Point = (Position of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • 133-Eevee 0098 <gen> Equal to (Triggering unit)
        • Then - Actions
          • Unit - Create 1 136-Flareon for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
          • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • 037-Vulpix 0029 <gen> Equal to (Triggering unit)
            • Then - Actions
              • Unit - Create 1 038-Ninetails for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
              • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • 058-Growlithe 0140 <gen> Equal to (Triggering unit)
                • Then - Actions
                  • Unit - Create 1 059-Arcanine for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
                  • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
                • Else - Actions
                  • Custom script: call RemoveLocation (udg_Temp_Point)
                  • Hero - Set (Last created unit) Hero-level to (Hero level of (Triggering unit)), Show level-up graphics
                  • For each (Integer A) from 1 to 6, do (Hero - Give Items[((Integer A) - 1)] to (Last created unit))
                  • Item - Remove (Item being manipulated)
Btw, why does EvilAznBoi's trigger in trigger-tags look like a normal one (with indents, and mine is only a mess? n other words, how to indent a trigger script like that??
 
Last edited by a moderator:
Level 40
Joined
Dec 14, 2005
Messages
10,532
Indent 4/statement, assuming Events, Conditions, Actions, If/Then/Else, Loop, Unit Group, and a Trigger are statements

Eg.

(trigger name)
(4 spaces)Events
(8 spaces)Your Events here
(4 spaces)Conditions
(8 spaces)Your Conditions Here
(4 spaces)Actions
(8 spaces)Do something
(8 spaces)If/Then/Else
(12 spaces)If - Conditions
(16 spaces)Your condition here

and so on
 
Level 2
Joined
Apr 18, 2007
Messages
12
Yeah, wyrmlord is right.
He means sthg like this:
  • FireStone
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Fire Stone
    • Actions
      • For each (Integer A) from 1 to 6, do (Set Items[((Integer A) - 1)] = (Item carried by (Triggering unit) in slot (Integer A)))
      • Unit - Remove (Triggering unit) from the game
      • Set Temp_Point = (Position of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • 133-Eevee 0098 <gen> Equal to (Triggering unit)
        • Then - Actions
          • Unit - Create 1 136-Flareon for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
          • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • 037-Vulpix 0029 <gen> Equal to (Triggering unit)
            • Then - Actions
              • Unit - Create 1 038-Ninetails for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
              • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • 058-Growlithe 0140 <gen> Equal to (Triggering unit)
                • Then - Actions
                  • Unit - Create 1 059-Arcanine for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
                  • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
                • Else - Actions
                  • Custom script: call RemoveLocation (udg_Temp_Point)
                  • Hero - Set (Last created unit) Hero-level to (Hero level of (Triggering unit)), Show level-up graphics
                  • For each (Integer A) from 1 to 6, do (Hero - Give Items[((Integer A) - 1)] to (Last created unit))
                  • Item - Remove (Item being manipulated)
Btw, why does EvilAznBoi's trigger in trigger-tags look like a normal one (with indents, and mine is only a mess? n other words, how to indent a trigger script like that??

hmm, I tried this trigger and now when I use it the triggering unit is removed from the game and it crashes my wc3.
 
Level 11
Joined
Jul 12, 2005
Messages
764
Try to remove the (Triggering unit) later...
Ok, let's see this indent thing: ***
  • FireStone
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Fire Stone
    • Actions
      • For each (Integer A) from 1 to 6, do (Set Items[((Integer A) - 1)] = (Item carried by (Triggering unit) in slot (Integer A)))
      • Set Temp_Point = (Position of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • 133-Eevee 0098 <gen> Equal to (Triggering unit)
        • Then - Actions
          • Unit - Create 1 136-Flareon for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
          • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
          • Else - Actions
      • ...
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Hero - Set (Last created unit) Hero-level to (Hero level of (Triggering unit)), Show level-up graphics
      • Unit - Remove (Triggering unit) from the game
      • For each (Integer A) from 1 to 6, do (Hero - Give Items[((Integer A) - 1)] to (Last created unit))
      • Item - Remove (Item being manipulated)
***EDIT: It does not work...
 
Last edited:
Level 5
Joined
Jun 23, 2004
Messages
126
Try to remove the (Triggering unit) later...
Ok, let's see this indent thing: ***
  • FireStone
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Fire Stone
    • Actions
      • For each (Integer A) from 1 to 6, do (Set Items[((Integer A) - 1)] = (Item carried by (Triggering unit) in slot (Integer A)))
      • Set Temp_Point = (Position of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • 133-Eevee 0098 <gen> Equal to (Triggering unit)
        • Then - Actions
          • Unit - Create 1 136-Flareon for (Owner of (Triggering unit)) at Temp_Point facing (Facing of (Triggering unit)) degrees
          • Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) for 10.00 seconds the text: Congratulations, Yo...
          • Else - Actions
      • ...
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Hero - Set (Last created unit) Hero-level to (Hero level of (Triggering unit)), Show level-up graphics
      • Unit - Remove (Triggering unit) from the game
      • For each (Integer A) from 1 to 6, do (Hero - Give Items[((Integer A) - 1)] to (Last created unit))
      • Item - Remove (Item being manipulated)
***EDIT: It does not work...


I got yelled at by Dr Super Good for not knowing about this bug :wink:

Basically the Trigger tag is bugged, especially if you're using Internet Explorer. My suggestion would be to switch to Firefox.

Edit: @ EvilAznBoi, I don't think that trigger is gonna work at all. It's kinda curious that it's inconsistent, inefficient and even broken in some places, yet you're removing the point with a custom script, heh. I'll see what I can do to help you out, give me a few mins.
 
Level 5
Joined
Jun 23, 2004
Messages
126
Hell, I use Opera...

:bored: Dunno, works great for me in Firefox.

  • Morph
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Orb of Fire
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Hero manipulating item)) Equal to Lava Spawn (Level 1)
          • (Unit-type of (Hero manipulating item)) Equal to Lava Spawn (Level 2)
          • (Unit-type of (Hero manipulating item)) Equal to Lava Spawn (Level 3)
    • Actions
      • Item - Remove (Item being manipulated)
      • Set ReplacePoint = (Position of (Hero manipulating item))
      • Set ReplaceAngle = (Facing of (Hero manipulating item))
      • Set ReplaceXP = (Hero experience of (Hero manipulating item))
      • Set ReplaceType = (Unit-type of (Hero manipulating item))
      • Set ReplaceOwner = (Owner of (Hero manipulating item))
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set ItemVar[(Integer A)] = (Item carried by (Hero manipulating item) in slot (Integer A))
          • Hero - Drop the item from slot (Integer A) of (Hero manipulating item)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ReplaceType Equal to Lava Spawn (Level 1)
        • Then - Actions
          • Unit - Replace (Hero manipulating item) with a Lava Spawn (Level 2) using The old unit's relative life and mana
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ReplaceType Equal to Lava Spawn (Level 2)
        • Then - Actions
          • Unit - Replace (Hero manipulating item) with a Lava Spawn (Level 3) using The old unit's relative life and mana
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ReplaceType Equal to Lava Spawn (Level 3)
        • Then - Actions
          • Unit - Replace (Hero manipulating item) with a Firelord using The old unit's relative life and mana
        • Else - Actions
      • Hero - Set (Last replaced unit) experience to ReplaceXP, Hide level-up graphics
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Give ItemVar[(Integer A)] to (Last replaced unit)
There ya go. I honestly don't think that you can read off the Triggering Unit's XP and type and such after he's been removed, so I saved them in variables.

You can see I also used Unit-Type Comparisons instead of Unit Comparisons, but you can do whatever.

Edit: I used Replace functions instead so the Life and Mana carry over.
 
Status
Not open for further replies.
Top