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

If a unit uses an item,How to make that ability of item to be done to an other unit?

Status
Not open for further replies.
Level 3
Joined
Dec 5, 2015
Messages
24
Hi,I made a backpack for a hero.Actually there is no problem with it except one thing.I want that if the backpack uses an item,Its output becomes for the hero(Not for backpack).
For example:
If a player uses a potion which is in the backpack and it heals 3000 hp.I want that hero to heal 3000hp.
Or if an item makes unit invulnerable and if player is using it while its in backpack...I want its effect to be done to hero..not to backpack.
In an other words:If there are Unit A and Unit B.If Unit B uses an item (Only active ability like potions or heals or anythings else like that) i want the ability of that item who used by Unit B becomes for Unit A.
I searched everywhere but i couldn't find a way.But i am sure its possible Because of saw it in many maps.But i want the standard way for doing that,Fastest way.And Best way.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
You can detect when an item is used for the backpack and use triggers and abilities to make the actual hero have the effect.
For example if backpack uses heal potion, you make a trigger that increases the hp of the hero. Depending on the effect of the item you have to use different strategies to make it work, so it's a bit difficult.
I don't think there is a direct way to make items work for a different unit.
 
Level 3
Joined
Dec 5, 2015
Messages
24
You can detect when an item is used for the backpack and use triggers and abilities to make the actual hero have the effect.
For example if backpack uses heal potion, you make a trigger that increases the hp of the hero. Depending on the effect of the item you have to use different strategies to make it work, so it's a bit difficult.
I don't think there is a direct way to make items work for a different unit.
But there are so much potions and Items like that.If i start doing it for all of them it will take so much time.There are like more than 150 items i need to act like that.Writing triggers for all of them....Will take time but still possible.
Anyway Thanks for you replay.I think i have to follow your path.
If there is no other idea to make it directly.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
If there is no other idea to make it directly.
I doubt there is one, but I would would wait a bit before doing so much work. Maybe someone knows a better solution.

One thing you could do for no-target items (potions, scrolls etc.) is creating tome versions of them and using them on that hero. Using a hashtable you can map items to tomes, which can save a lot of time for these kind of items.
The tome has the advantage, that it does not take an inventory slot.

Maybe it's also possible to remove an item from the inventory of the hero, if the inventory is full. Then you can add the used item to the hero, activate it for the hero, remove and add the originally removed item again.
 
Level 3
Joined
Dec 5, 2015
Messages
24
I doubt there is one, but I would would wait a bit before doing so much work. Maybe someone knows a better solution.
Yeah i wont do it so fast.
If anyone has any better idea please replay here.I have to know it.Its really important.
One thing you could do for no-target items (potions, scrolls etc.) is creating tome versions of them and using them on that hero. Using a hashtable you can map items to tomes, which can save a lot of time for these kind of items.
The tome has the advantage, that it does not take an inventory slot.
But i want that unit to use that item at anywhere of the map.so he can use potions at the mid of the fight.
Maybe it's also possible to remove an item from the inventory of the hero, if the inventory is full. Then you can add the used item to the hero, activate it for the hero, remove and add the originally removed item again.
I thought about it...But i doubt about if its possible or not and i couldn't find the required actions for that.I will try it.And lets see if it will work.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
But i want that unit to use that item at anywhere of the map.so he can use potions at the mid of the fight.
That would work during a fight. All you do is if the backpack uses heal potion, you give a tome to the actual hero, that has the healing effect. Since it is a tome it will be automatically used.

I thought about it...But i doubt about if its possible or not and i couldn't find the required actions for that.I will try it.And lets see if it will work.
Take a look at the map I uploaded. When the backpack uses an item, you give an item of this type to the hero and use it for the hero. In order to solve the full inventory problem one item is temporarily removed from the hero.
I used a hashtable to map the ability to the item, because I think there is no event "a hero uses an item" and you need to use "starts the effect of an ability"
The paladin is the hero, the archmage is the backpack and the blood mage can be used to damage the other heroes.

edit: there is an event "uses an item". It should be easier to make potions with this event, but for targeted items you need "starts the effect of an ability", so you know the target unit
 

Attachments

  • BackPackTest01.w3x
    17.9 KB · Views: 58
Level 3
Joined
Dec 5, 2015
Messages
24
Hi,I checked that map but that doesn't work.
Anyway i checked the actions and with some tests i found a trigger to do that.
I'm glad because now i don't have to go that much far and do that things.
5789.jpg

In that trigger if a unit type of Archmage uses an item,The paladin will have that ability.
Thanks,For your time and quick reply.It helped me so much.Ty for helping me.
Also here is the map:
 

Attachments

  • m1.w3x
    17.1 KB · Views: 79
Status
Not open for further replies.
Top