HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Need Help in this simple teleportin trigger

10-11-2006, 03:34 PM#1
zen87
Collapse JASS:
function teleport takes player p, unit u, region e  returns nothing
    call SetUnitPositionLocFacingBJ( u, gg_rct_Absurtus_House_B, bj_UNIT_FACING )
    call SetCameraBoundsToRectForPlayerBJ( p, e )
    call PanCameraToTimedLocForPlayer( p, gg_rct_Absurtus_House_B, 0 )
endfunction

function EnteringLocation takes nothing returns nothing
 local unit u = GetEnteringUnit()
 local player p = GetOwningPlayer(u)
    if (IsUnitInRegion (region gg_rct_Absurtus_House_A, u) == true ) then
        call teleport(p, u, gg_rct_Absurtus_House)
    elseif (IsUnitInRegion (region gg_rct_Absurtus_House_B, u) == true ) then
        call teleport(p, u, gg_rct_City_of_Absurtus)
    endif
 set u = null
 set p = null
endfunction
//===========================================================================
function InitTrig_town_teleports takes nothing returns nothing
 local trigger t = CreateTrigger()
    call TriggerRegisterEnterRectSimple( t, gg_rct_Absurtus_House_A )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Absurtus_House_B )
    call TriggerAddAction( t, function EnteringLocation )
 set t = null
endfunction

uhm this trigger is easy, when a unit enters AbsurtusHouseA then the trigger will bring him to AbsurtusHouseB and set camera bound at certain locartion, uhm wheres my mistake ? the thing dun seems to be correct sorry im still new to JASS so theres long way to learn
10-11-2006, 04:59 PM#2
Vexorian
Collapse JASS:
function EnteringLocation takes nothing returns nothing
 local unit u = GetEnteringUnit()
 local player p = GetOwningPlayer(u)
    if (IsUnitInRegion (region gg_rct_Absurtus_House_A, u) == true ) then
        call teleport(p, u, gg_rct_Absurtus_House)
    elseif (IsUnitInRegion (region gg_rct_Absurtus_House_B, u) == true ) then
        call teleport(p, u, gg_rct_City_of_Absurtus)
    endif
 set u = null
 set p = null
endfunction

that's not a way to make it work.

Welcome to hell caused by a blizzard naming problem - Those things World editor calls regions are called rects by JASS and jass has other things called regions which are like a group of points.

---

what you want to do is something like RectContainsCoords(gg_rct_Absurtus_House_A, GetUnitX(u),GetUnitY(u))
10-11-2006, 06:26 PM#3
aidan_124
I'm new to JASS (in case you hadn't guess). I'm trying to get a unit to be teleported to a region as shown (hopefully):
Collapse JASS:
function Ethereal_Usher_Conditions takes nothing returns boolean
if GetSpellAbilityId() == 'A012' then
return true
endif
return false
endfunction

function Ethereal_Usher_Actions takes nothing returns nothing
local integer i = 1
local player array Team_1
local player array Team_2
local rect gg_rct_Team1LeftHome
local rect gg_rct_Team2RightHome

call TriggerSleepAction( 0.5 )
loop
exitwhen i > 5
if  IsUnitOwnedByPlayer(GetSummoningUnit(),Team_1[i]) == true then
call SetUnitPositionLoc(GetSummonedUnit(), GetRectCenter(gg_rct_Team2RightHome) )
endif
if IsUnitOwnedByPlayer(GetSummoningUnit(),Team_2[i]) == true then
call SetUnitPositionLoc(GetSummonedUnit(), GetRectCenter(gg_rct_Team1LeftHome) )
endif
set i = i + 1
endloop
endfunction

function InitTrig_Ethereal_Usher takes nothing returns nothing
local trigger gg_trg_Ethereal_Usher
set gg_trg_Ethereal_Usher = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Ethereal_Usher,EVENT_PLAYER_UNIT_SUMMON)
call TriggerAddCondition(gg_trg_Ethereal_Usher,Condition(function Ethereal_Usher_Conditions))
call TriggerAddAction(gg_trg_Ethereal_Usher,function Ethereal_Usher_Actions)
endfunction

Variables Team_1 and Team_2 are set in a trigger on map initializtion, so they should be ok. Am i doing something obviously wrong with this moving (instant) to region or what am i doing wrong?
The unit changes team immediately after casting
Thanks
10-12-2006, 01:12 PM#4
Vexorian
what's goes wrong there? Also, next time make a new thread instead of a reply. The only thing I can notice right now are the memory leaks, you are not cleaning the points returned by GetRectCenter
10-12-2006, 02:20 PM#5
zen87
yeah vex, thx alot, i found the problem and it works now

btw aidan, next time don't leech other's topic, make ya own one, other might not see your post
10-14-2006, 01:22 PM#6
zen87
Uhm needed some help again >.< i modify the trigger so it teleport all the unit owned by player to the location instaed just the entering unit, now the problem is i don't know where is the problem and it shows error during saving!!

Collapse JASS:
function Conditions takes nothing returns boolean
    return IsUnitType(GetEnteringUnit(), UNIT_TYPE_HERO)
endfunction

function Filter takes nothing returns boolean
    return GetWidgetLife(GetFilterUnit()) > 0.405
endfunction

function Teleport takes player p, group g, rect r, real ux, real uy, string e returns nothing
 local unit f
    call SetCameraBoundsToRectForPlayerBJ( p, r )
    call PanCameraToTimedLocForPlayer( p, Location(ux, uy), 0 )
    call ClearTextMessages()
    call DisplayTimedTextToPlayer( p, 0.52, -1.00, 2.00, "|cffc1c1ff"+e+"|r" )
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl", ux, uy))
    loop
        set f = FirstOfGroup(g)
        exitwhen f == null
        call SetUnitPosition(f, ux, uy)
        call GroupRemoveUnit(g, f)
    endloop
 set f = null
 set p = null
 call DestroyGroup(g)
 set g = null
 set r = null
 set e = null
endfunction

function EnteringLocation takes nothing returns nothing
 local unit u = GetEnteringUnit()
 local unit c
 local group g = CreateGroup()
 local player p = GetOwningPlayer(u)
 local boolexpr b = Condition(function Filter)
 local real ux
 local real uy
 local rect r
 local string e
 call GroupEnumUnitsOfPlayer(g,p,b)
    if (RectContainsCoords(gg_rct_Absurtus_House_ent, GetUnitX(u),GetUnitY(u)) == true ) then
        set c = gg_unit_ncop_0162
        set ux = GetUnitX(c)
        set uy = GetUnitY(c)-250
        set r = gg_rct_Absurtus_House
        set e = "Entering Absurtus merchant shop"
    elseif (RectContainsCoords(gg_rct_Absurtus_House_exit, GetUnitX(u),GetUnitY(u)) == true ) then
        set c = gg_unit_ncp2_0161
        set ux = GetUnitX(c)
        set uy = GetUnitY(c)-250
        set r = gg_rct_City_of_Absurtus
        set e = "Entering City of Absurtus"
    endif
    call Teleport(p, g, r, ux, uy, e)
 set u = null
 set c = null
 call DestroyGroup(g)
 set g = null
 set p = null
 call DestroyBoolExpr(b)
 set b = null
 set r = null
 set e = null
endfunction
//===========================================================================
function InitTrig_town_teleports takes nothing returns nothing
 local trigger t = CreateTrigger()
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Absurtus_House_ent )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Absurtus_House_exit )
    call TriggerAddAction( t, function EnteringLocation )
 set t = null
endfunction
10-14-2006, 02:56 PM#7
Fireeye
Why did you use a group?!
I would simply use a takes unit u and move that unit if it is == Hero or whatever.
Also you did
Collapse JASS:
call GroupEnumUnitsOfPlayer(g,p,b)
and b is
Collapse JASS:
function Filter takes nothing returns boolean
    return GetWidgetLife(GetFilterUnit()) > 0.405
endfunction
As i see it, you pick every unit owned by the Owner of the entering unit with more than 0.405 hp.
10-14-2006, 03:17 PM#8
zen87
well i do as a group because i wanted to move all the units (eg, summoned unit) that alive (>0.405hp) together with the hero when the hero enter the location, also i will use this trigger for another waypoint system, so basically summoned unit cant buy item right, so i'll need to move all the controller's unit to that ceritan location upon teleporting
10-14-2006, 05:50 PM#9
The_AwaKening
Your problem is here I am thinking

call Teleport(p, r, g, ux, uy, e)

but you are checking for the group first in your function

function Teleport takes player p, group g, rect r, real ux, real uy, string e returns nothing

Just change it to

call Teleport(p, g, r, ux, uy, e)
10-14-2006, 06:02 PM#10
zen87
O_o ok fixed that... but... still canot >.< !! still got error !!

btw : i cut down quite a number of line from above... maybe the mistake was in other place ? well my whole teleport system is kinda long... here it goes...

Collapse JASS:
function Conditions takes nothing returns boolean
    return IsUnitType(GetEnteringUnit(), UNIT_TYPE_HERO)
endfunction

function Filter takes nothing returns boolean
    return GetWidgetLife(GetFilterUnit()) > 0.405
endfunction

function Teleport takes player p, group g, rect r, real ux, real uy, string e returns nothing
 local unit f
    call SetCameraBoundsToRectForPlayerBJ( p, r )
    call PanCameraToTimedLocForPlayer( p, Location(ux, uy), 0 )
    call ClearTextMessages()
    call DisplayTimedTextToPlayer( p, 0.52, -1.00, 2.00, "|cffc1c1ff"+e+"|r" )
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl", ux, uy))
    loop
        set f = FirstOfGroup(g)
        exitwhen f == null
        call SetUnitPosition(f, ux, uy)
        call GroupRemoveUnit(g, f)
    endloop
 set f = null
 set p = null
 call DestroyGroup(g)
 set g = null
 set r = null
 set e = null
endfunction

function Waypoints takes nothing returns nothing
 local unit u = GetManipulatingUnit()
 local unit c
 local group g = CreateGroup()
 local player p = GetOwningPlayer(u)
 local item it = GetManipulatedItem()
 local boolexpr b = Condition(function Filter)
 local real ux
 local real uy
 local rect r
 local string e
 call GroupEnumUnitsOfPlayer(g,p,b)
    if ( GetItemTypeId(it) == 'rdis' ) then
        set c = udg_WaypointPortal[0]
        set ux = GetUnitX(c)
        set uy = GetUnitY(c)-200
        set r = gg_rct_City_of_Absurtus
        set e = "Entering City of Absurtus"
    endif
    call Teleport(p, g, r, ux, uy, e)
 set u = null
 set c = null
 call DestroyGroup(g)
 set g = null
 set p = null
 set it = null
 call DestroyBoolExpr(b)
 set b = null
 set r = null
 set e = null
endfunction

function EnteringLocation takes nothing returns nothing
 local unit u = GetEnteringUnit()
 local unit c
 local group g = CreateGroup()
 local player p = GetOwningPlayer(u)
 local boolexpr b = Condition(function Filter)
 local real ux
 local real uy
 local rect r
 local string e
 call GroupEnumUnitsOfPlayer(g,p,b)
    if (RectContainsCoords(gg_rct_Absurtus_House_ent, GetUnitX(u),GetUnitY(u)) == true ) then
        set c = gg_unit_ncop_0162
        set ux = GetUnitX(c)
        set uy = GetUnitY(c)-250
        set r = gg_rct_Absurtus_House
        set e = "Entering Absurtus merchant shop"
    elseif (RectContainsCoords(gg_rct_Absurtus_House_exit, GetUnitX(u),GetUnitY(u)) == true ) then
        set c = gg_unit_ncp2_0161
        set ux = GetUnitX(c)
        set uy = GetUnitY(c)-250
        set r = gg_rct_City_of_Absurtus
        set e = "Entering City of Absurtus"
    elseif (RectContainsCoords(gg_rct_Hydro_Garden_ent, GetUnitX(u),GetUnitY(u)) == true ) then
        if (udg_GameSwitch[1] == true) then
            set c = gg_unit_ncp2_0161
            set ux = GetUnitX(c)
            set uy = GetUnitY(c)-250
            set r = gg_rct_City_of_Absurtus
            set e = "Entering The Garden of Hydromancer"
        else
            set c = gg_unit_ncp2_0159
            set ux = GetUnitX(c)-400
            set uy = GetUnitY(c)+100
            set r = gg_rct_City_of_Absurtus
            set e = "Some strange force pushed you away from the garden"
        endif
    endif
    call Teleport(p, g, r, ux, uy, e)
 set u = null
 set c = null
 call DestroyGroup(g)
 set g = null
 set p = null
 call DestroyBoolExpr(b)
 set b = null
 set r = null
 set e = null
endfunction
//===========================================================================
function InitTrig_Teleporting_System takes nothing returns nothing
 local trigger m = CreateTrigger()
 local trigger t = CreateTrigger()

    call TriggerRegisterAnyUnitEventBJ( m, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction( m, function Waypoints )

    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Absurtus_House_ent )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Absurtus_House_exit )
    call TriggerRegisterEnterRectSimple( t, gg_rct_Hydro_Garden_ent )
    call TriggerAddAction( t, function EnteringLocation )

 set m = null
 set t = null
endfunction
10-14-2006, 06:18 PM#11
The_AwaKening
Give me a clue at least. What line is it showing the error on and what is it saying the error is.

Also, you don't need to nullify the variables in the passed function. Just null them in the same function you created them in. Only f needs to be nulled in the Teleport function. You are also destroying group g in 2 places. Remove that line in the Teleport function as well.

Edit--
I don't know if WE sees it, but that group problem may be your error as well. You are destroying g in your Teleport function and then nullifying it. So this means in your original function "EnteringLocation" you are trying to Destroy a nullified group.
10-14-2006, 06:58 PM#12
zen87
the error starts from this line : im not sure, maybe the there is something wrong with my function name or something ?

ah, for the group problem, im quite sure the WE wont see it, but it will still let me save it but it just wont work in the game it thats the problem, but now it is showing error during the save =|
Collapse JASS:
//from here, and bla bla bla-------------
function Filter takes nothing returns boolean
    return GetWidgetLife(GetFilterUnit()) > 0.405
endfunction

function Teleport takes player p, group g, rect r, real ux, real uy, string e returns nothing
 local unit f
    call SetCameraBoundsToRectForPlayerBJ( p, r )
    call PanCameraToTimedLocForPlayer( p, Location(ux, uy), 0 )
    call ClearTextMessages()
...
10-14-2006, 09:36 PM#13
The_AwaKening
Ya, try renaming Filter to something else. Try TeleportBool or something like that. If that's not it, tell me what the error says. It would help a lot.

Edit --
It is definitely the Filter function. You need to rename it.
10-15-2006, 01:59 AM#14
zen87
Quote:
Originally Posted by The_AwaKening
Ya, try renaming Filter to something else. Try TeleportBool or something like that. If that's not it, tell me what the error says. It would help a lot.

Edit --
It is definitely the Filter function. You need to rename it.
my god !! it is really because of the filter fucntion !! oh wait... i think i got a Filter function in my other trigger as well... guess thats why the error appear...

anyway thanks alot !! rep for ya