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

Set Upgrade Range

Status
Not open for further replies.
Level 1
Joined
Jul 5, 2021
Messages
2
Hi. I was wondering if there was an easy* way to make upgrades only purchasable from a certain range, much how like how items behave. I'm making a unit that's a "trainer" for the hero and I'd like it if you could only get upgrades if you go visit him.
Note: I am not learning abilities from him. Mainly just stat upgrades. Thus the use of upgrades.

*by easy I mean a quick ability/number change in the object editor, a basic trigger, or something to that effect.

I would prefer to not use multiple dummy items/upgrades to have multiple triggers give me the real upgrades if I can avoid it. Thanks.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
Possible solutions:

- Use Powerups since they do this already.

- Make a Enters/Leaves region trigger that enables the "trainer" when you come within range and disables the trainer when you leave. You can use the Pause action to disable the unit while you're not nearby and Unpause to enable it. If your map is multiplayer then this can cause problems. Instead of pausing you could also Disable/Enable the upgrades. Additionally, you'd need to gain control of this unit to research the upgrades.

- If Powerups are too limiting, use Powerup items and have them represent the upgrades through triggers. If done properly using Arrays/Hashtables you wouldn't need more than 2 triggers to do so.

Item Upgrades example:
  • Setup IU
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set VariableSet IU_Hashtable = (Last created hashtable)
      • -------- --------
      • -------- Keep track of the upgrades: --------
      • -------- Make sure the [indexes] match! --------
      • Set VariableSet IU_Upgrades[1] = Iron Forged Swords
      • Set VariableSet IU_Upgrades[2] = Iron Plating
      • -------- --------
      • -------- Keep track of the items: --------
      • -------- Make sure the [indexes] match! --------
      • Set VariableSet IU_Items[1] = Iron Forged Swords (Item)
      • Set VariableSet IU_Items[2] = Iron Plating (Item)
      • -------- --------
      • -------- Keep track of the total number of items OR upgrades (it's the same amount either way): --------
      • Set VariableSet IU_Total = 2
      • -------- --------
      • -------- Store the items/upgrades into the hashtable: --------
      • For each (Integer IU_Loop) from 1 to IU_Total, do (Actions)
        • Loop - Actions
          • -------- Store the upgrade id in the hashtable using the matching item-type id as it's key: --------
          • Custom script: set udg_IU_Id = udg_IU_Items[udg_IU_Loop]
          • Custom script: set udg_IU_Id2 = udg_IU_Upgrades[udg_IU_Loop]
          • Hashtable - Save IU_Id2 as IU_Id of 0 in IU_Hashtable.
  • Acquire IU
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Item-type of (Item being manipulated)) is A powerup.) Equal to True
    • Actions
      • -------- Get the "item-type id" of the item being manipulated: --------
      • Set VariableSet IU_AcquiredItem = (Item being manipulated)
      • Custom script: set udg_IU_Id = GetItemTypeId(udg_IU_AcquiredItem)
      • -------- --------
      • -------- Load the upgrade from the hashtable using the acquired item's "item-type id": --------
      • Custom script: set udg_IU_Upgrades[0] = LoadInteger(udg_IU_Hashtable, 0, udg_IU_Id)
      • -------- --------
      • -------- Research the loaded upgrade: --------
      • Player - Set the current research level of IU_Upgrades[0] to 1 for (Owner of (Triggering unit))
 

Attachments

  • Item Upgrades.w3m
    18.3 KB · Views: 4
Last edited:
Level 1
Joined
Jul 5, 2021
Messages
2
Thanks for the suggestions. I'll probably go with the pause/unpause option. I don't intend on making the map multiplayer so should be fine.
 
Status
Not open for further replies.
Top