Home   Help Search Login Register  

Author Topic: arrays and getdammage, setdammage question  (Read 923 times)

0 Members and 2 Guests are viewing this topic.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
arrays and getdammage, setdammage question
« on: 18 Mar 2003, 22:03:58 »
lets say i have 300 objects that i have named


x1 to x100
y1 to y100
z1 to z100

I basically want to make say 6 arrays
x1 to x50
x51 to x100
y1 to y50
y50 to y100
z1 to z50
z51 to z100

and for each array i want to run a getdammage check
if any object in that particular array is "getdammage >0.2"
i want to setdammage 0 for each in the list


now instead of typing

damcon1 = [x1, x2, x3, x4, x5, x6........... etc etc
damcon2 = [x51, x52, x53, x54, x55, x56 ...........etc etc
damcon3 = [y1, y2, y3, y4, y5, y6 ..............etc etc

is there a shorter way of doing it??


and once i have done this


to get it to run, am i better doing it from a repeating trigger or running a looping script


Its basically to run damage control on a heavily laden mplayer map with lots of buildings

the streets are very narrow and any damaged distorts these buildings, making it difficult to pass

Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:arrays and getdammage, setdammage question
« Reply #1 on: 19 Mar 2003, 01:50:29 »
Yikes!

well you could populate the arrays by running a couple of loops... eg.

damcon1 = []
damcon2 = []
damcon3 = []
...etc.

_i = 1
#loop
~0.01
? _i < 51: damcom1 = damcon1 + [(format ["x%1",_i])]
? _i >= 51: damcon2 = damcon2 + [(format ["x%1",_i])]
_i = _i + 1
? _i < 101: goto "loop"

etc...

However I'd advise caution running multiple array checking loops to look at damage... it will quite probably bring the server to it's knees.
Do you really need to check the damage of all those objects? And might eventhandlers not work better? ;)

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:arrays and getdammage, setdammage question
« Reply #2 on: 19 Mar 2003, 16:12:09 »
how would i use an event handler

would i have one for each object or would i have 1 per array



what i actually need to do is keep these buildings in a state of constant repair


Basically i have built a large city from scratch, the streets are very narrow and if one of the buildings takes an AT hit or a chopper crashes onto them, they obviously suffere damage. The distortion of these buildings is enough to create problems trying to pass them
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:arrays and getdammage, setdammage question
« Reply #3 on: 19 Mar 2003, 23:46:51 »
Hmm...

I'm not sure that eventhandlers would be any better to tell you the truth (they may in fact be worse).

What I would do, is not have so many bloody buildings ;D

However, if you must... I would remove as much of the script as possible. So, instead of having a checking routine to ask if the buildings are damaged, I'd just repair all the buildings every cycle anyway. So something like this:

bldRA = [ bld1,bld2,bl3... etc.]
_i = 0
#loop
~0.01
(bldRA select _i) setdammage 0
_i = _i + 1
if (_i <= (count bldRA)) then {goto "loop"} else {_i = 0; goto "loop"}

Try that out, and if you get cpu slowdown (as I suspect you will I'm afraid) give us a yell and we'll see if we can't sort something a bit more efficient out... ;)

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:arrays and getdammage, setdammage question
« Reply #4 on: 20 Mar 2003, 00:33:27 »
Yeah Terox, Sui's last suggestion sounds way better to me
than instantly checking 200 objects and if... setdammage
them. I would even not do this ever 0.01 seconds in a loop
than let's say have a delay of minimum 0.5 seconds from building to building. That way you wouldn't stress anything
in your misison. Or do you think it's really necessary to check
the buildings that often.

I mean if ppl start fighting an all out war against buildings, then there's still the #kick command available  ;)

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:arrays and getdammage, setdammage question
« Reply #5 on: 20 Mar 2003, 12:46:50 »
I had already though about spreading the cpu workload out

I was going to initially try 6 repair runs
each repair run i intend to exec from the init.sqs rather than a trigger
Each one to have a different initial delays before it starts
All having the same wait period between each loop
---------------------------------------------------------------------------------

[]exec "damcon1.sqs"
[]exec "damcon2.sqs"
[]exec "damcon3.sqs"  etc etc etc
--------------------------------------------------------------------------------
;;damcon1
~1
#start
~13
setdammage to 0 for say array of 50 buildings
goto "start"
-----------------------------------------------------------------------------------
;;damcon2
~3
#start
~13
setdammage to 0 for say array of50 buildings
goto "start"
------------------------------------------------------------------------------------
;;damcon3
~5
#start
~13
setdammage to 0 for say array of 50 buildings
goto "start"
---------------------------------------------------------------------------------------
;;damcon4
~7

;;damcon5
~9

;;damcon6
~11.   etc etc etc
--------------------------------------------------------------------------------------------


what i actually didnt think about was having a time delay, whilst setting damage to 0 for each element in the array

How would i do this
« Last Edit: 20 Mar 2003, 13:02:02 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:arrays and getdammage, setdammage question
« Reply #6 on: 20 Mar 2003, 14:34:58 »
Quote
what i actually didnt think about was having a time delay, whilst setting damage to 0 for each element in the array

How would i do this

Doesn't work when using foreach, but will work when
using the loop'ed version.

bldRA = [ bld1,bld2,bl3... etc.]
_i = 0
#loop
~0.5
(bldRA select _i) setdammage 0
_i = _i + 1
goto "loop"

~S~ CD
« Last Edit: 20 Mar 2003, 14:35:18 by Chris Death »
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:arrays and getdammage, setdammage question
« Reply #7 on: 21 Mar 2003, 00:43:23 »
thanks a lot guys,   will try this
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123