• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Moving a Dummy Unit by trigger to a point and then destroying it

Status
Not open for further replies.
Level 15
Joined
Sep 3, 2006
Messages
1,738
So I'm making an ability where a unit casts and then a dummy unit pops out in place of a missile and moves forward dealing damage to any unit it comes in contact with and dissapearing once it reaches the point of the ability being cast.

If you have difficulty understanding, it's basically like Invoker's Deafening Blast and Meteor Strike skills in DotA.

Now, I can create the unit and I can order it to move simply by moving to the point, but the problem is that it's difficult to add an Expiration Timer if I don't know when the dummy unit will reach the point (whether the caster chose to use the spell at full range or minimum range).

So what I'm asking is, can you move a dummy unit in GUI by trigger to a point and then remove the unit when it reaches the point and if so, how?
 
Level 3
Joined
Jul 6, 2008
Messages
42
try something like this , it can help.

  • Actions
    • Set startpoint = (Position of (Triggering unit))
    • Set endpoint = (Target point of ability being cast)
    • Set distance = (Distance between startpunkt and endpunkt)
    • Set time = ((distance / (Current movement speed of (Dummy_Unit)))
    • Unit - Add a time second Generic expiration timer to (Dummy_Unit)
Variables
point - startpoint
point - endpoint
real - distant
real - time
**Dummy_Unit can replace by the variable you give to your dummy unit , normal I prefer use "last created unit" , just put the create unit action before "Set time = ((distance / (Current movement speed of (Dummy_Unit)))" action.
 
Level 6
Joined
Feb 21, 2008
Messages
205
There's probably a more easier answer for this but ah well:

You could create a dummy unit at the point of ability being cast.
Every 0.2 sec of the game ----> And that dummy unit has a trigger that puts every unit that is equal to the unit type of [dummy - missile] and is within 20 range into a unit group. And another trigger that removes all units in [missile unit group] from the game. (checks also every 0.2sec).

This is the only answer I could think of right now, hope it helps.
 
Level 5
Joined
Nov 14, 2007
Messages
161
it should work fine unless there is some lag, think about it with real life such as driving, if i drive 60Miles per hour, and i am going somewhere that is 120 miles away how long does it take me.

120Miles/60Mph = 2Hours, give me a 2 hour expiration timer and ill die when i get there. same theory different numbers.
 
Level 15
Joined
Sep 3, 2006
Messages
1,738
The thing is, I want it to move quicker (more swift) by moving it every XX range every 0.01 seconds, making it look like it's moving of its own accord.

Now, I deducted this out all on my own, I just need the "facing angles" value in GUI.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Don't freaking use 0.01, for the love of the gods. The human eye stops seeing blinks at about 15-16 frames per second, you don't need freaking 100 of them to lag your computer. People usually use 0.04-0.05 for normal things and 0.03-0.04 for really accurate things (physics).

As to your question.
You calculate the velocities you want first, for example "velocity = dist/fps towards angle".
This means that every frame of the timer/timed event it will move by your velocity.
So, if you'd want to move 1000 in 1 second, you'll calculate "velocity = 1000/fps towards some_angle".
Lets say your timed event is shooting every 0.4 seconds (25 fps), it will be
"velocity = 40 towards some_angle.
You can calculate the angle with the GUI action "Angle between point and point", with cos and sin, or with atan2.

You'd also likely want to give the unit a expiration timer so you won't need to handle the killing.

This thing would be easy like hell in Jass, but since GUI has no locals, you'll need to start messing with groups.
If you want different speeds between your instances (shots) you'll need to make arrays that will hold every value and lots of stuff like that.

For the damage, you simply pick every unit in a very small range from the projectile and damage them.
 
lets make it clearer for him

Number of Units the unit moves per second = Speed

(e.g. every .01 seconds move instantly to blah blah offset 20, that = 2000 units per second)

if your distance (position of triggering unit to position of target point of ability being cast) is say, 2000, then distance(2000)÷Speed(2000) = you will get to your target in 1 second.

if say you cast it at 1522, then distance(1522)÷Speed(2000) = you will get to your target in 0.761 seconds.
 
Level 15
Joined
Sep 3, 2006
Messages
1,738
I understand all of this simply fine, I was just say 0.1 seconds as an example of wanting it to flow smoothly, rather than look extremely choppy.

The only thing I need, is how to judge the facing angle of one position (the spot of the dummy unit) and the spot of another position (the spot of the target) so that it can move towards the target. I think it's something like the Facing Angle of the 2 points offset by XX, but I'm not sure.
 
Level 15
Joined
Sep 3, 2006
Messages
1,738
Okay, I got the movement to work very smoothly (and it looks very good, thanks). The only problem now is that I have difficulty destroying the unit. This is the code I have for the unit.

  • Vacuous Buddha Slash Damage
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit - Move VacuousBuddhaSlash instantly to ((Position of VacuousBuddhaSlash) offset by 50.00 towards (Angle from (Position of Asakura_Yoh) to VacuousBuddhaSlash_Target) degrees)
      • Set DummyUnitGroup = (Units within 100.00 of VacuousBuddhaSlash_Target matching ((Unit-type of (Matching unit)) Equal to Vaccuous Buddha-Slash))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in DummyUnitGroup) Equal to 1
        • Then - Actions
          • Unit Group - Pick every unit in DummyUnitGroup and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Custom script: call DestroyGroup(udg_DummyUnitGroup)
          • Custom script: call RemoveLocation(udg_VacuousBuddhaSlash_Target)
        • Else - Actions
 
Status
Not open for further replies.
Top