Donations to help with Site, Vent, and Hosting costs are appreciated!
Welcome Guest [Log In] [Register]

You're currently viewing our forum as a guest. Register now or login to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple and fast.


Register HERE!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Preloading Models
Topic Started: Sep 9 2008, 02:50 AM (1,628 Views)
0chspelar
Member Avatar
Grammar Nazi
[ *  *  *  *  *  *  *  * ]
I was trying to figure out how to preload the models in my map before the init, cause zombie spawn lags sometimes, and general spawn and zombie mutation lags sometimes

http://www.hiveworkshop.com/forums/f279/game-caches-6273/


I found a tutorial on game cache, do I just make a gamecache and store the 3 units?

Zombie: O000:Otch

Mutated Zombie: O007:Otch

General: O006:Otch
Offline Profile Quote Post Goto Top
 
BDSM
Member Avatar
Sadistic Bastard
[ *  *  *  * ]
Place any unit's you use on map during initialization, along with spells you plan to use later.

OR

Load each model you plan to use with:

Code:
 
native Preload takes string filename returns nothing
Offline Profile Quote Post Goto Top
 
AwaKening
Member Avatar
How do ya like me now
[ *  *  *  *  *  *  *  *  * ]
Now you know why Dota lags at the beginning :o .

I use the method BDSM stated. All my heros are placed in a corner of the map and then removed via trigger in the Map Init; otherwise, you get a second of lag everytime someone picks a new hero that hasn't been picked yet. I sacrifice a bit of load time, but I'd rather have to wait there instead of in the game.
Posted Image
Offline Profile Quote Post Goto Top
 
0chspelar
Member Avatar
Grammar Nazi
[ *  *  *  *  *  *  *  * ]
oh, so I load them on the map and then destroy unit?

when i put them on the map who do i assign the units to? or is there a neutral or something.[redit][/redit]
Edited by 0chspelar, Sep 9 2008, 10:43 PM.
Offline Profile Quote Post Goto Top
 
AwaKening
Member Avatar
How do ya like me now
[ *  *  *  *  *  *  *  *  * ]
Player Neautral Passive (Player 15)

You can either make a trigger to create and remove them at start, or just preplace them so you only have to trigger the remove. The second method seems to load faster in my testing.
Posted Image
Offline Profile Quote Post Goto Top
 
BDSM
Member Avatar
Sadistic Bastard
[ *  *  *  * ]
Pre-placed units simply invoke the use of the CreateUnit native, albeit through a few chained functions calls. Also, since pre-placed units are declared before GUI triggers, you can easily just remove them with no worries. Pre-placed yields zero gain as far as loading time when compared to calling it yourself during map initialization. However, it does have one benefit: placing units exactly where you want to with greater ease.

As far as which player to assign the units to, it really doesn't matter so long as you're removing them in map initialization. No one would be the wiser. However, I would say it's good taste to give them to a "neutral" (as in not on any sides) player; for most maps this will be Player(15).
Offline Profile Quote Post Goto Top
 
0chspelar
Member Avatar
Grammar Nazi
[ *  *  *  *  *  *  *  * ]
yea i tried to pre place but I can't find the units after clicking nuetral passive. it only gives me neutral and naga units, do i have to copy them in the obj editor and move them to neutral?
Offline Profile Quote Post Goto Top
 
AwaKening
Member Avatar
How do ya like me now
[ *  *  *  *  *  *  *  *  * ]
No. I can't remember without looking at the map editor, but there is a way to do it. You could just preplace them as red, and then change to player neautral passive afterwards by double clicking the unit.
Posted Image
Offline Profile Quote Post Goto Top
 
0chspelar
Member Avatar
Grammar Nazi
[ *  *  *  *  *  *  *  * ]
oh ok

thanks, it worked, now i just need to make a trigger to destroy/ remove the units i'm guessing its something like

Code:
 

function Trig_preload_Func001A takes nothing returns nothing
call RemoveUnit( GetFilterUnit() )
endfunction

function Trig_preload_Actions takes nothing returns nothing
call ForGroupBJ( GetUnitsOfPlayerAll(Player(PLAYER_NEUTRAL_PASSIVE)), function Trig_preload_Func001A )
endfunction

//===========================================================================
function InitTrig_preload takes nothing returns nothing
set gg_trg_preload = CreateTrigger( )
call TriggerAddAction( gg_trg_preload, function Trig_preload_Actions )
endfunction






looks something like this? did it in gui and then switched to custom text, it saves, i guess i'll test it out.
[redit][/redit]
Edited by 0chspelar, Sep 18 2008, 04:20 PM.
Offline Profile Quote Post Goto Top
 
0chspelar
Member Avatar
Grammar Nazi
[ *  *  *  *  *  *  *  * ]
bah, i tested it, it didn't remove them. I set it to map init as the event, maybe i should have it wait .01 and then do it? instead of map init?

either that or i have to kill/ destroy unit or something. though remove is what i want right?
Edited by 0chspelar, Sep 18 2008, 04:30 PM.
Offline Profile Quote Post Goto Top
 
AwaKening
Member Avatar
How do ya like me now
[ *  *  *  *  *  *  *  *  * ]
Well #1, you need to be using GetEnumUnit() instead of GetFilterUnit(). Enum=pickedunit

#2, you will be removing anything on your map that is player 15. You probably don't want that. You need to make conditions to pick only certain types of units to remove, or put them in a region and select all in region. You could even just trigger the whole thing instead of preplacing them, won't make too much difference

#3, Your trigger will leak; although it's only run once, so not a huge deal, but get used to fixing any leak ;)

Example:

local group g
local boolexpr bx
set g=CreateGroup
set bx = Condition(function YourConditionsName)
call GroupEnumUnitsOfPlayer(g, Player(15), bx)
call ForGroup(g, function Trig_preload_Func001A)
call DestroyGroup(g)
set g=null
call DestroyBoolExpr(bx)
set bx=null
Posted Image
Offline Profile Quote Post Goto Top
 
0chspelar
Member Avatar
Grammar Nazi
[ *  *  *  *  *  *  *  * ]
nothing is 15 except the 3 models I set for preloading, so its really ok, to remove all player 15, its not gonna mess up anything

ah, yea so i have to null it to stop leaking?
Offline Profile Quote Post Goto Top
 
0chspelar
Member Avatar
Grammar Nazi
[ *  *  *  *  *  *  *  * ]
by conditions name, you mean my trigger name?
Offline Profile Quote Post Goto Top
 
AwaKening
Member Avatar
How do ya like me now
[ *  *  *  *  *  *  *  *  * ]
0chspelar
Sep 22 2008, 06:27 PM
by conditions name, you mean my trigger name?
NO

You have to make the conditon function within the trigger.

Example of a condition within your trigger. Then you link your boolexpr to it. set bx=Condition(function blabla_bool)
Code:
 
function blabla_bool takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO)
endfunction
Posted Image
Offline Profile Quote Post Goto Top
 
0chspelar
Member Avatar
Grammar Nazi
[ *  *  *  *  *  *  *  * ]
ah, so i have to add a boolean in there. along with all the other stuff i have, and add the nulls,
Offline Profile Quote Post Goto Top
 
0chspelar
Member Avatar
Grammar Nazi
[ *  *  *  *  *  *  *  * ]
is that bool in the actions?
Offline Profile Quote Post Goto Top
 
0chspelar
Member Avatar
Grammar Nazi
[ *  *  *  *  *  *  *  * ]
Code:
 

function Trig_preload_Func001A takes nothing returns nothing
call RemoveUnit( GetEnumUnit() )
endfunction

function remove_bool takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO)
endfunction

function Trig_preload_Actions takes nothing returns nothing
local group g
local boolexpr bx
set g=CreateGroup ()
set bx = Condition(function remove_bool)
call GroupEnumUnitsOfPlayer(g, Player(PLAYER_NEUTRAL_PASSIVE), bx)
call ForGroup(g, function Trig_preload_Func001A)
call DestroyGroup(g)
set g=null
call DestroyBoolExpr(bx)
set bx=null
call ForGroupBJ( GetUnitsOfPlayerAll(Player(PLAYER_NEUTRAL_PASSIVE)), function Trig_preload_Func001A )
endfunction

//===========================================================================
function InitTrig_preload takes nothing returns nothing
set gg_trg_preload = CreateTrigger( )
call TriggerAddAction( gg_trg_preload, function Trig_preload_Actions )
endfunction


all the info is there, I just need to organize it correctly, lookin at my old triggers.

:edit : Ok i rearranged it, I only get 1 error Expected '(' at set g=CreateGroup so i'll look at more of the old triggers for ideas.

2nd edit, dur, easy enough, ()

It saves, now to test it.
Edited by 0chspelar, Sep 23 2008, 02:26 PM.
Offline Profile Quote Post Goto Top
 
AwaKening
Member Avatar
How do ya like me now
[ *  *  *  *  *  *  *  *  * ]
You got the idea, just replace those shitty gui conversions with the code i gave you. I think you can do this alone. You have everything you need, just arrange it.
Posted Image
Offline Profile Quote Post Goto Top
 
0chspelar
Member Avatar
Grammar Nazi
[ *  *  *  *  *  *  *  * ]
Yea it works, but i forgot I use player 15 neutral passive for the graveyards and shops, so it took those out too. so I need to fix that, I turned the trigger off for now. I could make the pre placed player neutral aggressive or something. instead of redoing the whole trigger, i dunno what do you think. Also found another bug for a hero trigger but i'll post it in that thread.
Offline Profile Quote Post Goto Top
 
0chspelar
Member Avatar
Grammar Nazi
[ *  *  *  *  *  *  *  * ]
all 3 units are hero's i believe so i could

GetEnumUnit(HERO)

for player 15

or do it by each unitid

Zombie: O000:Otch

Mutated Zombie: O007:Otch

General: O006:Otch
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
ZetaBoards - Free Forum Hosting
Fully Featured & Customizable Free Forums
Go to Next Page
« Previous Topic · Mapping · Next Topic »
Add Reply

Skinned by AwaKening