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

[Spell] Ability To Strike. . .

Status
Not open for further replies.
Level 3
Joined
Jun 2, 2014
Messages
64
Ability To Strike. . .
I am trying to make an ability called Strike. Where when the unit casts this ability that the unit in front on the casting unit is stroke. The unit that was stroke then moves some range away from the casting unit (lets say about 400). I am also not wanting it to be a targetable ability, so I was trying the use War Stomp and figure out the rest in Trigger Editor. Which I can not fgure out. :vw_wtf: Please help!
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
take caster location
take caster angle
determine strike location by going distance from caster location towards caster angle direction (polar projection)
pick units there or only one or whatever you want
allocate a new index/memory space so you can store the direction and the units
start a timer with that index assigned, move the units periodically a bit towards saved direction
count down remaining ticks or make another timer marking the end of the movement, aborting the periodic timer and cleaning up
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
That is pretty tough language water...
If I didn't knew how to do it, I wouldn't understand it.

What you want to do is move a unit to a certain point over time.
So you want to move the unit very short distances very fast after each other. The lower the interval, the better it looks. There is one thing that we use as the lowest interval amount (0.03) where lowering it will not improve gameplay because you won't notice the difference between 0.03 and 0.02 but some might see the difference between 0.03 and 0.04.

This is pretty much how it works:
  • For each (Integer TempInteger) from 1 to 10, do (Actions)
    • Loop - Actions
      • Unit - Move Unit instantly to ((Position of Unit) offset by Speed towards Angle degrees)
      • Wait 0.03 seconds
The speed in this trigger is 0.03 X Movement Speed (Movement Speed is ussually somewhere between 200 and 300 for units and somewhere at 600 to 1200 for missiles).

There is only one problem... actually there are more problems but only one matters at this point.
"Wait 0.03 seconds" does not wait 0.03 seconds. "Wait 0.03 seconds of gametime" (which is way more accurate than the first one) also doesn't work with these low values.
There is a slight delay between the wait ends and the remaining stuff of the trigger runs.
That is why we use timers to make the wait. Timers are 185,923,157,041,283 times more accurate than waits... because timers have perfect accuracy.
The problem is that you have to save the unit, speed, direction, etc, etc, etc somewhere to use it every time.

The easiest way to do this is using arrays.
Every 0.03 seconds of gametime, you loop through every array and set the unit's location.
  • Interval
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Index) from 1 to Amount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RemainingDistanceArray[Amount] Greater than 0.00
            • Then - Actions
              • Set TempLocation = (Position of UnitArray[Index])
              • Set TempLocation2 = (TempLocation offset by SpeedArray[Index] towards AngleArray[Index] degrees)
              • Unit - Move UnitArray[Index] instantly to TempLocation2
              • Set RemainingDistanceArray[Index] = (RemainingDistanceArray[Index] - SpeedArray[Index])
            • Else - Actions
              • -------- Remove unit from array --------
This trigger is running exacly 33.333333 times per second of gametime and will update the movement of every unit in the array between 0 and Amount in the proper direction with the proper speed.
When the remaining distance is 0 or lower than 0, the unit must be removed from the array.

To add a unit to that, you have to increase the Amount and set the values in those slots to the values of that knockback.
  • Actions
    • Set Amount = (Amount + 1)
    • Set UnitArray[Amount] = (Triggering unit)
    • Set SpeedArray[Amount] = (0.03 x 700.00)
    • Set RemainingDistanceArray[Amount] = 400.00
    • Set AngleArray[Amount] = (Angle from TempLocation to TempLocation2)
To remove a unit from the array, which should be done inside the loop, you decrease the Amount and reset the values in the arrays.
  • Else - Actions
    • -------- Remove unit from array --------
    • Set UnitArray[Amount] = No unit
    • Set SpeedArray[Amount] = 0.00
    • Set RemainingDistanceArray[Amount] = 0.00
    • Set AngleArray[Amount] = 0.00
    • Set Amount = (Amount - 1)
You do need to make the custom scripts to remove leaks, disable the unit that is knocked back, use SetWidgetX() and SetWidgetY() to move the unit, enable and disable the Interval trigger if there are no knockbacks, etc, etc, etc, etc, etc.

To simplify knockbacks... some people just made it and told everyone to use it.
I suggest you to go to the spell section and download a few.

If you want to know how it works, go to the spell section and download a few.
Then look at how it works and recreate one for yourself.
Then you pretty much know what happens and how it works.
(Some knockback systems are a bit different than others and as I never used a knockback system from someone else, I have none that I can recommend you.
 
Status
Not open for further replies.
Top