• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

Help with arc

Status
Not open for further replies.
Level 11
Joined
Oct 9, 2015
Messages
721
So, when an unit finished casting an ability I want to create 1 dummy unit at the left side of the triggering unit, then add x expiration timer to it, and when it dies I want to create another dummy unit in front of it, and so on and so on, forming the arc described in the image. Can anyone help me achieve that ?

8prFd61



Red dots are dummy units, center os circle is the position of unit, vertical line is the facing of unit

Thanks in advice!

image can be oponed in a new tab! (I don't know the images sites that are compatible with the hive)
 
Level 11
Joined
Oct 9, 2015
Messages
721
I want to create the dummy units so it takes the form of the swing of a blade, and the units must be created only after the previous one is dead because it will be like when the sword will be passing there. I'll make actions when the units dies (something like damage nearby units) it's not an arc height, but in the side of the unit

by the way thanks for answering so fast!
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
1, its not an arc... get your definitions right.
2, "to create another dummy unit in front of it" in front?

I wont discuss wether it is better to have one unit that moves instead of several units that come and go, but you can think that out yourself.

To have the positions of the units, you only have to do a polar projection.
A projection to any polar degree from a certain position.
You simply store the last used degree and add a little to it.
Then you reapply the polar projection and create a new unit on that position.
(Polar projection can be done as GUI action "Point with polar offset".)

@TriggerHappy
Thumbnail was broken, link was not: << click
 
Level 14
Joined
Aug 31, 2009
Messages
775
Personally I would do something like this. Note, this is obviously mock code, so change it to what you desire.

For loop (A = 1 - 10) do
- Create a (Dummy Unit) for (Owner of (Caster)) at (Position of (Caster)) offset by (Real((X) * (A)) towards (Facing Angle of (Caster) + 90) degrees.

This will spawn 10 units in a line that are at 90 degrees to the caster in a line. The "Y" value can be set to anything. The bigger it is, the more spaced out the units are. If you space it out too much, you may want to spawn more units to fill the gaps.

After they are spawned, you will need to index them into an array variable. This will help to keep track of them. You will also need to save the initial casting angle, and assign each unit a unique value to keep its position in the line.

An example would be:

Set CastingAngle = (Facing angle of (Caster))
Set IntegerTimer = 0
Set StartPoint = (Position of (Caster))
For loop (A = 1 - 10) do
- Create a (Dummy Unit) for (Owner of (Caster)) at (Position of (Caster)) offset by (Real((X) * (A)) towards (Facing Angle of (Caster) + 90) degrees.
- Set DummyUnit[A] = (Last created unit)
END LOOP
Turn on (Periodic Trigger)


From there, we'll turn on a periodic trigger.

Note that this method is not MUI. You'll need to look up tutorials on indexing if you want to do that. Alternatively, you could use Hashtables, but that's bad on system resources. Obviously, this isn't leakless either.

As for the "timer" variable. I'll explain below.

Once you've kept track of them, you need to run a periodic trigger something like this:

Every 0.03 seconds:
If IntegerTimer < 30 then
- Set IntegerTimer = IntegerTimer + 1
- For Loop (A = 1 - 10) do
-- Move (Dummy[A]) instantly to (StartPoint) offset by ((CastingAngle) + 90 - (Real(TimerInteger) x 3)
-ENDLOOP
else
-For Loop (A = 1 - 10) do
-- Remove (Dummy[A]) from the game.
-ENDLOOP
- Turn off (This Trigger)
ENDIF


Basically, what this code would do is create 10 units in a line, evenly spaced out, and then move them in a 90 degree angle starting at a positive 90 degrees and finishing at the same angle as the original caster's angle after approximately 0.9 seconds. To make it slower, just change the period of the timer in periodic.
 
Status
Not open for further replies.
Top