BIS fnc animalSiteSpawn: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " <h3 style="display:none">Notes</h3> <dl class="command_description"> <!-- Note Section BEGIN --> <!-- Note Section END --> </dl>" to "")
m (Text replacement - "(\|[pr][0-9]+ *= *[^- ]*) *- *T([a-z ])" to "$1 - t$2")
 
(29 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Function|Comments=
{{RV|type=function


| arma3 |Game name=
|game1= arma3
|version1= 1.00


|1.00|Game version=
|gr1= Ambient


|gr1= Ambient |GROUP1=
|serverExec= server


|serverExec= server
|descr= Create an area that spawns animals. The animals will be created or deleted if a player is inside or outside the area's radius.


| Create an area that spawns animals. The animals will be created or deleted if a player is inside or outside the area's radius. |DESCRIPTION=
|s1= [animalSite, classnamesToSpawn, radius] call [[BIS_fnc_animalSiteSpawn]]


| [animalSite, classnamesToSpawn, radius] call [[BIS_fnc_animalSiteSpawn]]; |SYNTAX=
|p1= animalSite: [[Object]] - the object to create the site around.


|p1= [animalSite, classnamesToSpawn, radius]: [[Array]]|PARAMETER1=
|p2= classnamesToSpawn: [[Array]] of [[String]]s - animals that can be spawned.
|p2= animalSite: [[Object]] - The object to create the site around.|PARAMETER2=
|p3= classnamesToSpawn: [[Array]] - Animals that can be spawned.|PARAMETER3=
|p4= radius: [[Number]] - The radius by which animals are created or deleted.|PARAMETER4=


| [[Script_(Handle)]] |RETURNVALUE=
|p3= radius: [[Number]] - the radius by which animals are created or deleted.


|x1= <code>[ [[player]], ["rabbit_f","turtle_f","hen_random_f"], 200] [[call]] [[BIS_fnc_animalSiteSpawn]];</code> |=
|r1= [[Script Handle]]


| [[Arma 3 CfgVehicles Animals]] |SEEALSO=
|x1= <sqf>[player, ["rabbit_f", "turtle_f", "hen_random_f"], 200] call BIS_fnc_animalSiteSpawn;</sqf>


|seealso= [[Arma 3 CfgVehicles Animals]]
}}
}}


 
{{Note
<h3 style="display:none">Bottom Section</h3>
|user= DreadedEntity
 
|timestamp= 20141207083700
[[Category:Functions|{{uc:animalSiteSpawn}}]]
|text= The only way to stop the animals from spawning is to delete the object. When using this function, I recommend creating a non-solid object (almost anything from the "Objects (Helpers)" list in the editor, and using [[hideObjectGlobal]] on it. Using [[setVariable]] you can add the animal site to a reference object to find it easily when you want to delete it.
[[Category:{{Name|arma3}}: Functions|{{uc:animalSiteSpawn}}]]
<sqf>
 
private _obj = createVehicle ["Sign_Sphere10cm_F", getPos player, [], 0, "CAN_COLLIDE"];
<!-- CONTINUE Notes -->
hideObjectGlobal _obj;
<dl class="command_description">
player setVariable ["animalSite", _obj];
<dd class="notedate">Posted on December 7, 2014 - 08:37 (UTC)</dd>
_obj = nil;
<dt class="note">[[User:DreadedEntity|DreadedEntity]]</dt>
</sqf>
<dd class="note">
The only way to stop the animals from spawning is to delete the object. When using this function, I recommend creating a non-solid object (almost anything from the "Objects (Helpers)" list in the editor, and using [[hideObjectGlobal]] on it. Using [[setVariable]] you can add the animal site to a reference object to find it easily when you want to delete it.
<code>_obj = [[createVehicle]] ["Sign_Sphere10cm_F", [[getPos]] [[player]], [], 0, "CAN_COLLIDE"];
[[hideObjectGlobal]] _obj;
player [[setVariable]] ["animalSite", _obj];
_obj = [[nil]];</code>


There are two hidden variables, "animalCount" and "radius". Use [[setVariable]] on the object to change these.<br>
There are two hidden variables, "animalCount" and "radius". Use [[setVariable]] on the object to change these.<br>
Line 48: Line 41:
Both are numbers.<br><br>
Both are numbers.<br><br>
The "area" is imaginary. It is not a tangible area defined by trigger or marker radius, the area is only saved as an integer within the function.
The "area" is imaginary. It is not a tangible area defined by trigger or marker radius, the area is only saved as an integer within the function.
</dd>
}}
</dl>
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= Strangepete
<dd class="notedate">Posted on December 7, 2014 - 09:26 (UTC)</dd>
|timestamp= 20141207092600
<dt class="note">[[User:Strangepete|Strangepete]]</dt>
|text= Using the [[Script Handle]] returned, the function can be checked using [[scriptDone]] or killed with [[terminate]]; Existing generated animals will ''not'' be cleaned up when terminated.
<dd class="note">
<sqf>
Using the [[Script_(Handle)]] returned, the function can be checked using [[scriptDone]] or killed with [[terminate]]; Existing generated animals will ''not'' be cleaned up when terminated.
_handle = [params] call BIS_fnc_animalSiteSpawn;
<code>_handle <nowiki>=</nowiki> [''params''] [[call]] BIS_fnc_animalSiteSpawn;


if(!(scriptDone _handle)) then {
if !(scriptDone _handle) then {
    [[terminate]] _handle;
terminate _handle;
};</code>
};
</dd>
</sqf>
</dl>
}}
<!-- DISCONTINUE Notes -->

Latest revision as of 16:51, 8 November 2023

Hover & click on the images for description

Description

Description:
Create an area that spawns animals. The animals will be created or deleted if a player is inside or outside the area's radius.
Execution:
call
Groups:
Ambient

Syntax

Syntax:
[animalSite, classnamesToSpawn, radius] call BIS_fnc_animalSiteSpawn
Parameters:
animalSite: Object - the object to create the site around.
classnamesToSpawn: Array of Strings - animals that can be spawned.
radius: Number - the radius by which animals are created or deleted.
Return Value:
Script Handle

Examples

Example 1:
[player, ["rabbit_f", "turtle_f", "hen_random_f"], 200] call BIS_fnc_animalSiteSpawn;

Additional Information

See also:
Arma 3 CfgVehicles Animals

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
DreadedEntity - c
Posted on Dec 07, 2014 - 08:37 (UTC)
The only way to stop the animals from spawning is to delete the object. When using this function, I recommend creating a non-solid object (almost anything from the "Objects (Helpers)" list in the editor, and using hideObjectGlobal on it. Using setVariable you can add the animal site to a reference object to find it easily when you want to delete it.
private _obj = createVehicle ["Sign_Sphere10cm_F", getPos player, [], 0, "CAN_COLLIDE"]; hideObjectGlobal _obj; player setVariable ["animalSite", _obj]; _obj = nil;
There are two hidden variables, "animalCount" and "radius". Use setVariable on the object to change these.
animalCount is supposed to limit the amount of animals that can spawn. In the code, the algorithm for this is hard to understand.
radius refers to how far away from the object the animals can spawn.
Both are numbers.

The "area" is imaginary. It is not a tangible area defined by trigger or marker radius, the area is only saved as an integer within the function.
Strangepete - c
Posted on Dec 07, 2014 - 09:26 (UTC)
Using the Script Handle returned, the function can be checked using scriptDone or killed with terminate; Existing generated animals will not be cleaned up when terminated.
_handle = [params] call BIS_fnc_animalSiteSpawn; if !(scriptDone _handle) then { terminate _handle; };