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

[JASS] How to do Hook spells?

Status
Not open for further replies.
Level 13
Joined
Jul 26, 2008
Messages
1,009
Hi, I want to created a meat hook spell similar to that of Pudge, but am not sure how to do it.

I've seen it done a few different ways. What I'm looking for is either a way to do it in minimal vJASS or something.

I understand it extends a way, checks for units at it's farthest point, and then grabs any that comes close or ends and returns to the caster, but I've never been good at the coordinates for spell effects.

Specifically, how do I place one special effect after another in a line while stopping upon getting near a unit (or reaching it's distance), then grabbing that unit and bring it back with the effect to the unit casting?
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
That Meat Hook has been criticized for being coded inefficiently, and it's in GUI.

Phantom Hook, it teleports the unit to the caster on hit instead of dragging them, so I miss that entire half of the spell. (But it's pretty cool sounding)

Black Raven I hadn't looked at yet, I'll do so though just in case.

My biggest issue with these is that they're GUI.

I've barely used GUI, and thus rarely use globals, or have needed arrays for MUI/MPI, or have had to split timers into two seperate triggers. I've had some background in basic programming and always felt more comfortable with that.

Anyways I'll look at them and get what I can in order to learn how to do this. Couldn't hurt at least.
 
Level 9
Joined
Nov 28, 2008
Messages
704
If you want the basic pseudo code for how to do it:

Get the angle you want (hopefully in radians).

Create an x and a y velocity based on it (cos and sin of that angle * speed respectively). Choose a timer interval and times your velocities by this interval. You now have speed to move/interval.

Save your x/y current coordinates.

Create a timer, attach this data in it through use of a struct or using StringHashes (I prefer struct, less typing).

Every time the timer fires, check the area in which your current x and y coordinates are for a unit to drag. If none are found, (dont forget to filter out the casting unit!) then make a chain link at this new x and y. Then change your x and y coordinates by adding your interval speed to each. Add this new special effect to a hash table (using the timer as a key) and then up a counter of the number of effects made (also saved to hashtable/struct).

Wait for the timer to fire until a unit is found, or an unpathable area is found (suggestion: Vexorian made a function for that, and I have as well, would try and find that).

When the unit is found, start counting in reverse. Set a state or else create a new timer. Pause the unit if you want. Save it into your struct/hashtable.

Every time this timer fires, check if you have a unit saved to the spell. If so, move the unit to the hooks position. Destroy the effect your interval is at. Minus the effect coounter. Change the x and y coordinates to minus the x and y interval speeds. If there is no unit, do everything except the move the unit part.

Repeat until your number of effects left are 0.

Dunno if it's helpful, but if you can code, it should be more than enough to start. You can add range by adding a condition to when your hook fires of ending and retracting if range - velocity is less than 0 and such.

Edit: Personally though, I would make it as an addon for an already existing projectile system that has an option for you to set your own interval function. It does most of the work, especially if collision checking and stuff is already included.
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
I have xe but it uses more vJASS than I know. In a counter to that I've started to read a vJASS tutorial, as well as study the xe example codes. Still I hate delaying a project any more than I have to in order to study something. There's always some sort of new code or spell to study.

So I'm attempting this with what knowledge I currently have in hopes of learning as I go.

In the end overlord's pointed out examples and Moogle's psuedo code should allow me to contruct something in JASS that works.
 
Status
Not open for further replies.
Top