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

Adding new "Upgrade used" to a unit with trigger

Status
Not open for further replies.
Level 3
Joined
May 17, 2019
Messages
45
Hey,

I am willing to add an "upgrade used" to a unit by trigger, but what a pity it seems there is no trigger for this.

Does anyone know some JASS method or anything else ?

( Replacing the Unit or dummy workarounds are not a solution for me, I must use the same unit but add new used upgrade to it )

Thanks
 
Level 14
Joined
Feb 7, 2020
Messages
387
You may have to simulate the upgrade on the unit with triggers, rather than adding an upgrade to it. To my knowledge, there is no way to add upgrades used with GUI or JASS.

One creative way you might implement it is to simulate the Berseker upgrade functionality which swaps out the unit type Unit upgrade

That, or you need to rethink the conclusion that a dummy/replacement cannot be used.

edit: also, as another option, why not have two versions of the upgrade and increment one of them manually that applies specifically to that unit when you need it to? It'd help if you give more context on what you're trying to accomplish.
 
Level 3
Joined
May 17, 2019
Messages
45
The point was to add a custom upgrade to a Hero, based on the Knight's upgrade, which upgrades Max HP based on %.
Adding and removing that upgrade at will to any desired unit with triggers was an easy way to make a custom spell temporarilly increasing Max HP.

I could trigger it with 'Set max HP' but I am afraid that when a the hero dies, the buff is gone and I won't detect it for reverting to base HP even with 'unit dies event" (cause buffed is removed before that event runs, i think, though i didnt test it). And simply reverting HP with wait function, without paying attention to death possiblities, would result in a revived hero still having increased max hp though buff is gone and HP should be base hp.

That's why the upgrade way was very easy if only we could add and remove them at will with triggers.
 
Last edited:
Level 14
Joined
Feb 7, 2020
Messages
387
The point was to add a custom upgrade to a Hero, based on the Knight's upgrade, which upgrades Max HP based on %.
Adding and removing that upgrade at will to any desired unit with triggers was an easy way to make a custom spell temporarilly increasing Max HP.

I could trigger it with 'Set max HP' but I am afraid that when a the hero dies, the buff is gone and I won't detect it for reverting to base HP even with 'unit dies event" (cause buffed is removed before that event runs, i think, though i didnt test it). And simply reverting HP with wait function, without paying attention to death possiblities, would result in a revived hero still having increased max hp though buff is gone and HP should be base hp.

That's why the upgrade way was very easy if only we could add and remove them at will with triggers.
I think I found a way for you to do it.

I added 2 levels to the Animal War Training ability with the increment amount to -150. This lets you set it to level 2 when you want it to undo its hitpoint bonus, and back to level 1 when you want the health bonus.

Attached with functionality preview (type -1 to enable, -2 to disable).
 

Attachments

  • testerino.w3m
    12.5 KB · Views: 21
Level 3
Joined
May 17, 2019
Messages
45
Hi,

Unfortunately this method does not help.

It would works if only one specific unit could get a buff, but any different unit type in the map can get the buff.
Therefore, increasing tech level would affect all the units who use that tech upgrade.

That's why I need to add/remove those "Upgrade used" at will, so I can add it to any buffed unit.

Unfortunetely triggers can't do that, but maybe is there some JASS for it... which I don't know of.
 
Level 14
Joined
Feb 7, 2020
Messages
387
Hi,

Unfortunately this method does not help.

It would works if only one specific unit could get a buff, but any different unit type in the map can get the buff.
Therefore, increasing tech level would affect all the units who use that tech upgrade.

That's why I need to add/remove those "Upgrade used" at will, so I can add it to any buffed unit.

Unfortunetely triggers can't do that, but maybe is there some JASS for it... which I don't know of.
I would test setting max HP via triggers and undoing it on death. I think it works.

If it doesn't, set a boolean to false when you try to reduce their max HP if they aren't alive. When they respawn, check that boolean and then set their max HP to what it should be if it wasn't done already.

I searched the JASS API and there are no signs of a function that does exactly what you want outside of incrementing research or adding it as complete for a player: you need to find a workaround.
 
Level 3
Joined
May 17, 2019
Messages
45
The problem is that they don't always have the buff on, and when they die I can't detect if they were buffed or not (except using the parasite trick), so I can't just revert their HP back when they die. Plus it would not work when the unit picks some item increasing HP unless creating triggers for when a unit pick/drop an HP item. That would be too much work just for this.

Anyway, since it was made for Heroes, I did create one upgrade per hero and set reserch lvl to owner depending on the hero buffed. This way it was easy to do. Reset upgrade to 0 on death or after buff timer or on dispels.

But if it was supposed to target any generic unit, that way wouldn't have worked. What a pity they didn't implement such triggers. Buff events would have been great too...

Thank you for your help investigating the JASS possibilities.
 
Last edited:
Status
Not open for further replies.
Top