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

Placing units using GUI/JASS at map load

Status
Not open for further replies.
Level 6
Joined
Jan 12, 2011
Messages
110
Hello again,
I've seen pretty bad thing for me, and that's that when I pre-place many units on the map, the load time will be super huge and the game ?will lag?... (at least I hope I'm not mislead...)

Well, I've seen this in many maps, that when I normally open them in WE, there are no units on the map, but they're probably added at the map init via some trigger. (right now I'm reffering for example to Twilight's Eve)

Well, now to the questions:
1) Is it better to add creatures via trigger, or to pre-place them? What are the differences
and
2) Could somebody give me a plain example, how to do it? (either in GUI or JASS, but I'd be glad for both if possible).


Thanks to everybody who read this and will respond.
 
Level 6
Joined
Oct 4, 2011
Messages
226
Well I think creating them upon trigger is smoother. Some maps previde an in-game load duration (Just extra time alotted for players to handle the loading of triggers). How you summon units without leaking is.
  • Untitled Trigger 001
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Set Point_Variable = (Center of Spawn Region 0001 <gen>)
      • Unit - Create 1 Footman for Player 1 (Red) at Point_Variable facing 270.00 degrees
      • Custom script: call RemoveLocation ( udg_Point_Variable )
      • Set Point_Variable = (Center of Spawn Region 0002 <gen>)
      • Unit - Create 1 Rifleman for Player 1 (Red) at Point_Variable facing 90.00 degrees
      • Custom script: call RemoveLocation ( udg_Point_Variable )
      • Set Point_Variable = (Center of Spawn Region 0003 <gen>)
      • Unit - Create 1 Priest for Player 1 (Red) at Point_Variable facing 180.00 degrees
      • Custom script: call RemoveLocation ( udg_Point_Variable )
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
if you got really much units on your map, i would do it with triggers, else i would place them standard way.
if you are doing a rpg, just do it like that:
  • Trigger 1
    • Events
      • Unit - A unit enters Forest Area <gen>
    • Conditions
      • ((Triggering unit) is a Hero) equal to True
    • Actions
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set Random_Point = (Random point in Forest Area <gen>)
          • Unit - Create 1 Wolf for Neutral Hostile at Random_Point facing random degrees
          • Custom script: call RemoveLocation (udg_Random_Point)
  • Trigger 2
    • Events
      • Unit - A unit leaves Forest Area <gen>
    • Conditions
      • ((Triggering unit) is a Hero) equal to True
    • Aktionen
      • Set Creep_Group = (Units in Forest Area <gen> matching ((Owner of (Matching unit)) Gleich Neutral Hostile))
      • Unitgroup - Pick every unit in Creep_Group and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Custom script: call DestroyGroup (udg_Creep_Group)
with that triggers you can split your map into regions. if a hero enters the region, enemies will be spawned, if you leave region, theyll get removed.
 
Level 6
Joined
Jan 12, 2011
Messages
110
if you got really much units on your map, i would do it with triggers, else i would place them standard way.
if you are doing a rpg, just do it like that:
  • Trigger 1
    • Events
      • Unit - A unit enters Forest Area <gen>
    • Conditions
      • ((Triggering unit) is a Hero) equal to True
    • Actions
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set Random_Point = (Random point in Forest Area <gen>)
          • Unit - Create 1 Wolf for Neutral Hostile at Random_Point facing random degrees
          • Custom script: call RemoveLocation (udg_Random_Point)
  • Trigger 2
    • Events
      • Unit - A unit leaves Forest Area <gen>
    • Conditions
      • ((Triggering unit) is a Hero) equal to True
    • Aktionen
      • Set Creep_Group = (Units in Forest Area <gen> matching ((Owner of (Matching unit)) Gleich Neutral Hostile))
      • Unitgroup - Pick every unit in Creep_Group and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Custom script: call DestroyGroup (udg_Creep_Group)
with that triggers you can split your map into regions. if a hero enters the region, enemies will be spawned, if you leave region, theyll get removed.


Well, I'm actually doing ORPG (for up to 10 players), but you see, I was asking for trigger, that would spawn them on some place without making regions...
The thing is, I don't wan't all the units placed randomly (only some of they would, I'd think of 30%), but still, there would have to be pre-placed huge number of units.
Still, thanks for the triggers, but I think I'd be able to think of them myself :).

I suppose, that the thing I mean can be only done via JASS. As I said, I was thinking of Twilight's Eve, where there are no pre-placed units, and there are no random spawns, therefore it has to be written in JASS somehow. And that is what I was mainly asking for :).

Anyway, thanks for your time and help guys, I appreciate it.


And if there will be someone, who could give me a plain sight how to place the units via JASS, I'd be most grateful.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Donach, there are Custom Scripts (JASS) to create a unit using X/Y Coordenates. When you move your move over the map in the editor, you see 2 values changing in the bottom left corner. These are the X/Y. Just place the mouse where you want to create the unit, and take note of the X/Y. Then use the "call CreateUnit(player whichPlayer, integer unit-type id, real x, real y, real facing)" to create it.

It's leakless, and the fastest command to create a unit.
 
Level 5
Joined
Jun 16, 2004
Messages
108
I imagine what you are experiencing is the result of opening up forcefully unprotected maps in the WE rather than people actually creating all their units through triggers. Common symptom anyway, if you protect and optimize your map then unprotect it you may see the same thing happen.

I believe the map creates JASS code to create all the units on initialization every time you save. The map will use the war3mapUnits.doo file to generate the code, which is one of those files that typically gets optimized away. Once that happens the editor no longer "sees" all those units in the editor, but the code it last generated will be available of course.
 
As halo said, it already creates all the units via generated jass code in the war3map.j. If you are really concerned about loading times, then just use widgetizer as it will help it a lot.

If there are enough units, then yeah all those preplaced units may lead to longer loading times, but it is a bit tedious to trigger all of it. Even so, you would have to split it to create the units at different times elapsed, otherwise you'll just have a big lag spike in the beginning of the game--and a lot of people would rather just sit the loading screen for a few more seconds than have that.
 
Level 6
Joined
Jan 12, 2011
Messages
110
As halo said, it already creates all the units via generated jass code in the war3map.j. If you are really concerned about loading times, then just use widgetizer as it will help it a lot.

If there are enough units, then yeah all those preplaced units may lead to longer loading times, but it is a bit tedious to trigger all of it. Even so, you would have to split it to create the units at different times elapsed, otherwise you'll just have a big lag spike in the beginning of the game--and a lot of people would rather just sit the loading screen for a few more seconds than have that.

I've heard of widgetizer. But I kinda don't understand what does it do...
Is that so, that if I preplace all the units, then the widgetizer will move the units into file, so they won't be 'visible' in WE, but will load on map initialization?
If I'm mistaken, explain in to me, please.

Thanks a lot for everybody's answers.
 
Level 5
Joined
Aug 12, 2010
Messages
87
Dont forget create dummy heroes and put all items into them and then remove them on map initial so when you buy item first time you dont have lag, but shit i did 5 heroes x 6 items and loadint time added like 10-20 secs ffs.
 
I've heard of widgetizer. But I kinda don't understand what does it do...
Is that so, that if I preplace all the units, then the widgetizer will move the units into file, so they won't be 'visible' in WE, but will load on map initialization?
If I'm mistaken, explain in to me, please.

Thanks a lot for everybody's answers.

Well, I just meant that if you are worrying about loading times, then just use widgetizer when you are done with your map as it will speed up loading times by a significant amount.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
Avoid pre-placing units that might not be used. Especially for an RPG map you can often end up placing more units than players will encounters (such as low or high level areas when no-one is in that level range).

A better alternative for these situations is to dynamically spawn the units when players enter the area. This prevents any game load for units in areas players will not go to during a session.

Example - TKoK (at least the last version I played).
 
Avoid pre-placing units that might not be used. Especially for an RPG map you can often end up placing more units than players will encounters (such as low or high level areas when no-one is in that level range).

A better alternative for these situations is to dynamically spawn the units when players enter the area. This prevents any game load for units in areas players will not go to during a session.

Example - TKoK (at least the last version I played).
There is 1 thing that is far more powerful than creating and removing units from areas.

If you pause unit you will freeze animations and remove lag.

Both me and Magtheridon96 are working on script for SotP that will pause units and make them transparent (invisible) as soon as they leave some hero range.
Knowing Mag he will make it a lot complex and bother with unneeded details like always, but it should be presented as public resource then as well. So just wait few weeks :)
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
If you pause unit you will freeze animations and remove lag.

Both me and Magtheridon96 are working on script for SotP that will pause units and make them transparent (invisible) as soon as they leave some hero range.
Knowing Mag he will make it a lot complex and bother with unneeded details like always, but it should be presented as public resource then as well. So just wait few weeks :)
They still exist consuming resources when appropriate. Transparent does nothing to lessen GPU load. Hiding them might remove render load but they will still slow the game down in other ways.
 
They still exist consuming resources when appropriate. Transparent does nothing to lessen GPU load. Hiding them might remove render load but they will still slow the game down in other ways.
Maybe but just like doodads, you can spam over 1000 doodads on the screen and FPS will be high, but if you use animated ones, lag will become terrible already around 100 or less.
 
Level 6
Joined
Jan 12, 2011
Messages
110
Avoid pre-placing units that might not be used. Especially for an RPG map you can often end up placing more units than players will encounters (such as low or high level areas when no-one is in that level range).

A better alternative for these situations is to dynamically spawn the units when players enter the area. This prevents any game load for units in areas players will not go to during a session.

Example - TKoK (at least the last version I played).

So, If I would pause the units, if nobody comes for, let's say, 1 minute, and then remove them, it will help the lag?

And the main problem is load time, 'cuz I'm aiming to have about 500+ units preplaced. I just hope the widgetizer fixes this humongous load increase...

Thanks again for advice. I really appreciate it.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
Only spawn the units when they are needed. Additionally remove units which are no longer needed.

An example for an RPG would be to spawn all units when entering an area for the first time. When players are finished with the area they might never visit it again for the rest of the session so if there is no activity for 5 or so minutes in that area you remove all the units.

Be aware that creating units make a permanent leak. This is a WC3 game bug and the reason why TKoK uses unit recycling.
 
Level 6
Joined
Jan 12, 2011
Messages
110
Only spawn the units when they are needed. Additionally remove units which are no longer needed.

An example for an RPG would be to spawn all units when entering an area for the first time. When players are finished with the area they might never visit it again for the rest of the session so if there is no activity for 5 or so minutes in that area you remove all the units.

Be aware that creating units make a permanent leak. This is a WC3 game bug and the reason why TKoK uses unit recycling.

Unit recycling? What is that? Would I be able somehow to prevent the leak?
 
Status
Not open for further replies.
Top