• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Jass: Physics

Status
Not open for further replies.
I've seen these in several games and was just wondering if anyone could link me to a script. Preferably one like in Warlocks. I just want to screw around with the script and see what I can do. In Warlocks, if you havent played it, when someone gets hit by a spell it knocks them backwards. BUT whilst being knocked they can still move and cast spells. They can be sent flying backwards while running toward the center, slowing the amount that they are being flung backwards. Im thinking that he has scripts that move the units instead of them just moving through the Warcraft engine, but Im not all that sure. Would someone please give a script, or a link to a script?

//Oh and then if you could please explain it."/
 
In Warlocks you cast spells and they can collide with each other and explode. A player can get hit from a spell and be flying backwards ,0deg (while he is casting), and get hit by another from the side, 90 deg, and be sent threw the difference, 45 deg. I need a good knockback system, and a way to have variables to each and everything that happens.

There is a spell that splits one major proj into several small projs. Each one can be effected. A gravity altering spell can pass by and attract some of the projs but not others. I need a way to check every thing's direction that they are moving (not facing).
Also I need a better editor.

Actually I think I just solved my own problem... I could assign custom values to everything. And have spells or stuff like that be dummy units. Agh.

IN ALL. = I need a good knockback script that is easy to use.
I need an editor that can handle the more advanced JASS (I dont like unlimited).
I need a way to assign two real variables to an indefinate number of units.
Also, is there a way to make a custom event. Like unit collision, not exactly but basically if two units come within 50 range.
 
Level 22
Joined
Jun 23, 2007
Messages
3,242
use NewGen Editor, you can find it here in the tools section or in wc3c. It allows unlimited doodads and stuff, plus it supports Jass.
theres an event or condition in the trigger editor that says When X unit comes with X range of X unit/region. dunno if thats what youre looking for though.
 
Newgen, thats the one. I had it on another computer but forgot what it was called.
The event wont work. It requires a specific unit. When unit comes within XXX of UNIT, not gonna work. Perhaps I could implement it into the knockback function.
---
I couldnt find newgen in the tools.
---
I couldnt find NewGen online. Haven't they updated thier editor to the new version yet?
---
Maybe this should be moved to Trigger/Jass section or something. Here is what I got so far.
JASS:
see below
Problem is, this will go on forever. I need a way to subtract a friction of some variable to it during each timer iteration. How would I do that?
Also the collision section is wrong. Something could collide while facing another way. Also I think the timers are wrong...
Ignore syntax for now, just basic idea.
---
JASS:
function SpdX takes real Spd, real Angle returns real
    return (Spd * Cos(Angle) )
endfunction

function SpdY takes real Spd, real Angle returns real
    return (Spd * Sin(Angle) )
endfunction

function KBUnit takes unit Vic, real Speed, real Angle returns nothing
    SetUnitX( Vic, (GetUnitX( Vic ) + SpdX( Speed, Angle )) )//Syntax error, prolly up one line.
    SetUnitY( Vic, (GetUnitY( Vic ) + SpdY( Speed, Angle )) )
endfunction

function Nint takes nothing returns real
    return 0.035
endfunction

function Collision takes unit Vic, unit Agr, real Friction returns nothing
    local timer Tim = CreateTimer()
    local real Speed = GetUnitMoveSpeed( Agr )
    local real Angle = GetUnitFacing( Agr )   
    loop
        exitwhen (Speed == 0)
        call TimerStart( Tim, Nint(), true, function KBUnit( Vic, Speed, Angle ) )//Syntax error, prolly up one line.
        set Speed = Speed - Friction
    endloop
    call DestroyTimer( Tim )
    set Tim = null
endfunction

function Movement takes unit Cast, location Target returns nothing
    local timer Tim = CreateTimer()
    local location Casloc = GetUnitLoc( Cast )
    local real Speed = GetUnitMoveSpeed( Cast )
    local real Dist = DistanceBetweenPoints( Casloc, Target )
    local real Angle = AngleBetweenPoints( Casloc, Target )
    loop
        exitwhen (Dist == 0)
        if (Speed > Dist) then
            call TimerStart( Tim, Nint(), true, function KBUnit( Cast, Dist, Angle ) )//Syntax error, prolly up one line.
        else
            call TimerStart( Tim, Nint(), true, function KBUnit( Cast, Speed, Angle ) )//Syntax error, prolly up one line.
        endif
        set Casloc = GetUnitLoc( Cast )
        set Dist = DistanceBetweenPoints( Casloc, Target )
        set Angle = AngleBetweenPoints( Casloc, Target )
    endloop
    set Casloc = null
endfunction
I dont have time right now, post and go. Plz find errors and tell me. gtg be back later.
 
Last edited:
Status
Not open for further replies.
Top