Jump to content

DankanX37

Member
  • Content Count

    38
  • Joined

  • Last visited

  • Medals

Community Reputation

29 Excellent

About DankanX37

  • Rank
    Private First Class

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. It seems that when Shellcore projectiles are being used, the vehicle is created at [0,0,0] and it moves kinda weirdly in the air as if it tried to follow the shell but is stuck on the ground
  2. I made this code for a mod, it's a server-sided script that detects created shells or rockets and attaches a plane to them in order to make them targettable via radar. (In this case, I used a plane belonging to A3 vanilla in order to see it better, the real one has no model). The first two lines are just used to debug this via the console, plus some stuff I omitted. The issue is that when I fire a shell, I can see the plane briefly appearing and then it disappears and the shell isn't trackable, then once it explodes I see the "Deleted" message, whereas if I fire a missile I can see the plane being created and it's properly attached to it. The systemchat messages are: Local: true, Server: true, Owner: 0 (shells have 0 for ID, rockets have a number like 3 or 4) [193e96c6040# 414: plane_fighter_03_f.p3d] Deleted:193e96c6040# 414: plane_fighter_03_f.p3d There are no .rpt errors, I was wondering what could be the issue here since it works in SP and with rockets in MP... if(!isServer) exitWith {}; if(!isNil "lastId") then {removeMissionEventHandler ["ProjectileCreated", lastId];}; lastId = addMissionEventHandler ["ProjectileCreated", { params ["_projectile"]; if(_projectile isKindOf "ShellCore" or _projectile isKindOf "MissileCore") then { ("Local:" + str(local _projectile) + " - Server:" + str(isServer) + " - Owner: " + str(owner _projectile)) remoteExec ["systemChat", 0]; [_projectile] spawn { _projectile = _this select 0; sleep 0.1; private _localFake = "I_Plane_Fighter_03_CAS_F" createVehicle (getPos _projectile); _localFake allowDamage false; _localFake attachTo [_projectile, [0,2,0]]; [str (attachedObjects _projectile)] remoteExec ["systemChat", 0]; while {alive _projectile} do { sleep 0.04; }; ("Deleted:" + str _localFake) remoteExec ["systemChat", 0]; deleteVehicle _localFake; }; }; }];
  3. Yes apparently switching it to if(!local _unit) exitWith {} fixed this issue, though I find it strange that it's not running on the server, my fear is that it will run for every client... On top of that, I have the same issue with a function set to postInit, it has the exact same structure and once again, it's not running. I do want to mention that I am using FASTER and I have set the mod to run on Server, Client, and Headless. Could this have something to do with the matter?
  4. So I made a mod where I created a vehicle and I used the vehicle's "init" event handler. From the event handler I remotely execute a function: [_this # 0] remoteExec ['function', 2, false]; The first line of the function contains this: if(!isServer) exitWith {} I'm being told that the script isn't running and I was wondering what was wrong with this, everything compiles and works in SP, but on MP (dedicated servers) nothing works. Could it be I need to setup CfgRemoteExec? Thanks.
  5. Hello, I recently made an Iron Dome mod: Steam workshop link I am also releasing a standalone script used for guiding the missile, currently, 3 modes are available: Augmented proportional navigation APN Proportional navigation PN Pure pursuit LOS Here is the code: You can call this function (script) by using: [missile, target, [parameters]] execVM... Parameter is an array containing: Missile max speed: The speed the missile will travel (good values between 200 and 1000) Guidance law: The law that will be used: 0 - APN (best), 1 - PN, 2 - LOS Guidance gain: A constant typically between 3 and 5 Time to max: Missile speed will increase linearly until it reaches the max //params ["_missile", "_target", "_speed",]; private _missile = param[0]; private _target = param[1]; private _parameters = param[2]; //Speed, guidance, N private _speed = _parameters select 0; private _guidance = _parameters select 1; private _N = _parameters select 2; private _timeToMax = _parameters select 3; if(isNull _target) exitWith {}; //Weird issue with APN when engaging missiles idk _targetIsMissile = (_target isKindOf "MissileBase"); //Variables for the missile and logic private _increment = 0.02; private _currSpeed = _speed / 100; private _k = 1; private _initialDist = (_missile distance _target); private _closeEncounter = false; private _medianLoops = 5; _lowestDist = _initialDist; _incrementSpeed = (_speed - _currSpeed) / _timeToMax; //Vectorial quantities _guidVel = [0,0,0]; _leadAcc = [0,0,0]; _lastB = [0,0,0]; _tgtAccNorm = [0,0,0]; private _time = time; _loop = 0; while {alive _target and alive _missile} do { //Elapsed time _deltaT = (time - _time); //Speed _currSpeed = _currSpeed + _incrementSpeed * _deltaT; _currSpeed = _currSpeed min _speed; //LOS _posA = getPosASL _missile; _posB = getPosASL _target; _LOS = _posB vectorDiff _posA; _steering = _posA vectorFromTo _posB; _dist = _missile distance _target; //Relative velocity _velA = velocity _missile; _velB = velocity _target; _relVelocity = _velB vectorDiff _velA; if(_dist < _lowestDist) then { _lowestDist = _dist; }; //Was close if(_dist < 1000) then { _closeEncounter = true; }; //Now is far if(_closeEncounter and (_dist > 1500)) then { _mine = createMine ["DemoCharge_F", getPosATL _missile, [], 0]; _mine setDamage 1; deletevehicle _missile; }; switch (_guidance) do { //APN case 0: { //Impact Time Control Cooperative Guidance Law Design Based on Modified Proportional Navigation //https://www.mdpi.com/2226-4310/8/8/231/pdf //formula [30] _tGo = (_dist/(speed _missile)*(1+ ((acos(_velA vectorCos _steering)/90)^2)/(2*(2 * _N - 1)))); if(isNil "_tgo") then {continue}; //Zero effort miss _ZEM = _LOS vectorAdd (_relVelocity vectorMultiply _tGo); _losZEM = _ZEM vectorDotProduct _steering; _nrmZEM = (_ZEM vectorDiff (_steering vectorMultiply _losZEM)); //Weird behaviour when attacking missiles if(!_targetIsMissile) then { if(_loop == _medianLoops) then { //Target accelleration _tgtAcc = _leadAcc vectorMultiply (1/_medianLoops); _tgtAccLos = _tgtAcc vectorDotProduct _steering; _tgtAccNorm = _tgtAcc vectorDiff (_steering vectorMultiply _tgtAccLos); _loop = 0; } else { _tgtAcc = (_velB vectorDiff _lastB) vectorMultiply (1/_increment); _lastB = _velB; _leadAcc = _leadAcc vectorAdd _tgtAcc; _loop = _loop + 1; }; }; //augmented prop nav with ZEM and lowered proportional gain _leadAcc = (_nrmZEM vectorMultiply _N) vectorMultiply (1/(_tGo ^ 2)) vectorAdd (_tgtAccNorm vectorMultiply (_N/4)); _guidVel = (_leadAcc vectorMultiply _increment) vectorAdd _velA; }; //PN case 1: { //Calculate omega _rotation = _LOS vectorCrossProduct _relVelocity; _distance = _LOS vectorDotProduct _LOS; _rotation = _rotation vectorMultiply (1/_distance); //Desired accelleration to intercept _leadAcc = (_relVelocity vectorMultiply _N) vectorCrossProduct _rotation; _guidVel = (_leadAcc vectorMultiply _increment) vectorAdd _velA; }; //Pure pursuit case 2: { _guidVel = _steering; } }; //Set new speed _guidVel = ((vectorNormalized _guidVel) vectorMultiply _currSpeed); _missile setVectorDir _guidVel; _missile setVelocity _guidVel; //drawLine3D [_posA, _posA vectorAdd _LOS, [1,1,1,1]]; sleep _increment; }; //If the target died or the missile timedout make it blow in mid air if(alive _missile) then { waitUntil {(getposATL _missile select 2) > 100}; if(alive _target) then { sleep random 1; }; deletevehicle _missile; _mine = createMine ["DemoCharge_F", getPosATL _missile, [], 0]; _mine setDamage 1; }; true; This is more aimed at developers who want to build missile-based systems and for one reason or the other can't use the missile locking capability.
  6. This is a script I made that allows the vanilla C-RAM to attack incoming artillery shells. You can find the mod here: https://steamcommunity.com/sharedfiles/filedetails/?id=2825319340 or if you want 100% vanilla then use the following composition: https://steamcommunity.com/sharedfiles/filedetails/?id=2825313831 The target selection logic can be changed via action menu: Random Distance/Speed bias Thread bias: The system will engage the shell that is going to land the closest factoring time. Code: _unit = param[0]; _distance = param[1, 2500]; _tgtLogic = param[2, 0]; _typeArray = param[3, ["ShellBase","RocketBase","MissileBase"]]; _ignored = param[4, ["ammo_Missile_rim116"]]; if(_unit getVariable ["init",false]) exitWith {}; _unit setVariable ["init", true]; _unit setVariable ["_tgtLogic", _tgtLogic]; _unit addAction ["Change targeting mode", { params ["_target", "_caller", "_actionId", "_arguments"]; _tgtLogic = _target getVariable ["_tgtLogic", 0]; _tgtLogic = _tgtLogic + 1; if(_tgtLogic > 3) then { _tgtLogic = 0; }; _out = ""; switch (_tgtLogic) do { case 0: { _out = "Random selection"; }; case 1: { _out = "Distance/Speed bias"; }; case 2: { _out = "Threat bias"; }; default {_out = "No targeting"}; }; _id = owner _caller; ["Logic changed to: " + _out] remoteExec ["hint", _id]; _target setVariable ["_tgtLogic", _tgtLogic]; }, nil, 10, false, false, "", "!(_this in _target)", 10]; //Makes it better { _x setSkill 1; }foreach crew _unit; //Main loop _loops = ((count _typeArray) - 1); scopeName "start"; while {alive _unit} do { _tgtLogic = _unit getVariable ["_tgtLogic", 0]; _entities = []; for "_i" from 0 to _loops do { _near = _unit nearObjects [_typeArray select _i, _distance]; _entities append _near; }; _entities = _entities select {!(typeOf _x in _ignored)}; //_entities = _entities select {((getPosATL _x) select 2) > 25}; _entities = _entities select {alive _x}; if(count _entities > 0) then { //Init all the entities { if(_x getVariable ["toInit",true]) then { _x setVariable ["toInit",false]; [_x] spawn { _x = _this select 0; while {alive _x} do { _entities = (_x nearObjects ["BulletBase", 5]); if(count _entities > 0) then { _mine = createMine ["APERSMine", getPosATL _x, [], 0]; _mine setDamage 1; deletevehicle _x; }; sleep 0.02; }; _fake = (_x getVariable ["attachedObject", objNull]); detach _fake; deletevehicle _fake; }; }; }foreach _entities; //Pick one _target = objNull; _fake = objNull; _p = -1; _lastP = _p; _first = true; _wep = currentWeapon _unit; _g = 9.81; { switch (_tgtLogic) do { //Pure random case 0: { _target = selectRandom _entities; }; //Distance/Speed bias + direction case 1: { _vel = velocity _x; _dist = _unit distance _x; _aimQuality = _unit aimedAtTarget [_x, _wep]; _p = abs((_dist / _distance) -(_vel select 2)/100 + _aimQuality*2); if(_p > _lastP or _first) then { _target = _x; _lastP = _p; _first = false; }; }; //Threat bias case 2: { _vel = velocity _x; _pos = getPosASL _x; _alt = _pos select 2; _v0 = -(_vel select 2); //Negative when going up _root = ((_v0 ^ 2) - 2 * _g * (-_alt)); if(_root < 0) then {continue}; //Time to impact _t = round((-_v0 + sqrt(_root)) / _g); //Space travelled - approximation!!! _spaceX = ((_pos select 0) + (_vel select 0) * _t); _spaceY = ((_pos select 1) + (_vel select 1) * _t); _nPos = [_spaceX, _spaceY, 0]; _p = (_unit distance2d _nPos) + (_t * 10); if(_p < _lastP or {_first}) then { _target = _x; _lastP = _p; _first = false; /* systemChat (str _x); systemChat ("p:" + str _p); systemChat ("t:" + str _t); */ }; }; default {_target = objNull;}; }; }foreach _entities; if(isNull _target) then {breakTo "start";}; _target allowdamage false; _fake = (_target getVariable ["attachedObject", objNull]); if(isNull _fake) then { _fake = "B_Plane_Fighter_01_Stealth_F" createVehicle [0,0,100]; _fake hideObjectGlobal true; _fake allowdamage false; _fake attachTo [_target, [0,5,0]]; _target setVariable ["attachedObject", _fake]; }; _unit reveal _fake; (side driver _unit) reportRemoteTarget [_fake, 3600]; _fake confirmSensorTarget [west, true]; if(!isNull _fake) then { _unit doTarget _fake; _time = time; waitUntil{_unit aimedAtTarget [_fake, _wep] > 0.2 or (time - _time) > 2}; for "_i" from 1 to 100 do { if(!alive _target) exitWith {}; if(isNull _fake) exitWith {}; //Every 10 steps if((_i % 10) == 0) then { _unit doTarget _fake; }; if((_unit weaponDirection _wep) select 2 > 0.1) then { if(_unit aimedAtTarget [_fake, _wep] > 0.33) then { [_unit, _wep, [0]] call BIS_fnc_fire; }; }; sleep 0.013; //75 rounds per second }; //sleep 1; detach _fake; deletevehicle _fake; _target setVariable ["attachedObject", objNull]; }; }; sleep 0.1; }; removeallActions _unit; I'm also going to make a missile-based interceptor similar to the Israeli's iron dome.
  7. Hello, I am trying to re-create the Drone 40 UAV, I am looking for a modeler with some experience both with modeling and importing the stuff into Arma 3. (Animations)
  8. Hello everyone, I'm currently in the process of making a "Drone 40" mod. The idea is to replicate the DefendTex UAV-40 autonomous grenade, soo far I've written all of the code in regards to its logic Showcase. The problem is that I have pretty much zero experience with modeling and have no idea how to import one into the Arma engine, thus I am looking for a modeler to help me with this (mainly the import aspect, model -> p3d). If you're interested we can talk about this further.
  9. I solved this, I resorted to using the position of the module mixed with nearestObject in order to obtain the newly created mine and finish from there.
  10. Apparently, I was overwriting the default EH for the module, I fixed this by doing: class EventHandlers:EventHandlers { class myMod { init = "systemChat 'init vehicle';"; } } and class ModuleMine_F: ModuleEmpty_F { class EventHandlers; }; Tough the script still doesn't run on the created object but on the module.
  11. Hello everyone, I'm making a mod that adds a special mine, soo far I've written both the script and added the mine in the cfgAmmo, vehicles, mag etc... I'm now trying to make it work with Zeus interface, I've created the module and I'm able to spawn the mine, I wanted to hook my function using the "eventHandlers" class in the config. class myMine: ModuleMine_F { //removed for brevity _ammo = "myAmmo"; class EventHandlers { init = "systemChat 'init vehicle';"; }; }; But this seems to bug the module and the mine doesn't spawn. I tried to use the cfgAmmo EH: class myAmmo: ATMine_Range_Ammo { //removed for brevity class EventHandlers { init = "systemChat 'init ammo';"; }; }; But this one doesn't even fire when the mine is placed. Both are registered and visible in the Config Viewer. Is there a way to make a curator placed mine run a script on spawn? Thanks.
  12. Is there a way to create a bomb and make it home a laser target? Just wanted to know if there's a function for that. Thanks.
  13. heli_0 limitSpeed 60; heli_0 flyInHeight 130; //_i = 0; _dirS = 0; for [{_i=0}, {_i<12}, {_i=_i+1}] do { _dirS = _dirS + 30; _idealPos = tgtCenter getRelPos [350, _dirS]; group driver heli_0 addWaypoint [_idealPos, 0, _i]; } My solution was creating my own loiter script
  14. I'm trying to make a blackfish orbit an area while staying at a low speed, I tried with both limitspeed and forcespeed but the blackfish isn't slowing, I tried with other vehicles and it does work, so, my question is, can you limit loiter speed?
  15. DankanX37

    SCRIPT Cruise missile

    Yes, take a look at my showcase mission, it's inside the description.ext, anyway, I'll leave it here. "[] spawn fnc_CruiseMissile" To avoid spamming, it's a bit more complicated if you use triggers.
×