HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

On-Hit Spell Detection

03-13-2007, 10:09 PM#1
Hydrolisk
Well, I was browsing the tutorial section when I found one of them that mentioned something about dummy caster spells that can be triggered on-hit (as in right when the special effects hit, such as a hammer), such as Shadow Strike because of buff checks or something. I've kept browsing, searching for an answer, but I can't find anymore information.
I really need to know how I could detect when a spell hits exactly, or at least uber close. I'm getting tired of my spells going "BAM!" *Target explodes, wait 5 seconds, missile hits*
So can anyone help? I've pretty desperate and I can't think of anyway I can detect. Uber thanks.
03-14-2007, 02:43 AM#2
masda70
The idea is to have a dummy unit uniquely bound to a particular spell instance throughout its duration (as in no recycling, no multi-purpose, not player-controllable during that period). After it is ordered to cast for example a storm bolt, dynamically creating an on-damage triggered event response (as in X unit takes damage event) will allow you to precisely detect when the missile exactly hits its target, and you will know it was spell missile that hit that unit as the only information about the event you need to know is the fact that the damaging unit was the dummy unit. The dummy unit shouldn't be able to hit any other targets or do any other damage than the intended spell damage.
The dummy unit can then hold particular cache data of that spell instance, such as ability level.
This method will work as long as one dummy unit is exclusively reserved to each spell instance.
03-14-2007, 09:43 AM#3
Jazradel
Or something like this:
Code:
Unit starts the effect of an Ability

loop
     exitwhen Unit Has Buff
     wait 0.4 second
endloop
Do Something
03-14-2007, 05:16 PM#4
Hydrolisk
Bleh, my eyes are burnt when I see pure JASS holiness. Please, I am not worthy yet!
03-15-2007, 08:56 AM#5
Av3n
Quote:
Originally Posted by Hydrolisk
Bleh, my eyes are burnt when I see pure JASS holiness. Please, I am not worthy yet!

Then adapt. At some point you are going to use JASS

-Av3n
03-15-2007, 10:07 AM#6
Earth-Fury
Quote:
Originally Posted by Hydrolisk
Bleh, my eyes are burnt when I see pure JASS holiness. Please, I am not worthy yet!

I have a rather simple solution to that: Download Jass Shop Pro (tools section) (or jasscraft, i find them both about the same)

Syntax hightlighting + double clicking function names to see the native definition. Verry Noob friendly.

And, just take it 1 line at a time.

Example:

Collapse JASS:
globals
    integer array udg_PathingUnits
endglobals

function CheckPathability takes real x, real y, integer pathing_type returns boolean
    local location l = Location( x, y )
    local unit u = CreateUnitAtLoc( Player(15), udg_PathingUnits[pathing_type], l, 0. )
    
    set x = GetUnitX(u) + x
    set y = GetUnitY(u) + y
    
    call RemoveUnit( u )
    set u = null
    
    return x*x+y*y <= 100
endfunction

globals
Begin definition of global variables

integer array udg_PathingUnits
Create a new global array of integers named 'udg_PathingUnits'

endglobals
End defining block.

function CheckPathability takes real x, real y, integer pathing_type returns boolean
Ok, we have a function named "CheckPathability" that takes 2 reals, X and Y (probobly coordinates), and an integer, "pathing_type". Returns Boolean, probobly true if the coordinates X and Y are of "pathing_type"

local location l = Location( x, y )
We make a location with the X and Y arguments (so they where coordinates)

local unit u = CreateUnitAtLoc( Player(15), udg_PathingUnits[pathing_type], l, 0. )
So, our global array is going to hold unit types, and the pathing_type argument is an index in that array.

set x = GetUnitX(u) + x
So we add the unit X coordinate to the X we got passed in the function..

set y = GetUnitY(u) + y
And then Y.

call RemoveUnit( u )
Now we remove the unit...? wait, then whats its purpose in the first place?! (some things such as this need to simply be learnt. units created at locations are moved to pathable areas, so our "udg_PathingUnits" array holds a bunch of unit types we can check to see if they fit in a specific spot.)

set u = null
http://wc3campaigns.net/showthread.php?t=81872

return x*x+y*y <= 100
(ya know, im still not sure if this line is right... but its suposed to ensure that there is less then a specific differance between where the unit was created, and the origionally requested point)

endfunction
You just have to remember that if you try and look at the whole peice of code at once, you'll destroy your brain. But if you go throgh it line by line understanding it each line at a time, by the time you get to "return ___", you will know what its actually returning, and how it reached that 'conclusion'.

I hope this is atleast somewhat coherent. No sleep and all...
03-15-2007, 04:49 PM#7
Hydrolisk
Geez, I know I'm gonna have to adapt and learn JASS. And I'm trying to. Thanks, I guess.

So uh, do I absolutely need JASS? Because if I do, I'm gonna have to put off map development for a bit.
03-15-2007, 04:51 PM#8
Jacek
you don't need JASS, don't listen to these idiots...
03-15-2007, 05:01 PM#9
Earth-Fury
You don't need Jass to do allot.
You do need Jass to do some stuff.
You want to use Jass, because it most often makes thigns faster, easyer to read (once you know how), and lets you fix things like memory leaks ALLOT easyer... as well as making things that are nigh impossible in GUI rather simple.

And belive me, Jass makes you life easyer. And, you dont need to put off map making to learn Jass! You just have to learn jass as you go. Start by converting triggers you make into custom text to see how things work on a familiar level and go from there.
03-16-2007, 03:47 AM#10
Hydrolisk
I KNOW JASS WOULD MAKE MY LIFE EASIER! THAT'S WHY I'M TRYING TO LEARN!

Anyways, my question STILL hasn't been answered.
03-16-2007, 10:48 AM#11
StockBreak
With JASS things are easier, but you can create your own Damage Detection System also with GUI.
You could something like this:

Your first trigger:
Trigger:
Cast
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Acid Bomb (or your ability)
Collapse Actions
Trigger - Add to Damage Detection <gen> the event (Unit - (Target unit of ability being cast) Takes damage)

Your second trigger (it must have NO event)
Trigger:
Damage Detection
Events
Collapse Conditions
((Triggering unit) has buff Acid Bomb (or your ability)) Equal to True
Collapse Actions
Unit - Remove Acid Bomb (or your ability) buff from (Triggering unit)
-------- Do what you want --------

I hope it helps. Cheers.

EDIT: I suggest you using an ability based on Acid Bomb cause it has no side effects (such as stun) and it has a buff.
03-16-2007, 03:43 PM#12
masda70
Quote:
Originally Posted by Hydrolisk
Anyways, my question STILL hasn't been answered.

Did you try doing what I said? Or wasn't I clear enough? :(
03-16-2007, 04:52 PM#13
Hydrolisk
I guess it wasn't clear enough. It was sort of confusing too. Big bodies of text in this font without space and paragraphs are hard for me to see. I think I need glasses soon.

Thanks Earth-Fury. +Rep to any who tried to contribute. Uber thanks! ON WITH THE MAP.
03-16-2007, 06:12 PM#14
Earth-Fury
Quote:
Originally Posted by masda70
The idea is to have a dummy unit uniquely bound to a particular spell instance throughout its duration (as in no recycling, no multi-purpose, not player-controllable during that period). After it is ordered to cast for example a storm bolt, dynamically creating an on-damage triggered event response (as in X unit takes damage event) will allow you to precisely detect when the missile exactly hits its target, and you will know it was spell missile that hit that unit as the only information about the event you need to know is the fact that the damaging unit was the dummy unit. The dummy unit shouldn't be able to hit any other targets or do any other damage than the intended spell damage.
The dummy unit can then hold particular cache data of that spell instance, such as ability level.
This method will work as long as one dummy unit is exclusively reserved to each spell instance.

You have a dummy unit cast a spell. You create a trigger dynamically (which is rather easy to do in Jass, because all a trigger is is a function that is excecuted when an event happens.) that detects when a unit takes damage, and you do a check to see if it was the dummy unit did the damage.

This works because the dummy unit will just be sitting there doing nothing, so it won't be able to deal damage to anything else. So the dynamically created trigger will only fire once, when the spell hits and damages the unit. You can then do you're on-hit stuff within that trigger.

A bit complex a thing if you're just learning jass. Vex has a tutorial on triggers in jass (should read it if you haven't alredy)
http://wc3campaigns.net/showthread.php?t=80002
03-16-2007, 07:16 PM#15
Hydrolisk
Bleh, trying a bunch of tutorials at once won't help too much.