fire_bullet script some changes?

Posted By: Darkyyes

fire_bullet script some changes? - 01/24/09 03:05

the script that is given always shoot straight forward, how would it be if I want it to work with tilted cam as well?

also

is it possible to disable the fire_bullet() function to be triggered through some commands?
Code:
if (mouse_right == 1)
{
mouse_mode = 1; 
my.pan = player.pan; // rotate the player using the mouse
camera.tilt = camera.tilt; // look down at the player
} 

else
{
my.pan -= 6 * (mouse_force.x) * time_step; // rotate the player using the mouse
camera.tilt += mouse_force.y; // look down at the player
on_mouse_left = fire_bullets;
mouse_mode = 0;  
}


the way my code is now, it will still fire bullets
this is also the only place in my script the on_mouse_left is.
Posted By: George

Re: fire_bullet script some changes? - 01/24/09 07:09

This line doesn't help:

camera.tilt = camera.tilt; // look down at the player

It should be something like:

my.tilt = camera.tilt;

Sure, you can call "fire_bullets();" (without the quotes) from another function when you need it.
Posted By: Darkyyes

Re: fire_bullet script some changes? - 01/24/09 10:05

it works perfectly for me george. smile
as when i hold right mouse button the camera wont tilt, its not fps camera.

the reason why I want the "on_mouse_left = fire_bullets();" to be disabled when I hold the right mouse button is because I need it to click on panels thats why I enable mouse_mode.

could you show me a way to disable the on_mouse_left only while I am holding pressing right mouse button? or someway to toogle between the modes?
Posted By: George

Re: fire_bullet script some changes? - 01/24/09 13:13

Well, camera.tilt = camera.tilt is the same with 2 = 2, which is always right but not so useful.
Anyway, put something like this at the very beginning of your fire_bullets() function:

if (mouse_mode == 2) return; // don't fire bullets if the mouse pointer is visible
Posted By: Darkyyes

Re: fire_bullet script some changes? - 01/24/09 22:00

Thanks George smile
Got it to work as it should now. smile
mouse button to work, but any fix for shooting problem?

it shoot straight forward

Code:

action fire_bullets()

{
     if (mouse_right == 1) return;
     {

       VECTOR trace_coords[3];

       vec_set(trace_coords.x, vector(5000, 0, 0)); // trace 5000 quants in front of the player
       // rotate "trace_coords"

       vec_rotate(trace_coords.x, camera.pan); 
       vec_add(trace_coords.x, player.x); // add the resulting vector to player's position
       snd_play(bullet_wav, 100, 0); // play the bullet sound

       if (c_trace (player.x, trace_coords.x, IGNORE_ME + USE_POLYGON) > 0) // the "c_trace" ray has hit something?

       {

               if (you) // and the hit object is an entity?

               {

                       if (you.skill1 == 99) // and the hit entity has its skill1 set to 99?

                       {

                               you.skill50 = 30; // 30 = maximum rotation speed

                       }

               }

       }

}

}

Posted By: George

Re: fire_bullet script some changes? - 01/26/09 12:55

The problem could appear because your

vec_rotate(trace_coords.x, camera.pan);
vec_add(trace_coords.x, player.x);

lines of code rotate trace_coords in the direction given by the camera but add to it the position of the player. They should both be camera or player, depending on what you need.

Let's try to solve the problems one by one, please. No need to open multiple threads.
Posted By: Darkyyes

Re: fire_bullet script some changes? - 01/26/09 16:05

reason for
Code:
vec_rotate(trace_coords.x, camera.pan);
vec_add(trace_coords.x, player.x);

is that i want it to shoot from the player entity
but aim exactly where my camera center is
i can however change my player.pan and camera tilt with mouse
but it will only shoot straight forward not downwards or upwards




but what about the tilt of the camera?
vec_add(trace_coords.x, camera.tilt);
or
vec_rotate(trace_coords.x, camera.tilt);
or something?

if he is going to be aiming up straight and down.
Posted By: Darkyyes

Re: fire_bullet script some changes? - 01/27/09 01:52

ok I got it to work, thanks for clearing that part up, however I script something else inn as well then making it work properly smile
Posted By: George

Re: fire_bullet script some changes? - 01/27/09 13:01

It's good to hear that you've managed to solve the problem by yourself; that's one of the best ways when it comes to learning something.
© 2023 lite-C Forums