• 🏆 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] Optimize My Triggers?

Status
Not open for further replies.
Level 22
Joined
Jul 25, 2009
Messages
3,091
This might be better suited to Requests, but I'm not sure.

Basically I've done a large portion of work on a squad system where, the members of the squad are locusted and cannot be selected, this of course removes their health bars and makes it difficult to decipher how much health is left in your squad. So using a DDS and Heal Detection, (both created by Bribe iirc,) along with his unit indexer, I pooled the squad's entire hp into the leader's hp pool. So when a member of the squad takes damage, it's transferred to the leader. When the leader's hp falls below a certain threshold, defined by a calculation, a member of the squad will die (it's always the one that last took damage,) and if this unit was the leader, a new unit will be promoted. I think it could be uploaded as a system here on thw but there are some parts of it that are blatantly inefficient and I'm aware of this but have little idea how to fix them. There are also ideas I have that I'm not sure how to implement and would like help with this as well.

I think this squad system is very unique, and has few if any drawbacks, the only one that comes to mind is that locusted units cannot maintain formations but this could be easily fixed in the movement portion of the triggers, by ordering members of the squad to a point with an offset, relative to where the leader was ordered (which could also allow for interesting formations, not available in WC3, which could also be specific and changeable? I.e. a circular formation or triangular one depending on the squad.)

Anyone interested in helping just reply here or PM me or something, I'm only looking for one person to assist of course and we could upload the finished product as a co-authored resource.

Here are snippets of the code:


  • Removing Units
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • (Point-value of (Unit-type of DamageEventTarget)) Greater than 0
      • GDamageBlockingActive[(Custom value of DamageEventTarget)] Equal to False
    • Actions
      • Set TempUnit = GLeader[(Custom value of DamageEventTarget)]
      • Set TempInteger = (Custom value of DamageEventTarget)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Percentage life of GLeader[TempInteger]) Less than or equal to (GPercentage[TempInteger] x (GCurrentSquadSize[TempInteger] - 1.00))
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DamageEventTarget Equal to GLeader[TempInteger]
            • Then - Actions
              • Set TempGroup2 = (Units in (Playable map area) matching ((TempInteger Equal to (Custom value of (Matching unit))) and ((((Matching unit) is dead) Equal to False) and (TempUnit Not equal to (Matching unit)))))
              • Set TempUnit2 = (Random unit from TempGroup2)
              • Unit - Set life of TempUnit2 to (Life of DamageEventTarget)
              • Unit - Cause DamageEventSource to damage DamageEventTarget, dealing 111111.00 damage of attack type Normal and damage type Normal
              • Unit - Replace TempUnit2 with a (Unit-type of GLeader[TempInteger]) using The old unit's life and mana
              • Set GLeader[TempInteger] = (Last replaced unit)
              • Unit - Set the custom value of GLeader[TempInteger] to TempInteger
              • Unit - Change color of GLeader[TempInteger] to (Color of (Owner of GLeader[TempInteger]))
              • Set GCurrentSquadSize[TempInteger] = (GCurrentSquadSize[TempInteger] - 1.00)
            • Else - Actions
              • Unit - Cause DamageEventSource to damage DamageEventTarget, dealing 111111.00 damage of attack type Normal and damage type Normal
              • Set GCurrentSquadSize[TempInteger] = (GCurrentSquadSize[TempInteger] - 1.00)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DamageEventTarget Not equal to TempUnit
          • DamageEventAmount Less than 99999.00
        • Then - Actions
          • Unit - Cause DamageEventSource to damage TempUnit, dealing DamageEventAmount damage of attack type Normal and damage type Normal
        • Else - Actions



  • Reinforcing Units
    • Events
      • Game - HealEvent becomes Equal to 1.00
      • Game - HealEvent becomes Equal to 0.50
    • Conditions
    • Actions
      • Set TempInteger = (Custom value of heal_target)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GCurrentSquadSize[TempInteger] Less than (Real(GCurrentMaxSize[TempInteger]))
          • (Percentage life of GLeader[TempInteger]) Greater than (GPercentage[TempInteger] x (GCurrentSquadSize[TempInteger] - 0.00))
        • Then - Actions
          • Set TempUnit2 = (Random unit from (Units in (Playable map area) matching ((((Matching unit) is in GMemberGroup[TempInteger]) Equal to True) and (((Matching unit) is dead) Equal to True))))
          • Unit Group - Remove TempUnit2 from GMemberGroup[TempInteger]
          • Set GPoint[1] = (Position of heal_target)
          • Set tempLoc2 = (GPoint[1] offset by 160.00 towards (72.00 x (Real(GInt))) degrees)
          • Unit - Create 1 Locust Dummy for (Owner of heal_target) at tempLoc2 facing (Facing of heal_target) degrees
          • -------- Locust Switcher --------
          • Unit - Add Locust Switcher to (Last created unit)
          • Custom script: call UnitAddAbility(GetLastCreatedUnit(),'Aloc')
          • Custom script: call UnitRemoveAbility(GetLastCreatedUnit(),'Aloc')
          • Unit - Set level of Locust Switcher for (Last created unit) to (Point-value of (Unit-type of heal_target))
          • -------- ---------------------------- --------
          • AI - Ignore (Last created unit)'s guard position
          • Unit - Set the custom value of (Last created unit) to TempInteger
          • Special Effect - Create a special effect at tempLoc2 using Abilities\Spells\Items\AIlm\AIlmTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Unit - Disable supply usage for (Last created unit)
          • Set GCurrentSquadSize[TempInteger] = (GCurrentSquadSize[TempInteger] + 1.00)
          • Custom script: call RemoveLocation(udg_GPoint[1])
          • Custom script: call RemoveLocation(udg_tempLoc2)
        • Else - Actions



  • Squad Setups
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- ----------------------- --------
      • -------- Khorne --------
      • -------- ----------------------- --------
      • -------- Marauders --------
      • Set GLeaderIsDifferent[1] = False
      • Set GLeaderUnitType[1] = Marauder
      • Set GRealMaxSize[1] = 6
      • Set GCurrentMaxSize[1] = 6
      • Set GUpgradeItem01[1] = (Item-type of No item)
      • Set GMoraleDamageAmount[1] = 0
      • -------- Marauder Spearmen --------
      • Set GLeaderIsDifferent[2] = False
      • Set GLeaderUnitType[2] = Marauder Spearman
      • Set GRealMaxSize[2] = 6
      • Set GCurrentMaxSize[2] = 6
      • Set GUpgradeItem01[2] = (Item-type of No item)
      • Set GMoraleDamageAmount[2] = 0
      • -------- Chaos Warriors --------
      • Set GLeaderIsDifferent[3] = False
      • Set GLeaderUnitType[3] = Chaos Warrior
      • Set GRealMaxSize[3] = 6
      • Set GCurrentMaxSize[3] = 6
      • Set GUpgradeItem01[3] = (Item-type of No item)
      • Set GMoraleDamageAmount[3] = 0
      • -------- Bloodletters --------
      • Set GLeaderIsDifferent[4] = False
      • Set GLeaderUnitType[4] = Bloodletter
      • Set GRealMaxSize[4] = 4
      • Set GCurrentMaxSize[4] = 4
      • Set GUpgradeItem01[4] = (Item-type of No item)
      • Set GMoraleDamageAmount[4] = 0
      • -------- Warhounds --------
      • Set GLeaderIsDifferent[5] = False
      • Set GLeaderUnitType[5] = Warhound
      • Set GRealMaxSize[5] = 6
      • Set GCurrentMaxSize[5] = 6
      • Set GUpgradeItem01[5] = (Item-type of No item)
      • Set GMoraleDamageAmount[5] = 0
      • -------- Chaos Knights --------
      • Set GLeaderIsDifferent[6] = False
      • Set GLeaderUnitType[6] = Chaos Knight
      • Set GRealMaxSize[6] = 6
      • Set GCurrentMaxSize[6] = 6
      • Set GUpgradeItem01[6] = (Item-type of No item)
      • Set GMoraleDamageAmount[6] = 0
      • -------- ----------------------- --------
      • -------- Empire --------
      • -------- ----------------------- --------
      • -------- Regimentals --------
      • Set GLeaderIsDifferent[10] = False
      • Set GLeaderUnitType[10] = Regimental Soldier
      • Set GRealMaxSize[10] = 6
      • Set GCurrentMaxSize[10] = 6
      • Set GUpgradeItem01[10] = (Item-type of No item)
      • Set GMoraleDamageAmount[10] = 0
      • -------- Archers --------
      • Set GLeaderIsDifferent[11] = False
      • Set GLeaderUnitType[11] = Archer
      • Set GRealMaxSize[11] = 6
      • Set GCurrentMaxSize[11] = 6
      • Set GUpgradeItem01[11] = (Item-type of No item)
      • Set GMoraleDamageAmount[11] = 0
      • -------- Handgunners --------
      • Set GLeaderIsDifferent[12] = False
      • Set GLeaderUnitType[12] = Handgunner
      • Set GRealMaxSize[12] = 6
      • Set GCurrentMaxSize[12] = 6
      • Set GUpgradeItem01[12] = (Item-type of No item)
      • Set GMoraleDamageAmount[12] = 0
      • -------- Greatswords --------
      • Set GLeaderIsDifferent[13] = False
      • Set GLeaderUnitType[13] = Greatsword
      • Set GRealMaxSize[13] = 4
      • Set GCurrentMaxSize[13] = 4
      • Set GUpgradeItem01[13] = (Item-type of No item)
      • Set GMoraleDamageAmount[13] = 0
      • -------- Knights --------
      • Set GLeaderIsDifferent[14] = False
      • Set GLeaderUnitType[14] = Knight
      • Set GRealMaxSize[14] = 6
      • Set GCurrentMaxSize[14] = 6
      • Set GUpgradeItem01[14] = (Item-type of No item)
      • Set GMoraleDamageAmount[14] = 0
      • -------- Flagellants --------
      • Set GLeaderIsDifferent[15] = False
      • Set GLeaderUnitType[15] = Knight
      • Set GRealMaxSize[15] = 6
      • Set GCurrentMaxSize[15] = 6
      • Set GUpgradeItem01[15] = (Item-type of No item)
      • Set GMoraleDamageAmount[15] = 0
      • -------- ----------------------- --------
      • -------- Dark Elves --------
      • -------- ----------------------- --------
      • -------- Warriors --------
      • Set GLeaderIsDifferent[20] = False
      • Set GLeaderUnitType[20] = Warrior (Dark Elf)
      • Set GRealMaxSize[20] = 6
      • Set GCurrentMaxSize[20] = 6
      • Set GUpgradeItem01[20] = (Item-type of No item)
      • Set GMoraleDamageAmount[20] = 0
      • -------- Darkshards --------
      • Set GLeaderIsDifferent[21] = False
      • Set GLeaderUnitType[21] = Darkshard
      • Set GRealMaxSize[21] = 6
      • Set GCurrentMaxSize[21] = 6
      • Set GUpgradeItem01[21] = (Item-type of No item)
      • Set GMoraleDamageAmount[21] = 0
      • -------- Shades --------
      • Set GLeaderIsDifferent[22] = False
      • Set GLeaderUnitType[22] = Shade
      • Set GRealMaxSize[22] = 6
      • Set GCurrentMaxSize[22] = 6
      • Set GUpgradeItem01[22] = (Item-type of No item)
      • Set GMoraleDamageAmount[22] = 0
      • -------- Beastmaster --------
      • Set GLeaderIsDifferent[23] = False
      • Set GLeaderUnitType[23] = Beastmaster
      • Set GRealMaxSize[23] = 6
      • Set GCurrentMaxSize[23] = 6
      • Set GUpgradeItem01[23] = (Item-type of No item)
      • Set GMoraleDamageAmount[23] = 0
      • -------- Cold One --------
      • Set GLeaderIsDifferent[24] = False
      • Set GLeaderUnitType[24] = Cold One
      • Set GRealMaxSize[24] = 6
      • Set GCurrentMaxSize[24] = 6
      • Set GUpgradeItem01[24] = (Item-type of No item)
      • Set GMoraleDamageAmount[24] = 0
      • -------- Harpies --------
      • Set GLeaderIsDifferent[25] = False
      • Set GLeaderUnitType[25] = Harpy
      • Set GRealMaxSize[25] = 3
      • Set GCurrentMaxSize[25] = 3
      • Set GUpgradeItem01[25] = (Item-type of No item)
      • Set GMoraleDamageAmount[25] = 0
      • -------- Executioners --------
      • Set GLeaderIsDifferent[26] = False
      • Set GLeaderUnitType[26] = Executioner
      • Set GRealMaxSize[26] = 4
      • Set GCurrentMaxSize[26] = 4
      • Set GUpgradeItem01[26] = (Item-type of No item)
      • Set GMoraleDamageAmount[26] = 0



  • Unit is Trained
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Point-value of (Trained unit)) Greater than 0
        • Then - Actions
          • Set TempInteger = (Point-value of (Unit-type of (Trained unit)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GLeaderIsDifferent[TempInteger] Equal to True
            • Then - Actions
              • Set GNumber = (Custom value of (Last created unit))
              • Unit - Replace (Trained unit) with a GLeaderUnitType[TempInteger] using The new unit's max life and mana
              • Set GLeader[GNumber] = (Last replaced unit)
              • Unit - Set the custom value of GLeader[GNumber] to GNumber
              • Unit - Change color of GLeader[GNumber] to (Color of (Owner of (Triggering unit)))
            • Else - Actions
              • Set GNumber = (Custom value of (Trained unit))
              • Set GLeader[GNumber] = (Trained unit)
              • Unit - Set the custom value of GLeader[GNumber] to GNumber
              • Unit - Change color of GLeader[GNumber] to (Color of (Owner of (Triggering unit)))
          • Set GCurrentMaxSize[GNumber] = GRealMaxSize[TempInteger]
          • For each (Integer GInt) from 1 to (GRealMaxSize[TempInteger] - 1), do (Actions)
            • Loop - Actions
              • Set GCurrentSquadSize[GNumber] = (Real(GRealMaxSize[TempInteger]))
              • Set GPercentage[GNumber] = (100.00 / (Real(GRealMaxSize[TempInteger])))
              • Set GPoint[1] = (Position of GLeader[GNumber])
              • Set GPoint[2] = (Rally-Point of (Triggering unit) as a point)
              • Set tempLoc2 = (GPoint[1] offset by 160.00 towards (72.00 x (Real(GInt))) degrees)
              • Unit - Create 1 Locust Dummy for (Owner of (Triggering unit)) at tempLoc2 facing (Facing of GLeader[GNumber]) degrees
              • Unit - Order (Last created unit) to Move To GPoint[2]
              • Unit - Order GLeader[GNumber] to Move To GPoint[2]
              • Unit - Add Locust Switcher to (Last created unit)
              • Custom script: call UnitAddAbility(GetLastCreatedUnit(),'Aloc')
              • Custom script: call UnitRemoveAbility(GetLastCreatedUnit(),'Aloc')
              • Unit - Set level of Locust Switcher for (Last created unit) to TempInteger
              • AI - Ignore (Last created unit)'s guard position
              • Unit - Set the custom value of (Last created unit) to GNumber
              • Unit - Disable supply usage for (Last created unit)
              • Custom script: call RemoveLocation(udg_GPoint[1])
              • Custom script: call RemoveLocation(udg_GPoint[2])
        • Else - Actions
  • [/hidden]
 
Status
Not open for further replies.
Top