Jump to content
Sign in to follow this  
norrin

SQF revive script

Recommended Posts

I can not get the last Version run.

Shot someone but nothing happends.

I use the BETA Patch can it be taht the new one does not run with it because the Alpha does.

Share this post


Link to post
Share on other sites

To tell you the truth I'm not sure as I haven't tried it with the ArmA Public Beta Patch 1.05.5143 only 1.05.  

HulkingUnicorn has found a couple more JIP bugs in the current version of the script unfortunately and we are presently trying to find solutions to these problems.  

I'm also rewriting the script so that it works with playable AI but thats just introduced a whole range of new problems that we've started working on.

Hopefully sometime in the next week we'll have a new version to download that addreses most if not all of these issues.

Share this post


Link to post
Share on other sites

Here we go again. smile_o.gif

Revive SQF

Here’s a new version of my revive script. (25th April 2007).

Description:

This latest version uses a single script for both players and playable AI units and therefore playable AI units will revive downed team mates if within a four metre radius and if unconscious can be revived as well.

I’ve simplified things by removing the respawn counter that allowed mission builders to specify how many times each unit could be revived as it was causing too many JIP problems. I’ve also used HAILO’s JIP script to ensure the revive script is run on each joining player and I know I’ve said this before smile_o.gif but I haven’t been able to detect any JIP errors in testing.

In addition, I’ve changed the implementation of the revive action so that its always available to the player but it is in the action list (default middle mouse) and will only heal someone if you are within a radius of 4 metres.

If you join on an unconscious player you now join the mission unconscious and will require reviving before you can join the action. The latest version also allows the joining player to get all the other units states (ie either conscious or unconscious) so there are, as far as I can tell, no desync problems when someone joins.

To implement:

You no longer need the start markers but you still need to place a Respawn_west marker on an island away from the action. Then just copy across the code from the init.sqf (this includes the code to execute HAILO’s JIP script, you’ll also need to change the playable units names here) and the description.ext. Then copy across the three folders: revive_sqf, events and scripts (the last two for JIP) to your mission folder. You’ll also need to change the unit names in the array on line 30 in the onPlayerConnected.sqf file (which you can find in the events folder). Finally and most importantly you’ll need to change the code inside the revive_player.sqf at three points (each preceded with the comment “Set current unit statusâ€) to reflect the playable unit names you’ve used.

For instance at the first point in the revive script the first line (line 47) after the comment is:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (_name == alpha_1 && alpha_1_a) then {_respawn = true, _concious = true}; where:

“alpha_1†is the name of the first playable unit; and

“alpha_1_a†is a unique public variable associated with alpha_1 that will be used to keep track of this unit’s state.

Tested:

Version 1.05 with JIP

Bugs:

1. occasionally a “null object error - error invalid number in expression†flashes up it doesn’t seem to affect the functioning of the script but its damn annoying and I haven’t been able to track down the source of this problem yet so it any one knows what’s causing this please let me know. You can get rid of this error message by rejoining the mission in the same slot.

2. If a player joins on an unconscious group leader and is then revived the player draws the units pistol but still shoots out the primary weapon on its back. I seem to remember reading about this somewhere on the forums but a way around it is once revived respawn and revive again and you should be able to choose the primary weapon properly.

PS: Hulk if you’re still about I’m sorry I didn’t email you this version but I’m away again and using a net café to post this so if you’re still interested let me know how it goes.

Edited by W0lle
code tags fixed

Share this post


Link to post
Share on other sites
Bugs:

1. occasionally a “null object error - error invalid number in expression†flashes up it doesn’t seem to affect the functioning of the script but its damn annoying and I haven’t been able to track down the source of this problem yet so it any one knows what’s causing this please let me know. You can get rid of this error message by rejoining the mission in the same slot.

I haven't looked at the code yet but I think this is a mix up of a units "name" and object.

Share this post


Link to post
Share on other sites

Did you change the weapon respawn script? Before it was launched with

_unitnames = ["man1", "man2", "etc"];

but now you just use _units...

Nice to be able to revive ai, but that damn message is driving us nuts wink_o.gif

Rejoining the slot every three minutes is not an option.

Also, do try to find a better way of setting up the variables - editing the ifs isn't very practical smile_o.gif

Edit:

There seem to be a few more bugs sad_o.gif

When a connecting player picks a slot with an unconscious unit, he will be able to rotate and fire the gun on his back while the animation is running - he also doesn't get the uncounscious message. This led several players to think it was some kind of bug, and not part of the revive script. Clicking respawn seemed to fix it (as the camera stuff triggers when you die).

Also, uncounscious units have been 'moved' sometimes. If it is an ai unit, it is gone forever, but a player can use respawn to reappear (it seems like it got stuck on the island, even though the 'deathmarker' appeared... the deathmarker also disappeared on one occasion).

Btw, the weapon respawn didn't seem to be working when following the instructions in your post - creating an array with unitnames encased in quotes and running the weapon respawn script with that fixes it. The null error doesn't seem to show up until someone disconnects.

Share this post


Link to post
Share on other sites

I've added this to a mission i'm making to test it out and I notice the constant script errors also.

The only major bug I can see that plus you miss alot of equipment after your second revive (i.e. nvgoggles, pipebombs, binocs).

I really wish I knew scripting better so I could help, I think revive/tag respawn scripts are grand.

Share this post


Link to post
Share on other sites

EvilNate, try this to get the weapon respawn working:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_units = [man1, man2, man3];

_unit_names =["man1", "man2", "man3"];

//Initialise weapon_respawn script for all units

{[_x,1] exec "revive_sqf\weapons_respawn.sqs"} foreach _unit_names;

//Initialise revive script for all units

{call{[_x] execVM "revive_sqf\Revive_player.sqf"}}forEach _units;

You need 1 array with the units in brackets (for weapon respawn) and 1 array with just the units (for revive script)

Edited by W0lle

Share this post


Link to post
Share on other sites

Oops got a bit lost on the way to the forum.

Hulk as always your testing has been very helpful. smile_o.gif

Here's the latest version (30th April 2007C).

When a connecting player picks a slot with an unconscious unit, he will be able to rotate and fire the gun on his back while the animation is running - he also doesn't get the uncounscious message. This led several players to think it was some kind of bug, and not part of the revive script. Clicking respawn seemed to fix it (as the camera stuff triggers when you die).

I’ve revised the code again so that there is a short black-out period prior to a player joining a mission with the message “joining missionâ€.  This allows the JIP player to get all the surrounding units states so he does not witness the unconscious players and himself lying down.  It also activates the camera so if a player joins in an unconscious unit slot they cannot fire and they get a message that they are waiting to be revived.

Also, uncounscious units have been 'moved' sometimes. If it is an ai unit, it is gone forever, but a player can use respawn to reappear (it seems like it got stuck on the island, even though the 'deathmarker' appeared... the deathmarker also disappeared on one occasion).

One of the bugs you are describing I thinks relates to players joining on a unit while its revive timer is counting down.  So I’ve reduced the respawn timer from 8 to 4 seconds in the description.ext as this will reduce the likelihood of this happening in future but it may still occur so I’ve also implemented some code that tells the player he is joining on a dead unit and to pick another player slot.  There is some risk that this will muck up the rest of the timing of the script, I haven’t seen this so far in my testing but let me know if you run into probs and we may have to up the timer to 5 secs.

Did you change the weapon respawn script? Before it was launched with

_unitnames = ["man1", "man2", "etc"];

but now you just use _units...

Nice to be able to revive ai, but that damn message is driving us nuts wink_o.gif

Rejoining the slot every three minutes is not an option.

Hulk you are absolutely right about the quotes missing around the unit names in the init.sqf and onplayerconnect.sqf files – sorry m8 my bad.  One thing though is that you can just use the names with quotes for both the weapons and the revive scripts ie just define the array once with quotes (see my example) and this seems to remove almost all of the null object errors or as far as I can tell anyway – I only got one in a bout 2 hours of testing after I did this.

Also, do try to find a better way of setting up the variables - editing the ifs isn't very practical smile_o.gif

I’ve managed to remove one lot of the if statements by listing the array _units without the quotes around names at the start of the revive script but I’m having a bit more trouble with the other if statements though so I’ll keep working on it but I’m not sure of a solution to this at the moment.

Now for the bugs, for some reason occasionally the "joining mission" screen doesn’t appear when a player joins so if the unit is unconscious the camera doesn’t fire up and he doesn’t get the message he is unconscious and may find himself lying on the ground when he joins.  

The stupid thing is if that player joins in another slot in a different group without disconnecting from the server the joining mission message reappears and in some instances he can rejoin in the original slot and get the message back.  I’ve got no idea why this is happening and it may have something to do with the onplayerconnected cmd.

There's still the JIP on the group leader pistol bug on some occasions.

If the joining mission screen doesn't display and the player joins on a dead unit (respawn timer) they may end up on the island or actually join the mission standing even if unconcious (ie. desync).  I haven't been able to reproduce this error since I've reduced the respawn timer but it may still be there.

Share this post


Link to post
Share on other sites

How about adding an eventHandler killed? That disables user input for the 8 seconds it takes to respawn? Then whoever has the choice of waiting a few seconds before disconnecting, or shutting down arma the hard way...

Share this post


Link to post
Share on other sites

Hulk your changes to the "if" code are working nicely and I've updated the version I posted earlier today or you can get it here:

revive_010507.intro.zip

This version is much easier to implement as rather than the complicated "if" statements in the previous version of revive_player.sqf script you now only need to define two arrays at the start of the revive script, one with the unit names in quotation marks and the other without.

In my example mission the two arrays defined at the start of the revive script look like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_units = [alpha_1,alpha_2,alpha_3,beta_1,beta_2,beta_3,gamma_1,gamma_2,gamma_3];

_unit_names = ["alpha_1","alpha_2","alpha_3","beta_1","beta_2","beta_3","gamma_1","gamma_2","gamma_3"];

I'm still having some problems with players joining on units while the respawn timer is counting down.  It seems if you join under these conditions there is desync between the exisiting players and the one who joins.  Everyone sees the joining player as unconcious whereas he sees himself as alive. The joining player also gets a null object error if he joins on a dead unit, the only time I've seen it in the current version, so if this happens just go back to the unit selection menu and reselect the same unit and everything will go back into sync again.

EDIT: Updated file to the latest version 1st May 2007.  See post below for more details.

Edited by W0lle

Share this post


Link to post
Share on other sites

Another update with changes to the init.sqf code, camera_follow.sqs, revive_player.sqf, a new trigger placed in the mission editor and a new script "mission_end.sqf".

This new script in combination with the other changes keeps track of the number of concious players and ends the mission if all the players are unconcious.

It can be switched on or off by commenting out the line

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">call{[_units] execVM "revive_sqf\mission_end.sqf"}; in the init.sqf file by placing // at the start of the line ie. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//  call{[_units] execVM "revive_sqf\mission_end.sqf"};

The trigger that needs to be added in the editor looks like this in the example mission <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class Item0

{

position[]={2955.998779,21.107906,2461.976563};

a=1.000000;

b=1.000000;

activationBy="LOGIC";

timeoutMin=10.000000;

timeoutMid=10.000000;

timeoutMax=10.000000;

interruptable=0;

type="END1";

age="UNKNOWN";

expCond="mission_Over";

class Effects

{

track="ATrack8";

titleType="TEXT";

title="Mission Failed - all players are unconcious ";

};

You can get the new version here (ver 010507)

Edited by W0lle

Share this post


Link to post
Share on other sites

Where is the new Version ?

Because i become everytime scalar Error´s when i use more then one Player :-(

EDIT

As i asked the Rest of your Post was shown ;-)

Share this post


Link to post
Share on other sites

Thx loads i always use this in my coops now.. Its better than Respawning all the time and its better than dieing at the start of a coop and sitting out the rest of the game and it makes it more interesting for Rescue missions tounge2.gif

Share this post


Link to post
Share on other sites

Hey Norrin, I just picked up on this thread smile_o.gif this sounds quite interesting.

For my own purposes though, I'd like to ask a question/feature request:

Can the revive script be called according to a condition? For example I would like the script to have a value, lets say in the range 0 - 1 to give a probability of script execution. Also I might like to tie it into a condition also, for example if within a trigger area etc. But the probability one is the most immediately useful.

In this way I can make a more dynamic mission, people cannot necessarily rely on revive, while also I can force a revive in certain areas to make the mission players more careful in certain areas etc. (I can foresee that certain areas will be more difficult to perform a successful revive than others smile_o.gif)

Kindest regards

Share this post


Link to post
Share on other sites

Revive.SQF

New version available: ver 020507b

Description

A revive/respawn script in sqf format that allows all playable units to revive other playable units and be revived. While unconscious a camera is activated that follows the closest alive friendly unit if it is within 100 metres. In addition, the mission maker has the option of running an additional script that forces the mission to end if all the human players are unconscious. If you join the mission on a playable unit that is unconscious in game it triggers the camera when you join and you start the mission unconscious and will require reviving before you can move about.

Changes

Well I can hardly believe after all this time that I may have finally sorted out most of the remaining bugs in this script. I’ve moved from using HAILO’s JIP script (which wasn’t always activating for the joining player) to a variation on a trigger method described by Przemek_kondor to execute the revive_script and the “joining mission†screen when a player joins. As far as I can tell this new method always works. smile_o.gif

Now if you join on a unit while its respawn timer is counting down you get the correct message which is “Unit selected is dead please press escape, return to the unit selection menu and choose the same or another playable unit" and as long as you follow these instructions you shouldn’t run into any problems – lol, famous last words smile_o.gif.

I’ve also simplified the implementation of these scripts so now you only need to define the _unit array (ie the playable unit names in quotation marks) in the init.sqf and the onConnect.sqf files.

There also improvements to the follow-cam and I have managed to remove almost all of the null object errors thanks to suggestions from HulkingUnicorn (only one in 3 hours of intensive testing - yippee).

To implement the latest version in your missions.

1. Copy across the text from the init.sqf and the description.ext files into your init.sqf and description.ext files.

2. Copy the folder revive_sqf across to your mission directory.

3. Update the _unit array in the init.sqf and the onConnect.sqf (which you can find in the revive_sqf folder) files where commented to reflect the playable unit names used in your mission (remember to put them in quotation marks like in the example mission).

4. Create a marker on the map called Respawn_west away from the action – preferably on an island.

5. Create a gamelogic called Server

6. Create two triggers

For the 1st put -

Activation: Game Logic – Once

Timeout: min 10 max 10 med 10

Type: End #1

Condition: mission_Over

For the 2nd put -

Activation: Game Logic – Repeatedly

Countdown: min 0 max 0 med 0

Type: None

Condition: onConnect

On Act: call{[] execVM "revive_sqf\onConnect.sqf"};

7. You can toggle the mission_Over.sqf script (which ends the mission if all players are unconscious) on and off by commenting out its activation (ie. using //) in the init.sqf file.

Tested

On version 1.05 on both dedicated and local servers. Works with JIP.

Bugs

Still occasional problem if you join on an unconscious group leader – you have the pistol in hand but shoot from the rifle on your back, just respawn and get someone to revive you and the bug disappears.

@Matt – Thanks m8 smile_o.gif I’m hoping this version will fix any remaining major problems with the script and should be stable enough to run on dedicated servers without any hand holding – only time will tell I guess.

@DMarwick – I’m not sure about the condition stuff but it may be possible to start the revive script only once a certain zone has been entered – to be honest I’ve never tried. You could certainly implement a timer within the script so if you weren’t revived within lets say 60 sec you’d respawn back at base.

Edited by W0lle

Share this post


Link to post
Share on other sites

Hey norrin, so far so good but I seem to be having some of the same script errors as before. Great job so far!

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">`scaler |#|bool array string 0xe0ffffef` missing;

Here is my WIP mission that is using your script.

Demolicious beta 1.2

Edited by W0lle

Share this post


Link to post
Share on other sites

Same Scalar Error by me as i said a time ago

I use BAS:_frame but i mean that this should noting have to do with it...

In my Mission the Soldiers named w_1 ...w_10

If i use only w_1 all seams ok but if i use more then this one Error pops up.

Share this post


Link to post
Share on other sites

Only time I've got a scalar error was when I disabled the playable Ai at the briefing screen.  I'll have a look at your mission and check it out, thanks for the feedback guys. smile_o.gif

Edit: @EvilNate when I re-enabled the AI in the description.ext in your mission the scalar error disappeared so it looks like for the moment you can only use these scripts with the playable Ai enabled.  If I can think of a fix I'll put something together.  

@MCPXXL can you please check if you've got the playable AI disabled and if so re-enable and see if the error disappears otherwise post a link to your mission or PM me and I'll have a look at it.

Share this post


Link to post
Share on other sites

I do not need to look at, because AI is everytime disabled...

So what can we do to use ONLY Players ?

Share this post


Link to post
Share on other sites

I'm not sure cause a separate instance of the script needs to be running for each playable unit on each players PC for the script to stay in sync when people leave and join the server.  So if I set it up so that it only recognises human players at the mission start then the exisiting players don't have an instance of the script running for each joining player and the whole thing gets out of sync and looks terrible not to mention bringing back the null variable error.  

The only way around it maybe to re-introduce HAILO's join in progress script again so that a new instance of the script is run on the exisiting players machines when someone joins but this may cause big problems when someone leaves the server though.  

Either that or set up your playable units so that they are not in groups so human players can't order around the playable AI when they join a mission.  If you do that you could make the playable AI units invincible and friendly (using add EventHandlers and setCaptive true) so they are not targetted by the enemy until a human player joins and takes control.

I'll keep thinking about it but if you have any suggestions please let me know.

Share this post


Link to post
Share on other sites

It's true that if I change disableAI to zero and launch the mission the errors go away, but if you disable any AI in the "slotup" screen you get the same script errors.

I am in no way a script expert, but it seems like if you call and define the _units in revive.sqf and onConnect.sqf after the mission starts the intro, then keeps checking and updating the _units array while the game is in progress that might help.

Share this post


Link to post
Share on other sites

Some strange things are going on norrin...

Today an ai decided to jump out of a speeding stryker a few minutes into the mission (I trust the leader when he said he didn't give a disembark/eject order). He died immediatly, and disappeared completely, leaving a null error for most of us (1 guy got the error later).

Also I get the spin around while performing the unconscious animation bug (which might be my mistake) wink_o.gif

I'll send you the newest version of my mission smile_o.gif

Share this post


Link to post
Share on other sites

SQF_REVIVE for disabled AI

@EvilNate and MCPXXL

I think I’ve got the disabled AI error sorted, I posted this yesterday on OFPEC and have further revised the code since then.  The latest versions of the files are available below.  

Updated on 7th May 2007

These two versions (revive_player_AI_disabled.intro and revive_player_AI_disabled_medic.intro) of the script are only for use when playable AI is disabled on a dedicated server, if you are planning on using playable AI or a local server you’ll need to get the previous version of the script (ver 020507).

Changes

There's two additional scripts (“connected.sqf†and isplayer.sqf), a new trigger and quite a few changes to the existing scripts.

Additional notes for implementation

1. Just follow the same routine as for the previous version (ver 020507).

2. In addition you’ll also need to define the _unit array in the connected.sqf which you can find in the revive_sqf folder

3.  Finally you’ll need a new trigger placed in the editor

Activation: Game Logic – Repeatedly

Countdown: min 0 max 0 med 0

Type: None

Condition: connected

On Act: call{[] execVM "revive_sqf\connected.sqf"};

The two scripts are available here:

All players can revive (ver revive_player_AI_disabled.intro)

and

Only players who are medics can revive (ver revive_player_AI_disabled_medic.intro)

Bugs

1. If you respawn, then quickly disconnect from the server (all within 2 seconds) you can cause a null variable error for all continuing players.  This is unlikely to happen in practice unless you really go out of your way to do it.

2. If you hit respawn while unconcious then you are transported to Respawn_west, if this happens disconnect and rejoin in the same slot and you will rejoin concious at the mission start point.

EDIT:  Updated both zip files which contain code optimisation and bug fixes

@HulkingUnicorn, is it working any better since we discussed this yesterday.  If you're still having problems I'll make a new version using a modification of the disabled AI code.

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  

×