Spearhead 1944 Code Snippets: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (R3vo moved page Spearhead 1944 Useful code snippets to Spearhead 1944 Code Snippets without leaving a redirect: They are useful, otherwise wouldn't be documented)
m (formatting and category)
Line 1: Line 1:
= Useful code snippets =
= Determine positions of craters on terrain =


== Determine positions of craters on terrain ==
The craters that are part of the terrain, are not objects.
 
The craters that are part of the terrain, not objects.


[[File:Normandy-Crater.jpg|thumb]]
[[File:Normandy-Crater.jpg|thumb]]


They usually have crater decals in them. But the terrain ones do not link to the config versions so detecting them is harder.
They usually have crater decals in them but the once present on the terrain do not link to the config versions which makes detecting them is harder.


There may be a better way than this to find them, but this is what came to mind first.
In order to detect craters within 10 meters around the player, use the following code:
<sqf>
(nearestObjects [player, [], 10]) select
{
  ((getModelInfo _x) # 0) in ["spe_crater_decal_large.p3d","spe_crater_decal_small.p3d"]
};
</sqf>


<sqf>(nearestObjects [player, [], 10]) select {((getModelInfo _x) # 0) in ["spe_crater_decal_large.p3d","spe_crater_decal_small.p3d"]}</sqf>
[[Category: Spearhead 1944}}

Revision as of 12:53, 5 August 2023

Determine positions of craters on terrain

The craters that are part of the terrain, are not objects.

Normandy-Crater.jpg

They usually have crater decals in them but the once present on the terrain do not link to the config versions which makes detecting them is harder.

In order to detect craters within 10 meters around the player, use the following code:

(nearestObjects [player, [], 10]) select { ((getModelInfo _x) # 0) in ["spe_crater_decal_large.p3d","spe_crater_decal_small.p3d"] };

[[Category: Spearhead 1944}}