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

Problem with Angle

Status
Not open for further replies.
Level 12
Joined
Sep 11, 2011
Messages
1,176
I want to create a spell that throws 3 knife in different angle (the first is Position of the caster towards the target point of ability being cast, and i did the others by add and subtract it by 30.00 degrees).

i'm using Unit Indexer, Carrion Swarm as a base and doing it like this

  • Triple Knives
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Carrion Swarm
    • Actions
      • Set tempPoint = (Position of (Triggering unit))
      • Unit - Create 1 Dummy (1) for (Owner of (Triggering unit)) at tempPoint facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Group
      • Set cv = (Custom value of (Last created unit))
      • Set CS_Angle1[cv] = ((Angle from (Position of (Last created unit)) to (Target point of ability being cast)) - 30.00)
      • Set CS_Angle2[cv] = (Angle from (Position of (Last created unit)) to (Target point of ability being cast))
      • Set CS_Angle3[cv] = ((Angle from (Position of (Last created unit)) to (Target point of ability being cast)) + 30.00)
      • Set CS_MissileSpeed[cv] = (400.00 x 0.04)
      • Set CS_Duration[cv] = 2.00
      • Unit - Create 1 Dummy (1) for (Owner of (Triggering unit)) at tempPoint facing Default building facing degrees
      • Set CS_1stDummy[cv] = (Last created unit)
      • Unit - Create 1 Dummy (1) for (Owner of (Triggering unit)) at tempPoint facing Default building facing degrees
      • Set CS_2ndDummy[cv] = (Last created unit)
      • Unit - Create 1 Dummy (1) for (Owner of (Triggering unit)) at tempPoint facing Default building facing degrees
      • Set CS_3rdDummy[cv] = (Last created unit)
      • Custom script: call RemoveLocation(udg_tempPoint)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (TK Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on TK Loop <gen>
        • Else - Actions

  • TK Loop
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Set cv = (Custom value of (Picked unit))
          • Set CS_Duration[cv] = (CS_Duration[cv] - 0.04)
          • Unit - Move CS_1stDummy[cv] instantly to ((Position of (Picked unit)) offset by CS_MissileSpeed[cv] towards CS_Angle1[cv] degrees)
          • Unit - Move CS_2ndDummy[cv] instantly to ((Position of (Picked unit)) offset by CS_MissileSpeed[cv] towards CS_Angle2[cv] degrees)
          • Unit - Move CS_3rdDummy[cv] instantly to ((Position of (Picked unit)) offset by CS_MissileSpeed[cv] towards CS_Angle3[cv] degrees)
the problem is, the knives didn't move at all, it stays on the position of the dummy i created. anyone know what the problem is ?
 
Last edited:
Level 25
Joined
Jul 10, 2006
Messages
3,315
The last 3 dummies have no place to spawn; you remove tempPoint without resetting it to a new location.

That aside, a simpler way to make the spell would be to just create 3 dummies that each cast carrion swarm in a direction, unless of course you require additional effects apart from damage.

By convention, we use the period of 0.03 for looping spells.

Don't forget to clean up the memory leaks in your looping trigger; you leak a total of six in it.

EDIT: The reason the spell isn't working is that you have no action that moves the "origin" dummy (the one which you use to reference the index number).

If the 3x carrion swarm method mentioned earlier won't cut it, you should take a look at a projectile system to make 3 separate, index-independent projectile dummies.
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
The last 3 dummies have no place to spawn; you remove tempPoint without resetting it to a new location.

yes, i forgot that i didn't need to reset any variables there :S

That aside, a simpler way to make the spell would be to just create 3 dummies that each cast carrion swarm in a direction, unless of course you require additional effects apart from damage.

If the 3x carrion swarm method mentioned earlier won't cut it, you should take a look at a projectile system to make 3 separate, index-independent projectile dummies.

yes, the method you mentioned earlier works well, thanks again +rep when i can (i can't right now, i need to spread) :D

now it looks like this.

  • Triple Knives
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Carrion Swarm
    • Actions
      • Set tempPoint = (Position of (Triggering unit))
      • Set CS_Angle1 = ((Angle from (Position of (Last created unit)) to (Target point of ability being cast)) - 30.00)
      • Set CS_Angle2 = (Angle from (Position of (Last created unit)) to (Target point of ability being cast))
      • Set CS_Angle3 = ((Angle from (Position of (Last created unit)) to (Target point of ability being cast)) + 30.00)
      • Unit - Create 1 Dummy (1) for (Owner of (Triggering unit)) at tempPoint facing 0.00 degrees
      • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm ((Position of (Triggering unit)) offset by 256.00 towards CS_Angle1 degrees)
      • Unit - Create 1 Dummy (1) for (Owner of (Triggering unit)) at tempPoint facing 0.00 degrees
      • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm ((Position of (Triggering unit)) offset by 256.00 towards CS_Angle2 degrees)
      • Unit - Create 1 Dummy (1) for (Owner of (Triggering unit)) at tempPoint facing 0.00 degrees
      • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm ((Position of (Triggering unit)) offset by 256.00 towards CS_Angle3 degrees)
      • Custom script: call RemoveLocation(udg_tempPoint)
it's much more simpler now, thanks a lot :goblin_yeah:

EDIT : but the center one moves earlier than the other two, any way to prevent this so they move together?
EDIT 2 : and what i need to do to remove all the dummies that i already create ?
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
EDIT : but the center one moves earlier than the other two, any way to prevent this so they move together?

The side ones move slower because they move at different angles. Multiply the middle one's speed by cos(30).

EDIT 2 : and what i need to do to remove all the dummies that i already create ?

Use
  • Unit - Add expiration timer
to each dummy that is created.

EDIT: Your new code is still leaking points and has some flaws.
  • Set CS_Angle1 = ((Angle from (Position of (Last created unit)) to (Target point of ability being cast)) - 30.00)
Should be using angle from triggering unit, not last created unit. Leaks two points. Use this instead:
  • Set tempPoint = (Position of (Triggering unit))
  • Set tempPoint2 = (Target point of ability being cast)
  • Set CS_Angle1 = ((Angle from (tempPoint) to (tempPoint2)) - 30.00)
And do the same with where you are ordering them to cast.

And on that topic, with regards to earlier where I mentioned you should adjust the speed to cos(30), you should make a second carrion swarm dummy ability for the middle dummy caster that uses this new speed (calculate it in calculator or something)
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
Use
  • Unit - Add expiration timer
to each dummy that is created.

thanks, i forgot about this :goblin_jawdrop:

EDIT: Your new code is still leaking points and has some flaws.
  • Set CS_Angle1 = ((Angle from (Position of (Last created unit)) to (Target point of ability being cast)) - 30.00)
Should be using angle from triggering unit, not last created unit. Leaks two points. Use this instead:
  • Set tempPoint = (Position of (Triggering unit))
  • Set tempPoint2 = (Target point of ability being cast)
  • Set CS_Angle1 = ((Angle from (tempPoint) to (tempPoint2)) - 30.00)
And do the same with where you are ordering them to cast.

thanks, i didn't know that i should do this, i'm trying to remove the angle with RemoveLocation, but i realized that angle is a real variable and cannot be removed with RemoveLocation.

And on that topic, with regards to earlier where I mentioned you should adjust the speed to cos(30), you should make a second carrion swarm dummy ability for the middle dummy caster that uses this new speed (calculate it in calculator or something)

thanks, but nevermind about this, i tried to set the missile speed to the slowest and the carrrion swarm did move together.

Result :

  • Triple Carrion Swarm
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Carrion Swarm
    • Actions
      • Set tempPoint = (Position of (Triggering unit))
      • Set tempPoint2 = (Target point of ability being cast)
      • Set CS_Angle1 = ((Angle from tempPoint to tempPoint2) - 30.00)
      • Set CS_Angle2 = (Angle from tempPoint to tempPoint2)
      • Set CS_Angle3 = ((Angle from tempPoint to tempPoint2) + 30.00)
      • Unit - Create 1 Dummy (1) for (Owner of (Triggering unit)) at tempPoint facing 0.00 degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm (tempPoint offset by 256.00 towards CS_Angle1 degrees)
      • Unit - Create 1 Dummy (1) for (Owner of (Triggering unit)) at tempPoint facing 0.00 degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm (tempPoint offset by 256.00 towards CS_Angle2 degrees)
      • Unit - Create 1 Dummy (1) for (Owner of (Triggering unit)) at tempPoint facing 0.00 degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm (tempPoint offset by 256.00 towards CS_Angle3 degrees)
      • Custom script: call RemoveLocation(udg_tempPoint)
      • Custom script: call RemoveLocation(udg_tempPoint2)
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
  • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm (tempPoint offset by 256.00 towards CS_Angle1 degrees)
Still leaks - where you use (tempPoint offest by 257 towards etc)
Set a new location tempPoint3 = tempPoint offest by 256 towards angle, order the spell to be cast at that location, and remove it afterwards.
You'll have to create and remove it 3 times, once per dummy.
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
  • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm (tempPoint offset by 256.00 towards CS_Angle1 degrees)
Still leaks - where you use (tempPoint offest by 257 towards etc)
Set a new location tempPoint3 = tempPoint offest by 256 towards angle, order the spell to be cast at that location, and remove it afterwards.
You'll have to create and remove it 3 times, once per dummy.

thanks alot for this, i got so many spell that's using angle, i need to rework them :D

Result :

  • Triple Carrion Swarm
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Carrion Swarm
    • Actions
      • Set tempPoint = (Position of (Triggering unit))
      • Set tempPoint2 = (Target point of ability being cast)
      • Set CS_Angle1 = ((Angle from tempPoint to tempPoint2) - 30.00)
      • Set CS_Angle2 = (Angle from tempPoint to tempPoint2)
      • Set CS_Angle3 = ((Angle from tempPoint to tempPoint2) + 30.00)
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at tempPoint facing CS_Angle1 degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Set tempPoint3 = (tempPoint offset by 256.00 towards CS_Angle1 degrees)
      • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm tempPoint3
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at tempPoint facing CS_Angle2 degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation (udg_tempPoint3)
      • Set tempPoint3 = (tempPoint offset by 256.00 towards CS_Angle2 degrees)
      • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm tempPoint3
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at tempPoint facing CS_Angle3 degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation (udg_tempPoint3)
      • Set tempPoint3 = (tempPoint offset by 256.00 towards CS_Angle3 degrees)
      • Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm tempPoint3
      • Custom script: call RemoveLocation(udg_tempPoint)
      • Custom script: call RemoveLocation(udg_tempPoint2)
      • Custom script: call RemoveLocation (udg_tempPoint3)
 
Status
Not open for further replies.
Top