newiy
Member-
Content Count
74 -
Joined
-
Last visited
-
Medals
Everything posted by newiy
-
Is it possible to count the number of crew positions of any vehicle via script? Also, is it possible to randomize the crew position a unit is assigned when boarding a vehicle?
-
Ah well, Maths, EVEN MORE maths, physics and chemistry (they won't let me take biology *sniff*)... Still alive though... and for some reason, I'm beginning to enjoy calculus (even if my integration is sub par, but hey...)
-
In all weirdness... Anywho here's an updated version: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _veh = _this select 0 _freeslots = _this select 1 _logicarray = [] _slots = 0 #countcargo _logic = "logic" createVehicle [0,0,0] _logic MoveInCargo _veh _logicarray = _logicarray + [_logic] _slots = _slots + 1 ?(_logic in _veh): goto "countcargo" _logicarray = _logicarray - [_logic] deleteVehicle _logic _slots = _slots - 1 #randomizeloop ?(count ((crew _veh) - [driver _veh] - [commander _veh] - [gunner _veh]) == _slots - _freeslots_ || count _logicarray == 0): goto "check" _r = random (count _logicarray - 1) _r = _r - _r mod 1 (_logicarray select _r) setPos [0,0,0] deleteVehicle (_logicarray select _r) _logicarray set [_r, "DELETE"] _logicarray = _logicarray - ["DELETE"] ?(count ((crew _veh) - [driver _veh] - [commander _veh] - [gunner _veh]) > _slots - _freeslots && count _logicarray != 0): goto "randomizeloop" #Check @(count ((crew _veh) - [driver _veh] - [commander _veh] - [gunner _veh]) != _slots - _freeslots || getdammage _veh >= 1) ?(count ((crew _veh) - [driver _veh] - [commander _veh] - [gunner _veh]) > _slots - _freeslots && getdammage _veh < 1): goto "randomizeloop" ?(getdammage _veh < 1): goto "refill" {deleteVehicle _x} forEach _logicarray exit #refill ?(count _logicarray == 0): goto "check" _logic = "logic" createVehicle [0,0,0] _logic MoveInCargo _veh _logicarray = _logicarray + [_logic] ?(_logic in _veh): goto "refill" _logicarray = _logicarray - [_logic] deleteVehicle _logic goto "randomizeloop"
-
Heh, that worked Now, why didn't I think of that? Of course, now the problem is that not everyone gets to board the vehicle at the same time, but that's not a worry Here's a quick script! Comments anyone? <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _veh = _this select 0 _freeslots = 1 _logicarray = [] _slots = 0 #fillcargo _logic = "Logic" createVehicle getPos _veh _logic MoveInCargo _veh _logicarray = _logicarray + [_logic] _slots = _slots + 1 ?(_logic in _veh): goto "fillcargo" _logicarray = _logicarray - [_logic] deleteVehicle _logic _slots = _slots - 1 _i = 0 #randomizeloop _r = random (count _logicarray - 1) _r = _r - _r mod 1 (_logicarray select _r) setPos getpos _veh deleteVehicle (_logicarray select _r) _logicarray set [_r, "DELETE"] _logicarray = _logicarray - ["DELETE"] _i = _i + 1 ?(_i < _freeslots && count _logicarray != 0): goto "randomizeloop" @(count ((crew _veh) - [driver _veh] - [commander _veh] - [gunner _veh]) == _slots) ?(getdammage _veh < 1): goto "fillcargo" {deleteVehicle _x} forEach _logicarray
-
Random cargo positions. More for eyecandy reasons, it seems weird especially when the civil bus is boarded and everyone seats according to row. And count the cargo capacity of the vehicle. That is, how many passengers can this vehicle hold? Sorry for not being specific, was very tired on that day (and still am) .
-
Do you want a mission that is fully dynamic?
newiy replied to PLRSniper's topic in OFP : MISSION EDITING & SCRIPTING
Now that's REALLY ambitious! But of course, like ThruYerSternum said, you'll have to plan first. Also, if you're going to receive help, some sort of coordination is necessary. Here's an example of what I'll do if I were on a project like yours: Goals and Objectives (Must be specific goals and objectives, and which ones are more important to meet)? So far: 1) Dynamic - can be used on any map with little modification. 2) Userfriendly to set up. Features: ... Main Engine Plan: 1) Smaller engines? Command Engine, Logistics Engine etc... Details: At which level does the engine operate? Group level (faster but not as fine tuned) or Unit level (More fine tuned, slower)? Does it work on multiple levels too? Also, how tight are the loops? 15 sec delay? 'Bridging scripts', Scripts that pass data between various engines and levels. What kind of data and at what level? 2) How is data stored, and what is the scope of each data type? Details: Data at global level - e.g. Array of units on all sides, Strategic points, West commands array, Guerr commands array , East Command array, Data request lists Data at local level - e.g. Morale can be bridged and passed on request. Scripts/Functions needed: 1) General scripts - e.g. Sort functions, Nearest known enemy, Nearest known friendly, nearest known enemy location, unit value 2) Infrastructure scripts, highlevel - command engine 3) Infrastructure scripts, lowlevel - base building 4) AI Scripts, command level e.g. Assault planning and squad level: e.g. AI recon behaviour. 5) Task Scripts, e.g. Medivac, air support etc... 6) Eyecandy & Misc. scripts- e.g. smoking script, surrender scripts 7) Really low level stuff: Values of each unit etc... Well, stuff like that. Coordination: Place for each member to discuss etc... How are the scripts gonna be placed? Folder divisions like .../AI , /Engine Work out a standardization of naming conventions and such. E.g. SideEngineVar, GuerrCommandList _delay for delays, _i for loops stuff like that. Don't jump into coding without some sort of plan, and made it known to all involved in the project (hee, I never thought I'll say this, I hate planning and stuff)! -
Do you want a mission that is fully dynamic?
newiy replied to PLRSniper's topic in OFP : MISSION EDITING & SCRIPTING
No problem. I got the math sorted out... Nice array you have there, but what is it for? To order the medivac or for the vehicle to report what its doing? If it is to order the medivac, I forsee a problem of not being flexible enough to order specific units into the medivac! Also, what is the string "Order#" for, and how would you implement the priority levels? And is the array a global variable or 'attached' to a certain squad? -
Do you want a mission that is fully dynamic?
newiy replied to PLRSniper's topic in OFP : MISSION EDITING & SCRIPTING
Yes, and I can help you. I could do/did a request engine that handles air support, medivacs, evacs and stuff. I could also mess with code till I get something close to a desired effect. But as far as I know, it only works in SP. Unfortunately I'm really busy nowadays, so I can't really do much. -
Go progress bar go!
-
Go progress bar go!
-
Woohoo! One step closer to making civil missions more interesting. Also, happy birthday!
-
If it is full, they are considered stragglers. So it's the latter. But most of time, you'd be lucky to get 3 in a single evac. They tend to die in my experience... I don't know if it is possible to 'feel' the cargo capacity of the vehicle, if it is, it should be fairly easy to implement the former. You only have to touch the addTeam and addRequest scripts anyway so remember: [group requestgroup] exec "addmedirequest.sqs" [pilot, gunner, vehicle] exec "addteam.sqs" Opps, forgot to tell you to put this line: [] exec "requesthandler.sqs" in init.sqs
-
You'll have to forgive me if there are errors, these are chopped off from a larger project that I never completed, so there might have been some things I left out. Feel free to modify heavily for your use. It was designed to be abused, after all. You might want to write a script to allow AI to automatically call for medivacs. I have tested the original version with HMMWVs, UH60s, Trucks, M113 ambulances and plain M113, but I have not tested the modified version below, so there might be errors and bugs. Put the following code in your init.sqs <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;Medivac Lists MedivacRequest = [] MedivacComplied = [] MedivacPoint = [] ;MedivacPoint are objects, invisible H or gamelogics used to mark hospital locations ;Team Rosters MedivacFreeTeam = [] MedivacBusyTeam = [] Since my team rosters followed a specific format, here's the script to add a team. Teams start outside the vehicle. use this script to add teams if you using my scripts strictly. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ; *************************************** ; AddMedivac Team ;Usage is: [unit Pilot, unit Gunner, unit Vehicle] exec "addMediTeam.sqs" ;If there is no gunner, gunner is objNull ;This script also applies to land vehicles as well as helos ; *************************************** _newMediPilot = _this select 0 _newMediGunner = _this select 1 _newMediVeh = _this select 2 _newTeam = [_newMediPilot, _newMediGunner, _newMediVeh] [_newMediPilot] join grpNull ?(!IsNull _newMediGunner) : [_newMediGunner] Join group _newMediPilot MedivacFreeTeam = MedivacFreeTeam + [_newTeam] ;BusyTeam = BusyTeam + [group _newMediPilot] You don't need this line. Here's the request handler: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _papabear = [West, "HQ"] ;**************************************** ;MEDIVAC REQUEST HANDLER ;**************************************** ; ;Procedure: ;1)Check for requests ;2)If one is found, find out if there is already a medivac enroute to that location ;3)If there is, Carpool! ;4)If thre isn't, dispatch any teams you have on the roster. ;5)Repeat process as to fulfil as many requests as possible ; ;NOTES: ;In checking for the "nearest" team, aircraft get priority in selection. Aircraft have a "bias" coefficient #MedivacComply ~60 ;modify delay if necessary if (count MedivacRequest > 0) then {goto "MedivacCheck"} else {goto "MedivacComply"} #MedivacCheck _i = 0 _CurrentTeam = MedivacRequest select 0 ?(IsNull _CurrentTeam): MedivacRequest - [_CurrentTeam]; goto "MedivacComply" if (count MedivacComplied > 0) then {goto "CheckPoolLoop"} else {goto "CheckFreeTeams"} #CheckPoolLoop if (leader (MedivacComplied select _i) distance leader (MedivacRequest select 0) <= 500) then {goto "MediPoolSend"} ;Change 500 to a more appropriate radius if necessary... _i = _i + 1 if (_i < (count MedivacComplied)) then {goto "CheckPoolLoop"} #CheckFreeTeams if (count MedivacFreeTeam > 0) then {goto "MedivacSend"} else {goto "MedivacReject"} #MedivacSend if (!(MedivacRequest select 0 In MedivacComplied)) then {_papabear sideChat "This is HQ, medivac is dispatched and enroute."} MedivacComplied = MedivacComplied + [MedivacRequest select 0] MedivacRequest = MedivacRequest - [MedivacRequest select 0] _i = -1 _NearestMediPt = (MedivacPoint select 0) #GetNearestMediPt _i = _i + 1 if ((leader _CurrentTeam distance (MedivacPoint select _i)) < (leader _CurrentTeam distance _NearestMediPt)) then {_NearestMediPt = MedivacPoint select _i} if (_i < (count MedivacPoint - 1)) then {goto "GetNearestMediPt"} _i = -1 _DelIndex = 0 _NearestMediTeam = MedivacFreeTeam select 0 #GetNearestMediTeam _i = _i + 1 ?(!Alive ((MedivacFreeTeam select _i) select 0) || !Alive ((MedivacFreeTeam select _i) select 1)) then {goto "DeadMediTeam"} _MedivacTeamDistance = (leader _CurrentTeam) distance ((MedivacFreeTeam select _i) select 0) if (("Air" Counttype (MedivacFreeTeam select _i)) == 1) then {_MedivacTeamDistance  = _MedivacTeamDistance * 0.33} if (_MedivacTeamDistance < (leader _CurrentTeam distance (_NearestMediTeam select 0))) then {_NearestMediTeam = MedivacFreeTeam select _i; _DelIndex = _i} if (_i < (count MedivacFreeTeam - 1)) then {goto "GetNearestMediTeam"} MedivacBusyTeam = MedivacBusyTeam + [_NearestMediTeam] MedivacFreeTeam set [_DelIndex , "DELETE"] MedivacFreeTeam = MedivacFreeTeam - ["DELETE"] [_CurrentTeam, _NearestMediPt, _NearestMediTeam, count MedivacBusyTeam - 1] exec "Medivac.sqs" goto "MedivacComply" #MediPoolSend MedivacRequest = MedivacRequest - [MedivacRequest select 0] [_CurrentTeam, MedivacComplied select _i, (MedivacBusyTeam select _i) select 2] exec "MediPool.sqs" goto "MedivacComply" ; *************************************** #DeadMediTeam MedivacFreeTeam set [_i , "DELETE"] MedivacFreeTeam = MedivacFreeTeam - ["DELETE"] goto "MedivacComply" #MedivacReject _papabear sidechat "No medivacs available." goto "MedivacComply" In this script, I assume the pilots and gunners are outside the vehicle. Medivac script: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ; *************************************** ; Medivac Script ; *************************************** ; NOTES: This script can also be used with APCs, HMMWVs, Trucks as well as aircraft ;  Medivac team does not need a gunner ; ; USAGE: [Group to be medivacced, Gamelogic Destination, array MedivacTeam, Index of Medivac team for deleting purposes] exec "medivac.sqs" ; ; *************************************** RelPos = PreProcessFile "RelPos.sqf" _mediGroup = _this select 0 _mediDest = _this select 1 _mediPilot = (_this select 2) select 0 _mediGunner = (_this select 2) select 1 _mediVeh = (_this select 2) select 2 _DeleteThis = _this select 3 _papabear = [West, "HQ"] ; *************************************** ?(IsNull _mediGroup): goto "Clean" _ClearCheck = "logic" createVehicle [getPos leader _mediGroup select 0, getPos leader _mediGroup select 1, 0] _RelPos = [_MediVeh, _ClearCheck] call RelPos #SelectDest _EvacPoint = getPos leader _mediGroup ;You might want to change this! I have code for the clear evac zone, but it's too buggy at the moment _EvacMarker = "logic" createVehicle _EvacPoint ;don't remember what this is for... ; *************************************** _MediPilot AssignAsDriver _MediVeh ?(!IsNull _MediGunner) : _MediGunner AssignAsGunner _MediVeh (units group _mediPilot) OrderGetIn true ? (!Alive _mediPilot || getDammage _mediVeh == 1): goto "DeadMediTeam" @(driver _mediVeh == _mediPilot) _mediVeh setSpeedMode "FULL" ?("Air" countType [_mediVeh] == 1) : _mediVeh setBehaviour "CARELESS" _mediPilot doMove _EvacPoint #CheckDist ~1 ? (!Alive _mediPilot || getdammage _mediVeh >=  1): goto "DeadMediTeam" _marker = "logic" createvehicle [_EvacPoint select 0, _EvacPoint select 1, getPos _mediVeh select 2] if (_mediVeh distance _marker <= (speed _mediVeh * 1.5)) then {goto "Land"} deletevehicle _marker goto "CheckDist" #Land deletevehicle _marker if ("Air" countType [_MediVeh] == 1) then {commandStop _mediVeh} @(speed _mediVeh <= 50) ?("Air" countType [_MediVeh] == 0) : goto "LZSelected" _ClearCheck setpos [getPos _mediVeh select 0, getPos _mediVeh select 1, 0] _RelPos = [_clearCheck, _EvacMarker] call RelPos _Shiftx = 5 _Shifty = 5 ?(_RelPos select 0 < 0): _Shiftx * -1 ?(_RelPos select 1 < 0): _Shifty * -1 #CheckLZ ? ((nearestBuilding _ClearCheck) distance _ClearCheck > 5 || (_Clearcheck distance _EvacMarker > 150)) : goto "SelectEvacPoint" _NewPos = [(_RelPos select 0 + _Shiftx) + (_EvacPoint select 0), (_RelPos select 1 + _Shifty) + (_EvacPoint select 1), 0] _ClearCheck setPos _NewPos goto "CheckLZ" #SelectEvacPoint _lz = "HeliHEmpty" CreateVehicle _NewPos ; *************************************** ;Part where you assigned those injured to a new group ; *************************************** #LZSelected _x = 0 _EvacList = [] _mediCaller = units _mediGroup #CasualtyList if (count _MediCaller <= _x) then {goto "Board"} if (((getDammage (_MediCaller select _x) >= 0.3) && Alive (_MediCaller select _x)) || (HandsHit (_MediCaller select _x) == 1) || (Fleeing(_MediCaller select _x))) then {goto "AddList"} #ContinueCasualtyList _x = _x + 1 goto "CasualtyList" #AddList _EvacList = _EvacList + [_MediCaller select _x] _MediCaller select _x AssignAsCargo _mediVeh [_MediCaller select _x] join GrpNull goto "ContinueCasualtyList" ; *************************************** #Board _EvacList join group (_EvacList select 0) _MedivacGroup = group (_EvacList select 0) ? (!Alive _mediPilot || !Alive _mediVeh): goto "DeadMediTeam" _mediPilot sideChat "Medivac has arrived and is ready for boarding." if ("Air" countType [_MediVeh] == 1) then {_mediVeh Land "GET IN"} _EvacList OrderGetIn true ;Boarding complete ? (!Alive _mediPilot || getdammage _mediVeh >= 1): goto "DeadMediTeam" @(Speed _Mediveh == 0) _mediPilot CommandMove getPos _mediDest @(speed _MediVeh >= 20 || getdammage _Mediveh >= 1 || !Alive _MediPilot || count _EvacList == 0) ?(getdammage _Mediveh >= 1 || !Alive _MediPilot) : goto "DeadMediTeam" _mediPilot sideChat format["This is %1, returning to base now.", group _mediPilot] ;Stragglers should go back to their original group! _i = 0 #StragglerLoop if (!(_EvacList select _i In _mediVeh)) then {[_EvacList select _i] join _mediGroup} _i = _i + 1 if (_i < count _EvacList) then {goto "StragglerLoop"} @(_mediVeh distance _marker <= (speed _mediVeh * 1.5)) _ClearCheck setPos [getPos _mediVeh select 0, getPos _mediVeh select 1, 0] #CheckLZ2 ? (((nearestBuilding _ClearCheck) distance _ClearCheck > 5) || (_mediDest distance _ClearCheck > 150)) : goto "SelectLZ2" _Shiftx = _Shiftx + 5 _Shifty = _Shifty + 5 _NewPos = [_Shiftx + ((getPos _mediVeh) select 0), _Shifty + ((getPos _mediVeh) select 1), 0] _ClearCheck setPos _NewPos goto "CheckLZ2" #SelectLZ2 _lz2 = "HeliHEmpty" CreateVehicle _NewPos if ("Air" countType [_MediVeh] == 1) then {_mediVeh Land "LAND"} ?(Alive _mediPilot): _mediPilot sideChat "Medivac at destination." group (_EvacList select 0) LeaveVehicle _mediVeh group _MediPilot LeaveVehicle _mediVeh @(count crew _mediVeh == 0) ;[_MedivacGroup] exec "AddMergeRequest.sqs" script not included! ;Admin stuff deleteVehicle _lz deleteVehicle _lz2 deleteVehicle _ClearCheck deleteVehicle _evacMarker MedivacFreeTeam = MedivacFreeTeam + [_this select 2] ;Huh? I don't remember doing that! ; *************************************** ;Clean Corresponding Lists ; *************************************** #Clean MedivacComplied = MedivacComplied - [_MediGroup] MedivacBusyTeam set [_DeleteThis, "DELETE"] MedivacBusyTeam = MedivacBusyTeam - ["DELETE"] ; *************************************** exit ;*************************************** ;Medi team died during medivac ;*************************************** #DeadMediTeam ~1 _papabear sideChat "This is HQ, we have lost contact with the medivac team. We will dispatch another medivac soon. HQ out." _EvacList join _mediGroup MedivacRequest = MedivacRequest + [_mediGroup] MedivacComplied = MedivacComplied - [_mediGroup] MedivacBusyTeam set [_DeleteThis, "DELETE"] MedivacBusyTeam = MedivacBusyTeam - ["DELETE"] exit Carpool script! I'm actually amazed this works semi-decently. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ; *************************************** ; Medivac Pool Script ; *************************************** _PoolGroup = _this select 0 _RequestGroup = _this select 1 _MediVeh = _this select 2 _papabear = [west, "HQ"] _x = 0 _EvacList = [] _mediCaller = units _PoolGroup _papabear sideChat ["This is HQ. We have already dispatched a medivac to your area."] ; *************************************** ;Assign Injured to New Group ; *************************************** #CasualtyList if (count _MediCaller <= _x) then {goto "Board"} if ( ((getDammage (_MediCaller select _x) >= 0.3) && Alive (_MediCaller select _x)) || (HandsHit (_MediCaller select _x) == 1) || (Fleeing(_MediCaller select _x))) then {goto "AddList"} #ContinueCasualtyList _x = _x + 1 goto "CasualtyList" #AddList _EvacList = _EvacList + [_MediCaller select _x] [_MediCaller select _x] join GrpNull goto "ContinueCasualtyList" ; *************************************** #Board _EvacList join group (_EvacList select 0) _MedivacGroup = group (_EvacList select 0) {_x commandMove (getPos leader _RequestGroup)} forEach _EvacList ;Don't activate until at least the Medivac is on the way @(speed _MediVeh > 0 || !Alive _MediVeh || {!Alive _x} count _EvacList == count _EvacList) ;Check if the thing is within range to board @(((leader _MedivacGroup distance _Mediveh <= 200) && (speed _Mediveh == 0) && (leader _MedivacGroup knowsabout _Mediveh > 0)) || getdammage _MediVeh >= 1 || {!Alive _x} count _EvacList == count _EvacList) ?(getdammage _MediVeh >= 1 || (!Alive driver _MediVeh && !IsNull (driver _MediVeh))) : goto "DeadMediTeam" ?({!Alive _x} count _EvacList == count _EvacList) : goto "DeadCasualties" leader _Poolgroup sideChat format ["Wait for us, %1", group _mediVeh] {_x AssignAsCargo _MediVeh} forEach _EvacList _EvacList OrderGetIn true @(speed _MediVeh >= 20 || !Alive _Mediveh || !Alive _MediPilot) ;Stragglers should go back to their original group! _i = 0 #StragglerLoop if (!(_EvacList select _i In _mediVeh) && !IsNull _PoolGroup) then {[_EvacList select _i] join _PoolGroup} _i = _i + 1 if (_i < count _EvacList) then {goto "StragglerLoop"} ; *************************************** @({!(_x In _MediVeh)} count units _MedivacGroup == count units _MedivacGroup) ;[_MedivacGroup] exec "AddMergeRequest.sqs" exit ;*************************************** ;Medi team died during medivac ;*************************************** #DeadMediTeam ~1 _papabear  sideChat "We have lost contact with the medivac team. We will dispatch another medivac soon. HQ out." _EvacList join _PoolGroup MedivacRequest = MedivacRequest + [_PoolGroup] exit #DeadCasualties ~1 _papabear sideChat format["Casualties for %1 are down. Do not wait for them, %2.", _PoolGroup, group _MediVeh] exit You need this function, save it as RelPos.sqf <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> /*RELATIVE POSITION FUNCTION */ private["_Obj1", "_Obj2", "_Pos1", "_Pos2"]; _Obj1 = _this select 1; _Obj2 = _this select 0; _ReturnedArray = []; _Pos1 = getPos _Obj1; _Pos2 = getPos _Obj2; _ReturnedArray = [(_Pos2 select 0) - (_Pos1 select 0), (_Pos2 select 1) - (_Pos1 select 1), (_Pos2 select 2) - (_Pos1 select 2)]; _ReturnedArray; Here's the add request, it's the only script you'll need to mess with other than the add team. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ; *************************************** ; Add Medivac Request ; Usage is: [group _Requestgroup] exec "AddMediRequest.sqs" ; *************************************** _newMediRequest = _this select 0 _papabear = [West, "HQ"] (leader _newMediRequest) sideChat "Request for medivac, at position %1." if (((_newMediRequest In MedivacRequest) || (_newMediRequest In MedivacComplied)) && (!IsNull _newMediRequest)) then {goto "Denied"} else {goto "Approved"} #Denied _papabear sideChat "This is HQ, medivac request denied." goto "quit" #Approved _papabear sideChat "This is HQ, medivac request approved." MedivacRequest = MedivacRequest + [_newMediRequest] #quit exit
-
Yep, it is possible to give them a 'safe' zone. 1) You could assume that the zones between the hospital and the unit is free of enemies, and get the Medivac to land like 200m 'behind lines'. or 2) You could plonk an invisible H and do a check against a list for known enemies within the radius of the H. Possible, but very draining on the CPU... Â I'll get you the scripts, but I have to clean them up some... those were my first major scripts!
-
try using the createVehicle command
-
I did several scripts that did exactly this, it's on another computer so I'll have to type out the main ideas I used 3 main scripts, I doubt they work in MP, though but they work fine is SP: 1) Request handler 2) Medivac Script (for the actual evacuation) 3) 'Carpool' script (for teams in the same area, because more there are several wounded from different squads in the area, and the dumb medivac would only pick those up from one squad and merrily drive away.) One minor script: One script to add 'valid' requests. 1) Request handler One script to handle and dispatch medivac requests, it contained a few arrays to act as lists: Medivac free teams, Medivac busy teams, request list, complied list and evac points (if you have more than one hospital). The script has a loop that checks and dispatches requests accordingly. What is does is to dispatch the as many free teams to as many requests as possible. For every request, the script also checks for complied requests within a certain radius so more than one team could use the medivac. Fresh requests would be dropped from the request list and added to the complied list. If there was a request already dispatched in the area, the casualties would simply be assigned to the medivac (which happens to have the same index in the busy array as the complied team, so this is possible) that was dispatched to the area. Those 'carpooling' simply would be dropped from both request and complied lists. I forgot what I did to ensure that they could not make another request. Minor Script: To handle requests, I had an addRequest.sqs that simply made sure that if the request was not already queued, it would be added to the list. 2) Medivac script Medivac is deleted from free list and added to busy list Basically, it asked the team to be dispatched to the evac location (for simplicity's sake it can be at the location of the leader of the request team, or a preset extraction zone, but it is possible with some math to make it ~200m away from the wounded squad.) Assigns the wounded to a new array, and they join a new group on boarding the medivac. Stragglers will not be added to a new group, but instead will have to wait for a new round of requests and dispatching. Team is dropped from complied list at this point Medivac goes to nearest hospital. They disembark. Medivac is deleted from busy list and added to free team list again. 3) Medipool script Basically, it assigns the wounded to a new team and gets them to move to the position of the leader of the team that is sharing. They get assigned to the vehicle when it is at a certain distance and board it. Stragglers will be returned to their original group. ISSUES: Medivac might get destroyed enroute. Either make them semi-invulnerable or remove them from the lists and reset all requests. Place checks throughout the medivac and medipool script. Lousy AI driving ensures that the victims sometimes get runover or the medivac gets stuck! Request locations may be in dumb places, such as forrests or extremely hilly terrain... so eeek! Wounded die while the team is on the way. But that's okay. NOTES: Script can be modified to do plain evacuations, reinforcements etc... Which are considerably easier to script than medivacs.
-
How values can they be assigned to an Array? And d
newiy replied to JLC's topic in OFP : MISSION EDITING & SCRIPTING
1) _pointList set [0, _pointList select 2] 2)_pointList = _pointList + [xxxx] -
I really don't mind, but I hope it won't be too much to the extent it becomes irritating and detracts from everything else .
-
Create a script file in the directory of your mission, then paste the loop code into the script. If you wish to have the loop start from the beginning of the mission, you can put it in init.sqs, but I prefer to keep my init.sqs clean and write the loop in a seperate file and put [] exec "scriptname.sqs" in init.sqs
-
Funny you asked.... I was working on a morale script earlier this month for private use, but it is still very buggy and it takes into account several factors like: Enemy Distance (I used Average distance of all known enemies) Strength of enemy vs. Friendly strength. (I made AI overvalue friendly strength...) Average damage of the group. And a bias value of sorts... This bias is supposed to account for things like low ammo (haven't implemented this yet), current state etc... I made it affect what "scripted" behaviours I have made available to the AI, but the system is still not too reliable, the AI will surrender inappropriately... etc... I don't think it can really be used in MP, but does it makes the AI a *little* bit smarter in SP, though it is still as blind as a bat esp. in CQB. The script lags because of the amount of functions I use. I'll post a skeleton of my system (don't think I'll finish it, ever!) if anyone is interested, and some related functions.
-
Guided missiles flying in the crosshair
newiy replied to InqWiper's topic in OFP : MISSION EDITING & SCRIPTING
Did you try tweaking the magnitude of the corrections? The idea is to reduce the magnitude as the missle approaches the crosshair so it doesn't overshoot. Anyhow, I'm all out of ideas at the moment. -
Guided missiles flying in the crosshair
newiy replied to InqWiper's topic in OFP : MISSION EDITING & SCRIPTING
Since I'm clueless as to how missles are actually supposed to fly IRL or the math behind it, this is guesswork. In that case, I believe instead of target, you find the relative position of the player to the missle. Since a missle is 3d, you'll have to find two angles... You have to set up a loop to do the following... second angle will be: Alpha = atan (Relx_missle/ Rely_missle) Beta = atan(Relz_missle / sqrt(Relx_missle^2 + Rely_missle^2)) From these angles, find how much it is off. Then using the missle's current relative velocity, try to get the missle's relative x and z components to 0. Using alpha and beta, find the desired correction direction on the missle's relative velocity... (if Relx is neg then the correction should be in the positive x direction... same goes for the z component) The magnitude of the correction is entirely up to how you want the missle to fly. You might want to change the real y component of the velocity in order to maintain a constant speed: The y after correction should be: sqrt (speed - New REAL x - New REAL z) Don't forget to change relative velocity back to actual velocity before assigning it to the missle! Not sure if this will work, but I believe it should. If you succeed, the missle won't exactly fly in the centre of the crosshair, but zig zag like crazy, unless you defined the magnitude of the corrections nicely (not sure how to do this, but it sure can't be constant). If there's another solution, I'm interested too. -
Guided missiles flying in the crosshair
newiy replied to InqWiper's topic in OFP : MISSION EDITING & SCRIPTING
Not sure exactly what your problem is... But if I may venture a guess, is the problem is trying to find the correct angle to face the camera? If that is the case, then 1) Get the relative position of the target to the player: This can be done by subtracting the corresponding coordinates in the following fashion: Relative x = Target x - Player x Relative y = Target y - Player y Relative z = Target z - Player z 2) The angle you want is atan (Relative x/ Relative y) Good luck ;) -
I wrote a small script that would cause units to "orbit" a desired object (it works with moving units too, but not very well ), but I have two problems with it... 1) I'm not sure how to modify the delay I put in the script so the unit would move continuously (for faster units) and without distorting the circle too much (for slower units)... I tried the good ol' t = d/s but it only made it worse. 2) The unit will just stand still when the radius of the circle is small. (Ingame limitation?) Here's the script: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _Performer = _this select 0 _Radius = _this select 1 _Ascension = _this select 2 _Reference = _this select 3 _t = 0 _deg = 0 _Point = "logic" createVehicle (getPos _Performer) #PerformLoop ?(!Alive _Performer) : goto "End" ;change this delay? ~1 _t = _t + (pi / 12) _deg = _t * (180 / pi) _r = _radius _Relx = _r * (cos _deg) _Rely = _r * (sin _deg) _Obsx = _Relx + ((getPos _Reference) select 0) _Obsy = _Rely + ((getPos _Reference) select 1) ;Doesn't seem to work :( _Obsz = ((getPos _Performer) select 2) + _Ascension _NewPos = [_Obsx, _Obsy, _Obsz] _Point setPos _NewPos _Performer doMove _NewPos goto "Performloop" #End deleteVehicle _Point exit Actually I have something to confess... the only reason I wrote this script was so I could watch units move according to my favourite graphs in polar coordinates... I'm strange like that. Thanks in advance for any help I might receive.