OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Shadow.D. ^BOB^ on 31 Mar 2008, 02:03:20
-
Hi there, after searching the forums and looking through the scripts i cant seem to find what im looking for.
Basically i want to create a rearm/repair/refuel trigger for any vehicle. Basically like Evolution has at the airfield, as soon as you stop or land it services the vehicle.
Also on a side note, at the moment im using a rather long condition in my triggers for multiple vehicles destroyed.. e.g.
"not alive sam1 and not alive sam2 and not alive sam3;"
Is there a way i can shorten this?
Thankyou in advance for any help.
-
Hey Bob!
Not sure if there is such a script somewhere, mandoble or someone of the editors depot might be able to help you.
You can surely shorten it by a bit.
!alive sam1 && !alive sam2 && !alive sam3;
Or do you mean putting them into an array and checking if they're alive?
-
Well, ! for not isn't really shortening it logically and personally I prefer not anyway. If you want some code that scales better if the number of things being checked increases, you might try:
({ alive _x } count [sam1, sam2, sam3]) == 0
This technique also works with pre-existing arrays, so you could check if all vehicles in a mission had been destroyed (or you could create your own array to check):
({ alive _x } count vehicles) == 0
-
Cheers lads, just the servicing to sort now :)
I had a look at the Evolution system, its just a trigger over the area. Im guessing there is a scipt in there which activates using the trigger name, But for the life of me i cant find it amongst everything else in there ::)
-
For the repair/refuel station, create a trigger that is activated by the appropriate side(s):
true
{ if (_x in vehicles) then {_x setDammage ((getDammage _x) - 0.01); _x setFuel (((Fuel _x) + 0.01) min 1); }} forEach thisList
Changing the two 0.01 values will speed up or slow down the rate of repair/refuelling.
Oops, re-ammoing is a bit more complex, since it isn't obvious what ammo types you need to rearm with, so I'll leave that to you finding a proper script or someone else giving the full wisdom.
EDIT: In evolution, it should just be running the script from the trigger activation. If it isn't, then yes, a script will be using something like "list repairTriggerName" to look through the list.
EDIT2: I forgot that you'd need a "true" condition otherwise the repairing would only occur once whenever something entered the trigger zone.
EDIT3: Neither setFuel or getDamage are real commands. Shows how much I need a syntax highlighter to get anywhere at all.
-
Ta Spooner, yeah the trigger in evo must be using a triggername script as there is nothing in the activation. Im guessing the script must include all the deault vehicle ammo or something so it can re-arm everything.
Anyways back to trawling though scripts :)
Thx again.
Edit: Getting an error for the above trigger spooner, saying its missing ) somewhere, any ideas?
-
Sorry, I realise I put in an extra ) which I've now removed. I'm mad for my brackets ;P
If you want to speed things up, use an editor that allows searching through a number of text files at once. Just check what the name of the trigger is in the editor and search for that in all the evo scripts at once! I use CrimsonEditor (http://www.crimsoneditor.com) (free) and that function saves me an age ;P
-
Nice one spooner thats a very handy tool.
Still getting an ) error on that trigger though ???
Dont you just love ArmA :good:
-
I can't see any bracket errors, but I am not on a machine that has ArmA on it so I can't check in the editor. Could it be that you've used a ( instead of a { at the start of the line when you've copied it? Ah, but it might be that I used setDammage and getDamage, when it should be setDamage and getDammage (We'll suffer from that typo that BIS made 10 years ago, forever ;P ). Tell me if that helps...
-
Still getting the error, ive double checked the { and the spelling, all are how you say.
Im just going to start wacking random ('s in ad see what happens :yes:
Cheers for you help m8, i do appreciate it.
-
A recent question (http://www.ofpec.com/forum/index.php?topic=31240.0) might help you in your re-ammoing efforts.
The correct refuel/repair script should be (this compiles, at least, but hasn't been tested to see if it works as advertised - Thanks to Hoz and Myke for pointing out how bad I am at remembering ArmA commands and how to spell them ;P):
{ if (_x in vehicles) then {_x setDammage ((getDammage _x) - 0.01); _x setFuel (((fuel _x) + 0.01) min 1); }} forEach thisList
You might need to increase the percentage increases (this should equate to about 2% fuel and 2% repaired each second, which might be too slow for you). I assumed that you would know that the "condition: true" and "repeating" settings of the trigger would need to be set by you; I shouldn't assume anything ;P
Ultimately, though, just do a global search in Evo as I've suggested, and find out how to do it all easily and correctly ;/
-
Thx for you help spooner, im sure i can get something together.
:D :D
Edit - Finally found it, no idea how to modify it to a normal trigger tho :)
Looks like the ammo is done via the setvehicleammo.
EVO_Repair =
{
_vec = (vehicle player);
_type = typeOf vehicle player;
if(getDammage _vec > 0 or fuel _vec < 0.98 and not (_vec isKindOf "Man")) then
{
_inrepairzone = ((_vec in list AirportIn) or (_vec in list farp1) or (_vec in list farp2) or (_vec in list farp3) or (_vec in list reng1) or (_vec in list reng2) or (_vec in list reng3) or (_vec in list reng4) or (_vec in list dock1));
if(_inrepairzone and _vec != player and speed _vec > -2 and speed _vec < 2 and position _vec select 2 < 2.0 and (local _vec)) then
{
titleText [localize "EVO_014", "PLAIN DOWN",0.3];
for [{_loop2=0}, {_loop2<1}, {_loop2=_loop2}] do
{
sleep 0.200;
if (getDammage _vec > 0) then {_vec setDammage ((getDammage _vec)-0.0125);};
if (Fuel _vec < 1) then {_vec setFuel ((Fuel _vec)+0.0125);};
if (getDammage _vec == 0 and Fuel _vec == 1) then {_loop2=1;};
if(_vec != vehicle player or speed _vec < -2 or speed _vec > 2 or position _vec select 2 > 2.0) then {_loop2=1;titleText [localize "EVO_015", "PLAIN DOWN",0.3];};
_dam = (getDammage _vec)*100;
_ful = (Fuel _vec)*100;
hint format["Damage: %1\nFuel: %2",Round _dam,Round _ful];
};
_vec setVehicleAmmo 1;
if(_type == "AH6") then
{
_weapons = weapons _vec;
if(not ("Laserdesignator" in _weapons)) then
{
_vec addMagazine "Laserbatteries";
_vec addweapon "Laserdesignator"
}
else
{
_vec removeMagazine "Laserbatteries";
_vec addMagazine "Laserbatteries";
};
};
if(_type == "DC3" and score player >= rank6) then
{
_weapons = weapons _vec;
if(not ("BombLauncher" in _weapons)) then {_vec addweapon "BombLauncher"};
_vec removeMagazine "6Rnd_GBU12_AV8B";
_vec addMagazine "6Rnd_GBU12_AV8B";
_vec addMagazine "6Rnd_GBU12_AV8B";
};
};
};
};