The official site of Clan TMMM
 
HomeHomeSearchUsergroupsFAQRegisterLog in


Latest topics
» Gotta click fast - WC3 Mazing #mildlyinteresting
by hoffmann Wed Jun 21, 2017 10:28 pm

» Hey whats up
by Eat_bacon_daily Mon Oct 10, 2016 6:24 am

» I'm getting married and you guys are invited
by Achilles.42 Wed Sep 07, 2016 11:00 am

» Server Photo Album 1
by Pat1487 Sat Aug 06, 2016 5:28 pm

» Legacy of The Void Beta
by Achilles.42 Sun Oct 18, 2015 3:21 am

» Hey guys!!!
by Eat_bacon_daily Fri Oct 16, 2015 11:20 pm

» What everyone been up to
by The_Chosen_Oreo Sun Jun 14, 2015 11:55 am

SC2 Links
SC2 Challenge/Tourney Info

Official SC2 Forums

SC2 Curse

SC2Mapster

Team Liquid

SC2 Replayed

SC2 Strategy
WC3 Links
Clan_TMMM[Host] Info

WC3 Challenge/Tourny Rules

Epicwar
Poll
What game does everyone play now?
Starcraft 2
26%
 26% [ 8 ]
Warcraft 3
35%
 35% [ 11 ]
League of Legends
19%
 19% [ 6 ]
World of Warcraft
0%
 0% [ 0 ]
Diablo 2
0%
 0% [ 0 ]
No games at all
10%
 10% [ 3 ]
Other game not listed
10%
 10% [ 3 ]
Total Votes : 31
Transparency

Share | 
 

 Region Question

Go down 
AuthorMessage
Serenity09
Moderator
Moderator
avatar


PostSubject: Region Question   Fri Aug 12, 2011 5:55 pm

alright so i'm trying to make an easier/faster way to do waypoint movement for creatures

ie. creature enters rect 1, ordered to move to rect 2 and then on entering rect 2 ordered to move to rect 3 etc

but in JASS it looks like:

Code:
function Move1 takes nothing returns nothing
   call NextMove(gg_rct_Rect_019)
endfunction

function InitMove takes nothing returns nothing
   local trigger t = CreateTrigger()
   local region r = CreateRegion()

   call RegionAddRect(r, gg_rct_Rect_XXX)

   call TriggerRegisterEnterRegion(t, r, OwnedByGreen
       call TriggerAddAction(t, function Move1)

   set t = null
   set r = null
endfunction

which is awful considering it needs to be done for each one

so i tried doing this

Code:
library WaypointMove

struct WaypointMove
    private region Waypoint = CreateRegion()
    private rect Nextpoint
    private trigger EntryEvent = CreateTrigger()
   
    static method WaypointNextMove takes nothing returns nothing
        call IssuePointOrder(GetTriggerUnit(), "move", GetRectCenterX(Nextpoint), GetRectCenterY(Nextpoint))
    endmethod
   
    method onDestroy takes nothing returns nothing
        set Waypoint = null
        set Nextpoint = null
        set EntryEvent = null
    endmethod

    static method create takes rect r1, rect r2 returns WaypointMove
        local WaypointMove new = WaypointMove.allocate()
       
        call RegionAddRect(new.Waypoint, r1)
        set new.Nextpoint = r2
       
        call TriggerRegisterEnterRegion(new.EntryEvent, new.Waypoint, OwnedByGreen)
        call TriggerAddAction(new.EntryEvent, function WaypointNextMove)
       
        return new
    endmethod
endstruct

endlibrary

OwnedByGreen is a filter func which does what it should
the problem with this is that it doesn't recognize WaypointNextMove as a valid function when I try to add it to the trigger
I'm pretty sure I've run into this exact problem before xD
but if you have an idea of how to fix it'd make my life a lot easier
.create(rect1, rect2) and doneeeeeeeeeeeeeeee

i tried it without the struct first, but you run into the problem of having to pass rects into WaypointNextMove

ive already tried the obvious stuff
like
function WaypointMove.WaypointNextMove



i have one more question, but it took way too long to type this one up, so i'll ask it later
Back to top Go down
Pat1487
Moderator
Moderator
avatar


PostSubject: Re: Region Question   Sun Aug 14, 2011 8:32 pm

What is the exact error
And is that the only one

I think it has to do with TriggerAddAction looking for a function where as you gave it a method
VJass converts methods into functions, but names them something else (i think) so when TriggerAddAction gets to it, its name as a function is no longer what you named it as a method
Back to top Go down
Serenity09
Moderator
Moderator
avatar


PostSubject: Re: Region Question   Sun Aug 14, 2011 9:16 pm

Code:
library WaypointMove requires FilterFuncs

struct WaypointMove
    private region Waypoint = CreateRegion()
    private rect Nextpoint
    private trigger EntryEvent = CreateTrigger()
   
    private method WaypointNextMove takes nothing returns nothing
        call IssuePointOrder(GetTriggerUnit(), "move", GetRectCenterX(Nextpoint), GetRectCenterY(Nextpoint))
    endmethod
   
    method onDestroy takes nothing returns nothing
        set Waypoint = null
        set Nextpoint = null
        set EntryEvent = null
    endmethod

    static method create takes rect r1, rect r2 returns WaypointMove
        local WaypointMove new = WaypointMove.allocate()
       
        call RegionAddRect(new.Waypoint, r1)
        set new.Nextpoint = r2
       
        call TriggerRegisterEnterRegion(new.EntryEvent, new.Waypoint, GreenOrBrown)
        call TriggerAddAction(new.EntryEvent, function WaypointMove.WaypointNextMove)
       
        return new
    endmethod
endstruct

endlibrary

here's its current form
idk what i messed up the last time when i tried this out, but it turns out its the exact same problem that I had the first time I tried with the wisp wheel (but I can't fix it the same way)

the error (on the trigger add action line):
"WaypointNextMove is not an static method of WaypointMove that takes nothing"

and I can't make it static because then I lose the ability to reference individual structs (which is the entire point of the damn thing)
Back to top Go down
Sponsored content




PostSubject: Re: Region Question   

Back to top Go down
 
Region Question
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Clan TMMM :: Warcraft 3 :: WC3 Tutorials and Help-
Jump to: