I've got a very large array of 27 positions and then 27 sounds correlated with each position. I would love to add more, but I am not sure if I am doing this in the best way and would appreciate some wisdom/advice! I am running the script below once every 2.5 minutes in my mission to move various sound triggers around near the player. Basically I am trying to cut down on lag by having only one "chicken" sound and one "dog" sound but multiple places to put them. I'd love to get up to 100 positions or so, would really add a lot of value to the mission.
My question is, can you store this large Array of positions once and make it easier for the CPU to process it, or do i need to run all the positions every time, like every 2.5 minutes in my mission? What's the best way to handle this?
With 27 positions now i get a second or two of lag as the PC runs through the script. Thanks so much for your help!
Here's the script, which has 5 different sound triggers that will move to locations near the player to give "ear candy" during the mission.
;Move Sound Candy by Lee Hunt, thanks to Mr. Peanut and Ofpec.com for the help!
; Inspiration & idea for moving sound candy based on THobson's MoveTriggers in Abandoned Armies 1.40
_cow = _this select 0
_owl = _this select 1
_chicken = _this select 2
_wolf = _this select 3
_dog = _this select 4
; The locations are the objects the player wants to place sounds near
_Locations = [getpos player nearestObject 190635,getpos player nearestObject 202858,getpos player nearestObject 197342,getpos player nearestObject 139079,getpos player nearestObject 204230,getpos player nearestObject 587129,getpos player nearestObject 124858,getpos player nearestObject 60840,getpos player nearestObject 63502, getpos player nearestObject 64828,getpos player nearestObject 375029,getpos player nearestObject 433270,getpos player nearestObject 199685,getpos player nearestObject 219430,getpos player nearestObject 119372,getpos player nearestObject 446084,getpos player nearestObject 561030,getpos player nearestObject 256089,getpos player nearestObject 445124,getpos player nearestObject 264607,getpos player nearestObject 361471,getpos player nearestObject 373323,getpos player nearestObject 113770,getpos player nearestObject 255324,getpos player nearestObject 206350, getpos player nearestObject 64982,getpos player nearestObject 64384]
;The messages are the different sounds to be played at each location object, and can and should use the same sound to avoid having too many
; triggers on the map.
~5
_Messages = [_cow,_cow,_cow,_cow,_cow,_cow,_cow,_owl,_owl,_owl,_owl,_owl,_chicken,_chicken,_chicken,_chicken,_chicken,_chicken,_wolf,_wolf,_wolf,_wolf,_dog,_dog,_dog,_owl,_wolf]
~2
;Find out which location the player is closest to, _atrocity is used based on Thobson's Abandoned Armies
_GL = "logic" createvehicle [0,0,0]
_GL setPos getpos (_Locations select 0)
_atrocity = 0
_dist = player distance _GL
_i = 0
#loopfindAtrocity
_GL setPos getpos (_Locations select _i)
if ((player distance _GL) < _dist) then {_atrocity = _i;_dist = player distance _GL}
_i = _i + 1
if (_i < count _Locations) then {goto"loopfindAtrocity"}
_SoundCandy = (_Messages select _atrocity)
_SoundCandy setpos getpos (_locations select _atrocity)
~3
deleteVehicle _GL
exit