• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] How to preload a spell?

Status
Not open for further replies.
Level 12
Joined
Aug 12, 2008
Messages
350
The following spell lags for the first time the hero kills a unit. It only smooth after that. I'm not sure how to preload as said by so many spell makers to ensure the spell goes smooth.
Here is the trigger,
  • Strength and Honor
    • Events
      • Unit - A unit Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • ((Triggering unit) has buff Strength and Honor ) Equal to True
          • ((Killing unit) has buff Strength and Honor ) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Killing unit) has buff Strength and Honor ) Equal to True
        • Then - Actions
          • Set tempUnit = (Killing unit)
          • Set SH_level = (Level of Strength and Honor for tempUnit)
          • Custom script: set udg_O_key = GetHandleId (udg_tempUnit)
          • Set SH_stackMax = (5 x SH_level)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Strength and Honor for tempUnit) Equal to 0
            • Then - Actions
              • Unit - Add Strength and Honor to tempUnit
            • Else - Actions
          • Set tempInteger = (Load 1 of SH_key from Hashtable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • tempInteger Less than SH_stackMax
            • Then - Actions
              • Set SH_stack = (tempInteger + 1)
              • Unit - Set level of Strength and Honor for tempUnit to SH_stack
              • Hashtable - Save SH_stack as 1 of SH_key in Hashtable
            • Else - Actions
        • Else - Actions
          • Set tempUnit = (Triggering unit)
          • Custom script: set udg_O_key = GetHandleId (udg_tempUnit)
          • Set tempInteger = (Load 1 of SH_key from Hashtable)
          • Set SH_stack = (tempInteger / 2)
          • Unit - Set level of Strength and Honor for tempUnit to SH_stack
          • Hashtable - Save SH_stack as 1 of SH_key in Hashtable
 
Make the trigger run on map initialization. Place 2 units with your ability on the map, cause one of them to damage the other for 500000 at map initialization. Remove both the units at 0.01 seconds.
 
Thanks a lot, Meticulous :D +rep

EDIT: How do I remove them at 0.01 seconds? Do I need 2 triggers just for preload the spell? Is it like this:
  • Strength and Honor preload
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set tempPoint = (Center of Battle Ground <gen>)
      • Unit - Create 1 Bloodfiend for Player 5 (Yellow) at tempPoint facing Default building facing degrees
      • Set tempUnit = (Last created unit)
      • Unit - Set level of Strength and Honor for tempUnit to 1
      • Unit - Create 1 Bloodfiend for Player 5 (Yellow) at tempPoint facing Default building facing degrees
      • Unit - Cause tempUnit to damage (Last created unit), dealing 99999.00 damage of attack type Spells and damage type Normal
      • Wait 0.01 seconds
      • Unit - Remove tempUnit from the game
      • Unit - Remove (Last created unit) from the game
 
I don't think waits do anything at map initialization.

Don't create the units at map initialization, just pre-place them somewhere on the map. Then create a second trigger that runs at .01 seconds and remove the pre-placed units. Otherwise if you end up pre-loading multiple abilities (which you probably will on any big project) you'll have to create a lot of variables.
 
Just run any trigger that creates brief lag/delay the first time it's run at map initialization so you won't get any kind of interruptive stuttering in-game. If the trigger doesn't have a lot of if/then/elses or waits or timers you can usually just add a "run triggering ignoring conditions" action to your map initialization trigger to preload it.

I guess you can just remove any necessary units at map initialization as well, wasn't sure if it would make a difference. Also, make sure your hash table is created/set first (by putting the hash table actions at the top of the map initialization trigger) or abilities that use hash tables might not preload correctly.

  • Strength and Honor preload
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit - Add Strength and Honor to Bloodfiend 0001 <Gen>
      • Unit - Add Strength and Honor to Bloodfiend 0002 <Gen>
      • Unit - Cause Bloodfiend 0001 <Gen> to damage Bloodfiend 0002 <Gen> dealing 99999.00 damage of attack type Spells and damage type Normal
      • Unit - Remove Bloodfiend 0001 <Gen> from the game
      • Unit - Remove Bloodfiend 0002 <Gen> from the game
 
Status
Not open for further replies.
Back
Top