Jump to content
Sign in to follow this  
norrin

SQF revive script

Recommended Posts

If you are in the editor and place a player controlled unit somewhere, hit "preview" button and get somehow killed you can-not press "exit" as the input is completely disabled....

This can be solved...

Just add the following code (to revive_init.sqf for example), it's a little bit modified version of sickboys code:

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

T_INIT = false;

T_Server = false; T_Client = false; T_JIP = false;

T_MP = (if (playersNumber east + playersNumber west + playersNumber resistance + playersNumber civilian > 0) then {true} else {false});

if (isServer) then {

T_Server = true;

if (!(isNull player)) then {T_Client = true};

T_INIT = true;

} else {

T_Client = true;

if (isNull player) then {

T_JIP = true;

[] spawn {waitUntil {!(isNull player)};T_INIT = true};

} else {

T_INIT = true;

};

};

waitUntil {T_INIT};

Now in r_killedhandler.sqf add the following code after the first enableRadio false; (replace the "disableUserInput true;" line):

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

if (!(isNil "T_Server") && !(isNil "T_Client")) then {

if (!T_Server && T_Client) then {

disableUserInput true;

};

} else {

disableUserInput true;

};

Though you won't probably need "if (!(isNil "T_Server") && !(isNil "T_Client")) then {", I've made an addon for our server with a lot of scripts including revive, so we don't need to change the millions of revive missions we have but only update the addon.

Now you don't need to shutdown ArmA if you get killed during testing in the editor.

Xeno

Share this post


Link to post
Share on other sites

norrin do you remember the problem I had with line 65 r_killedhandler.sqf "while {true} #do " "Type String expected code"?

I updated to 1.45 1.09 ver. I looked over r_killedhandler of the one you fixed and the new 1.45 but I don't see any changes that would be a problem. You told me in an email "mission was conflicting with some of the code in the revive (I haven't seen this before) so I just removed the offending code and it seems to working OK". Their was actually a problem, you'd get "|#| <NULL-object> Error Invalid number in expression" it wouldn't say the line or anything but the "unconscious and waiting" would continue. I'm guessing it would have the same issue even if we fixed the "Line 65" problem in 1.45?

Share this post


Link to post
Share on other sites

Thanks for dealing with this xeno. smile_o.gif

M8, I really like your idea of a revive addon (I know someone else also mentioned this about 30 pages back in the thread) so once I get the next feature implemented (and its a beauty - but I can't say any more at this point) maybe we could look at creating a stand alone revive addon for all the punters, but I'm going to need help.gifhelp.gif

This would be really cool as we could possibly bundle SNKMAN's gpl2+ sounds addon as well (with his permission of course) and then we could have the downed units saying a whole range of extra stuff in different voices while they are lying unconscious.

Share this post


Link to post
Share on other sites
norrin do you remember the problem I had with line 65 r_killedhandler.sqf "while {true} #do " "Type String expected code"?

I updated to 1.45 1.09 ver. I looked over r_killedhandler of the one you fixed and the new 1.45 but I don't see any changes that would be a problem. You told me in an email "mission was conflicting with some of the code in the revive (I haven't seen this before) so I just removed the offending code and it seems to working OK". Their was actually a problem, you'd get "|#| <NULL-object> Error Invalid number in expression" it wouldn't say the line or anything but the "unconscious and waiting" would continue. I'm guessing it would have the same issue even if we fixed the "Line 65" problem in 1.45?

We must have posted at the same time m8. I'm not at home so I don't have my notes with me but the conflict I seem to remember was between the extended eventhandlers you were using and the revive code. What seemed to fix it last time was removing all the <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">enableRadio false; and <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">enableRadio true; from the r_killedhandler.sqf script in the revive_sqf folder.

If this doesn't work, email me your mission and I'll try and track down the problem.

Share this post


Link to post
Share on other sites
Thanks for dealing with this xeno. smile_o.gif

Thank you guys both.... i hop you'll include this code in the newer versions of the script....

Best Regards, Christian

Share this post


Link to post
Share on other sites

AI-disabled Revive 1.45 with drag body alpha

This is an alpha release and it incorporates a new drag body function that allows the player to drag an unconscious team mate out of the line of fire before you revive him.  I have to admit this is something I've been wanting to implement for some time.   This alpha version also incorporates the new code suggested by xeno a couple of posts back. 

If you're interested check out the quick and nasty video of what it looks like (sorry for the quality of this but I ran out of time):

I am disappearing for a few days but when I get back I'll make a more comprehensive movie showing the new function in a lot more detail.

You can get the alpha script here

Here's how it currently works

If you get within 2 metres of an unconscious player you now get an action to not only revive the unit but also one that allows you to drag the body.

If you select this action you crouch and drag the unconscious player a few steps backwards.  You then stand for a second - during this time you can change the direction in which you are dragging the body.  You then crouch and drag again etc etc.

While you are dragging the body you get an action to drop the body - this can be selected at any time and it detaches the body from the player dragging it.  Once you have done this you get the two actions again either to drag or to revive.    

If you do try the drag alpha make sure you let me know what you think and how I can improve it.  I'll be back online on Tuesday.

norrin

PS: Sounds like alef has written some great new scripts and options to add to the revive.

Share this post


Link to post
Share on other sites

Hi norrin,

You are getting the whole patched package with a diff.

With this patch, the unconscious player will drop his weapons on the ground or leave them in its body, with a "bury" timeout. 4 new parameters has been added in the init to drive this behaviour.

I've just see now the post about dragging unc. player around. That's a great idea ant you were not the only one who want this feature I suppose ... I'm going to merge it.

Greetings,

alef

EDIT: <s>Is this alpha for 1.09 ? </s>

EDIT: You mainly publicVariable arrays, so the 1.09. Do you think to patch your 1.08 branch too?

Share this post


Link to post
Share on other sites

Hate to be the first to ask this question but with V1.11 now released are you compatible?

Vengeance smile_o.gif

Share this post


Link to post
Share on other sites
Hate to be the first to ask this question but with V1.11 now released are you compatible?

Vengeance smile_o.gif

There's always one trouble maker smile_o.gif  I've just checked and there's nothing in the changelog that would suggest there's going to be a problem.

EDIT:  Just quickly checked a mission using the new beta and the revive with "drag"  option (and no I don't mean 6 inch heals, sequinned dresses and copius amounts of make-up smile_o.gif) and everything seems to be running well.  I've haven't had a chance to check all the revive features though but it looks like its going to be OK.

@ Alef - thanks m8.  Got your email it all looks excellent.  I'll get these features put into the latest revive and post it up when I get back on Tuesday.  Thanks again smile_o.gif

Share this post


Link to post
Share on other sites
Tomcat you know I can never explain anything without writing a book. smile_o.gif

Here goes, when the mission maker enables the new "punish rejoining player" option he also chooses how many lives a rejoining player gets if he quits and rejoins the server (eg. 3 lives).

mission example

So this is what happens next. Three players join at mission start with 10 lives each. The mission then runs for 2 minutes in which time the players can quit and rejoin the mission as many times as they like without being punished. At the 2 minute mark a message flashes up on the screen warning the players that if they quit they will rejoin the mission with only 3 lives. Player 1 is making like Rambo at this point and is killed. He can't be bothered to wait to be revived so he immediately quits and rejoins and has only 3 lives when he rejoins the server. Player 2 and 3 are playing like a team but player 2 finally loses all 10 lives and winds up dead, at this point he quits and rejoins but as he used his full allocation of lives (ie.10) he rejoins the mission with the full 10 lives. Just one other thing any player joining the mission in progress for the first time after the 2 minute mark will get 10 lives but they will get the warning message within 10 seconds of joining the server (ie. there is no 2 minute grace period for players joining in progress). I hope I haven't completely confused you now and this explanation makes things clearer.

just came back from a long trip and i see you have been busy...:)

just a quick question using your example.

player 1 (rambo) disconnects and reconnects after 2 minutes so he joins with 3 lives. After another 2 minutes he dies and disconnects and reconnects again....what happens then? is he still rejoining with 3 lives or joins with full 10 lives?

Share this post


Link to post
Share on other sites

new option very intresting)

waiting for ai-enabling script with smoke_cover and ai_real_drag_to_save_cover for heal action)

o) i'm forgot about medevac)

sorry my engliz and my overestimated requirements)) whistle.gif

Share this post


Link to post
Share on other sites

I would love to see this script as an AddOn which works even in simple editor mission.

Share this post


Link to post
Share on other sites

sounds great norrin ... will pop it into a few missions

and get back to you with some feedback .. smile_o.gif

Share this post


Link to post
Share on other sites

Hello guy's,

I was trying this new add-on with dragging of downed players but I can't get it to work.

The revive script says : wrong game version for revive.

And the mission itself said it needed 1.09.

I don't even have 1.09 installed anymore and I made this mission entirely on 1.08.

I looked everywhere but I couldn’t find the problem.

Did somebody encountered this already?

Or is version 1.09 needed for this. If thats true than i find it a little strange cause almost evrybody uses 1.08 right now.

Still its a great script... but i think i need to switch to a older version.

Share this post


Link to post
Share on other sites

Not the mission, the script said that it requires 1.09 because some really important features are added with 1.09.

Just use 1.09 or 1.11 for testing.

(There is a 1.08 version of the revive script, and it would be possible to bring the alpha to 1.08. But don't expect it before it goes beta because it is not a nice job to do it)

Share this post


Link to post
Share on other sites

I feel so stupid.. I didn't read the main page.

With the instructions on which to download.

I downloaded the script from Armaholic.. and there it says nothing about version 1.08 or 1.09

But thanks for the quick response man.. appreciate it.

Share this post


Link to post
Share on other sites

wow_o.gif Damn norrin this drag option looks ace, can't wait for RL to cut me some slack so I can try it for real. Fantastic job as always  notworthy.gif

Igor.

Share this post


Link to post
Share on other sites

Ouch wait a sec... I am newb omg.

Its script for MP of course.

God damn I though its for SP, hah xD

Share this post


Link to post
Share on other sites

AI disabled revive script update (27th March 2008 version x_1.46)

NB: This version of the revive is for ArmA 1.09+ only

You can get a new version of the script here: http://home.iprimus.com.au/simonnsl/norrinsArmA/AI_disabled_x_1.46.zip

Mobile Respawn Option

It is now possible to implement a built-in mobile respawn point as one of the respawn buttons in the unconscious dialogs.

To set up the mobile respawn point:

1. create a vehicle to act as a mobile respawn point in the editor, name it “r_mobile_spawn_vcl†and put this in the vehicles init line <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> this addEventHandler ["GETIN",{if ((_this select 1) == "driver") then {NORRN_landy_script = [_this select 0, _this select 2] execVM "revive_sqf\mobile\mobile_spawn.sqf"}}];this addEventHandler ["GETOUT",{[_this select 0] execVM "revive_sqf\mobile\mobile_remove_spawn.sqf"}]; nil = [this, 30] execVM "revive_sqf\mobile\vcl_respawn.sqf"Where 30 in the last line is the time before the mobile_respawn_vcl respawns after being destroyed

2. set <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">NORRN_mobile_spawn = 1; //array no.51 in the revive init.sqf

3. place a marker in the editor where the mobile respawn vehicle starts and give it a name such as “Base†in <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_NORRN_mobile_base_start = "Base"; //array no.52 (preferably make this an empty marker so it does n't show-up in the mission.

4. Create a second called eg “mobile†on top of the “Base†marker and put the name of this marker in <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _NORRN_Base_1 = "Mobile"; //array no.13

Here's how it works

Jump into the landrover and you'll get the action to deploy the camo. Just ignore it to start with and start driving the vehicle and the action will disappear. Stop the vehicle and switch off the engine the action to deploy will reappear.

Deploy the camo, you'll get your netting, ammo crate and the respawn point will be moved to the location of the landrover. You'll also get the option to stow the camo but ignore that for the time being.

Jump out of the vehicle and respawn and you'll reappear next to the landrover. Jump back in the vehicle and the action to stow the camo will reappear. Stow the camo and drive off. If you die while the camo is stowed then the respawn point is back at the flag.

If you destroy the vehicle while the camo is deployed the camo and ammo crates disappear and the vehicle respawns at base after a settable amount of time. The respawn point is also reset to the flag.

While the mobile spawn point is stowed the respawn marker will appear with the name ’’base“ in the respawn dialog and on the map and when it is deployed it will appear as mobile on the map and in the respawn dialog that way you can tell if its been deployed or not. You can also set up the enemy control of the mobile respawn points as you normally would for static respawn markers.

Restrictions

Only the vehicle's driver will get the option to deploy camo and he must get in the vehicle in the driver's position for it to appear (he can't get in the back and then move to the driver's position).

If the actions don't appear just get in and out of the vehicle as driver a 2nd time.

The engine must be off for the actions to appear.

Only the first respawn point (ie _Base_1) can be a mobile spawn point

alefs new functions

alef has passed on some code to me that gives the mission makers some new options for when a player respawns (either following use of the respawn dialog or if the revive timer elapses).

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Additional revive functions with many thanks to alef (0 - off, 1 - on except for _NORRN_bury_timeout)

_NORRN_drop_weapons = 1; //array no.48, Should the respawned player drop his weapons where he died?

_NORRN_cadaver = 0; //array no.49, Should the respawned player's body remain there?

_NORRN_bury_timeout = 120; //array no.50, If drop weapons OR player body, how long before the body is buried?

// 0=maximum (1200s) , n=seconds up to 1200s (hard coded)

Here's the new options:

1. the player dying then dropping his weapons when he respawns or

2. dying and his weapons stays on his body until the timer elapses and then he drops them and his body is deleted or

3. dying and his weapons stays on his body until the timer elapses and then he does not drop them and his body is deleted.

Limitations

The only problem with this new set-up is that if a player dies more than once and respawns at base before the body delete timer elapses the player's first dead body is deleted when the second one is made - so it may not drop its weapons.

Once again many thanks to alef for these changes and his other suggested script optimisations

Changes to the rejoin punish function

Its now possible to set a second rejoin punish function so that if a player rejoins a second time without having used his lives he rejoins the mission as a spectator eg.

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

The in mission warning messages have now been changed to reflect this.

Other script changes

I've also added some new options for the rejoin punish script and changed the code so the revive only works on units in the player_units array, so now you can have some players that use the revive and some that don't (eg pilots) if you need to set your mission up like this.

All players named in the NORRN_player_units array can drag unconscious units even if they cannot revive eg. if medics only can revive.

Share this post


Link to post
Share on other sites

norrin, can you please change your script that it won't overwrite nil?

For example this code will override nil to the script handle.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nil = [_bee, _NORRN_pos, _name_player] execVM "revive_sqf\cam_follow.sqf";

So please use a custom variable for example _script to retrieve the script handle.

Also please modify

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (NORRNCustomExec1 != "") then {call compile NORRNCustomExec1};

to

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (NORRNCustomExec1 != "") then {[_reviver] call compile NORRNCustomExec1};

This is required for, that we know who has revived the player.

Another point with the custom code:

Please give a note if these codes run global or local and on which's computer. NORRNCustomExec1 for example runs local on the revived persons computer.

Thanks

Share this post


Link to post
Share on other sites
norrin, can you please change your script that it won't overwrite nil?

For example this code will override nil to the script handle.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nil = [_bee, _NORRN_pos, _name_player] execVM "revive_sqf\cam_follow.sqf";

So please use a custom variable for example _script to retrieve the script handle.

Also please modify

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (NORRNCustomExec1 != "") then {call compile NORRNCustomExec1};

to

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (NORRNCustomExec1 != "") then {[_reviver] call compile NORRNCustomExec1};

This is required for, that we know who has revived the player.

Another point with the custom code:

Please give a note if these codes run global or local and on which's computer. NORRNCustomExec1 for example runs local on the revived persons computer.

Thanks

Hi m8,

Using nil as the script handle just ensures the script is not defining any unnecesary global variables.  If you need the script handles or the customExecs changed for a specific function in your mission set-up please feel free to change the code yourself to what ever you need smile_o.gif

As far as the custom codes are concerned they are all designed to be local to the client.  You can spawn/execute these on other players PCs and the server though by using the "setVehicleInit/processInitCommands" commands or by possibly using the new "addPublicVariableEventHandler" command (I haven't looked into this yet though).

norrin

Share this post


Link to post
Share on other sites
Using nil as the script handle just ensures the script is not defining any unnecesary global variables.

But when you use nil you're overwriting the value of nil.

nil is a predefined value that is use to dispose variables.

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

a = nil

After a = nil is a not set any more. When using format ["%1", a] it will refer to scalar bool array string 0xe0ffffef and a is undefined. But you assigned a script handle to nil, so a refers to <NULL-script> which is a defined variable. Take a look at nil in Biki or take a look in the ArmAEffects thread where the same problem is written with rain. After overwriting rain with some value you can't retrieve the current rain anymore.

Share this post


Link to post
Share on other sites

Point taken m8 but are you getting any <NULL-script> errors using these scripts.

My understanding and experience is (and I could be completely wrong) that scripts are not like variables and these scripts could in fact be run without giving them a script handle eg. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[_bee, _NORRN_pos, _name_player] execVM "revive_sqf\cam_follow.sqf"; and therefore they do not require a script handle at all (this is infact how many of the sub-scripts were called in the revive pre-xeno's changes).

By defining them as nil therefore no harm is done as long as we don't check to see if they are running (scriptDone) etc as they do not have a unique global script handle to access, which is the case here.

I personally haven't ever seen anything like a <NULL-script> error occurring in using these scripts nor have I had reports of it occurring. I'm sorry but I'm a bit of the opinion if it ain't broke why fix it - there's always plenty of other stuff to fix anyway. smile_o.gif

But please if you are getting <NULL-script> errors can you post pictures of where they are occurring so I can track down the offending scripts and implement a fix.

Share this post


Link to post
Share on other sites

Ok, the following code is a bit construct, but hopefully it shows the problem to you.

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

if (isNil "Firework_Script") then {

Firework_Script = [] execVM "Firework.sqf";

waitUntil {scriptdone Firework_Script};

Firework_Script = nil;

};

};

while {true} do {

if (random 100 <= 1) then {

[] spawn Code;

};

sleep 0.01;

};

The following code is random starting the "Firework.sqf" but only once a time (In the demo there will be only one flare in the air at the same time). This code works fine and don't need to have Firework_Script init first.

After the init of your revivescript (you have to uncomment it in init.sqf) the firework-script will only run one time. There will not be a constant flow of flares.

Demo: niltest.Intro.rar

What does the demo:

It will constantly spawns flares over the player. There will be only one flare at time and a little time between the flares. After overwriting nil with some value only one flare will show up and no others follows.

Share this post


Link to post
Share on other sites

M8 the link is not working for me, can you please send it to norrin@iprimus.com.au and I'll check it out.

EDIT:  I've just made my own mission using your code and why don't you do something like this instead as a work around:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Firework_Script = [] execVM "Firework.sqf";

Code = {

if (scriptdone Firework_Script) then {

Firework_Script = [] execVM "Firework.sqf";

waitUntil {scriptdone Firework_Script};

//Firework_Script = nil;

};

};

while {true} do {

if (random 100 <= 1) then {

[] spawn Code;

};

sleep 0.01;

};

As any script (not just the revive scripts) that you may use that defines a variable as nil will stop the processing of your example 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  

×