• 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] Jass not working, Blizzard bug?

Status
Not open for further replies.
Level 5
Joined
Jul 17, 2006
Messages
145
ok well iv noticed that whenever you pick every unit in a unit group and do <actions>, it sometimes tends to to work if you use certian functions such as "triggersleepaction()" etc. I dont know if thats the case here, (at least i hope not, i dont wanna have to remake this script again O__O) but that it is because of some stupid mistake i made.

Im also assuming that it picks one unit in a group, does the actions, and moves onto the next one. hence the use of a global var in this script

This script has passed the blizzard syntax check and the JassCraft syntax check. It runs the game without crashing, it just simply dosent work.


What this script _should_ do is pick every circle of power on the map, then create a rifleman at that position and give it some stationary buffs. then, it should pick every unit within 500 of the circle of type (building A000, a barracks) and also a tower, which i dont have in this map (im making a demo map for someone, just to showcase the trigger) and convert them to the player it made the rifleman for. it should do this for every player in turn, so that each player has an even (or almost even) number of "bases"

JASS:
function Trig_Barracks_Setup_Func001001002 takes nothing returns boolean
    return ( GetUnitTypeId(GetEnumUnit()) == 'ncp2' )
    // circle of power
endfunction

function Trig_Barracks_Setup_Func001Func002001003001 takes nothing returns boolean
    return ( GetUnitTypeId(GetEnumUnit()) == 'h000' )
endfunction
    // yes i realize they are the same, but they will be changed.  regardless, this should still work
function Trig_Barracks_Setup_Func001Func002001003002 takes nothing returns boolean
    return ( GetUnitTypeId(GetEnumUnit()) == 'h000' )
endfunction

function Trig_Barracks_Setup_Func001Func002001003 takes nothing returns boolean
    return GetBooleanOr( Trig_Barracks_Setup_Func001Func002001003001(), Trig_Barracks_Setup_Func001Func002001003002() )
endfunction

//===========================================================================

function Trig_Barracks_Setup_Func001Func002A takes nothing returns nothing
    call SetUnitOwner( GetEnumUnit(), ConvertedPlayer(udg_SetupPlayerNumber), true )
endfunction

function Trig_Barracks_Setup_Func001A takes nothing returns nothing
    local group g = GetUnitsInRangeOfLocMatching(500.00, GetUnitLoc(GetLastCreatedUnit()), Condition(function Trig_Barracks_Setup_Func001Func002001003))
    local unit u
    local location l = GetUnitLoc(GetEnumUnit())
    loop
        set udg_SetupPlayerNumber = udg_SetupPlayerNumber + 1
        exitwhen udg_SetupPlayerNumber > 12
        exitwhen GetPlayerSlotState(ConvertedPlayer(udg_SetupPlayerNumber)) == PLAYER_SLOT_STATE_PLAYING
    endloop
    if (udg_SetupPlayerNumber > 12) then
        set udg_SetupPlayerNumber = 1
    endif

    set u = CreateUnitAtLoc(ConvertedPlayer(udg_SetupPlayerNumber), 'hrif', l, bj_UNIT_FACING)
    call UnitAddAbility(u, 'A000')    //stationary ability, pretty much a 100% self-slow
    call AttachBoolean(u, "stationary", true)
    call ForGroupBJ( g, function Trig_Barracks_Setup_Func001Func002A )

    call RemoveLocation(l)
    set g = null
    set u = null
    set l = null
endfunction

function Trig_Barracks_Setup_Actions takes nothing returns nothing
    local group g = GetUnitsOfPlayerMatching(Player(PLAYER_NEUTRAL_PASSIVE), Condition(function Trig_Barracks_Setup_Func001001002))
    call ForGroupBJ( g, function Trig_Barracks_Setup_Func001A )
    set g = null
endfunction

//===========================================================================
function InitTrig_Barracks_Setup takes nothing returns nothing
    set gg_trg_Barracks_Setup = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Barracks_Setup, function Trig_Barracks_Setup_Actions )
endfunction

any help would be apricated. thx in advance :p
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Uhh the trigger has NO EVENRS and so unless it fires on map int it will not work and even if it is it will only run once on map int so it will not work twice.

It leaks like a sive and you did not optimize it eithor.

JASS:
function Trig_Barracks_Setup_Func001001002 takes nothing returns boolean
    return ( GetUnitTypeId(GetEnumUnit()) == 'ncp2' )
    // circle of power
endfunction

function Trig_Barracks_Setup_Func001Func002001003 takes nothing returns boolean
    return GetUnitTypeId(GetEnumUnit()) == 'h000' or GetUnitTypeId(GetEnumUnit()) == 'h000' 
endfunction

function Trig_Barracks_Setup_Func001Func002A takes nothing returns nothing
    call SetUnitOwner( GetEnumUnit(), ConvertedPlayer(udg_SetupPlayerNumber), true )
endfunction

function Trig_Barracks_Setup_Func001A takes nothing returns nothing
    local group g = GetUnitsInRangeOfLocMatching(500.00, GetUnitLoc(GetLastCreatedUnit()), Condition(function Trig_Barracks_Setup_Func001Func002001003))
    local unit u
    local location l = GetUnitLoc(GetEnumUnit())
    loop
        set udg_SetupPlayerNumber = udg_SetupPlayerNumber + 1
        exitwhen udg_SetupPlayerNumber > 12
        exitwhen GetPlayerSlotState(ConvertedPlayer(udg_SetupPlayerNumber)) == PLAYER_SLOT_STATE_PLAYING
    endloop
    if (udg_SetupPlayerNumber > 12) then
        set udg_SetupPlayerNumber = 1
    endif
    set u = CreateUnitAtLoc(ConvertedPlayer(udg_SetupPlayerNumber), 'hrif', l, bj_UNIT_FACING)
    call UnitAddAbility(u, 'A000')
    call AttachBoolean(u, "stationary", true)
//What the hell is this?   There is no native function called attach boolean. . .  How did you ge this pass syntax check even?
//POST ALL YOUR CODE THE SPELL USES OR NO ONE CAN HELP YOU SINCE WE CAN NOT READ MINDS!!!
    call ForGroupBJ( g, function Trig_Barracks_Setup_Func001Func002A )
    call DestroyGroup(g)
    call RemoveLocation(l)
    set g = null
    set u = null
    set l = null
endfunction

function Trig_Barracks_Setup_Actions takes nothing returns nothing
    local group g = GetUnitsOfPlayerMatching(Player(PLAYER_NEUTRAL_PASSIVE), Condition(function Trig_Barracks_Setup_Func001001002))
    call ForGroupBJ( g, function Trig_Barracks_Setup_Func001A )
    call DestroyGroup(g)
    set g = null
endfunction

function InitTrig_Barracks_Setup takes nothing returns nothing
    set gg_trg_Barracks_Setup = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Barracks_Setup, function Trig_Barracks_Setup_Actions )
endfunction

I removed all leaks but the condition leaks that are made, remove them your self. Make sure you are using the right event since if it fires on map int it will only fire once and not again, for it to fire again use a generic event.
 
Level 5
Joined
Jul 17, 2006
Messages
145
yea, its only supposed to be used onece when the map begins

yea i got rid of most of the leaks but thanks for the help :p


and also, the AttackBooldean() is part of Vexorians CsCache system, iv seen people post JASS script assuming that people know how to use cache systems, and JassCraft passes it as a normal function because so many people use it.
 
Level 5
Joined
Jul 17, 2006
Messages
145
yes purple thats what i was assuming :p
but what i ment was, when you mae a trigger that pickes every unit on the map and waits for 4 seconds, then displays their name, it dosent work. however, if you take out the wait, it does. i was wondering if that was the same concept that was happening here.

the jass above dosent have TriggerSleepAction() in at at all, because i know that it interupts the trigger. i just used it as an example.
 
Level 5
Joined
Jul 17, 2006
Messages
145
By the way, please post your GUI in the GUI forum from now on -- all you did was press Convert and replace globals with workers.

Also, try running this at Time = .01 seconds. Map Initialization can have problems, since that's when the units are created in the first place.

look at it closely. yes i pressed convert but i also added a _few_ special things in. however, i was assuming that the GUI forum was strictly for gui.. if i posted this JASS script there im sure someone woulda told me to post it here >_>

anyways
nop, just tryed that dosent work O_O

try this for me, you might find it interesting

open WE and create a few footmen or something
go into the triggers area and delete the meele triggers. make a trigger that runs after .1 second, and have it pick every unit on the map and display its name, like this:

  • Untitled Trigger 001
    • Events
      • Time - Elapsed game time is 0.10 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (Name of (Picked unit))
then, create another trigger. have it wait 5 seconds or so. have it do the same thing, except this time add a Wait before it displays the unit name, like this:

  • Untitled Trigger 002
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Wait 2.00 seconds
          • Game - Display to (All players) the text: (Name of (Picked unit))
i found that the first trigger will work, but the second will not.

and yes that is in GUI, split the topic if you really want to. i just think that sence the discussion revolves around JASS script, here would the best place for it.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
well for your knowledge, I use jass shop pro since WC3C keeps blocking me from downloading (stupid anti dl). And no wonder it passes the system, considering most of the programs made at WC3C base them selves around vexorians work since he is a major person there.

Yes I knew what it did, but no I did not now the exact coding of it and thus I might miss enterperate it.
 
Level 5
Joined
Jul 17, 2006
Messages
145
hmm i dident dl this from wc3c lol but i guess that makes sence.

ok so note to self when displaying triggers leave a comment? :p i guess that would make sence
thanks for the help ^^
any idea why the trigger wont work though? :s
 
Level 5
Joined
Jul 17, 2006
Messages
145
And Homicide, what I was saying is; Next time, don't convert it and change the globals to locals. Converted GUI is a nightmare to read

ahh ok :p

And super, you missed some leaks. And Condition() and Filter() don't leak

right, so i dont need to worry about the conditions. <_< dident think so lol but whatever. but yea i think all im missing is the group leaks, which shouldent be that hard to fix.

ok so now that weve optimized this trigger, anyone have any idea why it still dosent work? XD
 
Level 5
Joined
Jul 17, 2006
Messages
145
>_> oops
well heres my new code, but it still dosent work.

JASS:
function Trig_Barracks_Setup_Func001001002 takes nothing returns boolean
    return ( GetUnitTypeId(GetEnumUnit()) == 'ncp2' )
endfunction

function Trig_Barracks_Setup_Func001Func002001003001 takes nothing returns boolean
    return ( GetUnitTypeId(GetEnumUnit()) == 'h000' )
endfunction

function Trig_Barracks_Setup_Func001Func002001003002 takes nothing returns boolean
    return ( GetUnitTypeId(GetEnumUnit()) == 'h000' )
endfunction

function Trig_Barracks_Setup_Func001Func002001003 takes nothing returns boolean
    return GetBooleanOr( Trig_Barracks_Setup_Func001Func002001003001(), Trig_Barracks_Setup_Func001Func002001003002() )
endfunction

//===========================================================================

function Trig_Barracks_Setup_Func001Func002A takes nothing returns nothing
    call SetUnitOwner( GetEnumUnit(), ConvertedPlayer(udg_SetupPlayerNumber), true )
endfunction

function Trig_Barracks_Setup_Func001A takes nothing returns nothing
    local unit u
    local location l = GetUnitLoc(GetEnumUnit())
    local group g = GetUnitsInRangeOfLocMatching(500.00, l, Condition(function Trig_Barracks_Setup_Func001Func002001003))
    loop
        set udg_SetupPlayerNumber = udg_SetupPlayerNumber + 1
        exitwhen udg_SetupPlayerNumber > 12
        exitwhen GetPlayerSlotState(ConvertedPlayer(udg_SetupPlayerNumber)) == PLAYER_SLOT_STATE_PLAYING
    endloop
    if (udg_SetupPlayerNumber > 12) then
        set udg_SetupPlayerNumber = 1
    endif

    set u = CreateUnitAtLoc(ConvertedPlayer(udg_SetupPlayerNumber), 'hrif', l, bj_UNIT_FACING)
    call UnitAddAbility(u, 'A000')
    call AttachBoolean(u, "stationary", true)
    call ForGroupBJ( g, function Trig_Barracks_Setup_Func001Func002A )

    call RemoveLocation(l)
    call DestroyGroup(g)
    set u = null
    set l = null
    set g = null
endfunction

function Trig_Barracks_Setup_Actions takes nothing returns nothing
    local group g = GetUnitsOfPlayerMatching(Player(PLAYER_NEUTRAL_PASSIVE), Condition(function Trig_Barracks_Setup_Func001001002))
    call ForGroupBJ( g, function Trig_Barracks_Setup_Func001A )
    call DestroyGroup(g)
    set g = null
endfunction

//===========================================================================
function InitTrig_Barracks_Setup takes nothing returns nothing
    set gg_trg_Barracks_Setup = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Barracks_Setup, 0.30 )
    call TriggerAddAction( gg_trg_Barracks_Setup, function Trig_Barracks_Setup_Actions )
endfunction
 
Level 5
Joined
Feb 16, 2006
Messages
151
Yay, this makes things easier!
...
The codes are OK (thought there are some leaks, but leave me out of BJ stuff...)
The problem is a logical one:
...
Bah, it's so messed up that I will just post my version:
JASS:
function Trig_Barracks_Setup_Func001001002 takes nothing returns boolean
    return ( GetUnitTypeId(GetEnumUnit()) == 'ncp2' )
endfunction
function Trig_Barracks_Setup_Func001Func002001003001 takes nothing returns boolean
    return ( GetUnitTypeId(GetEnumUnit()) == 'h000' )
endfunction
function Trig_Barracks_Setup_Func001Func002001003002 takes nothing returns boolean
    return ( GetUnitTypeId(GetEnumUnit()) == 'h000' )
endfunction
function Trig_Barracks_Setup_Func001Func002001003 takes nothing returns boolean
    return GetBooleanOr( Trig_Barracks_Setup_Func001Func002001003001(), Trig_Barracks_Setup_Func001Func002001003002() )
endfunction
//===========================================================================
function Trig_Barracks_Setup_Func001Func002A takes nothing returns nothing
    call SetUnitOwner( GetEnumUnit(), ConvertedPlayer(udg_SetupPlayerNumber), true )
endfunction

function Trig_Barracks_Setup_Actions takes nothing returns nothing
    local group g = GetUnitsOfPlayerMatching(Player(PLAYER_NEUTRAL_PASSIVE), Condition(function Trig_Barracks_Setup_Func001001002))
    local unit first
    local unit u
    local group g2
    local location loc
    loop
        set udg_SetupPlayerNumber = udg_SetupPlayerNumber + 1
        exitwhen udg_SetupPlayerNumber > 12
        if (ConvertedPlayer(udg_SetupPlayerNumber) == PLAYER_SLOT_STATE_PLAYING) then
            set first = FirstOfGroup(g)
            exitwhen (first == null)
            set loc = GetUnitLoc(first)    
            set g2 = GetUnitsInRangeOfLocMatching(500.00,loc,Condition(function Trig_Barracks_Setup_Func001Func002001003))
            set u = CreateUnitAtLoc(ConvertedPlayer(udg_SetupPlayerNumber),'hrif',loc,0.00)// what is bj_UNIT_FACING ??
            call UnitAddAbility(u,'A000')
            call AttachBoolean(u,"stationary",true)
            call ForGroupBJ(g2,function Trig_Barracks_Setup_Func001Func002A)
            call GroupRemoveUnit(g,first)
            call RemoveLocation(loc)
            call DestroyGroup(g2)
        endif            
    endloop       
    call DestroyGroup(g)
    set g = null
    set first = null
    set u = null
    set g2 = null
    set loc = null
endfunction
//===========================================================================
function InitTrig_Barracks_Setup takes nothing returns nothing
    set gg_trg_Barracks_Setup = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Barracks_Setup, 0.30 )
    call TriggerAddAction( gg_trg_Barracks_Setup, function Trig_Barracks_Setup_Actions )
endfunction
 
Level 5
Joined
Jul 17, 2006
Messages
145
umm looks great i guess...but once it goes through 12 times or so it wont change the udg_SetupPlayerNumber back to 1.
besides, i dont really like using other peoples code, i dont learn from it. ^^

// what is bj_UNIT_FACING ??
thats the "default building angle" or whatever. prettymuch the angle that units appear at when you build say a footmen at a barracks.
 
Level 5
Joined
Jul 17, 2006
Messages
145
At what time am i allowed to revive a post? i didnt see it on the forum rules anywhere. (maybe im just blind but i dunno..)

anyways, i still havnt figured this out and i kina need it for the map im helping with O__O

i realize that maybe i did have a simple "logic error" but i am still clueless as to what UnMe found. im pretty sure the code he gave wont work but even if it did, once again i would like it explained to me as i do not like to blindly use other peoples code; i dont learn anything.
 
Status
Not open for further replies.
Top