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

Auto Rebuild. Pick one! unit..

Status
Not open for further replies.
Level 8
Joined
Sep 30, 2012
Messages
205
Was making another system that allows you to automatically rebuild your lost units.

However when a unit dies, i can say pick every unit, that is a owned by the player and rebuild the missing unit.
So the problem is if one footman dies, and the player owns two barracks, both barracks want to replace the missing footman.
Can i say: only pick one (barrack for example)?

thx in advance

  • Player 1 Enable Auto Rebuild
    • Events
      • Player - Player 1 (Red) types a chat message containing -erb as A substring
    • Conditions
    • Actions
      • Trigger - Turn on Player 1 Rebuild <gen>
      • Set Saying_Player = (Player group((Triggering player)))
      • Game - Display to Saying_Player the text: Enabled Rebuild
      • Custom script: call DestroyForce (udg_Saying_Player)
  • Player 1 Disable Auto Rebuild
    • Events
      • Player - Player 1 (Red) types a chat message containing -drb as A substring
    • Conditions
    • Actions
      • Trigger - Turn off Player 1 Rebuild <gen>
      • Set Saying_Player = (Player group((Triggering player)))
      • Game - Display to Saying_Player the text: Disabled Rebuild
      • Custom script: call DestroyForce (udg_Saying_Player)
  • Player 1 Rebuild
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Dying unit)) Equal to Player 1 (Red)
    • Actions
      • Game - Display to (All players matching ((Owner of (Dying unit)) Equal to Player 1 (Red))) the text: (Auto Rebuild: + (Name of (Dying unit)))
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to Player 1 (Red)
            • Then - Actions
              • Unit - Order (Picked unit) to train/upgrade to a (Unit-type of (Dying unit))
            • Else - Actions
 
Last edited:
Level 9
Joined
Dec 12, 2007
Messages
489
I suggest you use an integer array variable or boolean array variable for each player, then at the Player 1 Rebuild trigger, set the integer = 1 or boolean = true. then add AND condition to the if-then-else, check if the integer or boolean is the same as the value you set, then after order to train, change the value of the integer or boolean value to something else. this way, the 2nd picked unit check won't be ordered to train the unit again.

btw, this suffer almost the same problem with that Auto Build.
 
Level 8
Joined
Sep 30, 2012
Messages
205
nope that won't work..
the problem is at the core,
pick every unit and do: the pc really picks every unit..
it doesn't help to write big ass triggers before that and check if he had done this before..

oh and don't worry DyingUnit is a Variable..

  • Player 1 Rebuild
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Dying unit)) Equal to Player 1 (Red)
    • Actions
      • Set DyingUnit = (Dying unit)
      • Set Build_Real = 1.00
      • Trigger - Run Player 1 Rebuild Unit <gen> (checking conditions)
  • Player 1 Rebuild Unit
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Building_Int[1] Equal to 0
        • Then - Actions
          • Trigger - Run Check Building <gen> (checking conditions)
        • Else - Actions
      • Set Building_Int[2] = (Building_Int[2] + 1)
      • Set DyingUnit2[Building_Int[2]] = DyingUnit
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DyingUnit2[Building_Int[2]] is in BuildingGroup) Equal to True
        • Then - Actions
          • Set Building_Int[2] = (Building_Int[2] - 1)
        • Else - Actions
          • Set Building_Int[1] = (Building_Int[1] + 1)
          • Set Build_Real2[Building_Int[2]] = Build_Real
          • Unit Group - Add DyingUnit2[Building_Int[2]] to BuildingGroup
  • Check Building
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • Build_curReal[Building_Int[3]] Greater than or equal to Build_Real2[Building_Int[3]]
        • Then - Actions
          • Set Buidling_Deadboolean[Building_Int[3]] = True
          • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Picked unit)) Equal to (Owner of DyingUnit)
                • Then - Actions
                  • Set Build_curReal[Building_Int[3]] = 1.00
                  • Unit - Order (Picked unit) to train/upgrade to a (Unit-type of DyingUnit)
                  • Game - Display to (All players matching ((Owner of DyingUnit) Equal to (Owner of DyingUnit))) the text: (Auto Rebuild: + (Name of DyingUnit))
                • Else - Actions
          • Unit Group - Remove DyingUnit2[Building_Int[3]] from BuildingGroup
          • Set Build_curReal[Building_Int[3]] = 0.00
          • Set Building_Int[1] = (Building_Int[1] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Building_Int[1] Equal to 0
            • Then - Actions
              • Set Building_Int[2] = 0
            • Else - Actions
        • Else - Actions
well i figured it will be impossible with just triggers..
since you can't easily say which unit has been build where, when it dies
so you just pick every building and tell them to rebuild it
i can live with over replacement :)
 
Last edited:
Level 9
Joined
Dec 12, 2007
Messages
489
well I have left GUI for years, but won't this do what you want?
though I realize that how GUI handle their 'Set <var_name> = ....' is not enough, a short custom script is needed.

Requires:
Unit-Type variable named DyingUnit
Boolean array variable named IsRebuild
Player variable named Owner
Unit Group variable named TempGroup


  • Auto Rebuild
    • Events
      • Unit - A unit Dies
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Owner of (Triggering unit)) Not equal to Neutral Hostile
          • (Owner of (Triggering unit)) Not equal to Neutral Extra
          • (Owner of (Triggering unit)) Not equal to Neutral Victim
          • (Owner of (Triggering unit)) Not equal to Neutral Passive
    • Actions
      • Set DyingUnit = (Unit-type of (Triggering unit))
      • Set Owner = (Owner of (Triggering unit))
      • Set IsRebuild[(Player number of Owner)] = False
      • Set TempGroup = (Units owned by Owner matching (((Matching unit) is A structure) Equal to True))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • IsRebuild[(Player number of Owner)] Equal to False
            • Then - Actions
              • Custom script: set udg_IsRebuild[GetConvertedPlayerId(udg_Owner)] = IssueImmediateOrderById( GetEnumUnit(), udg_DyingUnit )
            • Else - Actions


This will work on all players excluding the Neutrals, haven't checked the behaviour upon Hero death.
This is exactly what my previous hint workaround with boolean variable, and it actually worked.
Did you really try?

Test map included for convenience, just send that peon, grunt, and raider to their death to Undead Tower at left bottom map.
the only drawback is that it will not rebuilding if required resource is not available upon death.

Additional info: test map is not optimized to be leak free.
 

Attachments

  • testmap.w3x
    13.7 KB · Views: 54
Level 8
Joined
Sep 30, 2012
Messages
205
Kick ass! Good job! Thanks man!

Yeah i did try it.. but i just lack the skill
and i might be stupid for that matter..
i should learn custom script after all

neato burrito

hey its a good thing that it still checks if you have the required resources and food! otherwise it would be of no use (well for me that is :p)


hey found a tiny flaw..
if two grunts die, one barrack will queue both, while the other stays idle..
i will try to solve it and come back if i can't figure it out
 
Last edited:
Level 33
Joined
Mar 27, 2008
Messages
8,035
You gotta use Hashtable for this.
For each initial spawn of units from a barrack, save the spawned unit to the barrack.
Once the unit dies, load the saved unit (which is the barrack) and order the barrack to train it.
This way, it will provide less data collision.
 
Level 9
Joined
Dec 12, 2007
Messages
489
hey its a good thing that it still checks if you have the required resources and food! otherwise it would be of no use (well for me that is :p)

hey found a tiny flaw..
if two grunts die, one barrack will queue both, while the other stays idle..
i will try to solve it and come back if i can't figure it out
well that check resource part is hardcoded by train order, you'll have to workaround it if you want to auto rebuild it even if the player has not enough required resource.

that flaw came from the way WC3 handle group enumeration, it always loop in same order through each unit, so you need more workaround for this.
You gotta use Hashtable for this.
For each initial spawn of units from a barrack, save the spawned unit to the barrack.
Once the unit dies, load the saved unit (which is the barrack) and order the barrack to train it.
This way, it will provide less data collision.
yes, this will work perfectly in consideration that the barrack still intact/not destroyed upon that specific unit death. if not, you will need to check for another possible building to train that unit should the initial building is gone.
to add detail, the sample code provided before will fail if the building has full training queue.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
if not, you will need to check for another possible building to train that unit should the initial building is gone.
Why would you decided to continue others' legacy ?
If the building is destroyed, clear all data attached to it, that's it.
This is not a system that adds up to your Total Training Queue.
This is for the building specific only - if the unit A dies that this unit is from Building A, only Building A re-trains this unit.

Here's a simple test map for you to get the hang of it.

NOTE: This is just an example, many typical bugs would occur such as removing from system's register and such. This is just to show basic ideas.

Furthermore, this is my own version of Auto-build System.

The way I see it (OP's version), is that the system would find any available training facility that would re-train the lost unit - it is different than mine where the lost unit would find its original training building - else, it won't be re-trained.
 

Attachments

  • Auto-build System.w3x
    13.3 KB · Views: 42
Level 9
Joined
Dec 12, 2007
Messages
489
Why would you decided to continue others' legacy ?
If the building is destroyed, clear all data attached to it, that's it.
This is not a system that adds up to your Total Training Queue.
This is for the building specific only - if the unit A dies that this unit is from Building A, only Building A re-trains this unit.
there is no info specified about that, the only thing is certain is if a unit dies, it will be retrained (or rebuilded in OP's term). now if working with that certain idea that dead unit will be trained at the origin building:
I hate working with GUI, too much limitations, so this use a lot of custom scripts to maintain the GUI form.
  • Auto Rebuild
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to False
      • ((Triggering unit) is A structure) Equal to False
      • (Owner of (Triggering unit)) Not equal to Neutral Hostile
      • (Owner of (Triggering unit)) Not equal to Neutral Extra
      • (Owner of (Triggering unit)) Not equal to Neutral Victim
      • (Owner of (Triggering unit)) Not equal to Neutral Passive
    • Actions
      • Set DyingUnit = (Unit-type of (Triggering unit))
      • Set Owner = (Owner of (Triggering unit))
      • Set IsRebuild[(Player number of Owner)] = False
      • Set IsExist = False
      • Custom script: set udg_TempUnit = LoadUnitHandle(udg_HashTable,GetHandleId(GetTriggerUnit()),0)
      • Custom script: if (udg_TempUnit != null) and (GetWidgetLife(udg_TempUnit) >.405) then
      • Set IsExist = True
      • Custom script: endif
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IsExist Equal to True
        • Then - Actions
          • Custom script: set udg_IsRebuild[GetConvertedPlayerId(udg_Owner)] = IssueImmediateOrderById( udg_TempUnit, udg_DyingUnit )
        • Else - Actions
          • Set TempGroup = (Units owned by Owner matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)))
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • IsRebuild[(Player number of Owner)] Equal to False
                • Then - Actions
                  • Custom script: set udg_IsRebuild[GetConvertedPlayerId(udg_Owner)] = IssueImmediateOrderById( GetEnumUnit(), udg_DyingUnit )
                • Else - Actions
          • Custom script: call DestroyGroup(udg_TempGroup)
      • Custom script: call FlushChildHashtable(udg_HashTable,GetHandleId(GetTriggerUnit()))
  • Map Start
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set HashTable = (Last created hashtable)
  • Register
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • Set TempUnit = (Trained unit)
      • Custom script: call SaveUnitHandle(udg_HashTable, GetHandleId(udg_TempUnit), 0, GetTriggerUnit())
it attach the trained unit to the builder, and retrain it on death in respective building. if in any case there is no origin building, like preplaced unit (example unit provided) or origin building is gone, it will seek possible building to be retrained.
though that still imperfect as it still suffer from the same looping unit, so even though there is 2 possible building, it will train at one definite building.
it also has a hardcoded food limit check, didn't notice it before.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Perhaps I was misled by the idea of "Auto-rebuild lost unit from any available training building".

Nevertheless, it would be great if you check my test map attached in previous post.

If that's what he want (Auto-rebuild lost unit from any available training building), he just have to perform a first check (is the initial building still alive?)
If yes, re-train from there, if no - pick any 1 (ONE) building of the same type (that is still alive in the map owned by the same player) and order it to re-train, simple as that.

I can even reconfigure my test map to suit this situation.
 
Level 9
Joined
Dec 12, 2007
Messages
489
Perhaps I was misled by the idea of "Auto-rebuild lost unit from any available training building".

Nevertheless, it would be great if you check my test map attached in previous post.
did that, it works perfectly on its purpose to retrain the unit at only its origin building.

it would be great if dead units will be retrained at unoccupied available structure,
but seeing that there is no native condition that checks the process of training except the
'Event - A unit begin training a unit',
'Event - A unit finishes training a unit' and
'Event - A unit cancel training a unit',

it will need more workaround to:
1. check for unoccupied available structure.
2. if all available structure is occupied, check for the least queue.
but I guess that's for the OP to find out how.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
That version should only apply to specific building - unlike your current system now, it applies to ALL building.
Like I suggested in that thread, register the building into the system via Unit Selected unit method;

  • Enable Auto Build
    • Events
      • Player - Player 1 (Red) types a chat message containing -eab as A substring
    • Conditions
    • Actions
      • Unit Group - Add all units of (Units currently selected by Player 1 (Red)) to AutoBuildGroup
That's just a basic trigger, if I were you, I would make it as a Hashtable, using Boolean as variable for the option to turn on/off.
 
Level 8
Joined
Sep 30, 2012
Messages
205
wupsi i didn't check "check this" of Dark_Axl
ok thats even better since it just combined the too..
but i had problems doing that system of yours for myself..
my worldeditor doesn't like your custom scripts..

anyway so i did this. seems to be working fine, however sometimes (very rarely) he just misses some units to rebuild them, or trains them somewhere else even though the origin barrack is still alive..

(oh and each player can enable/disable the system.. thats the Ar: 1/0 from the HashtableAr)

any clue why that might have happened?


  • Rebuild
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to False
      • ((Triggering unit) is A structure) Equal to False
    • Actions
      • Set DyingUnit2 = (Triggering unit)
      • Set Owner = (Owner of DyingUnit2)
      • Set DyingUnit = (Unit-type of DyingUnit2)
      • Set IsRebuild[(Player number of Owner)] = False
      • Set Ar = (Load 0 of (Key (Owner of DyingUnit2)) from HashtableAr)
      • Set Barrack = (Load 0 of HandleID in Hashtable)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Ar Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Barrack is alive) Equal to True
            • Then - Actions
              • Set TrainedUnit = (Triggering unit)
              • Custom script: set udg_HandleID = GetHandleId(udg_TrainedUnit)
              • Set Barrack = (Load 0 of HandleID in Hashtable)
              • Unit - Order Barrack to train/upgrade to a DyingUnit
            • Else - Actions
              • Set TempGroup = (Units owned by Owner matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)))
              • Unit Group - Pick every unit in TempGroup and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • IsRebuild[(Player number of Owner)] Equal to False
                    • Then - Actions
                      • Custom script: set udg_IsRebuild[GetConvertedPlayerId(udg_Owner)] = IssueImmediateOrderById( GetEnumUnit(), udg_DyingUnit )
                    • Else - Actions
              • Custom script: call DestroyGroup(udg_TempGroup)
        • Else - Actions
      • Set DyingUnit2 = No unit
      • Set DyingUnit = No unit-type
      • Set IsRebuild[(Player number of Owner)] = False
      • Set Ar = 0
      • Set Barrack = No unit
i also can't explain that if i want to clear the child hashtable of the triggering unit all hell breaks loose and the pc doesn't know the origin of the dying unit -most of times..

  • Hashtable - Clear all child hashtables of child (Key (Dying unit)) in Hashtable
 

Attachments

  • (4)LostTempleARV1.w3x
    245.1 KB · Views: 40
Level 9
Joined
Dec 12, 2007
Messages
489
wupsi i didn't check "check this" of Dark_Axl
sad-cat.jpeg

  • Rebuild
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to False
      • ((Triggering unit) is A structure) Equal to False
    • Actions
      • Set DyingUnit2 = (Triggering unit)
      • Set Owner = (Owner of DyingUnit2)
      • Set DyingUnit = (Unit-type of DyingUnit2)
      • Set IsRebuild[(Player number of Owner)] = False
      • Set Ar = (Load 0 of (Key (Owner of DyingUnit2)) from HashtableAr)
      • Set Barrack = (Load 0 of HandleID in Hashtable)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Ar Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Barrack is alive) Equal to True
            • Then - Actions
              • Set TrainedUnit = (Triggering unit)
              • Custom script: set udg_HandleID = GetHandleId(udg_TrainedUnit)
              • Set Barrack = (Load 0 of HandleID in Hashtable)
              • Unit - Order Barrack to train/upgrade to a DyingUnit
            • Else - Actions
there are 4 flaws in your trigger.
1.
  • Conditions
    • ((Triggering unit) is A Hero) Equal to False
    • ((Triggering unit) is A structure) Equal to False
  • Actions
    • Set DyingUnit2 = (Triggering unit)
    • Set Owner = (Owner of DyingUnit2)
    • Set DyingUnit = (Unit-type of DyingUnit2)
    • Set IsRebuild[(Player number of Owner)] = False
    • Set Ar = (Load 0 of (Key (Owner of DyingUnit2)) from HashtableAr)
    • Set Barrack = (Load 0 of HandleID in Hashtable)
at Set Barrack, whose HandleID being loaded?

2.
  • If - Conditions
    • (Barrack is alive) Equal to True
  • Then - Actions
    • Set TrainedUnit = (Triggering unit)
    • Custom script: set udg_HandleID = GetHandleId(udg_TrainedUnit)
    • Set Barrack = (Load 0 of HandleID in Hashtable)
    • Unit - Order Barrack to train/upgrade to a DyingUnit
  • Else - Actions
why need to redeclare Triggering Unit into another variable "TrainedUnit" when you already stored it in DyingUnit?

3. why need to set barrack again? when its should be the same barrack as above?

4. you need another trigger that register the barrack to the new retrained unit, like in my earlier post, like this one:
  • Register
  • Events
  • Unit - A unit Finishes training a unit
  • Conditions
  • Actions
  • Set TempUnit = (Trained unit)
  • Custom script: call SaveUnitHandle(udg_HashTable, GetHandleId(udg_TempUnit), 0, GetTriggerUnit())
that way, newly trained unit also have barrack to reference.

i also can't explain that if i want to clear the child hashtable of the triggering unit all hell breaks loose and the pc doesn't know the origin of the dying unit -most of times..

  • Hashtable - Clear all child hashtables of child (Key (Dying unit)) in Hashtable
where exactly did you put that line? obviously you only flushchildhashtable when that unit already dead and its hashtable value already loaded and not needed anymore, if not, of course it won't be able to retrieve the source barrack anymore.
 
Level 8
Joined
Sep 30, 2012
Messages
205
yeahyeah i do have register, didn't posted it earlier

my worldeditor won't save your custom script:
  • Custom script: call SaveUnitHandle(udg_HashTable, GetHandleId(udg_TempUnit), 0, GetTriggerUnit())
Error: Expected a name..

renamed the DyingUnit to DyingUnitTyp
and DyingUnit2 to DyingUnit to make it easier to read

and now its even shittier than before :(

  • Register
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • Set Barrack = (Triggering unit)
      • Set TrainedUnit = (Trained unit)
      • Custom script: set udg_HandleID = GetHandleId(udg_TrainedUnit)
      • Hashtable - Save Handle OfBarrack as 0 of HandleID in Hashtable
      • Set Barrack = No unit
      • Set TrainedUnit = No unit
  • Rebuild
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to False
      • ((Triggering unit) is A structure) Equal to False
    • Actions
      • Set DyingUnit = (Triggering unit)
      • Set Owner = (Owner of DyingUnit)
      • Set Ar = (Load 0 of (Key (Owner of DyingUnit)) from HashtableAr)
      • Set DyingUnitTyp = (Unit-type of DyingUnit)
      • Set IsRebuild[(Player number of Owner)] = False
      • Set Barrack = (Load 0 of HandleID in Hashtable)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Ar Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Barrack is alive) Equal to True
            • Then - Actions
              • Custom script: set udg_HandleID = GetHandleId(udg_DyingUnit)
              • Unit - Order Barrack to train/upgrade to a DyingUnitTyp
            • Else - Actions
              • Set TempGroup = (Units owned by Owner matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)))
              • Unit Group - Pick every unit in TempGroup and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • IsRebuild[(Player number of Owner)] Equal to False
                    • Then - Actions
                      • Custom script: set udg_IsRebuild[GetConvertedPlayerId(udg_Owner)] = IssueImmediateOrderById( GetEnumUnit(), udg_DyingUnitTyp )
                    • Else - Actions
              • Custom script: call DestroyGroup(udg_TempGroup)
        • Else - Actions
      • Set DyingUnit = No unit
      • Set DyingUnitTyp = No unit-type
      • Set IsRebuild[(Player number of Owner)] = False
      • Set Ar = 0
      • Set Barrack = No unit

yeah i left the clear hashtable command out for now, since it caused more problems it was at the very end of the trigger "rebuild"
 
Level 9
Joined
Dec 12, 2007
Messages
489
my worldeditor won't save your custom script:
  • Custom script: call SaveUnitHandle(udg_HashTable, GetHandleId(udg_TempUnit), 0, GetTriggerUnit())
Error: Expected a name..
if you copied that directly without editing, of course it would error out. to use it, you need to edit it to match with the global variable you're using.
  • Register
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • Set Barrack = (Triggering unit)
      • Set TrainedUnit = (Trained unit)
      • Custom script: set udg_HandleID = GetHandleId(udg_TrainedUnit)
      • Hashtable - Save Handle OfBarrack as 0 of HandleID in Hashtable
      • Set Barrack = No unit
      • Set TrainedUnit = No unit
to match yours, the line would be:
  • Custom script: call SaveUnitHandle(udg_Hashtable, GetHandleId(udg_TrainedUnit), 0, GetTriggerUnit())
notice the case different and different variable name.
  • Rebuild
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to False
      • ((Triggering unit) is A structure) Equal to False
    • Actions
      • Set DyingUnit = (Triggering unit)
      • Set Owner = (Owner of DyingUnit)
      • Set Ar = (Load 0 of (Key (Owner of DyingUnit)) from HashtableAr)
      • Set DyingUnitTyp = (Unit-type of DyingUnit)
      • Set IsRebuild[(Player number of Owner)] = False
      • Set Barrack = (Load 0 of HandleID in Hashtable)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Ar Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Barrack is alive) Equal to True
            • Then - Actions
              • Custom script: set udg_HandleID = GetHandleId(udg_DyingUnit)
              • Unit - Order Barrack to train/upgrade to a DyingUnitTyp
            • Else - Actions
              • Set TempGroup = (Units owned by Owner matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) is alive) Equal to True)))
              • Unit Group - Pick every unit in TempGroup and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • IsRebuild[(Player number of Owner)] Equal to False
                    • Then - Actions
                      • Custom script: set udg_IsRebuild[GetConvertedPlayerId(udg_Owner)] = IssueImmediateOrderById( GetEnumUnit(), udg_DyingUnitTyp )
                    • Else - Actions
              • Custom script: call DestroyGroup(udg_TempGroup)
        • Else - Actions
      • Set DyingUnit = No unit
      • Set DyingUnitTyp = No unit-type
      • Set IsRebuild[(Player number of Owner)] = False
      • Set Ar = 0
      • Set Barrack = No unit
you still didn't answer my previous post point 1. you misplaced the set udg_handleID = GetHandleId(udg_DyingUnit), it should be above the set barrack at least.
yeah i left the clear hashtable command out for now, since it caused more problems it was at the very end of the trigger "rebuild"
that's your problem, you should place that line of code before you set those global variable to null, at least above the set DyingUnit = no unit.
 
Status
Not open for further replies.
Top