• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

custom main hall problem. ( not a rookie )

Status
Not open for further replies.
Level 3
Joined
Jan 18, 2012
Messages
26
okay so i need to fix a bug with my map. Settin the unit classification at object editor to 'town hall' Wont Work, neither does the gameplay constants, so i need a trigger for that... i have somethin but it doesnt work well ( if u build more than 2 )
that is not the proper way to do this because if a 2nd one is created it sets the 2nd one as 'hiddenbasevariable' , so the 1st one has no variable now.... and it can not be deleted ( after a custom hall is killed )
  • Events
    • Unit - A unit Begins construction
  • Conditions
    • (Unit-type of (Triggering unit)) Equal to (==) Temple of Tides
  • Actions
    • Set NrofTownHalls[(Player number of (Owner of (Triggering unit)))] = NrofTownHalls[((Player number of (Owner of (Triggering unit))) + 1)]
    • Unit - Create 1 Castle for (Owner of (Triggering unit)) at (Position of (Constructing structure)) facing Default building facing (270.0) degrees
    • Set RevealBuildings[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
    • Set HiddenBaseVariable = (Last created unit)
    • Unit - Hide (Last created unit)
    • Unit - Add Invulnerable (Neutral) to (Last created unit)
    • Unit - Turn collision for (Last created unit) Off
    • Unit - Add classification of Ethereal to (Last created unit)
    • Unit - Remove Return Gold and Lumber from (Last created unit)
Heres what i have for the invisible castle remove after a custom hall is killed:
  • Unit - Kill HiddenBaseVariable
So ... any ideas how to fix it so it can act as a regular town hall would...?
 
Level 3
Joined
Jan 18, 2012
Messages
26
Thanks for the tip, ill try it :)!
and , temple of tides doesnt work like regular town hall ( because if theres more than 2 , and temple of tides is killed, a player still has an invisible castle, and cant be defeated)
 
Level 3
Joined
Jan 18, 2012
Messages
26
Oh and 1 thing, what trigger to make, so that only 1 unit will be removed from the group, when a temple of tides is killed?
 
Level 3
Joined
Jan 18, 2012
Messages
26
Ah i found a solution :) thanks to you i got an idea... make unit group for every player and add invis castle to unit group , and later if a temple of tides is killed, it takes first unit in unit group and removes it from game.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Thanks for the tip, ill try it :)!
and , temple of tides doesnt work like regular town hall ( because if theres more than 2 , and temple of tides is killed, a player still has an invisible castle, and cant be defeated)

T

Oh and 1 thing, what trigger to make, so that only 1 unit will be removed from the group, when a temple of tides is killed?

T

Ah i found a solution :) thanks to you i got an idea... make unit group for every player and add invis castle to unit group , and later if a temple of tides is killed, it takes first unit in unit group and removes it from game.

Tripple Post! :goblin_boom:

b.t.w. you're sure it's got nothing to do with this?:

(Unit-type of (Triggering unit)) Equal to (==) Temple of Tides

Unit - A unit Begins construction

The unit beginning the construction is the triggering unit, you know that right?
You might be looking for Constructing structure here instead. Just a wild guess...

I don't think a Temple of Tides is supposed to construct a structure right? Tell me if I'm mistaken...



Also: why refference 2 variables to be last created unit and then afterwards not even use them inside that same trigger? I don't get it :S
Why this:
  • Set HiddenBaseVariable = (Last created unit)
    • Unit - Hide (Last created unit)
    • Unit - Add Invulnerable (Neutral) to (Last created unit)
    • Unit - Turn collision for (Last created unit) Off
    • Unit - Add classification of Ethereal to (Last created unit)
    • Unit - Remove Return Gold and Lumber from (Last created unit)
instead of this:
  • Set HiddenBaseVariable = (Last created unit)
    • Unit - Hide HiddenBaseVariable
    • Unit - Add Invulnerable (Neutral) to HiddenBaseVariable
    • Unit - Turn collision for HiddenBaseVariable Off
    • Unit - Add classification of Ethereal to HiddenBaseVariable
    • Unit - Remove Return Gold and Lumber from HiddenBaseVariable
You should know that using a variable as refference is faster then using a function call which returns a value indirectly.

JASS:
function GetLastCreatedUnit takes nothing returns unit
    return bj_lastCreatedUnit
endfunction


Ah i found a solution :) thanks to you i got an idea... make unit group for every player and add invis castle to unit group , and later if a temple of tides is killed, it takes first unit in unit group and removes it from game.

This is a highly inefficient solution. Your going to create a unit group for each player just to store 1 unit which later on will be removed???
Why not set the castle to a variable, check if a temple of tides is killed and then simply remove the castle?
 
Last edited:
Level 3
Joined
Jan 18, 2012
Messages
26
yes hash, that solution you are saying is what i had before, but it didnt work if you built 2 temple of tides, because it sets hiddenbasevariable to the last created unit, so the castle that was created before that isnt hiddenbasevariable anymore, so if temple of tides is killed, the invisible castle that was created, would not be removed
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
yes hash, that solution you are saying is what i had before, but it didnt work if you built 2 temple of tides, because it sets hiddenbasevariable to the last created unit, so the castle that was created before that isnt hiddenbasevariable anymore, so if temple of tides is killed, the invisible castle that was created, would not be removed

Then why not use an array with an index variable?

index default value is 0

set index = index + 1
hiddenbasevariable[index] = last created unit

so first time the trigger is fired:
hiddenbasevariable[1] = last created unit

second time:
hiddenbasevariable[2] = last created unit

third time:
hiddenbasevariable[3] = last created unit

etc.

Now there's still one problem: what if you remove the unit from hiddenbasevariable[2]?

Well then we simply move all the other arrays in the index that are above the one that was being removed down by one. I created a small jass script that can do that.
Simply copy and paste it into a new trigger that you've converted to custom text.

JASS:
function cleanArray takes integer whichIndex returns nothing
      loop
         exitwhen whichIndex == udg_index
         set udg_hiddenbasevariable[whichIndex] = udg_hiddenbasevariable[whichIndex + 1]
         set udg_hiddenbasevariable[whichIndex + 1] = null
         set whichIndex = whichIndex + 1
      endloop
      set udg_index = udg_index - 1
endfunction

Then whenever you remove the unit from hiddenbasevariable[2] you simply use this Custom script:
call cleanArray(2)

Where 2 is the same index as the unit being removed.
 
Level 3
Joined
Jan 18, 2012
Messages
26
yes Major is right, and Hashj theres still a problem if different people use it, for example if i build 1 and my enemy builds 1, then mine gets destroyed , but enemy's castle is removed?

Anyways i found a working solution, was long but at least it works:
  • Events
    • Unit - A unit Begins construction
  • Conditions
    • (Unit-type of (Triggering unit)) Equal to (==) Temple of Tides
  • Actions
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 1 (Red)
      • Then - Actions
        • Set NrofTownHalls[(Player number of (Owner of (Triggering unit)))] = NrofTownHalls[((Player number of (Owner of (Triggering unit))) + 1)]
        • Unit - Create 1 Castle for (Owner of (Triggering unit)) at (Position of (Constructing structure)) facing Default building facing (270.0) degrees
        • Set RevealBuildings[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
        • Unit Group - Add (Last created unit) to Player1UnitGroup
        • Unit - Hide (Last created unit)
        • Unit - Add Invulnerable (Neutral) to (Last created unit)
        • Unit - Turn collision for (Last created unit) Off
        • Unit - Remove Return Gold and Lumber from (Last created unit)
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 2 (Blue)
      • Then - Actions
        • Set NrofTownHalls[(Player number of (Owner of (Triggering unit)))] = NrofTownHalls[((Player number of (Owner of (Triggering unit))) + 1)]
        • Unit - Create 1 Castle for (Owner of (Triggering unit)) at (Position of (Constructing structure)) facing Default building facing (270.0) degrees
        • Set RevealBuildings[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
        • Unit Group - Add (Last created unit) to PLayer2UnitGroupuu
        • Unit - Add Invulnerable (Neutral) to (Last created unit)
        • Unit - Hide (Last created unit)
        • Unit - Turn collision for (Last created unit) Off
        • Unit - Remove Return Gold and Lumber from (Last created unit)
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 3 (Teal)
      • Then - Actions
        • Set NrofTownHalls[(Player number of (Owner of (Triggering unit)))] = NrofTownHalls[((Player number of (Owner of (Triggering unit))) + 1)]
        • Unit - Create 1 Castle for (Owner of (Triggering unit)) at (Position of (Constructing structure)) facing Default building facing (270.0) degrees
        • Set RevealBuildings[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
        • Unit Group - Add (Last created unit) to PLayer3UnitGroup
        • Unit - Add Invulnerable (Neutral) to (Last created unit)
        • Unit - Turn collision for (Last created unit) Off
        • Unit - Remove Return Gold and Lumber from (Last created unit)
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 4 (Purple)
      • Then - Actions
        • Set NrofTownHalls[(Player number of (Owner of (Triggering unit)))] = NrofTownHalls[((Player number of (Owner of (Triggering unit))) + 1)]
        • Unit - Create 1 Castle for (Owner of (Triggering unit)) at (Position of (Constructing structure)) facing Default building facing (270.0) degrees
        • Set RevealBuildings[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
        • Unit Group - Add (Last created unit) to PLayer4UnitGroup
        • Unit - Add Invulnerable (Neutral) to (Last created unit)
        • Unit - Turn collision for (Last created unit) Off
        • Unit - Remove Return Gold and Lumber from (Last created unit)
        • Unit - Hide (Last created unit)
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 5 (Yellow)
      • Then - Actions
        • Set NrofTownHalls[(Player number of (Owner of (Triggering unit)))] = NrofTownHalls[((Player number of (Owner of (Triggering unit))) + 1)]
        • Unit - Create 1 Castle for (Owner of (Triggering unit)) at (Position of (Constructing structure)) facing Default building facing (270.0) degrees
        • Set RevealBuildings[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
        • Unit Group - Add (Last created unit) to Player5UnitGroup
        • Unit - Add Invulnerable (Neutral) to (Last created unit)
        • Unit - Turn collision for (Last created unit) Off
        • Unit - Hide (Last created unit)
        • Unit - Remove Return Gold and Lumber from (Last created unit)
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 6 (Orange)
      • Then - Actions
        • Set NrofTownHalls[(Player number of (Owner of (Triggering unit)))] = NrofTownHalls[((Player number of (Owner of (Triggering unit))) + 1)]
        • Unit - Create 1 Castle for (Owner of (Triggering unit)) at (Position of (Constructing structure)) facing Default building facing (270.0) degrees
        • Set RevealBuildings[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
        • Unit Group - Add (Last created unit) to Player6UnitGroup
        • Unit - Add Invulnerable (Neutral) to (Last created unit)
        • Unit - Turn collision for (Last created unit) Off
        • Unit - Hide (Last created unit)
        • Unit - Remove Return Gold and Lumber from (Last created unit)
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 7 (Green)
      • Then - Actions
        • Set NrofTownHalls[(Player number of (Owner of (Triggering unit)))] = NrofTownHalls[((Player number of (Owner of (Triggering unit))) + 1)]
        • Unit - Create 1 Castle for (Owner of (Triggering unit)) at (Position of (Constructing structure)) facing Default building facing (270.0) degrees
        • Set RevealBuildings[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
        • Unit Group - Add (Last created unit) to Player7UnitGroup
        • Unit - Add Invulnerable (Neutral) to (Last created unit)
        • Unit - Turn collision for (Last created unit) Off
        • Unit - Hide (Last created unit)
        • Unit - Remove Return Gold and Lumber from (Last created unit)
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 8 (Pink)
      • Then - Actions
        • Set NrofTownHalls[(Player number of (Owner of (Triggering unit)))] = NrofTownHalls[((Player number of (Owner of (Triggering unit))) + 1)]
        • Unit - Create 1 Castle for (Owner of (Triggering unit)) at (Position of (Constructing structure)) facing Default building facing (270.0) degrees
        • Set RevealBuildings[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
        • Unit Group - Add (Last created unit) to Player8UnitGroup
        • Unit - Add Invulnerable (Neutral) to (Last created unit)
        • Unit - Turn collision for (Last created unit) Off
        • Unit - Hide (Last created unit)
        • Unit - Remove Return Gold and Lumber from (Last created unit)
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 9 (Gray)
      • Then - Actions
        • Set NrofTownHalls[(Player number of (Owner of (Triggering unit)))] = NrofTownHalls[((Player number of (Owner of (Triggering unit))) + 1)]
        • Unit - Create 1 Castle for (Owner of (Triggering unit)) at (Position of (Constructing structure)) facing Default building facing (270.0) degrees
        • Set RevealBuildings[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
        • Unit Group - Add (Last created unit) to Player9UnitGroup
        • Unit - Add Invulnerable (Neutral) to (Last created unit)
        • Unit - Turn collision for (Last created unit) Off
        • Unit - Hide (Last created unit)
        • Unit - Remove Return Gold and Lumber from (Last created unit)
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 10 (Light Blue)
      • Then - Actions
        • Set NrofTownHalls[(Player number of (Owner of (Triggering unit)))] = NrofTownHalls[((Player number of (Owner of (Triggering unit))) + 1)]
        • Unit - Create 1 Castle for (Owner of (Triggering unit)) at (Position of (Constructing structure)) facing Default building facing (270.0) degrees
        • Set RevealBuildings[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
        • Unit Group - Add (Last created unit) to Player10UnitGroup
        • Unit - Add Invulnerable (Neutral) to (Last created unit)
        • Unit - Turn collision for (Last created unit) Off
        • Unit - Hide (Last created unit)
        • Unit - Remove Return Gold and Lumber from (Last created unit)
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 11 (Dark Green)
      • Then - Actions
        • Set NrofTownHalls[(Player number of (Owner of (Triggering unit)))] = NrofTownHalls[((Player number of (Owner of (Triggering unit))) + 1)]
        • Unit - Create 1 Castle for (Owner of (Triggering unit)) at (Position of (Constructing structure)) facing Default building facing (270.0) degrees
        • Set RevealBuildings[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
        • Unit Group - Add (Last created unit) to Player11UnitGroup
        • Unit - Add Invulnerable (Neutral) to (Last created unit)
        • Unit - Turn collision for (Last created unit) Off
        • Unit - Hide (Last created unit)
        • Unit - Remove Return Gold and Lumber from (Last created unit)
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 12 (Brown)
      • Then - Actions
        • Set NrofTownHalls[(Player number of (Owner of (Triggering unit)))] = NrofTownHalls[((Player number of (Owner of (Triggering unit))) + 1)]
        • Unit - Create 1 Castle for (Owner of (Triggering unit)) at (Position of (Constructing structure)) facing Default building facing (270.0) degrees
        • Set RevealBuildings[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
        • Unit Group - Add (Last created unit) to Player12UnitGroup
        • Unit - Add Invulnerable (Neutral) to (Last created unit)
        • Unit - Turn collision for (Last created unit) Off
        • Unit - Hide (Last created unit)
        • Unit - Remove Return Gold and Lumber from (Last created unit)
      • Else - Actions
        • Do nothing
And TO remove the castle:
  • Events
    • Unit - A unit Dies
  • Conditions
    • (Unit-type of (Dying unit)) Equal to (==) Temple of Tides
  • Actions
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 1 (Red)
      • Then - Actions
        • Unit - Remove (Random unit from Player1UnitGroup) from the game
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 2 (Blue)
      • Then - Actions
        • Unit - Remove (Random unit from PLayer2UnitGroupuu) from the game
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 3 (Teal)
      • Then - Actions
        • Unit - Remove (Random unit from PLayer3UnitGroup) from the game
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 4 (Purple)
      • Then - Actions
        • Unit - Remove (Random unit from PLayer4UnitGroup) from the game
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 5 (Yellow)
      • Then - Actions
        • Unit - Remove (Random unit from Player5UnitGroup) from the game
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 6 (Orange)
      • Then - Actions
        • Unit - Remove (Random unit from Player6UnitGroup) from the game
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 7 (Green)
      • Then - Actions
        • Unit - Remove (Random unit from Player7UnitGroup) from the game
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 8 (Pink)
      • Then - Actions
        • Unit - Remove (Random unit from Player8UnitGroup) from the game
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 9 (Gray)
      • Then - Actions
        • Unit - Remove (Random unit from Player9UnitGroup) from the game
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 10 (Light Blue)
      • Then - Actions
        • Unit - Remove (Random unit from Player10UnitGroup) from the game
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 11 (Dark Green)
      • Then - Actions
        • Unit - Remove (Random unit from Player11UnitGroup) from the game
      • Else - Actions
        • Do nothing
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to (==) Player 12 (Brown)
      • Then - Actions
        • Unit - Remove (Random unit from Player12UnitGroup) from the game
      • Else - Actions
        • Do nothing
 
Last edited:
Level 9
Joined
Nov 19, 2011
Messages
516
Use for actions

  • FOR
    • Events
      • Unit - A unit dies
    • Conditions
      • Unit type (triggering unit) equals Temple of Tides
    • Actions
      • For each (Integer A) do
        • Actions
          • If (Owner of (Triggering Unit) equals Player(For loop integer A)) then (Unit - Remove (Random unit from PlayerUnitGroup[For loop integer A] from the game)) else (Do Nothing)
Thats shorter but works same way than 2nd trigger. And is easier to modify of course.
 
Last edited:
Please remove Do Nothing from your triggers, there is no need for it really :)
That's 12 + 12 = 24
24 DoNothing will result adding 4 lines of code into script per 1 Do Nothing call = 96 lines of unneeded code :)

Also use arrays and for loop actions to reduce number of triggers from 12 (1 for each player) to single 1 trigger.
 
Last edited:
Status
Not open for further replies.
Top