Jump to content
Sign in to follow this  
daimyo21

Help with suicide bomber script

Recommended Posts

OK so I got this suicide bomber script working like a charm and im trying to make it work better with vehicles moving attacking the player.

So far the moving vehicles work well when the vehicle is named. So heres the code and Ill explain

Civilian/Vehicle Ini code: [This, victim] exec SMAT.SQS

//Smat = the civ/vehicle, and Target is now looking for a target named "victim"

_SMAT = _This Select 0

_Target = _This Select 1

@ ((_SMAT KnowsAbout _Target) > 1) || (! (Alive _SMAT))

? (! (Alive _SMAT)) : Exit

_SMAT SetUnitPos "Up"

_SMAT SetSpeedMode "Full"

_SMAT SetCombatMode "Red"

_SMAT SetBehaviour "Careless"

_Speak = False

#Loop

_SMAT DoMove GetPos _Target

? ((_SMAT Distance _Target) < 14) || (! (Alive _SMAT)) && (Random 10 > 1) : GoTo "Explosion"

? (! (Alive _SMAT)) : Exit

~ (10 + random 1.5)

GoTo "Loop"

#Explosion

_Ammo = ["grenade"]

_Rnd = Random ((Count _Ammo) - 0.001)

_Bomb = _Ammo Select (_Rnd - (_Rnd Mod 1))

_Bomb createvehicle GetPos _SMAT

"Grenade" createvehicle GetPos _SMAT

Exit

*Basically I want to know if there is a way to make the civ "SMat" Target all or any kind of BLUFOR unit including vehicles manned by blufor or US soldiers etc etc.

Ive tried adding [This, BLUFOR or BIS_US etc etc but it just declares those as the unit name.

Any help or advice would be great that uses this script. I know I can place triggers near non-moving cars/civs for blufor but as for individual units that charge the player, I want them to charge all blufor and not just the ones with names victim1, 2, 3, 4

Share this post


Link to post
Share on other sites

Noob question...Can you explain how I can put this in one of my missions? I would like to "not" know where or when it is going to happen.

Cheers.

Share this post


Link to post
Share on other sites

well so far if u have ambient civilian module working, its hard to spot civilians running or civilian like players running at u as they run around/away and then back in this script. What im trying to figure outis how to make 1 single civilian target all types of blufor, player or not... so I dont have to add 5 civilians and set there targets to each person in my squad so civ1 = teammate1, civ2 = teammate2 etc.. more realistic if I were to run near abomber and he doesnt explode but suddenly player2 runs near me and we both blow up... etc

Share this post


Link to post
Share on other sites

Here's a version of a "random hunter killer suicide bomber" script. The best part is if called right, you'll never know who the bomber is till it might be too late. :)

marketday.jpg

Call the script from a Trigger to pick a random bomber:

nul = [thislist select floor(random count thislist), WEST, 7, 20, true, true] execVM "hkRandom.sqf";

or from a unit's init field to specify the bomber:

nul = [this] execVM "hkRandom.sqf";

There are optional arguments for the side to attack, percentage chance to attack once a target is found, range to start looking for targets within, whether or not to warn the group that's being attacked and an optional sound file to be played by the attacking bomber.

MarketDay is a demo mission where you can see this script in action. Here's the code:

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault 2
// Created by: kylania
// 
// Based on code from SNKMAN
// http://forums.bistudio.com/showpost.php?p=1623731&postcount=4
//////////////////////////////////////////////////////////////////
//  Examples: 
//
//  Called from a trigger, Civilians - Present - Once to set 1 bomber out of preset Civs, attacking WEST, 70% chance of attack and 50m range.
//  nul = [thislist select floor(random count thislist), WEST, 7, 50] execVM "hkRandom.sqf";
//
//  Called from a unit's init, 100% chance to attack EAST units within 100m with a warning and shout.
//  nul = [this, EAST, 10, 100, true, true];
//
//  Default, attacking WEST targets 30% of the time within 20m warning the group but not yelling out a shout.
//  nul = [this] execVM "hkRandom.sqf";
//
//////////////////////////////////////////////////////////////////

_unit = _this select 0;  // Bomber unit, set randomly by trigger.
_side = if (count _this > 1) then {_this select 1} else {WEST};  // Side to attack, default West.
_prob = if (count _this > 2) then {_this select 2} else {3};  // Probilitiy of attack once a target is found, Number 1 - 10, higher = more chance.  Default 3 (30% chance or so);
_range = if (count _this > 3) then {_this select 3} else {20};  // Range to look for targets in, default 20m.
_warn = if (count _this > 4) then {_this select 4} else {true};  // Option to warn the attacked group, all group members will target the bomber, AI won't shoot civs though.  Default true.
_shout = if (count _this > 5) then {_this select 5} else {false};  // Option to make the bomber say a sound (declared below) before attacking.  Default false.
_sound = "allahu";  // Sound file declared in CfgSounds in description.ext for use with _shout option.

// Defaults.
_looking = true;
_target = objNull;

// Set to true to see status messages from the bomber.
_demo = true; 

if (isServer) then {

 // Init the target array.
 if (isNil "TargetArray") then {TargetArray = [];};

 // Start hunting.
 while {_looking} do {
_targets = _unit nearTargets _range;  // Check targets within range.

if (count TargetArray > 0) then {_targets = _targets - TargetArray;};

// We have targets in range...
if (count _targets > 0) then
{
	_count = 0;
	while { (_count < count _targets) } do
	{
		_selectTarget = (_targets select _count);
		// Make sure we know about the target and that they match the side we want to attack.
		if ( (_unit knowsAbout (_selectTarget select 4) > 0) && (_selectTarget select 2 == _side) ) then
		{
			TargetArray = TargetArray + [_selectTarget select 4];  // Grab the target unit objects
		};
	_count = _count + 1;
	};
};

// If we have valid target objects...
if (count TargetArray > 0) then {

	// Lets see if we're ready to die...
	_chance = round(random 9) + 1;

	// Demo text.
	if (_demo) then {_txt = format["Probability: %1, Roll: %2",_prob, _chance]; titleText[_txt, "PLAIN"];};

	// If the bomber is ready to die, stop looking and pick one of the random targets found...
	if (_chance <= _prob) then {
		if (_demo) then {hint format["Found these targets: %1", TargetArray];};
		_looking = false;
		_target = TargetArray select floor(random count TargetArray);
	} else {
		// The bomber is NOT ready to die, so do nothing.
		if (_demo) then {hintSilent "Sill hunting, not ready to die...";};
	};

} else {
	// No targets found so do nothing.
	if (_demo) then { hintSilent "Still hunting...";};
};

// Wait a while and clear any targets previously found.
sleep 5;
TargetArray = [];
 };

 // At this point we've found a target (broke out of loop via _looking = false)

 // Charge at the target!
 _unit SetUnitPos "Up";
 _unit SetSpeedMode "Full";
 _unit SetCombatMode "Red";
 _unit SetBehaviour "Careless";
 if (_demo) then {hint format["INCOMING for you %1!", _target];};

 // Shout or warn per options
 if (_shout) then {_unit say [_sound,5]};
 if (_warn) then {units (group _target) commandTarget _unit};

 // Make the bomber keep chasing the target till dead or within 3m.
 while {alive _unit && (_unit distance _target > 3)} do {
_unit doMove getPos _target;
sleep 3;
 };

 // We're in range, make sure we're still alive then pull the pin!
 if (alive _unit) then {"grenade" createVehicle getPos _unit};

};

Share this post


Link to post
Share on other sites

Do you mind if he shows up as an enemy?

On solution would be to pick some of the militiamen that look like civilians and take away their guns.

Share this post


Link to post
Share on other sites

Hey man, question...

how do I get rid of the music that gets added to my mission when I run the script?

awesome script! works fine

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
Sign in to follow this  

×