Jump to content
Sign in to follow this  
norrin

SQF revive script

Recommended Posts

Nice job Norrin, I might start using it in my missions as it has became a lot more mature!

Share this post


Link to post
Share on other sites

Thanks sickboy that would be an honour indeed m8. smile_o.gif

I've gotta say its been a long an arduous process especially with JIP and although I can't guarantee its completely bug free its certainly light years along from where I naively started some months back. Its kind of embarrassing that its taken this long and gone through so many changes but so far the current version seems to be stable and it has allowed me to add features and fix bugs as they come up with fairly minor changes to the backbone code. So I'm hoping I'm not that far off a problem free revive/respawn system.

AI-enabled revive script and AI-disabled revive script (with respawn counter).

Share this post


Link to post
Share on other sites

No worries... And even though a "Revive System" sounds fairly easy, I can say that it's not... It's fairly complex code, because there is much to take into account... Aswell as that it requires hacks/workarounds to do as wished smile_o.gif

I don't think you should be ashamed for the time it took, I think you should be proud to be where you are now; Made a nice accomplishment and prolly learnt a lot from it smile_o.gif

Share this post


Link to post
Share on other sites

Hi again mate!

Tested the newest version today:

* About half an hour into the mission a stryker blew up with 3 players and 2 ai inside - we got the null error + ai moving around in circles anti-clockwise on the ground (while turning clockwise)...   One player left after the script kicked in, and I got a generic error in expression error (forgot to take screenshot, though).

* We got no errors the next round (even though we died in the stryker once more).

* I had the mission ending script disabled (call line commented out).

On the plus side, it's only 1 array to update now, and way less lines in the init.swf smile_o.gif

Share this post


Link to post
Share on other sites

Damn, I hate vehicles. smile_o.gif

Weird the error would occur the first time you played through but not the second, can you remember there being any differences between the two times you were killed eg the number of players or AI onboard when you were hit?

I have to admit on a couple of occasions in testing I've got errors that I've never been able to replicate and had to put down to some bizarre alignment of the planets.

Anyway, I'll set up some tests in which I destroy vehicles with multiple players and AI onboard over the next few days and see if I can trigger the same error and if I can I'll try and come up with a solution.

As always thanks m8. smile_o.gif

Share this post


Link to post
Share on other sites

I think we may have been one player more or less the first time (and thus one more or less ai tounge2.gif).

Actually, now that I think about it, it went ok the first time and we got the error the second time. The first time we died from driving down a mountainside at full speed (east of Tlaloc), the second from being blown up by a bmp (on the mountain north of a farm about a kilometer from Baja Valor).

Happy testing wink_o.gif

Share this post


Link to post
Share on other sites

Hi Norrin,

I did what you suggested and commented out the line in the onConnect.sqf script and early testing looks positive. The issue with the looping animation seems to have been resolved by commenting this line out.

I will get my clanmates to join in my mission and confirm.

Great stuff once again.

Share this post


Link to post
Share on other sites

Norrin, have you noticed increase fps usage with the new version?

I have to test if it could be due to other changes in my mission, but I honestly don't see what I've changed recently as able to drop about 10 server fps...

The fps drop caused huge drops in stability, I guess - I got this null error lots of times, and script stopped working for some ai.

I'll try putting your newest version on one of my older versions and see how it goes.

Share this post


Link to post
Share on other sites

No I haven't m8.  The script hasn't changed that much from previous versions just a couple of extra lines of code so its unlikely but not impossible.  I have found if you use too many instances of UPS and the revive script that can really screw things up though.  Let me know what you find out?

I've started running vehicle tests and the problem with the AI enabled version you've been using seeing seems to occur when you have a combination of playable Ai and players in a vehicle - when the vehicle is destroyed one of the AI disappears and that sets off a chain reaction of errors as the scripts still thinks that the AI unit exists.  I've got some ideas for a work around just haven't had a chance to try them out yet.

EDIT: Hulk, I've just run some tests using a demo revive mission I'm writing that is set on Sara and uses the UPS script about a dozen times as well as a few other scripts and I can find very little difference in fps between using the old version, the new version or disabling the revive script altogether. The test wasn't as intensive as what you're probably doing as there were only 4 units running the revive_scripts in this mission so let me know if you find anything.

Share this post


Link to post
Share on other sites

I think I've found the what's causing the disappearing playable AI bug and null variable error in the AI enabled script.

You need to replace line 134 in the revive_player.sqf, which reads <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">deleteVehicle _body; with this <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (!alive _body) then {deleteVehicle _body}; When I get some more time tomorrow I'll post the revised scripts.

Share this post


Link to post
Share on other sites

Yes, checking if it's dead first seems to be a good idea smile_o.gif

Would this also cover the disappearing ai from vehicles exploding while containing both players and ai?

Edit: Your script seems to not the be culprit smile_o.gif

Guess I'll just have to think hard on what I've added recently that could do something like this (talking about server fps loss).

Share this post


Link to post
Share on other sites
Yes, checking if it's dead first seems to be a good idea smile_o.gif

Would this also cover the disappearing ai from vehicles exploding while containing both players and ai?

Edit: Your script seems to not the be culprit smile_o.gif

Guess I'll just have to think hard on what I've added recently that could do something like this (talking about server fps loss).

Whew thats a relief smile_o.gif.

You're right about checking if they were dead the disappearring AI had me competely flummoxed until I worked out that was the problem - seems pretty obvious now.

Although I've found it alot harder to create the bug you're describing I'm hoping this change will also fix the disappearing AI from vehicles you are seeing as the problem it does fix is also related to AI dying in vehicles. Anyway here's hoping, let me know how you get on.

EDIT: Here's the revised AI-enabled revive script (29th May 2007) with the changes to the deletevehicle command (also updated previous links).

I'm not sure whether this is also a problem for the AI_disabled scripts (as there is no AI) but I'll run some further tests tonight and let you know if I need to make similar changes to these scripts as well.

Updated original post in thread.

EDIT: Got bored last night and made a short vid of the AI_enabled script in action from different player perspectives you can see it

Share this post


Link to post
Share on other sites
Quote[/b] ]//This variable can be changed if for example you only one sort of unit to be able to revive or

//you want to use these scripts for a different side

_can_revive = "SoldierWB";

_can_be_revived = "SoldierWB";

How do I make this ANY west (blufor) type of soldier???

Share this post


Link to post
Share on other sites
Quote[/b] ]//This variable can be changed if for example you only one sort of unit to be able to revive or

//you want to use these scripts for a different side

_can_revive = "SoldierWB";

_can_be_revived = "SoldierWB";

How do I make this ANY west (blufor) type of soldier???

Hi m8,

The way its currently set up in the snippet of code you've posted should work for any BLUFOR man class unit (ie. soldier). If its not working could you please post a link or send me your mission so I can check your code.

Thanks

PS: A short vid of the AI_enabled script in action from different player perspectives can now be seen on

Share this post


Link to post
Share on other sites

Your script dooesn't seem to work. I used a copy of the AI_Disabled_West stuff, and it fails with this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_Near_Unit = _Near_Units |#| Select |'

Error Zero Divisor

I get this AFTER I'm shot, and the camera action starts - Help?

FYI.. what I did was:

1. Copied your init.sqf to my mission dir, exactly.

2. Added correct variables to description.ext (revive time, no ai, etc)

3. Changed unit names in the 3 files you have to change them in:

_units = ["Ua1","Ua2","Ua3","Ua4","Ua5","Ua6

","Ua7","Ua8","Ua9","Ua10","Ua11",&

amp;

quot;Ua12"];

(Curious why not put this once in INIT.SQS and just call it from there?)

And boom.. errors? sad_o.gif

... I stay dead, even though people use "revive" on me... and the error stays on the screen constant.

Share this post


Link to post
Share on other sites

satexas69 can you please send a copy of your mission to norrins_nook@iprimus.com.au so I can take a look at it, if its a bug this will help me enormously in tracking it down.

The reason why the scripts were not called from the init.sqf was that method did not, for what ever reason, work reliably every time a player joined nor did HAILO's on player connect script though in other instances where I've used it, it works perfectly. Therefore, I ended up using a sequence of triggers that fire seperately when some one joins in prog on the joining players computers and on the existing players computers, hence the need to repeat the _unit array.

Share this post


Link to post
Share on other sites

Thanks for the fast response. I PM'd you with a URL click-to-download download link.. figured that would be easiest smile_o.gif

Russ

Share this post


Link to post
Share on other sites

Thanks for the fast response. I PM'd you with a URL click-to-download download link.. figured that would be easiest smile_o.gif

Russ

OK several hours later I think I've got it sussed and its one of those bizarre things about ArmA.

Now it would appear that

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//This variable can be changed if for example you only one sort of unit to be able to revive or

//you want to use these scripts for a different side

_can_revive = "SoldierEB";

_can_be_revived = "SoldierEB"; works for OPFOR units, and<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//This variable can be changed if for example you only one sort of unit to be able to revive or

//you want to use these scripts for a different side

_can_revive = "SoldierGB";

_can_be_revived = "SoldierGB"; works for independent units but for some reason "soldierWB" doesn't always work for BLUFOR units. A work around for this is to use "man" in all the revive_player scripts when using BLUFOR units ie.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//This variable can be changed if for example you only one sort of unit to be able to revive or

//you want to use these scripts for a different side

_can_revive = "man";

_can_be_revived = "man";

I've checked this in your mission satexas69 and the revive_scripts now seems to be working.

Share this post


Link to post
Share on other sites

Norrin,

Excellent work. Changing the code to "man" instead of the soldier worked excellent. I and a friend jumped into the mission, killed each other, and revived one another testing.

BUT, we ran into other "issues".

1. I commented out this line:

//call{[_units] execVM "revive_sqf\mission_end.sqf"};

... which is supposed to keep the mission from ending when we both die. Ok, that works, the mission does not end.

HOWEVER, once we're both dead, we're both dead with us looking at our corpses and we have to disconnect from the server to start over. We can't use "ESC" and "respawn" manually.. we stay dead.

Which leads me to:

2. Is there any way you can set some kind of "countdown" so that if we're not revived by a certain amount of seconds (perhaps a variable we can adjust) you auto-respawn back to a specific marker?

3. A far lesser important option would be maybe to have a "respawn now" button that one could click to avoid waiting the revive possibility and auto-respawn you "now".

Your script is 50x better than the other one being used, and I'm absolutely thrilled at not only the way you have it set up, but the great way you're supporting it.

Excellent work!

P.S. It would be cool if your dead markers would say the person's "DESCRIPTION" instead of the unit's "NAME" - IE, "Joe Buck" instead of "Man1" (or in my case "UA1"). If you need a looksie on how to do that, there's a neat airstrike script that uses a lot of naming in it I can send/get to you. In fact, it even uses the person's gaming nick instead of the hard-coded charcter name... "SATEXAS69 is down"

- Russ

Share this post


Link to post
Share on other sites

NPs m8.  I'm glad we could get it sorted. smile_o.gif

Just a quick question were you playing on a dedicated or a local server cause if you were on a dedicated server you should be able to disconnect one at a time and reconnect back at the mission start point without having to restart the entire mission.

As for giving you the option to do this I've never really considered it as I designed this script to make missions slower, harder and so that they require more team work to complete so if you're all dead you have start again and be more careful.  

I do see what you're saying though so I guess I could add a timer that after 2 - 5 minutes (up to the mission makers descretion) would spawn you back at the start point all healed and ready to go without having to restart.  Shouldn't be too hard as I've done something similar in the past but it risks adding bugs. sad_o.gif Anyway I'll take a look at it over the next few days.

Finally, I've toyed with the idea of using the players name rather than the units name but this causes some JIP probs with the AI_enabled script so I reverted back to the units tag. I could possibly set the name of the unconcious marker back to the player's name in the AI_disabled script though - I'll test it out.

Share this post


Link to post
Share on other sites
Quote[/b] ]

Finally, I've toyed with the idea of using the players name rather than the units name but this causes some JIP probs with the AI_enabled script so I reverted back to the units tag

Are you talking about players name staying in the marker problem after he disconnects?

Wouldn't it be possible to set the marker text to the units name every few minutes somewhere inside your loop?

Share this post


Link to post
Share on other sites

Norrin,

Sounds excellent.  (Yes, we use a dedi-server, feel free to test on it at ANY time - still have IP and pass that I sent earlier?)

If it helps, we'll ALWAYS be using the "no-AI" feature. We like it 100000000x better... and I don't mind you having "2 versions" of your script, one with more or less features than the other. Yeah, bugs are a pain in the ass! smile_o.gif

I'm using your script for a Paraiso map where the city has waves and waves of troops that engage upon it, making a dynamic battle that lasts many, many hours.

To keep it interesting, and co-op up, I'd like to use the revive where if a buddy revivies you, you don't spawn all the way back at base.... but also where that person doesn't have to wait "forever" as that drives many people NUTS.

The other revive script, which I think is inferior to yours, runs a timer to where if you aren't revived by "x" time, you auto go back to base. I would like to see that in your script - maybe as an option if not regular feature.

Another reason I'd like that feature is becuase we play on our dedicated server where normally 2-5 people are on at once... and that's a small number easy to die at once before revive on a big mission...

Thanks!

Russ

Share this post


Link to post
Share on other sites

For some reason I'm little reluctant to release this but as far as I can tell the latest versions of the AI_disabled revive scripts seem to work well - I'm sure someone will prove me wrong. tounge2.gifsmile_o.gif

You can get them from here: 070607

Here's the implementation notes:

REVIVE SCRIPT - AI disabled dialog beta

Creates playable units that fall unconcious when killed which can then be revived

© JUNE 2007 - norrin (norrins_nook@iprimus.com.au)  

Version:  Beta 8.0 (Revivable Players - AI disabled) - 7th June 2007

Description

* A revive/respawn script in sqf format that allows all players to revive other players and be revived.  

* The mission maker can set the number of revives available to each player – once this limit is reached the player is declared dead and then must disconnect and select another playable unit and spawn at the mission start point.

* Any players JIP spawn at the mission start point and have any current unconcious markers added to their maps

* While unconscious a camera is activated that follows the closest alive friendly unit if it is within 100 metres.

* While unconcious the player also has the option to press the respawn button that will heal him and transport him back to the mission start point  

* In addition, the mission maker has the option of running an additional script that forces the mission to end if all the players are unconscious (default condition is off).  

* Designed for use with the playable AI disabled

Missions included:

AI_disabled_dialog_beta - test mission and version of the script for Blufor forces

AI_disabled_dialog_beta_medic - test mission and version of the script for Blufor forces, medics only can revive

Changes from previous versions

Ability for the player to respawn at base if he is playing alone or if he gets sick of waiting to be revived

All JIP players have the locations of the current unconcious markers added to their map when they join the mission.

Tweaks to a number of other scripts including the unconcious_camera script to eliminate bugs

Simplified the definition of the _units array by replacing it with the global array player_units. Now you only nedd to define this array once in the init.sqf script.  

Implemented a respawn counter that if reached results in the player’s unit dying out right and which requires the player to go back to the unit selection menu and rejoin the mission at the mission start point.  The number of revives available before a unit dies can be set in line 46 of the revive_player.sqf that can be found in the revive_sqf folder (currently set at 1 for testing purposes).

I’ve also made it simpler to convert the scripts for use with other sides.  Just change the entries at lines 42 and 43 of the revive_player.sqf.  

NB: at this time you can only use the medic only version if wish to specify that only a single unit type can revive.  For the more general version of these new scripts (eg. AI_disabled_west) just put the generic soldier class for whatever side you wish to use (eg. soldierWB or soldierEB) in both lines.  I’ve had to do this as there are some problems with the ‘typeOf’ and ‘isKindOf’ commands that if fixed will allow a more generic script to be created.

Implementation

NB: Please make sure you use the latest versions of all the files as changes have been made to quite a few of the original scripts

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 revive_sqf folder across to your mission directory.

3. Update the player_units array in the init.sqf 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 Boot_Hill away from the action for the dead units – preferably on an island.

5. Create a second marker on the map called "Start_west" where you wish the players who choose the respawn dialog option to be teleported to.  

6. Create a gamelogic called Server

7. Create four triggers in the editor

For the 1st put -

Activation: Game Logic – Once

Timeout: min 15 max 15 med 15

Type: End #1

Condition: mission_Over

Effects:

Track: Short: Casualties of War

Type: TEXT

Effect: Plain

Text: Mission Failed - all players are unconcious

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"};

For the third –

Activation: Game Logic – Repeatedly

Countdown: min 0 max 0 med 0

Type: None

Condition: connected

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

For the fourth

Activation: Game Logic – Repeatedly

Countdown: min 0 max 0 med 0

Type: None

Condition: onConnect

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

8. 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 //) on line 28 of the onConnect.sqf file - default is off.

9. Make any changes to the _max_respawn variable and the _can_revive and _can_be_ revived variables in the revive_player.sqf (described above).

Tested

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

Bugs

If you do not get the joining mission message upon starting the mission then return to the unit selection screen and try again (I’ve only seen this a couple of times in many hours of testing so you may not ever experience it).

There's still some niggling problems with the camera.

Very Important

Some users have reported the although the scripts work up to a point (ie. the player falls unconcious and the unconcious camera activates) the units cannot be revived by friendly units.  This seems to be related to some problem with the "soldierWB" code on lines 42 and 43 of the revive_player.sqf script.  If this occurs replace this code with "Man" as a work around in lines 42 and 43 of the revive_player script. If using the medic only script try putting "man" for the  _can_be_revived variable on line 43 of the revive_player.sqf.  Unfortunately, although allowing the script to run, using "Man" instead of "soldierWB" will allow the unconcious camera to attach to civilians or even enemy units so it is far preferable to use the "soldierWB" code if possible.

As always I hope I haven't forgotten anything.  

Good luck smile_o.gif

norrin      

@satexas69 this yet another revised version

Share this post


Link to post
Share on other sites

Heya Norrin Nice job as usual mate!

I haven't taken a look at the code so forgive me if i'm making wrong assumptions smile_o.gif

I was kinda wondering why you don't create the triggers on the fly instead of making mission makers go through the pain of a bunch of manually creating triggers etc?

Example of creating triggers:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> SIX_trig = createTrigger ["EmptyDetector",getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition")];

SIX_trig setTriggerType "NONE";

SIX_trig setTriggerActivation ["ANY", "PRESENT", true];

SIX_trig setTriggerArea [40000, 40000, 0, false ];

SIX_trig setTriggerStatements ["this", "", ""];

The "getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition")" part makes sure that the trigger comes on the middle of the Island. smile_o.gif you can simply make it [0,0] for switches that don't need any trigger area etc. etc. BIKI explains the functions.

Share this post


Link to post
Share on other sites
Heya Norrin Nice job as usual mate!

I haven't taken a look at the code so forgive me if i'm making wrong assumptions smile_o.gif

I was kinda wondering why you don't create the triggers on the fly instead of making mission makers go through the pain of a bunch of manually creating triggers etc?

Example of creating triggers:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> SIX_trig = createTrigger ["EmptyDetector",getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition")];

SIX_trig setTriggerType "NONE";

SIX_trig setTriggerActivation ["ANY", "PRESENT", true];

SIX_trig setTriggerArea [40000, 40000, 0, false ];

SIX_trig setTriggerStatements ["this", "", ""];

The "getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition")" part makes sure that the trigger comes on the middle of the Island. smile_o.gif you can simply make it [0,0] for switches that don't need any trigger area etc. etc. BIKI explains the functions.

M8, I think you may have me confused with someone who knows what he's doing. smile_o.gif Anyway, I'm sold, I must admit I never thought of it, I'll look into over the weekend and try and get something implemented.  See it didn't take long. tounge2.gifsmile_o.gif For the latest version of the revive_AI_disabled script, for anyone brave enough to try it, grab it here: 070607

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  

×