• 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.

downgrade group selection

Status
Not open for further replies.
Level 3
Joined
Feb 11, 2013
Messages
21
Hey guys, my first post and also my first map build attempt.

So I'm creating a TD and I want to downgrade groups of towers together and then keep the selection on the group. I can only achieve selecting the last replaced unit which is one. Here's my code:

ij9ugolpj


Thanks!
 

Attachments

  • downgrade.png
    downgrade.png
    49.2 KB · Views: 115
Level 3
Joined
Feb 10, 2013
Messages
40
I don't think triggers are required in this case, or I misunderstood your problem.

In classic Warcraft III, selecting multiple Ziggurats (for example) and clicking the "Upgrade to Spirit Tower" button will upgrade them while keeping the group selected. To do so, you need to add the downgraded unit to your original tower's "Techtree - Upgrades to" value in the Object Editor

Or did I misunderstand ?

PS : Next time, copy your trigger using "Copy as text" and copy that text between [trigger ][ /trigger] banners :p

Hope this helps !
 
Level 3
Joined
Feb 11, 2013
Messages
21
Hey thanks for the fast reply and the tips on the trigger posting.

Yeah I could do what you suggest but propably the downgrade icon would be lost and maybe by downgrading I would rebuy my old tower.

I could recreate all my towers with a different icon and cost but thats just inefficient.

Any other suggestions?
 
Level 3
Joined
Feb 11, 2013
Messages
21
I want to downgrade group of towers

And the actions that I want to do are:
-downgrade the group of towers.
-return the money of the last upgrade(sum).
-select the selection the triggering player had.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
I know this will use alot of ifs but it is easier and much easier to read.
  • Untitled Trigger 001
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • Unit - Add a 0.01 second Generic expiration timer to (Sold unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Selling unit)) Equal to Guard Tower
        • Then - Actions
          • Unit - Replace (Selling unit) with a Scout Tower using The new unit's default life and mana
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Selling unit)) Equal to Cannon Tower
        • Then - Actions
          • Unit - Replace (Selling unit) with a Arcane Tower using The new unit's default life and mana
        • Else - Actions
      • Selection - Select (Last replaced unit) for (Triggering player)

I can try to make something more advanced if you want to.
 
Level 3
Joined
Feb 11, 2013
Messages
21
Hey thanks for trying to help me, but I think you didn't understand what I need.

The main thing I want to do is to group downgrade the towers and after that, maintain the selection of the group selected.
To make myself clear, let's say I have three Air towers LVL3 and I want to downgrade them. I select them all and click the downgrade button, the action does happen, but then it just selects the one of the three towers.

I hope I made myself clear,
thanks again guys for the replies!
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
This works for me, but it is in JASS for the large part:

Setup Trigger:
  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)
      • -------- === Setup Building Downgrades === --------
      • -------- Castle --> Keep (+800 gold) --------
      • Custom script: call SaveInteger(udg_Hashtable, 'hcas', 0, 'hkee')
      • Custom script: call SaveInteger(udg_Hashtable, 'hcas', 1, 800)
      • -------- Keep --> Town Hall (+500 gold) --------
      • Custom script: call SaveInteger(udg_Hashtable, 'hkee', 0, 'htow')
      • Custom script: call SaveInteger(udg_Hashtable, 'hkee', 1, 500)
      • -------- Blacksmith --> Lumber Mill (+350 gold) --------
      • Custom script: call SaveInteger(udg_Hashtable, 'hbla', 0, 'hlum')
      • Custom script: call SaveInteger(udg_Hashtable, 'hbla', 1, 350)
      • -------- Cannon Tower --> Watch Tower (+200 gold) --------
      • Custom script: call SaveInteger(udg_Hashtable, 'hctw', 0, 'hwtw')
      • Custom script: call SaveInteger(udg_Hashtable, 'hctw', 1, 200)
      • -------- Guard Tower --> Watch Tower (+100 gold) --------
      • Custom script: call SaveInteger(udg_Hashtable, 'hgtw', 0, 'hwtw')
      • Custom script: call SaveInteger(udg_Hashtable, 'hgtw', 1, 100)
      • -------- Hero Altar --> Farm (+125 gold) --------
      • Custom script: call SaveInteger(udg_Hashtable, 'halt', 0, 'hhou')
      • Custom script: call SaveInteger(udg_Hashtable, 'halt', 1, 125)
System (you don't have to change anything here):
  • Downgrade
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units currently selected by (Triggering player)) 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 (Triggering player)
            • Then - Actions
              • Custom script: set udg_HandleId = GetUnitTypeId(GetEnumUnit())
              • Custom script: set udg_TempInt = LoadInteger(udg_Hashtable, udg_HandleId, 0)
              • Custom script: if udg_TempInt > 0 then
              • Unit - Kill (Picked unit)
              • Unit - Remove (Picked unit) from the game
              • Custom script: call SetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) + LoadInteger(udg_Hashtable, udg_HandleId, 1))
              • Custom script: set bj_lastCreatedUnit = CreateUnit(GetTriggerPlayer(), udg_TempInt, GetUnitX(GetEnumUnit()), GetUnitY(GetEnumUnit()), 270.)
              • Selection - Add (Last created unit) to selection for (Triggering player)
              • Custom script: endif
            • Else - Actions
The reason I choose this method, is so it doesn't have to loop through all the possible building types it could be.
It just picks the building and changes it (if possible), no loops.

The setup goes as following:
call SaveInteger(udg_Hashtable, 'hcas', 0, 'hkee') saves the downgraded building.
call SaveInteger(udg_Hashtable, 'hcas', 1, 800) saves the gold cost.
All those things between apostrophes you see are Raw Id's. Go to the object editor and press CTRL + D, all object names will now be 4-character 'strings' (they're actually integers, but that aside).

In the code, the first part is the building that gets downgraded. In the examples above, this is the Human Castle ('hcas').
The second part is the value that gets saved. The building that gets saved is the Human Keep ('hkee'), the gold cost is 800 (random value :D).

I've attached a demo-map for easier copying.
(The comments are to make it easier, you don't have to write it out for each building ^^).

Edit: oops, the spell should have "Unique Cast" enabled :D (fixed).
 

Attachments

  • Downgrade Buildings.w3x
    18 KB · Views: 42
Level 3
Joined
Feb 11, 2013
Messages
21
That's a great post dude I'm tottaly grateful. Gonna dig into learning how to use JASS and gonna reply with the results asap.
 
Status
Not open for further replies.
Top