Home   Help Search Login Register  

Author Topic: Grouplink Script  (Read 7963 times)

0 Members and 1 Guest are viewing this topic.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Grouplink Script
« on: 21 Nov 2002, 10:46:32 »
*NOTE: lastest attachment is further down the page*

This is the script that I wrote for Operation Lojack to control the enemy AI groups. It gives groups the ability to call other groups in for backup when they spot enemies.

I have modified it from the one I used in Lojack to be simpler for people to use in their own missions, plus I have given the script the ability to run on multiple groups at the same time.

The demo mission contains three east squads and three west squads, all of them running the grouplink script. You start out as a resistance soldier on a hill overlooking a town (you are friendly to both sides, so you can just watch the action). A west squad will attack the town, and a big death bowl will ensue, as both sides call their buddys into the fray.

I've balanced the groups on the map so that, sometimes the East will win and sometimes the West will win.

If you are not a scripter, or don't care how it works, and just want to see the script in action, you can skip the following and just download the attached demo mission.  ;)

Here is a flowchart of how the script works...
--------------------------------------------
Script Execution:

[[ge1,ge2,ge3],[ge1],gw1,3] exec "grouplink.sqs"

[ge1,ge2,ge3]  <- all of the groups that can be called for backup

[ge1] <--"static groups" - groups can call for backup, but cannot be called for backup - good for bases and towns

gw1 <--the "target group" (the one that the other groups check)

3 <--group behaviour 1=conservative, 2=balanced, 3=aggressive


Script Flow:

First, the script gathers groups that are checking the target group and cycles though them, checking how much the leaders know about each of the target group's members. If the leader of a group knows enough about one of the target groups members, the scripts pauses for a few seconds and then checks to make sure one of the members is still alive. If the group still has members, then the script passes to a second loop. The second loop calculates which of the other groups is closest to the one that needs backup. Once this is decided, the backup group is orders to a random spot near the position of the detected unit. Both the group that needs backup, and the group being called for backup are placed into a global array, so that other instances of the grouplink script can no longer access these groups. The script then waits for a time (15-60 seconds depecnding on the behaviour setting), and then runs through the detection process again. If the group still detects the target group they can then update the backup group with the position of the target group, or call in a different group that is closer.


ATTACHMENT HAD BEEN DELETED...please scroll down for the latest version.


« Last Edit: 22 Nov 2002, 05:56:08 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Grouplink Script
« Reply #1 on: 22 Nov 2002, 01:15:39 »
didnt find ny bugs  ;D xept maybe dat i tried it 10 times nd da americans always won so its not dat balanced  ;)  ;D

i was thinkin bout it - nd i wanna modify da script litle  ;) - wana make it wiser - i wil start workin on it tomorow i hope i wil make da script check da specialty of da group (like if it have a Vulcan in it) nd if so dis group wil b called if dere r choppers attackin  ;D my intention is dat dey wil call da most usefull reinfocments as long as dey r in less dan som range (not sure stil how much) wat do u think ?  ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Grouplink Script
« Reply #2 on: 22 Nov 2002, 02:10:10 »
The americans has an M1A1 and the Russians have a T-72, so yeah I supposed the map isnt too balanced. You could allways modify the tank that the americans have to even it out a bit :P


Modifying the script to check what type of units the various groups contain can be done, and would require some more loops that check the target group and backup groups for types. This would set the release of the script back a long time. I'm gonna release it in it's current form and maybe I'lll look into adding some fuzzy logic later.

« Last Edit: 22 Nov 2002, 02:13:10 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Grouplink Script
« Reply #3 on: 22 Nov 2002, 02:18:53 »
i think i wil convert da script  ;)  ;D so im startin my workin tomorow  ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Grouplink Script
« Reply #4 on: 22 Nov 2002, 05:54:50 »
New version attached. Fixes bug with groups not being able to detect vehicles - tank platoons/choppers/ect.

ATTACHMENT DELETED - SEE BELOW FOR LATEST VERSION

« Last Edit: 24 Nov 2002, 05:52:38 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Grouplink Script
« Reply #5 on: 24 Nov 2002, 05:51:36 »
Ok, I give in LCD. I was thinking last night (yeah I do that sometimes :) ), and I thought of a relatively easy way to get the groups so that they will only call in "appropriate" reenforcements.

Now, when a 12 man infantry squad runs into a couple of eastern soldiers on a patrol, they wont call in the M1A1's for backup. :P Instead they won't call backup at all. A squad will only call for backup if it is overmatched, by the squad it detects.

I've accompished this by writing a neat little subroutine into the script that "rates" a squad based on what vehicles/ect. they have.

Helicopters and planes are worth the most, followed by AA tanks, Tanks, APCs ,LAW soldiers and finally, soldiers. I'll be expanding the rating subroutine later to be more granular (right now an m60 gets the same rating as a T-80 - not too realistic)  :P

When a squad is severely overmatched, instead of running straight into their death, like before, they will retreat like sane little soldiers, and call for the nearest backup with an appropriate "rating". If there is no appropriate backup available, the squad wont call anyone. Instead, they will just retreat.

Here is the latest version. In this one I've added markers on the map that follow the various groups, plus I've added a radio command that will allow you to teleport anywhere on the map, using the "onmapsingleclick function.

attachemnt deleted - see lower thread for latest ver
« Last Edit: 04 Dec 2002, 07:07:38 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Grouplink Script
« Reply #6 on: 24 Nov 2002, 11:29:20 »
cool  ;D

i was thinkin also  :o  ;D

i decied 2 make a whole AI script  :o now this will take som time but it will happen (im prety much sure  ;)) so wat i wanna ask is if i can use parts of ur script in it ? u wil b in da credits of course  ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Grouplink Script
« Reply #7 on: 24 Nov 2002, 23:49:49 »
...so wat i wanna ask is if i can use parts of ur script in it...

Sure you can rape the code all you want, but you would probably get more satisfaction if you made it from scratch yourself.
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Grouplink Script
« Reply #8 on: 25 Nov 2002, 00:07:29 »
tanks

i know wat u meen  ;)

btw i like ur new script ver  :-*  ;)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Wires

  • Guest
Re:Grouplink Script
« Reply #9 on: 26 Nov 2002, 07:37:34 »
toadlife would it be possible to make a group call in multiple groups that, with a combined rating, match the enemy group they encounter? This could make for some interesting tacticle dicisions by the AI.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Grouplink Script
« Reply #10 on: 26 Nov 2002, 10:56:33 »
toadlife would it be possible to make a group call in multiple groups that, with a combined rating, match the enemy group they encounter? This could make for some interesting tacticle dicisions by the AI.

A minute ago, I thought that it would be hard to do that, but now that I've thought about it for a sec, it would only take a few changes in the routine that searches for backup groups.

If the group is severely over matched (a couple of tanks against an infantry squad), instead of going through the array of backup groups and picking just one group to call, it could find one group, add it to an array and add that groups rating to a variable, and then find another group do the same thing. It could then calculate the combined rating and decide if it is enough. If the two nearest squads were not enough, then it could fall back to the default routine - find the nearest group with an appropriate rating.

An situation where this might be helpfull, is one where an infantry squad happens upon a small armored squad (two BMP's and a T72 for example). If there were a couple of infantry squads with multiple LAW/AT soldiers near by, and a group of tanks far away, the group could call in the two squads, instead of a large group of tanks that is very far away.
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline Arctic

  • Members
  • *
  • In Utero
Re:Grouplink Script
« Reply #11 on: 26 Nov 2002, 18:06:38 »
I am recieving an error when I play! It says:

Code: [Select]
if |#|(count units gw6 > 0) then {{gw6m} setmarkerpos getpos leader gw6;} else {{gw6m} setmarkertype {empty}}': Error Unknown Operator
I am running v1.46 does that have anything to do with the error?

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Grouplink Script
« Reply #12 on: 26 Nov 2002, 19:57:19 »
The script wont work with 1.46. You need at least 1.85, or whatever version fvirst supported "while > do" and "in > then > else" commands. :P

The new prgramming finctions of Resistance are too usefull. Sorry!  :-[
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline Arctic

  • Members
  • *
  • In Utero
Re:Grouplink Script
« Reply #13 on: 26 Nov 2002, 20:15:18 »
Darn! It looks like Resistance will be appearing on my Christmas list this year ... ;)


Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Grouplink Script
« Reply #14 on: 04 Dec 2002, 07:08:59 »
New version, with the rating subroutine greatly improved. Now the ratings are based on the proper unit classes (thanks STT) and caculated accurately (they worked, but were a bit screwy before).

Soldiers = 1 point
Motorcycles = 1 point
Cars = 2 points
Jeeps = 5 points
Trucks = 5 points
LAW/AT/AA Soldiers = 10 points
APC = 20 points
Tanks = 50 points
Helicopters = 100 points
Planes = 100 points

You might ask 'Why in heck I would give points to regular vehicles?' Well, most of the time they would NOT get points, unless they have guns on them and those guns can be fired. A jeep with a machine gun would get 5 points, where as a regular jeep would get none. This will make sure that addon vehicles with weapons that are based on the car/truck/jeep classes get points. I'm sure there are some addons like that out there.

A big improvment in the rating routine, is that is it checks if the vehicle has weapons and they can be fired. A BMP/Tank with a blown up turret isn't much of a threat. Before, soldiers would retreat from a BMP/Tank even if it was useless, and useless BMPs/Tanks would rate themselves highly even though they couldn't fire their weapons. All that is accounted for now.

The new demo mission displays the ratings of the various groups as they detect other groups and call for backup like so....


Calling for help[/i]


Not calling for help[/i]

ATTACHMENT DELETED - SEE BELOW FOR LATEST VERSION
« Last Edit: 05 Dec 2002, 11:45:03 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.