• 🏆 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!

[Solved] One time lag upon ability cast.

Status
Not open for further replies.
Level 3
Joined
Feb 19, 2016
Messages
32
So, I am creating an ability that works just like Frenzy in Homm3[1].
It works just fine, at least for now, except for one annoying bug. It freezes the game for 3-5 seconds upon first cast(And first cast only! Each cast after the first one works well.).
It doesn't matter if the skill is used at a specific unit or unit type.

There's a couple of tweaks I have to do yet, like adding the part that makes buff actually visible in buffs and to make it expire, but I'll do them later. After I fix this goddamn issue.

I'd be glad if I got help anytime soon :3


1 - For those who never played it: The spell converts armor value of the target into its attack value. Mostly useful.

Here are the triggers with adnotations.
The initialization - Most probably nothing wrong here.
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Frenzy 0 - Main skill --------
      • Set Frenzy[0] = Frenzy
      • -------- Frenzy 1 - Skill used to raise unit's hp when finding it's armor value. --------
      • Set Frenzy[1] = LifeBon (Greater)
      • -------- 2 - Reduction armor, each even level reduces armor by one. --------
      • -------- 3 - Damage increase, each level increases damage by 3. --------
      • -------- 10 - Spellbook for the two skills above. --------
      • Set Frenzy[2] = Armor Red
      • Set Frenzy[3] = Dmg Bonus
      • Set Frenzy[10] = SuperSpellBook
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Disable Frenzy[10] for (Picked player)
      • -------- Initialize 50 armor values(Up to 25 armor) --------
      • -------- Didn't find any other way to convert damage reduction percent into armor. --------
      • Set ArmorConst[0] = 0.00
      • For each (Integer A) from 1 to 50, do (Actions)
        • Loop - Actions
          • Set ArmorConst[(Integer A)] = (((0.50 x (Real((Integer A)))) x 0.06) / (1.00 + (((Real((Integer A))) x 0.50) x 0.06)))
The skill trigger - Didn't make the one used to remove buffs yet, because at primo I need to deal with lag issue.
  • Start
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frenzy[0]
    • Actions
      • Set TempUnit[0] = (Target unit of ability being cast)
      • Unit - Add Frenzy[1] to TempUnit[0]
      • -------- Here is the part that returns armor of the unit as TempReal[5]. --------
      • Set TempReal[0] = (Life of TempUnit[0])
      • Unit - Cause TempUnit[0] to damage TempUnit[0], dealing 1000.00 damage of attack type Chaos and damage type Normal
      • Set TempReal[1] = (Life of TempUnit[0])
      • Unit - Set life of TempUnit[0] to TempReal[0]
      • Unit - Remove Frenzy[1] from TempUnit[0]
      • Set TempReal[3] = ((TempReal[0] - TempReal[1]) x 1.00)
      • Set TempReal[4] = ((1000.00 - TempReal[3]) / 1000.00)
      • -------- Loop for finding up the armor value. Accuracy: 0,5 armor(Which doesn't matter at all when removing armor. The skill doesn't allow us to remove half of an armor point.). --------
      • For each (Integer A) from 0 to 50, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempReal[4] Greater than ArmorConst[(Integer A)]
            • Then - Actions
            • Else - Actions
              • Set TempReal[5] = ((Real((Integer A))) / 2.00)
              • -------- Just a debug message. Game freezes BEFORE it appears. --------
              • Game - Display to (All players) the text: (String(TempReal[5]))
              • -------- Adds the spellbook and sets the buff strenght depending on amount of armor target has. --------
              • Unit - Add Frenzy[10] to TempUnit[0]
              • Unit - Set level of Frenzy[2] for TempUnit[0] to (Integer A)
              • Unit - Set level of Frenzy[3] for TempUnit[0] to (Integer A)
              • Set TempUnit[0] = No unit
              • Skip remaining actions
      • -------- Clearing up the variable in case I meet a unit with more than 25 armor. --------
      • Set TempUnit[0] = No unit
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
You need to preload the ability. If something is used for the first time (model, ability, ...) it must be loaded into the game. Usually it does not take long is not noticeable, but if you have an ability that adds an ability with 100 levels to a unit all the data from 100 levels must be loaded.
If possible you could make the effect of the ability already appear on map initialization on a dummy unit, so the data can be loaded before the game starts.
How much levels have the Frenzy Abilities? If they have a lot of levels, just add all of them at map initialization to a dummy unit and remove it after that.
 
Level 3
Joined
Feb 19, 2016
Messages
32
Each's got 50, more than the trigger requires is unnessesary. But it's great to know it works this way!
Thanks!
 
Status
Not open for further replies.
Top