Jass passing variables to other functions

kissmenow21

New Member
Reaction score
0
Hi, I've started learning about jass.. Two days ago I had almost zero knowledge but then after learning about Polled wait, I kinda regained confidence. But there are two problems...

I have read multiple number of other posts on those problems but they did not fully answer my questions very well.. or I suck very hard at searching

1. The code is extremely messy but if you look at the inside of the loop, you can see this line of code (this will be noticeable in my full code)

JASS:
 call ForGroupBJ( GetUnitsInRangeOfLocMatching(250.00, Location((manX-ptX)/divConst*exit+ptX,(manY-ptY)/divConst*exit+ptY), Condition(function Trig_tong_condition)), function Trig_tong_action )


This (when I converted "Unit - Pick all unit blah blah") needed two new side functions to work. The two functions are "tong_condition" and "tong_action". But the problem is that I can't pass the variable "man" to the function.

I tried putting

scope tong initializer Init on the first line and on the last line and putting in globals and it gave me 100s of error messages that says

syntax error
statement out of function x 100s

If there is a way to pick units that'd be great.
If there is a way to pass a variable easier, that'd be great. Thank you !

2. if you have time, can you give me an example of a timer that will work just like Polled wait that I put there? I just want a wait that is more precise. Thank you !

My first Jass code (full) below. If it's not significant, you don't have to proof read and help me fix/organize/destroy variable it XD. I just want to see it work and make it more elegant later! :D
JASS:

function Trig_tong_condition takes nothing returns boolean
    return ( GetOwningPlayer(GetEnumUnit()) != GetOwningPlayer(man) )
endfunction

function Trig_tong_action takes nothing returns nothing
    call UnitDamageTargetBJ( man, GetEnumUnit(), 1004.00, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
endfunction


function Trig_flame_blader_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00P' ) ) then
        return false
    endif
    return true
endfunction

function Trig_flame_blader_Actions takes nothing returns nothing
local effect eff
//local unit man
local location pt
local location realpt
local unit dummy
local real killtime
local location manloc
local real ptX
local real ptY
local real manX
local real manY
local real divConst
local integer exit

call DisplayTextToForce(GetPlayersAll(),"start function")
    call AddSpecialEffectTargetUnitBJ( "hand, right", GetSpellAbilityUnit(), "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl" )
    set eff = GetLastCreatedEffectBJ()
    set man = GetSpellAbilityUnit()
    set pt = GetSpellTargetLoc()
    call PolledWait(.002)
    set manloc = GetUnitLoc(man)
    set killtime = DistanceBetweenPoints(manloc, pt)/522-.5
    call SetUnitAnimation( man, "ATTACK" )
    call PauseUnitBJ( true, man )


call DisplayTextToForce(GetPlayersAll(),"ah what tha heck")
    call SetUnitPositionLocFacingBJ( man, pt, AngleBetweenPoints(manloc, pt) )
    set realpt = GetUnitLoc(man)
    set manX = GetLocationX(manloc)
    set manY = GetLocationY(manloc)
    set ptX = GetLocationX(realpt)
    set ptY = GetLocationY(realpt)
    set exit = 10
    set divConst = exit
    call DisplayTextToForce(GetPlayersAll(),"b4 loop")
loop
exitwhen exit<0
    
    //call CreateNUnitsAtLocFacingLocBJ( 1, 'h00J', GetOwningPlayer(GetSpellAbilityUnit()), Location((manX-ptX)/divConst*exit+ptX,(manY-ptY)/divConst*exit+ptY), pt )
    
    //set dummy = GetLastCreatedUnit()
    //call SetUnitVertexColorBJ(dummy,0,0,0,100)
    //call UnitDamagePointLoc( man, 0, 250.00, Location((manX-ptX)/divConst*exit+ptX,(manY-ptY)/divConst*exit+ptY), 100.00, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )


/*   @@@@@@@@@@@@@ LOOK HERE !!!!!!!! The code mentioned in my problem 1 @@@@@@@@@@@@@@@@     */
    call ForGroupBJ( GetUnitsInRangeOfLocMatching(250.00, Location((manX-ptX)/divConst*exit+ptX,(manY-ptY)/divConst*exit+ptY), Condition(function Trig_tong_condition)), function Trig_tong_action )    
/*   @@@@@@@@@@@@@ LOOK HERE !!!!!!!! The code mentioned in my problem 1 @@@@@@@@@@@@@@@@     */

    //call KillUnit(dummy)
    //set dummy = null
    call DisplayTextToForce(GetPlayersAll(),I2S(exit))
    set exit=exit-1
endloop 

call DisplayTextToForce(GetPlayersAll(),"after loop")

    call SetUnitAnimation( man, "Attack" )
    call SetUnitTimeScalePercent( man, 10.00 )
    call SetUnitVertexColorBJ(man,0,0,0,70)
    



    //call SetUnitTimeScalePercent( man, 500.00 )
    call PolledWait(.1)
    call SetUnitVertexColorBJ(man,100,100,100,40)
    call SetUnitTimeScalePercent( man, 200.00 )
    call PolledWait(.4)
    call PauseUnitBJ( false, man )
    call SetUnitVertexColorBJ(man,100,100,100,0)
    call SetUnitTimeScalePercent( man, 100.00 )    
    call DestroyEffectBJ( eff )
    set man = null
    set eff = null
    set pt = null
    call PolledWait(killtime)
    call KillUnit(dummy)
    set dummy = null
endfunction

//===========================================================================
function InitTrig_tong takes nothing returns nothing
    set gg_trg_tong = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_tong, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_tong, Condition( function Trig_flame_blader_Conditions ) )
    call TriggerAddAction( gg_trg_tong, function Trig_flame_blader_Actions )
endfunction
 
You are using Jass NewGen, correct?
 
Are you trying to use that Syntax Check button? That doesn't work with vJass.
 
JASS:
globals
    unit globalUnit
endglobals


Yes, vJass is wonderful ^^
E: Bah i actually misread <.< I missed the few lines saying that he tried globals and scope.
My bad :/ Excuse me
 
Thank you so much guys

so the problem was that I was using "check syntax" button. lol..

It works now.

Thank you again!! you guys are reat :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top