Giving unit an item

Status
Not open for further replies.
Level 2
Joined
Sep 23, 2013
Messages
18
I have this trigger. What I wanted was to spawn 1 dummy unit at the location of the riderless horse and give him an item (scroll of speed) and make him use it. everything works. The only problem is, there seems to be another dummy unit that spawns at a separate location. I am completely stumped. I isolated the cause to be due to the dummy unit using the item. How should I go about this? is there a better way?

  • Events
    • Time - Every 7.63 seconds of game time
  • Conditions
  • Actions
    • Set Target_loc = (Position of Riderless Horse 0018 <gen>)
    • Unit - Create 1 Dummy Unit for (Owner of Riderless Horse 0018 <gen>) at Target_loc facing Default building facing degrees
    • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
    • Hero - Create Scroll of Speed and give it to (Last created unit)
    • Hero - Order (Last created unit) to use (Last created item)
    • Custom script: call RemoveLocation (udg_Target_loc)
I also tried

  • Hero - Order (Last created unit) to use (Item carried by (Last created unit) in slot 1)
This is the screenshots so at least you have an idea where they spawn. As soon as the dummy spawns beside the riderless horse, another dummy spawns at the farm, the item is used and we get the movement speed buff. I just need the other dummy to not spawn. :O

1zou.jpg


Any insights would be deeply appreciated.
 
Level 2
Joined
Sep 23, 2013
Messages
18
"Unit - Create 1 Dummy Unit for (Owner of Riderless Horse 0018 <gen>) at Target_loc facing Default building facing degrees"
"Add a 2.00 second Generic expiration timer to (Last created unit)"

try removing that and see if the additional unit still is spawned

No units spawn. If I remove the
Hero - Order (Last created unit) to use (Last created item)

The unit spawns properly but then, the item is not used :(
 
Level 7
Joined
Mar 6, 2006
Messages
282
This is conflicting information.

You say that two dummies are spawned due to a trigger that creates just one unit.

And when you remove the unit creation action, then NO dummies spawn?

To be completely sure, check how many dummies spawn by disabling this trigger, testing, then enabling and testing.

Edit: wait a second, this trigger runs every 8 seconds, so these dummies may not be spawning at the same time. Where is the Riderless Horse when the 2nd dummy is spawning, because that position may not be where you think it is anymore "Set Target_loc = (Position of Riderless Horse 0018 <gen>)". Like, was the Riderless Horse killed at the farm or something?
 
Level 2
Joined
Sep 23, 2013
Messages
18
This is conflicting information.

You say that two dummies are spawned due to a trigger that creates just one unit.

And when you remove the unit creation action, then NO dummies spawn?

To be completely sure, check how many dummies spawn by disabling this trigger, testing, then enabling and testing.

That's what makes it so confusing for me. If the trigger is disabled, no dummies spawn.. and if i remove the trigger for the dummy to use the item, just 1 dummy spawns.. but if i make the dummy use the item, another dummy spawns. I thought it was due to some other trigger so i first disabled the trigger, but then no dummies are spawned.. so the next thing i did was to remove the item giving and item using, 1 dummy spawns.. i then added the give item to dummy, 1 dummy spawns.. then i add the dummy uses item, another dummy appears :O

Edit: wait a second, this trigger runs every 8 seconds, so these dummies may not be spawning at the same time. Where is the Riderless Horse when the 2nd dummy is spawning, because that position may not be where you think it is anymore "Set Target_loc = (Position of Riderless Horse 0018 <gen>)". Like, was the Riderless Horse killed at the farm or something?

The riderless horse is invulnerable and does not move at all. And ive noticed that they spawn at relatively the same time, considering the clicks and all.. so more or less the same time
 
Level 2
Joined
Sep 23, 2013
Messages
18
It HAS to be another trigger then. If you don't have too many of them, disable as many as you can until your problem stops happening, then figure out which trigger is doing it.

I did, i disabled them all then opened each 1 by 1, only that trigger creates that error.
I think I know the problem. (blind guess)

I think that the dummy you create triggers a "unit enters region" event and that trigger maybe creates a dublicate of the entering unit or something.

I changed the location to center of playable map area, both still spawns..

now I did an experiment

  • Actions
    • Set Target_loc = (Center of (Playable map area))
    • Item - Create Scroll of Speed at (Center of (Playable map area))
    • Set Temp_item = (Last created item)
    • Unit - Create 1 Dummy Unit for (Owner of Riderless Horse 0018 <gen>) at Target_loc facing Default building facing degrees
    • Set Temp_unit[0] = (Last created unit)
    • Unit - Add a 2.00 second Generic expiration timer to Temp_unit[0]
    • Hero - Give Temp_item to Temp_unit[0]
    • Hero - Order Temp_unit[0] to use (Item carried by (Last created unit) of type Scroll of Speed)
    • Custom script: call RemoveLocation (udg_Target_loc)
    • Custom script: call RemoveUnit (udg_Temp_unit[0])
i made it into that and used variables though i dont know what script to call to remove the item.. anyways, after turning it into that, the dummy no longer spawns at the center of playable map, but only spawns at the farm.... >.< and no, i have no regions whatsoever that makes units instantly teleport to the farm area :O

EDIT:
I decided to change the owner of the riderless horse to me, so now i own it, and so with it i also changed the dummy unit to be a normal paladin hero, and i changed the event to happen once the game is 5sec and never happen again. I then tried to spawn the item, the item is spawned, i added the trigger to give the item to the paladin, it works.. nothing bad so far.. and since the paladin has it.. i decided to click the item.. them boom! the peasant at the farm appears :O what in the blazes is that? :O all i did with the item was adjust the range to 99999 xD

EDIT: EDIT:
Thanks for the help guys, from the revelation that the item itself was causing it, i decided to look deep into how the item was used and as it turns out it casts an ability, so i searched for all my triggers that has that event and found that a trigger was indeed causing it and it just did not occur to me. Thank you guys for the help and DysfunctionaI, you were right! +rep to all...
P.S. how to mark this as solved? :O
 
Last edited:
Status
Not open for further replies.
Top