wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 04-28-2009, 01:04 PM   #1
wraithseeker
User
 
Join Date: Feb 2009
Posts: 406

wraithseeker is on a distinguished road (17)

Default Creatiing Units Failed

Collapse JASS:
library Initialization initializer Init

globals
    private constant integer DOLPHIN = 'h00C'
    private constant integer FISHSCHOOL = 'h00A'
    private constant integer SHARK = 'h00B'
    private real mx
    private real my
    private real bx
    private real by
endglobals

private function Actions takes nothing returns nothing
    local integer i = 0
    local unit u
    local real x
    local real y
    local boolean b
    loop
        exitwhen i > GetRandomInt(2,4)
        set x = GetRandomReal(mx,bx)
        set y = GetRandomReal(my,by)
        if not IsTerrainPathable(x,y,PATHING_TYPE_FLYABILITY) then
            set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),DOLPHIN,x,y,GetRandomReal(0,360))
        else
            loop
                exitwhen b == false
                set x = GetRandomReal(mx,bx)
                set y = GetRandomReal(my,by)
                set b = IsTerrainPathable(x,y,PATHING_TYPE_FLYABILITY)
            endloop
        if b == false then
            set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),DOLPHIN,x,y,GetRandomReal(0,360))
        endif
        endif
        call BJDebugMsg("UNIT IS CREATED")
        set i = i + 1
        endloop
        set u = null
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function Actions)
    set mx = GetRectMinX(gg_rct_Underwater)
    set my = GetRectMinY(gg_rct_Underwater)
    set bx = GetRectMaxX(gg_rct_Underwater)
    set by = GetRectMaxY(gg_rct_Underwater)
endfunction

endlibrary

What this is supposed to do is to start a loop and set x and y to a random point in a rect and checks if the point is boundary.

I am not very sure true or false is boundary but I know this detects boundary.

Collapse JASS:
  if IsTerrainPathable(x,y,PATHING_TYPE_FLYABILITY)

And when the point is boundary, it runs a loop that will exit when x and y becomes a point that is not boundary and then I do a check if b == false and create the unit. But right now, it is doing nothing at all.

Anybody have a slight clue of what is wrong?
wraithseeker is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 04-28-2009, 05:05 PM   #2
cosmicat
Probably AFK
 
cosmicat's Avatar
 
Join Date: Feb 2009
Posts: 635

cosmicat will become famous soon enough (71)cosmicat will become famous soon enough (71)cosmicat will become famous soon enough (71)

Default

IsTerrainPathable returns true if the terrain is pathable.

Your code seems to generate a random pair of coordinates within a pathable rect, and keep doing so until it gets a random pair of coordinates that are not pathable. You might want to take out the "not" in your first if statement and exitwhen b == true in your loop, since right now I think you have an infinite loop.
__________________
+++++++++++[>++++++>++++++++++>++++++++++<<<-]>+.>+.++++.+>-.----.------.--.<.
cosmicat is offline   Reply With Quote
Old 04-29-2009, 05:21 AM   #3
snowtiger
User
 
snowtiger's Avatar
 
Join Date: Oct 2007
Posts: 63

snowtiger has little to show at this moment (1)

Default

Quote:
Originally Posted by cosmicat
IsTerrainPathable returns true if the terrain is pathable.
Did you test that? As far as I remember, IsTerrainBuildable returned false if it was, and true if it wasn't.
snowtiger is offline   Reply With Quote
Old 04-29-2009, 05:43 AM   #4
wraithseeker
User
 
Join Date: Feb 2009
Posts: 406

wraithseeker is on a distinguished road (17)

Default

Here is the current code, don't know why my screen isn't filled with BJDebugMsgs since I did a loop of 60 times and it displayed about only 6 times.

Collapse JASS:
scope test initializer Init

globals
    private constant integer DOLPHIN = 'h00C'
    private constant integer FISHSCHOOL = 'h00A'
    private constant integer SHARK = 'h00B'
    private real mx
    private real my
    private real bx
    private real by
endglobals

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
 local integer i = 0
    local unit u
    local real x
    local real y
    local boolean b
    loop
        exitwhen i > 60
        set x = GetRandomReal(mx,bx)
        set y = GetRandomReal(my,by)
        if not IsTerrainPathable(x,y,PATHING_TYPE_FLYABILITY) then
            set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),DOLPHIN,x,y,GetRandomReal(0,360))
        else
            loop
                exitwhen b == false
                set x = GetRandomReal(mx,bx)
                set y = GetRandomReal(my,by)
                set b = IsTerrainPathable(x,y,PATHING_TYPE_FLYABILITY)
            endloop
        if b == false then
            set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),DOLPHIN,x,y,GetRandomReal(0,360))
            set b = true
        endif
    
        endif
        call BJDebugMsg("UNIT IS CREATED")
        set i = i + 1
        endloop
        call PanCameraToTimed(x,y,0)
endfunction

//===========================================================================
function Init takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterTimerEvent(t,2,false)
    call TriggerAddAction(t, function Trig_Untitled_Trigger_001_Actions )
     set mx = GetRectMinX(gg_rct_Underwater)
    set my = GetRectMinY(gg_rct_Underwater)
    set bx = GetRectMaxX(gg_rct_Underwater)
    set by = GetRectMaxY(gg_rct_Underwater)
endfunction

endscope
wraithseeker is offline   Reply With Quote
Old 04-29-2009, 06:04 AM   #5
snowtiger
User
 
snowtiger's Avatar
 
Join Date: Oct 2007
Posts: 63

snowtiger has little to show at this moment (1)

Default

Quote:
Originally Posted by wraithseeker
Here is the current code, don't know why my screen isn't filled with BJDebugMsgs since I did a loop of 60 times and it displayed about only 6 times.

Collapse JASS:
scope test initializer Init

globals
    private constant integer DOLPHIN = 'h00C'
    private constant integer FISHSCHOOL = 'h00A'
    private constant integer SHARK = 'h00B'
    private real mx
    private real my
    private real bx
    private real by
endglobals

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
 local integer i = 0
    local unit u
    local real x
    local real y
    local boolean b
    loop
        exitwhen i > 60
        set x = GetRandomReal(mx,bx)
        set y = GetRandomReal(my,by)
        if not IsTerrainPathable(x,y,PATHING_TYPE_FLYABILITY) then
            set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),DOLPHIN,x,y,GetRandomReal(0,360))
        else
            loop
                exitwhen b == false
                set x = GetRandomReal(mx,bx)
                set y = GetRandomReal(my,by)
                set b = IsTerrainPathable(x,y,PATHING_TYPE_FLYABILITY)
            endloop
        if b == false then
            set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),DOLPHIN,x,y,GetRandomReal(0,360))
            set b = true
        endif
    
        endif
        call BJDebugMsg("UNIT IS CREATED")
        set i = i + 1
        endloop
        call PanCameraToTimed(x,y,0)
endfunction
You didn't give b an initial value, so it stops when it has to evaluate that (the first time it loops trough).

EDIT: so the fix is:

local boolean b = true

Last edited by snowtiger : 04-29-2009 at 06:15 AM.
snowtiger is offline   Reply With Quote
Old 04-29-2009, 06:23 AM   #6
wraithseeker
User
 
Join Date: Feb 2009
Posts: 406

wraithseeker is on a distinguished road (17)

Default

Like this? I just wanted to double check.
Collapse JASS:
library Initialization initializer Init

globals
    private constant integer DOLPHIN = 'h00C'
    private constant integer FISHSCHOOL = 'h00A'
    private constant integer SHARK = 'h00B'
    private real mx
    private real my
    private real bx
    private real by
endglobals

private function Actions takes nothing returns nothing
    local integer i = 0
    local unit u
    local real x
    local real y
    local boolean b = true
    loop
        exitwhen i > 60
        set x = GetRandomReal(mx,bx)
        set y = GetRandomReal(my,by)
        if not IsTerrainPathable(x,y,PATHING_TYPE_FLYABILITY) then
            set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),DOLPHIN,x,y,GetRandomReal(0,360))
        else
            loop
                exitwhen b == false
                set x = GetRandomReal(mx,bx)
                set y = GetRandomReal(my,by)
                set b = IsTerrainPathable(x,y,PATHING_TYPE_FLYABILITY)
            endloop
        if b == false then
            set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),DOLPHIN,x,y,GetRandomReal(0,360))
        endif
        set b = true
        endif
        call BJDebugMsg("UNIT IS CREATED")
        set i = i + 1
        endloop
        call BJDebugMsg("started")
        call PanCameraToTimed(x,y,0)
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEventSingle(t,2)
    call TriggerAddAction(t, function Actions)
    set mx = GetRectMinX(gg_rct_Underwater)
    set my = GetRectMinY(gg_rct_Underwater)
    set bx = GetRectMaxX(gg_rct_Underwater)
    set by = GetRectMaxY(gg_rct_Underwater)
endfunction

endlibrary

Last edited by wraithseeker : 04-29-2009 at 06:23 AM.
wraithseeker is offline   Reply With Quote
Old 04-29-2009, 06:31 AM   #7
snowtiger
User
 
snowtiger's Avatar
 
Join Date: Oct 2007
Posts: 63

snowtiger has little to show at this moment (1)

Default

Yeah, because previously, warcraft looked if b was false, but b wasn't set yet, so it stopped executing that code, = no more units created.
snowtiger is offline   Reply With Quote
Old 04-29-2009, 06:36 AM   #8
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,520

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

Some of your code is redundant. You should do:
Collapse JASS:
library Initialization initializer Init

globals
    private constant integer DOLPHIN = 'h00C'
    private constant integer FISHSCHOOL = 'h00A'
    private constant integer SHARK = 'h00B'
    private real mx
    private real my
    private real bx
    private real by
endglobals

private function Actions takes nothing returns nothing
    local integer i = 0
    local unit u
    local real x
    local real y

    loop
        exitwhen i > 60
            loop
                set x = GetRandomReal(mx,bx)
                set y = GetRandomReal(my,by)
                exitwhen not IsTerrainPathable(x,y,PATHING_TYPE_FLYABILITY)
            endloop
        set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),DOLPHIN,x,y,GetRandomReal(0,360))
        call BJDebugMsg("UNIT IS CREATED")
        set i = i + 1
    endloop
 
    call BJDebugMsg("started")
    call PanCameraToTimed(x,y,0)
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEventSingle(t,2)
    call TriggerAddAction(t, function Actions)
    set mx = GetRectMinX(gg_rct_Underwater)
    set my = GetRectMinY(gg_rct_Underwater)
    set bx = GetRectMaxX(gg_rct_Underwater)
    set by = GetRectMaxY(gg_rct_Underwater)
endfunction

endlibrary
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request Thread Done for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.

Last edited by Pyrogasm : 04-29-2009 at 06:37 AM.
Pyrogasm is offline   Reply With Quote
Old 04-29-2009, 06:51 PM   #9
cosmicat
Probably AFK
 
cosmicat's Avatar
 
Join Date: Feb 2009
Posts: 635

cosmicat will become famous soon enough (71)cosmicat will become famous soon enough (71)cosmicat will become famous soon enough (71)

Default

Quote:
Originally Posted by snowtiger
Did you test that? As far as I remember, IsTerrainBuildable returned false if it was, and true if it wasn't.
Nope, sorry. I just expected the function name to make some kind of sense. You're right - Blizzard is retarded.
__________________
+++++++++++[>++++++>++++++++++>++++++++++<<<-]>+.>+.++++.+>-.----.------.--.<.
cosmicat is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 07:17 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2018, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services