Jump to content
Sign in to follow this  
Melmarkian

Own AI-Revivescript stops working?

Recommended Posts

Hi,

I got a little script for my campaign called "reviveAI.sqf". It gives the AI units a revive. It waits until they are dead and replaces them with the same kind of unit, the loadout when they died and reloads the identity.

And I tested it and it always worked.

But! When I place it in certain missions, it magically stops working. I get a error in the rpt:

Error in expression <<NULL-object>>
 Error position: <<NULL-object>>
 Error Invalid number in expression
Error in expression <<NULL-object>>
 Error position: <<NULL-object>>
 Error Invalid number in expression
Error in expression <<null>>
 Error position: <<null>>
 Error Invalid number in expression
Error in expression <<null>>
 Error position: <<null>>
 Error Invalid number in expression

Without any clearer statements as normal.

Here are two missions:

http://www.mediafire.com/?qfnkj1unl1dt0l6

This one always works, even if the units get killed every second.

http://www.mediafire.com/?02rid8535sx0mj3

This one gives the error after the first or second kill with null-object. (I rearranged it so they start to shoot in the first few seconds).

Please ignore the ACE-testmessage at the start. I implemented a new upsmon-version to see if it caused the error.

The strange thing about it is I really cannot see any difference. And I tried a lot of things to break it in the first mission.

I tested with:

- Modules (First Aid)

- UPSMON

- With player in group and without

- named group / group without name

- medic in group

- healing during kill

Would be nice if someone could have a look at it. And sorry, the script is a bit messy.

Share this post


Link to post
Share on other sites

i know that norrins revive did not work "before" along with murklors "save AI in trigger" script, dont know if thats been fixed in later releases.

Maybe its similar to what you use..

Share this post


Link to post
Share on other sites

Some error could be in the line:

deleteVehicle _unit;  
call compile format ["_type createUnit [(getMarkerPos 'dead_%1'), _group, 'this setVehicleVarName ''%1'';%1 = this;']", _unit];

it deletes the unit and after that creates a new one with the same name. Maybe I have to save the unitvarname before the !alive unit fires and use this variable in the createunit.

If I do this:

_name = call compile format ["%1", _unit];

Would the variablename saved? Even if I delete _unit afterwards? I think yes.

And this could be working afterwards( using the generated string instead of the unit-object):

call compile format ["_type createUnit [(getMarkerPos 'dead_%1'), _group, 'this setVehicleVarName %1;%1 = this;']", _name];

(Sorry I cannot test it at the moment. I just try to understand the issue)

Share this post


Link to post
Share on other sites
An AI compatible revive would be brilliant!

Norrins revive 0.50 does that, and i saw on armaholic a short while ago about a new AI reveive, and drag script as well.

Share this post


Link to post
Share on other sites

I've not found norrin's AI working on AI disabled missions. I have spoken to norrin about this. The problem is that in disabledAI missions the AI are not treated as potential revivers (even though it IS setup correctly).

A revive script that does do this (although DAPman's is coming close!) would be great.

Share this post


Link to post
Share on other sites

Ok, redone it and it works now. There was a problem with values of variables set to null before used.

This one works:

nul = [unitname, lives, "identity"] execVM "reviver.sqf"

reviver.sqf

// nul = [unit, lives, identity] execVM "reviver.sqf";

//

// Simple respawn for AI units which activates the First Aid system on them and let them keep their current gear. They start in agony state after the respawn.

// If you uncomment the hintC lines you will get infos as the script processes

private ["_reviveunhide", "_revivenewsetup","_reviveweaponstring", "_revivecreate", "_revivestring", "_revivepos", "_reviveunit","_revivelives","_reviveidentity","_revivename","_revivetype","_revivegroup","_reviveweapons","_revivemags"];

_reviveunit = _this select 0; // should be clear, but unit must be named for the script to work

_revivelives = _this select 1; // how often the respawn works

_reviveidentity = _this select 2; // setIdentity value, use "" if you don´t want to use it

_revivename = call compile format ["%1", _reviveunit];

_revivetype = typeOf _reviveunit;

_revivegroup = group _reviveunit;

_reviveweapons = weapons _reviveunit;

_revivemags = magazines _reviveunit;

sleep 0.1;

//hintC format ["Unit: %1 Lives: %2 Identity: %3 Nameasstring: %4 Type: %5 Group: %6 Weapons: %7 Magazines: %8", _reviveunit, _revivelives, _reviveidentity, _revivename, _revivetype, _revivegroup, _reviveweapons, _revivemags];

revivelogicgroup = createCenter sideLogic;

revivegrouplogic = createGroup revivelogicgroup;

waituntil {!alive _reviveunit};

_reviveweapons = weapons _reviveunit;

_revivemags = magazines _reviveunit;

_revivepos = getPosATL _reviveunit;

_revivename = format ["%1", _reviveunit];

_revivestring = format ["'%1' createUnit [%2 , _revivegroup, '%3 = this; this setVehicleVarName ""%3""; this setIdentity ""%4""', 0.6, 'LIEUTENANT']; hideobject %3", _revivetype, _revivepos, _reviveunit, _reviveidentity];

_reviveweaponstring = format ["%1 setdamage 0.8; ; removeAllWeapons %1; {%1 removeMagazine _x} foreach magazines %1; removeAllItems %1; {%1 addMagazine _x} forEach _revivemags; {%1 addWeapon _x} forEach _reviveweapons; %1 selectWeapon (primaryWeapon _name); nul = [%1, _revivelives, _reviveidentity] execVM 'reviver.sqf'", _reviveunit];

_reviveunhide = format ["%1 setUnconscious true;%1 hideobject false", _reviveunit];

_revivemodulestring = format ["ais1_%1%2 = revivegrouplogic createUnit ['FirstAidSystem', position %1,[],0,'NONE']; ais2_%1%2 = revivegrouplogic createUnit

['BattleFieldClearance', position %1,[],0,'NONE']; ais3_%1%2 = revivegrouplogic createUnit ['AlternativeInjurySimulation', position %1,[],0,'NONE']; ais1_%1%2

synchronizeObjectsAdd [%1]; ais2_%1%2 synchronizeObjectsAdd [%1]; ais3_%1%2 synchronizeObjectsAdd [%1]; ", _reviveunit, _revivelives];

//copyToClipboard _revivestring;

//hintc _revivestring;

sleep 0.2;

//hintC format ["Unit: %1 Lives: %2 Identity: %3 Nameasstring: %4 Type: %5 Group: %6 Weapons: %7 Magazines: %8", _reviveunit, _revivelives, _reviveidentity, _revivename, _revivetype, _revivegroup, _reviveweapons, _revivemags];

_revivelives = _revivelives - 1;

hideBody _reviveunit;

sleep 2;

deleteVehicle _reviveunit;

sleep 1;

//hintC format ["Unit: %1 Lives: %2 Identity: %3 Nameasstring: %4 Type: %5 Group: %6 Weapons: %7 Magazines: %8", _reviveunit, _revivelives, _reviveidentity, _revivename, _revivetype, _revivegroup, _reviveweapons, _revivemags];

_revivecreate = compile _revivestring;

call _revivecreate;

sleep 0.2;

_revivenewsetup = compile _reviveweaponstring;

call _revivenewsetup;

call compile _revivemodulestring;

sleep 1.6;

call compile _reviveunhide;

//hintC format ["Unit: %1 Lives: %2 Identity: %3 Nameasstring: %4 Type: %5 Group: %6 Weapons: %7 Magazines: %8", _reviveunit, _revivelives, _reviveidentity, _revivename, _revivetype, _revivegroup, _reviveweapons, _revivemags];

And sorry Kremator. I think you misunderstood what I was trying to do. I did this script to give my AI buddys a second chance. I have a few missions where you fail when they die and I hated this in the original Harvest Red campaign, because they are sometimes running directly into enemy fire (like myself :)). But for story reasons I wanted to have the same condition, so I wrote this piece of code to make it less annoying.

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  

×