Jump to content
neodyn

Enemy should dropp Items

Recommended Posts

Hello,

 

i want to make a kind of Insurgency mission.

 

What i expect:

A player kills an AI the dead AI drops an suitcase.

 

The script:

if (isServer || isDedicated) then {
	if (random 100 >= (paramsArray select 3)) then {
		private["_unit","_intelItems","_selectedItem","_droppedItem"];
		_unit = _this select 0;
		_intelItems = "Land_Suitcase_F";
		INS_droppedItems = [];
		_selectedItem = _intelItems call BIS_fnc_selectRandom;
		_droppedItem = createVehicle [_selectedItem, _unit, [], 0, "None"];
		[[_droppedItem,"<t color='#00FF00'>Grab Intel</t>"],"fnc_addactionMP", true, true] spawnBIS_fnc_MP;
		_droppedItem setPosATL getPosATL (_this select 0);
		INS_droppedItems set [count INS_droppedItems, _droppedItem];
		publicVariable "INS_droppedItems";
	};
};

What happens:

the "paramsArray select 3" is set to 90%. So nearly every enemy should drop an Intel.

 

Maybe intresting:  the whole AI handling is made by ALIVE

 

Anyone who can help me to force AI drop me some intel?

Share this post


Link to post
Share on other sites
_droppedItem = createVehicle [_selectedItem, position _unit, [], 0, "None"]; //createVehicle needs a position.

You should really play with "-showscripterrors". ;)

 

EDIT : I assume the script is triggered by an EH?

If playing with Alive, you better make sure the mod stores those when caching/uncaching units...

Share this post


Link to post
Share on other sites

I run Arma with "-showscripterrors". 

But it seems the scripts wont be triggert.

 

I think the line sets an pos.

According to BIwiki:

_veh = createVehicle ["ah1w", position player, [], 0, "FLY"];

I can't find an error

Share this post


Link to post
Share on other sites

Again : if you're playing with Alive, you need to make sure your "Killed" EH is actually added to spawned units.

Either run a loop to check for newly added infantry, or do this the other way around :

Add a "fired" EH to each of the player group units; from there you just need to check if they kill their target - and then execute your script on it.

Share this post


Link to post
Share on other sites

I use such an EH (EventHandler)

if (isServer || isDedicated) then {
	private["_unit"];
	_unit = _this select 0;
	if ((side _unit == EAST) || (side _unit == RESISTANCE)) then {
		_unit addEventHandler ["Killed", {_this call INS_fnc_intelDrop}];
		if (ins_debug) then {
			["EventHandler added to unit"] call ALIVE_fnc_dump;
		};
	} else {
		if (ins_debug) then {
			["Skipping Unit"] call ALIVE_fnc_dump;
		};
	};
};

Share this post


Link to post
Share on other sites

And where do you execute the above from?

Is it launched by a trigger?

  • Like 1

Share this post


Link to post
Share on other sites

Oh damn you got it.

 

I had to trigger it in my description.ext.

class Extended_InitPost_EventHandlers {
class Man 
 {
  init = "_this call INS_fnc_handlerRegister";
 };
};

Thank you so much haleks

  • Like 1

Share this post


Link to post
Share on other sites

I was looking for this particular kind of insurgency where enemies drops an suitcase. If you be able to finish this do you have plans to release it?

Share this post


Link to post
Share on other sites
Okay so now the AI drops the Intel. Everything works good.
But now 2 more problems came up.
 
1) I can't find a way how to place / drop the intel, for example 0.5m far away of the killed AI.
The code:
_droppedItem = createVehicle [_selectedItem, _unit, [], 0, "None"];
[[_droppedItem,"<t color='#FF0000'>Get Intel</t>"],"INS_fnc_addactionMP", true, true] spawn BIS_fnc_MP;
_droppedItem setPosATL getPosATL (_this select 0);

so try to change the first line to:

_droppedItem = createVehicle [_selectedItem, _unit + 0.5, [], 0, "None"];
Brings up an error.
 
Then i found out accoring to BIWIKI ( https://community.bistudio.com/wiki/createVehicle )
_droppedItem = createVehicle [_selectedItem, _unit, [], 0.5, "None"];
But brings up an error.
 
What do i had to do to resolve this issue?
 
2) 
Everytime the intel has been dropped or placed in or an house, it is not possilbe to pick it up.
So the object i.e. Laptop show me the option "Get Intel" but when click on "Get Intel" nothing happen.
This only occures on dropped Items of dead AI and on Items placed on or in houses.
 
The code for fnc_addactionMP :
private["_object","_screenMsg"];
_object = _this select 0;
_screenMsg = _this select 1;
if(isNull _object) exitWith {};
_object addaction [_screenMsg,"call INS_fnc_intelPickup", nil, 6, True, True, "", "(_target distance _this) < 6"];
The code for fnc_intelPickup :
private ["_intelItems","_intel","_used","_ID","_cases","_case","_cache","_x"];


_intelItems = INS_INTELDROPPED + INS_INTELSPAWNED;
_intel = _this select 0;
_used = _this select 1;
_ID = _this select 2;
_intel removeAction _ID;
_cases = nearestObjects[getPos player, _intelItems, 4.5];


if (isNull CACHE) then {
private ["_title","_text"];


_title = "TEXT bla", _title];


["openSideTop",1.4] call ALIVE_fnc_displayMenu;
["setSideTopText",_text] call ALIVE_fnc_displayMenu;


{
deleteVehicle _x;
} forEach _cases;
} else {


_cache = CACHE;


if (count _cases == 0) exitWith {};


{
deleteVehicle _x;
[_cache, "INS_fnc_createIntel", false, false] spawn BIS_fnc_MP;
} forEach _cases;


 player groupChat "Juhu";


 [nil, "INS_fnc_pickedUpIntel", true, false] spawn BIS_fnc_MP;


};

So is there an Problem while placing the Item with " ... setPosATL getPosATL ...".

I don't really understand the " ... setPosATL getPosATL ..." object.

Share this post


Link to post
Share on other sites
_droppedItem = createVehicle [_selectedItem, _unit, [], 0.5, "None"];
But brings up an error.

Once again, createVehicle needs a position, not an object. ^^'

_droppedItem = createVehicle [_selectedItem, position _unit, [], 0.5, "None"];

The code for fnc_addactionMP :

 

private["_object","_screenMsg"];
_object = _this select 0;
_screenMsg = _this select 1;
if(isNull _object) exitWith {};
_object addaction [_screenMsg,"call INS_fnc_intelPickup", nil, 6, True, True, "", "(_target distance _this) < 6"];
You forgot to pass the object in the action argument :

_object addaction [_screenMsg,"call INS_fnc_intelPickup", [_object], 6, True, True, "", "(_target distance _this) < 6"];
If you fail to do that, _target won't refer to anything.

Share this post


Link to post
Share on other sites

There is a nice function from BIS which you give the exact relative position from a given object, given distance and given angle.

 

So, if you want it, lets say 1 meter on the back of someone:

 

_pos = [_unit,1,getDir _unit + 180] call BIS_fnc_relPos;

 

and then:

 

_droppedItem = createVehicle [_selectedItem, _pos, [], 0, "None"];

 

From that you have a variable _pos which contains a position array (like [23123,1442,90]) which you can use with lots of commands like thing setPos _pos.

 

Also you can "play" with that function, lets say random angles and random distances:

 

_pos = [_unit, random 10, random 360] call BIS_fnc_relPos;

 

Very useful!!!

  • Like 2

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

×