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

Knockback Unit

JASS:
function Test takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local real x1 = GetUnitX(c)
    local real y1 = GetUnitY(c)
    local real x2 = GetUnitX(t)
    local real y2 = GetUnitY(t)
    local real dist = 500
    local real angle = Atan2(y2 - y1, x2, x1)
    local real dur = 2
    call Knockback(t, dist, angle, dur)
    set c = null
    set t = null
endfunction

Shouldn't the line

JASS:
local real angle = Atan2(y2 - y1, x2, x1)

Be

JASS:
local real angle = Atan2(y2 - y1, x2 - x1)

?
 

DKG

DKG

Level 3
Joined
Jan 29, 2008
Messages
54
Shouldn't the line

JASS:
local real angle = Atan2(y2 - y1, x2, x1)

Be

JASS:
local real angle = Atan2(y2 - y1, x2 - x1)

?

Yeah it should, but thats easy to figure out when you chuck it in and jasshelper tells you you're passing too many arguments.
 

DKG

DKG

Level 3
Joined
Jan 29, 2008
Messages
54
Are you using NewGen world editor? Need Jasshelper or it'll throw a fit.
 
And yes, I have the latest ver of NewGen

I alrdy said I do, and I put it in JASSCraft, and I get the same problem.

Does this require anything else? Like Caster System or something?

Also, I think a cool think to add would be an UPWARD (as in aeriel) aspect to this knockback, because there pretty much aren't any knockbacks that do that.

i.e: most knockback functions pretty much look like this: ____ (as the path), but one that went like this .-`-. would be rather unique and really cool.
 

DKG

DKG

Level 3
Joined
Jan 29, 2008
Messages
54
Well I just chucked it into a new map and everything compiled just fine, not sure whats wrong with yours.

I'm assuming you copied everything correctly, put it into its own trigger etc?
 

DKG

DKG

Level 3
Joined
Jan 29, 2008
Messages
54
Try quoting the post, and copying the raw code, apparently that can be a problem for some people.
 

DKG

DKG

Level 3
Joined
Jan 29, 2008
Messages
54
Looks exactly the same as mine ><

whats the specifics of the syntax error?
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Of course JassCraft returns an error, it doesn't have the vJass syntax, I thought that was already known.

Thanks for pointing the Test error out. Everything should be fine, if your syntax checker doesn't recognize libraries, then something is obviously wrong with it.
 
.....I know how to properly test maps.
Also, WE doesn't even LET me test the map, just like Warcraft wont let me play the map.
And this knockback function is the only new thing I added, it worked perfectly fine before.

Also, I used the integrate WeU funtion of the NewGen editor, I'll see if turning that off makes any difference.
 
Last edited:
Level 21
Joined
Dec 9, 2007
Messages
3,096
Lol

It doesn't works for me, look here at the attached image, please ask me where's my mistake!!!:eekani:
 

Attachments

  • That is the image in jpg.JPG
    That is the image in jpg.JPG
    42 KB · Views: 113
Level 5
Joined
Jan 15, 2007
Messages
199
Silvenon said:
JASS:
            if (x < MAX_X and y < MAX_Y and x > MIN_X and y > MIN_Y) and not BoolAr[1] then
                call SetUnitX(dat.u, x)
                call SetUnitY(dat.u, y)
            endif

            set dat.d1 = dat.d1 - dat.d2

            if dat.d1 <= 0 or (x > MAX_X or y > MAX_Y or x < MIN_X or y < MIN_Y) or BoolAr[1] then
                set Ar[i] = Ar[Total - 1]
                set Total = Total - 1

                call dat.destroy()
            endif


->

JASS:
            if dat.d1 <= 0 or (x > MAX_X or y > MAX_Y or x < MIN_X or y < MIN_Y) or BoolAr[1] then
                set Ar[i] = Ar[Total - 1]
                set Total = Total - 1

                call dat.destroy()
            else
                call SetUnitX(dat.u, x)
                call SetUnitY(dat.u, y)
            endif

More efficient (tho very slightly), and doesn't slide partially into the wall on the last interval, also, won't this go through cliffs?

You could do

JASS:
            if dat.d1 <= 0 or (x > MAX_X or y > MAX_Y or x < MIN_X or y < MIN_Y) or BoolAr[1] or IsTerrainPathable( x, y, PATHING_TYPE_WALKABILITY ) == false then
(IsTerrainPathable is bugged and returns the opposite of what it should, thats why I put == false)

Soo, overall, change what i Quoted from yours to:


JASS:
            if dat.d1 <= 0 or (x > MAX_X or y > MAX_Y or x < MIN_X or y < MIN_Y) or BoolAr[1] or IsTerrainPathable( x, y, PATHING_TYPE_WALKABILITY ) == false then
                set Ar[i] = Ar[Total - 1]
                set Total = Total - 1

                call dat.destroy()
            else
                call SetUnitX(dat.u, x)
                call SetUnitY(dat.u, y)
            endif
 

DPL

DPL

Level 5
Joined
Apr 14, 2008
Messages
171
You all are talking nosense :D !
This sistem is great :) . Easy to understand
 
Level 12
Joined
Mar 23, 2008
Messages
942
* unit u = the unit being knockbacked
* real d = the distance the unit is knockbacked to
* real a = the angle (direction of the knockback) in RADIANS
* real w = the duration of the knockback
* real r = the radius of tree destroying, but there's a new trick: if you put a negative number as the radius, the unit will stop knockbacking when it gets in that range of a tree and if you put a positive value, the unit will destroy trees when it gets in that range of a tree (if you don't want any of those, just put 0)
* integer t = type 0 means no effect (both s and p should be ""), type 1 means periodic effect (meaning you should put "" as the attachment point, parameter p), type 2 means a special effect attached on the unit and destroyed when the knockback is finished (this is where you use parameter p)
* string s = the path to the special effect you want to use (periodic), that effect will be destroyed immediatelly (you can put "" if you don't want a special effect)
* string p = used for type 2, it's the attachment point of the effect, "chest" is default (so if you put "", it will be "chest")
I can only use (u, d, a, w) if I try to use the others input it says: "Too many arguments"
How can I fix it? Also, how can I make two attached effects instead of one?
Thanks

Edit1: Lolz I found it xD But how can I make it spawns two effects instead of one?
Edit2: Some tips to make it looks like the unit is pushing the floor?
Edit3: The unit still pass trough trees and walls even if I put -1 to -250 in real r.
 
Last edited:
Level 7
Joined
Nov 4, 2006
Messages
153
non-jasser here!
I need help calling it, with the special effects
I did:
  • tempUnit[1] = attacked unit
  • tempReal[1] = 100
  • tempReal[2] = radians(angle between attacker and attacked) - im aware of the leaks
  • tempReal[3] = 1.10
  • custom script: call KnockbackEx(udg_tempUnit[1], udg_tempReal[1], udg_tempReal[2], udg_tempReal[3], 0, 1, "Abilities\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl", "")
eh, dont' know how to make the fancy trigger images...anyways please help :)
it's not working for some reason but I can get the Knockback(target, distance, angle, duration) to work, but I'm not sure how to correctly put in the parameters for the KnockbackEx (I want no destroying trees and periodic effect)
 
Last edited:
Level 3
Joined
Jun 14, 2007
Messages
56
Hey Silvenon, Does this knockback function work with missiles?

What would i have to change to make it work for missiles? AkA how to make it detect a collision?
 
Level 11
Joined
Nov 4, 2007
Messages
337
This is bugged!
All knockback systems except mine are bugged!
You loop thorugh the knockbacks and if a knockback is finished, you decrease Total.
But:
You have knockbacks 1-4
knockback 2 finishes.
So knockback 4 stops.
wtf?
Thats just bugged!

Solution that I use:
JASS:
function PushUp_Structs takes integer fromwhere returns nothing
    local integer i = fromwhere
        loop
    set i = i + 1
    exitwhen i > Total
    set Knockbackdata[i-1] = Knockbackdata[i]
        endloop
    set Total = Total - 1
endfunction

So the following first numbers are the knockbacks.
And the number after '=' is the new number of the knockback
--- means knockback ended

1 = 1
2 = ---
3 = 2
4 = 3

1 = 1
2 = ---
3 = 2

1 = 1
2 = ---

1 = ---
 
Level 8
Joined
Aug 6, 2008
Messages
451
You should test it before posting lol. It works just fine.

Lets say that we have: [a] [c] [d] Total = 4

[a]=0 =1 [c]=2 [d]=3

stops:

set Ar = Ar[Total - 1]
set Ar[1] = Ar[4-1]
set Ar[1] = Ar[3]

Result: [a] [d] [c] - Total = 3


You get it?

edit. some editing..
 
Level 14
Joined
Nov 18, 2007
Messages
816
Replace: (method Execute)
JASS:
            if dat.d1 <= 0 or (x > MAX_X or y > MAX_Y or x < MIN_X or y < MIN_Y) or BoolAr[1] then
                set Ar[i] = Ar[Total - 1]
                set Total = Total - 1

                call dat.destroy()
            endif

With:
JASS:
            if ((dat.d1<=(dat.d2/2) and dat.d2>=0) or (dat.d1>=(dat.d2/2) and dat.d2<0)) or (x > MAX_X or y > MAX_Y or x < MIN_X or y < MIN_Y) or BoolAr[1] then
                set Total = Total - 1 // if im already changing his code, i might as well do some optimization
                set Ar[i] = Ar[Total]

                call dat.destroy()
            endif

And then use a negative distance.

Edit: That wont work for now....ill update when i have a solutionThat was easy.
 
Top