• 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] Teleport With Memory

Status
Not open for further replies.
Level 2
Joined
Sep 27, 2010
Messages
18
Not sure if this is where I need to post... I don't need help making the trigger, I've already finished it, and it works the way I want it to, I'm just not sure how efficient it is. I've checked it using the LeakCheck resource, but since this is my first JASS trigger I wanted to be certain.

Basically, multiple teleports go to the same room. That room has one exit, and it will always return the unit to its original starting point. Since I have no idea how to use the tables, I used a loop function and had each entrance be a separate trigger. Example below:

JASS:
function Trig_Portal_Store_11_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Portal_Store_11_Actions takes nothing returns nothing
    local unit LOTRTELEPORT
    set LOTRTELEPORT = GetTriggerUnit()
    call SetUnitPositionLoc( LOTRTELEPORT, GetRectCenter(gg_rct_Room10) )
    call PanCameraToTimedLocForPlayer( GetOwningPlayer(LOTRTELEPORT), GetUnitLoc(LOTRTELEPORT), 0.60 )
    call AttachSoundToUnitBJ(udg_Shop, LOTRTELEPORT)
    call SetSoundVolumeBJ(udg_Shop, 100)
    call PlaySoundBJ(udg_Shop)
    loop
        exitwhen ( RectContainsUnit(gg_rct_Out10, LOTRTELEPORT) == true )
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.25))
    endloop
    call SetUnitPositionLoc( LOTRTELEPORT, GetRectCenter(gg_rct_Out11) )
    call PanCameraToTimedLocForPlayer( GetOwningPlayer(LOTRTELEPORT), GetUnitLoc(LOTRTELEPORT), 0.60 )
endfunction

//===========================================================================
function InitTrig_Portal_Store_11 takes nothing returns nothing
    set gg_trg_Portal_Store_11 = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Portal_Store_11, gg_rct_In11 )
    call TriggerAddCondition( gg_trg_Portal_Store_11, Condition( function Trig_Portal_Store_11_Conditions ) )
    call TriggerAddAction( gg_trg_Portal_Store_11, function Trig_Portal_Store_11_Actions )
endfunction

I've tested, and it works with as many different "in" portals as I want to use, so that's not an issue.

Again this is my first JASS trigger, so I'm just looking for constructive criticism.

Thanks all,
Zypo88

P.S.
Here's an example map if what I said was confusing at all.
 

Attachments

  • JASS Multi-Teleport.w3m
    21.3 KB · Views: 90
its not efficient:

First: because of the BJ's (the codes in red). Use the natives instead (If you have JNGP, open the functions list and then search for the BJ that you use, click it to see the natives that it calls)...

Second: it uses a trigger sleep action

third: uses locs, use x,y instead...

fourth: it leaks all of the locations

fifth: merge the local part and the set part... local unit blah = GetTriggerUnit()

sixth: the condition is bad, replace the lines on the condition with this instead
return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true
 
Level 2
Joined
Sep 27, 2010
Messages
18
Awesome, thanks!

1. I think I see what you mean, I have JassCraft and it does list the natives. So I just need to replace the BJ's with the separate lines from their natives.

2. Is there a better way of having it wait, or is it just bad to do that period?

3. Will do, regions were just temp anyway because they're easier to drag around to where you want them.

4. So should I use local variables (the way I understand it, those get destroyed when the "spell" is finished... but I may have misunderstood), or do I just set the variables at the beginning and destroy them when it finishes? Also, is there anyway to keep the triggering location from leaking, since it does have to be always on?

5. Done.

6. Done. I originally copied this from the GUI condition, because I wasn't really sure how to set it up on my own.

Thanks again for the critique. + rep.
 
Status
Not open for further replies.
Top