Advertisement

Author Topic: Respawn AI Crew -How to  (Read 2420 times)

0 Members and 1 Guest are viewing this topic.

Respawn AI Crew -How to
« on: 28 Oct 2009, 23:31:53 »
Hi guys!
I did a search for AI Crew Respawn and wasn't really satisfied with what i found as it really didn't answer my questions.

so heres my situation, my WW2 historical realism unit and I have our own WW2 mod for Arma2, and i make alot of the mp missions, the situation goes like this I made a mission where we have an assorted number of tanks to choose from to attack a town that is protected by and reinforced by Russian tank support(t34/76,t34/85s, and Kv1s) through area triggers.

Now when I get killed and im commanding a tank with a crew, I die as well as the crew.

Problem is i respawn back at our base and i have no crew, so now i have to man the tank by myself which is np but its funner with crew.
(by the way we have a tiger tank with a crew of 5 like in real life ;) )

heres a coupe of ideas i had to remedy this:

 :scratch: Idea 1. when i die along with the crew, Ai respawn and join me, so with this idea i need a create unit command, and join player with name. i got the idea of how this works but have no idea how to do it. :dunno:

 :scratch: Idea 2. when i die with crew, as a player i can request crew, or AI  through trigger menu, and each time i press the button to request, I get one AI, and like the scenerio above AI crew would have to be created and join the player,(i seen this in arma1 eveolution blue) and with this im sure i will need class names which i do not have.
problem with this is im not the only player, nor the host of the mission, as we dont have our own server yet.

again i have no idea on how to do this

either idea would be great i think the first idea is more practical and probably alot more simpler.
all i know how to do is mp respawn, i have a script i found for vehicle respawn but this is something that my unit leader would like to see and im trying to make it happen, and like to learn how to do it.

any help, would be very much appreciated

Gunter
« Last Edit: 30 Oct 2009, 23:41:08 by Günter Severloh »
Grenadier-Regiment 187

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: AI Crew Respawn -How to
« Reply #1 on: 29 Oct 2009, 05:29:29 »
Create a marker called mrkDepot at the position you want AI to spawn at.
If there is more than one team than you need to change the script a little and create different markers for each team or change the spawn position to the position of the player which wouldn't make sense when you are in the field.

When a player gets into a tank, he will be able to use his radio to Request Crew Members if the crew count is less than 5. AI team members not on board don't count. Also, if you choose to disembark a crew member, you will be able to "cheat" and call in extra crew members up to maximum group size. Could probably be fixed by allowing command to be used only once per respawn.

Init Line of All Tanks:
this addEventHandler ["GetIn", {_fillcrew = [_this,5] execVM "fillcrew.sqf"}]; veh = [this, 30, 120, 0, FALSE, FALSE, 'this addEventHandler ["GetIn", {_fillcrew = [_this,5] execVM "fillcrew.sqf"}];'] execVM "vehicle.sqf";

fillcrew.sqf
Code: [Select]
private ["_handler", "_veh", "_seat", "_plyr", "_type", "_depot", "_group", "_slots", "_filled", "_trg", "_needed", "_wait", "_unit"];
_handler = _this select 0;
_veh = _handler select 0;
_seat = _handler select 1;
_plyr = _handler select 2;
if(!(isPlayer _plyr) || !((side _plyr) == west)) exitWith {};
_type = getText (configFile >> "CfgVehicles" >> (typeOf _veh) >> "crew");
_depot = getMarkerPos "mrkDepot";
_group = group _plyr;
_slots = _this select 1;
_filled = count(crew _veh);
if(_filled < _slots) then {
myVehNeedCrew = false;
_trg = createTrigger["EmptyDetector",getPos _veh];
_trg setTriggerArea[0,0,0,false];
_trg setTriggerActivation["JULIET","PRESENT",false];
_trg setTriggerStatements["this", "myVehNeedCrew = true;", ""];
_trg setTriggerText "Request Crew Members";
_needed = _slots - _filled;
_wait = time + 30;
while {_wait > time} do {
if(myVehNeedCrew) exitWith {
for "_x" from 1 to _needed do {
_unit = _group createUnit [_type, _depot, [], 0, "NONE"];
_unit setSkill (0.6 + random 0.4);
_unit setRank "CORPORAL";
_unit doMove _depot;
};
};
};
deleteVehicle _trg;
};

Couldn't test the code, so report any -showScriptErrors or RPT errors.

Also, the eventhandler will only persist if you use the default BIS vehicle respawn method.
If you are using a "respawn" method that deletes the old tank and creates a new one, you may need to re-initialize the eventhandler. I recommend Simple Vehicle Respawn by Tophe which has support for init lines.
« Last Edit: 29 Oct 2009, 20:51:41 by tcp »

Re: AI Crew Respawn -How to
« Reply #2 on: 29 Oct 2009, 08:53:49 »
Thanks for your reply, and help.

ok heres what i have done, started up armaedit, created a new sqf file, put the code in, saved the file put the sqf file into my mission folder and
went into arma2, in my mission, as i have an existing one that is all setup for respawns and such.

i created a marker as you said 
Code: [Select]
mrkDepot
Code: [Select]
this addEventHandler ["GetIn", {_fillcrew = [_this,5] execVM "fillcrew.sqf"}]; into 1 tank just to test it out.

 :D,I have been using that vehicle respawn script already.

so i put the code above into the tanks initalization line and the vehicle respawn code right after it.
looks like this:
Code: [Select]
this addEventHandler ["GetIn", {_fillcrew = [_this,5] execVM "fillcrew.sqf"}];veh = [this] execVM "vehicle.sqf"
well i have a crew of 5, so i went out into the field took on a few tanks had to bail out cuz the tank was disabled and then as i was bailing out a round came in hit the tank, tank blew up and then we ran, only to be gunned down by enemy inf, so i respawned, i seen the tank respawn, i have no crew obviously, and i got into the tank and now nothing, im lost, or i didn't do something right as i dont see the radio for which you were talking about. only thing that works is the vehicle respawn.

in my mission i start out as a squad i am a officer with 4 crew, and i choose whatever empty tank i want and go from there. when i die the tank respawns back at the same position i got it, and i respawn at a marker designated for infantry.

is there no easier way to have Ai just respawn and then join "name" being me and then id have my crew again?

or maybe i can put down a small building and it could be a trigger area wher i can request a number of crew, that could be an idea as well.

I mean i like your idea but it didn't work, i got no errors or anything, so I must have done something wrong.


thanks for the help.

Gunter
Grenadier-Regiment 187

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: AI Crew Respawn -How to
« Reply #3 on: 29 Oct 2009, 19:27:15 »
You aren't giving vehicle.sqf enough information. Not only do you need to put the addeventhandler in the init line. You also need to pass it to the respawn script. Like this:
this addEventHandler ["GetIn", {_fillcrew = [_this,5] execVM "fillcrew.sqf"}]; veh = [this, 30, 120, 0, FALSE, FALSE, 'this addEventHandler ["GetIn", {_fillcrew = [_this,5] execVM "fillcrew.sqf"}];'] execVM "vehicle.sqf";

Also, if you want to test it right away, tell your first crew not to board. Get in the tank by yourself. You should have the radio command display for 30 seconds. Request Crew Members and enough (4) additional crew should spawn at the Depot (not counting your disembarked crew).

Actually, now that I am testing I am finding a few scripting errors, so give me a chance to correct those as well.
« Last Edit: 29 Oct 2009, 19:39:46 by tcp »

Re: AI Crew Respawn -How to
« Reply #4 on: 29 Oct 2009, 19:59:49 »
Quote
You also need to pass it to the respawn script.
I see what your saying. i'm really new to scripting, all I know how to do is to take a code and put into armaedit and make the file and then put the codes into the init lines of whatever it will be in, i know how to make respawns but most of this stuff i dont really understand how it works.

If you give me codes and tell me where to put them then I will be able to get to work. Im not new to the editor, been in it since OFP but i never really got into respawns and such until i got hooked up with my unit, as the issue came up, that when you die in the mission that was it and we had to resart the server, long story short i went out to learn how to do it.

anyways for this stuff you kinda of have to be specifc about how to do it, and where to place them, or you will lose me, but so far i got what your saying. i'll let you figure out the script errors out as id be lost as to what to do. i appreciate what your doing and it really sounds like a great idea.

thanks alot
Grenadier-Regiment 187

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: AI Crew Respawn -How to
« Reply #5 on: 29 Oct 2009, 20:53:40 »
OK code is fixed and tested.

Re: AI Crew Respawn -How to
« Reply #6 on: 29 Oct 2009, 22:18:09 »
great
so just put this
Code: [Select]
this addEventHandler ["GetIn", {_fillcrew = [_this,5] execVM "fillcrew.sqf"}]; veh = [this, 30, 120, 0, FALSE, FALSE, 'this addEventHandler ["GetIn", {_fillcrew = [_this,5] execVM "fillcrew.sqf"}];'] execVM "vehicle.sqf";in the tanks init line, and it works?

how do i configure this code to make it work for multiple players that all want their own crews?
Grenadier-Regiment 187

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: AI Crew Respawn -How to
« Reply #7 on: 29 Oct 2009, 23:13:21 »
As long as every tank has it, it just checks that the player is on side West, so everyone should be able to use it in MP. The only issue might be with the radio trigger, its supposed to be local to the player so no one else should see the trigger, although if might need some tweaking if that's not the case.

Re: AI Crew Respawn -How to
« Reply #8 on: 29 Oct 2009, 23:33:20 »
am i missing something?
it still dont work, do i need a trigger or something to make this work.

i took your updated script remade a new sqf file in armaedit, saved it put it into my mission, added this code:
Code: [Select]
this addEventHandler ["GetIn", {_fillcrew = [_this,5] execVM "fillcrew.sqf"}]; veh = [this, 30, 120, 0, FALSE, FALSE, 'this addEventHandler ["GetIn", {_fillcrew = [_this,5] execVM "fillcrew.sqf"}];'] execVM "vehicle.sqf";to the tank init line and thats it.

I have a marker on the map for the AI called:
Code: [Select]
mrkDepot
i go out with my crew again i get killed my crew all die as do i, i respawn and i have no crew. i go to the tank that has the code just for testing atm, and im looking for a radio. is it in the action menu?, or is it on the map as in a radio trigger? type radio?

as of right now it dont work, like i siad you have to be specific to what is making it work for you, as im obviously missing something, or have dones something wrong.

what if as i mentioned before that maybe there could be a building that a player, which could be any player and request a crew, it could be a number you put in and then a createunit command goes and 5 crew show up, but the thing would be the crew would join you, it would be join "name" so every officer that starts out in the mission has a name and when you go up to the building, you request crew they appear and join you somehow. jsut an idea not sure if it would work but im still somewhat confused.

if you did a radio trigger it wont work as only the guy hosting the mission will see it.
so it has to be with the tank, you get into the tank radio comes up and u request the ncrew, and so on, i think thats the idea uyou got but im not sure.

thanks again for your help
« Last Edit: 29 Oct 2009, 23:41:43 by Günter Severloh »
Grenadier-Regiment 187

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: AI Crew Respawn -How to
« Reply #9 on: 30 Oct 2009, 20:13:40 »
Working Example Mission: http://www.filefront.com/14828615/crew.utes.pbo

Every squad leader can use radio. Command menu (0 - 0)

Radio trigger is supposed to be local so it shouldn't interfere with anything. I've tested on dedicated server.

However, I am converting it to an action to make it easier.

Here it is: http://www.filefront.com/14828891/crewAct.utes.pbo

This is what the init line for each tank looks like now:
this addAction ["Request Additional Crew", "fillcrew.sqf", 4, -7,     false, true, "", "((side _this) == west) && (_this in crew _target) && ((count(crew _target)) < 4)"]; veh = [this, 5, 120, 0, TRUE, FALSE, 'this addAction ["Request Additional Crew", "fillcrew.sqf", 4, -7,     false, true, "", "((side _this) == west) && (_this in crew _target) && ((count(crew _target)) < 4)"];'] execVM "vehicle.sqf";

You'll need to change 4 to crew size for that vehicle. Don't worry about -7, it's just the action's priority.

Also, the configs for a vehicle are supposed to specify the class name of crew that are supposed to man it. Since you are using a custom mod, I am not sure if that is the case. If so, you will have to supply the class name (_type string) to be used in the script.

Also, to avoid exploiting this command, I prevented spawning more crewman when you already have enough crewman to man two tanks (including yourself if you are crewman class). It will spawn the needed units the first time you exceed the limit, but won't allow further spawning until you get below the limit again.
« Last Edit: 30 Oct 2009, 21:24:38 by tcp »

Re: Respawn AI Crew -How to
« Reply #10 on: 30 Oct 2009, 22:21:23 »
Thanks very much for your reply and example, i got it to work and it works exactly as you say.
the action menu is the best option, i think when i first tried out the codes and scripts thats probably what i was looking for some radio addition. its perfect.

what i want to do is figure out how to change the class name for the type of crew, as the WW2 mod we have is custom made, all the tanks we have, have custom WW2 crew, we have German and Russian crew but we only play the axis side.

I found the addon that has the crew.
I extracted it and it has a config, can you look at this config and tell me which class i am supposed to use.

I'm assuming this is the class i want:
Code: [Select]
class rw_crew
{
displayName = "Axis Panzercrew";
};

here is the whole config for the crew addon:

Code: [Select]
#include "BasicDefines.hpp"
class CfgPatches {
class rw_crew   {
units[] = {"rw_crew"};
};
};

class CfgVehicleClasses
{
class rw_crew
{
displayName = "Axis Panzercrew";
};
        class rw_crewr
{
displayName = "russian tankcrew";
};

};

class CfgSkeletons
{

class Head
{
isDiscrete = 0;
skeletonInherit = "";
skeletonBones[] =
{
"neck","",
"neck1","neck",
"head","neck1",
"loboci","head",
"soboci","head",
"poboci","head",
"lkoutek","head",
"skoutek","head",
"pkoutek","head",
"vicka","head",
"spodni ret","head"
};
};
class OFP2_ManSkeleton
{
isDiscrete = 0;
skeletonInherit = "Head";
skeletonBones[] =
{
"Weapon","",
"launcher","",
"Camera","",
"Spine","",
"Spine1","",
"Spine2","",
"Spine3","",
"Pelvis","",
//Left upper side
"LeftShoulder","",
"LeftArm","",
"LeftArmRoll","",
"LeftForeArm","",
"LeftForeArmRoll","",
"LeftHand","",
"LeftHandRing","",
"LeftHandRing1","",
"LeftHandRing2","",
"LeftHandRing3","",
"LeftHandPinky1","",
"LeftHandPinky2","",
"LeftHandPinky3","",
"LeftHandMiddle1","",
"LeftHandMiddle2","",
"LeftHandMiddle3","",
"LeftHandIndex1","",
"LeftHandIndex2","",
"LeftHandIndex3","",
"LeftHandThumb1","",
"LeftHandThumb2","",
"LeftHandThumb3","",

//Right upper side
"RightShoulder","",
"RightArm","",
"RightArmRoll","",
"RightForeArm","",
"RightForeArmRoll","",
"RightHand","",
"RightHandRing","",
"RightHandRing1","",
"RightHandRing2","",
"RightHandRing3","",
"RightHandPinky1","",
"RightHandPinky2","",
"RightHandPinky3","",
"RightHandMiddle1","",
"RightHandMiddle2","",
"RightHandMiddle3","",
"RightHandIndex1","",
"RightHandIndex2","",
"RightHandIndex3","",
"RightHandThumb1","",
"RightHandThumb2","",
"RightHandThumb3","",
//Left lower side
"LeftUpLeg","",
"LeftUpLegRoll","",
"LeftLeg","",
"LeftLegRoll","",
"LeftFoot","",
"LeftToeBase","",
//Right lower side
"RightUpLeg","",
"RightUpLegRoll","",
"RightLeg","",
"RightLegRoll","",
"RightFoot","",
"RightToeBase",""
};
  };

class default;
class Flag: Default {};
class FlagCarrier: Default
{
skeletonInherit = "Default";
skeletonBones[] =
{
"stozar","",
"vlajka",""
};
};
};

class CfgModels
{
class Default
{
sections[] = {};
sectionsInherit="";
};

class flag_vojak : Default
{
sections[] = {"latka"};
};
class Head: Default
{
sections[] =
{
"osobnost","brejle"
};
skeletonName = "Head";
};
class ArmaMan : Default
{
sections[] =
{
"osobnost","Head_Injury","Body_Injury","l_leg_injury","l_arm_injury","r_arm_injury","r_leg_injury","clan"};
 skeletonName = "OFP2_ManSkeleton";
};

        class heer1 : ArmaMan
{
sectionsInherit = "ArmaMan";
sections[] =
{};
};

        class heer2 : ArmaMan
{
sectionsInherit = "ArmaMan";
sections[] =
{};
};

        class heeroff : ArmaMan
{
sectionsInherit = "ArmaMan";
sections[] =
{};
};

        class ss1 : ArmaMan
{
sectionsInherit = "ArmaMan";
sections[] =
{};
};

        class ss2 : ArmaMan
{
sectionsInherit = "ArmaMan";
sections[] =
{};
};

        class ssoff : ArmaMan
{
sectionsInherit = "ArmaMan";
sections[] =
{};
};

        class sovcrew : ArmaMan
{
sectionsInherit = "ArmaMan";
sections[] =
{};
};



};

class CfgVehicles {
/*extern*/ class Man;

class CAManBase: Man {
/*extern*/ class TalkTopics;

class HitPoints {
/*extern*/ class HitHead;
/*extern*/ class HitBody;
};
};
class SoldierEB: CAManBase {

class TalkTopics: TalkTopics {
};
};

class SoldierWB: CAManBase {

class TalkTopics: TalkTopics {
};
};

class SoldierGB: CAManBase {

class TalkTopics: TalkTopics {
};
};
/*extern*/ class NonStrategic;

        class rw_gcrew1 : SoldierWB
        {
vehicleClass = "rw_crew";
                side = "1";
                faceType = "Man";
                genericNames = "EnglishMen";
                portrait = "\Ca\characters\data\portraits\comBarHead_usmc_soldier_ca";
picture = "\Ca\characters\data\Ico\i_null_CA.paa";
icon = "\Ca\characters2\data\icon\i_soldier_CA.paa";
                cost = 80000;
camouflage = 1.800000;
accuracy = 2.000000;
displayName = "Heer Crew (fieldcap)";
model = "\rwcrew\heer1.p3d";
scope = public;
weapons[] = {"rw_mp401","rw_p38","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch"};
magazines[] = {"rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_HandGnaz","rw_HandGnaz"};
respawnWeapons[] = {"rw_mp401","rw_p38","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch"};
respawnMagazines[] = {"rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_HandGnaz","rw_HandGnaz"};
                hiddenSelections[] = {};

class HitPoints: HitPoints {

class HitHead: HitHead {
armor = 0.850000;
};

class HitBody: HitBody {
armor = 1;
passThrough = 0.800000;
};
};

       class Wounds {
tex[] = {};
  mat[] = {"rwcrew\data\heer_body.rvmat", "rwcrew\data\soldier_captive_body_wound1.rvmat", "rwcrew\data\soldier_captive_body_wound2.rvmat", "rwcrew\data\soldier_captive_hhl.rvmat",
                                 "rwcrew\data\soldier_captive_hhl_wound1.rvmat", "rwcrew\data\soldier_captive_hhl_wound2.rvmat","rwcrew\data\us_rukavy_hhl.rvmat","rwcrew\data\us_rukavy_hhl_wound1.rvmat", "rwcrew\data\us_rukavy_hhl_wound2.rvmat",
                                 "rwcrew\data\emp_body.rvmat", "rwcrew\data\soldier_captive_body_wound1.rvmat", "rwcrew\data\soldier_captive_body_wound2.rvmat",};

};
               class TalkTopics: TalkTopics
                {
                core_en = "Core_Full";
};
languages[] = {"EN"};


         };

         class rw_gcrew2: rw_gcrew1
         {
accuracy = 3.900000;
displayName = "Heer Crew (cap)";
model = "\rwcrew\heer2.p3d";
weapons[] = {"rw_mp401","rw_p38","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch"};
magazines[] = {"rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_HandGnaz","rw_HandGnaz"};
respawnWeapons[] = {"rw_mp401","rw_p38","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch"};
respawnMagazines[] = {"rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_HandGnaz","rw_HandGnaz"};
                hiddenSelections[] = {};
};

        class rw_gcrew3: rw_gcrew1
         {
accuracy = 3.900000;
displayName = "Heer Crew Officer";
model = "\rwcrew\heeroff.p3d";
weapons[] = {"rw_p38","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch", "Binocular"};
magazines[] = {"rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_HandGnaz","rw_HandGnaz"};
respawnWeapons[] = {"rw_p38","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch"};
respawnMagazines[] = {"rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_HandGnaz","rw_HandGnaz"};
                hiddenSelections[] = {};
};

         class rw_gcrew4: rw_gcrew1
         {
accuracy = 3.900000;
displayName = "SS Crew (fieldcap)";
model = "\rwcrew\ss2.p3d";
weapons[] = {"rw_mp401","rw_p38","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch"};
magazines[] = {"rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_HandGnaz","rw_HandGnaz"};
respawnWeapons[] = {"rw_mp401","rw_p38","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch"};
respawnMagazines[] = {"rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_HandGnaz","rw_HandGnaz"};
                hiddenSelections[] = {};
};

        class rw_gcrew5: rw_gcrew1
        {
accuracy = 3.900000;
displayName = "SS Crew (cap)";
model = "\rwcrew\ss2.p3d";
weapons[] = {"rw_mp401","rw_p38","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch"};
magazines[] = {"rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_HandGnaz","rw_HandGnaz"};
respawnWeapons[] = {"rw_mp401","rw_p38","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch"};
respawnMagazines[] = {"rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_32Rnd_mp","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_HandGnaz","rw_HandGnaz"};
                hiddenSelections[] = {};
};

         class rw_gcrew6: rw_gcrew1
         {
accuracy = 3.900000;
displayName = "SS Crew Officer";
model = "\rwcrew\ssoff.p3d";
weapons[] = {"rw_p38","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch", "Binocular"};
magazines[] = {"rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_HandGnaz","rw_HandGnaz"};
respawnWeapons[] = {"rw_p38","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch"};
respawnMagazines[] = {"rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_8Rnd_p38","rw_HandGnaz","rw_HandGnaz"};
                hiddenSelections[] = {};
};

        class rw_sovcrew1 : SoldierEB
        {
vehicleClass = "rw_crewr";
                scope = 2;
                side = "0";
                faceType = "Man";
                genericNames = "RussianMen";
                identityTypes[] = {"Head_RU", "RU_Glasses"};
                portrait = "\Ca\characters\data\portraits\comBarHead_ru_soldier_ca";
picture = "\Ca\characters\data\Ico\i_null_CA.paa";
icon = "\Ca\characters2\data\icon\i_soldier_CA.paa";
                cost = 80000;
camouflage = 1.800000;
accuracy = 2.000000;
displayName = "Tank Crew";
model = "\rwcrew\sovcrew.p3d";
weapons[] = {"rw_PPS43","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch", "Binocular"};
magazines[] = {"rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_HandGF1","rw_HandGF1"};
respawnWeapons[] = {"rw_PPS43","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch"};
respawnMagazines[] = {"rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_HandGF1","rw_HandGF1"};
                hiddenSelections[] = {};

class HitPoints: HitPoints {

class HitHead: HitHead {
armor = 0.850000;
};

class HitBody: HitBody {
armor = 1;
passThrough = 0.800000;
};
};

       class Wounds {
tex[] = {};
  mat[] = {"rwcrew\data\redarmy_body.rvmat", "rwcrew\data\soldier_captive_body_wound1.rvmat", "rwcrew\data\soldier_captive_body_wound2.rvmat", "rwcrew\data\soldier_captive_hhl.rvmat","rwcrew\data\soldier_captive_hhl_wound1.rvmat", "rwcrew\data\soldier_captive_hhl_wound2.rvmat",
                                 "rwcrew\data\us_rukavy_hhl.rvmat","rwcrew\data\us_rukavy_hhl_wound1.rvmat", "rwcrew\data\us_rukavy_hhl_wound2.rvmat"};

};
               class TalkTopics: TalkTopics
                {
                core_ru = "Core_Full";
};
core_ru = "Core_Full";


        };
        class rw_sovcrew2: rw_sovcrew1
        {
accuracy = 3.900000;
displayName = "Tank Crew1";
model = "\rwcrew\sovcrew.p3d";
weapons[] = {"rw_PPS43","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch"};
magazines[] = {"rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_HandGF1","rw_HandGF1"};
respawnWeapons[] = {"rw_PPS43","rw_Throw","Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch"};
respawnMagazines[] = {"rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_35Rnd_mp","rw_HandGF1","rw_HandGF1"};
                hiddenSelections[] = {};
};


      
};

Once we figure out the class for the axis crew, how do you integrate it into the SQF, and then
what would the new code look like after the class i want is in the code that i put into the tank's init line?
==========================================================================
Edit:

Wait a minute on what i said above about the class.

I just did a test, i went into the editor, loaded up the latest mission with the request additonal crew in the action menu.

i put down a tiger tank which has 5 positions
commander,driver, gunner, radio operator, and loader.

i got into the tank as a normal modern day crewman and requested crew, i pop out of the cupola and look to my right which is where the depot is where the crew will spawn, and i see the axis crew spawn. so somehowthe code that we put into the tank's initalization line it works in conjunction with the addon that being the tiger tank. thats odd but it works.

so by default when i request a crew i get 3 crewman for ever request, so in the code to put into the tank i just change   

"fillcrew.sqf", 4,  <---that number 4 to a 5 to get 4 crew correct?
========================================================
Edit:

ok i changed the 4 to a 5 and i respawned 5 crew this time.

the great thing about this script and code is it isn't limited to just MP, it works in SP as well, and not only for just WW2 , but works with any tank!

heres some pic of my crewed tank:

i get in the tank and the request crew action shows up only if my tank is not fully crewed
http://img407.imageshack.us/img407/2760/gd004.jpg

heres the tank crewed after i requested it, they respawn at the depot
and you just tell them to mount
http://img142.imageshack.us/img142/3170/gd005.jpg

tank fully crewed
http://img689.imageshack.us/img689/7259/gd003.jpg

tank fully crewed 2
http://img407.imageshack.us/img407/2231/gd002.jpg

Here is a vid i just put together to demostrate this great script
http://www.youtube.com/watch?v=L6fq2dgbKks

Thank you to TCP for all his help and effort for makign the script, and testing it, very much appreciate it!

Gunter
« Last Edit: 31 Oct 2009, 02:38:41 by Günter Severloh »
Grenadier-Regiment 187

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Respawn AI Crew -How to
« Reply #11 on: 31 Oct 2009, 03:22:47 »
Pretty cool screens.

Yea, it actually looks under the tank's config to find the crew class name "rw_crew".

One small change, to make it work for both sides.

Make sure you keep the check for player side specific to each tank. The script is not meant to work for stolen tanks (wrong class would be spawned). Note that there are four instances of #seats (5) within an init line when using the vehicle respawn script. Depot markers are set as "mrkDepotR" and "mrkDepot".

East:
this addAction ["Request Additional Crew", "fillcrew.sqf", [5,"mrkDepotR"], -7,     false, true, "", "((side _this) == east) && (_this in crew _target) && ((count(crew _target)) < 5)"]; veh = [this, 10, 120, 0, TRUE, FALSE, 'this addAction ["Request Additional Crew", "fillcrew.sqf", [5,"mrkDepotR"], -7,     false, true, "", "((side _this) == east) && (_this in crew _target) && ((count(crew _target)) < 5)"];'] execVM "vehicle.sqf";

West:
this addAction ["Request Additional Crew", "fillcrew.sqf", [5,"mrkDepot"], -7,     false, true, "", "((side _this) == west) && (_this in crew _target) && ((count(crew _target)) < 5)"]; veh = [this, 10, 120, 0, TRUE, FALSE, 'this addAction ["Request Additional Crew", "fillcrew.sqf", [5,"mrkDepot"], -7,     false, true, "", "((side _this) == west) && (_this in crew _target) && ((count(crew _target)) < 5)"];'] execVM "vehicle.sqf";

Code: [Select]
private ["_veh", "_plyr", "_type", "_depot", "_group", "_slots", "_filled", "_needed", "_unit"];
_veh = _this select 0;
_plyr = _this select 1;
_exvar = _this select 3;
_slots = _exvar select 0;
_depot = getMarkerPos (_exvar select 1);
_type = getText (configFile >> "CfgVehicles" >> (typeOf _veh) >> "crew");
if((_type countType units group _plyr) >= (_slots * 2)) exitWith {_plyr groupChat "Crew limit exceeded.";};
_group = group _plyr;
_filled = count(crew _veh);
_needed = _slots - _filled;
_nom = getText (configFile >> "CfgVehicles" >> _type >> "displayName");
_plyr groupChat (str _needed + " " + _nom + " At Depot.");
for "_x" from 1 to _needed do {
_unit = _group createUnit [_type, _depot, [], 0, "NONE"];
_unit setSkill (0.6 + random 0.4);
_unit setRank "CORPORAL";
_unit doMove _depot;
};

Re: Respawn AI Crew -How to
« Reply #12 on: 31 Oct 2009, 04:15:35 »
ok,
tested it out, heres what i did.

made a new SQF with your latest code,
saved it as fillcrew.sqf put it in my missions folder
then i took the codes for the east which would be the russian codes, and put them into a T34 tank.

i added a mrkDepotR depot marker.

problem.
i get into the tank, request additional crew, shows up in action menu, i click it and then i get an error says:

Code: [Select]
script fillcrew.sqf not found
checked to see if the fillcrew file is in the missions folder, it is.
checked the spelling of it, it is spelled:    fillcrew.sqf
checked to see if i have the markers      i do
checked the codes to put into tanks init line    i do.

is there something missing in the script that makes it ask for the fillcrew.sqf?
Grenadier-Regiment 187

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Respawn AI Crew -How to
« Reply #13 on: 31 Oct 2009, 04:51:53 »
What does Windows Explorer list the file as under Type heading. If you don't have Show Extensions for known file types, Windows could be showing fillcrew.sqf.txt as fillcrew.sqf

It's a common mistake. I think that's what it must be, because I started with a fresh mission and just copied and pasted from above and it works. http://www.filefront.com/14831113/crewTT.utes.pbo

Make player BLUFOR to test for other side.
« Last Edit: 31 Oct 2009, 04:58:17 by tcp »

Re: Respawn AI Crew -How to
« Reply #14 on: 31 Oct 2009, 05:33:47 »
ok i checked out your mission, and its works great.

what i noticed is that the german tanks have a crew of 5,
russian tanks on the other hand have a crew of 4 but works overall!

another idea
i was wondering and this is just an idea, i got the config to the panzer crews above,and i can get the configs for the tanks themselves, i was thinking how could we make this feature apart of a tank, no outside scripts to put into folders like we are doing but part of the config for each tank.

i still would have to make a respawn script for inf and one for vehicle respawn np, but if we could make it a feature, a permanent feature of the tank itself.

I was thinking that i know a marker would be needed to spawn the AI crew, but what if somehow the tank created a marker or somehow just used a createunit command and the tank would fill with crew.

the thing to keep in mind though we could use a function or handler that checks how many spots are in the tank and then adds crew accordingly, and then obviously we'd keep the action menu command.

What you think TCP.
Grenadier-Regiment 187