Lucky44 13 Posted March 18, 2012 (edited) Here's what I'm trying to do: spawn a vehicle, and then every 3 seconds, check to see if it's taken 25% damage or more, and if so, setDamage to 100% on it. Here's what I'm trying in a script that's called by a trigger on map: _tankSquad2 = createGroup EAST; Tank4 = [(getMarkerPos "mrk_pos1"), 90, "T34_TK_EP1", _tankSquad2] call bis_fnc_spawnvehicle; publicVariable "Tank4"; _damTot = (damage Tank4); while _damTot < 1 do { if ((damage Tank4) >= .25) then {Tank4 SetDamage 1}; sleep 3; _damTot = (damage Tank4); // update value to current level }; This all works fine on a vehicle placed on the map in editor, and the spawning works fine, but after spawning, it creates an "Error damage: Type Array, expected Object". Actually, at the PV line, if I used that line, it throws the error there ("Type Array, expected Object"). I assume that the name I'm giving the tank (e.g., Tank4) is not getting associated with the tank object. What am I doing wrong there? Edited March 18, 2012 by Lucky44 Share this post Link to post Share on other sites
fencr0c 10 Posted March 18, 2012 BIS_fnc_spawnVehicle returns an array, second element of array is the vehicle created. Share this post Link to post Share on other sites
Craig_VG 20 Posted March 18, 2012 So it would be: _damTot = (damage (Tank4 select 1)); Share this post Link to post Share on other sites
Lucky44 13 Posted March 18, 2012 Gah! Thank you both so much. I wasted a couple hours on that...duh. ---------- Post added at 04:50 PM ---------- Previous post was at 04:37 PM ---------- Now wait a second. That got me thinking: in the first line of my code above, I createGroup and give it the name _TankSquad2. In the BIS_fnc_SpawnVehicle line, I refer to that group. I thought I was assigning the new vehicle to that group. Which seems to be right. But is "Tank4" also a name for the group? Or is it just an array of the UNITS in the group...must be that, huh? OK, I could just not post this, but I think I'll leave it for future people who might be as confused as I've been :) ---------- Post added at 05:23 PM ---------- Previous post was at 04:50 PM ---------- And here's another twist: the array created by BIS_fnc_spawnVehicle is the array of units (crewmen) in the vehicle. The FIRST element of the array, i.e., (tank4 select 0), is actually the VEHICLE. ---------- Post added at 05:41 PM ---------- Previous post was at 05:23 PM ---------- So here's what my final code looks like, cleaned up a bit: _veh = (tank4 select 0); // set the name of the vehicle Group Array, from BIS_fnc_spawnVehicle, here _damTot = damage _veh; while {_damTot < 1} do { if ((damage _veh) >=0.20) then {_veh SetDamage 1}; // set this level so that if there's enough damage for crew to bail out, vehicle will be destroyed sleep 3; _damTot = (damage _veh); }; Thanks again for the help! Share this post Link to post Share on other sites