Jump to content
  • 0

AI heli crash loot


BetterDeadThanZed

Question

I found this topic on opendayz.net: http://opendayz.net/threads/ai-helicopter-crashes-spawn-loot.18701/#post-113557

 

I installed it and when the AI heli is shot down, it does spawn loot per the RPT file, but I am not finding the loot on the ground. I've posted some errors in my log file on that thread, so maybe you guys can look at it and tell me what you think? I've shot down 4 helicopters and not found loot at any of them.

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

I've downloaded the mbnqcrash.sqf from somewhere and had a look.

 

Your cited rpt suggests to take the unknown ItemBookBible out of line 242

_items = ["ItemBookBible", "ItemSandbag", "PipeBomb"]; 

Looking at

	_pos0 = _centrum0 + ceil(random _spawnradious)* cos ceil(random 360);
	_pos1 = _centrum1 + ceil(random _spawnradious)* cos ceil(random 360);
	_pos2 = _lootlift;

I shudder :-) (using cos in both coordinates and both, radius and angle are randomly determined twice, thus being totally independent). I'd prefer something more well defined, like

        _radius = _minradius + (random _spawnradious)
        _angle  = (random 360)
	_pos0 = _centrum0 + _radius * cos _angle;
	_pos1 = _centrum1 + _radius * sin _angle;

using new private variable _radius, _angle for a standard polar formula and _minradius, set to something like 10m,  to avoid the loot spawning under the heliwrack.

 

Perhaps play with _lootlift, too. At crash positions you get a cratered landscape that may well exceed the default 0.1m in height.

 

Then I'd (re-)activate some of the diag_log lines (e.g. line 189). They can tell you how many of which loot has spawned where. Perhaps something like

	{
	  _spawnlootpoint addMagazineCargoGlobal [_x,(floor(random _itemsamount))];
          diag_log format["spawned %1 at %2", _x, _spawnlootpoint]
	} foreach _items;

Note that _x is an internal variable automatically generated in loops.

 

For test purposes you could set all _spawnchance to 1.0. temporarily.

Link to comment
Share on other sites

  • 0

You lost me there. What you are talking about is definitely beyond any knowledge I have... Now, according to what I've seen in my server's chat, some people are saying they are finding loot when they shoot down an AI heli but when I test it on my test server, I find none. I just tried it again and here's the log:

20:03:28 "[MBNQ] NPC heli destroyed, spawning loot"
20:03:35 Error in expression <_spawnlootpoint addMagazineCargoGlobal [_x,(floor(random _itemsamount))];		
} fo>
20:03:35   Error position: <_x,(floor(random _itemsamount))];		
} fo>
20:03:35   Error Undefined variable in expression: _x
20:03:35 File z\addons\dayz_server\DZAI\spawn_functions\mbnqcrash.sqf, line 185
20:03:35 "[MBNQ] ERROR: Out of limit 11 items at NPC UH1H_TK_EP1 crash site"
20:03:36 "[MBNQ] NPC Crash loot spawner done"
20:03:36 "[MBNQ] Spawned 11 items at NPC UH1H_TK_EP1 crash site"

Line 185: 

_spawnlootpoint addMagazineCargoGlobal [_x,(floor(random _itemsamount))];
Link to comment
Share on other sites

  • 0

according to what I've seen in my server's chat, some people are saying they are finding loot when they shoot down an AI heli but when I test it on my test server, I find none

 That may be due to the randomly chosen location of the loot which may or may not be covered by the heli wrack or earth mounds.

 

You could try to get a better location by expanding

private [
	"_lootrepeat",

to

private [
        "_angle",
        "_radius", 
        "_minradius",
	"_lootrepeat",

changing

_lootlift = 0.1;

to

_lootlift = 0.1;
_minradius = 10.0;

and replacing

	_pos0 = _centrum0 + ceil(random _spawnradious)* cos ceil(random 360);
	_pos1 = _centrum1 + ceil(random _spawnradious)* cos ceil(random 360);

with

        _radius = _minradius + (random _spawnradious)
        _angle  = (random 360)
	_pos0 = _centrum0 + _ radius * cos _angle;
	_pos1 = _centrum1 + _ radius * sin _angle;

I just tried it again and here's the log:

That's odd. _x is a magic variable https://community.bistudio.com/wiki/forEach that does not need to be defined explicitely.

As this is the only place in the script where a foreach loop is used and your log indicates that the spawning of weapons has been performed (the error occurs in the _magspawn function, while the 'spawned 11 items' message comes from the _weaponspawn function), I guess the variable _item in

	{
	_spawnlootpoint addMagazineCargoGlobal [_x,(floor(random _itemsamount))];	
        } foreach _items;

	// diag_log format["Zmienna items %1",_items];

does not contain an array. Try to uncomment the diag_log after the loop (Zmienna...) so we can see how _items looks like and can repair it.

 

To find the spawned weapons try to expand

	_spawneditems = _spawneditems + 1;
	if ( _spawneditems > _lootamount ) exitWith {diag_log format["[MBNQ] ERROR: Out of limit %1 items at NPC %2 crash site",_spawneditems,(typeOf _crashedHeli)]};

to

	_spawneditems = _spawneditems + 1;
        diag_log format ["[MBNQ] _weaponspawn at pos %1", _itemSpawnPos];
	if ( _spawneditems > _lootamount ) exitWith {diag_log format["[MBNQ] ERROR: Out of limit %1 items at NPC %2 crash site",_spawneditems,(typeOf _crashedHeli)]};

This should give you the position(s) where the items spawned and you can use InfiStar to navigate to the exact point.

 

As I didn't test the code I proposed, I hope there are no systax errors in it....

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...