Jump to content
Sign in to follow this  
avibird 1

EventHandler issues following save game function units will not take Damage.

Recommended Posts

I use a modify revive system that I have been working on for a series of missions (CTI template)  that all the playable units will never die only go into a state of unconsciousness when seriously injured using this in the units init  -

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

This mission was designed mostly for SP/coop play with a few players on a host server. I am almost done with all the missions individually (all works great) and was attempting to make a version as one continuous mission using the  enableSaving [true, true]; function in the mission init.sqf  following a save game all the playable units will not take  damage and will never fall unconscious?

 

Do I need to add a something like this to the code in the playable units.

 

this addEventHandler["Respawn",{your code in here}];

 

this addEventHandler ["Respawn", { (_this select 0) }];

 

 

I never was good with  EventHandler codes for  Respawns.

Share this post


Link to post
Share on other sites

I attempted multiple things with no luck. It works fine in the single player environment but in the multiplayer environment following a saved game all the units Will become damaged but will never fall unconscious and that is a gamebreaker for sure lol.

The whole point was not to have a mission with respawns but to have a system of last man standing. As long as one playable unit was still alive there was a chance the mission could continue if that player could revive his teammates ie playable units.

Really need help with this.

Is it the save game function or something with how I am calling the EventHandler using the playable units init.

Share this post


Link to post
Share on other sites

So you need to script things upon player respawn. Isnt it?

Assuming you know how to build a básica playera respawn BASE type

Ive never used TVE respawn EH. Insted, I use onPlayerRespawn.sqf which execs automatically and is easy yo use.

Google it forma deeper knowledge

Share this post


Link to post
Share on other sites

hey barbolani I don't think you fully understand what I am saying or maybe I have no clue what the hell I am saying lol ;) which could most likely be the case.

 

I do not use respawns in the mission. My respawn  is set to side  in my  description.ext   respawn= 5;

 

 I have a  modify revive system that the player/Playable unit (AI) will never die they will stay in a state of  unconsciousness until a teammate or AI unit revives them.  using this code in the units init 

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

 

If all playable units are unconscious mission  is over.  It's like a last man standing revive template I have been working on.

 

The issue is when I use the save game function via mission,init code enableSaving [true, true];

All the units will not fall unconscious in a multiplayer environment they will take damage. You can see the blood and they can get healed but no state of unconscious.

 

Everything works fine in a single player environment I can save the game and the damage system works as it did before the save.

 

My questions are

1. Is it the save  in MP that could cause the issue.

2. Is it how I am calling the damage EH from the unit init

3. why does it work in  single player  and not multiplayer

4, What can I try to fix it so my units will never die only go unconscious when they take damage

Share this post


Link to post
Share on other sites

After more testing the issue is most likely coming from the way I am calling the EH for damage -

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

from all the playable unit init box via editor.

 

I made a Invulnerable.sqf  with the code for the eventhandle damage inside for all playable units

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

I called the Invulnerable.sqf from the mission.init with this code  

if (isServer) then {
[] call compile preprocessfile "Invulnerable.sqf";
};

This is the editor names for the 11 playable units and one non playable AI for the squad. I don't know if I need to add the names in the Invulnerable.sqf.

 

Raven_SL 

Raven_GL 

Raven_MM

Raven_MG

Raven_RAT

Raven_RS 

Raven_ES 

Raven_AT 

Raven_AA 

Raven_RO

Raven_MED
Raven_AMED

 

 

I really need to get this working out to complete the mission. Any help or suggestions would be greatly appreciated. This is getting a little over my knowledge at this point.  I just want to make a system that playable units only will never die but the whole team could be unconscious causing the mission to end. Last man standing mode for coop play. I never like to play with respawns since my OFP days so this is the best compromise I could think of for larger scale mission.  Avibird
 

Share this post


Link to post
Share on other sites

 

I made a Invulnerable.sqf  with the code for the eventhandle damage inside for all playable units

 

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

 

in init.sqf

if (hasInterface) then {


    player addEventHandler ["HandleDamage",{

        private ["_player", "_dam"];
    
        _player = _this select 0;
        _dam = _this select 2;
        
            if (_dam > 0.8) then {
            
                _player setDamage 0.8;
                _player setCaptive true;
                _player playAction "Unconscious";
                
            };
    }];
};

Share this post


Link to post
Share on other sites

@ davidoss thank you I will give it a go. Does this code only work for players or will it work for playable AI units as well. If not would I need to add something like this forEach playableUnits;

Or

_allPlayers = [];

{ if (isPlayer _x) then { _allPlayers pushBack _x; }; } forEach playableUnits;

Share this post


Link to post
Share on other sites

Still can't get this to work right following a save game . Could someone tell me if this is not possible. The my original way of putting the code in the units init works at the start following the game save units can get damage but will never fall unconscious.

 

I have attempted putting code in the mission.sqf, making a separate sqf with mode codes, making a trigger calling  the code lines to after the save game.

 

The only thing I need is for all my playable units to have this addEventHandler ["HandleDamage",{ _dam = _this select 2; if (_dam > 0.9) then {_dam = 0.8}; _dam }]; forEach playableUnits; working following game save.

 

I have been at this for four days. I know it can be done just getting the right codes in the right place.

Share this post


Link to post
Share on other sites

"player addEventHandler"... works only for players.

 

So you are trying to build a revive, and you say it does work, except when you save & exit in MP.

 

But you only post a EH line, which is for sure a small part of the revive.

 

First: post your revive.

 

Revives are not an easy task, that's why ppl use BTC, Farooq etc.. because building your own is a bit difficult. This said, it will be probably easier for you to use them and adapt whatever to them.

 

Second: you want to apply the EH to certain units, not only players. Then allUnits is your array, the only thing you have to do is a check to do exceptions to units you want not to add the EH.

 

Third: EH addition does not require the units to be local, so you have to do it from the server. If not, and done by script, you probably add the EH n times being n the number of players connected.

 

Fourth: EH effects are local, so check the commands you use have global effect (animations etc..).

 

Hope it helps.

Share this post


Link to post
Share on other sites

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

I really doubt that code works by any means.

Share this post


Link to post
Share on other sites

@ barbolani  this addEventHandler ["HandleDamage",{ _dam = _this select 2; if (_dam > 0.9) then {_dam = 0.8}; _dam }]; forEach playableUnits;   definitely works for all playable units at game start. the code is in there init box but after a save game it does not work.

 

I am using a  modify revive system DAPMAN Current Version 0.2.5

 

the code that davidoss give works for the players not  playable units. following a game save. his code is called from mission.init    

if (hasInterface) then {


    player addEventHandler ["HandleDamage",{

        private ["_player", "_dam"];
    
        _player = _this select 0;
        _dam = _this select 2;
        
            if (_dam > 0.8) then {
            
                _player setDamage 0.8;
                _player setCaptive true;
                _player playAction "Unconscious";
                
            };
    }];
};

I attempted to replace the _Players with _allPlayers that did not work. What can I use in his code to make all Playable units.  

I am getting closer now.  The human Players can use the modify revive system and will go unconscious but never die. Just need it to work for the AI Playable units now.

Share this post


Link to post
Share on other sites

Its not only the syntax rules of Arma says IT DOES NOT WORK.

 

Also my .rpt says IT DOES NOT WORK

 

20:25:20 Error in expression <.9) then {_dam = 0.8}; _dam }]; forEach playableUnits>
20:25:20   Error position: <playableUnits>
20:25:20   Error Falta ;
20:25:20 Error in expression <.9) then {_dam = 0.8}; _dam }]; forEach playableUnits>
20:25:20   Error position: <playableUnits>
20:25:20   Error Falta ;

Share this post


Link to post
Share on other sites

Hey just put this in a unit init box

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

without the forEach playableUnits; I can guarantee it will work at game start. I  use DAPMAN revive it is modified  so the playableUnits/ai and humans the killer timer is off set to -1 the units will fall unconscious around .6/7 of damage the code above will never allow them to die only stay unconscious. If you don't have a system to put them unconscious they will just take damage mostly to .8 but will never go unconscious. DAPMAN works after a game save for sure but the issue is I can't get the eventHandler to get recalled for the units following a game save.

 

davidoss code works after a game save but ONLY for the players and not for the playableUnits ie AI units which I also have the teamswitch enabled. In davidoss code I needed to take out the _player setCaptive true; and _player playAction "Unconscious";  because DAPMAN revive already has it build in.  

 

How do I get the units init box code to carryover after a  game save for all playableUnits. THIS is my main issue.

or how do I write a good Invulnerable.sqf including davidoss code above for all my playableUnits and call it from the mission.Init so it will work again following a game save.

 

thank you guys for the help I am almost there. Just need this last part.

Share this post


Link to post
Share on other sites

I just ran a test and this seems to work, but as I know next to nothing about MP it's probably wrong.

 

init.sqf

{
   _x addEventHandler ["HandleDamage",{

        private ["_player", "_dam"];
    
        _player = _this select 0;
        _dam = _this select 2;
        
            if (_dam > 0.8) then {
            
                _player setDamage 0.8;
                _player setCaptive true;
                _player playAction "Unconscious";
            };_dam;
    }];

    } foreach playableunits+switchableunits;

One thing  I do notice is that blood vanishes from time to time.

 

Share this post


Link to post
Share on other sites

So, as I said, that wasn't the code you are using.

 

Now I understand. You want to use a combination of DAPMAN and another EH added to avoid death.

 

f2k sel is the solution to assign the EH to any playable.

 

Now: why not modify DAPMAN instead?

Share this post


Link to post
Share on other sites

So, as I said, that wasn't the code you are using.

 

Now I understand. You want to use a combination of DAPMAN and another EH added to avoid death.

 

f2k sel is the solution to assign the EH to any playable.

 

Now: why not modify DAPMAN instead?

 

 

I'm really not sure,  I just realized I didn't check if playable also includes player.

 

} foreach playableunits+switchableunits+allplayers;

 

may fix that if it's an issue

Share this post


Link to post
Share on other sites

I'm really not sure,  I just realized I didn't check if playable also includes player.

 

} foreach playableunits+switchableunits+allplayers;

 

may fix that if it's an issue

playableUnits is enough is his case, as he wants to add it also for playable AI not selected by any player.

Share this post


Link to post
Share on other sites

@ davidoss barbolani f2k sel I just felt like we had a foursome :) thank you guys some much after a quick test it seems to work following game save. The units take less hits now to reach unconscious but that is a good side effect in my opinion for overall game play.  I know sometimes I don't explain what I need but most of the time I have no clue what I need but I do know what I want :D scripting language is still very foreign to me. its like attempting calculus when your background is only arithmetic. This is why I love this community for the sharing and helping others with this hobby of ours.  I really appreciate all the direction feedback and Help on this.  Avibird

Share this post


Link to post
Share on other sites

@ barbolani that is not really the case. The mission was designed for SP and for a small group of coop play the mission is called full spectrum warriors. blufor will have 14 different squad/groups to play with ranging from command rifle medical logistic Engineering armor amphibian and air units. Limited resources at start as you advance through the sections additional weapons vehicles will come available. Only crew can use armor and only pilots can use air vehicles.

The only issue I see right now is that I have three medics that are not playable because I use the automedic script in them. These units can get killed now. I guess this code line does not include allwest units

foreach playableunits+switchableunits+allplayers;

I certainly do not want or west units never to die on the mission. I can make the three automedics playable but if a player takes control of that unit the automedic script breaks. Is there a way to limited a switchable unit to a set player. I know I have seen this before where a unit slot was reserved.

Share this post


Link to post
Share on other sites

If you know the object name you could place it in an array

 

foreach playableunits+switchableunits+allplayers+[bill,tom,joe];

 

 

I think.

Share this post


Link to post
Share on other sites

F2k sel the issue is the three units are not playable/switchable they are non playable units in a group of playable units using the automedic script. I certainly do not want ever blufor unit throughout the entire mission to never die there are Spawn blufor units during mission at times. If I could lock the three automedic slots I could make them playable I don't have to worry about somebody switching into those units and breaks the script that runs the automedics.

Share this post


Link to post
Share on other sites

playable == MP

Switchable  == SP

 

They are basically the same, one works in MP the other in SP using both together covers both bases so you don't have to keep changing the code.

If you know which AI units you want and you can name them you can add them to the list of objects as shown in the previous post.

 

The result should be  playable+switchable+players+three medics should  all now have the EVH added to them, no other AI units should be affected.

Share this post


Link to post
Share on other sites

F2k sel just to clarify it did work for the non playable medics

foreach playableunits+switchableunits+allplayers+[bill,tom,joe];

The funny thing the script/code works now following a game save and that was the main issue I was having with the code and how I was calling it BUT now the units can get killed in static weapons and cargo spaces. They will not die if in a driver gunner or commander positions. More testing needed. The funny thing about Arma is when you fix one issue it could lead to a few new ones. Imagine how the developers feel lol.

Share this post


Link to post
Share on other sites

Are you sure, they seem fine to me, are we talking medic or players.

Share this post


Link to post
Share on other sites

MY two main squad leaders got killed one in a static AT gun and the other in a cargo slot in a moveing vehicle from a jet fighter that was bad LOL I had no time to jump out. Both times I was the leader. I need to test more to see if it happens again and if it only when your are the unit and not the AI.

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  

×