Jump to content
Sign in to follow this  
Monsada

UPSMON - Urban Patrol Script Mon

Recommended Posts

"The new script is running in parallel, spawn does not wait for it to be done, instead spawn returns a Script handle. "

http://community.bistudio.com/wiki/spawn

I don't know how low level it runs but in my testings I noticed that spawning functions seems to run in parallel, principal process don't wait to finish it and continues runing, the result was more better performance than doing it with call. This is much util more over ordering units of group doing things like animations, getin, getout of vehicles and more commands that requires a litle sleep for good completion like enableAI. You can do the order and continue the principal process, each unit will do the order runing it in "parallel".

In the only I don't noticed nothing is spawning the enterely script in the init of leader group, as u could see in the sample. I tried it with 20 platoons spawning UPSMON and another time with EXECVM, I noticed no diference, I think i read somewhere that each units runs in parallel, same as spawn.

execVM is basically "turn this file into code and then spawn it", while spawn just spawns the code given to it. Same deal with exec and call, except it calls instead of spawning a new "thread" (not an actual thread though, but it does run in "parallel". What I mean by "parallel" yet not true parallel is that the engine will basically alternate between the scripts and, as you said, will not wait for one to finish, so if one script is sleeping or waiting another can run in the meanwhile, and if multiple ones are running the engine will handle which ones get to run when so that they all get executed rather than 1 script freezing everything. However, as far as I know you will never have more than 1 script running on more than 1 CPU at any given time. It's kinda like running a multi-threaded application on a single CPU - it's just something that helps making things more logical, but doesn't actually help performance.

Share this post


Link to post
Share on other sites
Thanks for the awesome script :0 I use this one now for my MCC (mission generator ). However i would like some more details on the usage of vehicles.

Under what conditions are vehicles used? I havent seen them do that so i am curious.

Platoons will use any eart vehicle, if people want I will do the same with helicopters for doing paradrops near objectives.

For implementing only u need is putting empty vehicles in map, like players IA will use them if enemy is far away, by the distance needed for using vehicles they will use them when called for reinforcement.

U can see this in the sample mision http://www.megaupload.com/?d=9YRQG24O

Why Ias get in vehicles?

When reinforcement is called (KRON_UPS_reinforcement = true; put in the trigger of detection) Platoons that were far away get the position of enemies, then check the distance to the closest target, if the distance is more than ( close_enouht + safe_dist ) * 1.2 is considered far and leader look for any vehicle near (cars, tanks, trucks), if there is any all platoons reserve positions in and get in. They will use vehicles of civilians too if they need!

---------- Post added at 02:05 AM ---------- Previous post was at 01:53 AM ----------

execVM is basically "turn this file into code and then spawn it", while spawn just spawns the code given to it. Same deal with exec and call, except it calls instead of spawning a new "thread" (not an actual thread though, but it does run in "parallel". What I mean by "parallel" yet not true parallel is that the engine will basically alternate between the scripts and, as you said, will not wait for one to finish, so if one script is sleeping or waiting another can run in the meanwhile, and if multiple ones are running the engine will handle which ones get to run when so that they all get executed rather than 1 script freezing everything. However, as far as I know you will never have more than 1 script running on more than 1 CPU at any given time. It's kinda like running a multi-threaded application on a single CPU - it's just something that helps making things more logical, but doesn't actually help performance.

Now I agree with u but disapoint in one thing, in my case I have some functions that requires sleeps for working properly, moreover this functions are used in any soldier of platoon, this means a sleep for each soldier and the result was an execution too slow on the main script, thanks to spawning functions I can run this ones in "parallel" while main script continues executing and dont wait for this sleeps, in this case I can see performance is much more better. I spect that spawn functions will use in low level new threads but this is only work of bohemia if it does or not. In Arma 2 has said that gets better profit of multiple cores I think in some way this will be doing, maybe someone of bohemia could respond to this better and get of any doubt.

I propose u take a test with debug mode = 1 execute mision test, next do another test on a copy of the mission but changing all spawn for calls, then u will can see what I'm saying, version with spawn runs more faster and smother than version with calls.

Edited by Monsada
adding more explanation

Share this post


Link to post
Share on other sites
Platoons will use any eart vehicle, if people want I will do the same with helicopters for doing paradrops near objectives.

Yes! Please! Pretty Please! PORFIS!!! :D

Splicer.

Share this post


Link to post
Share on other sites
Yes! Please! Pretty Please! PORFIS!!! :D

Splicer.

jajajaja ok, then I have two new objectives, respawn and air transport and combat. I like it. I need something in change, a video in conditions of how UPSMON works.

Edited by Monsada

Share this post


Link to post
Share on other sites

Now I agree with u but disapoint in one thing, in my case I have some functions that requires sleeps for working properly, moreover this functions are used in any soldier of platoon, this means a sleep for each soldier and the result was an execution too slow on the main script, thanks to spawning functions I can run this ones in "parallel" while main script continues executing and dont wait for this sleeps, in this case I can see performance is much more better. I spect that spawn functions will use in low level new threads but this is only work of bohemia if it does or not. In Arma 2 has said that gets better profit of multiple cores I think in some way this will be doing, maybe someone of bohemia could respond to this better and get of any doubt.

I propose u take a test with debug mode = 1 execute mision test, next do another test on a copy of the mission but changing all spawn for calls, then u will can see what I'm saying, version with spawn runs more faster and smother than version with calls.

People have already tested to see if things run in parallel by taking 2 scripts that use and change the same variable in a single command, and they never managed to create any artifacts that would happen if the scripts actually did run in true parallel. For example if you run the following script twice (assuming number was set to 0 before spawning the script twice):

for "_i" from 1 to 10000 do
{
  number = number + 1;
};

If the script would actually run in parallel on 2 CPUs then you could have a situation where both scripts would read the same number (say 0) and set it to number+1 (say 1). Then after both scripts finish running you will possibly have number Actually smaller than 20,000.

However in Arma 2 you will always get 20,000, which means the scripts never run in parallel - at best one script gets interrupted so that the other can run, and never in the middle of a single command. Actual windows threads can get interrupted in the middle of such a command and will be able to cause the issue of the total sum actually ending up as less than 20,000.

Spawning scripts does do one good thing - it allows you to sleep/wait in one script while another runs and have the engine manage which scripts runs when instead of having to handle it yourself, which is why unrelated scripts should pretty much always be spawned rather than called.

Share this post


Link to post
Share on other sites
People have already tested to see if things run in parallel by taking 2 scripts that use and change the same variable in a single command, and they never managed to create any artifacts that would happen if the scripts actually did run in true parallel. For example if you run the following script twice (assuming number was set to 0 before spawning the script twice):

for "_i" from 1 to 10000 do
{
  number = number + 1;
};

If the script would actually run in parallel on 2 CPUs then you could have a situation where both scripts would read the same number (say 0) and set it to number+1 (say 1). Then after both scripts finish running you will possibly have number Actually smaller than 20,000.

However in Arma 2 you will always get 20,000, which means the scripts never run in parallel - at best one script gets interrupted so that the other can run, and never in the middle of a single command. Actual windows threads can get interrupted in the middle of such a command and will be able to cause the issue of the total sum actually ending up as less than 20,000.

Spawning scripts does do one good thing - it allows you to sleep/wait in one script while another runs and have the engine manage which scripts runs when instead of having to handle it yourself, which is why unrelated scripts should pretty much always be spawned rather than called.

Great test Galzohar, this means that the only reason for employing spawn functions is when doing sleeps, interesting, is good to know.

Never will go to bed without learning something.

Thanks for the info ;)

Share this post


Link to post
Share on other sites
Platoons will use any eart vehicle, if people want I will do the same with helicopters for doing paradrops near objectives.

For implementing only u need is putting empty vehicles in map, like players IA will use them if enemy is far away, by the distance needed for using vehicles they will use them when called for reinforcement.

U can see this in the sample mision http://www.megaupload.com/?d=9YRQG24O

Aaaah ok. Well i am using your upsmon not from static missions but they spawn into zones (which are also made on the fly) (mcc).

I am not realy using the reinforcements because the mission maker simple moves a zone so all the units attached to it go on the move. So we make reinforcements work like that.

Now to my questions:

-Apart from reinforcements do units use vehicles if they are empty if they need to cross a large piece of terrain?

-Vehicles are spawned during mission and in no way will there be a static list with all vehicles available. Do the units scan for possible vehicles all time?

My best hope would be the AI unit is for any reason to cross a large piece of terrain. it can even be because the zone is 1 by 1 km. At any point they see a usable transport they go use it?

Share this post


Link to post
Share on other sites
Aaaah ok. Well i am using your upsmon not from static missions but they spawn into zones (which are also made on the fly) (mcc).

I am not realy using the reinforcements because the mission maker simple moves a zone so all the units attached to it go on the move. So we make reinforcements work like that.

Now to my questions:

-Apart from reinforcements do units use vehicles if they are empty if they need to cross a large piece of terrain?

-Vehicles are spawned during mission and in no way will there be a static list with all vehicles available. Do the units scan for possible vehicles all time?

My best hope would be the AI unit is for any reason to cross a large piece of terrain. it can even be because the zone is 1 by 1 km. At any point they see a usable transport they go use it?

First I must say that lider cheks for vehicles is he is far away from enemy, that means that u can spawn vehicles in run time. The problem for u is the distance, leader uses next formula for cheking vehicles

_dist >= ( _closeenough + KRON_UPS_safedist )*1.2) 

the problem then is the distance for comunicating and sharing the enemy, if platoon not know enemy will not check and if is far from sharedist from enemy will not known about them, u can set next parameter to put the distance u need in meters.

KRON_UPS_sharedist = 1000;

chek it and tell me.

Share this post


Link to post
Share on other sites

Versión 4.2.5 Implementada

Changes in version:

//Version: 4.2.5

// Added

// Air transport

// Paratroop air transported units

// Improved comunications

// Modificaciones:

// Updated for an action radio of 1000 meters or avove.

// Added some translations to english

Video:

Share this post


Link to post
Share on other sites

New version available

//Version: 4.2.6

// Added

//

// Modified:

// Fixed bug that leaves a soldier in front of vehicle afte geting out.

// Fixed bug that made AI to disenbark from heli before arriving objective.

http://www.megaupload.com/?d=Y52DS4ZN

http://www.simulacion-esp.com/v3/index.php?app=core&module=attach&section=attach&attach_id=1435

video:

Edited by Monsada

Share this post


Link to post
Share on other sites

Hi Monsada,

GREAT! But the website says that the file is temporarily unavailable...

Splicer.

Share this post


Link to post
Share on other sites
Hi Monsada,

GREAT! But the website says that the file is temporarily unavailable...

Splicer.

Yes, I don't know why, I put another link.

Share this post


Link to post
Share on other sites

Hi Monsada. Thanks for the great script, I am having tons of fun playing my missions with it.

I tried the last version, 4.2.6, but my units still paradrop early from the heli. Way short of target marker. Is there any parameter I can use to make them jump correctly?

thanks.

Share this post


Link to post
Share on other sites

Hi Monsada. First i want to thank you for that great script. Most things are working very well. I got two questions:

1. Is it possible to set the paradrop more accurate? (Heli flys in more height and don´t drop so early?

2. Usually we play as BLUFOR against OPFOR. If i use the german BWMod-Soldiers instead of USMC the script don´t work. They don´t call for reinforcement - i think they don´t see the BWMod-Soldiers as an real enemy. Of course the russians shoot at them, but they dont say "Enemy detected". If i change the german Soldiers to USMC and they enter the sensor it starts the heli for reinforcement. The BWMod soldiers don´t. Can i add them somewhere in the script to be detected as BLUFOR, too?

Share this post


Link to post
Share on other sites

Hi MadMike, I'm glad UPSMON likes u.

Well

1. Is it possible to set the paradrop more accurate? (Heli flys in more height and don´t drop so early?

Is a good idea, I will implement it in next revisión:

KRON_UPS_flyInHeight=80;

Then u will can put what u want.

2. Usually we play as BLUFOR against OPFOR. If i use the german BWMod-Soldiers instead of USMC the script don´t work. They don´t call for reinforcement - i think they don´t see the BWMod-Soldiers as an real enemy. Of course the russians shoot at them, but they dont say "Enemy detected". If i change the german Soldiers to USMC and they enter the sensor it starts the heli for reinforcement. The BWMod soldiers don´t. Can i add them somewhere in the script to be detected as BLUFOR, too?

There are 3 tipes that is recognized, BLUEFOR, OPFOR and resistance.

Well for resistance AI's UPSMON needs to know who is the enemy, for it u have this parameter array:

KRON_UPS_Res_enemy = [east];

If u want resistance will be enemy to all put [east, west] instead, maybe this is the problem, if it not correct the problem, then may be a bug, please send me your mission to chs.monsada@gmail.com and explain me how to test it. I will correct the bug.

---------- Post added at 12:09 PM ---------- Previous post was at 11:53 AM ----------

Hi Monsada. Thanks for the great script, I am having tons of fun playing my missions with it.

I tried the last version, 4.2.6, but my units still paradrop early from the heli. Way short of target marker. Is there any parameter I can use to make them jump correctly?

thanks.

Hi bobrock,

thats ok, Paradrop will do in a random distance from 0.2 * (safedist+closeenought), why? I don't want AI always paradroop on enemy because of fire and dinamice result, playes won't know when paradrop AI and don't know if they will land.

I will implement a parameter KRON_UPS_paradropdist.

AI will paradrop in a random distance with the max put in this parameter. Doing this u will fix it at 0 and other players as mine would put 400 meters.

If there is no troubles will be post in next days

Share this post


Link to post
Share on other sites

Hi Monsada! Thanks for your fast response.

First: The parameters KRON_UPS_flyInHeight and KRON_UPS_paradropdist are a very nice idea! :)

Second: Maybe you can place the units i told you in your testmission and check if your ai-members will call for reinforcement and the "enemy detected"-parameter will be given. For me they still say "under fire by unknown target" or something like that.

Here is the link to the units (BWMod-Soldiers):

http://www.armaholic.com/page.php?id=7955

Thx for your help!!!

Edit: The BWSoldiers are not RES - in the Editor they are available under BLUFOR (Bundeswehr).

Edited by MadMike[Brig2010]

Share this post


Link to post
Share on other sites

i will check it, dont worry, if there is a problem i will find and correct it.

Share this post


Link to post
Share on other sites

@Monsada

I found out something really strange. The script works even very well with the BWMod-Soldiers - but only if the players are ai-controlled. If the Soldiers are made "playable" in the editor (like my team of 5 soldiers) and are controlled by human players the ai don´t call "enemy detected" and no reinforcement is coming.

Why don´t they detect "my squad" as an enemy? Maybe its because i gave them name p1, p2, p3, p4, and so on? I do this because of the revive_script.

Maybe you have an idea?

Edited by MadMike[Brig2010]

Share this post


Link to post
Share on other sites
@Monsada

I found out something really strange. The script works even very well with the BWMod-Soldiers - but only if the players are ai-controlled. If the Soldiers are made "playable" in the editor (like my team of 5 soldiers) and are controlled by human players the ai don´t call "enemy detected" and no reinforcement is coming.

Why don´t they detect "my squad" as an enemy? Maybe its because i gave them name p1, p2, p3, p4, and so on? I do this because of the revive_script.

Maybe you have an idea?

Ahhh then the problem is this!! UPSMON is for AI groups, no have sense with players, upsmon solves the relation between squads of AI, is made for gaving enemy AI more global intelillence and making easy mision editing.

in any case u could put as a player in a UPSMON squad but not into leader, the leader must be an AI.

---------- Post added at 07:49 PM ---------- Previous post was at 07:46 PM ----------

Version: 5.0.0

Well I have implemented the upgrades demanded, closed version 4

// Version: 5.0.0

// Added

// KRON_UPS_flyInHeight: Height that heli will fly this input will be randomiced in a 10%

// KRON_UPS_paradropdist: Max distance to target for doing paradrop, will be randomiced between 0 and 100% of this value.

// parameter "fortify" makes leader order to take positions on nearly buildings at distance 100 meters near leader,

// squads with fortify will ignore "MOVE" rol.

// Modified:

// Fixed bug that eventually stoped hely when paradrops done.

Downloads

http://www.megaupload.com/?d=3EC1FQQG

http://www.simulacion-esp.com/v3/index.php?app=core&module=attach&section=attach&attach_id=1439

Share this post


Link to post
Share on other sites

So when the only BLUFOR members are me and my friends - the OPFOR will never call for reinforcement (heli)?

So this script only works when ai fights against ai? Isn´t it possible that the ai detect enemies which are human controlled (because we only play with disabled ai)?

I hope you understand? Its usually me and 4 friends on the BLUFOR side against OPFOR which is completely controlled by ai. But they dont recognize us as enemies.

Edited by MadMike[Brig2010]

Share this post


Link to post
Share on other sites

May be I don't understand u.

scritp runs in leader AI only, enemies may be players or AI aswell. If script runs in opfor AI must recognie u as enemy. Is estrange what u say Please send me your mision or I will not can help u

Edited by Monsada

Share this post


Link to post
Share on other sites

Hey Monsada.

Thanks for all the info and effort with version 5.00.

I'm gonna give it a try right now.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×