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

pseudo item system issue

Status
Not open for further replies.
Level 23
Joined
Oct 18, 2008
Messages
938
I have an item which needs to be invisible to one player, so I made it so that when its dropped it gets hidden and a unit created in its place, which can be 'picked up' by nearby heroes, giving again a item in their inventory and the unit becoming hidden.

the system works fine except for one weird part.

  • Lose
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Teleporter Piece
    • Actions
      • Trigger - Turn off (This trigger)
      • Unit - Create 1 Teleporter Piece for Player 2 (Blue) at (Position of (Hero manipulating item)) facing (Random angle) degrees
      • Item - Create (Item-type of (Item being manipulated)) at (Position of (Hero manipulating item))
      • Item - Hide (Last created item)
      • Hashtable - Save Handle Of(Last created item) as (Key Piece) of (Key (Last created unit)) in Hash
      • Item - Remove (Item being manipulated)
      • Trigger - Turn on (This trigger)
when giving the item to another unit, it doesn't show up in their inventory but the engine still treats it as existing in some ways - they get the aura ability that it has, for example. it seems that this is because the events go like this:

1. item is lost
2. item is removed because it was lost
3. item is acquired even though it doesn't exist anymore

and the engine gets confused in some way.

is there an elegant way to fix this? I don't know all effects of this strange bug so I'd like to prevent it if possible. sadly there doesn't seem to be any specific trigger that would run when items are transferred between units.
 
Level 39
Joined
Feb 27, 2007
Messages
5,019
This doesn't solve your problem in any way, but there's no real need to remove and then recreate & hide the item every time. You should just be able to force whichever unit has it to drop it on the ground and then just hide it directly.
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
firstly, I would like to say that your trigger leaks a point. My trigger below will show you how I clean them. also you might wanna check this thread by Ralle showing things that leak and way to clean them.

Having said that, I managed to find a way to avoid your issue. However, this will only work if the item is transferred to unit belongs to another player.

  • Loses
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Warsong Battle Drums
    • Actions
      • Trigger - Turn off (This trigger)
      • Set tempLoc = (Position of (Triggering unit))
      • Unit - Create 1 Footman for Player 1 (Red) at tempLoc facing Default building facing degrees
      • Item - Create (Item-type of (Item being manipulated)) at tempLoc
      • Item - Hide (Last created item)
      • Hashtable - Save Handle Of (Last Created Item) as (Key Piece) of (Key (Last Created Unit) in Hash
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Item being manipulated) is in (Playable map area)) Equal to True
        • Then - Actions
          • Item - Remove (Item being manipulated)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_tempLoc)
      • Trigger - Turn on (This trigger)
  • Acquires
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Warsong Battle Drums
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Owner of (Item being manipulated)) Equal to (Player(16))
              • (Owner of (Item being manipulated)) Equal to (Triggering player)
        • Then - Actions
          • Item - Change ownership of (Item being manipulated) to (Triggering player) and Retain color
        • Else - Actions
          • Trigger - Turn off Loses <gen>
          • Hero - Drop (Item being manipulated) from (Triggering unit)
          • Item - Remove (Item being manipulated)
          • Trigger - Turn on Loses <gen>
Basically, what I do was checking if the lost item is dropped on to the ground or is being given to another player. If it's dropped, then remove item directly. If it's being given to another player, then drop the item from the hero first and then remove the dropped item. This will prevent the item from taking effect forever even after being removed.

I attached a test map for you to try and see if it's what you want to do. At least this is what I get from your explanation. If not, then make it clearer and I will further help you.
 

Attachments

  • Transfer.w3x
    17.3 KB · Views: 30
Last edited:
Level 23
Joined
Oct 18, 2008
Messages
938
firstly, I would like to say that your trigger leaks a point. My trigger below will show you how I clean them. also you might wanna check this thread by Ralle showing things that leak and way to clean them.

Having said that, I managed to find a way to avoid your issue. However, this will only work if the item is transferred to unit belongs to another player.

  • Loses
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Warsong Battle Drums
    • Actions
      • Trigger - Turn off (This trigger)
      • Set tempLoc = (Position of (Triggering unit))
      • Unit - Create 1 Footman for Player 1 (Red) at tempLoc facing Default building facing degrees
      • Item - Create (Item-type of (Item being manipulated)) at tempLoc
      • Item - Hide (Last created item)
      • Hashtable - Save Handle Of (Last Created Item) as (Key Piece) of (Key (Last Created Unit) in Hash
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Item being manipulated) is in (Playable map area)) Equal to True
        • Then - Actions
          • Item - Remove (Item being manipulated)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_tempLoc)
      • Trigger - Turn on (This trigger)
  • Acquires
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Warsong Battle Drums
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Owner of (Item being manipulated)) Equal to (Player(16))
              • (Owner of (Item being manipulated)) Equal to (Triggering player)
        • Then - Actions
          • Item - Change ownership of (Item being manipulated) to (Triggering player) and Retain color
        • Else - Actions
          • Trigger - Turn off Loses <gen>
          • Hero - Drop (Item being manipulated) from (Triggering unit)
          • Item - Remove (Item being manipulated)
          • Trigger - Turn on Loses <gen>
Basically, what I do was checking if the lost item is dropped on to the ground or is being given to another player. If it's dropped, then remove item directly. If it's being given to another player, then drop the item from the hero first and then remove the dropped item. This will prevent the item from taking effect forever even after being removed.

I attached a test map for you to try and see if it's what you want to do. At least this is what I get from your explanation. If not, then make it clearer and I will further help you.

I don't quite get the function of ownership here. does the check if it's on the floor work somehow? the whole issue was that the item being lost happens before it's actually moved.

Maybe delay item removal? Instead of removing it, it can be dropped and placed somewhere else. Something like a 0 second timeout timer could be used to perform the clean up as after such a timeout phase 3 should have passed and the item can be removed correctly from its new owner.

ended up doing it with this
 
Level 39
Joined
Feb 27, 2007
Messages
5,019
I don't quite get the function of ownership here. does the check if it's on the floor work somehow? the whole issue was that the item being lost happens before it's actually moved.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((Item being manipulated) is in (Playable map area)) Equal to True
    • Then - Actions
      • Item - Remove (Item being manipulated)
    • Else - Actions
 
Status
Not open for further replies.
Top