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 09-05-2009, 07:01 PM   #1
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default Trackable limit problem?

Hi guys, having in mind my project died (thx Blizz ...) I am now starting something a lot smaller, just to have small fun, I call it SpaceShipFighters but I think I may need a new name xD

I am using trackables, and I want to cover an entire map with them, just like Kattana's did here:
http://www.wc3jass.com/viewtopic.php?t=1997

However my the trackables represent by peasants don't reach half of the map .... and now they simply don't get activated .... and I don't understand why ... is there a limit to the number of trackables one can have, or am I doing something wrong?

Trackable, you only need to know the create method...
Collapse JASS:
//===========================================================================
//This simple library defines a trackable. It needs a special imported model
//and units to make sense.
//===========================================================================
library Trackable 
    struct Trackable
        real tcX
        real tcY
        real tcFacing
        string tcPath
        trackable track
        player tcOwner
        
        static method create takes real x, real y, real facing, string path, player owner returns Trackable
            local Trackable this = Trackable.allocate()
            
            if GetLocalPlayer() != owner then
                set .tcPath = ""
            else 
                set .tcPath = path 
            endif
            
            set .tcX = x
            set .tcY = y
            set .tcFacing = facing
            set .tcOwner = owner
            set .track = CreateTrackable(.tcPath, .tcX, .tcY, .tcFacing)
            
            return this
        endmethod
    
        //getters
        method operator x takes nothing returns real
            return .tcX
        endmethod
        
        method operator y takes nothing returns real
            return .tcY
        endmethod
        
        method operator facing takes nothing returns real
            return .tcFacing
        endmethod
    
        method operator path takes nothing returns string
            return .tcPath
        endmethod
        
        method operator tracker takes nothing returns trackable
            return .track
        endmethod
        
        method operator owner takes nothing returns player
            return .tcOwner
        endmethod
        
        //setters
        method operator x= takes real newX returns nothing
            set .tcX = newX
        endmethod
        
        method operator y= takes real newY returns nothing
            set .tcY = newY
        endmethod
        
        method operator facing= takes real newFacing returns nothing
            set .tcFacing = newFacing
        endmethod
        
        method operator path= takes string newPath returns nothing
            set .tcPath = newPath
        endmethod
        
        method operator owner= takes player newPlayer returns nothing
            set .tcOwner = newPlayer
        endmethod
    endstruct
endlibrary

code...
Collapse JASS:
    globals 
        boolean array PlayersOnline
        constant integer MAX_PLAYERS = 4
        private constant string TRACK_PATH = "units\\human\\Peasant\\Peasant.mdl"
        private constant real TRACK_SIZE = 80.
    endglobals
//===========================================================================
    private function TrackableHit takes nothing returns nothing
        call BJDebugMsg("cliked!")
    endfunction
//===========================================================================
    private function TrackableTrack takes nothing returns nothing
        call BJDebugMsg("over!")
    endfunction
//===========================================================================
private function CreateTrackables takes nothing returns nothing
        local real maxX = GetRectMaxX(bj_mapInitialPlayableArea)
        local real maxY = GetRectMaxY(bj_mapInitialPlayableArea)
        local real minX = GetRectMinX(bj_mapInitialPlayableArea)
        local real minY = GetRectMinX(bj_mapInitialPlayableArea)
        local real currentX = minX + TRACK_SIZE
        local real currentY = minY + TRACK_SIZE
        local trigger onHit = CreateTrigger()
        local trigger onTrack = CreateTrigger()
        local integer i = 0
        local Trackable tracker
        
        call CreateUnit(Player(0), 'hfoo', minX, minY, 0)
        call CreateUnit(Player(0), 'hfoo', maxX, maxY, 0)
        
        //see who is playing
        loop
            exitwhen i == MAX_PLAYERS
            
            if GetPlayerController(Player(i)) == MAP_CONTROL_USER then
                set PlayersOnline[i] = true
                
                //create the trackables
                loop
                    exitwhen currentY > maxY - TRACK_SIZE
                    call BJDebugMsg("y= " + R2S(currentY))
                    
                    set currentX = minX + TRACK_SIZE
                    loop
                        exitwhen currentX > maxX - TRACK_SIZE

                        set tracker = Trackable.create(currentX, currentY, 0., TRACK_PATH, Player(i))
                        call TriggerRegisterTrackableTrackEvent(onTrack, tracker.track)
                        call TriggerRegisterTrackableHitEvent(onHit, tracker.track)
                        
                        set currentX = currentX + TRACK_SIZE*2
                    endloop
                    
                    set currentY = currentY + TRACK_SIZE*2
                endloop
                
                call TriggerAddAction(onTrack, function TrackableTrack)
                call TriggerAddAction(onHit, function TrackableHit)
            else
                set PlayersOnline[i] = false
            endif
            
            set i = i + 1
        endloop
        
        call BJDebugMsg("maxY = "+R2S(maxY))
    endfunction

The BJ message from currentY dies for some reason and I don't understand why ... further more the events don't work, so I am assuming that the thread dies somewhere in the middle, but I just can't find where ...

I appreciate help and here is map.

rep++ given ...
Attached Files
File Type: w3x SpaceShipFight.w3x (109.2 KB, 21 views)
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 09-05-2009, 07:44 PM   #2
Hans_Maulwurf
root bloody root
 
Hans_Maulwurf's Avatar
 
Join Date: Mar 2007
Posts: 117

Hans_Maulwurf will become famous soon enough (52)Hans_Maulwurf will become famous soon enough (52)

Send a message via ICQ to Hans_Maulwurf
Default

I know that problem. You just hit the oplimit of the tread. The x loop inside the y loop inside the playerloop is too much. maybe you can put the x loop into a function, which you call with .execute?
__________________

Suit up! Tonight is gonna be legen... wait for it... DARY!
Hans_Maulwurf is offline   Reply With Quote
Old 09-05-2009, 08:28 PM   #3
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Quote:
You just hit the oplimit of the tread.
There is an oplimit for threads !? Didn't know that ... This is the code I tested:

Collapse JASS:
scope StartMap initializer Init
    globals 
        boolean array PlayersOnline
        constant integer MAX_PLAYERS = 4
        private constant string TRACK_PATH = "units\\human\\Peasant\\Peasant.mdl"
        private constant real TRACK_SIZE = 80.
    endglobals
//===========================================================================
    private function TrackableHit takes nothing returns nothing
        call BJDebugMsg("cliked!")
    endfunction
//===========================================================================
    private function TrackableTrack takes nothing returns nothing
        call BJDebugMsg("over!")
    endfunction
//===========================================================================
    private function CreateLines takes real x, real y, integer i, real maxX, trigger onTrack, trigger onHit returns nothing
        local real currentX = x
        local Trackable tracker
        
        loop
            exitwhen currentX > maxX - TRACK_SIZE

            set tracker = Trackable.create(currentX, y, 0., TRACK_PATH, Player(i))
            call TriggerRegisterTrackableTrackEvent(onTrack, tracker.track)
            call TriggerRegisterTrackableHitEvent(onHit, tracker.track)
            
            set currentX = currentX + TRACK_SIZE*2
        endloop
endfunction
//===========================================================================
    private function CreateTrackables takes nothing returns nothing
        local real maxX = GetRectMaxX(bj_mapInitialPlayableArea)
        local real maxY = GetRectMaxY(bj_mapInitialPlayableArea)
        local real minX = GetRectMinX(bj_mapInitialPlayableArea)
        local real minY = GetRectMinX(bj_mapInitialPlayableArea)
        local real currentX = minX + TRACK_SIZE
        local real currentY = minY + TRACK_SIZE
        local trigger onHit = CreateTrigger()
        local trigger onTrack = CreateTrigger()
        local integer i = 0
        local Trackable tracker
        
        call CreateUnit(Player(0), 'hfoo', minX, minY, 0)
        call CreateUnit(Player(0), 'hfoo', maxX, maxY, 0)
        
        //see who is playing
        loop
            exitwhen i == MAX_PLAYERS
            
            if GetPlayerController(Player(i)) == MAP_CONTROL_USER then
                set PlayersOnline[i] = true
                
                //create the trackables
                loop
                    exitwhen currentY > maxY - TRACK_SIZE
                    call BJDebugMsg("y= " + R2S(currentY))
                    
                    set currentX = minX + TRACK_SIZE

                    call CreateLines(currentX, currentY, i, maxX, onTrack, onHit)
                    set currentY = currentY + TRACK_SIZE*2
                endloop
                
                call TriggerAddAction(onTrack, function TrackableTrack)
                call TriggerAddAction(onHit, function TrackableHit)
            else
                set PlayersOnline[i] = false
            endif
            
            set i = i + 1
        endloop
        
        call BJDebugMsg("maxY = "+R2S(maxY))
    endfunction
//===========================================================================
    private function Init takes nothing returns nothing
        local trigger StartMapTrg = CreateTrigger(  )
        call TriggerRegisterTimerEvent(StartMapTrg, 0.01, false )
        call TriggerAddAction(StartMapTrg, function CreateTrackables )
    endfunction
endscope

It also does not work ... is it because the map is too big? 256x256 ?
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition

Last edited by Flame_Phoenix : 09-05-2009 at 08:28 PM.
Flame_Phoenix is offline   Reply With Quote
Old 09-05-2009, 09:50 PM   #4
Veev
User
 
Join Date: Nov 2006
Posts: 199

Veev will become famous soon enough (63)Veev will become famous soon enough (63)Veev will become famous soon enough (63)

Default

You're trying to make way too many things way too fast. Also, I am pretty sure a 256x256 map has 65536 32-by-32 unit squares, and if each trackable is 80 (?) units wide, you'd need to make approximately 10,400 trackables for ONE player and you have FOUR. So, yes, you're doing way too much at once, since that trigger is attempting to create over 40,000 trackables "at once."

You most certainly need to reduce the size of your map. Or you can figure out some way to make the trigger run slower (perhaps use a timer? Not sure what is best, here). I have no idea what the op-limit is, but you have definitely hit it.

Last edited by Veev : 09-05-2009 at 09:55 PM.
Veev is offline   Reply With Quote
Old 09-06-2009, 01:23 AM   #5
Bobo_The_Kodo
oO
 
Bobo_The_Kodo's Avatar
 
Join Date: Jul 2008
Posts: 580

Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)

Default

would be safe to create 1000 - 2500 per timer interval, or TSA's reset op limit >.< w/e

1048576 trackables? delete map -> new idea Oo

Last edited by Bobo_The_Kodo : 09-06-2009 at 02:10 AM.
Bobo_The_Kodo is offline   Reply With Quote
Old 09-06-2009, 02:15 AM   #6
Zandose
User
 
Join Date: Feb 2004
Posts: 525

Zandose is on a distinguished road (23)

Default

If I remember right, I've tried trackables before and something around a 64x64 map filled with trackables every 128.00 starts to cause lag.
Zandose is offline   Reply With Quote
Old 09-06-2009, 11:17 AM   #7
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Ahhh .... too many things too fast ...
Having in mind I intend to make this run by levels, perhaps I should only create trackables when a new level starts ... I had no idea this would be a problem. Thx.
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Old 09-06-2009, 02:42 PM   #8
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Quote:
Originally Posted by Flame_Phoenix
Ahhh .... too many things too fast ...
Having in mind I intend to make this run by levels, perhaps I should only create trackables when a new level starts ... I had no idea this would be a problem. Thx.
Perhaps you should reuse the same trackables for all levels, then?
__________________
Anitarf is offline   Reply With Quote
Old 09-06-2009, 06:55 PM   #9
Veev
User
 
Join Date: Nov 2006
Posts: 199

Veev will become famous soon enough (63)Veev will become famous soon enough (63)Veev will become famous soon enough (63)

Default

I think your best plan of attack, Flame, would be to use smaller map, use a timer to create the trackables, and reuse the trackables.
Veev is offline   Reply With Quote
Old 09-06-2009, 07:05 PM   #10
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

I don't get it. How can I change the X and Y of a trackable if I can't move it nor destroy it?
Anyway, you guys are correct. My first approach (using trackables) was, at least, incorrect. Even reusing trackables I would need an entire screen of them, plus the fact I have 4 players, so I would have to multiply that by 4. This is cause a considerable amount of lag thus limiting my options.

I decided that to create my spacehip map I will instead use arrow keys to move the ship. It is also easy and it allows me to turn the ship angle when moving it =).

Rep++ to all, thanks for help.

Btw, is there a way to know when I am hitting the oplimit ? Is there a test? Or am I doomed to brute force with BJ mesages?
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition

Last edited by Flame_Phoenix : 09-06-2009 at 07:05 PM.
Flame_Phoenix is offline   Reply With Quote
Old 09-06-2009, 07:26 PM   #11
Eleandor
User
 
Join Date: Jan 2006
Posts: 118

Eleandor is on a distinguished road (12)

Default

If it stops running, you've hit the oplimit...

Just use TSA to reset it.
Eleandor is offline   Reply With Quote
Old 09-06-2009, 08:14 PM   #12
Hans_Maulwurf
root bloody root
 
Hans_Maulwurf's Avatar
 
Join Date: Mar 2007
Posts: 117

Hans_Maulwurf will become famous soon enough (52)Hans_Maulwurf will become famous soon enough (52)

Send a message via ICQ to Hans_Maulwurf
Default

You don't necessary have to abandon the trackables idea. When you want to create a 2d shooter, you dont have to create tracks across the whole map. Think a bit outside the box for a moment. Instead of moving your ship forward every interval, you could leave it alone and move everything else (enemys/powerups/enviroment) backwards. That concept itself defenetly works (I once did a mario like jump n run with flash this way). This way you only need 1 screen filled with tracks. And at least for me, this didnt drop any performance. Only problem would be, you couldnt really use wc3 terrain.
Just a small idea that came into mind.
__________________

Suit up! Tonight is gonna be legen... wait for it... DARY!

Last edited by Hans_Maulwurf : 09-06-2009 at 08:15 PM.
Hans_Maulwurf is offline   Reply With Quote
Old 09-07-2009, 01:52 PM   #13
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Your idea and concept may just work, I am admired. I am now sure if I can use it by some reasons:
- I still don't know how I am going to use the terrain (I don't even know if I will make an entire adventure on space without terrain, but for that I would need a little white model that could look like a star... )
- Using trackables does not allow my ship to have turn animations when I move it. Using keys I can add a curvature when you go right and left.
- Using trackables I cannot tell the difference between the right button and left button of the mouse, so the ship would lose a secondary attack.

On the other hand ...
I know I am already converted to key, but I didn't stop working on my trackable library.
Now I am using TSA to reset the oplimit, but I am having this message:Click image for larger version

Name:	Image1.jpg
Views:	41
Size:	184.4 KB
ID:	45507

The game has insane lag, so I can only assume that has to be bad ...
But what is this exactly?
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Old 09-07-2009, 03:32 PM   #14
Themerion
Brahms-fan
 
Themerion's Avatar
 
Join Date: Jan 2006
Posts: 642

Submissions (2)

Themerion has a spectacular aura about (114)Themerion has a spectacular aura about (114)Themerion has a spectacular aura about (114)Themerion has a spectacular aura about (114)

Default

I think you are using more than 8190 struct instances of Trackable. Remember that a struct is allocated in an array, so you have to tell JASSHelper to use multiple arrays in order to have more instances than 8190 (or if it's 8191, whatev, it's not the important point)...

Collapse JASS:
// This struct can have 16382 instances!
struct MYTYPE[16382]
endstruct

But I really think that if possible, you should go for what Anitarf said.
__________________
Submissions::
(v)JASS Tutorial
Covers how to make fast and safe coding for common tasks in vJASS/JASS.
Creep Respawn System
It has never been easier to respawn creep groups...
Themerion is offline   Reply With Quote
Old 09-07-2009, 04:00 PM   #15
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

AUch ....
Trackables are not the right solution. The reason why I am still making questions is because I simply like learning =)
Thanks for your answer though, I always wanted to know what that meant.
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition

Last edited by Flame_Phoenix : 09-07-2009 at 04:01 PM.
Flame_Phoenix 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 03:50 PM.


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

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