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

Need help with a simple trigger

Status
Not open for further replies.
Level 2
Joined
Sep 13, 2010
Messages
23
Hi! I've just started to create simple triggers with GUI and I've ran into a problem

What I'm trying to create is a special effect that fires at the location of a dropped item. The dropped item is also removed in the process. I've been trying to figure out why special effect fires at the wrong locations instead of the location where I last dropped the item, before it was removed.

I bet I'm just missing something very obvious to everyone else. Thanks in advance!


  • Weapon Drop
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Iron Longsword
    • Actions
      • Set Temp_Point = (Position of (Item being manipulated))
      • Special Effect - Create a special effect at Temp_Point using Abilities\Spells\Human\Polymorph\PolyMorphTarget.mdl
      • Item - Remove (Item being manipulated)
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation (udg_Temp_Point)
 
Last edited:
Level 2
Joined
Sep 13, 2010
Messages
23
The special effect keeps firing at the location where I picked up the item, instead of where I dropped it.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
This fixed it. Thank you! Could you explain the reasoning behind this? I'm new to this stuff and I'd love to know what kind of difference does it make..

Well the trigger is probably running before the item is actually dropped, so the sequence goes like this

Unit picks up item >
Unit ordered to drop item >
Trigger lost item function ran >
Item is dropped

When you add the 0.00 second wait, you let everything else run first than come back and finish the trigger. So

Unit picks up item >
Unit ordered to drop item >
Trigger lost item function ran to sleep >
Item is dropped >
Trigger lost item function resumed after the sleep

so "Item is dropped" gets put before the rest of the actions and the position of the item is correct
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
You should do it like this to make it MUI. If it is multiplayer and two or more units drop an item at the same time the way yours is above ( with the wait added at top) it can bug.

This will make it MUI and solve your problem.

  • Weapon Drop
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Iron Longsword
    • Actions
      • Custom script: local item itm = GetManipulatedItem()
      • Custom script: local location udg_Temp_Point = Location(GetItemX(itm), GetItemY(itm))
      • Wait - 0.00 seconds
      • Special Effect - Create a special effect at Temp_Point using Abilities\Spells\Human\Polymorph\PolyMorphTarget.mdl
      • Item - Remove (Item being manipulated)
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Custom script: set itm = null
      • Custom script: set udg_Temp_Point = null
@Arhowk
Thanks for the solution i forgot about that stupid little wait time lol.
 
Last edited:
Level 2
Joined
Sep 13, 2010
Messages
23
Lol i forgot to put the wait in there. Also adding a wait without local variables makes it so it is not MUI. I updated my trigger above.

Actually your trigger still has the same result as the one I posted first. Special effect still fires at the location where the item was picked.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Huh that is odd. Use a timer like maker suggested then. That is your best option.

zzzz its fixed. Seriously. Even if GetManipulatedItem() wasn't thread safe than the likelihood of two items being dropped within the same frame is next to null

This fixed it. Thank you! Could you explain the reasoning behind this? I'm new to this stuff and I'd love to know what kind of difference does it make..
 
Level 25
Joined
Sep 26, 2009
Messages
2,373
tbh can't the problem in Death's trigger be that he saves the location before wait? I would think that that way it will still save the incorrect location, wait 0.00 seconds and create effect at loc.
In that sense, I think it would be correct to save only the item, after 0.00 wait set temp loc = position of saved item and create effect at temp loc.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
tbh can't the problem in Death's trigger be that he saves the location before wait? I would think that that way it will still save the incorrect location, wait 0.00 seconds and create effect at loc.
In that sense, I think it would be correct to save only the item, after 0.00 wait set temp loc = position of saved item and create effect at temp loc.

I believe you are right. I have no way to test it though if you could ?

Here is what i was thinking.

  • Weapon Drop
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Iron Longsword
    • Actions
      • Custom script: local item udg_tempItem = GetManipulatedItem()
      • Wait - 0.00 seconds
      • Set Temp_Point = (Center of (tempItem))
      • Special Effect - Create a special effect at Temp_Point using Abilities\Spells\Human\Polymorph\PolyMorphTarget.mdl
      • Item - Remove (Item being manipulated)
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Custom script: set udg_tempItem = null
      • Custom script: set udg_Temp_Point = null
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
I know this that is why i suggested going the way you suggested over the way that was suggested by arhowk.

I was simply providing an MUI example to arhowks suggestion.

seriously. fact check before you spam a thread. Manipulated Item is threadsafe.

@Maker its still too little for anyone to do something about it. By the time the request for an action gets sent to the host, the 0.1-0.2 seconds will already be elapsed
 

Attachments

  • lok.w3x
    16.3 KB · Views: 29
Level 29
Joined
Oct 24, 2012
Messages
6,543
seriously. fact check before you spam a thread. Manipulated Item is threadsafe.

As i have said above i have no way of testing Warcraft 3 atm. That is why i asked someone to try out the triggers i have posted.
I am not spamming a thread. It is simple optimization.

If Manipulated item does act like a local variable then i do apologize. I still have no way of testing it though.
 
Status
Not open for further replies.
Top