Jump to content

valefor

Member
  • Content Count

    12
  • Joined

  • Last visited

  • Medals

Community Reputation

0 Neutral

About valefor

  • Rank
    Private First Class
  1. Hi. I am trying to get into scripting in Arma 3 and thought a fun little exercise would be to create a simple queue system for some helicopters in a mission. The basic idea is as follows: A number of playable units (AI and players) start at a location, some choppers are spawned (with crew). Each playable unit is entered into a queue, and all choppers are entered into a different queue. Once there are enough people to fill a chopper (or justify one traveling), a number of passengers are popped off the queue. These passengers are made into a group, told to enter a helicopter (also just popped off its queue), before the helicopter takes off, transports them to their destination, where they get out. Afterward, the helicopter returns back to its base and queues up again. If a playable unit dies, they respawn at a respawn point and are queued up back for another transport. All playable units are in individual groups initially and are only grouped up once they are transported. This also means that upon respawn, I remove units from their previous group. For simplicity's sake, if the helicopter or the pilot dies, I simply delete the entire vehicle and spawn it again instantly. This is also very in progress, so a lot of functionality is not implemented yet (like AI re-queueing if their spot in a chopper is taken by a player. It probably doesn't work online either, as I haven't gotten into the topic of local or global execution yet). The reason I am writing this post is that I have run into an issue that I don't really know how to deal with. (think it is just one issue, but it manifests in multiple ways) 1: Most of the time after respawn, AI controlled playables never leave their position. They join groups and order their group members to enter vehicles, but they never actually move to execute the order. (They can physically move in place, going prone, shooting back in case of friendly fire, etc, but I haven't been able to get them to move around). 2: Other times they respawn, form into groups and try to walk to the location (more than 2 km away). 3: A few times (very uncommon) a small group might actually respawn fully functionally and get into the chopper. (If they haven't already been reserved by a nonfunctioning group). If I kill them before they enter a chopper they usually respawn fully functional. I am kinda at my witts end, having spent a lot of time trying to debug this yesterday and today, and was hoping that someone here perhaps has some tips. I have added my code (with explanatory comments below). Any help or pointers as to why this might be happening would be truly appreciated. // All playable units are given this as their initialization script PM_fnc_InitPlayable = { Respawn = { private _unit = param[0, objNull, [objNull]]; // Put them in their own group upon respawn, to avoid being spammed with orders etc etc. [_unit] joinSilent createGroup [side _playable, true]; // Just experimentation to see if any of these things affected why the AI's wouldn't move. (group _unit) setBehaviour "CARELESS"; // They don't manage to move to this waypoint either. private _base_helipad_0 = (missionNamespace getVariable "HelipadBase_0"); private _load_wp = (group _unit) addWaypoint [position _base_helipad_0, 10]; _load_wp setWaypointType "MOVE"; _load_wp setWaypointSpeed "FULL"; _load_wp setWaypointCombatMode "YELLOW"; _load_wp setWaypointStatements ["true", "deleteWaypoint [group this, currentWaypoint (group this)];"]; // Tried to see if it was a problem that they were still "ordered" to get in their former vehicle (which is why I unnassign it) [_unit] orderGetIn false; unassignVehicle _unit; [format ["Assigned to vehicle: %1", assignedVehicle _unit]] call PM_fnc_Log; }; QueueLater = { private _playable = param[0, objNull, [objNull]]; sleep 1.0; // Need to sleep a bit, otherwise the choppers aren't ready to be queued into. [_playable] call PM_fnc_EnqueuePassenger; }; private _playable = param[0, objNull, [objNull]]; _playable addEventHandler["Respawn", { [(_this select 0), (_this select 1)] call Respawn; // Send in dead corpse to get weapons information etc from. [(_this select 0)] call PM_fnc_EnqueuePassenger; }]; [_playable] spawn QueueLater; }; // These are supplied as function library functions, to have access to them in the editor and other scripts. // Written with function names here so it is easier to read: PM_fnc_EnqueuePassenger = { private _passenger = param[0, objNull, [objNull]]; gQueuedPassengers pushBack _passenger; }; // Just simple function for creating a BLUFOR helicopter to be used by independents, // and to give different combat mode to gunners and pilots. CreateHelicopter = { private _in_pos = param [0, [], [[]],3]; private _vehicle = "B_Heli_Transport_01_F" createVehicle _in_pos; private _pilots = createGroup [independent, true]; [_vehicle, _pilots, false, "", "I_Helipilot_F"] call BIS_fnc_spawnCrew; deleteVehicle (_vehicle turretUnit[0]); deleteVehicle (_vehicle turretUnit[1]); deleteVehicle (_vehicle turretUnit[2]); private _gunners = createGroup [independent, true]; _gunners createUnit["I_Helipilot_F", position _vehicle, [], 0, "FORM"]; _gunners createUnit["I_Helipilot_F", position _vehicle, [], 0, "FORM"]; { _x moveInTurret[_vehicle, [_forEachIndex + 1]]; } forEach (units _gunners); (units _gunners) orderGetIn true; _vehicle lockTurret [[0], true]; _vehicle lockTurret [[1], true]; _vehicle lockTurret [[2], true]; _vehicle lockDriver true; _gunners setBehaviour "COMBAT"; _gunners setCombatMode "YELLOW"; _vehicle; }; // Sets up the helicopter for its transport route. HelicopterTransport = { private _vehicle = param[0, objNull, [objNull]]; private _base = param [1, objNull, [objNull]]; private _destination = param [2, objNull, [objNull]]; private _pilots = group _vehicle; // Just here to ensure it doesn't take off until people are actually in. waitUntil { count (crew _vehicle) > 3; }; [format ["%1 Moving to target", _vehicle]] call PM_fnc_Log; private _landing_wp = _pilots addWaypoint [position _destination, 10]; _landing_wp setWaypointType "TR UNLOAD"; _landing_wp setWaypointSpeed "FULL"; _landing_wp setWaypointCombatMode "YELLOW"; _landing_wp setWaypointBehaviour "CARELESS"; _landing_wp setWaypointStatements ["true", "deleteWaypoint [group this, currentWaypoint (group this)]"]; // Waiting until we have actually moved to the place where we are unloading people. // < 2 because from what I have seen so far it seems stuff always have at least one waypoint by default (?) waitUntil { count (waypoints _pilots) < 2; }; [format ["%1 Returning home, alive status: %2", _vehicle, (alive _vehicle) and (alive driver _vehicle)]] call PM_fnc_Log; private _load_wp = _pilots addWaypoint [position _base, 10]; _load_wp setWaypointType "MOVE"; _load_wp setWaypointSpeed "FULL"; _load_wp setWaypointCombatMode "YELLOW"; _load_wp setWaypointStatements ["true", "deleteWaypoint [group this, currentWaypoint (group this)];"]; // Waiting until we get back home with queueing up. waitUntil { count (waypoints _pilots) < 2; }; // Double check incase we died before getting back home. if ((alive _vehicle) and (alive driver _vehicle)) then { [format ["%1 arrived home", _vehicle]] call PM_fnc_Log; _vehicle land "GET IN"; [[_vehicle, _base, _destination]] call EnqueueHelicopter; }; }; // Function for respawning helicopter. // Essentially just waits for the helicopter to die. // then removes it completely, and spawns a new one, queues it up, etc. RespawnHelicopter = { private _params = param[0, []]; private _vehicle = _params # 0; private _base = _params # 1; private _destination = _params # 2; waitUntil { (!alive _vehicle) or (!alive driver _vehicle); }; // Want to ensure stuff is actually dead, so it can be removed (?) // Also, don't allow other people to fly the chopper, so might as well just kill the poeple in it. _vehicle setDamage 1; (driver _vehicle) setDamage 1; (_vehicle turretUnit[0]) setDamage 1; (_vehicle turretUnit[1]) setDamage 1; // I don't really want this in here, because if the chopper crashes and people survive, then they should be allowed to get out // However, for some reason, the AI did work one time when this was in. But it's kinda voodoo code, and I don't really like that. { forceRespawn _x; } forEach (crew _vehicle); ["Respawning Helicopter"] call PM_fnc_Log; _vehicle = [position _base] call CreateHelicopter; [[_vehicle, _base, _destination]] call EnqueueHelicopter; [[_vehicle, _base, _destination]] spawn RespawnHelicopter; }; // Just the two global queues. // Don't have the impression that I can easily create classes or something here, so I just made them global like this. // Format in gQueuedHelicopters is: [[<helicopter>, <base helipad>, <target helipad>], ...] gQueuedHelicopters = []; gQueuedPassengers = []; EnqueueHelicopter = { ["Queueing Helicopter"] call PM_fnc_Log; private _chopper = param[0, []]; gQueuedHelicopters pushBack _chopper; [format["Current helicopters queued: %1", count gQueuedHelicopters]] call PM_fnc_Log; }; // Essentially main logic for the queueing system. // As explained in the post. Just wait for enough people and enough choppers to be in the queues // Then pop off enough people for a group, group them together and send em to a chopper. QueueingSystemMain = { // Hack, this should be parameter or, it should perhaps just not be done in here. private _beach_helipad = (missionNamespace getVariable "HelipadBeach_0"); while {true} do { // Wait until enough people to satisfy a chopper going off. waitUntil { (count gQueuedPassengers >= 2) and (count gQueuedHelicopters >= 1); }; // Create groups of for the passengers while {count gQueuedPassengers >= 2 and count gQueuedHelicopters >= 1} do { private _new = createGroup [independent, true]; private _new_group = gQueuedPassengers select[0, 8]; gQueuedPassengers deleteRange[0, 8]; private _heli_info = gQueuedHelicopters deleteAt 0; private _helicopter = _heli_info select 0; [format["Dequeued helicopter, Current chopper queue: %1, Current passenger queue: %2", count gQueuedHelicopters, count gQueuedPassengers]] call PM_fnc_Log; _new_group joinSilent _new; { _x assignAsCargo _helicopter; } forEach (units _new); units _new orderGetIn true; [format["New Group: %1", (units _new)]] call PM_fnc_Log; // Hacky waypoint just to get people into combat when they arrive at their location. private _startup_wp = _new addWaypoint [position _beach_helipad, 400]; _startup_wp setWaypointType "SAD"; _startup_wp setWaypointSpeed "FULL"; _startup_wp setWaypointCombatMode "YELLOW"; _startup_wp setWaypointBehaviour "COMBAT"; // Call on helicopter. [_helicopter, _heli_info # 1, _heli_info # 2] spawn HelicopterTransport; }; }; }; Main = { [] spawn QueueingSystemMain; private _beach_helipad_0 = (missionNamespace getVariable "HelipadBeach_0"); private _beach_helipad_1 = (missionNamespace getVariable "HelipadBeach_1"); private _beach_helipad_2 = (missionNamespace getVariable "HelipadBeach_2"); private _beach_helipad_3 = (missionNamespace getVariable "HelipadBeach_3"); private _base_helipad_0 = (missionNamespace getVariable "HelipadBase_0"); private _base_helipad_1 = (missionNamespace getVariable "HelipadBase_1"); private _base_helipad_2 = (missionNamespace getVariable "HelipadBase_2"); private _base_helipad_3 = (missionNamespace getVariable "HelipadBase_3"); [[objNull, _base_helipad_0, _beach_helipad_0]] spawn RespawnHelicopter; [[objNull, _base_helipad_1, _beach_helipad_1]] spawn RespawnHelicopter; [[objNull, _base_helipad_2, _beach_helipad_2]] spawn RespawnHelicopter; [[objNull, _base_helipad_3, _beach_helipad_3]] spawn RespawnHelicopter; }; // Just personal preference to avoid if possible to have stuff directly in file, I find it harder to see what is executed and what isn't. [] call Main;
  2. valefor

    Respawn with Custom loadout

    Working perfectly, thanks :)
  3. valefor

    Respawn with Custom loadout

    Right, I am trying kinda the same thing. I have a switch inside my code so that I don't need more than one script for variations. However I don't know how to get out the second value ("role") upon respawn. My script looks like this: So in the init line of the squad leader i enter this: null = [this,1] execVM "Loadout_Regular.sqf"; this addeventhandler ["respawn","_this execVM 'Loadout_Regular.sqf'"]; What I am wondering is how do I get the second "value" out after respawn, the one that defines what role/class you will respawn as?
  4. Hello, long time since I posted here, this might be an easy question, but I did not really find what I was looking for when I tried searching so I decided to make a post about it. I am currently trying to make some sort of Helicopter transport mission, where the player plays a pilot and transports AI in and out of the battlefield or other different locations. So far I have just used the get in/get out waypoints, and it is working out when the first playthrough, The problem however arises after death, because the troops are supposed to respawn so I can return to camp and pick them up again. While they do respawn they still go straigth for their last waypoint and don't stand around waiting for me. So I am wondering how you can reset waypoint progression upon death, so that as soon as they respawn they just wait at the pickup waypoint until I arive back. The waypoint progression for the player won't be any problem, because they will just cycle, so if the player die they just continue flying the helicopter once they respawn. The pickup waypoints are also synced which is why I am a bit unsure how to do this. Hoping that I have described the problem well enough and that someone out there could give me an answer :)
  5. It still dont work, but can it have anything to do with the fact that i have _ in the unit names? for example one is called _t1. Because now it says: "Local name in global script" or something. Ok, so I changed the names of the troops, so now I don't get an error anymore, but the troops still lie down. Will they always lie down now matter what if they don't have weapons? Btw, when it stands thislist; who is it acutally reffering to? btw. after testning now, im not really sure if the script work at all.
  6. Ok, so I created a trigger, and when I copy/pasted your code into on activation is just got that classic error saying: Foreach: type string, expected code. Were I supposed to do somethign with that code or just copy it? btw, all these units are playable so that the can respawn using the script I made. I dont know if that has anything to do with it though.
  7. So, I'm working on a mission with a lot of racs soldiers that I need to keep standing, but no matter how hard I try (I've tried to script this myself, but I never get it to work, I'm a bit of a noob though) the units continue to lie down after they have respawned. Would anyone be so nice to make me a script that force the soldiers to stay standing (and now I mean to always stand, not to stand still :P) after respawn? I would be most happy if this was a sqs or any other scripts that is wrote outside the game since its about 100 troops I need to stay standing and I dont want to change the init line of them all :P Ive been working on this mission for a month now and its starting to piss me off :P
  8. Tried both Respawn_west and respawn_west, respawn west and Respawn west
  9. Right since its not working i'l tell you how i do it, tell me what that is wrong. I start the game move into the editor make a player(blufor), make a point called Respawn_west i save it to user mission, i go out of the game and into the mission folder, i make a notepad witch i call Description.ext in the description i type respawn=3; respawndelay=4; i save the document i start up the game start up the editor exports the mission to multiplayer mission i start a server and starts up the map but when i die or push respawn nothing happends exept that i turn into a seagul....
  10. So i have to "Depbo" the Description.ext into the mission PBO file?
  11. Yeah i think ive done that thing, ive been on that page, typed that in but i dont get it to work, yeah ive called the document: Description.ext, but arma cant seem to be able to read it. since the game dont follow my scripting
  12. Sorry if this topic has been made before, but when i where reading over them i didn't understand a **** as i am new to programming and not really understand much, i wondered if someone could give me a exact way in how to make troops/players to respawn, and i would really enjoy if someone could link up or give an example on how a Description.ext (with respawn) would look when it is complete and working,
×