Jump to content
Sign in to follow this  
stuguy

my vehicle unassignment script breaks future vehicle assignment interations

Recommended Posts

I am using the addaction menu to add quick on the fly troop management and vehicle assignment scripts.  I have the troop management down solid.  Units can come in and out of my group, and in and out of my high command module with the flick of the mouse wheel.  However, the same cannot be said completely about assigning the vehicles.  I got the assign part down, though I currently am not assigning drivers (yet).  The problem is that when I choose to unassign one of my highcommand subordinates from their vehicle with my script, that vehicle is no longer eligible for reassignment or unassignment.  My addaction for that car/tank/truck is just gone.  Reactivating the script doesn't work.  I can, however, reassign the group to another vehicle, however, if I unassign them, the same happens once again, vehicle is no longer eligible for reassignment.  Just a note here, these groups were added under player with the "player hcSetGroup [group];".  I do have a synced HCcommand module to my player, and a synced subordinate command module to the hc module on the map.

 

addhcvehicle = { 
 player addaction ["Assign to Squad 1", {mygrp1 addVehicle cursorTarget},nil,1,false,true,"",format ['(!(isnull cursortarget) && (alive cursortarget) && ({ alive _x } count units mygrp1 > 0) && ((side cursorTarget) == side player) && (locked cursortarget < 2) && !(cursorTarget isKindof "Man"))'],15,false]; 
}; 
null = []spawn addhcvehicle;


removehcvehicle = {
    player addaction ["Remove from Squad 1", {mygrp1 leaveVehicle cursorTarget},nil,1,false,true,"",format ['(!(isnull cursortarget) && (alive cursortarget) && ({ alive _x } count units mygrp1 > 0) && (locked cursortarget < 2) && ({if (assignedVehicle _x == cursortarget) exitwith {true}}forEach units mygrp1))'],15,false];
};
null = []spawn removehcvehicle;

 

Share this post


Link to post
Share on other sites

I kept reading and reading.  I think I found a better solution:

mygrp1 = createGroup side player; 
[commander cursorTarget ] joinSilent mygrp1; 
{_x joinAssilent [mygrp1,2];}forEach crew cursorTarget - [commander cursorTarget];
driver cursortarget assignAsDriver cursortarget;  
commander cursortarget  assignAsCommander cursortarget;  
gunner cursortarget assignAsGunner cursortarget;
crew cursortarget allowGetIn true;   
player hcsetgroup [mygrp1,""]; 

My scripts have the ability to flip my men between HC and my group with addaction menu without hassle, so I realized that I could just put dudes in the vehicle manually from my group and run the above code to lock them in place.  I can create conditions that check for particular vehicle classes and adjust the assignment parameters as needed.  I am now playing with an additional fire team in a BMP2 and assigning that seperate HC group as cargo, and will likely use radio commands to set their orders to get in and out.

Share this post


Link to post
Share on other sites

The first issue was due to this in the condition of the action: (side cursorTarget) == side player

An empty object (including vehicles) belong to the civilian side. When the group dismounts the side is switched and voila,  no action.

 

You'd have to test for: side cursorTarget in [side player, civilian] 

This will include inanimate objects too though,  I'll let you figure that out. ;) 

Share this post


Link to post
Share on other sites
2 hours ago, mrcurry said:

The first issue was due to this in the condition of the action: (side cursorTarget) == side player

An empty object (including vehicles) belong to the civilian side. When the group dismounts the side is switched and voila,  no action.

 

You'd have to test for: side cursorTarget in [side player, civilian] 

This will include inanimate objects too though,  I'll let you figure that out. ;) 

Thanks for the response.  I was wondering why the first script was getting the axe when everyone piled out of the car, and what you say makes perfect sense.  I am about done with my new library and it is running much better than this first post.  Hell, even the second post I made got overhauled.

 

As for testing for inanimate objects, I am currently writing up a library of iskindof and vehicle type features so I can fix the bugs in my unit and vehicle interactions, as well as expand the potential for assigning vehicle crews to various types of vehicles without having to micromanage units.  I rather like what I have at the moment, aim and click, and the dude is in your group.  Aim and click and the dude is assigned to a car or in a subcommander module, or both.  No thousands of menus and getting shot in the back, no fuss.

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  

×