• 🏆 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!

I'm having problems Moving Regions

Status
Not open for further replies.
Level 3
Joined
Jul 3, 2011
Messages
13
My goal is to create a set of triggers where after the player orders the Hero to move from point A to point B, the Hero will automatically stop using "Hold Position".

After much troubleshooting, I narrowed the problem down to action itself....Moving the Region. I can't seem to move the damn region at all. I tried creating a variable and tying it to the region. I tried creating the region with triggers, but when I attempted to create a "When Unit Enters This Region" trigger, the Variable doesn't exist on the list.


I have a feeling there's something fundamentally wrong with regions when it comes to moving them. Is there an easier way?

Please help!:ogre_frown:
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Yes there is something wrong, its called GUI is retarded and lies to you.

So called "Regions" in GUI are actually "rect"s. The event however uses a "region" type. Thus the event secretly converts a rect into a region for you. I am not sure if moving a rect will actually change the region it is bound to, and it not doing so would explain the problems you have.

The only real solution is to learn JASS to understand how the JASS interpreter actually works in WC3 and then design code to support the functionality you want.
 

Deleted member 177737

D

Deleted member 177737

Maby there is a way to set the newly created region as a variable and then use that variable as the reference?

(I've honestly never tried doing what your doing, but this is how I would do it...if it is possible)
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
This is solvable but annoying. It requires a healthy amount of custom script, in fact using JassHelper to compile would be preferred because then you can use "region" global variables instead of "rect" globals.

If you have a region named "MyInGameRegion", you can do this:

JASS:
scope bullocks initializer Init

globals
    private region myRegion
endglobals

private function OnEnter takes nothing returns boolean
    // A unit has entered "MyInGameRegion"
    return false
endfunction

private function Init takes nothing returns nothing
    set myRegion = CreateRegion()
    call RegionAddRect(myRegion, gg_rct_MyInGameRegion)
    call TriggerRegisterEnterRegion(CreateTrigger(), myRegion, Filter(function OnEnter))
endfunction

//This next function works the magic.
function MoveMyInGameRegion takes real x, real y returns nothing
    call RegionClearRect(myRegion, gg_rct_MyInGameRegion)
    call MoveRectTo(gg_rct_MyInGameRegion, x, y)
    call RegionAddRect(myRegion, gg_rct_MyInGameRegion)
endfunction

endscope

Edit: Honestly it is probably better to just use a periodic trigger and check when the unit is in range.
 
Last edited:
Status
Not open for further replies.
Top