dreadedentity 278 Posted September 28, 2014 Hello all, I got bored again tonight and decided to mess around with Event Handlers. Turns out making a gun that shoots strider's is easy! I wish my video didn't come out at 360p for some reason and is blurry as hell. add to your init.sqf player addEventHandler ["Fired", { _bullet = _this select 6; _dir = _this select 0; _velocity = velocity _bullet; [_bullet, _velocity, _dir] spawn { sleep 0.02; _newPos = getPos (_this select 0); deleteVehicle (_this select 0); _newBullet = createVehicle ["I_MRAP_03_F", _newPos, [], 0, "NONE"]; //_newBullet setDir (_this select 2); //breaks setVelocity for some reason. do not uncomment. _newBullet setVelocity (_this select 1); }; }]; Share this post Link to post Share on other sites
das attorney 858 Posted September 28, 2014 (edited) Nice effort. Some of the syntax is wrong though which is why you had issues with setDir plus you don't need to spawn unless you really want to. player addEventHandler ["Fired", { _bullet = _this select 6; _unit = _this select 0; _newPos = _unit modelToWorld [0,8,1]; _veh = createVehicle ["I_MRAP_03_F",_newPos,[],0,"CAN_COLLIDE"]; _veh setDir getDir _unit; _veh setVelocity velocity _bullet; deleteVehicle _bullet; }]; Edited September 28, 2014 by Das Attorney stuff Share this post Link to post Share on other sites
dreadedentity 278 Posted September 28, 2014 (edited) Thanks, I still get commands wrong sometimes too! Anyway, the reason I had spawned a new thread was specifically for the sleep statement, you don't want to spawn a car right at the barrel. Maybe I should have tested that, though. I just thought it was best to avoid it so I don't inadvertently create an awesome suicide method. :p Also, I noticed that sometimes the cars would not be spawned where they should (sometimes they'd be off to the side), is that related to the "CAN_COLLIDE" you changed? Edited September 28, 2014 by DreadedEntity Share this post Link to post Share on other sites
jshock 513 Posted September 28, 2014 Yes the CAN_COLLIDE tells the engine that the object being created doesn't need to go through a "safe position" to spawn check, basically putting it where it's "supposed" to be. Now obviously if it ends up somewhere without proper space, a vehicle might just explode, but I never minded a fireworks show here and there :p. Share this post Link to post Share on other sites