Jump to content
avibird 1

Can you limit a unit damage value to a set number so it will not go below the number.

Recommended Posts

I'm trying to set up a way to limit a player/unit ability to take full damage so the unit can't actually die but will become incapacitated using one of the many community revive script.  In ARMA2 I was able to limit a vehicle hit damage so the vehicle never got fully destroyed only undriveable. I have been away for a while from the game and do not have the old code lines or files anymore. Can anyone help with this. I know this can be done but been away from the editor and scripting.  

Share this post


Link to post
Share on other sites

I'm trying to set up a way to limit a player/unit ability to take full damage so the unit can't actually die but will become incapacitated using one of the many community revive script.  In ARMA2 I was able to limit a vehicle hit damage so the vehicle never got fully destroyed only undriveable. I have been away for a while from the game and do not have the old code lines or files anymore. Can anyone help with this. I know this can be done but been away from the editor and scripting.  

I am writing this from the top of my head so I haven't tested it to be sure but here you go

 

while {alive player} do
{
_health = getDammage player;
if (_health <= 75) then {
player setdamage 0.75;
hint "player's damage is at 75%";
};
sleep 1;
};

The number 75 is the number that the damage isnt allowed to go below that that. Make a script.sqf in the mission file and make a trigger in the editor, make it radio whatever you want and put this inside the trigger act: null = []execVM "script.sqf";

As I said I am not sure this will work at all since its from the top of my head written from a phone at school :D

Share this post


Link to post
Share on other sites

nonono, alex method could be ok if Arma was based on napoleonic wars (joking)

 

Because you may receive in less than 1 sec a lot of damage from different sources, or even better, one source can damage serveral things at a time.

 

What you are asking is what is called a "Revive". There are around 2 or 3 very good ones around the scene.

 

All those are based on the HandleDamage event handler. Messing uo with it may take some time fo have complete functionality.

 

Maybe using them is easier and enough or maybe you want the player to stay up and fighting no matter how much damage.

 

Then the only part you have to tweak from those scripts is the one that calls to the incapacitated state.

 

Or you can mess up with the EventHandler, your call!

Share this post


Link to post
Share on other sites

Anyway: maybe this snippet is enough for you:

player addEventHandler ["HandleDamage",
  {
  _unit = _this select 0;
  _part = _this select 1;
  _dam = _this select 2;
  if ((_part == "") and (_dam > 0.95)) then {_dam = 0.9};
   _dam
   }];

  • Like 1

Share this post


Link to post
Share on other sites

Anyway: maybe this snippet is enough for you:

player addEventHandler ["HandleDamage",
  {
  _unit = _this select 0;
  _part = _this select 1;
  _dam = _this select 2;
  if ((_part == "") and (_dam > 0.95)) then {_dam = 0.9};
   _dam
   }];

Oh crap I didn't read about the incapitated stage. You should use the BIS revive script its pretty neat and easy to use in a mission.

Share this post


Link to post
Share on other sites
error :o none of the codes scripts above work ):

Share this post


Link to post
Share on other sites

Thank you alex150201 and barbolani for the feedback. Let me explain a little better what I am trying to get done (: I am attempting to work around that fact that Bohemia took out a respawn system for SP missions.  I love using AI First Aid Support script by DAP. I have been using it since ARMA2 it is the only revive script that allows in game spawn units to be revived. as far as I know most revive script only work with AI units that are placed down via 2D editor. I am working on a SP sandbox mission template that will have team switch enabled so the player can switch to a particular playable unit for it's unique abilities to use for the multiple objectives/missions within the template.  

 

The first step is to find a way to allow the revive script to work so the unit can and will get incapacitated but not fully blood out and die. Then the player can just wait to get revived by his AI units under his control or other AI units in the AO. If all friendly units are dead in the AO then the player can team switch out to a different playable unit and bring a new squad to try to rescue the other playable unit that was incapacitated. This is my concept for the template and a work around that fact bohemia took out the ability to respawn in SP or the ability to team switch in MP.

 

If anyone can help with a working demo mission of this concept I would greatly appreciate it. Avibird

Share this post


Link to post
Share on other sites

unPBO Antistasi (in my signature) and check the revive folder.

 

It's inspired by BTC but hasn't the MP problems it has.

 

And it will be fully compatible with what you want to achieve, which in Antistasi is called "Termporally AI Control". The only thing you have to do is.

 

In player's init (initPlayerLocal or editori init field) assigna a variable, "owner", so:

 

player setVariable ["owner",player,true];

 

And when you spawn AI or the AI in the editor you assign it's owner as the player:

 

_unit setVariable ["owner",player,true]

 

I make the variables MP global in case you want to control HC groups, if not, you can make it totally local.

 

So when you remote control the AI with select player, to return to the original player (in the way you want) you just have to code:

 

player selectplayer (player getVariable "owner")

 

That's totally compatible with the revive you see in Antistasi, which checks when you are injured, if you are your "original player" and if not, return to the original one. And same when the "original player" get's hurt.

 

Hope this helps, it took me one week coding all this stuff...

Share this post


Link to post
Share on other sites

@ barbolani I will check it out however I don't really follow you lol. I will look at it but can you still team switch ?

Authenic gameplay module AGM

1.7 Medical System

Part of: AGM_Medical

When using the medical system AGM offers you probably want to fine tune some aspects of the wounding, healing or gameplay mechanics and fit them to your needs. The "Medical System" module offers a lot of settings to do just that.

Default value: NoPrevent instant death? (Boolean)

Prevent instant death and always put players in unconscious state instead.

Default value: NoPrevent death while unconscious? (Boolean)

Make unconscious units invulnerable.

If this is true then the player will never die only be unconscious so then if you can still work teams switch function you will be able to switch to a new playable unit and the old unit will never die will just sit there until you get revived I'm hoping it's that simple.

If that's how it works then there must be a simple code to put in to prevent death by limiting the amount of damage and unit can take.

Share this post


Link to post
Share on other sites

Yes, is what I meant, if some script or mod suits your needs, don't mess trying to build it by your own, as a revive script needs a bit of testing around until you've got it (at least for me it was).

Share this post


Link to post
Share on other sites

This is driving me nuts. There must be a simple way to limit a units damage level to prevent the damage to reach 1 resulting in full death! Help needed.

Share this post


Link to post
Share on other sites

Try this, in my last snippet I forgot to treat other parts damage:

player addEventHandler ["HandleDamage",
  {
  _unit = _this select 0;
  _part = _this select 1;
  _dam = _this select 2;
  if (_dam > 0.95) then {_dam = 0.9};
  _dam
  }];

Share this post


Link to post
Share on other sites

Hey barbolani do I make a mission.sqf and put it in and call this from a trigger. Or can I place this in a unit init box.

Share this post


Link to post
Share on other sites

On the units init which yyou want to give them that effect. The snippet I gave you is only for players. If you want to make this available for more players or even AI, then, copypaste this in the desired unit init field:

this addEventHandler ["HandleDamage",
  {
  _dam = _this select 2;
  if (_dam > 0.95) then {_dam = 0.9};
  _dam
  }];

  • Like 2

Share this post


Link to post
Share on other sites

@ barbolani plus 1 for you :) the code works fine but my issue is I am fooling around trying to make a somewhat realistic respawn system mostly for SP/coop mission template. The idea is to have a set number of playable units in multiple different squads that have unique abilities ie recruitment of units, medics, repair, CAS, transport, logistics, motor pool, recon ect. All in a open world template.

 

I am using AI First Aid Support by DAP it is the only revive script that I know that works on AI that are spawned during gameplay.

I am also using AGM at the moment and will make a copy using ace3 when ace3 gets a little more further in development.

 

If I don't use DAP it's all fine with your code and using AGM health system however I want  the Spawned AI to have the use of a revive system.

 

My question is this is the code used in DAP to allow all units to use it.

 

[] execVM "ca\Modules\MP\data\scripts\MPFramework.sqf";
[AllUnits] execVM "DAPMAN\Init.sqf";                                                //All units
if (side _x == WEST) then {[[_x]] execVM "DAPMAN\Init.sqf";          //West units

if (side _x == EAST) then {[[_x]] execVM "DAPMAN\Init.sqf";           //East units

[[player]] execVM "DAPMAN\Init.sqf";                                               //Only human players

 

 

Is there a way to have only Playable units to use the script?

[[playable_AI] execVM "DAPMAN\Init.sqf";  

 

I looked around but can't find any information on this.                                             

Share this post


Link to post
Share on other sites

I dont know about DAP, you should ask there,

 

But I think what you want took me a few days to code and a whole life to learn. Let's try to make it less time compsuming for you ;)

 

Anyway I think you are entering in a zone which you need more scripting knowledge than you have already if you want to do it by yourself instead of using some third party published work.

 

BTC revive works fine with AI, but has some MP issues.

 

In MP my suggestion is to go back a few posts and use the Antistasi one. AFAIK there is no other revives that work well with AI and MP.

 

None of the Mod advanced medical systems will be managed by AI.

 

So you must choose between having an AI revive or and advanced medical system made for MP and humans.

 

It's my opinion with the info I have, perhaps some other can point you in other directions.

Share this post


Link to post
Share on other sites

Hey barbolani  lol  "Anyway I think you are entering in a zone which you need more scripting knowledge than you have already" Absolutely  this is what makes ARMA fun for me trail and error :) 

 

1. BTC revive works fine with AI,  Only if the AI are in your squad and I don't think with in game spawned AI units. I could be wrong but this is what I found when tested.

2. AFAIK there is no other revives that work well with AI and MP.  Dap works great for all units AI units SP/MP placed or spawned during the mission and it will even use AGM medical system :D  I never tested it with ACE3 I wanted them to update more before I fooled around with it.

 

I appreciate your feedback :wub: But I am very close to get this to work lol.

 

Like I said to call DAP from the mission init  you need this tow lines of code

 

[] execVM "ca\Modules\MP\data\scripts\MPFramework.sqf";
[AllUnits] execVM "DAPMAN\Init.sqf";                                                                     //WORKS FOR ALL PLAYERS & AI units placed and spawned during mission,

 

I have attempted this other codes

 

1. [[player]] execVM "DAPMAN\Init.sqf";                                                                //ONLY WORKS FOR PLAYERS

2.{[_x] execVM "DAPMAN/init.sqf";} forEach playableUnits;                                 //ONLY WORKS FOR PLAYERS

 

3.if (side _x == EAST) then {[[_x]] execVM "DAPMAN\Init.sqf";                           //does not work  East units        

4.if (side _x == WEST) then {[[_x]] execVM "DAPMAN\Init.sqf";                         //does not work West units

5.{[_x] execVM "DAPMAN/init.sqf";} forEach allUnits - playableUnits;                //does not call the script  ERROR MESSAGE script not found

6.[AllUnits - playableUnits] execVM "DAPMAN\Init.sqf";                                     //does not call the script  ERROR MESSAGE script not found

 

 

If you can think of anything else that would be great and if anyone else has any other feedback please shoot away. I am not going to give up on this so easy :blink: 

 

 

 

 


 

Share this post


Link to post
Share on other sites

Hey barbolani  lol  "Anyway I think you are entering in a zone which you need more scripting knowledge than you have already" Absolutely  this is what makes ARMA fun for me trail and error :) 

 

1. BTC revive works fine with AI,  Only if the AI are in your squad and I don't think with in game spawned AI units. I could be wrong but this is what I found when tested.

2. AFAIK there is no other revives that work well with AI and MP.  Dap works great for all units AI units SP/MP placed or spawned during the mission and it will even use AGM medical system :D  I never tested it with ACE3 I wanted them to update more before I fooled around with it.

 

I appreciate your feedback :wub: But I am very close to get this to work lol.

 

Like I said to call DAP from the mission init  you need this tow lines of code

 

[] execVM "ca\Modules\MP\data\scripts\MPFramework.sqf";

[AllUnits] execVM "DAPMAN\Init.sqf";                                                       //WORKS FOR ALL PLAYERS & AI units placed and spawned during mission,

 

I have attempted this other codes

 

1. [[player]] execVM "DAPMAN\Init.sqf";                                                                //ONLY WORKS FOR PLAYERS

2.{[_x] execVM "DAPMAN/init.sqf";} forEach playableUnits;                                 //ONLY WORKS FOR PLAYERS

 

3.if (side _x == EAST) then {[[_x]] execVM "DAPMAN\Init.sqf";                            //does no work  East units        

4.if (side _x == WEST) then {[[_x]] execVM "DAPMAN\Init.sqf";                           //does not work West units

5.{[_x] execVM "DAPMAN/init.sqf";} forEach allUnits - playableUnits;                  //does not call the script  ERROR MESSAGE script not found

6.[AllUnits - playableUnits] execVM "DAPMAN\Init.sqf";                                      //does not call the script  ERROR MESSAGE script not found

 

 

If you can think of anything else that would be great and if anyone else has any other feedback please shot away. I am not going to give up on this so easy :blink: 

 

 

 

 

 

 

Of course I am not saying you don't try to build our solution because you lack of knowledge :)

 

What I mean is the knowledge required to make what you want exceeds the focus of this thread and you knoeed knowledge of several materials, such as what's an event handler, array manipulation etc.. So before having your hands deeply in this matter, a tutorial/manual of general scripting will be useful for you.

 

And anyway you started asking for a damage limiter and now we are talking about DAP!!!!

 

BTC does not require to be in the same group than AI. Tested already (a lot)

 

Ok, I don´t really know DAP, so if suits your needs, let´s go to the init part, Ill put you the correct way to call it.

 

Assuming DAP call requires an array inside an array (curious, don't know why)

 

3. if (side _x == EAST) then {[[_x]] execVM "DAPMAN\Init.sqf"; should be: {if (side _x == EAST) then {[[_x]] execVM "DAPMAN\init.sqf"}} forEach allUnits

4.if (side _x == WEST) then {[[_x]] execVM "DAPMAN\Init.sqf"; same as above with WEST

5.{[_x] execVM "DAPMAN/init.sqf";} forEach allUnits - playableUnits;  should be {[[_x]] execVM "DAPMAN\init.sqf";} forEach allUnits - playableUnits; The file error y because you didnt used backslash.

6.[AllUnits - playableUnits] execVM "DAPMAN\Init.sqf"; should work (same as above regarding the error) But anyway for double checking you can build an array variable first like:

arrayForDAP = allUnits - playableUnits;

[arrayForDAP] execVM "DAPMAN\init.sqf"

Share this post


Link to post
Share on other sites

@barbolani once again thank you for your feedback after some testing only with DAP no AGM.

 

3. {if (side _x == EAST) then {[[_x]] execVM "DAPMAN\init.sqf"}} forEach allUnits   works for all editor AI east units only. no spawned units

 

5. {[[_x]] execVM "DAPMAN\init.sqf";} forEach allUnits - playableUnits;                    works for all AI units editor and spawned + playable units :(

 

6.[[AllUnits - playableUnits]] execVM "DAPMAN\Init.sqf";                                          works for all units editor, spawned and playable units 

 

 

I Will keep on trying :wacko:   I don't think the  -PlayableUnits   command  works for that ?                 

Share this post


Link to post
Share on other sites

6 won't work, you are calling the script with an array, inside an array and other array inside. Note allUnits and playableUnits are arrays by themselves. The correct:

 

6.[AllUnits - playableUnits] execVM "DAPMAN\Init.sqf";                                          

 

Man, from damage limiter to DAP initialization and now we discover spawned units!!!! We have changed the topic three times.

 

Look, any spawned unit you will have to initialise DAP on them after the unit creation. Arma is not clever enough to guess you want DAP on a brand new created unit.

 

So after your createUnit line, like

 

_unit = _group createUnit blabla

 

You need

[[_unit]] execVM "DAPMAN\init.sqf"

 

If you spawn a group with BIS_fnc_spawnGroup, then

 

_group = [lots of params] call BIS_fnc_spawnGroup;

 

You need:

[units _group] execVM "DAPMAN\init.sqf";

Share this post


Link to post
Share on other sites

@ barbolani LOL I know my mind is jumping around but these two issues go hand in hand for what I am trying to make work.I am very close.

6.[AllUnits - playableUnits] execVM "DAPMAN\Init.sqf"; did not exclude the playable units using the DAP revive script. If you say it works I will attempt again to use it.

There must be a simple code/command that can just block(blacklist)a particular script to run on a editor named unit in a array somehow.

for example (I am not saying this is even close to being correct format but something like this.

[man1,man2 man3]=[sTOP/BLOCK/PREVENT] execVM "DAPMAN\init.sqf; forEach Unit

What do you think?

Share this post


Link to post
Share on other sites

Yes, bust you must tell us the whole environment in order to get help.

 

Not by small bits of info on each post.

 

Tell me: MP? JIP? Units are spawned or from the editor? What units you want to include or exclude from DAP?

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

×