Jump to content
Sign in to follow this  
Tankbuster

repair at repair stations?

Recommended Posts

One of my players asked me if we could implement this?

We know that it's possible to refuel at the fuel stations on the map, this is clearly an island thing and not coded by the mission maker.

But is it possibly to have a scripted repair when you are very near the Land_repair_center?

Land_repair_center_01.jpg

Bearing in mind these are map objects, not ones placed by the mission maker, how would we go about this?

---------- Post added at 07:07 PM ---------- Previous post was at 05:49 PM ----------

Presumably, we need to find the all these stations on the map first.

nearEntities?

Share this post


Link to post
Share on other sites

An idea:

Place a sensor on map. Set it to REPEATEDLY.

Condition:

count (nearestObjects [vehicle player, ["Land_Repair_Center"], 10]) > 0 AND local player AND vehicle player isKindOf "CAR"

OnActivation:

ID01=((nearestObjects [vehicle player, ["Land_Repair_Center"], 10]) select 0) addAction ["Repair","NameOfYourRepairScript.sqf"];

Repair script:

private["_obj","_caller","_id"];
_obj = _this select 0;
_caller = _this select 1;
_id = _this select 2;
_obj removeAction _id;
vehicle _caller setDammage 0;

;)

Share this post


Link to post
Share on other sites

I've done a nearestObjects using Land_repair_center as the filter, but the returned array is empty.

Share this post


Link to post
Share on other sites

another idea.

place this in an init.sqf file and it just places a trigger around the repair centers.

When a vehicle enters it repairs it.

{
_dir =	getdir _x;
_reppos = createTrigger["emptyDetector",getPos _x];
_reppos setTriggerArea [11,11,_dir,false]; 
_reppos setTriggerActivation ["any","present",true]; 
_reppos setTriggerStatements["this","{null=[_x,thistrigger] execVM 'repairing.sqf'} foreach thislist",""];
} forEach (nearestObjects [player, ["Land_repair_center"], 10000]);  

save as repairing.sqf

_veh = _this select 0;
_reppos = _this select 1;

_veh_dam = getdammage _veh;

if (!(vehicle _veh isKindOf "CAR")) exitwith {Hint "We can't repair that here"};


while {getdammage _veh  > 0 and _veh distance _reppos  < 11} do {

titleText ["Repairing", "PLAIN"] ;
sleep 1.6;
_veh_dam = _veh_dam - 0.1;
_veh setdamage _veh_dam;
};
if (getdammage _veh  == 0) then {
titleText ["Repairs Complete", "PLAIN"] ;
} else {
     titleText ["Vehicle is Still Damaged", "PLAIN"] ;
     };

Share this post


Link to post
Share on other sites

Nope. using nearestObjects on Land_repair_center is not getting any data. :(

If I filter for "House" in the middle of Feruz, I get this;

f7374800# 33431: mil_repair_center_ep1.p3d

That's finding the model. 33431 is the object ID.

Share this post


Link to post
Share on other sites

Possible there are different type names of the building? My example works fine for me...

Try to get the building class name with e.g. player sideChat format["%1", typeOf cursorTarget]; while pointing on the building...

Share this post


Link to post
Share on other sites

Presumably, we need to find the all these stations on the map first.

nearEntities?

OK, well nearEntities is not the way. It doesn't find buildings, map or editor placed.

---------- Post added at 11:26 PM ---------- Previous post was at 11:12 PM ----------

Possible there are different type names of the building? My example works fine for me...

Try to get the building class name with e.g. player sideChat format["%1", typeOf cursorTarget]; while pointing on the building...

OK. Using pvpscene's lovely DevCon...

wibha.jpg

---------- Post added at 11:39 PM ---------- Previous post was at 11:26 PM ----------

Right, using the classname discovered above, nearestObjects is now getting hits.

But I wonder if there are other buildings in use? Can I get only objects with 'repair' somewhere in it's class name?

Share this post


Link to post
Share on other sites

But I wonder if there are other buildings in use? Can I get only objects with 'repair' somewhere in it's class name?

Apparently not. There's Land_House_C_12_EP1 which is more of a domestic car repair place. There#s 26 of them on Takistan, which is probably too many - enough to change the mission dynamic. I found 5 Land_Mil_Repair_center_EP1 on the map and can now add scripts to them.

Excellent. Thank you everyone. :)

Edited by Tankbuster

Share this post


Link to post
Share on other sites

OK, this is going well.

Because it gives a repair function that looks similar to the refuel @ fuel stations I referenced in the first post, I'm going with F2k Sel suggestions.

I'm placing the trigger, instead of centred on the player but right in the middle of the map, and looking for repair stations within 5200m. This excludes the two repair stations at the Loy Manara and Rasman airbases, but does find the remaining three, at Kilavur, Feruz and Garmsar, which is important for my mission.

Couple of followup questions though. Why are you getting the direction of the building? I can understand why you might want to do this if using a rectangular trigger so that the vehicle has to be at the front door of the repair centre (which is an excellent idea which I might do), but you're using a circular trigger?

Also, I have to consider locality. This is for an MP mission. I assume this will have to run on clients? If it runs on the server only, the vehicle won't be local to the server unless the crew dismount?

Share this post


Link to post
Share on other sites

I was using a rectangular trigger but probably a circle will work better.

Sorry I have no multiplayer experience.

I also added a sound file for the repairs which works very well.

I don't suppose you know how to get the spanner Icon to show?

Edited by F2k Sel

Share this post


Link to post
Share on other sites

I think I have the locality stuff figured out. Will report back. Many thanks for your help, mate. :)

Share this post


Link to post
Share on other sites

I don't suppose you know how to get the spanner Icon to show?

Mmm, no. It would be good if that could be made to work, just like it's refuelling counterpart.

Share this post


Link to post
Share on other sites

Somewhere in ancient ArmA 2 hisory I seem to remember Evo using these very building for repairing vehicles. I remember driving up next to them and getting the vehicle in repair text. Of course this was on base too. So this might provide you a trail. maybe not ....

Share this post


Link to post
Share on other sites

Wasn't there a "repair buildings can repair yes/no" switch in Domination at one point?

Might be worth looking thru an older Dom version or two.....

... an interesting topic.... From a terrain makers perspective, when we place fuelstations we automatically get the refuel capability (and a little fuel icon on the map), but I don't think repair centers have the same "embedded capability"... I wonder whether the "custom" CWR2 ones do? and/or if such a thing could be added at the terrain creation stage...?

one other micropoint to be aware of....

Object ID's aren't Carved in Stone - they're basically assembled at the .wrp (worldfile) export stage (I think), which technically means that if that terrain is ever re-edited or updated, the actual specific model Id's may change.

Not a problem, probably, for the BIS terrains - I think they're done updating the terrains themselves, but for user terrains etc...

B

Edited by Bushlurker

Share this post


Link to post
Share on other sites

You gave me an idea ChiefRedCloud.

just place this in the init.sqf

//init.sqf
_object = createvehicle ["HeliHEmpty",[0,0,0],[],0,"NONE"];

{
_Veh = [[getpos _x select 0,getpos _x select 1,-3.5],0,"MtvrRepair",civilian] call bis_fnc_spawnvehicle;
(_Veh select 0) attachto [_object];
} forEach (nearestObjects [[0,0,0], ["Land_repair_center","Land_House_C_12_EP1","Land_Mil_Repair_center_EP1"], 10000]); 

It now uses a buried truck for repairs.

Share this post


Link to post
Share on other sites

Hey why can't you just isolate the script used in domination by xeno and just place it with a marker at all the Repair sataions you want to be functional. This is what I did in my domination edit and it works great. The one issue is can you pull out and the script outside of his mission sometimes this can be hard to do if you miss a little pathway of code.

One of my players asked me if we could implement this?

We know that it's possible to refuel at the fuel stations on the map, this is clearly an island thing and not coded by the mission maker.

But is it possibly to have a scripted repair when you are very near the Land_repair_center?

Land_repair_center_01.jpg

Bearing in mind these are map objects, not ones placed by the mission maker, how would we go about this?

---------- Post added at 07:07 PM ---------- Previous post was at 05:49 PM ----------

Presumably, we need to find the all these stations on the map first.

nearEntities?

Share this post


Link to post
Share on other sites

The problem is that doing the nearestobjects with big radii is really tough on the server and as this is in MP, it's also hard on JIP clients. So I need to locate the repair stations manually and put triggers there manually too. Here's the data for Takistan.

Feruz 5187, 6051 object ID 33431
Jilavur 2643, 5112 object ID 29933
Garmsar 10343, 6406 object ID 95791

Rasman 5959, 11311 object ID 709
Loy Manara 8397, 1912 object ID 123317

F2K's code is excellent, but needs to be adapted for MP and dedi environments, which I'm doing now. Can't use titleText in MP for example - it's broadcast to all clients. :)

---------- Post added at 08:01 PM ---------- Previous post was at 07:57 PM ----------

Wasn't there a "repair buildings can repair yes/no" switch in Domination at one point?

Might be worth looking thru an older Dom version or two.....

AHA! yes, you're right, Bushie! My mission is indeed based on an old Domi edit and it has this feature, although we've never turned it on in parameters. It calls an FSM which actually looks for the wrong classname (it's looking for the Chernarus version of the building), just as I did earlier in this thread. I'll change the class name in the FSM and give it a try. :)

Share this post


Link to post
Share on other sites
Hey why can't you just isolate the script used in domination by xeno and just place it with a marker at all the Repair sataions you want to be functional.

It's a FSM called RepStation.fsm and not a normal script (changed that a loooong time ago).

And you just have to replace the nearestObject line in one of the FSM states to

_nobs = nearestObjects [position _vec, ["Land_repair_center", "Land_Mil_Repair_center_EP1"], 15];

It will repair vehicles on all repair stations when the player is the driver (it should run standalone and you just have to start it on each client).

Xeno

Share this post


Link to post
Share on other sites

Well, I don't understand the FSM that Xeno used, I'd just be fiddling with code rather blindly.

The biggest problem is that there's a repair station on both airbases. Because I'm using the two team version (based on Domi 2.29), player teams are in both Rasman and Manara AND, they don't get repair trucks or vehicle service point at the start of the mission - they have to win them through side missions - so having these buildings fixing vehicles rather puts the kybosh on that.

Looks like I'll have to go back to my method of manually placing triggers.

It will repair vehicles on all repair stations when the player is the driver (it should run standalone and you just have to start it on each client).

Xeno

We crossposted. I tried it... it works once the building classname is changed, but I can't allow the buildings on the airbases to have this property. :)

Edited by Tankbuster

Share this post


Link to post
Share on other sites

You can exclude items when using nearestobjects

{
_dir = getdir _x;
_reppos = createTrigger["emptyDetector",getPos _x];
_reppos setTriggerArea [10,10,_dir,false]; 
_reppos setTriggerActivation ["any","present",true]; 
_reppos setTriggerTimeout [1, 1, 1, false]; 
_reppos setTriggerStatements["this","{null=[_x,thistrigger] execVM 'repairing.sqf'} foreach thislist",""];

} forEach (NearestObjects [getpos player, ["Land_repair_center"], 10000]) - ((getpos gl) NearObjects 10);

If you have a game logic placed over the fuel station you don't want and it's named gl that station would not be issued a trigger.

Share this post


Link to post
Share on other sites

The nearestObjects thing is causing too much lag, especially when a player JIPS. I've got the locations of the repair centres, I'll manually put triggers on them.

Share this post


Link to post
Share on other sites

yes but you could just use it as a tool to get the x,y,z of each building and copytoclipboard and then place that into the array to create the triggers.

For just a few stations it's probably just quicker to place them and be done with it.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Yeah, that's what I'll do. I posted the data up in post 17. In fact, it'd probably be best to generate the triggers in the editor. :)

Share this post


Link to post
Share on other sites

here's my old thread on this - we have it working really well now in evolution

http://forums.bistudio.com/showthread.php?t=111797

there's an array of every type of repair type building (including cutom class buildings used by map makers)

it works fine on all maps

the script is in the data/scripts/mainthreadc.sqf

of any GITS evolution mission (see link in my sig)

Share this post


Link to post
Share on other sites

Thanks fellas. I do have it working now. nearObjects (or nearestObjects) is too laggy with these big radii so I put the triggers on the buildings in sqm. Bit cludgy, and not very geeky, but it works best, I think.

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  

×