• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[JASS] Global Rect Declaration Help

Status
Not open for further replies.
Level 4
Joined
Sep 24, 2004
Messages
49
JASS:
scope pZONE initializer init
globals
    private constant rect PORTALA   =   gg_rct_ENTRY_ZONE
    private constant rect PORTALB   =   gg_rct_EXIT_ZONE
endglobals

private function Conditions takes nothing returns boolean  
    return true
    //return GetPlayerController(GetOwningPlayer(GetEnteringUnit())) == MAP_CONTROL_USER 
endfunction

private function ActionsA takes nothing returns nothing
    local location l = Location(GetRectCenterX(PORTALB), GetRectCenterY(PORTALB))
    call SetUnitPositionLoc(GetEnteringUnit(), l)
    call RemoveLocation(l)
endfunction

private function ActionsB takes nothing returns nothing
    local location l = Location(GetRectCenterX(PORTALA), GetRectCenterY(PORTALA))
    call SetUnitPositionLoc(GetEnteringUnit(), l)
    call RemoveLocation(l)
endfunction

//===========================================================================
private function init takes nothing returns nothing
    local trigger tA = CreateTrigger(  )
    local trigger tB = CreateTrigger(  )
    local region rectRegionA = CreateRegion()
    local region rectRegionB = CreateRegion()
    call RegionAddRect(rectRegionA, PORTALA)
    call TriggerRegisterEnterRegion(tA, rectRegionA, null)
    call TriggerAddCondition( tA, Condition( function Conditions ) )
    call TriggerAddAction( tA, function ActionsA)
    //call RemoveRegion(rectRegionA)
    
    call RegionAddRect(rectRegionB, PORTALB)
    call TriggerRegisterEnterRegion(tB, rectRegionB, null)
    call TriggerAddCondition( tB, Condition( function Conditions ) )
    call TriggerAddAction( tB, function ActionsB)
    //call RemoveRegion(rectRegionB)
    
    set tA = null
    set tB = null
endfunction
endscope
When running the trigger: A unit enters the region - nothing happens. Is it not possible to declare constant rects in this way, or is it something else?
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
It's not possible to do it like that, but you can simply do this:

JASS:
globals
    private rect PORTALA
    private rect PORTALB
endglobals

// ...

private function init takes nothing returns nothing
    // ...
    set PORTALA = gg_rct_ENTRY_ZONE
    set PORTALB = gg_rct_EXIT_ZONE
    // ...
endfunction

Custom globals are initialized before those gg_ ones. Also, you have to remove "constant", because otherwise it will stay uninitialized.
 
Level 4
Joined
Sep 24, 2004
Messages
49
Maybe you got infinite loops because of those SetUnitPositionLoc functions. You can perhaps try SetUnitX/SetUnitY? Because otherwise I think the trigger is being fired over and over again.
Naw - I fixed it, but thanks.
Scope contains a group.
JASS:
if not(IsUnitInGroup(GetEnteringUnit(), UNITSWARPING)) then
        call SetUnitPositionLoc(GetEnteringUnit(), l)
        call GroupAddUnit(UNITSWARPING, GetEnteringUnit())
    else
        call GroupRemoveUnit(UNITSWARPING, GetEnteringUnit())
    endif
 
Status
Not open for further replies.
Top