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

Factory Ability Bug?

Status
Not open for further replies.
Level 2
Joined
Apr 18, 2011
Messages
11
Hey sorry to be a nuisence and ask another question today but i just ran another test of my map and noticed a serious bug.

What i want to have successfully is an ability like pocket factory which creates 3 different types of units (rather than just 1). I did this by initially editing the 'pocket factory' ability so that it uses the art i want and creates the first type of unit that i want. I then created 2 abilities based of the 'factory' ability and attatched them to the factory Unit that is made from using the initial pocket factory ability i.e. the factory itself. It all works well and produces what i want, but when the factory runs out of time and self-destructs (or is destroyed), the units created by the 2 abilities used by the factory continue to spawn for some time after.

I tried to fix this by creating a trigger which removes the abilities when the factory dies, but this did not work. Is there a known fix to this bug? or is it wiser to ask an expert to create a custom ability to do this?
 
I have created a custom Pocket factory for you. It is made, so that it spawns 3 units of different types, which you define in the Map Initialization trigger.

  • Pocket Factory
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Unit-type of (Summoned unit)) Equal to Pocket Factory (Level 1)
    • Actions
      • Custom script: local group g = CreateGroup()
      • -------- ----------------------------------- --------
      • Custom script: call SaveGroupHandle (udg_Hash, GetHandleId (GetSummonedUnit()), StringHash("g"), g)
      • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
      • -------- Interval of the ability: Every how many seconds the units will be spawned --------
      • -------- ----------------------------------- --------
      • Set Interval = 5.00
      • Hashtable - Save Interval as (Key interval) of (Key (Summoned unit)) in Hash
      • Hashtable - Save Interval as (Key interval2) of (Key (Summoned unit)) in Hash
      • -------- ----------------------------------- --------
      • -------- Duration of the ability --------
      • -------- ----------------------------------- --------
      • Set Duration = 20.00
      • Hashtable - Save Duration as (Key duration) of (Key (Summoned unit)) in Hash
      • -------- ----------------------------------- --------
      • -------- Offset of the ability: In what range the units will be spawned at. --------
      • -------- ----------------------------------- --------
      • Set Offset = 200.00
      • Hashtable - Save Offset as (Key offset) of (Key (Summoned unit)) in Hash
      • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
      • Unit Group - Add (Summoned unit) to PocketGroup
      • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
      • Trigger - Turn on Pocket Factory Periodic <gen>
      • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
      • Custom script: set g = null
  • Pocket Factory Periodic
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (PocketGroup is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Unit Group - Pick every unit in PocketGroup and do (Actions)
            • Loop - Actions
              • Set RealValuesLoading[1] = (Load (Key duration) of (Key (Picked unit)) from Hash)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • RealValuesLoading[1] Greater than 0.00
                • Then - Actions
                  • Hashtable - Save (RealValuesLoading[1] - 0.03) as (Key duration) of (Key (Picked unit)) in Hash
                  • Set RealValuesLoading[2] = (Load (Key interval2) of (Key (Picked unit)) from Hash)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • RealValuesLoading[2] Greater than 0.00
                    • Then - Actions
                      • Hashtable - Save (RealValuesLoading[2] - 0.03) as (Key interval2) of (Key (Picked unit)) in Hash
                    • Else - Actions
                      • Set RealValuesLoading[3] = (Load (Key interval) of (Key (Picked unit)) from Hash)
                      • Hashtable - Save RealValuesLoading[3] as (Key interval2) of (Key (Picked unit)) in Hash
                      • Set RealValuesLoading[4] = (Load (Key offset) of (Key (Picked unit)) from Hash)
                      • Set Points[1] = (Position of (Picked unit))
                      • Set Points[2] = (Points[1] offset by RealValuesLoading[4] towards (Random angle) degrees)
                      • For each (Integer Integer) from 1 to 3, do (Actions)
                        • Loop - Actions
                          • Unit - Create 1 UnitTypes[Integer] for (Owner of (Picked unit)) at Points[2] facing Default building facing degrees
                          • Animation - Change (Last created unit)'s size to (50.00%, 50.00%, 50.00%) of its original size
                          • Custom script: call GroupAddUnit (LoadGroupHandle(udg_Hash, GetHandleId (GetEnumUnit()), StringHash("g")), GetLastCreatedUnit())
                          • Custom script: call UnitRemoveAbility (GetLastCreatedUnit(), 'Aatk')
                      • Custom script: call RemoveLocation (udg_Points[1])
                      • Custom script: call RemoveLocation (udg_Points[2])
                • Else - Actions
                  • Unit Group - Remove (Picked unit) from PocketGroup
                  • Unit Group - Pick every unit in (Load (Key g) of (Key (Picked unit)) in Hash) and do (Actions)
                    • Loop - Actions
                      • Unit - Kill (Picked unit)
                  • Unit Group - Remove all units from (Load (Key g) of (Key (Picked unit)) in Hash)
                  • Custom script: call DestroyGroup (LoadGroupHandle(udg_Hash, GetHandleId (GetEnumUnit()), StringHash("g")))
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Hash
                  • Unit - Kill (Picked unit)
P.S. You can also use a variable of type Unit Group to refer to the "g" group, that is loaded 4 times in the trigger for greater efficiency, I left it to you.
 

Attachments

  • Custom Pocket Factory.w3x
    20.1 KB · Views: 99
Status
Not open for further replies.
Top