HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Storing Units...

05-26-2004, 09:00 PM#1
Ninja73
Hey

i have about 300 units in a area, they are creating lag, but i need them. i need 2 know if there is a way that i can store all of those units positions in an array, then remove the units. then i want to bring back the same units in the same positions as stored in the array. then again, after im done with them i want 2 remove them. i think i need 2 use a point variable, but i dont know how 2 do all of this.

can some1 plz help me?!?!?
05-26-2004, 10:02 PM#2
Ninja73
never mind, i got it all 2 work perfectaly

:)
05-27-2004, 05:31 PM#3
BladeKiller
Say please how u did that. : :(
I need to know that too. :(



:(
05-27-2004, 07:20 PM#4
Ninja73
^_^ ^_^ ^_^
Create a variable Titled like UNITARRAY or something, next you need 2 make it a POINT variable, then make it an array with a size of how ever many units u need 2 store. we'll say 300 for the example.

Now, place your 300 units (i am using them for a tank maze), ok, create a trigger. Make it run at map initilazition, then make it do the following actions:

For each (integer A) from 1 to (number of units goes here) do multiple actions.
Pick every unit in TankAreaRegion1 and do multiple actions:
set UNITARRAY[integer A] = position of picked unit
remove picked unit from the game

OK... this is the trigger that stores and removes the units and their positions!

Next... is the part of recalling units!
Create a trigger with the following:

Events:
Unit enters region StartTankRegion1

Conditions:
Unit type of entering unit is equal to Mazer

Actions:
Turn Off This Trigger
For each (integer A) from 1 to (unit number) do multiple actions:
unit create 1 Tank for Player 11 at UNITARRAY[integer A]

OK... your done! at map initilazition it will store the units positions, then remove the units to reduce lag, then when a player enters the region to recall the units it will create a new unit at the old units same position!

I Hope This Helped You!
05-27-2004, 07:22 PM#5
Ninja73
:D IF THIS HELPED YOU, PLEASE GIVE ME A POINT!

Quote:
Originally Posted by Ninja73
^_^ ^_^ ^_^
Create a variable Titled like UNITARRAY or something, next you need 2 make it a POINT variable, then make it an array with a size of how ever many units u need 2 store. we'll say 300 for the example.

Now, place your 300 units (i am using them for a tank maze), ok, create a trigger. Make it run at map initilazition, then make it do the following actions:

For each (integer A) from 1 to (number of units goes here) do multiple actions.
Pick every unit in TankAreaRegion1 and do multiple actions:
set UNITARRAY[integer A] = position of picked unit
remove picked unit from the game

OK... this is the trigger that stores and removes the units and their positions!

Next... is the part of recalling units!
Create a trigger with the following:

Events:
Unit enters region StartTankRegion1

Conditions:
Unit type of entering unit is equal to Mazer

Actions:
Turn Off This Trigger
For each (integer A) from 1 to (unit number) do multiple actions:
unit create 1 Tank for Player 11 at UNITARRAY[integer A]

OK... your done! at map initilazition it will store the units positions, then remove the units to reduce lag, then when a player enters the region to recall the units it will create a new unit at the old units same position!

I Hope This Helped You!

:D IF THIS HELPED YOU, PLEASE GIVE ME A POINT!
05-28-2004, 05:40 PM#6
xGT4x
I'm not a mod but I think doubleposting doubled in a thread isn't allowed so stop it and edit your last post! :<
To the topic: I bet your trigger causes extreme lagg, on my comp it would be like pausing the game for some seconds. Hiding and Showing doesn't cause lagg and it's pretty near to removing and creating new^^In some cases this is better :D
05-29-2004, 02:03 AM#7
genki-dama
Quote:
Originally Posted by XIID.GT4
I'm not a mod but I think doubleposting doubled in a thread isn't allowed so stop it and edit your last post! :<
To the topic: I bet your trigger causes extreme lagg, on my comp it would be like pausing the game for some seconds. Hiding and Showing doesn't cause lagg and it's pretty near to removing and creating new^^In some cases this is better :D


I agree - i would have used the hide trigger also.. like pick all units in region and hide picked unit. :D
05-29-2004, 11:24 AM#8
BladeKiller
Thx for answering
05-31-2004, 04:10 AM#9
LegolasArcher
Code:
For each (integer A) from 1 to (number of units goes here) do multiple actions.
Pick every unit in TankAreaRegion1 and do multiple actions:
set UNITARRAY[integer A] = position of picked unit
remove picked unit from the game


This is wrong. While it will work, it's running the unit loop 300 times when you only need to pick the units once. Also, you need an second array for multiple unit types. Fixed version:

Remove Trigger:
Code:
set i = 1
Pick every unit in TankAreaRegion1 and do multiple actions:
set UNITARRAY[i] = position of (picked unit)
set UNITTYPE[i] = unit type of (picked unit)
set PLAYEROWN[i] = owner of (picked unit)
set FACEANGLE = facing angle of (picked unit)
remove (picked unit) from the game


Restore Trigger:
Code:
For Each integer A from (1) to (i)
Create one (UNITTYPE[Integer A]) for PLAYEROWN[Integer A] at UNITARRAY[Integer A] facing FACEANGLE[Integer A]


It is more advisable to hide all the units, though. This will make extreme lag with the size of the loops if there are many units.
06-01-2004, 08:32 PM#10
Ninja73
:> :> :>
The trigger i used i have tested online many times and i have never had some1 lag from the trigger... however, if you just hide the units the units are still technically on the map, just hidden. Since the units are still on the map it will increase the lag rather than if there were no units in that area.
06-01-2004, 08:57 PM#11
LegolasArcher
And running through a large loop that creates and removes units (both cause slow down) whenever a unit enters X region doesnt create any lag?

I'll give you it would reduce lag when units are not in the area, but you'd have a spike when the units are created (especially since the GUI create unit facing angle has a memory leak, from what I hear). It might not be noticable in your case, though.