• 🏆 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] Optimization Help

Status
Not open for further replies.
Level 4
Joined
Jul 27, 2015
Messages
29
Hi there

Context: This trigger is meant to create a temporary dummy unit with hero abilities that the player can use to 'Spend talent points' similiar to an RPG. The number of points the player has in each talent is stored as levels of upgrades (A, B, C, D, E) in this case.

The dummy for talent spending will level these upgrades when it levels it's abilities, and the upgrades will be reset when the 'Tome of Retraining' ability is used - this is all handled in different triggers

I have two questions/problems:

1 - The trigger creates a lag spike when it is first run, future runs of the trigger do NOT, is there stuff here that I should/could be running at Map Initialization, I'm not sure what!

2 - Is there a more optimal way I could do this? I want to be able to call a function to autolevel the abilities up to the current upgrade amounts, but you can't reference a variable in the 'Hero - Learn Skill' action, otherwise I'd pass the specific talent abilities this way

Thanks in advance, trigger code below:
  • SlayerEntersOrderHall
    • Events
      • Unit - A unit enters slayerOrderHallFull <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Trigger - Turn off (This trigger)
      • Set tempLoc = (Position of [Configure Talents] SLAYER 0042 <gen>)
      • Unit - Create 1 Talents (Slayer) for (Owner of (Triggering unit)) at tempLoc facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_tempLoc)
      • Trigger - Turn on (This trigger)
      • Set tempUnit = (Last created unit)
      • Set tempInt = (Hero level of (Triggering unit))
      • Hero - Set tempUnit Hero-level to 20, Hide level-up graphics
      • Hero - Modify unspent skill points of tempUnit: Set to (Integer(((Real((Hero level of (Triggering unit)))) / 2.00))) points
      • For each (Integer tempInt) from 1 to (Current research level of TALENT A for (Owner of tempUnit)), do (Actions)
        • Loop - Actions
          • Hero - Learn skill for tempUnit: Slayer - Valour (Talent A)
          • Hero - Modify unspent skill points of tempUnit: Subtract 1 points
      • For each (Integer tempInt) from 1 to (Current research level of TALENT B for (Owner of tempUnit)), do (Actions)
        • Loop - Actions
          • Hero - Learn skill for tempUnit: Slayer - Leadership (Talent B)
          • Hero - Modify unspent skill points of tempUnit: Subtract 1 points
      • For each (Integer tempInt) from 1 to (Current research level of TALENT C for (Owner of tempUnit)), do (Actions)
        • Loop - Actions
          • Hero - Learn skill for tempUnit: Slayer - Discipline (Talent C)
          • Hero - Modify unspent skill points of tempUnit: Subtract 1 points
      • For each (Integer tempInt) from 1 to (Current research level of TALENT D for (Owner of tempUnit)), do (Actions)
        • Loop - Actions
          • Hero - Learn skill for tempUnit: Slayer - Survival (Talent D)
          • Hero - Modify unspent skill points of tempUnit: Subtract 1 points
      • For each (Integer tempInt) from 1 to (Current research level of TALENT E for (Owner of tempUnit)), do (Actions)
        • Loop - Actions
          • Hero - Learn skill for tempUnit: Slayer - Acrobatics (Talent E)
          • Hero - Modify unspent skill points of tempUnit: Subtract 1 points
      • Trigger - Turn on SlayerLeavesOrderHall <gen>
      • Trigger - Turn on SlayerTalentHandler <gen>
If anything about my intent with this trigger wasn't clear just ask!

Thanks
 
1 - The trigger creates a lag spike when it is first run, future runs of the trigger do NOT, is there stuff here that I should/could be running at Map Initialization, I'm not sure what!
non repeating lag spikes are commonly created by pushing new data into the RAM when something is used the first time. This can happen for anything from texture, image, sound, model or object Editor data.

Most common is texture/model when creating a new unit (not so heavy lags).
Ability when spawning units/items.
Ability when using add/Learn ability.
Checkout subject "Preload"

t you can't reference a variable in the 'Hero - Learn Skill' action, otherwise I'd pass the specific talent abilities this way
Accuatly one can refer to the ability learned, it is from the same type as the normal abilityId, but GUI misses wrapper functions to swap between them.
You will need kind of that custom script line.
  • Learn Skill
    • Events
      • Unit - A unit Learns a skill
    • Conditions
    • Actions
      • Custom script: set udg_Ability = GetLearnedSkill()
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Ability Equal to Attribut-Bonus
        • Then - Actions
        • Else - Actions
 
Level 4
Joined
Jul 27, 2015
Messages
29
non repeating lag spikes are commonly created by pushing new data into the RAM when something is used the first time. This can happen for anything from texture, image, sound, model or object Editor data.

Most common is texture/model when creating a new unit (not so heavy lags).
Ability when spawning units/items.
Ability when using add/Learn ability.
Checkout subject "Preload"


Accuatly one can refer to the ability learned, it is from the same type as the normal abilityId, but GUI misses wrapper functions to swap between them.
You will need kind of that custom script line.
  • Learn Skill
    • Events
      • Unit - A unit Learns a skill
    • Conditions
    • Actions
      • Custom script: set udg_Ability = GetLearnedSkill()
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Ability Equal to Attribut-Bonus
        • Then - Actions
        • Else - Actions



Thankyou for the help on information on the lag spike, I guess this means I need to initialize the object data by adding then removing the the unit from the map on initilization, I'll add it to my trigger thanks :)

The Learn Skill only accepts abilities in the object editor, or pre-determined hero order strings (which don't work for my custom abilities).


Do you think there is a custom script I could call to force the unit to learn a skill eg: 'LearnSkll()' or something similiar
 
Status
Not open for further replies.
Top