Home   Help Search Login Register  

Author Topic: Complete Refit...  (Read 2095 times)

0 Members and 3 Guests are viewing this topic.

Offline Shadow.D. ^BOB^

  • Members
  • *
Complete Refit...
« 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.

Offline Cheetah

  • Former Staff
  • ****
Re: Complete Refit...
« Reply #1 on: 31 Mar 2008, 09:43:19 »
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.

Code: [Select]
!alive sam1 && !alive sam2 && !alive sam3;
Or do you mean putting them into an array and checking if they're alive?
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Complete Refit...
« Reply #2 on: 31 Mar 2008, 13:31:16 »
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:
Code: (trigger condition to see if all units in array are dead) [Select]
({ 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):
Code: (trigger condition to see if all vehicles in game have been destroyed) [Select]
({ alive _x } count vehicles) == 0
« Last Edit: 31 Mar 2008, 13:39:25 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Complete Refit...
« Reply #3 on: 31 Mar 2008, 13:37:47 »
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  ::)

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Complete Refit...
« Reply #4 on: 31 Mar 2008, 13:40:06 »
For the repair/refuel station, create a trigger that is activated by the appropriate side(s):
Code: (trigger condition) [Select]
true

Code: (trigger activation) [Select]
{ 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.
« Last Edit: 01 Apr 2008, 02:24:06 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Complete Refit...
« Reply #5 on: 31 Mar 2008, 13:54:06 »
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?
« Last Edit: 31 Mar 2008, 14:01:11 by Shadow.D. ^BOB^ »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Complete Refit...
« Reply #6 on: 31 Mar 2008, 14:27:48 »
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 (free) and that function saves me an age ;P
« Last Edit: 01 Apr 2008, 01:43:58 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Complete Refit...
« Reply #7 on: 31 Mar 2008, 16:04:45 »
Nice one spooner thats a very handy tool.

Still getting an ) error on that trigger though  ???

Dont you just love ArmA  :good:

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Complete Refit...
« Reply #8 on: 31 Mar 2008, 16:37:20 »
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...
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Complete Refit...
« Reply #9 on: 31 Mar 2008, 17:01:11 »
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.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Complete Refit...
« Reply #10 on: 01 Apr 2008, 02:22:35 »
A recent question 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):
Code: [Select]
{ 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 ;/
« Last Edit: 01 Apr 2008, 02:26:41 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Complete Refit...
« Reply #11 on: 01 Apr 2008, 03:59:00 »
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.

Code: [Select]
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";
};
};
};
};
« Last Edit: 01 Apr 2008, 05:37:42 by Shadow.D. ^BOB^ »