1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  4. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  5. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] A Couple Problems :(

Discussion in 'Triggers & Scripts' started by CrueIIntentions, Nov 12, 2009.

  1. CrueIIntentions

    CrueIIntentions

    Joined:
    Jun 7, 2008
    Messages:
    440
    Resources:
    0
    Resources:
    0
    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:
    Code (vJASS):

    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.
     
  2. Cheezeman

    Cheezeman

    Joined:
    Aug 19, 2008
    Messages:
    437
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    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