Forum Jump :

Author Message


Posts: 5
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-02-16 05:50        
     
So today I was playing around with Kylania's Self Heal script (Source) and found it a pain in the rear to setup, so... I decided I'd use the same sort of approach but make it trigger when injured, shows up red and run from the init because well why not?

/* INIT SECTION */
// For initial spawn.
player addAction ["<t color='#FF0000'>Heal Self</t>", "healSelf.sqf", [], 1, false, true,"","getdammage player > 0"];

// After respawning.
while {true} do {
waitUntil {!alive player};
waitUntil {alive player};
player addAction ["<t color='#FF0000'>Heal Self</t>", "healSelf.sqf", [], 1, false, true,"","getdammage player > 0"];
};


Now the next fun part,

/* healSelf.sqf == create a .sqf and keep it with the mission.sqm file, you can move it just remember to link to it (i.e. scripts\healSelf.sqf) */

_unit = _this select 1;
_anim = "AinvPknlMstpSlayWrflDnon_medic";
_unit playMove _anim;
waitUntil {animationState _unit == _anim || !alive _unit};
waitUntil {animationState _unit != _anim || !alive _unit};
if (alive _unit) then {_unit setDamage 0};



Simple no?

UPDATED to include 654wak654's wait till anim finished before heal.

This post was edited by am i person (2016-02-17 00:52, ago)


Author Message


Posts: 1589
Rank:


Level: Member

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

 
#2 Posted at 2016-02-16 07:44        
     
player addAction ["<t color='#FF0000'>Heal Self</t>", {
  _unit = _this select 1;
  _unit playMove "AinvPknlMstpSlayWrflDnon_medic";
  _unit setDamage 0;
}, [], 1, false, true,"","damage _this > 0"];

in initPlayerLocal.sqf and onPlayerRespawn.sqf

And the simplest, saving respawn as well: player allowDamage false; (where you want).

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Advertisement


Author Message


Posts: 5
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2016-02-16 08:55        
     
# Pierre MGI :
player addAction ["<t color='#FF0000'>Heal Self</t>", {
  _unit = _this select 1;
  _unit playMove "AinvPknlMstpSlayWrflDnon_medic";
  _unit setDamage 0;
}, [], 1, false, true,"","damage _this > 0"];

in initPlayerLocal.sqf and onPlayerRespawn.sqf

And the simplest, saving respawn as well: player allowDamage false; (where you want).

Tried doing that but did not work for me, however I do not even use those sqf files as I run mine completely different (independent scripts initialised by init so I can remove/use them individually when making a new mission) but hey whatever works, works. As for allowDamage false, what's the fun of not being able to shoot someone's legs, let them heal and do it all over again? ]:->


Author Message


Posts: 1189
Rank:


Level: Member

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

 
#4 Posted at 2016-02-16 09:56        
     
You can also try this script:

self_heal.sqf:
sha = ["<t color='#FF0000'>Heal Self</t>", {
	_unit = _this select 1;
	_anim = "AinvPknlMstpSlayWrflDnon_medic";
	_unit playMove _anim;
	waitUntil {animationState _unit == _anim || !alive _unit};
	waitUntil {animationState _unit != _anim || !alive _unit};
	if (alive _unit) then {_unit setDamage 0};
}, [], 1, false, true, "", "damage _this > 0"];
player addAction sha;
player addEventHandler ["Respawn", {(_this select 0) addAction sha}];

It adds the action back on respawn, and it actually waits until the animation is successful to heal the player.

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: 1589
Rank:


Level: Member

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

 
#5 Posted at 2016-02-16 16:48        
     
am I person:
Tried doing that but did not work for me
This code works 100%. The question is: how do you use it? If you don't follow the post, you'll fail.
am I person:
independent scripts initialised by init so I can remove/use them individually when making a new mission
The problem is (almost) the same! This script will run if correctly spawned (not called).
But, as you're in MP (respawning is for MP), you should think about the fact a init.sqf runs every time a player joins + 1 time for server. That means, if you don't take care, you can run several times your scripts.
Did you try your addAction on a server? How many action menu for how many players?

This post was edited by Pierre MGI (2016-02-16 16:58, ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 5
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#6 Posted at 2016-02-16 23:57        
     
654wak654, that's quite a useful idea/trick, I'll have to give it a go later with my testing buddy.

UPDATE: Got your 'wait till anim finished' working, ripped apart the script for it to work how I wanted :-)

Pierre MGI, I only had 2 players in the server to test and no issue was present, however, once I get 3 in then we will try to break it to get multiple action menus. As with initPlayerLocal.sqf and onPlayerRespawn.sqf, do you have the init setup to load these like this
execVM "initPlayerLocal.sqf"; 
execVM "onPlayerRespawn.sqf";
and put the coding in those, does the respawn part include the waitUntil alive in the init or the onPlayerRespawn?

or am I looking at this wrong and it auto loads itself?

UPDATE: I did look into these, they are events scripts I see but regardless of what I do, they never seem to be working...

UPDATE 2: These events are handled in ArmA 3 not in OA as seen here

This post was edited by am i person (2016-02-17 00:46, ago)


Author Message


Posts: 1589
Rank:


Level: Member

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

 
#7 Posted at 2016-02-17 02:05        
     
Yes initplayerLocal and onPlayerRespawn.sqf are event scripts like init.sqf.
They run when needed at initialization or respawn. Very useful in MP.
onPlayerRespawn is fired in SP as well (I don't know why), but be sure these scripts work fine (for everyone in Arma3)!
And Yep, sorry, I didn't mention the OA context!

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 1189
Rank:


Level: Member

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

 
#8 Posted at 2016-02-17 08:16        
     
You could use one of the .sqs scripts, but I'd recommend sticking with good ol' fashion event handlers.
Irony is, I never figured out event handlers back in Arma 2 :-X .

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