{"name":"BIS_fnc_animalSiteSpawn","operator":null,"title":"BIS fnc animalSiteSpawn","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_animalSiteSpawn","revid":364276,"updated":"2024-05-06T09:38:32Z","groups":["Ambient"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.00"}],"since":{"game":"arma3","name":"Arma 3","version":"1.00"},"arma3_since":"1.00","branch":null,"locality":{"argument":null,"effect":null,"server_exec":true},"exec":null,"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.","syntaxes":[{"syntax":"[animalSite, classnamesToSpawn, radius] call BIS_fnc_animalSiteSpawn","since":null,"effect":null,"exec":null,"params":[{"name":"animalSite","type":"Object","optional":false,"default":null,"description":"the object to create the site around.","types":["Object"],"since":null,"text":"animalSite: Object - the object to create the site around."},{"name":"classnamesToSpawn","type":"Array of Strings","optional":false,"default":null,"description":"animals that can be spawned.","types":["Array","String"],"since":null,"text":"classnamesToSpawn: Array of Strings - animals that can be spawned."},{"name":"radius","type":"Number","optional":false,"default":null,"description":"the radius by which animals are created or deleted.","types":["Number"],"since":null,"text":"radius: Number - the radius by which animals are created or deleted."}],"returns":{"type":"Script Handle","types":["Script Handle"],"description":null,"text":"Script Handle"}}],"examples":[{"text":"```sqf\n[player, [\"rabbit_f\", \"turtle_f\", \"hen_random_f\"], 200] call BIS_fnc_animalSiteSpawn;\n```","code":["[player, [\"rabbit_f\", \"turtle_f\", \"hen_random_f\"], 200] call BIS_fnc_animalSiteSpawn;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["Arma 3: CfgVehicles Animals"],"notes":[{"user":"DreadedEntity","date":"2014-12-07T08:37:00Z","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.\n\n```sqf\nprivate _obj = createVehicle [\"Sign_Sphere10cm_F\", getPos player, [], 0, \"CAN_COLLIDE\"];\nhideObjectGlobal _obj;\nplayer setVariable [\"animalSite\", _obj];\n_obj = nil;\n```\n\nThere are two hidden variables, \"animalCount\" and \"radius\". Use setVariable on the object to change these.\n\nanimalCount is supposed to limit the amount of animals that can spawn. In the code, the algorithm for this is hard to understand.\n\nradius refers to how far away from the object the animals can spawn.\n\nBoth are numbers.\n\nThe \"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."},{"user":"Strangepete","date":"2014-12-07T09:26:00Z","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.\n\n```sqf\n_handle = [params] call BIS_fnc_animalSiteSpawn;\n\nif !(scriptDone _handle) then {\n    terminate _handle;\n};\n```"}],"categories":["Arma 3: Functions","Arma 3: New Functions","Function Group: Ambient","Functions","Functions: Server Execution","Introduced with Arma 3 version 1.00"],"docblock":null,"filled_from_docblock":[]}