• 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] knockback again

Status
Not open for further replies.
Level 19
Joined
May 1, 2008
Messages
1,130
so i'm trying to do a simple MUI knockback trigger in JASS using an old fashion GUI method.
I don't want extreme precision like sin, cos, x, y etc i just want to get it done so i came up with this code
JASS:
function slide_Actions takes nothing returns nothing
    local unit caster=GetSpellAbilityUnit()
    local location point1
    local location point2
    local integer time=40
    local real speed = 5
loop
set point1=GetUnitLoc(caster) 
set point2=PolarProjectionBJ(point1, speed, GetUnitFacing(caster))
call SetUnitPositionLoc(caster, point2)
set time=time-1
call RemoveLocation(point1)
call RemoveLocation(point2)
exitwhen time==0
endloop
set caster=null
set point1=null
set point2=null
endfunction

//===========================================================================
function InitTrig_slide takes nothing returns nothing
    set gg_trg_slide = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_slide, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_slide, function slide_Actions )
endfunction

i'm aware that this loop does the actions in a crazy short amount of time and looks like the unit just instantly moves to the endpoint without sliding ><, so is there a way to make this work as a good sliding trigger without any crazy coding which i am not aware since this is my very first code in jass? :mwahaha:
or is it MUI at all? :confused:
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
A) You have an initializing function that takes all your arguments (such as the unit to be knocked, the speed, angle, time, etc), this function starts a timer that in each iteration makes the moves.

B) You have an initializing function that takes all your arguments (such as the unit to be knocked, the speed, angle, time, etc), this function first checks if there are other "instances" running, if not then it starts a global timer, it then adds these arguments to a global array (a struct is neater, in case you want to use vJass), and at each iteration the timer makes the moves for all the "instances" with the info located in the arrays/structs.

B is faster and easier, but has a limit of 8192 instances (which you'll never get to anyway).

I won't give more info since it was answered already a million times already.
 
Status
Not open for further replies.
Top