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

Add 2nd page of abilities?

Status
Not open for further replies.
Level 1
Joined
Apr 25, 2020
Messages
3
Is it possible to add a second page of abilities to a unit?

I have a building that upgrades into the different races in the game and I was trying to add another race but that building is full. I tried adding a second building with the new race but I couldn't figure out how to make it kill the first building when you build the race from the second building. So if I can't add another page of abilities, how would I make the 2nd building kill the 1st? I don't want the players to be able to have 2 races.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
You can store the buildings as Unit variables (Array = On) and determine which structure to destroy like this:
  • Define Buildings
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Player 1: --------
      • Set VariableSet Building1[1] = Scout Tower 0000 <gen>
      • Set VariableSet Building2[1] = Scout Tower 0001 <gen>
      • -------- Player 2: --------
      • Set VariableSet Building1[2] = Scout Tower 0002 <gen>
      • Set VariableSet Building2[2] = Scout Tower 0003 <gen>
Then when you upgrade one of the two buildings you can easily check which one was upgraded and kill the other one.
  • Choose Race
    • Events
      • Unit - A unit Finishes an upgrade
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Equal to Building1[(Player number of (Triggering player))]
        • Then - Actions
          • Unit - Kill Building2[(Player number of (Triggering player))]
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to Building2[(Player number of (Triggering player))]
            • Then - Actions
              • Unit - Kill Building1[(Player number of (Triggering player))]
            • Else - Actions
And if you want to use a Page system it's slightly more complex. Here's one I had made for someone else a little while ago. This was designed for Training Units but it works pretty much exactly the same for Upgrading Units as well.
  • BPS Initial Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- CONFIGURE: --------
      • -------- - --------
      • -------- Set this to the total number of Structure TYPES that use this system. So if for example you were using each Race's Altar of Storms/Kings/etc... this should be set to 4 --------
      • Set VariableSet bps_TotalStructures = 1
      • -------- - --------
      • -------- Set these to the Next Page/ Previous Page abilities --------
      • Set VariableSet bps_NextPageAbility = Next Page
      • Set VariableSet bps_PrevPageAbility = Previous Page
      • -------- - --------
      • -------- STOP HERE --------
      • -------- - --------
      • Hashtable - Create a hashtable
      • Set VariableSet bps_Hashtable = (Last created hashtable)
      • Set VariableSet bps_StructureTypeLimit = (3 + bps_TotalStructures)
  • Add Barracks To System
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- CONFIGURE: --------
      • -------- - --------
      • Set VariableSet bps_Structure = Barracks
      • -------- - --------
      • Set VariableSet bps_TotalUnitsTrained = 14
      • -------- - --------
      • Set VariableSet bps_MaxUnitsPerPage = 8
      • -------- - --------
      • Set VariableSet bps_UnitType[1] = Footman
      • Set VariableSet bps_UnitType[2] = Knight
      • Set VariableSet bps_UnitType[3] = Rifleman
      • Set VariableSet bps_UnitType[4] = Mortar Team
      • Set VariableSet bps_UnitType[5] = Flying Machine
      • Set VariableSet bps_UnitType[6] = Gryphon Rider
      • Set VariableSet bps_UnitType[7] = Priest
      • Set VariableSet bps_UnitType[8] = Sorceress
      • Set VariableSet bps_UnitType[9] = Siege Engine
      • Set VariableSet bps_UnitType[10] = Spellbreaker
      • Set VariableSet bps_UnitType[11] = Acolyte
      • Set VariableSet bps_UnitType[12] = Ghoul
      • Set VariableSet bps_UnitType[13] = Crypt Fiend
      • Set VariableSet bps_UnitType[14] = Abomination
      • -------- - --------
      • -------- STOP HERE --------
      • -------- - --------
      • -------- Run System --------
      • Trigger - Run BPS Run <gen> (ignoring conditions)
How to Import:
1) Make sure that you turn on "Automatically create unknown variables" under File/Preferences/General in the editor. Optional: Turn on allow negative real values as well (this isn't needed for the system but it's useful!).
2) In the Object Editor, copy the Next Page ability and paste it into your map. Then do the same with the Previous Page ability.
3) In the Trigger Editor, copy the Building Page System folder and paste it into your map.
4) You can delete the "Add Ancient of War To System" trigger BUT keep the "Add Barracks to System" trigger.
5) Modify the "Add Barracks to System" trigger to work for the Structure in your map.

In other words, configure the variables between CONFIGURE and STOP HERE.
bps_Structure = The Unit-Type of your Race-choosing Structure. bps_TotalUnitsTrained = How many different Units it can choose from (Races in your case). bps_MaxUnitsPerPage = How many Units should be available to choose from in each page (No more than 10). Then fill out the bps_UnitTypes setting their values to be equal to each different Race's Structure. If you need more than the 14 that I provided you can copy and paste them and add [15], [16], etc... up to as many as you want.

6) Click the BPS Initial Setup trigger and set "bps_TotalStructures" to 1. Also, set "bps_NextPageAbility" and "bps_PrevPageAbility" to match the Next Page / Previous Page abilities that you imported.
7) In the Object Editor, make sure that your Structure can Upgrade To ALL of the possible structures and make sure it has the Next Page and Previous Page abilities added to it.
8) Finished.
 

Attachments

  • Upgrade Race.w3m
    17.2 KB · Views: 16
  • Building Page System v.3.w3x
    23.4 KB · Views: 20
Last edited:
Level 1
Joined
Apr 25, 2020
Messages
3
So I was trying the page system out method out. I thought it would look nicer than having 2 buildings spawned, and I wanted to try it since it was more complicated. I got the next page and previous page abilities to work, and there was 2 pages of units to upgrade to. Unfortunately, I couldn't figure out how to add another upgrade to the "Upgrades to" list. I tried adding my new race and the buttons are all grayed out. I saw on your Barracks that you had more than I did, but it wouldn't let me add even as many as you had. What am I not doing that I should be doing?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Looks like Upgrades To has a limit. Sorry I didn't see that before.

Anyway, not a hard fix. I tweaked this new version to work specifically for your map using Units Trained instead of Upgrades To. You'll have to update ALL of the system's triggers. Make sure to delete the old triggers before you paste the new ones into the map.

You'll need this Choose Race trigger to make it work. When you "begin training" a Race Structure (choose a race) this trigger runs and replaces the "training" structure with the chosen Race structure. This mimics the behavior of upgrading.
  • Choose Race
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Barracks
    • Actions
      • -------- Make sure to put your base Race-choosing Structure in the Conditions --------
      • Unit - Replace (Triggering unit) with a (Trained unit-type) using The old unit's relative life and mana
So again, you'll want to use Units Trained instead of Upgrades To in the Object Editor.


I also added these Actions to the "Add Barracks To System" trigger:
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units of type bps_Structure) and do (Actions)
      • Loop - Actions
        • Unit - Remove Rally from (Picked unit)
        • Unit - For (Picked unit), Ability bps_PrevPageAbility, Disable ability: True, Hide UI: False
This will remove the Rally ability from the structure (it was annoying/unneeded). I also made it so you cannot use the Previous Page ability while viewing the 1st page, and you cannot use the Next Page ability while viewing the last page. This is nice as it lets the player know that they're on the 1st/last pages.

Note that because I tweaked the system specifically for your map there might be bugs if you use this system for more than just your Race structure. In other words, it'll work fine as long as you only Add your Race Structure to the system.
 

Attachments

  • Building Page System v.4.w3x
    24.3 KB · Views: 13
Last edited:
Status
Not open for further replies.
Top