Forum Jump :

Author Message

Posts: 2

Level: Member

Country: ca
In-game name:

#1 Posted at 2015-11-07 23:36        
Hi all,
I am tring to create a basic addon that decreases the amount of fatigue by a variable. I have made it in individual missions, but I'd like to make it an addon so I can have it accessible all the time with my group...

I have looked for a guide on how to get this started, but haven't come up with anything. Everything I see is about creating some magical 'p' drive and all this... It seems like it's overly complex for what I'm attempting - I should just be able to script this, correct?

Anyways, I have the following script:

if !(hasInterface) exitWith{};
waitUntil {!isNull(findDisplay 46)};
waitUntil {!isNull player};

//set global variables
missionNamespace setVariable ["OHTC_FatigueMultiplier", 0.3];

_l = 0; //The last fatigue we had
while {true} do {
	if(!(isNil "OHTC_FatigueMultiplier") && typeName OHTC_FatigueMultiplier == "SCALAR" && OHTC_FatigueMultiplier >0 0 OHTC_FatigueMultiplier <= 1) then {
		//The current fatigue of the player
		_c = getfatigue player;
		//The default increase: ie: difference between what we have now, and what we had last time we ran
		_di = _c - _l;
		//The NEW increase in fatigue would be the percentage we request of the default increase
		_ni = _di - (_di * OHTC_FatigueMultiplier);
		//Assuming we've gone up: let's set the fatigue to the new value;
		if(_ni > 0) then {
			player setFatigue _c - _ni;
		systemChat format ["Last: %1, Current: %2, Default Inc: %3, Multiplier: %4, New Inc: %5, Final Fatigue: %6", _l, _c, _di, OHTC_FatigueMultiplier, _ni, getfatigue player];
		//Now we set our last historical value to our modified value
		_l = getfatigue player;

	sleep 1;

And I want it as a mod. I've taken apart a couple mods with Elitness, but I'm not understanding how to piece one together myself.

I have folder in my arma directory called "@OHTCfatigueMultiplier".
Inside this folder I have another folder called "addons"
Inside the addons folder I have a script - init.sqf - that contains the above script.

What else am I missing, please?

Thank you

This post was edited by JayNic (2015-11-07 23:52, ago)

Author Message

Posts: 1589

Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 59
In-game name: Kobayashi Maru

#2 Posted at 2015-11-08 00:27        
You need to pbo your files. if you look at an addon, you'll find the addons folder, plus a possible keys folder for signed ones (to install it in a server for example).
You have all you need in arma3 tools:

Before pbo, you must have a config.cpp (a kind of description.ext) with the classes cfgPatches (your addon identifier)
and cfgFunctions (the way to launch your addon via an sqf).
Avoid init.sqf, this is a special sqf for all scripted missions. choose something else, the important thing is to launch your main sqf function via cfgFunctions.
You can find some docs on BIKI and other sites.



Author Message

Posts: 1189

Level: Member

Country: tr
Occupation: Computer Science student
Age: 22
In-game name: Wak

#3 Posted at 2015-11-08 09:19        
Your addon is fairly simple, but you'll still need the arma 3 tool set. You should have two files in a folder called config.cpp and init.sqf (the name of the script really doesn't matter). For this example, I'm going to name the folder fatigue_adjusment, if you want to change it, you should change any text in the config.cpp that says fatigue_adjusment with the name of your choice. The folder will become a pbo later, which you'll put under
Arma 3\@OHTCfatigueMultiplier\AddOns\fatigue_adjusment.pbo

Put this c++ code inside the config.cpp and edit it if you want:

Since we're calling it as a function, we'll have to spawn the code inside the init.sqf, look at my modifications. Also since this code will run at postInit, I took the freedom of removing the unnecessary waitUntils. Also there is a error at line 8, but I didn't touch that:

This post was edited by 654wak654 (2015-11-08 11:09, ago)

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message

Posts: 2

Level: Member

Country: ca
In-game name:

#4 Posted at 2015-11-09 00:43        
Thanks so much, 654wak654!

I was able to get it working how you mentioned.
I really appreciate this explanation. Arma modding is really interesting to me, but the wiki and documentation are terrible. There's far too much tacit knowledge floating around, and not very verbose/available tutorials