• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] A Couple Problems :(

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
Okay, So i read all of the jass tutorials and all of them start nice and slow, and then jumps. I read trying to find out how to, say creating a unit at a local point. I then Tried converting the trigger from GUI to JASS and going about it that way. While it works, i wanted to remove the "BJ"'s and such. This is what i have so far. Im novice, so please bear with me:thumbs_up:
JASS:
function Trig_Light_Invisible_Sins_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetEnteringUnit()) == 'e005' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Light_Invisible_Sins_Actions takes nothing returns nothing
    local unit u
    local unit a
    local location p = GetRandomLocInRect(gg_rct_Light_Summon)
    local location t = GetRandomLocInRect(gg_rct_Light_Reinforcement_Spawn)
    local integer g = 10
       call KillUnit(GetTriggerUnit())
       loop
           exitwhen g == 0
           set u = CreateUnit( player(9), 'e00F', p, 0, 0)
           set a = CreateUnit( player(9), 'e00F', t, 0, 0)
           set g = g - 1
           set udg_Light_Unit = udg_Light_Unit + 2
           call TriggerSleepAction(1)
       endloop
    call RemoveLocation(t)
    call RemoveLocation(p)
    set u = null
    set a = null
endfunction

//===========================================================================
function InitTrig_Light_Invisible_Sins takes nothing returns nothing
    set gg_trg_Light_Invisible_Sins = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Light_Invisible_Sins, gg_rct_Light_No_Entry_Zone )
    call TriggerAddCondition( gg_trg_Light_Invisible_Sins, Condition( function Trig_Light_Invisible_Sins_Conditions ) )
    call TriggerAddAction( gg_trg_Light_Invisible_Sins, function Trig_Light_Invisible_Sins_Actions )
endfunction

Please help :(

EDIT: I notice now i could have used local unit arrays there, oops.
 
Level 10
Joined
Aug 19, 2008
Messages
491
To remove BJ's, I recommend you to download Jass NewGen Pack as it contains TESH which will make things easier (you'll know what I mean in a second).
When you've opened NewGen WE, it'll run like normal WE but with some modifications. Please do disable Reinventing the Craft and UMSWE because they'll most likely be in the way though.

Anyway open your map in NewGen WE and check out your code (in Trigger Editor, yes). Your code should be colored, bolded and stuff much like what you see here.
All functions you see that are colored red are most likely 'simple', 'swapped', made over-complicated or BJs, which are basically the same thing.
Here's a pic:
Pic1.png

As you can see, three of your lines are colored red (purple color indicates natives; the best you can have) except that you've spelled Player(9) with lower-case p (player(9)) in line 11 and 12. This will give you a syntax error.
I want you to scroll over the first code that is red GetRandomLocInRect(gg_rct_Light_Summon) while holding down ctrl. This will make the function go Underscored Blue like it was a link.
Click the link.
Now you should see this:
Pic2.png

As you may or may not see, this function just returns
Location(GetRandomReal(GetRectMinX(whichRect), GetRectMaxX(whichRect)), GetRandomReal(GetRectMinY(whichRect), GetRectMaxY(whichRect)))


Copy everything after 'return' and paste it over GetRandomLocInRect(gg_rct_Light_Summon) (which we want to replace)
Since your 'whichRect' is 'gg_rct_Light_Summon', I want you to replace all whichRect's with gg_rct_Light_Summon's.
Like so:
local location p = Location(GetRandomReal(GetRectMinX(gg_rct_Light_Summon), GetRectMaxX(gg_rct_Light_Summon)), GetRandomReal(GetRectMinY(gg_rct_Light_Summon), GetRectMaxY(gg_rct_Light_Summon)))

Now you've sucessfully replaced a BJ. Try to do the same with the other two lines as excercise, and please replace player(9) with Player(9).
Other than that just write if you have problems.

Cheers
 
Status
Not open for further replies.
Top