XD help me fix my slide trigger, <Major Noob> XD

M

Mythic Fr0st

Guest
Help me fix my slide trigger, its fun! you get to see what kind of strange things get processed by my mind! XD

PHP:
function Trig_Slide_Actions takes nothing returns nothing
  local real x
  local real y
  local real a
  local real L
  local integer i = 1
     set L = GetUnitLoc, udg_Raq[i]
     set x = GetUnitLoc, udg_Raq[i], 40*cos
     set y = GetUnitLoc, udg_Raq[i], 40*sin
     set a = x*y
     if GetTerrainType(L) not ( equal to "lice") then
     call SetUnitPosition udg_Raq[i](a)
     
endfunction

//===========================================================================
function InitTrig_Slide takes nothing returns nothing
    set gg_trg_Slide = CreateTrigger(  )
    call TriggerRegisterEventTimerPeriodic(Trig_Ice_Slide_Actions, .03)
    call TriggerAddAction( gg_trg_Slide, function Trig_Slide_Actions )
endfunction

I dont know what im doing lol
 

NiKaNoRoU_GR

New Member
Reaction score
115
Advices:
1.70%+ of your words consist of XD and lol.
At least lower it public
2.You could use
Code:
 tags thank you.
 

monoVertex

I'm back!
Reaction score
460
Fr0zen said:
Code:
  if GetTerrainType(L) not ( equal to "lice") then

WTF :nuts:

It should be GetTerrainType(L) != 'the_rawcode_of_the_terrain_here' then

Attention: you must use ' not "
 
M

Mythic Fr0st

Guest
hmm

thanks Smith, XD lol :) I cant wait to till my next problems XD! lol, and no Lolz, nik XD I am nothing without lol and XD, XD is my friendly nooby face:) XD lol
lol is my sentence beginner and starter, most of the time lol, see like
Code:
 AND /CODE] tags :) lol, seriously cant stop it, and why would I use code tags on jass (Wth) ??!? ^_^
 
M

Mythic Fr0st

Guest
hmm

I've never seen you post jass... you dont post jass with code tags lol...
You dont even know jass XD as far as you've told me lol
 
C

CryptWizard

Guest
Basically, you have the syntax all wrong, here is just a bit of a guide on the syntax of JASS.

Code:
function Trig_Slide_Actions takes nothing returns nothing
  local real x
  local real y
  local real a
  local real L
  local integer i = 1
     set L = GetUnitLoc, udg_Raq[i]
     set x = GetUnitLoc, udg_Raq[i], 40*cos
     set y = GetUnitLoc, udg_Raq[i], 40*sin
     set a = x*y
     if GetTerrainType(L) not ( equal to "lice") then
     call SetUnitPosition udg_Raq[i](a)
     
endfunction

//======================================================================  =====
function InitTrig_Slide takes nothing returns nothing
    set gg_trg_Slide = CreateTrigger(  )
    call TriggerRegisterEventTimerPeriodic(Trig_Ice_Slide_Actions, .03)
    call TriggerAddAction( gg_trg_Slide, function Trig_Slide_Actions )
endfunction

Calling a Function
FunctionName(argument1, argument2, argument_etc)
Code:
set L = GetUnitLoc, udg_Raq[i]
should be
Code:
set L = GetUnitLoc(udg_Raq[i])
I have no idea what the next 2 lines mean.

Heres the correct syntax for the if statement:
Code:
if GetTerrainType(L) not ( equal to "lice") then
should be
Code:
if (GetTerrainType(L) != 'lice') then
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
You could just use my slide trigger:

Code:
function H2I takes handle h returns integer
    return h
    return 0
endfunction

function LocalVars takes nothing returns gamecache
    // Replace InitGameCache("jasslocalvars.w3v") with a global variable!!
    return InitGameCache("jasslocalvars.w3v")
endfunction

function GetHandleTimer takes handle subject, string name returns timer
    return GetStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    return null
endfunction

function GetHandleUnit takes handle subject, string name returns unit
    return GetStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    return null
endfunction

function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction
 
function StopSlide takes unit Slider returns nothing
    local timer t = GetHandleTimer(Slider,"t")
    call FlushHandleLocals(t)
    call DestroyTimer(t)
    set t = null
    //Flushes the stuff attached to the timer, and destroys the timer, so you don't have to :).
    //call FlushHandleLocals(Slider)
endfunction

function ConstantSlide takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local string ts = I2S(H2I(t))
    local unit S = GetHandleUnit(t,"S")
    local real A = GetStoredReal(LocalVars(),ts,"A")
    local real D = GetStoredReal(LocalVars(),ts,"D")
    local real Speed = GetStoredReal(LocalVars(),ts,"Speed")
    local real X = GetUnitX(S) + Speed * Cos(A * bj_DEGTORAD)
    local real Y = GetUnitY(S) + Speed * Sin(A * bj_DEGTORAD)
    //This will make it so you can still control the unit.
	//Uses the exact same formula as PolarProjectionsBJ.
     if RectContainsCoords(GetCameraBoundsMapRect(),X,Y) then
        call SetUnitX(S,X)
        call SetUnitY(S,Y)
    else
        set D = Speed
    endif
    if D != 0 then
        //Only if it's supposed to be sliding to a certain place will it check to see if it should stop the slide
        //Or restore the distance, for future checking.
        //(This way it won't keep restoring 0 for no reason)
        set D = D - Speed
        if D == 0 then
            call StopSlide(S)
        else
            call StoreReal(LocalVars(),ts,"D",D)
        endif
    endif
    set t = null
    set S = null
endfunction

function SimpleSlide takes unit Slider, real Distance, real Angle, real SpeedPerSec, real UpdateTime returns nothing
    //If the distance is 0, it will attach the timer to the unit
	//(and the unit to the timer for the sliding part)
	//and it will constantly slide until you call the StopSlide function
	//or until you destroy the timer.  
	//(Not recommended, since the stopslide function will destroy the timer
	//and remove all the leaks/clean up the locals).
	local timer t = CreateTimer()
	local unit S = Slider
	local real D = Distance
	local real A = Angle
	local real Speed = SpeedPerSec * UpdateTime
	local real UT = UpdateTime
	local string ts = I2S(H2I(t))
    call StoreInteger(LocalVars(),ts,"S",H2I(S))
    call StoreReal(LocalVars(),ts,"A",A)
    call StoreReal(LocalVars(),ts,"D",D)
    call StoreReal(LocalVars(),ts,"Speed",Speed)
    call StoreInteger(LocalVars(),I2S(H2I(S)),"t",H2I(t))
    call StoreReal(LocalVars(),ts,"UT",UT)
    call TimerStart(t,UT,true,function ConstantSlide)
    set ts = ""
    set t = null
endfunction

Right now You can just call it with this:

call SimpleSlide(Unit,0.00,Angle,(SpeedoftheUnit REAL),0.04)

This will constantly move the unit toward the angle you give it, at the speed you give it, until you use this to stop the unit's sliding:

call StopSlide(Unit)

If you want to make it use the unit's facing angle, just modify this part:

Code:
    local unit S = GetHandleUnit(t,"S")
    local real A = GetStoredReal(LocalVars(),ts,"A")
    local real D = GetStoredReal(LocalVars(),ts,"D")

Which is under the ConstantSlide function. Change it to this:

Code:
    local unit S = GetHandleUnit(t,"S")
    local real A = GetUnitFacing(S)
    local real D = GetStoredReal(LocalVars(),ts,"D")

And if you don't want the unit to be able to move around while sliding, just pause the unit before and after the slide.
 
M

Mythic Fr0st

Guest
wow

Wow...

Complex lol, thanks ^_^ I'll see if I can do it XD i've never used gamecache before o_O

Hmm, why pause, why not at a timer, that runs it every .03 seconds... and also checks the terrain type?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top