OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: ido on 18 Sep 2006, 11:49:16
-
I have made the following script that runs in the background of my mission until a hostage is secured, it does 9 iterations every 5 seconds:
_ogroup = [uo1,uo2,uo3,uo4,uo5,uo6,uo7,uo8,uo9]
_sgroup = [us1,us2,us3,us4,us5,us6,us7,us8,us9]
#START
~5
_i=0
#LOOP
_officer = (_ogroup select _i);
_sargent = (_sgroup select _i);
?!(alive hostage) : goto "EXIT_DEAD"
?((_officer distance hostage)<=(5)) : goto "EXIT_O"
?((_sargent distance hostage)<=(5)) : goto "EXIT_S"
_i = _i+1;
?_i==9 : goto "START"
goto "LOOP"
#EXIT_O
"1" objStatus "DONE"
hostage setCaptive false
cap_freed = TRUE
[hostage] join group _officer
exit
#EXIT_S
"1" objStatus "DONE"
hostage setCaptive false
cap_freed = TRUE
[hostage] join group _sargent
exit
#EXIT_DEAD
"1" objStatus "FAIL"
exit
what will be the impact on FR. and on the same issue what will be the impact if I make the island full with enemy ambushes ?
-
Rather lagy, I would suppose :o , however, depends on what kind of computer you are running :confused:. Is this for MP or SP?
-
MP, anyway can I improve it somehow ? I have a hostage moving around all the time and it is possible that a freindly heli will be in his vicinity so I don't want the heli to set him free only the two groups in the unit arrays
-
Well, i can't tell you how much impact it will have onto the F/R, but i can help
you with the improving thingy. ;)
_osgroup = [uo1,uo2,uo3,uo4,uo5,uo6,uo7,uo8,uo9,us1,us2,us3,us4,us5,us6,us7,us8,us9]
#LOOP
~5
?!(alive hostage) : goto "EXIT_DEAD"
"if (_x distance hostage) <= 5 then {{1} objStatus {DONE}; hostage setCaptive false; cap_freed = true; [hostage] join _x; exit}" forEach _osgroup
goto "LOOP"
#EXIT_DEAD
"1" objStatus "FAIL"
exit
I've made one array out of your two arrays, since you don't need two arrays for that in your case.
The if line checks if anybody of the script is in range of 5 meters to the hostage and if so, the hostage will check this
guy's group and objective will tick off and cap_freed will be true and script exits.
To make it multiplayer compatible, you will need to tell some more details about how you execute the script, or where
it is running (client/server), and you should ask a mod to move it over to mp scripting forum also.
~S~ CD
-
Chris thanx,
I guess I can make it with only one array, the two arrays are leftovers from trail and error :P
for your question:
it runs at the begining of the mission using a trigger that has TRUE in its condition...
the mission has one more repeating trigger that checks if the heli found the hostage, follows him (using a follow script) if it does and if it loses him it'll go back to its waypoints. and many more repeating triggers for enemy patrols in various locations on the map.
so for now worse case scenario is having this script and the follow script running in the background.
I've test ran it with 3 other players yesterday and it was pretty laggy, but I don't know if it was because of all of the scripts & triggers or because that the map is packed with units (or maybe a combination of them both)
I tried to improve it a little today by removing a smokescreen arty that ran in the start of the mission and reducing the HE arty to minimum, when checking it in single player the FR got alot better, but then again we experienced the lags long after the arty stopped firing
-
Lots of units will make you laggy.. but it all depends on your computer and the server.
Scripts and triggers (especially looping ones) can put a lot of pressure on a computer, and especially a server. Think of games that have a lot going in them, with lots of scripts. CTI's.. very laggy most of time. Also maps like crime city is a very laggy map, because there is a lot of triggers and scripts running.
Making a good mission would also mean making a lag-less one to :P
-
Ok, just wanted to share I found a way around the endless loop by making an AddAction to the hostage and running the script once when someone uses the action. the thing is I saw this remark on COMREF:
"When a player uses the action, the attatched script will only be run on that player's computer. "
does it mean that if the player is not a group leader, the leader will not know the hostage joined his team ?
-
Well, basically the join command should be recognized global, wherever it has been
executed.
If you do something else inside the addaction script like for example say: cap_freed = true
You need to broadcast the new status of cap_freed by using publicVariable.
e.g:
cap_freed = true
publicVariable "cap_freed"
If you have a trigger in your mission with the condition: cap_freed
this trigger will become active everywhere, after exuting these two lines
somewhere locally.
However, this is multiplayer editing and you should let the thread get moved into the
right section of the forums - best you send an IM to a moderator of this forum section.
That way more people who know about multiplayer editing can give you answers and
later other people can easier find this thread when searching for something like this. ;)
btw - at start of the mission there's happening a little bit more than your scripts etc., because
of initialisation of each object.
If you take a look into your mission.sqm file you will see a good overview of what will be executed
at missionstart. Now adding a smokescreen arty or other createVehicle/camcreates would off course
influence your framerate for a while.
~S~ CD