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

[Solved] Making an item usable through triggers is somehow causing it to drop on death?

Level 3
Joined
Jan 17, 2024
Messages
11
I have a few items that are all set up in similar ways and all have the same issue. These are items that start as "Actively Used" false and become "Actively Used" true after they gain 1 more or charges or after they gain max charges (depending on the item). What I've found is that when I die with any of these items when they are "usable" they will drop on death and show the correct number of charges on them on the item on the ground. When I try to pick them up I can't, they disappear. Why are they dropping on the ground / how can I prevent this?

These are the facts:
1. An item that gains charges but is not yet toggle to usable will not drop on death.
2. An item that gains charges and is made usable will drop on death.
3. If an item was made usable, is used, and is now toggled back to unusable, it will not drop on death (regardless of number of charges).
4. Same as 3, but if it goes back to usable after this it will drop on death (redundant of 2, the point is to say that through its lifecycles these truths still hold)
5. I am doing this on a hero, not a unit with backpack, other 60+ items in the game function normally on hero death.

Here is an example of one of the items. They start unusable and becomes usable through the triggers that follow


1709144538235.png


This isn't relevant but including it in case of an oversight.
  • Disintegration Staff Pickup
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Disintegration Staff
      • ((Triggering unit) is an illusion) Equal to False
    • Actions
      • Trigger - Turn on Disintegration Staff Activate <gen>
      • Trigger - Turn on Disintegration Staff Gain Charge <gen>
      • Trigger - Turn on Disintegration Staff Lost <gen>
Here is where I am adding charges / making the item usable when it reaches max charges
  • Disintegration Staff Gain Charge
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • ((Triggering unit) has an item of type Disintegration Staff) Equal to True
      • (Damage From Normal Attack) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Charges remaining in (Item carried by (Triggering unit) of type Disintegration Staff)) Less than 30
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Charges remaining in (Item carried by (Triggering unit) of type Disintegration Staff)) Equal to 29
            • Then - Actions
              • Item - Set Item: (Item carried by (Triggering unit) of type Disintegration Staff)'s Boolean Field: Actively Used ('iusa') to Value: True
            • Else - Actions
          • Item - Set charges remaining in (Item carried by (Triggering unit) of type Disintegration Staff) to ((Charges remaining in (Item carried by (Triggering unit) of type Disintegration Staff)) + 1)
        • Else - Actions

Here is where the item becomes unusable again after using it
  • Disintegration Staff Activate
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Disintegration Staff Kill
    • Actions
      • Unit - Kill (Target unit of ability being cast)
      • Item - Set Item: (Item carried by (Triggering unit) of type Disintegration Staff)'s Boolean Field: Actively Used ('iusa') to Value: False
      • Item - Set charges remaining in (Item carried by (Triggering unit) of type Disintegration Staff) to 0
This should also be irrelevant, including for completeness
  • Disintegration Staff Lost
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • ((Triggering unit) is an illusion) Equal to False
      • (Item-type of (Item being manipulated)) Equal to Disintegration Staff
    • Actions
      • Trigger - Turn off Disintegration Staff Activate <gen>
      • Trigger - Turn off Disintegration Staff Gain Charge <gen>
      • Trigger - Turn off (This trigger)
 
Level 25
Joined
Sep 26, 2009
Messages
2,383
I am not sure if it is intentional or if it is a bug, but changing the state to Actively Used also changes its Dropped When Carrier Dies flag.
Checked via this:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Item: item's Boolean Field: Dropped When Carrier Dies ('idrp')) Equal to True
    • Then - Actions
      • Game - Display to (All players) the text: Drops
    • Else - Actions
      • Game - Display to (All players) the text: Does not drop
And saw the 'Dropped When Carrier Dies' returning 'True' upon reaching 30 stacks and getting back to 'False' upon item use/stack reset.

The solution is to just manually change the flag after setting the 'Actively Used' to True:
  • Item - Set Item: (Item carried by (Triggering unit) of type The_Item)'s Boolean Field: Actively Used ('iusa') to Value: True
  • Item - Set Item: (Item carried by (Triggering unit) of type The_Item)'s Boolean Field: Dropped When Carrier Dies ('idrp') to Value: False
 
Level 3
Joined
Jan 17, 2024
Messages
11
Thank you so much / I hate that this worked. I literally took out my debug statements that show exactly what you just pasted before posting, and I had already checked that and it was not printing true/drops for me which is why I posted. Odd.

Wait......... not odd ... ughhhh I was checking immediately after setting the field, which isn't when it "takes effect". Similar to other areas of editing fields directly you have to give the item a nudge for it to "take effect", which is why I have all of those changes happening right before I change the charges on the item, since that nudges it. I should have printed my debug commands after that.

Regardless, thank you so much!
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,579
Thank you so much / I hate that this worked. I literally took out my debug statements that show exactly what you just pasted before posting, and I had already checked that and it was not printing true/drops for me which is why I posted. Odd.

Wait......... not odd ... ughhhh I was checking immediately after setting the field, which isn't when it "takes effect". Similar to other areas of editing fields directly you have to give the item a nudge for it to "take effect", which is why I have all of those changes happening right before I change the charges on the item, since that nudges it. I should have printed my debug commands after that.

Regardless, thank you so much!
Yes, you have to give them a nudge... sometimes, but not all of the time. It depends, sort of, sometimes, maybe? :peasant-grin:

At this point I just assume something doesn't work from the get go and "nudge" it from all directions.
 
Top