• 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.

[General] The effective way to optimize a defense/survival map?

Status
Not open for further replies.
Level 2
Joined
May 19, 2013
Messages
7
Hello there,

I have a question, we already knew that tower defense or survival maps (especially tower defense) will create a lots of creeps. If we only test map, so it's fine. But when we play online, for example with 8 other players - each player doesn't have a same ping ==> Lag if the creeps is too many. (a tower defense game at round 30th)

So, the question here is there anyway to optimize the map to reduce lag in this situation?
 
Level 10
Joined
Apr 18, 2009
Messages
601
This is a great and simple tutorial on memory leaks that I always use for reference:
http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/basic-memory-leaks-5889/

How you spawn your creeps is vitally important. Don't spawn them all at once as soon as a level starts. Instead, spawn a few every second or so and increment a counter until that counter reaches the desired amount of creeps for that level.

Other than that, it depends on your map really. Do you want to have multiple spawn locations or just one? Is it important for the gameplay to have all 100 creeps at the map at once? If you temporarily stop creeps from spawning when there are, say, 50 or more already on the map, then re-activate the spawn trigger as soon as the number drops below 50 then that will be a great optimisation. For example, you'd probably want to consider this method for hero survivals, but rarely for TDs as the point there is to have a stream of creeps rush and use their superior numbers to overwhelm the damage output of the towers.

So the best optimisations generally depends on what specific map you are making and what would work in that unique instance.
 
Level 2
Joined
May 19, 2013
Messages
7
Thanks for your replies, guys.

Actually, I'm working on both map (tower defense and survival). I was a map modder since 2 years ago, then I have a real life => blah blah blah...

Now I became a map modder again for entertain myself after a lots of hours coding...

----

Well, let's take the tower defense map as an example. I have 8 spawn locations for 8 players. The creeps were spawn at the same time.

I'm now using custom polled wait function by Vexorian (see below)

JASS:
function CustomPolledWait takes real duration returns nothing
 local real timeRemaining
 local real st=TimerGetElapsed( bj_gameStartedTimer)
    if st <= 0 then
        set bj_gameStartedTimer = CreateTimer()
        call TimerStart(bj_gameStartedTimer, 1000000, false, null)
    endif
    if (duration > 0) then
        loop
            set timeRemaining = duration - TimerGetElapsed( bj_gameStartedTimer) + st
            exitwhen timeRemaining <= 0
            if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then
                call TriggerSleepAction(0.1 * timeRemaining)
            else
                call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
            endif
        endloop
    endif
endfunction

And there is no leaks, because I always destroy them after use. And I'm using MemoryLeakHelper too.

I'm working to convert all GUI/MUI in my map to JASS, it will make me feel more readable than GUI/MUI. Althought this is not finished but when I test the game, the game is smoothly than before not convert.

Is there any framework in JASS before ? Because I'm thinking about create a opensource framework for map modders...
 
Level 10
Joined
Apr 18, 2009
Messages
601
No problem for the response, hope it can help.

Is what you're asking now basically if there is any framework in JASS for spawning units in a smooth and optimal fashion?

Are you also saying that you want response on how to optimise a TD with 8 spawns? If so, about how many creeps are (max) on the map during each level? When do you think the lagg needs to be reduced? Is it only during spawn time or when too many creeps are at the map? The latter would be hard to fix with just code optimisation because it's not dependent on the code we write but rather the inherent code of the game that blizzard wrote and we cannot get to.

I'm mostly asking these questions to help others know what's the subject of this thread at this point (what to answer and discuss, right?). I'm not really into JASS myself so I'm afraid that I can't be helpful when it comes to specific JASS code.
 
Level 2
Joined
May 19, 2013
Messages
7
Thanks to Licheus. Your questions make me see the light! I think I found the solution in this situation

@deathismyfriend: Yes, you're right. A timer is what I need, totally forgot it :p
 
Status
Not open for further replies.
Top