Jump to content
Sign in to follow this  
Gunter Severloh

Need help tweaking scripts dealing with bandages in SLX

Recommended Posts

Hey guys,

Im working on a full bug free version of SLX, which is going well.

ATM I am trying to tweak a file that allows the player to bandage them self ingame when wounded.

What I'm looking to do is tweak this feature as when you are wounded ingame and bandage yourself,

you will go into this crouch like animation, then go back to a normal stance when done bandaging.

Problem is 1 bandage dont do a dam thing, so you have to bandage yourself like 8-10 times to get the bleeding to stop,

and its rather annoying.

I'd like to get it to where its 1-2 bandages before your "healed" at least not bleeding to death.

What i need help with is to identify and I got an idea of what lines or code it is to tweak but not 100%

sure so I need help to identify and how to tweak them.

here are the 2 scripts Im looking at i think deal with the bandaging/bleeding:

what I bolded is what i was thinking had to do with the number of times you had to bandage

as well as the rate of which you bled.

and then for the 2nd script was looking at the bleed rate, but I have no idea on what to actually change.

SLX_Bandage.sqf

_unit=_this select 0;
_ally=_this select 1;
_index=-1;
if((count _this)>2)then{_index=_this select 2};

// _Debug=1;

[b]if(!isnil "_Debug")then{player globalchat format["bandage %1 %2 %3 %4",_this];};[/b]

if( 
(!alive _unit) 
|| 
(_unit getvariable "SLX_BleedRate")<0.000005 
)exitwith{
SLX_NetCode=["
	(_this select 1) removeaction (_this select 2);
	[(_this select 1)] call SLX_Bandage_Action;
",_unit,_index];
SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode';
};


if( (_unit getVariable "BIS_BC_dragger") || (_unit getVariable "BIS_BC_carrier") )exitwith{};

if( 
((animationState _unit) in ["ainvpknlmstpsnonwnondnon_healed_1","ainvpknlmstpsnonwnondnon_healed_2","ainvpknlmstpslaywrfldnon_healed1","ainvpknlmstpslaywrfldnon_healed2"]) 
|| 
(_ally distance _unit>4) 
|| 
( (_ally!=_unit) && ((vehicle _ally)!=_ally) && ((vehicle _unit)!=(vehicle _ally)) ) 
|| 
(_ally in SLX_Wounded_Arr) 
)exitwith{};

_ally reveal _unit;
_unit reveal _ally;
if( 
(!captive _unit) 
&& 
(_ally!=_unit) 
&& 
(_ally countEnemy [_unit]>0||_unit countEnemy [_ally]>0) 
)exitwith{
[[_ally], "curse",1,1] call SLX_Shout;
};

// find a near friendly AI to help bandage
_units=[];
{_units=_units+[_x]} foreach (nearestObjects [_unit,["Man"],4]);
{if( ((_unit countFriendly [_x])>0) && (_x!=_unit) && (!isplayer _x) && (alive _x) && !(_x in SLX_Wounded_arr) )then{_ally=_x};} foreach _units;

if(
!isplayer _unit 
|| 
((getNumber (configFile/"CfgVehicles"/typeOf _ally/"attendant"))>0)
)then{_unit setVariable ["SLX_BleedRate",0,true];};

SLX_NetCode=['(_this select 1) action ["heal",(_this select 2)];',_unit,_ally]; 
SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode';
sleep 5;
SLX_NetCode=['(_this select 1) action ["heal",(_this select 2)];',_unit,_ally]; 
SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode';
sleep 5;
// SLX_NetCode=['(_this select 1) action ["heal",(_this select 2)];',_unit,_ally]; 
// SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode';
// sleep 5;

if(isnil "SLX_Burn_Arr")then{SLX_Burn_Arr=[];};

if( _ally!=_unit || !isplayer _unit )then{
SLX_NetCode=['SLX_Burn_Arr=SLX_Burn_Arr-[(_this select 1)];(_this select 2) addRating (skill (_this select 1))*200;(_this select 1) setVariable ["SLX_BleedRate",0];',_unit,_ally]; 
SLX_NetCode call compile (SLX_NetCode select 0); 
publicVariable 'SLX_NetCode';
};

if(_ally==_unit)then{
_unit setVariable ["SLX_BleedRate",(_unit getvariable "SLX_BleedRate")*.5,true];
};

if((_unit getvariable "SLX_BleedRate")<0.000005)then{
if( _ally!=_unit )then{
	[[_ally], "support_done"] call SLX_Shout;
}; 
SLX_NetCode=["[(_this select 1)] call SLX_Bandage_Action;",_unit]; 
SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode'; 
}else{
if(_ally==player)then{hintsilent "Still bleeding...";};
};

if(!isnil "_Debug")then{player globalchat format["bandage end %1 %2 %3 %4",_this];};

SLX_Bleeding.sqf

// bleeding damage and effects

// _debug=1;

_unit=_this select 0;

if(isNil "SLX_BloodDrops")then{SLX_BloodDrops=[];if(isNil "SLX_BloodDropsMax")then{SLX_BloodDropsMax=1000};};
if(isnil {_unit getvariable "SLX_Bleeding"})then{_unit setVariable ["SLX_Bleeding",false]};

// check for BIS AIS wounded
if(isnil {_unit getvariable "injured"})then{_unit setVariable ["injured",false]};

sleep random 0.1;
if(_unit getvariable "SLX_Bleeding")exitwith{};
// if(true)exitwith{};
_unit setVariable ["SLX_Bleeding",true];

_bleedRate=0;
_blood=objNull;
_blackoutTime=0;
_nearestAllies=[];
sleep 2;
_startdamage=damage _unit;
_standingTime=0;
_st=time;
_enemy=objNull;

// get the position to test if they are standing still and for blood drop location
_pos=[
(getpos vehicle _unit select 0),
(getpos vehicle _unit select 1),
(vehicle _unit distance (getpos vehicle _unit))
];

// start add action
if( (local _unit) && (alive _unit) )then{SLX_NetCode=[ '(_this select 1) call SLX_Bandage_Action;',[_unit,true]]; SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode';};

_wait=.5+random .5;

// set bleed rate
_bleedRate=(_unit getvariable "SLX_BleedRate");

if(!isnil "_debug")then{
player globalchat format["Bleeding start %1 %2 %3",_unit,damage _unit,_bleedRate];
diag_log call compile 'format["Bleeding start %1 %2 %3",[["unit",_unit],["dmg",damage _unit],["bleed",_bleedRate]]];';
};

for [{_i=0}, { (alive _unit) && (_unit getvariable "SLX_Bleeding") }, {_i=_i+1}] do
{
_dmg=damage _unit;

if(!isnil "_debug")then{
	_debug=[
		"unit ",_unit,
		"time ",time,
		"stand ",_standingTime,
		"dmg ",_dmg,
		"bleed ",_bleedRate,
		"rate ",(_unit getvariable "SLX_BleedRate"),
		"wait ",_wait,
		"bleed rate wait", (3-(_bleedRate*10000)), 
		"speed pos ", speed vehicle _unit,
		( abs( ((_pos select 0)-((getpos (vehicle _unit)) select 0)) ) ),
		( abs( ((_pos select 1)-((getpos (vehicle _unit)) select 1)) ) ),
		"blood left",(1-_dmg), 
		"min time to live",( ( (.9-(_dmg*.9)) /_bleedRate) * .5 ) / 60
	];
	player globalchat format["Bleeding %1 %2 %3 %4 %5 %6 %7 %8 %9", _debug];
	diag_log call compile 'format["Bleeding %1 %2 %3 %4 %5 %6 %7 %8 %9", _debug];';
};

sleep _wait;
_wait=0.1 max (3-(_bleedRate*10000));
//0.000276194
//(3-(.000207083*10000))
sleep _wait;
_wait=.5+random .5;

// if wounded then don't have bandage action
if( (_unit in SLX_Wounded_Arr) && (isnil "SLX_NoFirstAid") && (local _unit) && (alive _unit) && ((_unit getVariable "SLX_Bandage")>-1) )then{SLX_NetCode=[ '[(_this select 1)] call SLX_Bandage_Action;',_unit]; SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode';};

// reduce bleeding when partially healed
if( ( damage _unit<_dmg) && (local _unit) )then{SLX_NetCode=[ '(_this select 1) setVariable ["SLX_BleedRate",((_this select 1) getvariable "SLX_BleedRate")*.3];',_unit]; SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode';};

// stop bleeding if healed
if((damage _unit<_startdamage) && (local _unit) )then{SLX_NetCode=[ '(_this select 1) setVariable ["SLX_BleedRate",0];',_unit]; SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode';};

// set bleed rate
_bleedRate=(_unit getvariable "SLX_BleedRate");

// end bleeding
if( (_bleedRate<0.000005) || !(_unit getvariable "SLX_Bleeding") )exitwith{_unit setvariable ["SLX_Bleeding",false]};


// readd bandage action if not wounded
if(
	(!(_unit in SLX_Wounded_Arr))
	&& ((_unit getvariable "SLX_Bandage")<0)
	&& (local _unit)
	&& (alive _unit)
	&& (_bleedRate>0)
)then{SLX_NetCode=[ '(_this select 1) call SLX_Bandage_Action;',[_unit,true]]; SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode';};


// Bleeding damage
if(
	(local _unit)
	&&(alive _unit)
	// &&((damage _unit) < 0.8)
	&&
	!(_unit getvariable "injured")
)then{
	_unit setdamage ((damage _unit)+_bleedRate);
	if(!isnil {_unit getvariable "SLX_HitLegs"})then{_unit sethit ["legs",_unit getvariable "SLX_HitLegs"];};
	if(!isnil {_unit getvariable "SLX_HitHands"})then{_unit sethit ["hands",_unit getvariable "SLX_HitHands"];};
	if(!isnil {_unit getvariable "SLX_HitHead"})then{_unit sethit ["head_hit",_unit getvariable "SLX_HitHead"];};
	if(!isnil {_unit getvariable "SLX_HitBody"})then{_unit sethit ["body",_unit getvariable "SLX_HitBody"];};
// set damageHandler EH levels if they exist
	if(!isnil {_unit getvariable "head_hit"})then{_unit sethit ["head_hit",_unit getvariable "head_hit"];};
	if(!isnil {_unit getvariable "body"})then{_unit sethit ["body",_unit getvariable "body"];};
	if(!isnil {_unit getvariable "legs"})then{_unit sethit ["legs",_unit getvariable "legs"];};
	if(!isnil {_unit getvariable "hands"})then{_unit sethit ["hands",_unit getvariable "hands"];};
	if(!alive _unit)then{
		[_unit,"body",0.01] call SLX_Wounds_Damaged
	}else{
		if( (damage _unit>SLX_Wounded) && !(_unit in SLX_Wounded_Arr) )then{[_unit,"legs",1,"wounded"] call SLX_Wounds_Damaged};
	};
};

// check if person is standng still and set standing time
if(
	(speed vehicle _unit<.6)
	&&
	(
		( abs( ((_pos select 0)-((getpos (vehicle _unit)) select 0)) ) < .5)
		&&
		( abs( ((_pos select 1)-((getpos (vehicle _unit)) select 1)) ) < .5)
	)
)then{
	_standingTime=_standingTime+1;
	_pos set [0, (getpos vehicle _unit select 0)];
	_pos set [1, (getpos vehicle _unit select 1)];
}else{
	_wait=.5+random .5;
	_standingTime=-1;
// get the position to test if they are standing still and for blood drop location
	// _pos=[
		// (getpos vehicle _unit select 0),
		// (getpos vehicle _unit select 1),
		// (vehicle _unit distance (getpos vehicle _unit))
	// ];
	_pos=_unit modeltoworld [0,0,0];
};



// Make AI bandage if there are no enemies around, or they are hidden, or the enemies are unaware;
if( isnil "_enemy" )then{_enemy=objNull;};
if( (isnull _enemy) )then{
	_enemy=_unit getvariable "SLX_HitBy";
	if((_unit countEnemy [_enemy])<1)then{_enemy=objnull};
};
if( (isnull _enemy) )then{
	_enemy=(vehicle _unit findNearestEnemy vehicle _unit);
};
if(count crew _enemy<1)then{_enemy=((_enemy getVariable "SLX_Position") select 4);};
if( isnil "_enemy" )then{_enemy=objNull;};

//player globalchat format["bandage? %1 %2 %3 %4",_unit, _enemy, captive _enemy,(_enemy knowsabout vehicle _unit)];

if( (local _unit) && (time-_st>30) )then{
	if( (vehicle _unit!=_unit) || (!isplayer _unit) )then{
		if(
			(isnull _enemy)
			||
			(({!captive _x}count units _enemy)<1)
			||
			( ((vehicle _unit) distance (_enemy getHideFrom vehicle _unit))>2 )
			||
			(vehicle _unit!=_unit)
		)then{
			if( !((animationState _unit) in [
				"ainvpknlmstpsnonwnondnon_healed_1",
				"ainvpknlmstpsnonwnondnon_healed_2",
				"ainvpknlmstpslaywrfldnon_healed1",
				"ainvpknlmstpslaywrfldnon_healed2"])
				&& !(_unit in SLX_Wounded_Arr)
			)then{
				if(
					(
						(({!captive _x}count units _enemy)<1)
						|| (isnull _enemy)
						|| ( ((vehicle _unit) distance (_enemy getHideFrom vehicle _unit))>2 )
						||
						(vehicle _unit!=_unit)
					)
					&&
					(((vehicle _unit) distance (vehicle _enemy))>10)
				)then{
					[_unit,_unit,(_unit getvariable "SLX_Bandage")] execVM (SLX_Wounds_Path+"f\SLX_Bandage.sqf");
				};
			};
		};
	};
};


// Find nearest ally and have them come help if there are no enemies around.
// Behavior: When a bleeding person is stopped next to any friendly AI they should get bandaged.
// Things to avoid: Doing too many checks for people.
// When AI's should help bandage: when close while standing still

// Check if person has been standing for long enough to accumulate enough blood droplets and stop making them if there are too many.
if(_standingTime<25)then{

	// Blood droplet;

//player globalchat format["bleeding: %1 %2 %3 %4 %5 %6 %7 %8", _unit, getpos _unit,_wait,time];
	_blood=objNull;
	if(vehicle _unit==_unit)then{
		_blood="SLX_BloodSprayVeh" createvehiclelocal [-10,-10,10];
		if(!canstand _unit)then{
			_blood setpos (_unit modeltoworld [
				(((_unit selectionposition "rightfoot") select 0)*.5)+random .2-random .4,
				(((_unit selectionposition "rightfoot") select 1)*.5)+random .4-random .4,
			0]);
		}else{
			_blood setpos [(_pos select 0)+random .4-random .4,
			(_pos select 1)+random .4-random .4,
			(_pos select 2)];
		};
	};

}else{_wait=1+random 2;};


// Blackout
if(
	(isplayer _unit)
	&& (local _unit)
	&& (_blackoutTime==0)
	&& (damage _unit>.7)
	&& (random (_bleedRate*800)>(1-(damage _unit)))
)then{
	TitleText ["", "black out",5];
	random 1 fadesound 0.5;
	_st=time;
	_blackoutTime=random (damage _unit*3);
	_wait=1+random 1;
};
if(
	(isplayer _unit)
	&& (local _unit)
	&& (_blackoutTime!=0)
	&& (time-_st>_blackoutTime)
)then{
	TitleText ["", "black in",5];
	random 1 fadesound 1;
	_blackoutTime=0;
};
if(time<_st)then{
	_st=time;
	_blackoutTime=random (damage _unit*3);
};


// Shout;
if( (local _unit) && (random 1<0.05) )then{[[_unit], "Bleeding",1] call SLX_Shout};

};

if(!isnil "_debug")then{
player globalchat format["Bleeding end %1 %2 %3",_unit,damage _unit,_bleedRate];
diag_log call compile 'format["Bleeding end %1 %2 %3",[["unit",_unit],["dmg",damage _unit],["bleed",_bleedRate]]];';
};

if( (isplayer _unit) && (local _unit) )then{TitleText ["", "plain",5]};

if(local _unit)then{SLX_NetCode=[ '(_this select 1) setvariable ["SLX_Bleeding",false]; [(_this select 1)] call SLX_Bandage_Action;',_unit]; SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode';};

Can anyone help?

Share this post


Link to post
Share on other sites

Nobody has any idea, or can point out something I dont know, I'm looking to learn.

Share this post


Link to post
Share on other sites

It looks like the part of that you emboldened is just a debug message Solus inserted for testing. All it does is send a chat message with the parameters passed to the script from the executing instance.

I would not try to adjust SLX_Bleeding.sqf. I don't think there are any changes to be made there unless you want to reduce the overall bleed rate and there appears to be quite a few things tied into it, so changing it might break something.

If you want to adjust how much bleeding is stopped when the player is bandaging himself, I think you need to adjust the number in this if-block in SLX_Bandage.sqf

if(_ally==_unit)then{
_unit setVariable ["SLX_BleedRate",(_unit getvariable "SLX_BleedRate")*.5,true];
};

As currently written it would appear to reduce bleeding by 50% (.5). Try tweaking that number until you get the desired result. Good luck and let me know if that has no apparent effect.

Edited by Loyalguard

Share this post


Link to post
Share on other sites

Hi Loyalguard,

Makes sense, i will try that.

I was looking at the bleedrate, but was pondering on what do i change here to slow it down faster.

---------- Post added at 12:38 PM ---------- Previous post was at 12:19 PM ----------

Tested it out, thru a couple of grenades near, to get myself wounded, and the bandage thing didn't come up and

i know I was wounded as I was bleeding on the arms and legs but no actual blood drops, its like SLX wounds stopped working and I couldn't walk.

I also got errors saying stuff is missing when i started the test, so its got to be something else.

---------- Post added at 12:41 PM ---------- Previous post was at 12:38 PM ----------

What about this:

SLX_bleeding

[color="SeaGreen"]// set bleed rate[/color]
_bleedRate=(_unit getvariable "SLX_BleedRate");

if(!isnil "_debug")then{
player globalchat format["Bleeding start %1 %2 %3",_unit,damage _unit,_bleedRate];
diag_log call compile 'format["Bleeding start %1 %2 %3",[["unit",_unit],["dmg",damage _unit],["bleed",_bleedRate]]];';
};

for [{_i=0}, { (alive _unit) && (_unit getvariable "SLX_Bleeding") }, {_i=_i+1}] do
{
_dmg=damage _unit;

if(!isnil "_debug")then{
	_debug=[
		"unit ",_unit,
		"time ",time,
		"stand ",_standingTime,
		"dmg ",_dmg,
		"bleed ",_bleedRate,
		"rate ",(_unit getvariable "SLX_BleedRate"),
		"wait ",_wait,
		"bleed rate wait", (3-(_bleedRate*10000)), 
		"speed pos ", speed vehicle _unit,
		( abs( ((_pos select 0)-((getpos (vehicle _unit)) select 0)) ) ),
		( abs( ((_pos select 1)-((getpos (vehicle _unit)) select 1)) ) ),
		"blood left",(1-_dmg), 
		"min time to live",( ( (.9-(_dmg*.9)) /_bleedRate) * .5 ) / 60
	];
	player globalchat format["Bleeding %1 %2 %3 %4 %5 %6 %7 %8 %9", _debug];
	diag_log call compile 'format["Bleeding %1 %2 %3 %4 %5 %6 %7 %8 %9", _debug];';
};

sleep _wait;
_wait=0.1 max (3-(_bleedRate*10000));
//0.000276194
//(3-(.000207083*10000))
sleep _wait;
_wait=.5+random .5;

[color="SeaGreen"]// if wounded then don't have bandage action[/color]
if( (_unit in SLX_Wounded_Arr) && (isnil "SLX_NoFirstAid") && (local _unit) && (alive _unit) && ((_unit getVariable "SLX_Bandage")>-1) )then{SLX_NetCode=[ '[(_this select 1)] call SLX_Bandage_Action;',_unit]; SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode';};

[color="SeaGreen"]// reduce bleeding when partially healed[/color]
if( ( damage _unit<_dmg) && (local _unit) )then{SLX_NetCode=[ '(_this select 1) setVariable ["SLX_BleedRate",((_this select 1) getvariable "SLX_BleedRate")*.3];',_unit]; SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode';};

[color="SeaGreen"]// stop bleeding if healed[/color]
if((damage _unit<_startdamage) && (local _unit) )then{SLX_NetCode=[ '(_this select 1) setVariable ["SLX_BleedRate",0];',_unit]; SLX_NetCode call compile (SLX_NetCode select 0); publicVariable 'SLX_NetCode';};

[color="SeaGreen"]// set bleed rate[/color]
_bleedRate=(_unit getvariable "SLX_BleedRate");

[color="SeaGreen"]// end bleeding[/color]
if( (_bleedRate<0.000005) || !(_unit getvariable "SLX_Bleeding") )exitwith{_unit setvariable ["SLX_Bleeding",false]};

Share this post


Link to post
Share on other sites

Did you get errors just from changing .5 to something else or did you make other changes?

Share this post


Link to post
Share on other sites

Ya I got errors, the Slx_wounds stopped working, i got a few errors these are what they were:

Warning Message: Cannot load texture slx_wounds\data\periph_blood_ca.paa.

Warning Message: Cannot load texture slx_wounds\data\slx_woundedhead.paa.

Warning Message: Cannot open object slx_wounds\models\slx_bloodpool.p3d

Warning Message: Cannot load texture SLX_Wounds\data\periph_blood_ca.paa.

Warning Message: Cannot load texture slx_wounds\data\ambulance_move.paa.

Animation slx_wounds\anim\dragger\slx_draggerdrivergetin.rtm not found or empty

Animation slx_wounds\anim\dragger\slx_draggerdrivergetout.rtm not found or empty

Animation slx_wounds\anim\dragger\slx_draggerdriver.rtm not found or empty

that was the RPT, but ingame I mostly got

Cannot load texture slx_wounds\data\periph_blood_ca.paa. right when i loaded the mission, and the mission

was just a soldier nothing else, i had him throw a grenade close by and he got wounded from it, and fromt hat the SLX_wounds

wouldn't do anything, no blood, nothing.

So im thinking it has to be something else.

Either slow the bleedrate, or fix it so that when you bandage that you only need to bandage once,

so there has to be a line of code that says how much to heal per bandage, i mean it takes quite a few bandages

depending how wounded you are to just to stop bleeding, and Im sure it is realistic in some way but ingame its annoying, I think 1-2 times is enough.

Share this post


Link to post
Share on other sites

There is a lot going on in both of those scripts. Have you seen a player have the ability to bandage themselves? The reason I ask is because it looks to me that if you are wounded you can't bandage yourself....unless I am reading it incorrectly.

There is also the consideration that it looks like bleed rate might also be influenced by what body parts are also hit, so, if you are wounded in legs, hands, head, etc....you might need more than one bandage.

I am now not sure if SLX_Bandage.sqf even works for the player on himself.

This needs a deeper look.

Share this post


Link to post
Share on other sites

Srry for the late reply, ya no matter what wounding you got be it multiple places you can bandage yourself.

Thats probably what it is as you said

if you are wounded in legs, hands, head, etc....you might need more than one bandage.

the wounding system is body part specific.

Maybe it should be left alone, dont really know what else to do with it, unless you got ideas.

Share this post


Link to post
Share on other sites

Let me chew on it for a ahwile but I am trying to wrap up a couple of other projects right now and do not have much free time. I'll get back to you ASAP.

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  

×