Jump to content
nikiller

Nikiller's scripts pack

Recommended Posts

hi,

For mission makers who are tired to preview their mission 100 times when they want to place a unit inside a building here is a good solution. This script randomly place unit properly inside building with predefined positions.

Addon needed: N/A

Addon suggested: WW4 Modpack 2.5

Script suggested: WW4 HD conversion

Version: 1.0

By: Nikiller

Credits: Baddo and Nikiller

MP compatable: yes

Required version: OFP 1.96 or CWA (ofp 1.99)

Description: This script randomly place unit properly inside building with predefined positions

installation: put the ai folder in your mission folder, place the unit near the building and write in the unit's init field or in the init.sqs [unitName] exec "building_pos.sqs";

Note: for performance purpose I strongly recommand to make an array to define the unit name (i.e nik_east_ai=[e1,e2,e3,e4,e5,e6,e7,e8,e9]) in the init.sqs

NB: I suggest you to don't place AI grenadier inside building or it will blow itself

init.sqs

;********************************
;init Script by Nikiller v0.9b
;contact: nikillerofp@hotmail.fr
;********************************

nik_host=local server
nik_east_ai=[e1,e2,e3,e4,e5,e6,e7,e8,e9]

;-----------------------------------------------------------------------------------------
; Place unit inside building
;-----------------------------------------------------------------------------------------
{_x removeMagazines "HandGreande"} forEach nik_east_ai
{_x setUnitPos "UP"} forEach nik_east_ai
{[_x] exec "ai\misc\building_pos.sqs"} forEach nik_east_ai

exit

building_pos.sqs

;**********************************************************
;Pos Building Script by Nikiler v0.9b
;Pos a unit to the differents predefined building positions
;Note: place a game logic named server on the map
;contact: nikillerofp@hotmail.fr
;[unitName] exec "scriptname.sqs"
;**********************************************************
~0.5+random 1

if nik_host then {} else {goto "ende"}

_u=_this select 0

_i=0
_p=getPos _u
_b= nearestBuilding _u
_n=name _u

while { format ["%1", _b buildingPos _i] != "[0,0,0]" } do {_i=_i + 1}
_i=_i - 1
_u setPos (_b buildingPos (random _i)) 
if ((getPos _u select 0==0) and (getPos _u select 1==0)) then {_u setPos _p}

#ende

exit

Here's a demo to show how it works: DEMO LINK

cya.

Nikiller.

Edited by Nikiller
Uploaded new demo

Share this post


Link to post
Share on other sites

@Nikiller

Man you are a real scripting GURU!

Thanks for "Voice reloading" fix ;)

@controlled chopper crash:

Good script! Is it possible to make chopper spin not only horizontally but also roll a little? Would make the falling down more

:) Edited by Icarus

Share this post


Link to post
Share on other sites

hi,

Here's a script to force a tank to fire on random places in a defined area.

Addon needed: N/A

Addon suggested: N/A

Version: 1.0

By: Nikiller

Credits: Nikiller

MP compatable: yes

Required version: OFP 1.96 or CWA (ofp 1.99)

Description: this script makes a tank fire at random places in a defined area. Mission maker can choose the distance, axe X and axe Y.

installation: put the fx folder in your mission folder, give the unit a name and write in the unit's init field or in the init.sqs [vehicleName,axeX,axeY,distance] exec "fx\force_fire\tank_fire.sqs".

Note: for performance purpose I strongly recommand to make an array to define the vehicles name (i.e nik_west_m1a1=[WestM1A11,WestM1A12]) in the init.sqs

init.sqs

;********************************
;init Script by Nikiller v0.9b
;contact: nikillerofp@hotmail.fr
;********************************

nik_host=local server
nik_west_m1a1=[WestM1A11,WestM1A12]

;-----------------------------------------------------------------------------------------
; Force tank to fire
;-----------------------------------------------------------------------------------------
{[_x,150,100,100] exec "fx\force_fire\tank_fire.sqs"} forEach nik_west_m1a1

exit

tank_fire.sqs

;******************************************************
;Tank Fire Script by Nikiller v0.9b
;Force tank to fire on a defined area
;Note: Place a game logic named server on the map
;contact: nikillerofp@hotmail.fr
;[vehicleName,axeX,axeY,distance] exec "scriptName.sqs"
;example: [WestM1A11,200,100,100] exec "scriptName.sqs"
;******************************************************

~1+random 3

_u = _this select 0
_sx = _this select 1
_sy = _this select 2
_d = _this select 3

if nik_host then {} else {goto "ende"}

_u setBehaviour "COMBAT"
_del1=5
_del2=0.5
_g=gunner _u
_m=(magazines (_u) select 0)
_pu=getPos _u
_diru=getDir _u
_t="fire" createVehicle [0,0,0]
_t setPos [(_pu select 0)+_d*sin _diru,(_pu select 1)+_d*cos _diru,-0.5]
~_del2
_u doWatch _t
_pt=getPos _t

#l
~_del1
if ((canFire _u) && (alive _g)) then {} else {goto "dead"}
_cx=_pt select 0
_cy=_pt select 1
_cz=_pt select 2
_cx=_cx+(-_sx+random 2*_sx)
_cy=_cy+random _sy
_cz=-0.5
;hint format ["%1", getPos _t]
_t setPos [_cx,_cy,_cz]
~_del2
_u fire (weapons (_u) select 0)
if (someAmmo _u) then {goto "l"}

~_del1
if ((canFire _u) && (alive _g)) then {_u removeMagazines _m; _u addMagazine _m; goto "l"}

#dead
_u doWatch objNull
~_del1
_t setPos [0,0,0]
~_del1
deleteVehicle _t
;hint "DEBUG: exit tank_fire.sqs"

#ende

exit

Here's a demo to show how it works: DEMO LINK

cya.

Nikiller.

Edited by Nikiller
new demo link

Share this post


Link to post
Share on other sites

hi,

As some mission makers requested, here's a script to force an MG to fire D-Day style on a units array. It can also be defined by a trigger list. When the MG gunnner dies a new one will replace him. Mission maker can set "new" gunner as much as ofp engine allows.

Addon needed: N/A

Addon suggested: N/A

Version: 1.0

By: Nikiller

Credits: Nikiller

MP compatable: yes

Required version: OFP 1.96 or CWA (ofp 1.99)

Description: this script force an MG to fire D-Day style on a unit array it can also be defined by a trigger list.

installation: put the fx folder in your mission folder, give the unit a name and write in the unit's init field or in the init.sqs [enemyListArray,mgName,gunnerReplacerName] exec "fx\force_fire\mg_fire.sqs".

Note: for performance purpose I strongly recommand to make an array to define the vehicles name (i.e nik_east_mg=[eastMG1,eastMG2]) in the init.sqs

init.sqs

;********************************
;init Script by Nikiller v0.9b
;contact: nikillerofp@hotmail.fr
;********************************

nik_host=local server

exit

mg_fire.sqs

;****************************************************************
;MG Fire Script by Nikiller v0.9b
;Force MG to fire ala D-Day style on an array of unit
;Note: Place a game logic named server on the map
;contact: nikillerofp@hotmail.fr
;[enemyListArray,mgName,gunnerReplacerName] exec "scriptName.sqs"
;****************************************************************

if nik_host then {} else {goto "ende"}

_list = _this select 0
_u = _this select 1
_xt = _this select 2

_rm=100
_rc=0
_rm=_rm/1.2+random 10
_m=(magazines (_u) select 0)

#wait
~3
if (canFire _u) then {} else {goto "dead"}
if (count _list==0) then {goto "wait"} else {goto "pick"}

#rez
_rc=0

#main
_g=gunner _u
_aim=[(getPos _t select 0)+10*(sin(getDir _u)),(getPos _t select 1)+10*(cos(getDir _u)),(getPos _t select 2)-3]
_ax=_aim select 0
_ay=_aim select 1
_az=_aim select 2
if (count _list==0) then {goto "wait"}
if (alive _t) then {} else {goto "pick"}
if (alive _g) then {} else {goto "new"}
if (canFire _u) then {} else {goto "dead"}
if (someAmmo _u) then {} else {goto "add"}
_u doWatch [(_ax)-10+(random 5*4),(_ay)-10+(random 5*4),(_az)-2+(random 2*10)]
~0.1
_u fire (weapons (_u) select 0)
~0.1
_rc=_rc + 1
if (_rc < _rm) then {goto "rez"}
if (random 10 > 0.2) then {goto "main"}

#pick
_r=random count _list
_r=_r-_r %1
_t=_list select _r
~3
goto "main"

#add
~3
if (alive _u) then {_u removeMagazines _m; _u addMagazine _m; goto "main"}

#dead
;hint "DEBUG: mg dead"
goto "ende"

#new
if ("alive _x" count units _xt <= 0) then {goto "ende"}
_g=units _xt select (count units _xt - 1)
_g assignAsGunner _u
[_g] orderGetIn TRUE

#check
~0.5
if (alive _g) then {} else {goto "new"}
~1
if (!(_g in _u) && (alive _u)) then {goto "check"}
[_g] join grpnull
goto "wait"

#ende

exit

Here's a demo to show how it works: DEMO LINK

cya.

Nikiller.

Edited by Nikiller
updated demo link

Share this post


Link to post
Share on other sites

hi,

Here's a script who ends the mission when too much civilian or too much friendlies or too much stuff you don't want them to be killed are killed. (wow that's a lot of killed :D)

Addon needed: N/A

Addon suggested: N/A

Version: 1.0

By: Nikiller

Credits: Nikiller

MP compatable: yes

Required version: OFP 1.96 or CWA (ofp 1.99)

Description: this script ends the mission when too much civilian or too much friendlies or too much stuff you don't want them to be killed are killed.

installation: put the player folder in your mission folder, give the unit a name and write in the unit's init field or in the init.sqs unitName addEventHandler ["killed",{[(_this select 0),(_this select 1)] exec "player\friendly_fire\friendly_fire.sqs"}].

Note: for performance purpose I strongly recommand to make an array to define the units name (i.e nik_friendly=[p1,p2,p3,p4,p5,p6,p7,p8,p9]) in the init.sqs

init.sqs

;********************************
;init Script by Nikiller v0.9b
;contact: nikillerofp@hotmail.fr
;********************************

nik_friendly=[p1,p2,p3,p4,p5,p6,p7,p8,p9,c1,c2,c3,c4,c5,c6,c7,c8,c9]

;-----------------------------------------------------------------------------------------
; Friendly fire
;-----------------------------------------------------------------------------------------
nik_friendlyfire=0
{_x addEventHandler ["killed",{[(_this select 0),(_this select 1)] exec "player\friendly_fire\friendly_fire.sqs"}]} forEach nik_friendly

exit

friendly_fire.sqs

;*************************************************
;Friendly Fire Script by Nikiller v0.9b
;End the mission if too much friendlies are killed
;contact: nikillerofp@hotmail.fr
;[victimName,killerName] exec "scriptName.sqs"
;*************************************************

_victim=_this select 0
_killer=_this select 1

if (_killer==player) then {} else {goto "ende"}

nik_friendlyfire=nik_friendlyfire+1
publicVariable "nik_friendlyfire"
hint format ["%2 was killed by %1\n\nYOU KILLED A FRIEND\n\nWATCH YOUR FIRE %1!",name _killer,name _victim]

#ende

exit

Here's a demo to show how it works: DEMO LINK

cya.

Nikiller.

Edited by Nikiller
updated demo link

Share this post


Link to post
Share on other sites

hi,

@controlled chopper crash:

Good script! Is it possible to make chopper spin not only horizontally but also roll a little? Would make the falling down more

:)

Sorry for slow answer but I didn't saw your post :rolleyes:. Nice crash vid :eek: but unfortunetly it's not possible to do that in ofp with setDir or it is above my scripting knowledge. SetDir command is a 2 dimensions command it means that I can only make the chopper turn horizontally. Maybe with setPos, which is 3 dimension command and some trigo calculations, I will have a look later if I don't forget :D.

Problem if I make the crash more realistic is the landing zone becomes unpredicable and the choper may be destroyed on a tree, a rock or whatever object. I think you can force the chopper to land where you want but it will look ugly especially in MP.

Here's a modified and more realistic version of the script but the landing zone becomes unpredicable and the choper may be destroyed. You can tweak the values to obtain what you want but please make a note that it is a modified version in the script header. You can use the same demo as before just replace the old version by this one.

controled_crash.sqs

;************************************************************************************************************************************************
;Controled Crash Script by Nikiller v0.9b modified version version to make the crash more realistic but LZ is unpredicable and the chopper may be destroyed
;Make a chopper crash and cargo survive
;Note: Place a game logic named server on the map
;[unitName] exec "scriptName.sqs"
;************************************************************************************************************************************************

if nik_host then {} else {goto "ende"}

_v = _this select 0

_rate=0
_d=driver _v
_g=gunner _v
_l="l"
_delay=0.01
_rnd=random 2
_velrnd=2+random 2
_velad=-0.2+random 0.4

? _rnd>0 && _rnd<1: _factor=2+random 2
? _rnd>1 && _rnd<2: _factor=-2-random 2

#l
~_delay
if (alive _v) then {} else {goto "ende"}
_vel=velocity _v
_dir=direction _v
_v setDir (_dir+_factor)
_v setVelocity [(_vel select 0)+_velad,(_vel select 1)+_velad,-(2+_velrnd+_rate)]
_rate = _rate + .01
if (getPos _v select 2>0.5) then {goto _l}

_v setFuel 0
_v setVelocity [0,0,-0.5]
_v setDammage 0.7
{_x setDammage 1} forEach [_d,_g]

#ende

exit

@All: AI kidnap player script will release in the next days when I find a bit time to make a serious testing session.

cya.

Nikiller.

Edited by Nikiller

Share this post


Link to post
Share on other sites

hi,

This script randomly set a unit face. It 's not very usefull with default BIS faces since there's allready random faces via the config.cpp. But it can be very usefull if you want to use an addon's faces with another addon (i.e using taleb faces on WW4 insurgency). You can do that by editing the face.sqf array with the addon face names you want use.

Addon needed: N/A

Addon suggested: N/A

Version: 1.0

By: Nikiller

Credits: Nikiller

MP compatable: yes

Required version: OFP 1.96 or CWA (ofp 1.99)

Description: This script randomly set a unit face

installation: Write in the init.sqs [unitName] exec "face.sqs";

face.sqs

;**********************************************
;Random Face Script by Nikiller v0.9b
;Set random face
;contact: nikillerofp@hotmail.fr
;[unitName] exec "scriptName.sqs"
;**********************************************
~1
_u = _this select 0

_f=call loadFile "face.sqf"
_c=count _f
if (alive _u) then {_r=random _c; _r=_r-_r mod 1; _u setFace (_f select _r)}

exit

face.sqf

[

"face1",
"face2",
"face3",
"face4",
"face5",
"face6",
"face7",
"face8",
"face9",
"face10",
"face12",
"face13",
"face14",
"face15",
"face16",
"face17",
"face18",
"face19",
"face20",
"face21",
"face23",
"face24",
"face25",
"face26",
"face27",
"face28",
"face29",
"face30",
"face31",
"face32",
"face33",
"face34",
"face35",
"face36",
"face37",
"face38",
"face39",
"face40",
"face41",
"face42",
"face43",
"face44",
"face45",
"face46",
"face47",
"face48",
"face49",
"face50",
"face51",
"faceR01",
"faceR02",
"faceR03",
"faceR04"

]

cya.

Nikiller.

Edited by Nikiller

Share this post


Link to post
Share on other sites

@Controlled crash

Now that's a chopper crash! Sitting inside a falling helicopter felt scary :)

Good job.

Icarus

Share this post


Link to post
Share on other sites

hi,

This script decrease or increase a projectile velocity (rocket,shell...). It means that an rpg launcher can fire farther or less far. It's up to the mission maker.

Addon needed: N/A

Addon suggested: N/A

Version: 1.0

By: Nikiller

Credits: Nikiller and Mad Max

MP compatable: yes

Required version: OFP 1.96 or CWA (ofp 1.99)

Description: This script decrease or increase a projectile velocity (rocket,shell...).

installation: Write in the init.sqs [unitName] exec "init_launcher.sqs";

ofp weapon classnames

init_launcher.sqs

;**************************************
;Init Launcher Script By Nikiller v0.9b
;contact: nikillerofp@hotmail.fr
;[unitName] exec "scriptName.sqs"
;**************************************

_u = _this select 0

; Array with all launchers ammo classes:
_ar=["9K32","AA"]

; Acceleration factors and counts:
_af=[[0.5,40],[0.5,40]]

nik_rpg_ar=_ar
nik_rpg_ca=count _ar
nik_rpg_af=_af
if (not isNull _u) then {_u addEventHandler [{fired},{_this exec {player\launcher\fired.sqs}}]}

exit

fired.sqs

;****************************************************************
;Fired Script By Nikiller v0.9b
;contact: nikillerofp@hotmail.fr
;unitName addEventHandler [{fired},{_this exec {scriptname.sqs}}]
;****************************************************************

_m = _this select 0
_a = _this select 4

_r=objNull
_s=true
_n=0
_i=0
while {_s and _i<nik_rpg_ca} do {if (_a==nik_rpg_ar select _i) then {_r=nearestObject [_m,_a]; _s=false}; _i=_i+1}
if (not local _r) then {goto "ende"}
_f=nik_rpg_af select (_i-1) select 0
_c=nik_rpg_af select (_i-1) select 1

#l
~0.02
if (not isNull _r) then {_v=velocity _r; _r setVelocity [(_v select 0)*_f,(_v select 1)*_f,(_v select 2)*_f]; _n=_n+1; if (_n < _c) then {goto "l"}}

#ende

exit

Here's a demo to show how it works: DEMO LINK

cya.

Nikiller.

Edited by Nikiller
fixed dead link

Share this post


Link to post
Share on other sites

hi,

This script delete trigger after activation. It saves a lot of performance.

Addon needed: N/A

Addon suggested: N/A

Version: 1.0

By: Nikiller

Credits: Nikiller and Mad Max

MP compatable: yes

Required version: OFP 1.96 or CWA (ofp 1.99)

Description: This script delete trigger after activation.

installation: Write in the trigger activation field trigerName exec "del_trig.sqs";

NB: Never use this this script with repeatidly trigger.

init.sqs

;********************************
;init Script by Nikiller v0.9b
;contact: nikillerofp@hotmail.fr
;********************************

nik_host=local server

exit

del_trig.sqs

;***************************************
;Delete Trigger Script By Nikiller v0.9b
;Note: Place a game logic named server
;contact: nikillerofp@hotmail.fr
;triggerName exec "scriptname.sqs"
;***************************************

if nik_host then {} else {goto "ende"}

_trig=_this

~60
deleteVehicle _trig

#ende

exit

cya.

Nikiller.

Edited by Nikiller

Share this post


Link to post
Share on other sites

hi,

I finally found the time to test my AI kidnap player script. I release it as beta version and if not bugs are found or good suggestions are made it will be the final version. This script can be used as funny way to punish lone wolf players in MP or just to make escape missions. If you have questions/suggestions don't be shy! ;)

Addon needed: N/A

Addon suggested: WW4 Modpack 2.5

Version: 1.0

By: Nikiller

Credits: Baddo, Mad Max and Nikiller

MP compatable: yes

Required version: OFP 1.96 or CWA (ofp 1.99)

Description: This script makes AI kidnap player and interrogate him

installation: put the ai folder, fx folder and performance folder in your mission folder and write in the init.sqs [kidnapedUnitName,kidnaperGroupName,kidnapChopperGroupName,interrogationOfficerGroupName,spawnPositionName,typeOfKidnaper,typeOfChopperPilot,typeOfChopper,typeOfTruck,typeOfMG,typeOfInterrogationOfficer] exec "scriptName.sqs"

example: [p1,nik_NaperGrp,nik_NapChopGrp,nik_NapOfficerGrp,nik_SpawnPosNap,"SoldierESaboteurBizon","SoldierEPilot","Mi17","Ural","M2StaticMgE","OfficerE"] exec "scriptName.sqs"

init.sqs

;*********************************************************
;init Script by Nikiller v0.9b
;contact: nikillerofp@hotmail.fr
;*********************************************************

nik_host=local server
nik_client=local player
nik_players=[p1]

;-----------------------------------------------------------------------------------------
; Blood
;-----------------------------------------------------------------------------------------
nik_fx="player"
nik_fblood=preprocessFile "fx\blood\blood.sqf"
{[_x] exec "fx\blood\blood.sqs"} forEach nik_players

;-----------------------------------------------------------------------------------------
; Kidnap player
;-----------------------------------------------------------------------------------------
nik_falivegroup=preprocessFile "ai\kidnap\alivegroup.sqf"
nik_fdir=preprocessFile "ai\kidnap\direction.sqf"
nik_finzone=preprocessFile "ai\kidnap\inzone.sqf"
[p1,nik_NaperGrp,nik_NapChopGrp,nik_NapOfficerGrp,nik_SpawnPosNap,"SoldierESaboteurBizon","SoldierEPilot","Mi17","Ural","M2StaticMgE","OfficerE"] exec "ai\kidnap\kidnap.sqs"

;-----------------------------------------------------------------------------------------
; Crash site (for demo only)
;-----------------------------------------------------------------------------------------
titleText ["", "BLACK FADED", 0.3]
{[_x] exec "fx\voice\voice.sqs"} forEach units EastGrp1
WestUH601 lock true
[WestUH601,[p1]] exec "crash_victim.sqs"
[] exec "fx\misc\black_screen.sqs"
[WestUH601] exec "fx\fire_effect\burn.sqs"
[] exec "crash_chat.sqs"

exit

Now the big part :)

ai folder

kidnap folder

kidnap.sqs

;*************************************************
;Kidnap Script by Nikiller v0.9b
;Make AI kidnap player and interrogate him
;Note: Place a game logic named server on the map
;contact: nikillerofp@hotmail.fr
;[kidnapedUnitName,kidnaperGroupName,kidnapChopperGroupName,interrogationOfficerGroupName,spawnPositionName,typeOfKidnaper,typeOfChopperPilot,typeOfChopper,typeOfTruck,typeOfMG,typeOfInterrogationOfficer] exec "scriptName.sqs"
;example: [p1,nik_NaperGrp,nik_NapChopGrp,nik_NapOfficerGrp,nik_SpawnPosNap,"SoldierESaboteurBizon","SoldierEPilot","Mi17","Ural","M2StaticMgE","OfficerE"] exec "scriptName.sqs"
;*************************************************

if nik_host then {} else {goto "ende"}

_kd          = _this select 0
_napergrp    = _this select 1
_chopgrp     = _this select 2
_officergrp  = _this select 3
_pos         = _this select 4
_typenaper   = _this select 5
_typepilot   = _this select 6
_typechopper = _this select 7
_typetruck   = _this select 8
_typemg      = _this select 9
_typeofficer = _this select 10

_spawnpos=getPos _pos

_initnaper={this setUnitPos "UP"; [this] exec "fx\blood\blood.sqs"; this removeAllEventHandlers "killed";  this addEventHandler ["killed", {[(_this select 0),120] exec "performance\del_unit.sqs"}]}
_sknaper=1
_ranaper="CORPORAL"

_sci=0
_scj=3

#spawnnaper
~0.5
? !(alive _kd): goto "exit1"
_typenaper createUnit [_spawnpos,_napergrp,_initnaper,_sknaper,_ranaper]
? (({alive _x} count (units _napergrp))<12): goto "spawnnaper"

_napergrp setCombatMode "BLUE"
_sci=_sci+1
? _sci>=_scj: _napergrp setCombatMode "RED"

~1
_steps=360/count units _napergrp
_dist=250
_i=0

#posnaper
~0.5
? !(alive _kd): goto "exit1"
_units=units _napergrp select _i
_px=getpos _kd select 0
_py=getpos _kd select 1
_px=_px+(sin(_i*_steps)*_dist)
_py=_py+(cos(_i*_steps)*_dist)
_units setpos [_px,_py, 0]
_i=_i+1
? (_i<{alive _x} count (units _napergrp)): goto "posnaper"

? (_sci>=_scj): {_x reveal _kd} forEach units _napergrp; goto "ende"

_dist=6

#raz
_i=0

#movenaper
~1
? !(alive _kd): goto "exit1"
_kr=units _napergrp select _i
if ((_kr distance _kd<_dist) && (alive _kd) && (alive _kr)) then {goto "capture"} else {_kr doMove getPos _kd}
if (_napergrp call nik_falivegroup) then {} else {goto "spawnnaper"}
_i=_i+1
? (_i<{alive _x} count (units _napergrp)): goto "movenaper"
goto "raz"

#capture
_ac="EJECT"
? !(_kd==vehicle _kd): _kd action [_ac,vehicle _kd]
~1
{doStop _x} forEach units _napergrp
_kd switchMove "FXStandSurDown"
? !(alive _kr): _kr=objNull; goto "raz"
;hint format ["DEBUG:\n\nkidnapper name:\n\n%1",name _kr] 
_kd setCaptive true
_kr setDamage 0
_kr setSpeedMode "FULL"
[_kr] join grpNull
[_kd] join grpNull
~4
_pu=getPos _kd
_diru=getDir _kd
_dist=1
_kr setPos [(_pu select 0)+_dist*sin _diru,(_pu select 1)+_dist*cos _diru,0]
~0.5
_kr setDir ([_kr,_kd] call nik_fdir)
_kr playMove "CombatStrokeGun"
~1
_kd switchMove "CivilDead"
_kr setUnitPos "AUTO"
(group _kr) setCombatMode "YELLOW"
~2
_kr setDir ([_kr,_kd] call nik_fdir)
_kr playMove "combatToMedic"
~3
_mags=magazines _kd
_weaps=weapons _kd
{_kd removeMagazine _x} forEach _mags
{_kd removeWeapon _x} forEach _weaps

#spawnnapchop
~0.1
? !(alive _kd) || !(alive _kr): goto "exit1"
_initchop={this setCaptive true; this setCombatMode "BLUE"; this setBehaviour "CARELESS"; {this disableAI _x} forEach ["TARGET","AUTOTARGET"]}
_skchop=1
_radchop="SERGEANT"
_ragchop="LIEUTENANT"
_ac="ENGINE ON"
_typepilot createUnit [_spawnpos,_chopgrp,_initchop,_skchop,_radchop]
~0.5
_typepilot createUnit [_spawnpos,_chopgrp,_initchop,_skchop,_ragchop]
_napchop=_typechopper createVehicle [0,0,0]
_napchop addEventHandler ["killed", {[(_this select 0),120] exec "performance\del_vehicle.sqs"}]
_napchop lock true
_napchop setPos [_spawnpos select 0 ,_spawnpos select 1, 1000]
_napchop setDir 0
_nappilot=(units _chopgrp) select 0
_napgunner=(units _chopgrp) select 1
_nappilot assignAsDriver _napchop
_nappilot moveInDriver _napchop
_nappilot action [_ac,_napchop]
_napgunner assignAsGunner _napchop
_napgunner moveInGunner _napchop
_napchop setVelocity [0,0,0]
_napchop flyInHeight 100
~5
_napchop doMove getPos _kr
~10
_pu=getPos _kd
_diru=getDir _kd
_dist=250
_napchop setPos [(_pu select 0)+_dist*sin _diru,(_pu select 1)+_dist*cos _diru,+150]

~0.5
_kr doMove (getPos _napchop)
_kr assignAsCargo _napchop

_xa=0
_ya=2.5
_za=0
_dist=6

#dragcapture
~0.05
_kd setDir getDir _kr
? (alive _kr) && (alive _kd) && (alive _napchop) && (_kr distance _napchop>_dist): _kd setPos [(getPos _kr select 0)-((((_xa^2)+(_ya^2))^0.5)*sin (getDir _kr)), (getPos _kr select 1) -((((_xa^2)+(_ya^2))^0.5)*cos (getDir _kr)), (getPos _kr select 2)+_za]; goto "dragcapture"

~1
? (alive _kd) && (alive _napchop) && (alive _kr): _kd moveInCargo _napchop
{_kd removeMagazine _x} forEach _mags
{_kd removeWeapon _x} forEach _weaps

#allin
~3
? !(alive _kd) || !(alive _napchop) || !(alive _kr): goto "exit1"
? !(_kr in _napchop) && !(_kd in _napchop): goto "allin"

{_x setDamage 1} forEach units _napergrp

_napchop doMove _spawnpos

#movenapchop
~1
? !(alive _kd) || !(alive _napchop) || !(alive _kr): goto "exit1"
? !(unitReady _napchop): goto "movenapchop"

_land="GET OUT"
unassignVehicle _kr
[_kr] orderGetIn false
_napchop land _land

#getout
~1
? !(alive _kd) || !(alive _napchop) || !(alive _kr): goto "exit1"
? (getPos _napchop select 2>5): goto "getout"
~1
_ac="GETOUT"
_kd action [_ac,_napchop]
? !(alive _kd) || !(alive _kr): goto "exit1"
~1
_kd switchMove "CivilDead"
~1
[_nappilot,_napgunner] join grpNull
_napchop doMove [0,0,0]
[_napchop,120] exec "performance\del_vehicle.sqs"

#buildcamp
? !(alive _kd) || !(alive _kr): goto "exit1"
_naptent="CampEast" createVehicle [0,0,0]
_naptent setPos _spawnpos
_napchair="ChairX" createVehicle [0,0,0]
_napchair setDir 180
_napchair setPos _spawnpos
~0.1
_typeshed="ShedSmall"
_napshed1=_typeshed createVehicle [0,0,0]
_napshed1 setDir 0
[_pos,_napshed1,20,-20,0] exec "ai\misc\setpos.sqs"
_napshed2=_typeshed createVehicle [0,0,0]
_napshed2 setDir 90
[_pos,_napshed2,-20,-20,0] exec "ai\misc\setpos.sqs"
_napshed3=_typeshed createVehicle [0,0,0]
_napshed3 setDir 180
[_pos,_napshed3,-20,20,0] exec "ai\misc\setpos.sqs"
_napshed4=_typeshed createVehicle [0,0,0]
_napshed4 setDir 270
[_pos,_napshed4,20,20,0] exec "ai\misc\setpos.sqs"
~0.1
_naptruck=_typetruck createVehicle [0,0,0]
_naptruck setDir 30
_naptruck addEventHandler ["killed", {[(_this select 0),120] exec "performance\del_vehicle.sqs"}]
[_pos,_naptruck,10,0,0] exec "ai\misc\setpos.sqs"
~0.1
_napfire="Fire" createVehicle [0,0,0]
_napfire setDir 0
[_pos,_napfire,0,10,0] exec "ai\misc\setpos.sqs"
_napfire inflame true
~0.1
_napmg1=_typemg createVehicle [0,0,0]
_napmg1 setDir 180
_napmg1 setPos (getPos _napshed1)
_napmg2=_typemg createVehicle [0,0,0]
_napmg2 setDir 270
_napmg2 setPos (getPos _napshed2)
_napmg3=_typemg createVehicle [0,0,0]
_napmg3 setDir 0
_napmg3 setPos (getPos _napshed3)
_napmg4=_typemg createVehicle [0,0,0]
_napmg4 setDir 90
_napmg4 setPos (getPos _napshed4)
~0.1
_initofficer={this setUnitPos "UP"; this removeWeapon "Binocular"; [this] exec "ai\kidnap\voice.sqs"; [this] exec "fx\blood\blood.sqs"; this removeAllEventHandlers "killed"; this addEventHandler ["killed", {[(_this select 0),120] exec "performance\del_unit.sqs"}]}
_skofficer=1
_raofficer="MAJOR"
_typeofficer createUnit [_spawnpos,_officergrp,_initofficer,_skofficer,_raofficer]
_napofficer=(units _officergrp) select 0
_position=3
[_napofficer,_naptent,_position,90] exec "ai\misc\pos_building_added.sqs"

_initnapercamp={[this] exec "fx\blood\blood.sqs"; this removeAllEventHandlers "killed"; this addEventHandler ["killed", {[(_this select 0),120] exec "performance\del_unit.sqs"}]}
_sknapercamp=1
_ranapercamp="CORPORAL"

#spawnnapercamp
~0.5
? !(alive _kd) || !(alive _kr): goto "exit1"
_typenaper createUnit [_spawnpos,_officergrp,_initnapercamp,_sknapercamp,_ranapercamp]
? (({alive _x} count (units _officergrp))<12): goto "spawnnapercamp"

_napgunnercamp1=(units _officergrp) select 1
_napgunnercamp2=(units _officergrp) select 2
_napgunnercamp3=(units _officergrp) select 3
_napgunnercamp4=(units _officergrp) select 4

_napgunnercamp1 assignAsGunner _napmg1
_napgunnercamp1 moveInGunner _napmg1
_napgunnercamp2 assignAsGunner _napmg2
_napgunnercamp2 moveInGunner _napmg2
_napgunnercamp3 assignAsGunner _napmg3
_napgunnercamp3 moveInGunner _napmg3
_napgunnercamp4 assignAsGunner _napmg4
_napgunnercamp4 moveInGunner _napmg4

_napobjar=[_naptent,_napchair,_napshed1,_napshed2,_napshed3,_napshed4,_napfire,_napmg1,_napmg2,_napmg3,_napmg4]
{_x addEventHandler ["killed", {[(_this select 0),120] exec "performance\del_unit.sqs"}]} forEach _napobjar

_kr doMove _spawnpos
_dist=4

#dragcamp
~0.05
_kd setDir getDir _kr
? (alive _kr) && (alive _kd) && (_kr distance _pos>_dist): _kd setPos [(getPos _kr select 0)-((((_xa^2)+(_ya^2))^0.5)*sin (getDir _kr)), (getPos _kr select 1) -((((_xa^2)+(_ya^2))^0.5)*cos (getDir _kr)), (getPos _kr select 2)+_za]; goto "dragcamp"

#interrogation
? !(alive _kd): goto "exit1"
doStop _kr
~1
_kd setPos (getPos _napchair)
_kd switchMove "OnChair"
~2
_kd setDir ([_kd,_napofficer] call nik_fdir)
[_napofficer,_kd,10,5] exec "ai\kidnap\force_infantry_fire.sqs"
~55
if (alive _kd) then {} else {goto "exit1"}
_kd switchMove "StandStrokeFist"
~1
_napofficer setDamage 0.7
_kd switchMove "StandStrokeFist"
~1
_napofficer setDamage 1
~20+random 10
_kd setCaptive false
goto "exit2"

#exit1
_ac="EJECT"
? !(_kd==vehicle _kd): _kd action [_ac,vehicle _kd]
~1
_kd switchMove ""
_kd setCaptive false

#exit2
~5
if ([nik_players,_pos,600] call nik_finzone) then {goto "exit2"} 

#clean
~5
[_naptruck] exec "ai\kidnap\fuel_leak.sqs"
_napobjar=[_naptent,_napchair,_napshed1,_napshed2,_napshed3,_napshed4,_napfire,_napmg1,_napmg2,_napmg3,_napmg4]
_naperar=units _napergrp
_napchopar=[_napchop,_nappilot,_napgunner]
_napofficerar=units _officergrp
_krar=[_kr]
_napallar=_napobjar+_naperar+_napchopar+_napofficerar+_krar
~5
{if !(isNull _x) then {_x setPos [0,0,0]}} forEach _napallar
~5
{if !(isNull _x) then {_x setDamage 1}} forEach _napallar

#ende

exit

fuel_leak.sqs

;*************************************************************
;Fuel Leak Script by Nikiller v0.9b modified for kidnap script
;Simulate a fuel leak on a vehicle until no fuel left
;Note: Place a game logic named server on the map
;contact: nikillerofp@hotmail.fr
;[vehicleName] exec "scriptName.sqs"
;*************************************************************

~20

if nik_host then {} else {goto "ende"}

_v = _this select 0

#l
~2
if ((alive _v) && (fuel _v>0)) then {_v setFuel ((fuel _v)-0.05); goto "l"}

~10
_c=crew _v
_i=0
_j=count _c
_ac="GETOUT"

#l2
(_c select _i) action [_ac,_v]
unassignVehicle (_c select _i)
_i=_i+1
~0.5
?_j>_i: goto "l2"

_v lock true

#wait
~5
if ([nik_players,_v,600] call nik_finzone) then {goto "wait"}

[_v,30] exec "performance\del_vehicle.sqs"

#ende

exit

force_infantry_fire.sqs

;*************************************************************************
;Infantry Fire Script by Nikiller v0.9b modified for kidnap script
;Force infantry to fire in the sky and playMove StrokeGun
;Note: This script is for effect purpose only
;contact: nikillerofp@hotmail.fr
;[unitName,targetName,numberOfShot,delayBetweenShot] exec "scriptName.sqs"
;*************************************************************************

~1+random 3

if nik_host then {} else {goto "ende"}

_u = _this select 0
_t = _this select 1
_n = _this select 2
_d = _this select 3

_m=(magazines (_u) select 0)
_i=0
_j=_n

#l
~_d
if ((alive _u) && (alive _t)) then {_u fire (weapons (_u) select 0)} else {goto "ende"}
~1
if ((alive _u) && (alive _t)) then {_u playMove "CombatStrokeGun"; _t setDammage ((getDammage _t)+0.07)} else {goto "ende"}
if (someAmmo _u) then {} else {goto "add"}
_i=_i+1
if (_i<_j) then {goto "l"} else {goto "ende"}

#add
~2
if (alive _u) then {_u removeMagazines _m; {_u addMagazine _m} forEach [1,2,3,4,5]; goto "l"}

#ende

exit

voice.sqs

;*****************************************************************
;Voice Script by Nikiller v0.9b modified version for kidnap script
;Make unit say random stuffs every 40<x<100 sec
;Note: unit is moving lips since say commmand
;contact: nikillerofp@hotmail.fr
;[unitName] exec "scriptName.sqs"
;*****************************************************************

~1

if nik_client then {} else {goto "ende"}

_u = _this select 0

_vw=call loadFile "ai\kidnap\voice_west.sqf"
_ve=call loadFile "ai\kidnap\voice_east.sqf"

? (side _u==west): _v=_vw
? ((side _u==east) or (side _u==resistance)): _v=_ve

_c=count _v

#loop
_d=5
~_d
if (alive _u) then {_r=random _c; _r=_r-_r mod 1; _u say (_v select _r); goto "loop"}

#ende

exit

voice_east.sqf

[

"RUS1",
"RUS3",
"RUS4",
"RUS5",
"RUS8",
"RUS10",
"RUS14",
"RUS15",
"RUS16",
"RUS17",
"RUS20"

]

voice_west.sqf

[

"ENG1",
"ENG2",
"ENG3",
"ENG8",
"ENG9",
"ENG10",
"ENG22",
"ENG23",
"ENG24",
"ENG25",
"ENG26",
"ENG29",
"ENG30",
"ENG31",
"ENG37"

]

alivegroup.sqf

// ******************************************************************************************

// alivegroup.sqf (modified version by Nikiller)

// Baddo 2005

// ******************************************************************************************

private "_grpAlive";

_grpAlive = false;

if ( {alive _x} count units _this > 0 ) then { _grpAlive = true; };

_grpAlive

direction.sqf

private ["_t", "_nz", "_x", "_y"];
_t = _this select 0;
_nz = _this select 1;
_x = (getpos _nz select 0) - (getpos _t select 0);
_y = (getpos _nz select 1) - (getpos _t select 1);
_x atan2 _y

inzone.sqf

// in_zone

private [{_u_ar},{_obj},{_dis},{_zone},{_c},{_i}];

_u_ar = _this select 0;
_obj  = _this select 1;
_dis  = _this select 2;

_zone=false;
_c=count _u_ar;
_i=0;
while {(_i < _c) and (not _zone)} do
{
	_u=_u_ar select _i;
	if (alive _u) then
		{
			if ((vehicle _u) distance _obj < _dis) then
				{
					_zone=true;
				};
		};
	_i=_i+1;
};

_zone

misc folder

pos_building_added.sqs

;**********************************************************************
;Pos Building Script by Nikiller v0.9b
;Put a unit in building with predefined position
;NOTE: Place a game logic named server on the map
;NOTE2: do not remove the 1 sec delay or it will not work
;contact: nikillerofp@hotmail.fr
;[unitName,buildingName,buidingPos,unitDirection] exec "scriptName.sqs"
;**********************************************************************

~1

if nik_host then {} else {goto "ende"}

_u = _this select 0
_o = _this select 1
_p = _this select 2
_d = _this select 3

_gp=getPos _u
_b=_o
_pos=_b buildingPos _p
_u setFormDir _d
_u setPos _pos
if ((getPos _u select 0==0) and (getPos _u select 1==0)) then {_u setPos _gp}

#ende

exit

setpos.sqs

;********************************************************
;Set Pos Script by Nikiller v0.9b
;SetPos a unit from another one or from the unit itself
;contact: nikillerofp@hotmail.fr
;[referenceunitName,unitName,x,y,z] exec "scriptName.sqs"
;********************************************************

if nik_host then {} else {goto "ende"}

_ref = _this select 0
_u  = _this select 1
_px = _this select 2
_py = _this select 3
_pz = _this select 4

_pref=getPos _ref

_u setPos [(_pref select 0)+_px, (_pref select 1)+_py, (_pref select 2)+_pz]

#ende

exit

fx folder

blood folder

blood.sqs

; *****************************************************
; ** Blood
; *****************************************************

_u = _this select 0

~1

_dis=500

#wait
~3
if (alive _u) then {if (vehicle (call nik_fx) distance _u > _dis) then {goto "wait"}} else {goto "ende"}

_d=damage _u

#fx
@ (damage _u > _d) or (not alive _u)
if (vehicle (call nik_fx) distance _u < _dis) then {[_u] call nik_fblood} else {goto "wait"}
if (alive _u) then {_d=damage _u; goto "fx"}

#ende

exit

blood.sqf

// Blood

private [{_u},{_m},{_c},{_v},{_a},{_s}];

_u = _this select 0;

_m=12+random 4;
_c=0;

while {_c < _m} do
{
	_v=random 2;
	_a=-90+random 180;
	_s=[random 0.2,random 0.6,random 1];
	drop ["cl_water","","Billboard",1,random 2,[0,0,0.75],[_v*sin _a,_v*cos _a,random 3],0.5,10,0,0,_s,[[random 1,0,0,random 1],[random 1,0,0,random 1],[random 1,0,0,0]],[0],1,0,"","",_u];
	_c=_c+1;
};

true

performance folder

del_unit.sqs

;*******************************************************
;Delete Dead Bodies Script by Nikiller v0.9b
;Delete dead bodies
;Note: Place a game logic named server on the map
;[unitName,delay] exec "scriptName.sqs"
;*******************************************************

if nik_host then {} else {goto "ende"}

_b = _this select 0
_d = _this select 1

_ac="hidebody"
~_d
if (alive gravedigger) then {gravedigger action [_ac,_b]}
~10
_b setPos [0,0,0]
~1
deleteVehicle _b

#ende

exit

del_vehicle.sqs

;*************************************************
;Delete Destroyed Vehicle Script by Nikiller v0.9b
;Delete destroyed vehicle and crew
;Note: Place a game logic named server on the map
;[vehicleName,delay] exec "scriptName.sqs"
;*************************************************

if nik_host then {} else {goto "ende"}

_v = _this select 0
_delay = _this select 1

_d=driver _v
_g=gunner _v
_c=commander _v
_all=[_v,_d,_g,_c]
~_delay
_v setPos [0,0,0]
~1
{deleteVehicle _x} forEach _all

#ende

exit

Here's a demo to show how it works: DEMO LINK

cya.

Nikiller.

Edited by Nikiller
updated dead link

Share this post


Link to post
Share on other sites

Hi .. Looking for a Script for any side to join the other in addaction.

Think of it like:

Player is captured , and is given choice of going west, est or res(GUR)

and ...

at any point .. can re-use addaction to leave said side to join another ...

Thanks

LFH

Share this post


Link to post
Share on other sites

hi,

Hi .. Looking for a Script for any side to join the other in addaction.

Think of it like:

Player is captured , and is given choice of going west, est or res(GUR)

and ...

at any point .. can re-use addaction to leave said side to join another ...

Thanks

LFH

If I understand you right you want to be able to change a unit's side using an addAction command. Unfortunetly it's not possible to change a unit's side during game in ofp or it is above my knowledges. Even if you join another side group (i.e: West unit join East group) then units from this group will kill you since you keep your side.

The 2 cases a unit's side changes during game are:

- When the unit dies his side becomes civilian.

- When the unit kills too much friendlies, empty vehicles, civilians then his rating value decrease . When his rating value reach -2000 then his side becomes enemy and the unit is attacked by everyone. You can change unit's side to enemy by using addRating command (i.e: this addRating -3000 in the unit's init field).

You can check which side is a unit with this line hint format ["%1", side unitName]

If you wan to know more about side: http://community.bistudio.com/wiki/side

cya.

Nikiller.

Edited by Nikiller

Share this post


Link to post
Share on other sites

Im really diggin these scripts. I especially want to check out the random pos within a building script. Any chance of piling them all together in a rar/zip file?

Also, do you know of any respawn scripts that, upon spawn, will execute the urban spawn script and will delete dead bodies?

Thanks

Share this post


Link to post
Share on other sites
If I understand you right you want to be able to change a unit's side using an addAction command. Unfortunetly it's not possible to change a unit's side during game in ofp or it is above my knowledges. Even if you join another side group (i.e: West unit join East group) then units from this group will kill you since you keep your side.

Technically you are 100% correct.

But try using the setcaptive command.

Set the unit to captive/prisoner then: player setCaptive true

from a script or trigger:

[player] join grpNull

~1

[player] join east_unit

to switch back to West:

[player] join grpNull

~1

[player] join west_man

~1

player setcaptive false

Will any enemy shoot at you if your east - prolly not. So more scripting would be needed. possibly removing setCaptive toggle states. But it would have to be a highly delicate balance - or your own side shoots you. So this method recommended for specialized mission making.

Edited by WW2Weasel

Share this post


Link to post
Share on other sites

Nikiller would you be willing to re-upload your AI spawn demo mission to a different site? Ol' Uncle Sam wasnt too happy with the previous one....

Thanks!

Edited by Blitzen

Share this post


Link to post
Share on other sites

hi,

Nikiller would you be willing to re-upload your AI spawn demo mission to a different site? Ol' Uncle Sam wasnt too happy with the previous one....

Thanks!

Damn! I have to reupload all the demo :butbut:. Thx for the tip Blitzen ;)

new spawn squad link: http://www.mediafire.com/?sv7lcol35aor64z

Link also updated in the spawn squad post.

Sorry didn't saw your last post. UPS in the spawn_squad.sqf is possible but it needs some modifications and it will not be MP compatible anymore. I will write a more specific script in the next days to make the spawned squad execute UPS and open a new post for that to don't get people confused :).

For the all in one pack that's a good idea. I allready thought about it but I was too lazy. I will do it soon.

cya.

Nikiller.

Share this post


Link to post
Share on other sites
hi,

Sorry didn't saw your last post. UPS in the spawn_squad.sqf is possible but it needs some modifications and it will not be MP compatible anymore. I will write a more specific script in the next days to make the spawned squad execute UPS and open a new post for that to don't get people confused :).

cya.

Nikiller.

That would be awesome! Thanks for working on it!

EDIT:

I love your building position script! The days of finding out building position numbers have past! You can easily place soldiers within an entire city by using this script and increasing the AI's placement radius--its even more awesome in that its random everytime!

Edited by Blitzen

Share this post


Link to post
Share on other sites

hi,

This script spawn a custom squad and execute UPS. you can set behaviour, combat mode, init, formation, direction, rank and skill. It also delete dead bodies after 120 seconds but you can change the delay in spawnsquad_ups.sqf

IMPORTANT: To avoid spawn lags be sure that one model of each units spawned is placed somewhere on the map. This units don't need to be alive then put them in the sea if you want.

Addon needed: N/A

Addon suggested: WW4 modpack 2.5

Version: 1.0

By: Nikiller

Credits: Surpher and Nikiller

MP compatable: No (because of UPS)

Required version: OFP 1.96 or CWA (ofp 1.99)

Description: this script spawn a custom squad, execute UPS and mission maker can set skill, behaviour, formation, combat mode and so on.

installation: put the ai folder in your mission folder and read the HOW TO. Ask questions I will answer.

Note: for performance purpose I strongly recommand to put the spawned unit model somewhere on the map to avoid spawn lag.

HOW TO:

- First, you have to preprocessFile the spawnsquad_ups function in the init.sqs or in any scripts called from init.sqs without delay.

example: nik_fspawnsquad=preprocessFile "ai\spawn_manager\spawnsquad_ups.sqf"

- Second, you have to define an array containing the type of units you want to spawn, their init field (have a look here to understand better), their skill and their rank.

squadName=[["typeOf",number,"parameterNotUsed","unitInitField",skill,"rank"]]

example 1: nik_sq1=[["OfficerW",1,"sld","this addWeapon {NVGoggles}",0.9,"SERGEANT"],["SoldierWB",4,"sld","",0.7,"CORPORAL"],["SoldierWG",4,"sld","",0.7,"CORPORAL"],["SoldierWMG",2,"sld","",0.7,"CORPORAL"]]

In this example you will define a squad with 1 officer, with "this addWeapon {NVGoggles}" in init field, a skill of 0.9 and a rank of sergeant + 4 soldiers, nothing in init field, a skill of 0.7 and a rank of corporal + 2 machinegunners nothing in the init field a skill of 0.7 and a rank of corporal"

example 2: nik_sq2=[["SoldierWSaboteurPipe",12,"sld","this setCaptive true",0.9,"SERGEANT"]]

In this example you define a squad of 12 blackOp with setCaptive in init field,a skill of 0.9 and rank of sergeant.

example 3: nik_sq3=[["SoldierWG36a",2,"sld","",0.95,"SERGEANT"],["SoldierWG36a",8,"sld","",0.9,"CORPORAL"],["SoldierWSniper",2,"sld","",0.9,"CORPORAL"]]

In this example you will define a squad with 2 g36a soldiers, nothing in init field, a skill of 0.95 and rank of sergeant + 8 g36a soldiers, nothing in init field, a skill of 0.9 and rank of corporal + 2 snipers nothing in init field, a skill of 0.9 and rank of corporal.

NB: you can use a squad number as much as ofp engine allow. If you spawn more than 63 groups per side the squads above 63 will not spawn.

- Third, you have to define an array with the squad name defined in the array above, the spawn marker position (it must be a marker), the unit name from every others are spawned (this unit MUST exist or the squad won't be created, this unit can be the same for every squads), the squad behaviour, the squad combat mode, the squad formation, the UPS marker where the squad will patrol and the squad direction.

[squadName,"spawnMarkerName",dummyUnitName,"Behaviour","combatMode","formation","UPSMarkerName",direction] call nik_fspawnsquad

example1: [nik_sq1,"sq1_mark",nik_Dummy,"safe","red","vee","nik_town_mark",270] call nik_fspawnsquad

In this example you will spawn nik_sq1 (defined in the first array), the squad will spawn at the marker position named sq1_mark, the units from where the squad spawn is named nik_Dummy, the squad behaviour is safe, the squad combat mode is red (open fire engage at will), the squad formation is vee, the UPS marker name is nik_town_mark and the squad direction is 270°.

example2: [nik_sq2,"sq2_mark",nik_Dummy,"safe","yellow","wedge","nik_town_mark",270] call nik_fspawnsquad

In this example you will spawn nik_sq2 (defined in the first array), the squad will spawn at the marker position named sq2_mark, the units from where the squad spawn is named nik_Dummy, the squad behaviour is safe, the squad combat mode is yellow (open fire), the squad formation is wedge, the UPS marker name is nik_town_mark and the squad direction is 270°.

example3: [nik_sq3,"sq3_mark",nik_Dummy,"safe","red","line","nik_town_mark",270] call nik_fspawnsquad

In this example you will spawn nik_sq3 (defined in the first array), the squad will spawn at the marker named sq3_mark, the units from where the squad spawn is named nik_Dummy, the squad behaviour is safe, the squad combat mode is red (open fire engage at will), the squad formation is line, the UPS marker name is nik_town_mark and the squad direction is 270°.

init.sqs

;********************************
;init Script by Nikiller v0.9b
;contact: nikillerofp@hotm{ail.fr
;[] exec "scriptName.sqs}"
;********************************

nik_host=local server

;-----------------------------------------------------------------------------------------
; Teleport player (test only)
;-----------------------------------------------------------------------------------------
onMapSingleClick "player setPos _pos"

;-----------------------------------------------------------------------------------------
; Spawn squad UPS init
;-----------------------------------------------------------------------------------------
[] exec "ai\init_ai.sqs"

exit

init_ai.sqs

;*******************************************************
;AI Squad Init Script by Nikiller v0.9b
;Note: Place a game logic named server on the map
;contact: nikillerofp@hotmail.fr
;[] exec "scriptName.sqs"
;*******************************************************

if nik_host then {} else {goto "ende"}

;-----------------------------------------------------------------------------------------
; Spawn squad
;-----------------------------------------------------------------------------------------
nik_fspawnsquad=preprocessFile "ai\spawn_manager\spawnsquad_ups.sqf"
nik_sq1=[["OfficerW",1,"sld","",0.9,"SERGEANT"],["SoldierWB",4,"sld","",0.7,"CORPORAL"],["SoldierWG",4,"sld","",0.7,"CORPORAL"],["SoldierWMG",2,"sld","",0.7,"CORPORAL"]]
nik_sq2=[["SoldierWSaboteurPipe",12,"sld","",0.9,"SERGEANT"]]
nik_sq3=[["SoldierWG36a",2,"sld","",0.95,"SERGEANT"],["SoldierWG36a",8,"sld","",0.9,"CORPORAL"],["SoldierWSniper",2,"sld","",0.9,"CORPORAL"]]
~1
[nik_sq1,"sq1_mark",nik_Dummy,"safe","red","vee","nik_town_mark",270] call nik_fspawnsquad
~0.5
[nik_sq2,"sq2_mark",nik_Dummy,"safe","yellow","wedge","nik_town_mark",270] call nik_fspawnsquad
~0.5
[nik_sq3,"sq3_mark",nik_Dummy,"safe","red","line","nik_town_mark",270] call nik_fspawnsquad

#ende

exit

spawnsquad_ups.sqf

private ["_squadtype","_location","_group","_behaviour","_combatmode","_formation","_itemnum","_unit","_unitClass","_unitCount","_unitType","_unitInit","_unitSkill","_unitRank","_count","_dir"];

_squadtype = _this select 0;
_location = _this select 1;
_group = _this select 2;
_behaviour = _this select 3;
_combatmode = _this select 4;
_formation = _this select 5;
_move = _this select 6;
_dir = _this select 7;
_itemnum = 0;

if (nik_host) then
{
 while {_itemnum < count _squadtype}
Do
{
 	_unit = _squadtype select _itemnum;
_unitClass = _unit select 0;
_unitCount = _unit select 1;
_unitType = _unit select 2;
_unitInit = _unit select 3;
_unitSkill = _unit select 4;
_unitRank = _unit select 5;
_count = 0;
While {_count < _unitCount}
Do
{
 	_unitClass createUnit [getmarkerPos _location, _group, _unitInit, _unitSkill, _unitRank];
_count = _count + 1;
if (_count == 1 && _itemnum == 0) then 
{
	_newLeader = nearestObject [getmarkerPos _location, _unitClass];
	[_newLeader,_move] exec "ups.sqs";[_newLeader] join GrpNull; _group = _newLeader;
};
};
_itemnum = _itemnum + 1;
};
{
_x setcombatmode _combatmode;
_x setbehaviour _behaviour;
_x removealleventhandlers "killed";
_x setformation _formation;
_x setdir _dir;
_x addEventHandler ["killed", {[(_this select 0),120] exec "performance\del_unit.sqs"}];
}
forEach units _group;
true
}
Else
{
 false
};

_group

del_unit.sqs

;*******************************************************
;Delete Dead Bodies Script by Nikiller v0.9b
;Delete dead bodies
;Note: Place a game logic named server on the map
;[unitName,delay] exec "scriptName.sqs"
;*******************************************************

if nik_host then {} else {goto "ende"}

_b = _this select 0
_d = _this select 1

_ac="hidebody"
~_d
if (alive gravedigger) then {gravedigger action [_ac,_b]}
~10
_b setPos [0,0,0]
~1
deleteVehicle _b

#ende

exit

Here's a demo to show how it works: DEMO LINK

cya.

Nikiller.

Edited by Nikiller
updated dead link

Share this post


Link to post
Share on other sites

I just gave your UPS spawn script a quick glance and I have a few questions...

1) Is there anyway you can change which groups/units are spawned? For example how could I spawn WW4 units/groups, etc?

2) Is there anyway you can spawn units via a unit's init line? That way I could edit the spawn parameters in-game and could move spawn points in-game-->I wanna use gamelogics as spawn points :)

3) I assume that this would'nt work with vehicles....?

Thank you for making it! :D

Share this post


Link to post
Share on other sites

hi,

@ all: I included an HOW TO in the spawn squad UPS post. Please read it first.

1) Is there anyway you can change which groups/units are spawned? For example how could I spawn WW4 units/groups, etc?

Yes of course, you have to change the typeOf unit in the squad array (first array). Have a look in the WW4 documentation you will find all the classNames you need (weapons, units...).

example: nik_sq1=[["WW4_MOTSquadLeader",1,"sld","this addWeapon {NVGoggles}",0.9,"SERGEANT"],["WW4_MOTRifleman",4,"sld","",0.7,"CORPORAL"],["WW4_MOTMachinegun",2,"sld","",0.7,"CORPORAL"],["WW4_MOTGrenadier",4,"sld","",0.7,"CORPORAL"]]

2) Is there anyway you can spawn units via a unit's init line? That way I could edit the spawn parameters in-game and could move spawn points in-game-->I wanna use gamelogics as spawn points

I don't really see the point of using an unit's init field :confused:, it's not very userfriendly environment to script but it can work (not tested). BTW, I strongly recommand to use a text editor to call the scripts. Don't use gamelogics or it won't work. Use empty markers instead ;). Don't forget to press markers or you will not see them.

3) I assume that this would'nt work with vehicles....?

You are right it doesn't work with vehicles. I will have to write another script for that. :)

cya.

Nikiller.

Share this post


Link to post
Share on other sites

First off, thank you very much for all of your help thus far :D

Now, I've got a tricky one for you...

I've edited the spawned units to be WW4 units per your instructions; however, these spawned units dont seem to engage at all? Its almost as if they have setcaptive true turned on because its like they're ghosts. The spawned groups dont seem to notice/engage each other (even after walking right by one another) and regular, non-spawned units wont engage them either. Any ideas?? :confused:

I've also got 3 more quick questions:

1) What does the "sld" parameter mean?

2) I dont understand what the Nik_dummy is for

3) Is this script an infinite or limited respawn system?

Here is a copy of my AI init file (only file I have edited)

;*******************************************************

;AI Init Script by Nikiller v0.9b

;Note: Place a game logic named server on the map

;contact: nikillerofp@hotmail.fr

;[] exec "scriptName.sqs"

;*******************************************************

if nik_host then {} else {goto "ende"}

;-----------------------------------------------------------------------------------------

; Spawn squad

;-----------------------------------------------------------------------------------------

nik_fspawnsquad=preprocessFile "ai\spawn_manager\spawnsquad_ups.sqf"

~1

nik_sq1=[["WW4_WARRifleman",1,"sld","",0.7,"SERGEANT"],["WW4_WARAutorifleman",2,"sld","",0.5,"CORPORAL"],["WW4_WARGrenadier",2,"sld","",0.7,"CORPORAL"],["WW4_WARMedic",2,"sld","",0.7,"CORPORAL"],["WW4_WARRifleman",4,"sld","",0.5,"CORPORAL"],["WW4_WARRocket",1,"sld","",0.5,"CORPORAL"]]

nik_sq2=[["WW4_MOTRifleman",1,"sld","",0.7,"SERGEANT"],["WW4_MOTMachinegun",2,"sld","",0.5,"CORPORAL"],["WW4_MOTGrenadier",2,"sld","",0.7,"CORPORAL"],["WW4_MOTMedic",2,"sld","",0.7,"CORPORAL"],["WW4_MOTRifleman",4,"sld","",0.5,"CORPORAL"],["WW4_MOTRocket",1,"sld","",0.5,"CORPORAL"]]

nik_sq3=[["SoldierWG36a",2,"sld","",0.95,"SERGEANT"],["SoldierWG36a",8,"sld","",0.9,"CORPORAL"],["SoldierWSniper",2,"sld","",0.9,"CORPORAL"]]

~5

[nik_sq1,"sq1_mark",nik_Dummy,"Aware","red","vee","nik_town_mark",0] call nik_fspawnsquad

~0.5

[nik_sq2,"sq2_mark",nik_Dummy,"Aware","red","wedge","nik_town_mark",180] call nik_fspawnsquad

~0.5

[nik_sq3,"sq3_mark",nik_Dummy,"safe","red","line","nik_town_mark",270] call nik_fspawnsquad

#ende

exit

Share this post


Link to post
Share on other sites

hi,

First off, thank you very much for all of your help thus far :D

No problem, better to ask questions than copy and paste without any clue how it works. I understand that this script is a bit complex to use but it is also very flexible and powerful. From one unit you can populate the whole island without any performance impact of course if you use smart timing. Without modification you can spawn a crowd of civilians or simulate a big battle.

I've edited the spawned units to be WW4 units per your instructions; however, these spawned units dont seem to engage at all? Its almost as if they have setcaptive true turned on because its like they're ghosts. The spawned groups dont seem to notice/engage each other (even after walking right by one another) and regular, non-spawned units wont engage them either. Any ideas?? :confused:

I know what is wrong, I should have explain you before but I become old and I forget things :).

Your problem is that you are using the same dummy unit for each sides, it means that each spawned units are the same side and will never engage each others.

In the first demo I uploaded, the dummy unit is at north Nogova airport (little island) and is a west unit so every squads spawned are west even if it's east models. Then to fix it you have to spawn east squad from east dummy unit, west squad from west dummy unit and resistance squad from resistance dummy unit.

so your init_ai.sqs will look like this:

;************************************************* ******
;AI Init Script by Nikiller v0.9b
;Note: Place a game logic named server on the map
;contact: nikillerofp@hotmail.fr
;[] exec "scriptName.sqs"
;************************************************* ******

if nik_host then {} else {goto "ende"}

;-----------------------------------------------------------------------------------------
; Spawn squad
;-----------------------------------------------------------------------------------------
nik_fspawnsquadups=preprocessFile "ai\spawn_manager\spawnsquad_ups.sqf"
~1
nik_west_sq1=[["WW4_WARRifleman",1,"sld","",0.7,"SERGEANT"],["WW4_WARAutorifleman",2,"sld","",0.5,"CORPORAL "],["WW4_WARGrenadier",2,"sld","",0.7,"CORPORAL"],["WW4_WARMedic",2,"sld","",0.7,"CORPORAL"],["WW4_WARRifleman",4,"sld","",0.5,"CORPORAL"],["WW4_WARRocket",1,"sld","",0.5,"CORPORAL"]]
nik_west_sq2=[["WW4_WARRifleman",1,"sld","",0.7,"SERGEANT"],["WW4_WARAutorifleman",2,"sld","",0.5,"CORPORAL "],["WW4_WARGrenadier",2,"sld","",0.7,"CORPORAL"],["WW4_WARMedic",2,"sld","",0.7,"CORPORAL"],["WW4_WARRifleman",4,"sld","",0.5,"CORPORAL"],["WW4_WARRocket",1,"sld","",0.5,"CORPORAL"]]
nik_west_sq3=[["WW4_WARRifleman",1,"sld","",0.7,"SERGEANT"],["WW4_WARAutorifleman",2,"sld","",0.5,"CORPORAL "],["WW4_WARGrenadier",2,"sld","",0.7,"CORPORAL"],["WW4_WARMedic",2,"sld","",0.7,"CORPORAL"],["WW4_WARRifleman",4,"sld","",0.5,"CORPORAL"],["WW4_WARRocket",1,"sld","",0.5,"CORPORAL"]]

nik_east_sq1=[["WW4_MOTRifleman",1,"sld","",0.7,"SERGEANT"],["WW4_MOTMachinegun",2,"sld","",0.5,"CORPORAL"],["WW4_MOTGrenadier",2,"sld","",0.7,"CORPORAL"],["WW4_MOTMedic",2,"sld","",0.7,"CORPORAL"],["WW4_MOTRifleman",4,"sld","",0.5,"CORPORAL"],["WW4_MOTRocket",1,"sld","",0.5,"CORPORAL"]]
nik_east_sq2=[["WW4_MOTRifleman",1,"sld","",0.7,"SERGEANT"],["WW4_MOTMachinegun",2,"sld","",0.5,"CORPORAL"],["WW4_MOTGrenadier",2,"sld","",0.7,"CORPORAL"],["WW4_MOTMedic",2,"sld","",0.7,"CORPORAL"],["WW4_MOTRifleman",4,"sld","",0.5,"CORPORAL"],["WW4_MOTRocket",1,"sld","",0.5,"CORPORAL"]]
nik_east_sq3=[["WW4_MOTRifleman",1,"sld","",0.7,"SERGEANT"],["WW4_MOTMachinegun",2,"sld","",0.5,"CORPORAL"],["WW4_MOTGrenadier",2,"sld","",0.7,"CORPORAL"],["WW4_MOTMedic",2,"sld","",0.7,"CORPORAL"],["WW4_MOTRifleman",4,"sld","",0.5,"CORPORAL"],["WW4_MOTRocket",1,"sld","",0.5,"CORPORAL"]]

~5
[nik_west_sq1,"west_sq1_mark",nik_WestDummy,"Aware","red","vee"," nik_town_mark",0] call nik_fspawnsquadups
~0.5
[nik_west_sq2,"west_sq2_mark",nik_WestDummy,"Aware","red","vee"," nik_town_mark",0] call nik_fspawnsquadups
~0.5
[nik_west_sq3,"west_sq3_mark",nik_WestDummy,"Aware","red","vee"," nik_town_mark",0] call nik_fspawnsquadups
~0.5
[nik_east_sq1,"east_sq1_mark",nik_EastDummy,"Aware","red","wedge" ,"nik_town_mark",180] call nik_fspawnsquadups
~0.5
[nik_east_sq2,"east_sq2_mark",nik_EastDummy,"Aware","red","wedge" ,"nik_town_mark",180] call nik_fspawnsquadups
~0.5
[nik_east_sq3,"east_sq3_mark",nik_EastDummy,"Aware","red","wedge" ,"nik_town_mark",180] call nik_fspawnsquadups

#ende


exit

Here's a demo to show how it works: DEMO LINK

1) What does the "sld" parameter mean?

It's a not used parameter leave it as it is.

2) I dont understand what the Nik_dummy is for

It is the unit from where all the others will be spawned. In ofp you need at least one unit present on the map to spawn others units. In ArmA2 not. In the demo the dummy units (east and west) are in the north nogova airport. I suggest to put those units in safe place on a little island far away from the action with this stop true in their init field and maybe this setCaptive true too.

3) Is this script an infinite or limited respawn system?

In the demo respawn is limited to 1, it means that groups will spawn only one time. But it can becomes inifinitive if you use for example a script who check if no units in the group are left and then execute spawn script to spawn a new one.

cya.

Nikiller.

Edited by Nikiller

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×