Wolfenswan's function library

Party-approved future science plus handbooks for the revolution
User avatar
wolfenswan
Posts: 1209
Joined: Wed May 25, 2011 4:59 pm

Wolfenswan's function library

Post by wolfenswan »

Ahead of FA Template: NO
If ws_fnc is ahead of the FA template, it is because there have not been any critical updates to the library.

Updating your FA template is easy:
Download the archive from below and overwrite the ws_fnc folder in your mission directory. You can ignore the install guide below.

Latest master version: See README.
Github: Repository
Download: master.zip

What is this?
This is a collection of various functions that I've worked on the last weeks for way too long to streamline my mission making. None of them are revolutionary but all of them have been designed with efficiency, modularity and performance in mind. The idea is to reduce the need for repetitive scripting as much as possible while avoiding the need for third-party scripts and the problems that come with that. I've also tried and comment everything as best as possible to make understanding the code easier.

How do I use it?
Unzip the archive into your mission root folder. You should now have a ws_fnc/ folder with various sub-folders (named tools, AI etc.). Open the description.ext that came with the archive and copy & paste the entire part within

Code: Select all

cfgFunctions { }
into cfgFunctions at the bottom of your own description.ext.

If you use F3 it should look sth. like this:

Code: Select all

class CfgFunctions
{
	class F
	{
		//All F3 relevant functions
	};

	#include "ws_fnc\config.hpp"
};
If you now open the function viewer inside the editor (CTRL+F) you should be able to see all descriptions for all listed. Make sure to select "missionConfigFile" in the top-left drop down menu.

Is there a readme?
If you did the above you should be able to view all functions inside the game. Every major function is thoroughly document and explained in itself. You can also view all individual documentation on either github or by opening the .sqf files with a text editor.

Example functions
getPos (various functions)
Similar to SHK_Pos, it allows for easy return of randomized positions, positions within a defined marker/trigger area, positions only on roads etc.

createGroup/createVehicle
Advanced versions of the default createGroup/createVehicle scripting commands.

taskDefend
Orders AI to hold a position, manning statics and entering buildings.

createGarrison
Fills those empty buildings and bunkers with AI the easy way.

taskAmbush
Orders AI to lay an ambush on a position. They will move to a hiding spot which provides over watch over the ambush location.

taskConvoy
Hate how AI convoys always screw up no matter what you try to do? This little function will make them drive in an orderly column and also react to an engagement in a borderline smart fashion.

taskLand
Want airborne reinforcements but the transport helos keep bugging out when in contact? This should help.

collectMarkers
Placed dozens of markers all labeld mkr_1,mkr_2 etc but too lazy to put them all in an array manually? This function does the trick.

User avatar
wolfenswan
Posts: 1209
Joined: Wed May 25, 2011 4:59 pm

Re: Wolfenswan's function library

Post by wolfenswan »

Updated various functions to work together with A3, changed folder structure and made all functions register nicely in the new A3 library.

Updated:
ws_fnc_taskDefend
Now works with both A3 and A2. Performance slightly increased.

ws_fnc_betterVehicle
Uses event handler instead of while loop now. better perfomance.

New functions:
ws_fnc_taskCrew
Make units crew all static weapons and empty vehicle turrets in a given radius.

ws_fnc_attachLight
Attaches a light source to the given object. Brightness, color etc. can be modified.

ws_fnc_showFPS (A3 only)
Measures player FPS ingame for given time frame and displays afterwards.

ws_fnc_broadcast (A3 only)
Broadcasts a string to all clients, regardless of locality.

ws_fnc_gameCheck
Returns true when running A3, false when running A2.

User avatar
wolfenswan
Posts: 1209
Joined: Wed May 25, 2011 4:59 pm

Re: Wolfenswan's function library

Post by wolfenswan »

Update 10.10

Minor tweaks to some functions and restructuring of how getPos works.

New Functions
ws_fnc_loadVehicle
loads a single group, several groups or an array of units into designated vehicle, prioritizing driver/gunner/commander (in that order) over cargo slots
returns units that were not loaded

ws_fnc_nearestRoadPos
Returns nearest position on road

ws_fnc_nearestLandPos
Returns nearest position on dry land

ws_fnc_checkHC
Returns true when called on a headless client

User avatar
wolfenswan
Posts: 1209
Joined: Wed May 25, 2011 4:59 pm

Re: Wolfenswan's function library

Post by wolfenswan »

Update 11.10

New:
ws_fnc_taskAmbush
Makes a group find a position providing overwatch over the the parsed position. If enemy approaches the trigger or comes to close to the hiding group they start engaging.

ws_fnc_getPosInArea
Return a random position within a marker or trigger area

User avatar
wolfenswan
Posts: 1209
Joined: Wed May 25, 2011 4:59 pm

Re: Wolfenswan's function library

Post by wolfenswan »

Update 29.01

Misc. improvements.

New:
ws_fnc_cache
- caching system based on Black Mamba's work

User avatar
wolfenswan
Posts: 1209
Joined: Wed May 25, 2011 4:59 pm

Re: Wolfenswan's function library

Post by wolfenswan »

Update 31.01.

Several fixes and overhauls, especially for A2 version.

New:
ws_fnc_createGarrison - fills buildings in a town with units of specified side

ws_fnc_collectBuildings - collects Buildings in given area

User avatar
wolfenswan
Posts: 1209
Joined: Wed May 25, 2011 4:59 pm

Re: Wolfenswan's function library

Post by wolfenswan »

Update 01.02.

No new function but renamed all existing ones to clear up the description.ext. Thus if you update you have to manually delete all the old ones (all .sqfs apart from ws_fnc_init)

User avatar
wolfenswan
Posts: 1209
Joined: Wed May 25, 2011 4:59 pm

Re: Wolfenswan's function library

Post by wolfenswan »

Update 21.02.2014

New Functions
tripFlare
Creates colored smoke + chemlight at position

attachChem
attaches a chem light to unit

attachIR
attaches IR strobe to unit

Restructuring
New category (folder): misc/
Moved into misc/:
  • broadcast
  • showIntro
  • switchLights
  • attachLight
Other
  • Small bugfixes
  • Re-worked comments to several script (mostly adding examples)

User avatar
Dogface
Posts: 163
Joined: Wed Jan 23, 2013 1:13 am

Re: Wolfenswan's function library

Post by Dogface »

Preeeetty!

Cheers Wolfenswan, I hadn't really looked at these functions before but it turns out they are super neat and I shall surely be using them.

User avatar
wolfenswan
Posts: 1209
Joined: Wed May 25, 2011 4:59 pm

Re: Wolfenswan's function library

Post by wolfenswan »

Update 28.02.2014

new:
ws_fnc_taskLand (A3 only):
Prompts a Helicopter to land a certain location. It will ignore enemy fire as best as possible.
If it has units in cargo it'll wait until all are out, if it is empty,
it'll wait for the designated time or until all cargo seats are filled.
Afterwards it'll move to the designated location.

Fixes/Misc:
Added private declaration to ws_fnc_getEPos
Fixed title in ws_fnc_taskAmbush

Post Reply