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

Same Research, Different Unit

Level 3
Joined
Feb 3, 2016
Messages
43
How to enable a Research/Upgrade option per unit? I want to have a custom Research Y option for every instance of unit X. But, after fully "upgrading" a unit (the unit X itself has the custom Research Y available), the same Research Y is gone from any future instances of unit X?

I want to make every copy of a tower to be able to upgrade itself using the custom Research, but once any copy of that unit researches that upgrade, only the next level is available for any unit, instead of individually tracked research progress for each one.
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
So if I understand correctly, you have, let's say a 'Flame Tower' which can be upgraded to 'Empowered Flame Tower' and that can be upgraded to final 'Ultimate Flame Tower'.
You have 4 'Flame Towers', all can upgrade to 'Empowered Flame Tower', but the moment one of them is upgraded to 'Empowered Flame Tower', then all the remaining 3 + the upgraded one can all be only upgraded to 'Ultimate Flame Tower'?

Is that right?
 
Level 3
Joined
Feb 3, 2016
Messages
43
So if I understand correctly, you have, let's say a 'Flame Tower' which can be upgraded to 'Empowered Flame Tower' and that can be upgraded to final 'Ultimate Flame Tower'.
You have 4 'Flame Towers', all can upgrade to 'Empowered Flame Tower', but the moment one of them is upgraded to 'Empowered Flame Tower', then all the remaining 3 + the upgraded one can all be only upgraded to 'Ultimate Flame Tower'?

Is that right?
No.

I have a Flame Tower that I want to have some upgrades for (for example, adding or improving abilities present on the tower). Not upgrading the unit itself into another unit, but upgrades for the unit itself.

The research option seems to be player-wide, as researching a level 1 upgrade on unit no.1 leaves only upgrades of higher level available on any other copies of that unit.
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
Research is applied to all units, so you will need a workaround.
I had a similar situation in one of my own projects and I resolved it by using abilities and training units.
It's a lot of work and there may be some parts of the research mechanism that this does not cover, but maybe you will want to use it.

The basic idea is as follows:
  1. Use a custom 'Charge Gold and Lumber' ability instead of a research. This ability just drains your gold/lumber on use and does not do anything else. Good thing is it shows the gold and lumber cost instead of mana in the UI.
  2. Create a dummy unit - this dummy will be used for visuals/UI and to set research time length
    1. Name and description of the dummy should match 1:1 to the ability/research name and description.
    2. You will use the dummy unit instead of a research to emulate the 'training'/'research' behavior in UI. The name and description is important since you can hover over the unit in training queue to see detail
  3. On map initialization, make the dummy unit unavailable for training for given player
  4. Finally, when a unit starts casting your custom 'Charge Gold and Lumber', detect that via trigger, hide that ability, make the dummy available for training, order the triggering unit to train the dummy and then make training of the dummy immediately unavailable again.
  5. Have triggers with 'Unit - A unit Cancels/Finishes training a unit' events
    1. Cancels => refund gold/lumber lost via the custom ability, show the ability again
    2. Finishes => remove trained dummy unit from game, apply any bonuses your research should originally give via things like item abilities, etc.

  • Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player - Make Test Upgrade (Dummy unit) Unavailable for training/construction by Player 1 (Red)
  • Starts
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Test Upgrade (Charge Gold abil)
    • Actions
      • Unit - For (Triggering unit), Ability (Ability being cast), Disable ability: True, Hide UI: True
      • Player - Make Test Upgrade (Dummy unit) Available for training/construction by (Triggering player)
      • Unit - Order (Triggering unit) to train/upgrade to a Test Upgrade (Dummy unit)
      • Player - Make Test Upgrade (Dummy unit) Unavailable for training/construction by (Triggering player)
  • Cancel
    • Events
      • Unit - A unit Cancels training a unit
    • Conditions
      • (Trained unit-type) Equal to Test Upgrade (Dummy unit)
    • Actions
      • -------- The ability charged 50 gold and 15 lumber --------
      • Player - Set (Triggering player).Current gold to (((Triggering player) Current gold) + 50)
      • Player - Set (Triggering player).Current lumber to (((Triggering player) Current lumber) + 15)
      • Unit - For (Triggering unit), Ability Test Upgrade (Charge Gold abil), Disable ability: False, Hide UI: False
  • Finish
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Trained unit-type) Equal to Test Upgrade (Dummy unit)
    • Actions
      • Unit - Remove (Trained unit) from the game
      • Unit - Remove Test Upgrade (Charge Gold abil) from (Triggering unit)
      • Unit - Add Next Level Test Upgrade (Charge Gold abil) to (Triggering unit)
      • -------- apply bonuses of this research to the unit, etc. --------
      • Unit - Add Item Damage Bonus (+10) to (Triggering unit)
 
Top