Patrol

SS 2 Forum für Scripte und den Mapeditor.
Antworten
Benutzeravatar
Comrade Kimo
Hauptfeldwebel
Hauptfeldwebel
Beiträge: 479
Registriert: 03.09.2020, 03:48
Wohnort: Sharqia
Kontaktdaten:

Patrol

Beitrag von Comrade Kimo »

Greetings, gentlemen

I need some help regarding patrol scripts; thanks to my friend I was able to use a beginner script for patrolling but it's not as effective. It is explained on our channel in the video below




As I played the original missions of Sudden Strike 2, I saw some patrol script where units patrol several points and when all units of the designated group is at that point they will move on to the next one, it's something to do with the "add patrol locations to group X" - "Shift patrol locations to group X - "Clear patrol locations to group X", which I have no idea how to use.

Any answer would be much appreciated, thanks in advance.
Footage from the bloody frontlines on Youtube!

https://www.youtube.com/@SuddenStrike_HQ/videos

Bild


military9
Benutzeravatar
Comrade Kimo
Hauptfeldwebel
Hauptfeldwebel
Beiträge: 479
Registriert: 03.09.2020, 03:48
Wohnort: Sharqia
Kontaktdaten:

Re: Patrol

Beitrag von Comrade Kimo »

Anyone? :cry:
Footage from the bloody frontlines on Youtube!

https://www.youtube.com/@SuddenStrike_HQ/videos

Bild


military9
Benutzeravatar
Gareth
Hauptfeldwebel
Hauptfeldwebel
Beiträge: 472
Registriert: 31.07.2006, 01:40
Wohnort: nicht mehr Dortmund
Kontaktdaten:

Re: Patrol

Beitrag von Gareth »

If noone else answers then I will try. What a pity that gehtnix isn't around anymore. He was such a scripting wizard and could have helped you much better than I can...

The kind of patrol that you described should be possible by changing AI locations for the patrol group each time 100% of the group have reached a patrol location. But the script functions you mentioned provide another way of scripting a patrol. Each group can have a list of patrol locations.
add patrol locations for group - defines a pair of locations and adds them to the list, If you set different zones the patrol group will split up and advance to both zones
clear patrol locations for group - deletes the list of patrol locations
shift patrol locations for group - sets the next pair of patrol locations from the list as AI_LOC1 and AI_LOC2, If the last pair is reached then the patrol locations that were defined first are used again
I made a little example mission to demonstrate add and shift. Map sources are for vanilla SSRW normal scheme. The patrol group A1 starts in zone 1, splits up and moves to zones 2 and 3, then to zones 4 and 5, then to zone 6 and back to zone 1 again. AI behavior is infantry defend location, AI group is A0 and AI location is 1. I have used a cell to make sure that shifting the patrol locations only occurs once while units are in a zone. You will notice that the soldiers don't always advance to the nearest of the next two patrol locations but will choose one of the zones by random. So after splitting the group up it might be better to unite the group in one location before sending them to two different locations again.
Dateianhänge
map.000.zip
Patrol Demo
(19.18 KiB) 147-mal heruntergeladen
Free Ukraine from russian aggression!
Benutzeravatar
Comrade Kimo
Hauptfeldwebel
Hauptfeldwebel
Beiträge: 479
Registriert: 03.09.2020, 03:48
Wohnort: Sharqia
Kontaktdaten:

Re: Patrol

Beitrag von Comrade Kimo »

Thank you very much for this. But I understand nothing in cells and mathematical operations, can this be carried out just as fine without one? I also don't really plan for splitting the patrol group into different locations, just all the group going to the same location all together. If you could make a script about it then it would be great help.

Can you also please explain in what order you put the locations in the condition?
Dateianhänge
2024-07-09_21-42-01.png
2024-07-09_21-42-01.png (25.52 KiB) 5698 mal betrachtet
Footage from the bloody frontlines on Youtube!

https://www.youtube.com/@SuddenStrike_HQ/videos

Bild


military9
Benutzeravatar
Gareth
Hauptfeldwebel
Hauptfeldwebel
Beiträge: 472
Registriert: 31.07.2006, 01:40
Wohnort: nicht mehr Dortmund
Kontaktdaten:

Re: Patrol

Beitrag von Gareth »

Cells and mathematical operations are not so hard to understand. A cell is like a variable in a programming language or in mathematics. You can store a number in a cell by using "let cell contain value". I have used this in my example to identify the phase that the patrol script has reached. Think of the cell as a piece of paper for taking notes about things you need to remember. I want to remember the patrol phase.
I'll try to explain script by script.

Step 1: If the mission has just started then the screen is moved to zone 1 (for the user to be able to watch the units move). Also the list of patrol locations is prepared. After this the list looks like this:
2-3, 4-5, 6-6, 1-1
Exlude this condition is used because this script won't be needed anymore.

Step 2: If 5 seconds have passed since the mission started then "Start patrol..." is printed to the screen and the number 1 is stored in cell C_0.
The value 1 tells me that patrol phase 1 is the current patrol phase.
Please note: This meaning of the value is not predefined by Sudden Strike. It is my personal definition to be used in this example. In another mission I could use a different interpretation of value 1.
This script is not needed anymore so: exclude this condition.

Step 2, 2nd script: If all units of my patrol group are in zone 1 AND cell C_0 contains the number 1 then a message for the user is displayed. A new number is stored in cell C_0 showing that patrol phase 1 has passed. Now I need to remember that phase 2 is the current phase, so I store number 2 in C_0. Last but not least I shift patrol locations for the patrol group. This sets AI locations for the group to zone 2 and zone 3.
At this point I can explain why I use the cell value to represent the patrol phase. If I didn't use C_0=1 as part of the condition then the script would be triggered just by the whole group being in zone 1. This would shift patrol locations to zones 2 and 3. Now the soldiers start moving but it will take some time until the first soldier leaves zone 1. So the whole group is still in zone 1. And bang! The script is triggered again and patrol locations are shifted again, this time to zones 4 and 5.
In my version this can't happen because the number 1 stored in C_0 is part of the condition. After the first time being triggered the number changes to 2 and the whole condition doesn't hold anymore even if still 100% of the group are in zone 1. I hope you understand this. If not feel free to ask.

Step 3: As the group has been split up between zones 2 and 3 I have to test both zones for presence of soldiers from the patrol group. If at least one of them is in zone 2 AND at least one of them is in zone 3 AND the value contained in C_0 is 2 (meaning that phase 2 is the current patrol phase) then a message is displayed, C_0 gets the new value 3 (patrol phase 3 has been reached) and patrol locations are shifted again to the next pair of locations in the patrol list: zone 4 and 5.

Step 4: Mostly the same as step 3. If soldiers from the patrol group are in zone 4 AND in zone 5 and the current patrol phase is phase 3 (number 3 is contained in C_0) then a message is displayed, C_0 is set to number 4 (patrol phase 4 has just begun) and patrol locations are shifted once again. As the next pair has two identical numbers (6-6) the group's AI locations are both set to zone 6. This means that all group members will now move to zone 6 and unite there.

Step 5: If the patrol group is united again in zone 6 AND C_0 contains number 4 (patrol phase 4 is the current phase) then a message is displayed, cell C_0 is set back to number 1 (in order to start the patrol again) and the group's patrol locations are set to the last pair in the list of patrol locations (1-1).

When the patrol group arrives there the condition in Step 2 script 2 holds again and the whole patrol is started over.
Free Ukraine from russian aggression!
Benutzeravatar
Gareth
Hauptfeldwebel
Hauptfeldwebel
Beiträge: 472
Registriert: 31.07.2006, 01:40
Wohnort: nicht mehr Dortmund
Kontaktdaten:

Re: Patrol

Beitrag von Gareth »

Comrade Kimo hat geschrieben: 09.07.2024, 20:12 But I understand nothing in cells and mathematical operations, can this be carried out just as fine without one? I also don't really plan for splitting the patrol group into different locations, just all the group going to the same location all together. If you could make a script about it then it would be great help.
I made two more examples (mis.001 and mis.002) in which the patrol group does not split up. In mis.001 I use cells again, this time the value of cell C_0 represents the number of the zone that will be the next destination.
In mis.002 the cells are replaced by a timer. Perhaps you are more comfortable with this version. :wink:
You might want to compare both variants. They are very similar so if you understand the version with timer you might as well understand the cell version. Cells are such a flexible tool. Have you noticed the function "add number of units in group to cell" for example? You could add the number of units in certain groups to a cell, then ask If the cell contains less than 100 (meaning the groups consist of less than 100 units) and if this is true then send some reinforcements. I really recommend to play around with them.
Comrade Kimo hat geschrieben: 09.07.2024, 20:12 Can you also please explain in what order you put the locations in the condition?
I added the locations in the same order in which the group should visit them.
I had planned for the group starting in zone 1, then going to zones 2 and 3, then 4 and 5, then 6 and back to 1.
That is why the order is as it is seen in your screenshot: 2-3, then 4-5, then 6, then 1. Zone 1 is added as last because the group is already in zone 1 at mission start. So patrol locations need to be shifted first to zones 2 and 3.
The conditions used in the other scripts are corresponding with this order.
Dateianhänge
map.000.zip
(27.82 KiB) 153-mal heruntergeladen
Free Ukraine from russian aggression!
Benutzeravatar
Comrade Kimo
Hauptfeldwebel
Hauptfeldwebel
Beiträge: 479
Registriert: 03.09.2020, 03:48
Wohnort: Sharqia
Kontaktdaten:

Re: Patrol

Beitrag von Comrade Kimo »

I absolutely appreciate your help, thank you very much comrade military9
Footage from the bloody frontlines on Youtube!

https://www.youtube.com/@SuddenStrike_HQ/videos

Bild


military9
Antworten

Zurück zu „Sudden Strike 2 Mapeditor / Scripte“