• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[Trigger] GUI Trigger Lag

Status
Not open for further replies.
Level 2
Joined
Dec 27, 2010
Messages
15
Hey

Im making this map where a Slayer is created by placing a specific item on a player owned circle of power (Which can be built anywhere) and casting the "Summon Slayer" ability.

I have this trigger which checks if the item is the right type (Ice Shard) and then acts accordingly. However there are a few problems.

Major Issue:
-The trigger always lags for a few seconds when a Slayer is summoned successfully

Minor Issues: (Trivial but would be nice to fix)
-It can only be used by one player at a time (Only takes a second to run)
-Memory leaks (Only runs about 6 times per game)
-Uses unnecessary variables?

So I don't really mind about the minor stuff, but its very messy and I'm not really sure how to go about cleaning it up. If anyone could help out with the lag whenever it runs successfully, that'd be great. Here it is:

  • Slayer Summoning
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Summon Slayer
    • Actions
      • Trigger - Turn off (This trigger)
      • Set CastingUnitSS = (Casting unit)
      • Item - Pick every item in (Region centered at (Position of CastingUnitSS) with size (128.00, 128.00)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Picked item)) Equal to Ice Shard
            • Then - Actions
              • Unit - Remove Summon Slayer from CastingUnitSS
              • Set BooleanIceShardYN[((Player number of (Owner of CastingUnitSS)) - 1)] = True
              • Set IceShard[((Player number of (Owner of CastingUnitSS)) - 1)] = (Picked item)
            • Else - Actions
              • Set BooleanIceShardYN[((Player number of (Owner of CastingUnitSS)) - 1)] = False
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BooleanIceShardYN[((Player number of (Owner of CastingUnitSS)) - 1)] Equal to True
        • Then - Actions
          • Item - Remove IceShard[((Player number of (Owner of CastingUnitSS)) - 1)]
          • Special Effect - Create a special effect at (Position of CastingUnitSS) using Abilities\Spells\Human\ReviveHuman\ReviveHuman.mdl
          • Unit - Create 1 Slayer for (Owner of CastingUnitSS) at (Position of CastingUnitSS) facing 270.00 degrees
          • Game - Display to (All players) the text: ((Name of (Owner of CastingUnitSS)) + has summoned a |cffffcc00Slayer.|r)
        • Else - Actions
          • Game - Display to (Player group((Owner of CastingUnitSS))) the text: |c00ff0000No effect...
      • Trigger - Turn on (This trigger)
Thats all of it. Any suggestions would be appreciated, cheers. :eekani:
 
- use >>> spawns a summoned unit
- use >>> summoned = (Triggering Unit)
- why do you need turn off & turn on?
- use checking conditions, like if slayer-type unit is greater than 0 then REMOVE summoned unit, else DONT remove it...

Can you explain in more depth? Sorry I'm not paticulary adept and dont understand. And it is turned on and off so multiple players can't run it at the same time.
 
I'd rather not share the map until its finished. Could u just show me a couple suggestions to stop it lagging in this form:
  • Events
  • Conditions
  • Actions
 
i'm so sorry for my unreasonable request,maybe you can convert the trigger
to jass and post it(just this trigger).....okay??
 
  • Slayer Summoning
  • Events
  • Unit - A unit Begins casting an ability
  • Conditions
  • (Ability being cast) Equal to Summon Slayer
  • Actions
  • Set CastingUnitSS = (Casting unit)
  • Item - Pick every item in (Region centered at (Position of CastingUnitSS) with size (128.00, 128.00)) and do (Actions)
  • Loop - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Item-type of (Picked item)) Equal to Ice Shard
  • Then - Actions
  • Unit - Remove Summon Slayer from CastingUnitSS
  • Set loc = (Position of CastingUnitSS)
  • Special Effect - Create a special effect at (loc) using Abilities\Spells\Human\ReviveHuman\ReviveHuman.mdl
  • Unit - Create 1 Slayer for (Owner of CastingUnitSS) at (loc) facing 270.00 degrees
  • Game - Display to (All players) the text: ((Name of (Owner of CastingUnitSS)) + has summoned a |cffffcc00Slayer.|r)
  • Special Effect - Destroy (Last created special effect)
  • Custom script: call RemoveLocation(udg_loc)
    • Custom script: return
    • Else - Actions
  • Game - Display to (Player group((Owner of CastingUnitSS))) the text: |c00ff0000No effect..
 
Hey thanks man. That all looks good ill try it out. +rep

EDIT: It's looking much better:
  • Slayer Summoning
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Summon Slayer
    • Actions
      • Set CastingUnitSS = (Casting unit)
      • Set tempLocation = (Region centered at (Position of (Casting unit)) with size (128.00, 128.00))
      • Item - Pick every item in tempLocation and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Picked item)) Equal to Ice Shard
            • Then - Actions
              • Item - Remove (Picked item)
              • Unit - Remove Summon Slayer from CastingUnitSS
              • Set tempPoint = (Position of CastingUnitSS)
              • Special Effect - Create a special effect at tempPoint using Abilities\Spells\Human\ReviveHuman\ReviveHuman.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Create 1 Slayer for (Owner of CastingUnitSS) at tempPoint facing 270.00 degrees
              • Game - Display to (All players) the text: ((Name of (Owner of CastingUnitSS)) + |cffffcc00has summoned a slayer.|r)
            • Else - Actions
              • Game - Display to (All players) the text: |c00ff0000No effect...
      • Custom script: call RemoveRect(udg_tempLocation)
      • Custom script: call RemoveLocation(udg_tempPoint)
However the Else - Actions doesnt seem to work. When there's no item at the position, no actions run and it doesnt display the text it should.
 
Last edited:
Does the spell lag the second time you use it in a game? If not, perhaps the lag is from the fact that the slayer unit wasn't preloaded while the map was loading. To do this, create a trigger that runs on map initialization and in the trigger, create the slayer unit and then remove it right afterwards. The other option is to put all units that need to be preloaded in a region and then remove all units in that region while the map is loading (in a map initialization trigger).
 
Omg yea that fixes it. Thanks a million dude! :thumbs_up: +rep

I might just go back to the original trigger - but in my above post could anyone suggest how the Else - Actions could be made to work?
 
  • Slayer Summoning
    • Events
    • Unit - A unit Begins casting an ability
    • Conditions
    • (Ability being cast) Equal to Summon Slayer
    • Actions
    • Set CastingUnitSS = (Casting unit)
    • Item - Pick every item in (Region centered at (Position of CastingUnitSS) with size (128.00, 128.00)) and do (Actions)
    • Loop - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • (Item-type of (Picked item)) Equal to Ice Shard
    • Then - Actions
    • Unit - Remove Summon Slayer from CastingUnitSS
    • Set loc = (Position of CastingUnitSS)
    • Special Effect - Create a special effect at (loc) using Abilities\Spells\Human\ReviveHuman\ReviveHuman.mdl
    • Unit - Create 1 Slayer for (Owner of CastingUnitSS) at (loc) facing 270.00 degrees
    • Game - Display to (All players) the text: ((Name of (Owner of CastingUnitSS)) + has summoned a |cffffcc00Slayer.|r)
    • Special Effect - Destroy (Last created special effect)
    • Custom script: call RemoveLocation(udg_loc)
    • Custom script: return
    • Else - Actions
    • Do nothing
    • Game - Display to (Player group((Owner of CastingUnitSS))) the text: |c00ff0000No effect..
guy ,i propose that you should not delete "Custom script: return" for the reason that if there are two items whose type is Ice Shard
,then it will create more than one Slayer ..
else " Game - Display to (Player group((Owner of CastingUnitSS))) the text: |c00ff0000No effect " is out of " If (All Conditions are True) then do (Then Actions) else do (Else Actions)
" or it will not display the text i.
 
Ohk. I've got that all working with variables. However the "return" function doesnt actually stop the loop when I tested the map. Whats wrong?

  • Slayer Summoning
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Summon Slayer
    • Actions
      • Set CastingUnitSS = (Casting unit)
      • Set tempLocation = (Region centered at (Position of (Casting unit)) with size (128.00, 128.00))
      • Set SkipYN = False
      • Item - Pick every item in tempLocation and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Picked item)) Equal to Ice Shard
            • Then - Actions
              • Item - Remove (Picked item)
              • Unit - Remove Summon Slayer from CastingUnitSS
              • Set tempPoint = (Position of CastingUnitSS)
              • Special Effect - Create a special effect at tempPoint using Abilities\Spells\Human\ReviveHuman\ReviveHuman.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Create 1 Slayer for (Owner of CastingUnitSS) at tempPoint facing 270.00 degrees
              • Game - Display to (All players) the text: ((Name of (Owner of CastingUnitSS)) + |cffffcc00has summoned a slayer.|r)
              • Set SkipYN = True
              • Custom script: call RemoveRect(udg_tempLocation)
              • Custom script: call RemoveLocation(udg_tempPoint)
              • Custom script: return
            • Else - Actions
              • Do nothing
      • If (SkipYN Equal to False) then do (Game - Display to (All players) the text: |c00ff0000No effect...) else do (Do nothing)
 
Return only breaks out of the current function. The pick every item calls the handler function which handles the picked item. So in reality your only breaking out of the function that handles each individual item. It still calls the handler function for all other items.

Ok, so is there any way to prevent the function handling the other items after it has picked an item of the type Ice Shard?
 
The region is so small that I doubt there are many items in there. You could let it loop them, prevent the code proceeding to the then branch by adding the boolean SkipYN check along with the item type check.

Remove the do nothing call. Do nothing causes a function call. Leaving the else empty is a better choise.

When you set the region, you're leaking the position of caster.
 
Thanks g. Will get to work on it +rep

EDIT: Cheerz every1! Trigger finally fixed, thanks every1 +rep all round. Thread closed :thumbs_up:
 
Status
Not open for further replies.
Back
Top