Jackael 10 Posted September 1, 2009 (edited) I would like to know if there is a way to make it so that when the player is in a specific location they have the ability to detonate satchel charges that are owned by an AI. By specific location I mean that the player can't detonate them unless they are IN the location (trigger would work here) Also I need a script for making an AI place a satchel charge in a specific location (i.e. next to a truck to blow it up) when a trigger is activated. Edited September 1, 2009 by Jackael Share this post Link to post Share on other sites
kylania 568 Posted September 1, 2009 TOUCHOFF unitOne action ["TOUCHOFF", unitTwo] Soldier 'unitOne' plays the action animation. UnitTwo's satchels are "touched off". UnitTwo must be within range (300m) of his satchels to touch them off. Example: player action ["TOUCHOFF", AIunitname] To make an AI set a bomb, use unitName fire "Pipebombmuzzle"; Share this post Link to post Share on other sites
Jackael 10 Posted September 1, 2009 Thanks a lot, these are very helpful =] Share this post Link to post Share on other sites
nomdeplume 0 Posted September 2, 2009 In case it's helpful, here's a "placebombs" script I made to do something similar. It can be executed on a unit, takes another object (source of satchel charges) as a parameter, a string of code to run once complete, and an arbitrary number of marker names which serve as the location to place the bombs. I execute it from a waypoint with a command like: nil = [leader this, uh1y_1, "bombs1=true", "tgt_4", "tgt_1", "tgt_2", "tgt_3"] execVM "placebombs.sqf" This causes the leader of the group that activated the waypoint to move to "uh1y_1" (a helicopter, but can be any object which has satchel charges in its cargo, e.g. an ammo crate), pick up bombs until it has 4 of them (because of the 4 dropoff points), then go to each one in turn and place a satchel charge. Once finished, it returns to its starting location, and then executes the code "bombs1=true". I use that as a flag to continue moving on from the present waypoint (along with bombs2=true, which is another execution of the same script on a different unit with different target positions). The target positions are markers with icon type 'none' so they don't appear in the briefing map etc. This is probably way overkill for your needs but might be helpful in some way to someone. There's a bunch of 'sideChat' commands in there to let you know its status which should make it easy to remove bits of code you don't actually need. Obviously if you do use this you should remove those once you've tested it and you're happy with it, as they kind of kill the immersion a bit. placebombs.sqf private ["_unit", "_ammo", "_dcmd", "_startpos", "_movescript"]; private ["_bombsneeded", "_index", "_marker"]; _unit = _this select 0; _ammo = _this select 1; _dcmd = _this select 2; _startpos = position _unit; _movescript = [_unit, position _ammo, 15] execVM "movecloseto.sqf"; waitUntil {ScriptDone _movescript}; _bombsneeded = count _this - 3; _unit sideChat format["Grabbing some bombs (%1)", _bombsneeded]; while { {_x == "PIPEBOMB"} count magazines _unit < _bombsneeded } do { _unit action ["TakeMagazine", _ammo, "PipeBomb"]; sleep 3; }; _index = 3; while {_index < count _this} do { _marker = _this select _index; _unit sideChat format["Going to position #%1, %2", _index, _marker]; _movescript = [_unit, getMarkerPos _marker, 1] execVM "movecloseto.sqf"; waitUntil {ScriptDone _movescript}; _unit Fire ["pipebombmuzzle", "pipebombmuzzle", "pipebomb"]; _index = _index + 1; }; _unit sideChat "Bombs placed, returning to start position"; _movescript = [_unit, _startpos] execVM "movecloseto.sqf"; waitUntil {ScriptDone _movescript, 2}; call compile _dcmd; This is the movecloseto.sqf referenced above. I wanted to make something clever and bullet-proof but eventually gave up because there's lots of issues with trying to get an AI close to something. I was using a helicopter as the pickup point for satchels and unless they're boarding it, AI really don't like getting anywhere near them. movecloseto.sqf private ["_unit", "_dest", "_dist", "_curdistance", "_mindistance"]; _dist = 5; _unit = _this select 0; _dest = _this select 1; if (count _this >= 3) then { _dist = _this select 2; }; _unit doMove _dest; _curdistance = _unit distance _dest; _mindistance = _curdistance; while {_curdistance > _dist} do { sleep 0.5; _curdistance = _unit distance _dest; if (_curdistance >= _mindistance) then { _unit doMove _dest; }; if (_curdistance < _mindistance) then { _mindistance = _curdistance; }; }; _curdistance Share this post Link to post Share on other sites