Jump to content
Sign in to follow this  
a666

spawn not being executed

Recommended Posts

I am trying to expand the camera.sqf which comes with ARMA2 in order to be able to create a bullet/shell/whatever and send it to a target location (center of the screen).

Unfortunately I haven't been able to do so. For some reason

displayaddeventhandler ["keydown","
...
[_pos, _dirh, _dirv] spawn DEATHCAM_gun; <- this goddamn line103 in deathcam.sqf
...
"];

does nothing.

So I am wondering why this is happening.

You can check the whole code here.

Or the demo mission I am using.

And, if someone a a better idea about how to do what I am trying to do, any contribution is welcome.

Share this post


Link to post
Share on other sites

I am not trying to make a camera which will follow a bullet (a bulletcam).

What I am trying to do is to make a camera which you can move manualy, and on keydown of, let's say, spacebar will create a bullet (createVehicle) at the position of the camera and send it downrange to a position defined by screenToWorld.

Essentially a camera that shoots bullets...

Share this post


Link to post
Share on other sites

That is a bizarre idea and will involve math which makes me cry. Hopefully one of the setVelocity experts will chime in with an idea. :)

Why would you need such a thing anyway?

Share this post


Link to post
Share on other sites

I am basing the code on the massively awesome work of LurchiDerLurch ac130 script (as said in the init function), so the math is mostly resolved, the setVelocity works (even through it is kinda slow). The functions I got work.

The problem is that once the camera.sqf (in my case called deathcam.sqf) is running, this code:

[] spawn somefunctionname;

never executes, even when I called deathcam.sqf with an execVM.

The problem is that inside the code which gets the keyboard events via

displayAddEventHandler ["keydown"], "code or call functionname"];

seems to take the syntax of a sqs script (example, sleep 1; returns error).

Essentialy some guy I play multiplayer with asked me if it was possible to make such a thing (he likes to see things blow up, probably :)), and has I was learning scripting I told him that I would try doing it...

And almost everything is resolved, except this.

Share this post


Link to post
Share on other sites

deathcam_gun.sqf

waitUntil {sleep 0.1};

Share this post


Link to post
Share on other sites

Alright, it's done. And I simplified a lot the whole enchilada.

Twirly, your code gave me plenty of ideas, thank you.

Had to create a sidelogic at the screenToWorld location. Obtain its posASL.

Get the posASL for the cam, a little math, and voila, a death bringin' f'ing cam.

	screenpos = screenToWorld[0.5,0.5];
if (isNil("target")) then {
	target = (createGroup (createCenter sideLogic)) createUnit ["LOGIC", screenpos, [], 0, ""];
}else{
	target setPos screenpos;
};
tpos = getPosASL target;
_pos = getPosASL DEATHCAM;
_muzvel = 20;


//uses some functions from LurchiderLurch AC130
_angles = [_pos,tpos]call LDL_getObjectAngles;
_dirh = [_angles select 0]call LDL_normalizeAngle;
_dirv = [_angles select 1]call LDL_normalizeAngle;

_spread = (random (DEATHCAM_spread select DEATHCAM_currentspread))/10;

_dirh = _dirh + sin(random 360)*_spread;
_dirv = _dirv + cos(random 360)*_spread;

_r_sphere = 100;
_z = _r_sphere* cos(_dirv - 90);
_r = sqrt(_r_sphere^2 - _z^2);
_x = sin(_dirh)*_r;
_y = cos(_dirh)*_r;

_vel = [_x * _muzvel,_y * _muzvel,_z * _muzvel];

_bullet = (DEATHCAM_ammo select DEATHCAM_currentammo) createVehicle _pos;
_bullet setPosASL _pos;

_bullet setVelocity _vel;

Edited by a666

Share this post


Link to post
Share on other sites

Cool mate.... I'll give your routine a little spin later with some cattle for ammo. Always fun!!!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×