Jump to content

Melmarkian

Member
  • Content Count

    123
  • Joined

  • Last visited

  • Medals

Posts posted by Melmarkian


  1. 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.


  2. 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)


  3. Hi,

    I have a little script I used to simulate such undercoveractions:

    It does:

    - set you to captive

    - removes captive as long as you carry a primaryweapon

    - If you shoot inside the radius it removes setcaptive and sends the nearest unit looking for the position where shoot was fired.

    - removes captive when you stay a certain time near an enemy

    - It will reset you to captive when:

    - Your distance to the nearestunit of side is greater then _getaway

    - The knowsabout of the nearestunit of side is lesser than 1.4

    You call it with:

    nul = [playername,

    radius(distance the script searches for units),

    getaway (distance for a reset when you are found),

    side ( which side is considered enemy)

    ] execvm "under.sqf";

    undercover = true;

    _bomber = _this select 0;

    _radius = _this select 1;

    _getaway = _this select 2;

    _side = _this select 3;

    _bomber addEventHandler ["Fired", {shooting = true;}];

    sleep 1;

    while {(alive _bomber) AND undercover} do {

    shooting = false;

    _bomber setCaptive true;

    gotya = false;

    sleep 2;

    while {primaryWeapon _bomber != ""} do {

    _bomber setCaptive false;

    hintSilent "You carry a weapon!";

    sleep 3;

    };

    _nearestunits = nearestObjects [_bomber,["Man","Car","Tank"],_radius];

    _nearestunitofside = [];

    if(_side countSide _nearestunits > 0) then{

    {

    _unit = _x;

    if(side _unit == _side) then{_nearestunitofside = _nearestunitofside + [_unit]};

    } foreach _nearestunits;

    if (shooting AND (count _nearestunitofside != 0) AND ((_nearestunitofside select 0) distance _bomber < _getaway - 50) ) then {

    gotya = true;

    hint "Someone must have heard the shot";

    sleep 4;

    _bomber setCaptive false;

    (_nearestunitofside select 0) domove position _bomber;

    };

    if((_nearestunitofside select 0) distance _bomber < 20) then {

    sleep 4;

    if((_nearestunitofside select 0) distance _bomber < 20 ) then {

    _random = floor(random 3);

    _alertmessage = ["Watch Out!", "Keep Distance!", "Someone´s watching us", "They notice you!"] select _random;

    call compile format ["hint '%1';", _alertmessage];

    sleep 8;

    if((_nearestunitofside select 0) distance _bomber < 14 ) then {

    gotya = true;

    _bomber setCaptive false;

    hint "THEY HAVE FOUND YOU";

    sleep 4;

    (_nearestunitofside select 0) glanceAt _bomber;

    (_nearestunitofside select 0) reveal _bomber;

    sleep 7;

    };

    };

    };

    };

    while {gotya} do {

    _nearestunits = nearestObjects [_bomber,["Man","Car","Tank"],_radius];

    _nearestunitofside = [];

    if(_side countSide _nearestunits > 0) then{

    {

    _unit = _x;

    if(side _unit == _side) then{_nearestunitofside = _nearestunitofside + [_unit]};

    } foreach _nearestunits;

    hintSilent "Get Away";

    sleep 4;

    //Hint Format ["closest unit is %1",_nearestunitofside select 0];

    if(((_nearestunitofside select 0) distance _bomber > _getaway) OR ((_nearestunitofside select 0) knowsAbout _bomber < 1.4) OR (count _nearestunitofside == 0)) then { hint "You should be safe now"; gotya = false; shooting = false; };

    };

    };

    }; // While alive and undercover

    And I also made an script you can execute for units in your group to give them the same status:

    I use it in the initfield of the unit with: nul = [unitname] execVM "undercoverbuddy.sqf";

    private ["_member"];

    _member = _this select 0;

    waitUntil {undercover};

    while {undercover} do {

    _member setCaptive true;

    removeAllWeapons _member;

    _member disableAI "AUTOTARGET";

    _member disableAI "TARGET";

    _member setBehaviour "CARELESS";

    waitUntil {shooting OR gotya};

    _member enableAI "AUTOTARGET";

    _member enableAI "TARGET";

    _member setBehaviour "AWARE";

    _member setCaptive false;

    _member addMagazine "8Rnd_9x18_Makarov";

    _member addMagazine "8Rnd_9x18_Makarov";

    _member addMagazine "8Rnd_9x18_Makarov";

    _member addMagazine "8Rnd_9x18_Makarov";

    _member addMagazine "8Rnd_9x18_Makarov";

    _member addWeapon "Makarov";

    waitUntil {!gotya};

    };

    _member enableAI "AUTOTARGET";

    _member enableAI "TARGET";

    _member setBehaviour "AWARE";

    _member setCaptive false;

    _member addMagazine "8Rnd_9x18_Makarov";

    _member addMagazine "8Rnd_9x18_Makarov";

    _member addMagazine "8Rnd_9x18_Makarov";

    _member addMagazine "8Rnd_9x18_Makarov";

    _member addMagazine "8Rnd_9x18_Makarov";

    _member addWeapon "Makarov";

    Maybe some of this helps you. I tested the script with respawn, but I didn´t find a quick solution.


  4. 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.


  5. Here is an example:

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

    The squad GroupOne you see on the airfield has the commands in the init-field. When you preview the mission you will notice they start all inside the truck (trooptruck).

    You can use the radiotrigger alpha (0 - 0 - 1) to let them disembark. But you could set the trigger to any condition you wish.

    I hope you have A2 because its on utes. Let me know if you want a different island.

    The commands are explained in the spoiler:

    groupOne = group this;

    // I use this to define a group, in this case groupOne.

    {_x assignAsCargo trooptruck} foreach units groupOne;

    // trooptruck is the name of the vehicle and groupOne is the name of the group to enter

    {_x moveInCargo trooptruck} foreach units groupOne;

    // same as above


  6. Hi,

    what I use for squads starting in cars is this:

    in the leaders init field:

    {_x assignAsCargo nameofthevehicle} foreach units group nameofunit;

    {_x moveinCargo nameofthevehicle} foreach units group nameofunit;

    To get them out I use a trigger (for example Opfor detected by bluefor)

    {unassignVehicle _x} foreach units group nameofunit;

    and additionally this to get them in the fight:

    groupname setBehaviour "Combat";

    groupname setCombatMode "red";

    hope this helps!


  7. Lol, ok I finally made it. I rebuild the complete system and it works now. But don´t ask me what I did wrong.

    So if someone wants to do it and is stuck like me:

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

    This is a testcampaign with 3 missions where you can see how the savestatus/loadstatus is done.

    PBO and Files included.

    What is also discoverd in the process is the exit.sqf. Everything you write in there will be executed at the end of the mission. Seems to be a good place for weaponpool and status modifications.

    Another discovery (maybe just for me):

    To read the objects.sav file you can use the unRap Tool by Kegetys. It will convert the file into an .cpp which is readable

    • Like 1

  8. Hi,

    ok so I have a problem with saving of chars in a campaign. I tried this:

    At the last trigger (with "END1"), I execute a script called "ende.sqf" with

    unitname savestatus "unitname1";

    In the init.sqf of the next mission I use:

    unitname loadstatus "unitname1";

    And then again at the end of the mission:

    unitname savestatus "unitname2" (Because I read somewhere you always have to give a new name)

    But my men always start with the standard loadout of their soldier class. I experimented a bit and to my surprise, they carried over their wounds in the next mission? This is what really confuses me.

    Could there be a problem with units of the same name used in the intro of the mission? I also tried to open the objects.sav to see whats saved, but I haven´t had any luck with opening the file.

    ---------- Post added at 06:26 PM ---------- Previous post was at 05:09 PM ----------

    Ok, tested two more things:

    Different name for units in intro and mission => no effect.

    Executed the script with a hint before the mission ends => no effect.

    I tried to load the status saved in mission 1 in the 3rd mission. => isn´t working either (backpack goes missing, too)

    tested with .sqs => no effect

    tested with player instead of charname => no effect

    Different names of units between the mission are not a problem, either. (worked between 1 & 2)

    The status save works from my first to the second mission. But not afterwards.

    I actually use a sqs file in the first mission, but that cannot make a difference?

    The wounding i reported earlier was also between 1 and 2 mission. One more thing: When I load the third mission the playerchar resets to standard loadout but also loses his backpack!

    I am confused...

    Edit3:

    I even made an testcampaign now and it works without problems...

    But not in the other one!


  9. Almost ready. Last mission is being worked on at the moment.

    I finally managed to get the campaignstructure to work and integrate a weaponpool together with saved equip for the soldiers.

    The campaign will be 8 missions long with a lot of cutscenes.

    So, any suggestions or feedback for the first part?


  10. Hi,

    I recently wrote a revive script for the AI in the playerteam. The script stores things like unitname, identity and lives and then waits until the unit is !alive.

    Now to my question:

    I read somewhere about the preprocessor command and functions for arma2. The text said that if I use a script more than once it should be made into a function. Is there really a big difference between the functions and a simple script call? I noticed for example that UPSMON uses a the normal execVM method and I´m sure there are a lot of repeating scripts in there.

    Does someone has any better insight into this or experience with this? Or some lecture about the matter?

    I know this one, but its not really helping me.

    http://community.bistudio.com/wiki/Code_Optimisation


  11. This is how I would do it. Don´t know if it is good way but it works:

    It just chooses the tasks that are not set to true. In your .sqf which include the mission you can set the variable to true. It will then begin to search for a new one.

    if (! isServer) exitwith {}; // NOTE: in multiplayer, only server should create random numbers.
    
    taskscompletedcount = 0; 
    firsttask = false;
    secondtask = false;
    thirdtask = false;
    fourthtask = false;
    
    
    // Pick Location ///////////////////////////////////////////////////////////////////////
    while {taskscompletedcount < 4} do {
    
    n1 = round ((random 13) + 0.5); // generates random number from 1 to 1"
    
    if (n1 == 1 AND !firsttask) then
    {
    
       hint "Task 1 is now active";
       sleep 10;
       waitUntil {firsttask};
       hint "Task1 completed";
       taskscompletedcount = taskscompletedcount + 1;
    };
    
    if (n1 == 2 AND !secondtask) then
    {
    
       hint "Task 2 is now active";
       sleep 10;
       waitUntil {secondtask};
       hint "Task2 completed";
       taskscompletedcount = taskscompletedcount + 1;
    
    };
    
    if (n1 == 3 AND !thirdtask) then
    {
    
       hint "Task 3 is now active";
       sleep 10;
       waitUntil {thirdtask};
       hint "Task3 completed";
       taskscompletedcount = taskscompletedcount + 1;
    
    };
    
    if (n1 == 4 AND !fourthtask) then
    {
    
       hint "Task 4 is now active";
       sleep 10;
       waitUntil {fourthtask};
       hint "Task4 completed";
       taskscompletedcount = taskscompletedcount + 1;
    
    };
    
    
    };
    
    hint "All done";


  12. Just for the fun:

    The same mission but it shoots a cow which explodes when it reaches the target.

    AND you can shoot exploding cows with radio alpha. Just point at your target and trigger the radio.

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

    It takes a few seconds before the next cow is loaded. I wanted to slow the cow down a bit, but I really don´t understand how the velocity stuff works.


  13. Hi, don´t know what you really mean?

    When I want an explosion in an I use this script with an trigger:

    private ["_p1","_target","_shooter","_dispersion","_randomdisp"];
    
    _target = _this select 0;        // Where the explosion happens
    _dispersion = _this select 1;   // random area around the target for explosions
    
    
    _randomdisp = _dispersion *2;
    
    
    
    
    
    _p1 = [(getpos _target select 0) + _dispersion - random _randomdisp, (getpos _target select 1) + _dispersion - random _randomdisp, (getpos _target select 2) + 40 ];
    
    
    bomb = "ARTY_Sh_82_HE" createVehicle _p1;
    
    
    

    You can call it with: nul = [target, dispersion] execVM "howeveryounamethescript.sqf"

    How often you want it to explode depends on the trigger settings. You could set it with a timeout and repeat to get more than one explosion.


  14. The first mission runs with min 24 fps on my machine. But my pc is really new.

    But I did a quick cleaning of the mission and now it runs with 40 fps after a few seconds.

    Here´s the new version:

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

    I am now in the process of mission 5-7 and they are mostly finished. Just a few texts and errorchecks missing. After those are ready I will create a campaignfile with continued weaponpool.

    The campaign itself isn´t completed after this chapter with Team Fox. I have already 3 sidestorys/sequels on paper. The actual release of those will depend a bit on the feedback after the complete first campaign is finished.

×