Home   Help Search Login Register  

Author Topic: Using one script for many groups  (Read 619 times)

0 Members and 1 Guest are viewing this topic.

M_S_Holder

  • Guest
Using one script for many groups
« on: 25 Nov 2004, 07:00:10 »
I have a script that counts the number of men in an enemy AI squad and then respawns a man if the that number is less than 12.  It delays a few minutes, counts again, and adds another, does it again, and again, looping.

The script constantly keeps enemies for me to fight, but my problem is this:

How do I use just ONE script that can do this for many enemy AI squads?  For example, in the init box of the leader of each AI squad, how can I call the same script?

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Using one script for many groups
« Reply #1 on: 25 Nov 2004, 07:16:14 »
It will depend on how your script works exactly...

I'd suggest something like this:

Unit's init line
this exec "script.sqs"

Your script
_grp = (group _this)

...

"SoldierWB" createunit [(getpos pos), _grp, ""]
...

So that will assign the soldier to the same group as whatever the leader was in ;)

M_S_Holder

  • Guest
Re:Using one script for many groups
« Reply #2 on: 25 Nov 2004, 09:29:01 »
I know how to do that.

I'll try to be clearer:

I have six enemy groups named G1, G2, G3, G4, G5, and G6.

I also have six identicle scripts for each of these groups.  All six scripts do the same thing: they add a man every minute or so if the number is below 12.

How can I use just ONE script for all six groups?  I think it has something to do with _this select 1.  How does that work?

wait wait wait wait . . .

Okay, I think you actually did answer my question.
« Last Edit: 25 Nov 2004, 09:33:17 by M_S_Holder »

M_S_Holder

  • Guest
Re:Using one script for many groups
« Reply #3 on: 25 Nov 2004, 10:26:24 »
I wonder why this scvript doesn't work:
/////////////////////////////////////////////////////////
_gp = (group this)

#Loop
~1
?Count units _gp<12: goto "addmember"
goto "Loop"

#addmember
"SoldierEB" createUnit [getMarkerPos "barracks", _gp, "removeallweapons this", 0.5, "Corporal"]
goto "Loop"

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Using one script for many groups
« Reply #4 on: 25 Nov 2004, 10:41:00 »
group _this

not

group this
Plenty of reviewed ArmA missions for you to play

M_S_Holder

  • Guest
Re:Using one script for many groups
« Reply #5 on: 25 Nov 2004, 13:17:46 »
Thank you this works just fine, but I've another question about this:

Can "createunit" also create a t72 or a t80?  I know how createvehicle works, but I can't seem to create a fully crewed tank with createunit.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Using one script for many groups
« Reply #6 on: 25 Nov 2004, 20:17:54 »
I think you will need to create the tank and its crew seperately......then assign them to the tank and move them in.

assignAsDriver and moveInDriver for example.

You may need to name the tank also.


Planck
« Last Edit: 25 Nov 2004, 20:31:34 by Planck »
I know a little about a lot, and a lot about a little.

Dane

  • Guest
Re:Using one script for many groups
« Reply #7 on: 25 Nov 2004, 20:36:57 »
yeah like this...

tank1 = "T80" createvehicle getpos g1
"SoldierECrew" createunit [getpos g1, east1, "c1 = this", 1, "SERGEANT"]
"SoldierECrew" createunit [getpos g1, east1, "c2 = this", 1, "CORPORAL"]
"SoldierECrew" createunit [getpos g1, east1, "c3 = this", 1, "PRIVATE"]
c1 moveincommander tank1
c2 moveingunner tank1
c3 moveindriver tank1

g1 = a gamelogic or a marker, if marker it is getMarkerPos "g1"
east1 = the group the units are assigned to
c1,c2,c3 = the names of the vehicle crew

To spawn units in to a group you have to place a single unit on your map and place this in his initfield : east1=group this; deleteVehicle this.
« Last Edit: 25 Nov 2004, 20:43:51 by Dane »