Home   Help Search Login Register  

Author Topic: Creating Groups of Infantry  (Read 3061 times)

0 Members and 1 Guest are viewing this topic.

Mike

  • Guest
Creating Groups of Infantry
« on: 01 Oct 2002, 08:07:24 »
I want to create groups of maybe 6-8 infantry (Officer,Soldier,LAW,LAW,Soldier,MachineGunner,Soldier,Medic) at a gamelogic then have then the group move to another gamelogic. I have a general idea on how I could go about doing this, but I haven't used createunit yet and I dont know how to wright out the group move to gamelogic..

Basically to have ongoing small arms fire and not create too much lag.. All I can do now is put all the groups in the map and they sit there until their waypoint is unlocked.. Makes the game slow down a lot..

Thanks to any of u scripting wizzards that could help me  :cheers:
« Last Edit: 11 Oct 2002, 03:45:40 by Mike »

Backoff

  • Guest
Re:Creating Groups of Infantry
« Reply #1 on: 01 Oct 2002, 13:21:17 »
If you are courageous enough, you can try to use my create squad script  :D

You will find it here with a readme.txt .

Hope this helps

Mike

  • Guest
Re:Creating Groups of Infantry
« Reply #2 on: 02 Oct 2002, 01:47:24 »
wow thats some pretty crazy stuff u got there  ;D Im sure ill figure out what I need  :D


Thanks !!  :cheers:

Mike

  • Guest
Re:Creating Groups of Infantry
« Reply #3 on: 02 Oct 2002, 04:20:57 »
Ok once I read the readme it was all clear.. How can I get the units I spawn into the game to move to a certian point (gamelogic?) so they can do the attacking?

and to call script more than once should I make another script that I execute from the game that has:

[WestMechInfSquad, getpos MyGameLogic, groupAlpha, groupBravo, "mount", 1, "CORPORAL"] exec "createsquad.sqs"
CreateSquadRunning = True
@!CreateSquadRunning
[WestInfSquad, getpos MyGameLogic, groupAlpha, groupBravo] exec "createsquad.sqs"
CreateSquadRunning = True
@!CreateSquadRunning

? or can you exec scripts from scripts? im not too script smart yet ;)
« Last Edit: 02 Oct 2002, 04:25:39 by Mike »

Backoff

  • Guest
Re:Creating Groups of Infantry
« Reply #4 on: 02 Oct 2002, 22:16:14 »
Hi Mike,

I'm very glad to hear that you understood my bad english in the readme.txt  ;)

The script will output two array variables after its execution:

NewVcl
NewSquad

NewSquad will contain all soldiers created by the scripts. All these soldiers will be on the same group and the leader of this group is always the first element in the NewSquad array. So, to give him the order to move to a game logic position, just use this code when the createsquad finished:

group(NewSquad select 0) move getpos MyGameLogic

that's it... if you look at the demo mission provided with the script, you'll find the code i have mentionned above.

About the multiple script call, you can make it as you wrote, in the same script. Basically, the createquad.sqs script is intended to be called from another script. In my demo mission, there is a script named war.sqs. This script call the createsquad.sqs several times.

Hope this answered your questions  :)

***edited***
for the multiple script call, it would be better to set the CreateSquadRunning to True just before the script call:

CreateSquadRunning = True
<script call>
@!CreateSquadRunning
« Last Edit: 02 Oct 2002, 22:52:39 by Backoff »

Mike

  • Guest
Re:Creating Groups of Infantry
« Reply #5 on: 02 Oct 2002, 22:19:31 »
Yup everything is clear.. Thanks again ;)  :cheers:


just one more question  ;D

How do I deletevehicle all these units.. I want to make it so when u leave far enough away from the old units they get deleted making it so the game wont lag up more and more.. (create as I go, delete as I leave theory) Can I name the units taht I create.. or do they have a name allready? Or can I do something like deletevehicle NewSquad   ?  But that would probably delete everyone if it worked.. Any sudgestions on the best meathod to delete?
« Last Edit: 02 Oct 2002, 22:27:11 by Mike »

Backoff

  • Guest
Re:Creating Groups of Infantry
« Reply #6 on: 05 Oct 2002, 13:24:55 »
Hi Mike,

If you want to delete all created units, use this:

"deleteVehicle _x" foreach NewSquad
"deleteVehicle _x" foreach NewVcl

But Keep in mind that if you create multiple squads, the NewAqud and NewVcl variables will be overwritten. You may need to store these values in another variables, i.e. after the script exection: MyNewSquad1 = NewSquad

To give name to the new units you can do that:

aP1 = NewSquad select 0
aP2 = NewSquad select 1
aP3 = NewSquad select 2
aP4 = NewSquad select 3
etc...

hope this helps

Mike

  • Guest
Re:Creating Groups of Infantry
« Reply #7 on: 06 Oct 2002, 05:09:09 »
Thanks ;) !!

One more question. (Jeese I must be a pain in the --- by now..) but I tried the following piece of script to make a BMP then have it move to a gamelogic:

Code: [Select]
[[["#BMP", 1, "vcl"]], getpos EastStart9, groupAlpha, groupBravo, "none"] exec "createsquad.sqs"
CreateSquadRunning = true
@!CreateSquadRunning
_leader = NewSquad select 0
group _leader move getpos destination2

no errors come up, and BMP wont spawn? what did I do wrong?..
« Last Edit: 06 Oct 2002, 05:11:27 by Mike »

Backoff

  • Guest
Re:Creating Groups of Infantry
« Reply #8 on: 06 Oct 2002, 12:50:40 »
The vehicle class is wrong, don't use "#BMP", but "BMP" instead. Also use _leader = NewVcl select 0... it should work

Mike

  • Guest
Re:Creating Groups of Infantry
« Reply #9 on: 06 Oct 2002, 23:02:37 »
Thanks! :)

Ive managed to delete most of everything.. the crewmen still stay where the tank used to be when it gets deleted..
« Last Edit: 14 Oct 2002, 00:18:27 by Mike »

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re:Creating Groups of Infantry
« Reply #10 on: 15 Oct 2002, 14:34:21 »
Hi Mike. I'm pretty new to scripting so forgive me if i can't give you exact code, just an idea:

- save pos of tank (getpos tank) prior to deleting it
- delete crewmen by using the get nearestobject function. it can search for any 'crewEast' units. combine this with checking the distance of the crew-unit with the former saved tank pos (if the crew unit is less than 5m away, delete it).
- put the delete& get object lines into a loop until you don't find a crew-unit anymore or the nearest crew unit is more than 5m away.

Hope that inspires a bit. As i said, i'm a n00b to scripting.  ::)
« Last Edit: 15 Oct 2002, 14:36:11 by DrStrangelove »

CareyBear

  • Guest
Re:Creating Groups of Infantry
« Reply #11 on: 16 Oct 2002, 11:39:57 »
This isn't directly helpful for you, but...

The reason the crew doesn't get deleted is that the vehicle reference refers to the vehicle object not the crew.

If you want to be able to delete the crew, create them seperately as a squad of three crewmembers and then moveInDriver, moveInGunner and moveInCommander them into a created empty vehicle.

That would be an approach which would solve your problem. I haven't read Backoff's script, but I suspect a minor modification would allow that.

Cheers.

Backoff

  • Guest
Re:Creating Groups of Infantry
« Reply #12 on: 16 Oct 2002, 15:15:38 »
Hi Mike,

Sorry for the delay.

this code will delete all created vehicle (those that are in the NewVcl array) and their crew:

_i = 0
#deleteV
  _vcl = NewVcl select _i
  #deleteC
    _crew = (crew _vcl) select 0
    deletevehicle _crew
  ?(count crew _vcl) > 0: goto "deleteC"
  deletevehicle _vcl
  _i = _i + 1
?(_i < count NewVcl): goto "deleteV"

Mike

  • Guest
Re:Creating Groups of Infantry
« Reply #13 on: 16 Oct 2002, 21:34:04 »
 :cheers:

Thanks too the lot of yas! ;)

Mike

  • Guest
Re:Creating Groups of Infantry
« Reply #14 on: 09 Nov 2002, 06:33:26 »
I unsolved the topic for another problem that came up :\

My script looks like this

[[["Jeep", 1, "vcl"]], getpos ArmyVehicle, groupBravo, groupAlpha, "empty", 1, "CORPORAL"] exec "createsquad.sqs"
CreateSquadRunning = true
@!CreateSquadRunning
MyNewVcl1 = NewVcl
_leader = NewVcl select 0

I want to be able to exec a script that needs a Name of the jeep to work.. Its to lock and unlock the vehicle with addaction.. Can Someone tell me how to add a name to the bugger? Maybe Backoff could enlighten me..  ;D