Jump to content
Sign in to follow this  
celery

CLY Heal - a self-bandaging script

Recommended Posts

I've been trying to figure out how to make a script just like this for a mission I'm working on right now. With the idea to give each coop player 3 Med Kits, and the ability to get more from a field hospital tent, but never be able to carry more than 3. The problem I have is... I'm not an expert at scripting. I was directed to this thread when I asked for help, and it seems like your bandage script is exactly what I want to put into my mission. I tried the script and it seems great, but I have a couple of questions...

I'm not sure exactly what the damage threshold value does. I tried lowering the value and I seemed to take less damage in general, but I'm not really sure. When I set the threshold to 0 I died very easily, like I hit a small rock while driving slowly on an ATV and I died right away. What does the threshold value actually do? The default value is 0.15 and I am assuming that you had to be more than 0.15 damage before the option to use bandages will appear. Is this correct?

Also, is there a way to make it so I can get more bandages from say... a Field Hospital? I have 2 medics in my mission that can deploy a mash_EP1 tent and I really want players to be able to get more bandages from the field hospitals that the medic deploy. But I don't want players to be able to take more than 3 bandages.

Share this post


Link to post
Share on other sites

The threshold's only purpose is to make the healing action active when you have at least that amount of damage. If you want a tent to give out bandages, add an action to it that increases the player's "CLY_healings" variable when that variable isn't 3 or more.

Share this post


Link to post
Share on other sites

This is the trigger so far...

tentS2 addAction ["Take bandages","take_bandages.sqf",nil,1,true,true,"","alive tentS2 and player distance _target<10"];

So exactly how would I add...

getVariable CLY_healings<3 and

... to the trigger condition?

lol, sorry I'm not better at this stuff. I tried jamming it in the trigger a several different way and keep getting errors. ( :P )

Also, in my "take_bandages.sqf" I started trying to script it, but I'm not sure what I'm doing. Kind of embarrassed to even post this, but this it what it looks like so far...

_tent = _this select 0;
_man = _this select 1;

if ((_man getVariable "CLY_healings")==0) then {
_man setVariable ["CLY_healings",(this getVariable "CLY_healings")+3,true]
} else {
if ((_man getVariable "CLY_healings")==1) then {
_man setVariable ["CLY_healings",(this getVariable "CLY_healings")+2,true]
} else {
if ((_man getVariable "CLY_healings")==2) then {
_man setVariable ["CLY_healings",(this getVariable "CLY_healings")+1,true]
};
};
};

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

Just set it to 3 when you use the action from the tent, no need to do math. :)

Share this post


Link to post
Share on other sites

Well, the action could be like this:

this addAction ["Take bandage","take_bandages.sqf",nil,1.4,true,true,"","_this getVariable 'CLY_healings'>=0 and _this getVariable 'CLY_healings'<3"]

And the script:

_caller=_this select 1;
_caller setVariable ["CLY_healings",(_caller getVariable "CLY_healings")+1,true];

Share this post


Link to post
Share on other sites

Thank you.

It worked great.

Is there a way to make it so players can never have more than X amount of bandages. Like in my case, I don't want players to be able to carry more than 3 bandages in their pockets. I don't want some guy taking bandages from the tent and stuffing them in his friends pockets and vice versa, then there will be 2 guys running around with like 50 bandages. Also, when I perform any action that involves animation, like deploying a weapon, or repairing a vehicle, the action "Cancel Bandaging" appears. Would it be okay to change it so it says "Cancel action"?

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

Don't use bandage objects at all and don't use the +1 for take bandage script. Just use the variable and have the tent set it to 3 specifically. That way you can't "horde" anything since you can't increase your count anyway, you can only use up the uses or set it to 3.

Share this post


Link to post
Share on other sites

I wasn't too far off on my first attempt. this is what I am using now and it works perfect. Maybe it's not the simplest method, but I tried doing it the other way and I couldn't get it to work.

_caller=_this select 1;

if ((_caller getVariable "CLY_healings")==2) then {
_caller setVariable ["CLY_healings",(_caller getVariable "CLY_healings")+1,true]
} else {
if ((_caller getVariable "CLY_healings")==1) then {
_caller setVariable ["CLY_healings",(_caller getVariable "CLY_healings")+2,true]
} else {
if ((_caller getVariable "CLY_healings")==0) then {
_caller setVariable ["CLY_healings",(_caller getVariable "CLY_healings")+3,true]
};
};
};
hint "You now have 3 Bndages";
sleep 6;
hint "";

If I change...

_giveaction=100

_takeaction=100

to be...

_giveaction=0

_takeaction=0

will it disable the a ability to give and take from players completely? ...and if so, would it cause any problems throughout the rest of the script? I love the ability to heal others, but I'd rather not use the give and take stuff in this particular mission I am working on. In my next mission yes, but not in this one. I want players to be mostly dependent on the 2 medics in the mission.

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

setting...

_giveaction=0

_takeaction=0

...didn't disable those abilities. In testing, I gave all 3 of my bandages to a AI soldier, then I grabbed 3 more at the tent, then I gave 3 more to the soldier, etc. Takes like 1 minutes to load him up with like 20.

Bulldog, you could just join and test it for yourself if you want. Most everything is done, but I'm still testing everything a little.

---------- Post added at 08:04 PM ---------- Previous post was at 07:32 PM ----------

Celery, is there any way to limit the player bandages so they can't carry more than 3? If it would involve a ton of extra script, then forget I asked. I just thought that if it was something simple, like 1 line of script to add in, then it would really help stop players from stuffing each others pockets full of bandages.

Share this post


Link to post
Share on other sites

If you want to limit the number, add a maximum bandage condition to the actions the same way most of them have a minimum one.

Share this post


Link to post
Share on other sites

Okay, I'll give that a try. I know I can do this. But don't get mad if I come back in 10 hours asking for help again, lol.

---------- Post added at 09:22 PM ---------- Previous post was at 08:24 PM ----------

I took a guess that for the give action I would need to change it to look like this:

_giveaction=_nearestaliveactive addAction [format ["Give bandage to %1%2",name _nearestaliveactive,_leftstring],"cly\cly_heal.sqs","give",1.37,false,false,"","_this!=_target and alive _target and !(animationState _this in CLY_healanims) and time>_this getVariable 'CLY_healcooldown' and _target getVariable 'CLY_healings'>=0 _target getVariable 'CLY_healings'<3 and _this getVariable 'CLY_healings'>0 and _this getVariable 'CLY_healings'<=3 and _this distance _target<3"]

and for the take action:

_takeaction=_nearestdeadactive addAction ["Take bandages","cly\cly_heal.sqs","take",1.38,true,false,"","_this!=_target and _target getVariable 'CLY_healings'>0 _target getVariable 'CLY_healings'<=3 and _this getVariable 'CLY_healings'>=0 _this getVariable 'CLY_healings'<=3 and _this distance _target<3"]

Going to test it again now.

Share this post


Link to post
Share on other sites

About the "heal others" thing, this only works with playable units or only with units that also run the heal script ?

Share this post


Link to post
Share on other sites

You can heal any non-hostile unit.

Share this post


Link to post
Share on other sites

Would there be a way for me to remove that "heal others" function ?

(Maybe just add some // :D )

Share this post


Link to post
Share on other sites

I've been using a lightly modified version of this script for a couple of weeks now. I love it, my friends love it. I only found one bug that occurs when I heal another player - it would give me some sort of error. I don't remember the exact error, but I do remember that it said something about "target setHit ["legs"... something" and there is only one line in the script that refers to legs:

?!canStand _target:_target setHit ["legs",CLY_healdamage];_target setVariable ["CLY_healings",(_target getVariable "CLY_healings")-1,true]

The same error happened on a few occasions. Besides that the script is working fine, but I did want to ask if you could help me figure out a way to remove the functionality from a medic, since the medics in my missions don't have any need for the bandages at all. I don't know how to write sqs scripts at all. I still have lots of trouble just writing sqf scripts, but if it was an sqf script I would want to add something in the way of...

if (player isKindOf "US_Delta_Force_Medic_EP1") exitWith {};
if (player isKindOf "BAF_Soldier_Medic_MTP") exitWith {};

Is exitWith {}; correct? Well, in any case, I wanted the script to check to see if the player is one of these 2 types of medics and if so, then exit the script. Basically I'm just trying to figure out how to remove the whole heal functionality from the medics since they can already perform heal these actions normally. Any help would be appreciated.

Share this post


Link to post
Share on other sites

I'll soon release a much better version that's been used in Chernarus Apocalypse. I just need to see if some of the MP things work as they should.

Share this post


Link to post
Share on other sites

Script updated!

Changed format to sqf and probably fixed all the issues. You are now notified when someone gives you a bandage or heals you.

Share this post


Link to post
Share on other sites
Changed format to sqf and probably fixed all the issues. You are now notified when someone gives you a bandage or heals you.

Changed format to sqf and probably fixed all the issues.
Changed format to sqf
sqf

Celery with SQF!? *Cue Imperial March*

Share this post


Link to post
Share on other sites

welcome to 21st century :)

Share this post


Link to post
Share on other sites

Dude, I've been making sqf scripts since forever.

Share this post


Link to post
Share on other sites

Thanks for the script update Celery. Mate, if you wrote your scripts in Visual COBOL I would still use them!

When did they say we were moving to Lua?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×