Home   Help Search Login Register  

Author Topic: How to add init field to respawn groups script?  (Read 601 times)

0 Members and 1 Guest are viewing this topic.

CptBravo

  • Guest
How to add init field to respawn groups script?
« on: 04 Apr 2003, 00:52:44 »
Hi,

I'm using the creat units scripts. I am creating"respawning"  AI controlled groups on battle field.

I just want to add "stuff" in their init field, such weapons, dofire this, addface, gear etc .. how do I do that? where does the init field go??

I'm posting the script and I hope someone can show me where to add it.

Thank you very much.

Here is the script:

;begin script

_pos = _this select 0
_grp = _this select 1

"MAF_Officer" createunit [getpos _pos,_grp,"",1,"LIEUTENANT"]
"MAF_SoldierDMG" createunit [getpos _pos,_grp,"",0.8,"SERGEANT"]
"MAF_SoldierWMortar" createunit [getpos _pos,_grp,"",0.8,"CORPORAL"]
"MAF_SoldierDMedic" createunit [getpos _pos,_grp,"",0.8,"CORPORAL"]
"MAF_HeavyGrenadier" createunit [getpos _pos,_grp,"",0.8,"CORPORAL"]
"MAF_SoldierDB" createunit [getpos _pos,_grp,"",0.8,"CORPORAL"]
"MAF_SoldierDB" createunit [getpos _pos,_grp,"",0.8,"CORPORAL"]
"MAF_SoldierDB" createunit [getpos _pos,_grp,"",0.8,"CORPORAL"]
"MAF_SoldierDB" createunit [getpos _pos,_grp,"",0.8,"CORPORAL"]
"MAF_SoldierDB" createunit [getpos _pos,_grp,"",0.8,"CORPORAL"]
"MAF_SoldierDB" createunit [getpos _pos,_grp,"",0.8,"CORPORAL"]
"MAF_SoldierDB" createunit [getpos _pos,_grp,"",0.8,"CORPORAL"]
~1
_units = units _grp
_grp setformation "LINE"
_grp setbehaviour "AWARE"
_grp setcombatmode "GREEN"
"_x allowfleeing 0" foreach _units

#loop
?(("Alive _x" count _units) == 0): "deletevehicle _x" foreach _units; exit
~random(10) + 10
goto "loop"

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:How to add init field to respawn groups script?
« Reply #1 on: 04 Apr 2003, 01:45:30 »
"MAF_Officer" createunit [getpos _pos,_grp,"right here",1,"LIEUTENANT"]

The place I marked is the init line in a createunit call ;)

CptBravo

  • Guest
Re:How to add init field to respawn groups script?
« Reply #2 on: 04 Apr 2003, 04:56:38 »
Hi Sui,

Thanks for your quick response.

I have tried it but it keeps giving me error msg. I am sure it is something stupid I did .. umm not what it is though.

I'm posting the new script with some of the stuff I tried to do. Let me know please what I'm doing wrong.

Thanks again in advance.

Script:
------------------------------------------------------------------

;begin script

_pos = _this select 0
_grp = _this select 1

"uce_rustgrsOfficer" createunit [getpos _pos,_grp,"this setface "Spetznaz"",1,"CAPTAIN"]
"uce_rustgrsMedic" createunit [getpos _pos,_grp,"removeAllWeapons this",0.5,"LIEUTNANT"]
"uce_rustgrsSoldier" createunit [getpos _pos,_grp,"removeAllWeapons this;  this addMagazine "M16"; this addWeapon "M16"",0.2,"SERGEANT"]
~1
_units = units _grp
_grp setformation "LINE"
_grp setbehaviour "AWARE"
_grp setcombatmode "GREEN"
"_x allowfleeing 0" foreach _units

#loop
?(("Alive _x" count _units) == 0): "deletevehicle _x" foreach _units; exit
~random(10) + 10
goto "loop"

 -------------------------------------------------------------------

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:How to add init field to respawn groups script?
« Reply #3 on: 05 Apr 2003, 11:56:24 »
Ahh... you want to use strings within a string... this is where OFP can get tricky ;)

If you have a string ("") within another string, you need to put the inner string in double quotes. So here's an example from your code:

"uce_rustgrsOfficer" createunit [getpos _pos,_grp,"this setface "Spetznaz"",1,"CAPTAIN"]

Should be:

"uce_rustgrsOfficer" createunit [getpos _pos,_grp,"this setface ""Spetznaz""",1,"CAPTAIN"]

Note the three (3) """ at the end there... it can get pretty ridiculous ;)

I think another option is to use {}, but I'm not exactly sure how the syntax is with those, as I've always used quotes ;)