• 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] Creating one unit "in front" on another

Status
Not open for further replies.
Level 24
Joined
Feb 28, 2007
Messages
3,479
Hello THW. My problem of today concerns the action that creates a unit. My current code lies just below:
  • Unit - Create 1 MyUnit for (Owner of (Casting unit)) at (Position of (Casting unit)) facing (Facing of (Casting unit)) degrees
Now, this works fine, however it looks bad. Because make an example of how it should be like this:
Example.JPG
As you can see, if the casting (red arrow) is facing upwards, the created unit is spawned in front of him, in this case north of him, and facing north just as him. If the casting unit is facing right, the second unit is created to the east of him and so on. I wonder if this is somehow possible, thanks. Also, if you did not quite understand my problem, here is an example of how it is now and shouldn't be.
Example2.JPG
Thanks in advance, and thanks for taking your time to read this, hopefully you can come up with a soft solution to my problem.
 
Level 19
Joined
May 1, 2008
Messages
1,130
  • Actions
    • Unit - Create 1 unit for player at ((Position of (Casting unit)) offset by 100.00(or whatever how close u want him to be) towards ((Facing of (Casting unit)) - 90.00) degrees) facing facing angle of (casting unit) degrees
(Casting unit)) - 90.00) degrees) use here arithmetic
offset by 100.00(or whatever how close u want him to be) towards x use here polar offset
 
Level 24
Joined
Feb 28, 2007
Messages
3,479
Still does not work 100%, gonna post full code if that matters.
  • Events
    • Unit - A unit Begins casting an ability
  • Conditions
    • (Ability being cast) Equal to Projectile Launch
  • Actions
    • Unit - Create 1 ProjectileUnit for (Owner of (Casting unit)) at ((Position of (Casting unit)) offset by 100.00 towards ((Facing of (Casting unit)) - 90.00) degrees) facing (Facing of (Casting unit)) degrees
    • Unit - Change color of (Last created unit) to Green
    • Unit - Order (Last created unit) to Move To ((Target point of ability being cast) offset by 512.00 towards (Facing of (Casting unit)) degrees)
So basically what this is supposed to do is create a unit in front of the caster of the ability that should move forward in the direction the hero was facing when he cast the spell. But now it is totally messy, if you are facing right, and cast the spell to the left of you, the ProjectileUnit is going off into some totally random direction, perhaps with this you can help me further?
 
Level 19
Joined
May 1, 2008
Messages
1,130
so u want the green ball thingy to appear not in front but slightly to the right of the caster?
ohh crap i know your problem :D
its because of the turn rate of the casting unit
its like a unit can cast the spell instantly even if its with its back on the target unit
try adding some waits or something (its like the casting unit must first face the target point then to cast the spell
try adding a 0.50 wait to the beggining of the trigger or something or better to add some cast time to the spell
 
Level 9
Joined
May 27, 2006
Messages
498
Use Unit - A unit starts effect of an ability instead of Begins casting an ability. Its much more efficient and will trigger only when the spell has been succesfully casted, meaning after the unit got close enough to cast it, etc.

And, by the way, try reading this topic, your trigger leaks 3 locations and would cause lag if used many times.
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Projectile Launch
  • Actions
    • Set angle = Facing of (Triggering Unit)
    • Set temppoint1 = (Position of (Triggering Unit))
    • Set temppoint2 = (temppoint1 offset by 100 towards (angle -30) degrees)
    • Set temppoint3 = Target point of ability being cast
    • Set temppoint4 = temppoint3 offset by 512.00 towards angle degrees
    • Unit - Create 1 ProjectileUnit for (Owner of (Triggering Unit)) at temppoint2 facing angle degrees
    • Unit - Change color of (Last created unit) to Green
    • Unit - Order (Last created unit) to Move To temppoint4
    • Custom script: call RemoveLocation(udg_temppoint1)
    • Custom script: call RemoveLocation(udg_temppoint2)
    • Custom script: call RemoveLocation(udg_temppoint3)
    • Custom script: call RemoveLocation(udg_temppoint4)
Try this one :>
 
Level 19
Joined
May 1, 2008
Messages
1,130
Use Unit - A unit starts effect of an ability instead of Begins casting an ability. Its much more efficient and will trigger only when the spell has been succesfully casted, meaning after the unit got close enough to cast it, etc.

And, by the way, try reading this topic, your trigger leaks 3 locations and would cause lag if used many times.
for a trigger like that wtf pc u have?
i made a spell like that and tried it 100000x times and i have paleolitic-age pc :hohum: and didn't lag at all.
 
Level 9
Joined
May 27, 2006
Messages
498
Maybe 3 locations per trigger launch is not much, but when you'll do a periodic trigger that launches every 0.04 second, it would be 75 leaks per second. Now as an average game usually lasts minimal 10 minutes, it is 60 x 10 x 75 = 45'000... And thats only for one periodic trigger, with only 3 location leaks. This will slow your comp down.

for a trigger like that wtf pc u have?
i made a spell like that and tried it 100000x times and i have paleolitic-age pc :hohum: and didn't lag at all.
Its an ability-activated trigger, meaning it wont be used as many times as a periodic one. But its always better to remove ALL locations that you've declared, just to get used to removing leaks.
 
Level 19
Joined
May 1, 2008
Messages
1,130
Maybe 3 locations per trigger launch is not much, but when you'll do a periodic trigger that launches every 0.04 second, it would be 75 leaks per second. Now as an average game usually lasts minimal 10 minutes, it is 60 x 10 x 75 = 45'000... And thats only for one periodic trigger, with only 3 location leaks. This will slow your comp down.


Its an ability-activated trigger, meaning it wont be used as many times as a periodic one. But its always better to remove ALL locations that you've declared, just to get used to removing leaks.
yeah yeah u have a point there :D
you get +rep for your wisdom :O
 
Status
Not open for further replies.
Top