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

Arrow Throw with Triggers

Status
Not open for further replies.
Level 19
Joined
Apr 21, 2013
Messages
1,194
Hey guys, i'm trying to learn to create spells with triggers and i want to make a spell like the one in DOTA windrunner's powershot skill.

I just need someone to give an example easy code for this to get more familiar with the codes. I tried a lot but couldn't manage to move it and lots of other issues.

The projectile will create a bleeding effect when cutting through enemies and it will explode the units it hits if that unit has less than or equal to the spell damage.
 
Level 19
Joined
Apr 21, 2013
Messages
1,194
In that case look into utilizing a projectile system, and coding your spell around that.

http://www.hiveworkshop.com/forums/...ine&order=DESC&search=arrow&c=114&d=list&r=20

maybe this'll do it :D

but for further explanation, the player clicks on a point and an arrow goes in that direction piercing through every organic enemies and cutting trees down. For the units that it hits a bleeding effect is created and if the unit that the arrow hits has lower life than the spell damage that unit explodes instead of dying.

And btw, i checked the link and it's looks too complicated i want someone who has time and can make an easy coding with comments showing which code is for which action, clearly.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
At least try tinkering with the system TriggerHappy provided, you don't need to edit everything, mess with the configurations on the triggers.

If, however, you want to learn how to make something like that, then you should look for a tutorial in the tutorial section. I agree with TH, this isn't easy.
 
Level 19
Joined
Apr 21, 2013
Messages
1,194
I tried to change a custom spell as i wanted but it was a mess. Then i tried to make it from zero this time i couldn't make it move.

At least someone can tell me what should i do to make my arrow move?

I did like this only the movement but it dowsnt move, it just stays where it spawns and moves with my hero and changes its angle in respect to the point of target ability being cast.

  • Time - Every 0.03 seconds of game time
  • Set tempPoint1 = (Position of arrowCaster)
  • Set arrowStart = (tempPoint1 offset by 101.00 towards (Angle from tempPoint1 to (Target point of ability being cast)) degrees)
  • Unit - Create 1 Arrow for (Owner of arrowCaster) at arrowStart facing (Angle from tempPoint1 to (Target point of ability being cast)) degrees
  • Set arrow = (Last created unit)
  • Set tempPoint2 = (Position of arrow)
  • Set tempPoint3 = (tempPoint2 offset by 5.00 towards (Angle from tempPoint1 to tempPoint2) degrees)
  • Unit - Move arrow instantly to tempPoint3
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
You'll never get it unless you figure it out yourself, but a demo spell can help people understand concepts better. I will try to put something together for you with numerous comments, but keep experimenting and learning!

I'll try to have it for you by tomorrow evening.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
I have this spell when I am 10 years old but it is not mine when I am a newbie I'm messing and creating some stuffs in Mirana's Elunes Arrow and I changed it to powershot, from Windrruner ability that the arrow will pass through the enemies in a line and deals a damage.
I'll attach the test map ability BUT strictly don't submit it to spell sections, this is some example of code but don't use custom value of....
 

Attachments

  • Priestess of the Moon [Boundary Block].w3x
    45.8 KB · Views: 43
Level 19
Joined
Apr 21, 2013
Messages
1,194
I have this spell when I am 10 years old but it is not mine when I am a newbie I'm messing and creating some stuffs in Mirana's Elunes Arrow and I changed it to powershot, from Windrruner ability that the arrow will pass through the enemies in a line and deals a damage.
I'll attach the test map ability BUT strictly don't submit it to spell sections, this is some example of code but don't use custom value of....

This is a very good example for me to study on the movement loops i like this, the arrow loop is again a bit complicated but now i understand that the spell i studied before is far more complicated than this one thats why i always keep telling "easy codes" :D
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
I will not explain the indexing.
I will just explain the way to move this ^^'

First create a projectile (a unit with the model of the projectile).
Then get the angle the projectile have to go.
Get the distance you want it to travel every 0.03 second, the good period to do this (the best period in GUI otherwise use 0.03125 in JASS).
Then every 0.03 second set the position of the projectile with the formulas :
X_of_projectile + distance_every_0.03_second*angle = new_X_of_projectile
Y_of_projectile + distance_every_0.03_second*angle = new_Y_of_projectile

Then if you want to stop if it is in the range of a unit.
Grab the range you want around the projectile.
After every move of the projectile, pick every unit around the projectile and if there is one damage it and remove the projectile.
Otherwise continue the loop to move.

If you want it to damage everyone pierced unit once.
Grab the range you want around the projectile.
After every move pick every unit around it, check if they are on the already damaged group. If not so damage them and add them to the damaged group.
Then continue the loop until it has reached the final point.
 
Level 19
Joined
Apr 21, 2013
Messages
1,194
okay i almost did the movement but the arrow wont go in the direction i want it neither goes diagonally downwards to the left or the exact opposite of that direction, it won't go to the other directions

  • Events
    • Time - Every 0.03 seconds of game time
  • Actions
    • Set tempPoint1 = (Position of arrowCaster)
    • Set arrowStart = (tempPoint1 offset by 101.00 towards arrowAngle degrees)
    • Unit - Create 1 Arrow for (Owner of arrowCaster) at (Position of arrowCaster) facing arrowAngle degrees
    • Set arrow = (Last created unit)
    • Unit - Add a 1.00 second Generic expiration timer to arrow
    • Set Xcoord = (Xcoord + (arrowAngle x arrowDistanceTravel))
    • Set Ycoord = (Ycoord + (arrowAngle x arrowDistanceTravel))
    • Set tempPoint2 = (Point(Xcoord, Ycoord))
    • Unit - Move arrow instantly to tempPoint2
    • Unit Group - Pick every unit in (Units within 100.00 of (Position of arrow) matching (True Equal to True)) and do (Actions)
      • Loop - Actions
        • If ((Life of (Picked unit)) Less than or equal to 150.00) then do (Unit - Explode (Picked unit)) else do (Unit - Cause arrow to damage (Picked unit), dealing arrowDamage[(Level of Arrow for arrowCaster)] damage of attack type Pierce and damage type Normal)
    • Custom script: call RemoveLocation(udg_tempPoint1)
    • Custom script: call RemoveLocation(udg_tempPoint2)
    • Custom script: call RemoveLocation(udg_arrowStart)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • LoopInt Equal to 50
      • Then - Actions
        • Trigger - Turn off (This trigger)
      • Else - Actions
        • Set LoopInt = (LoopInt + 1)
this is the movement code what's the problem? I think it's about the coordinate calculating but i'm not sure.. :S

P.S. there maybe unnecessary variables, because i'm messing around don't bother them :)
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
Alright take a look at this GREAT tutorial that help you understand Indexing, which is to say it makes it so that any number of units can cast your spell at any given time. (Within reason of course)

http://www.hiveworkshop.com/forums/tutorial-submission-283/visualize-dynamic-indexing-241896/

So you can take a look at the test map, I spent some time to comment each line if you have any questions let me know.

I see you trying to use X and Y, while its not really any more difficult, it maybe be easier to try and understand it with purely locations first.
 

Attachments

  • Powershot Example.w3x
    30.6 KB · Views: 46
Status
Not open for further replies.
Top