Detect targeted unit of an item?

WolSHaman

knowledgeably ignorant
Reaction score
51
I'm making an RPG right now. In the RPG there will be armored enemies, who have to be damaged with armor grenades. When a unit is hit with an armored grenade, it loses its 'armored' ability. However, I've been having trouble implementing this. I can get the condition to check that the correct item is used, but I can't seem to target the target of the used item in the trigger editor. My code looks something like this:

Event:
Unit- A unit uses an item

Conditions
Item Type of Item being Manipulated equal to Concussion Grenade

Action:
Remove armored from (unit targeted by item)


The bold part is the part that keeps going awry. I've tried triggering unit, target unit of issued order and target unit of ability being cast, and none of them seem to work. Is there any way to do stuff to the unit targeted by the item? Thanks!
 

Xialian

Member
Reaction score
8
I would pick all the units in the desired area and remove the Armored ability from them.

It would go something like this, although I haven't tried using item spells as positions before, so this won't be 100% accurate.
Trigger:
  • Armored
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item being manipulated) Equal to Concussion Grenade
    • Actions
      • Unit Group - Pick every unit in (Units within 250.00 of (Position of (Item being manipulated)) matching ((Owner of (Matching unit)) Equal to Neutral Hostile)) and do (Unit - Remove Armored buff from (Picked unit))
      • Set ArmoredUnits = (Last created unit group)
      • Custom script: call DestroyGroup (udg_ArmoredUnits)

Hope this helps :)
 

WolSHaman

knowledgeably ignorant
Reaction score
51
I would pick all the units in the desired area and remove the Armored ability from them.

It would go something like this, although I haven't tried using item spells as positions before, so this won't be 100% accurate.
Trigger:
  • Armored
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item being manipulated) Equal to Concussion Grenade
    • Actions
      • Unit Group - Pick every unit in (Units within 250.00 of (Position of (Item being manipulated)) matching ((Owner of (Matching unit)) Equal to Neutral Hostile)) and do (Unit - Remove Armored buff from (Picked unit))
      • Set ArmoredUnits = (Last created unit group)
      • Custom script: call DestroyGroup (udg_ArmoredUnits)

Hope this helps :)



That was my first idea, but that makes it more of an AoE effect around the hero using the item, whereas what I want is more of a targeted ability. I might create a special stunned buff and have the ability give that buff, and then I check every half second or whatever if a unit has the buff and is armored, and if they do I remove the armored status, or something like that, but I was wondering if there was a more direct route for targeted abilities. Thanks for the advice though!
 

O.A

Quantum physics rules
Reaction score
29
You have to use the 'Unit starts the effects of an ability' event, and 'Target unit of ability being cast' to refer to the target. In the condition use 'Ability being cast equal to (your custom Item ability)'.
 

vypur85

Hibernate
Reaction score
803
Just to elaborate what O.A has mentioned. This is pretty common in item triggering.

Use 'A unit starts the effect of an ability' whenever you want to detect the target unit. The ability being cast would be the active ability used in the item. You cannot detect which item was used here.

Use 'A unit uses an item' whenever you want to know which item was used. 'Triggering unit' would be the hero user, which 'Item being manipulated' is the item used. You cannot detect the targeted unit using this event.
 

jonas

You can change this now in User CP.
Reaction score
67
Is the timing in such a way that we can first detect one, then the other, and thus get all the information we need?
 

Slapshot136

Divide et impera
Reaction score
471
Is the timing in such a way that we can first detect one, then the other, and thus get all the information we need?
Don't think so, you would probably need to store the item used in "A unit uses an item" (possibly with a time value) somehow and then reference your stored item when the effect starts
 

jonas

You can change this now in User CP.
Reaction score
67
[Y]ou would probably need to store the item used in "A unit uses an item" (possibly with a time value) somehow and then reference your stored item when the effect starts

Indeed. Now the question is, is the timing of the events in such a way that this is possible?
I.e.:
* are the two events quasi-instantaneous
* is the order of the two events fixed
* can you interrupt the process between the two events such that one event occurs and the other doesn't (like, stun the unit in just the right millisecond)
 

kingkwong92

Well-Known Member
Reaction score
25
I've always just used:

Unit starts the effect of an ability
Ability equals ______
Remove _______ from target unit of ability being cast

As long as the item has that ability in the object manager. I don't really see the problem am I missing something?
 

jonas

You can change this now in User CP.
Reaction score
67
It was not really related to the original question. I was just wondering if it's theoretically possible...
 

Slapshot136

Divide et impera
Reaction score
471
Indeed. Now the question is, is the timing of the events in such a way that this is possible?
I.e.:
* are the two events quasi-instantaneous
* is the order of the two events fixed
* can you interrupt the process between the two events such that one event occurs and the other doesn't (like, stun the unit in just the right millisecond)

that depends (mostly) on the ability itself - for example if the ability is something like a potion, then the they are quasi-instantaneous, although the uses an item will always be before starts the effect of, however if it's a projectile, then there is a delay between the two when the projectile is launched (item used), and when it lands (starts effect)
and it is also possible for it to be interrupted if the ability has a casting time and the unit is re-ordered or stunned during this time

also I am not quite sure what happens as far as unit turning or chasing, i.e. if the item is "used" before the unit lines up and gets in range or not

I've always just used:

Unit starts the effect of an ability
Ability equals ______
Remove _______ from target unit of ability being cast

As long as the item has that ability in the object manager. I don't really see the problem am I missing something?

lets go with an example - Mage uses "fireball item" on footman - how would you know which "fireball item" was used by the caster (assuming they have multiple in their inventory)? how would you know if they used "fireball" or "frost bolt"?
 
Last edited:

kingkwong92

Well-Known Member
Reaction score
25
I create a separate ability for each item. So each item that has a triggered ability, has a unique ability. Its not hard to just create another ability and change it for the item. That's why I hardly ever use the event unit uses an item.
 

vypur85

Hibernate
Reaction score
803
> I create a separate ability for each item
You misunderstood. Your way is still not possible to detect the item type.
In some cases, it's essential to detect item casted.

Like you said, you created separate ability for each item. So when you use the unique the ability, how do you propose to check which item it is casted from?

A simple example.
Imagine you wanna create an item which will removed upon casting of the item ability. How would you do it?

At the end of the day, both events serve their purposes.
 

afisakov

You can change this now in User CP.
Reaction score
37
> I create a separate ability for each item
You misunderstood. Your way is still not possible to detect the item type.
In some cases, it's essential to detect item casted.

Like you said, you created separate ability for each item. So when you use the unique the ability, how do you propose to check which item it is casted from?

A simple example.
Imagine you wanna create an item which will removed upon casting of the item ability. How would you do it?

At the end of the day, both events serve their purposes.

I still do not see the problem with
Unit starts the effect of an ability
Ability equals ______
Remove _______ from target unit of ability being cast
Checking which item is cast from should be fairly simple if you create ability grenade1, grenade2, grenadesmall(item), grenadelauncher(item) etc. for each unique item type.
Therefore even if a unit and an item have grenade with same damage and range you create a separate copy of it for the item and therefore always know if it was cast from the item.
Since you can give each relevant item type its own copy of ability I do not see why you need to detect "item used" instead of using ability used for all triggers.

If item is to be removed upon casting just give it charges=1 and make it consume-able.
 

vypur85

Hibernate
Reaction score
803
> Checking which item is cast from...
> therefore always know if it was cast from the item...
From 'A unit starts the effect of an ability' event? Nope.

> If item is to be removed upon casting just give it charges=1 and make it consume-able.
Explain how would you want to do so by just using 'A unit starts the effect...'.
Try it yourself in WE and then show me the triggers. I may be wrong myself, well, no one's perfect.

Again, I must stress that both events serve their own purposes.
 

jonas

You can change this now in User CP.
Reaction score
67
The problem is if you can have multiple instances of the item on the same unit and you want to modify the item - e.g., add charges whenever you use the item, if charges is 3 then the effect becomes stronger. charges are reset then or when X seconds pass, whatever happens earlier.
 

afisakov

You can change this now in User CP.
Reaction score
37
>
> therefore always know if it was cast from the item...
From 'A unit starts the effect of an ability' event? Nope.
Like I said, make an item version of the ability. Since that version is only assigned to items (not units), whenever it is cast you know it was done by an item.
As for knowing which item cast... if items are identical it does not matter (and cooldown shared so not adviseable for player to carry), if diff items, you can make each it own version of ability to detect which used.

>
> If item is to be removed upon casting just give it charges=1 and make it consume-able.
Explain how would you want to do so by just using 'A unit starts the effect...'.
Try it yourself in WE and then show me the triggers. I may be wrong myself, well, no one's perfect.
Use Wand of illusion or a potion as base. The trigger gives the spell effect, and the item goes away on its own because it is consumable (like potions already do). Did a simple test and it seemed to work.

The problem is if you can have multiple instances of the item on the same unit and you want to modify the item - e.g., add charges whenever you use the item, if charges is 3 then the effect becomes stronger. charges are reset then or when X seconds pass, whatever happens earlier.
Ok, you got me there. Never considered directly modifying item when ability used.
 

vypur85

Hibernate
Reaction score
803
> whenever it is cast you know it was done by an item...
Like I said. Show me the triggers.
Item removal is just an example.
What if the damage of the spell depends on the number of charges of the item?
This is just another example. There could be many other examples related to item reference.
Again, perhaps you can show me the trigger in your next reply.
Like real triggers.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
> whenever it is cast you know it was done by an item...
Like I said. Show me the triggers.
Item removal is just an example.
What if the damage of the spell depends on the number of charges of the item?
This is just another example. There could be many other examples related to item reference.
Again, perhaps you can show me the trigger in your next reply.
Like real triggers.
Trigger:
  • Arbor Grip
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Arbor Grip (Item)
    • Actions
      • Item - Remove (Item carried by (Triggering unit) of type Wand of Arbor)

At this point afisakov was only talking about differentiating casting from an item vs. casting from a unit ability, without considering the need to know the item being used to cast.
 

vypur85

Hibernate
Reaction score
803
Trigger:
  • Arbor Grip
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Arbor Grip (Item)
    • Actions
      • Item - Remove (Item carried by (Triggering unit) of type Wand of Arbor)

At this point afisakov was only talking about differentiating casting from an item vs. casting from a unit ability, without considering the need to know the item being used to cast.
I know what he means.
I'm just stressing both events are important.
Saying that "I just use one event but not the other, and it's enough...", isn't too right.

You can't just prefer one event over the other. Both are equally important, depending on situation.

Me said:
At the end of the day, both events serve their purposes.
Again, I must stress that both events serve their own purposes.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top