• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Spell lags on first cast, but then runs smoothly after

Status
Not open for further replies.
Level 1
Joined
Feb 17, 2017
Messages
5
Hi,

I'm trying to get a custom spell working for my map. See the trigger below. The game freezes up the first time a unit with the aura attacks an enemy. But then runs smoothly after that. Does anyone know what's wrong? I've initialized all integer variables to 1. I'm guessing something isn't initialized correctly and that's why it lags on the first go around of this trigger? Thanks for any help! :D

upload_2017-2-16_18-48-30.png
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
You have to preload the dummy unit on map init. The lag occurs because the game has to load all the data for the unit.

You can fix this by either using a dummy global caster created on map init, or you can just simply create the dummy unit , add the ability to them, and then remove them (also all on map init).

Also, you should learn how to post triggers on the website. It's a lot easier and more convenient for everyone! Take a look at this tutorial.
 
Level 1
Joined
Feb 17, 2017
Messages
5
That worked! Thanks for your help! I'll try out the tutorial you sent me!
  • Stat Steal
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Triggering unit) is A ground unit) Equal to True
      • ((Attacking unit) has buff Attack Speed Transfer ) Equal to True
    • Actions
      • Set Berserk_Caster = (Attacking unit)
      • Set Berserk_Ability_Level = (Level of Attack Speed Transfer for Berserk_Caster)
      • Set Berserk_Owner = (Owner of Berserk_Caster)
      • Set Berserk_Caster_Location = (Position of (Attacking unit))
      • Set Berserk_Enemy = (Attacked unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Berserk_Enemy has buff Attack Speed Loss ) Equal to False
        • Then - Actions
          • Set Beserker_Total_Level = Berserk_Ability_Level
          • Set Berserk_Incrementor = 0
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Berserk_Enemy has buff Attack Speed Loss ) Equal to True
          • Beserker_Total_Level Less than (Berserk_Ability_Level x 4)
        • Then - Actions
          • Set Berserk_Incrementor = (Berserk_Incrementor + 1)
          • Set Beserker_Total_Level = (Berserk_Ability_Level + Berserk_Incrementor)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Berserk_Enemy has buff Attack Speed Loss ) Equal to True
          • Beserker_Total_Level Equal to (Berserk_Ability_Level x 4)
        • Then - Actions
          • Set Beserker_Total_Level = (Berserk_Ability_Level + Berserk_Incrementor)
        • Else - Actions
      • Unit - Create 1 Dummy for Berserk_Owner at Berserk_Caster_Location facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Add Attack_Speed_Subtract to (Last created unit)
      • Unit - Set level of Attack_Speed_Subtract for (Last created unit) to Beserker_Total_Level
      • Unit - Order (Last created unit) to Undead Necromancer - Cripple Berserk_Enemy
      • Unit - Create 1 Dummy for Berserk_Owner at Berserk_Caster_Location facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Add Attack_Speed_Bonus to (Last created unit)
      • Unit - Set level of Attack_Speed_Bonus for (Last created unit) to Beserker_Total_Level
      • Unit - Order (Last created unit) to Undead Necromancer - Cripple Berserk_Caster
      • Custom script: call RemoveLocation(udg_Berserk_Caster_Location)
JASS:
Stat Steal
    Events
        Unit - A unit Is attacked
    Conditions
        ((Triggering unit) is A ground unit) Equal to True
        ((Attacking unit) has buff Attack Speed Transfer ) Equal to True
    Actions
        Set Berserk_Caster = (Attacking unit)
        Set Berserk_Ability_Level = (Level of Attack Speed Transfer  for Berserk_Caster)
        Set Berserk_Owner = (Owner of Berserk_Caster)
        Set Berserk_Caster_Location = (Position of (Attacking unit))
        Set Berserk_Enemy = (Attacked unit)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Berserk_Enemy has buff Attack Speed Loss ) Equal to False
            Then - Actions
                Set Beserker_Total_Level = Berserk_Ability_Level
                Set Berserk_Incrementor = 0
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Berserk_Enemy has buff Attack Speed Loss ) Equal to True
                Beserker_Total_Level Less than (Berserk_Ability_Level x 4)
            Then - Actions
                Set Berserk_Incrementor = (Berserk_Incrementor + 1)
                Set Beserker_Total_Level = (Berserk_Ability_Level + Berserk_Incrementor)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Berserk_Enemy has buff Attack Speed Loss ) Equal to True
                Beserker_Total_Level Equal to (Berserk_Ability_Level x 4)
            Then - Actions
                Set Beserker_Total_Level = (Berserk_Ability_Level + Berserk_Incrementor)
            Else - Actions
        Unit - Create 1 Dummy for Berserk_Owner at Berserk_Caster_Location facing Default building facing degrees
        Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
        Unit - Add Attack_Speed_Subtract  to (Last created unit)
        Unit - Set level of Attack_Speed_Subtract  for (Last created unit) to Beserker_Total_Level
        Unit - Order (Last created unit) to Undead Necromancer - Cripple Berserk_Enemy
        Unit - Create 1 Dummy for Berserk_Owner at Berserk_Caster_Location facing Default building facing degrees
        Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
        Unit - Add Attack_Speed_Bonus  to (Last created unit)
        Unit - Set level of Attack_Speed_Bonus  for (Last created unit) to Beserker_Total_Level
        Unit - Order (Last created unit) to Undead Necromancer - Cripple Berserk_Caster
        Custom script:   call RemoveLocation(udg_Berserk_Caster_Location)
 
Last edited by a moderator:
Status
Not open for further replies.
Top