Jump to content
Sign in to follow this  
wiggum2

AddAction Question

Recommended Posts

Hi,

im currently stuck at this problem with a addaction.

I have a "Heal" action for a MP mission, every player should get this option if he is wounded.

So this as condition:

damage p1 > 0

This in OnAct:

heal = p1 addAction ["Apply field dressing", "heal.sqf", p1, 6, false, true, ""]; enableHeal = true;

There are triggers for all playable units (p1, p2, p3 and p4) with the same, just the unitname replaced inside the trigger.

The problem is, the action is added to the unit himself if he is wounded, so other units can apply this action too if they stand close to the wounded unit.

Example:

p1 is wounded and can apply the action. But p2 can also apply the action (on p1) if he stands close to him because the action is added to the unit p1...

And what i want is that only p1 can see and apply this action !

(remember, it should work in a MP game)

heal.sqf

_guy = _this select 3;
if (alive _guy) then
{
_guy say "fieldDressing";
_guy removeAction heal;
_guy playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 1;
_guy setDamage 0;
};

So there should be a solution i hope.

Share this post


Link to post
Share on other sites

Hi,

You dont even need the triggers:

_actionId = this addAction ["Heal", "heal.sqf",[], -1, false, true, "", "[color="Red"](_target == _this) && (damage _this > 0)[/color]"];

On red is the condition.

If the action caller is equal to the action holder AND damage bigger then 0 show Action.

http://community.bistudio.com/wiki/addAction

_neo_

Share this post


Link to post
Share on other sites

Thanks neokika !

I just have add this line into every units init:

_actionId = this addAction ["Heal", "fieldDressing.sqf", [color="Red"]p1[/color], -1, false, true, "", "(_target == _this) && (damage _this > 0)"];

The red part is the name of the unit which of course is different on every unit.

Share this post


Link to post
Share on other sites

Nope, the 3rd part needs to be an array anyway. Also the unit it's on is passed automatically as _this select 0. Try this:

_actionId = this addAction ["Heal", "fieldDressing.sqf", [], -1, false, true, "", "(_target == _this) && (damage _this > 0)"];

Then in your script:

_guy = _this select 0;
_act = _this select 2;
if (alive _guy) then
{
_guy say "fieldDressing";
_guy removeAction _act;
_guy playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 1;
_guy setDamage 0;
};

Share this post


Link to post
Share on other sites

This worked for me, but it only worked 1 time. The 2nd time I got hurt, the action would not appear. Also, if it's in the players init, and the player were to die and then respawn, won't the init be wiped clean on respawn and remove all the init commands so it can't be used after respawning?

Share this post


Link to post
Share on other sites

i was just trying out addEventHandler when i came back here and noticed that you mentioned to do the same. i was already using addEventHandler for weapons respawn, and thought it might work for healing as well, and it did. thanks for suggesting to use it.

i got everything working finally. the players can keep healing as many times as needed within their first life, but i had to change some stuff to get that resolved. after they respawn they can still keep healing as needed. works well online and offline. i appreciate the help so much, thanks for your help kylania and cobra4v320. it's such a relief to not have to spend anymore time trying to get this heal stuff working. now i can concentrate on all the other problematic things in my mission, lol, starting with assembling an m2 bag and tripod bag. i can't seem to find any tutorials for that.

Share this post


Link to post
Share on other sites

Glad to help!

As for the bag, just have someone place the tripod bag on the ground, look at it while wearing the M2 bag and you should get an action option to assemble weapon. One of them is bugged though, can't remember which. I think you can also just have two guys carrying them on their backs, and look at one guy and assemble that way too, not sure though.

Share this post


Link to post
Share on other sites

Yeah, it's a couple of months later, but I came back to this thread because I was wondering where the tripod bag is in the editor? Like, all I see is the actual weapon bags for a variety of different weapons, but I don't see just the tripod bag anywhere. I'm just getting tired of disassembling tripod weapons at base and shoving them into the back of a vehicle to take to the battlefield. It would be nice if it were possible to script a vehicle to already have a few tripod bags and weapon bags already in the vehicle. I mean... if I can put 3 tripod bags in the vehicle and 3 weapon bags in the vehicle while I'm playing the game, shouldn't there be a way to just script them into the vehicle ahead of time? Anybody?

---------- Post added at 09:15 AM ---------- Previous post was at 08:46 AM ----------

So I searched and found out that the tripod bag is called "Tripod_bag", so I scripted it into my mission. So now I have a bunch of tripod bags and mk19 bags near my ammo crate at base.

Is there anyway to script these things to already be inside a truck at missions start?

---------- Post added at 09:28 AM ---------- Previous post was at 09:15 AM ----------

Nevermind. I kept searching and came across this...

http://forums.bistudio.com/showthread.php?t=106571&highlight=bag+vehicle&page=2

so the answer is attachTo. Got it ;)

It actually sound like a fun scripting challenge.

Share this post


Link to post
Share on other sites

Next patch (1.55) will include a "addbackpackcargo" command which can be used to put bags on to vehicles.

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  

×