Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,731 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
My bullets don't go to the middle of the crosshair.Look -> #303295
12/27/09 22:24
12/27/09 22:24
Joined: Dec 2009
Posts: 74
Romania,Bucharest
Ted22 Offline OP
Junior Member
Ted22  Offline OP
Junior Member

Joined: Dec 2009
Posts: 74
Romania,Bucharest
My bullets don't go to the middle of the crosshair.Them aren't going to the middle of my crosshair.pcx,them are going to where the crosshair.pcx begins(on x,y)...Please help!Here is a part of the code:

.............................

mouse_mode=1;
mouse_map = crosshair_pcx;
wait (2);
while (1)
{
mouse_pos.x = 400;
mouse_pos.y = 300;
camera.pan -= mouse_force.x;
camera.tilt += mouse_force.y;

wait (1);
}

..............................

function fire_bullets()

{
VECTOR bullet_pos[3];
vec_for_vertex(bullet_pos, guard, 6);
ent_create("bullet.mdl", bullet_pos, move_bullets);
while(mouse_mode = 1)
{
vec_to_angle(guard.pan,mouse_dir3d);
wait(1);

}

Last edited by Ted22; 12/27/09 22:29.
Re: My bullets don't go to the middle of the crosshair.Look -> [Re: Ted22] #303296
12/27/09 22:26
12/27/09 22:26
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
place the crosshair at the mouse_pos and than subtract the half of the size of the crosshair. That you must do with the x and y cordinates wink

Re: My bullets don't go to the middle of the crosshair.Look -> [Re: Rei_Ayanami] #303297
12/27/09 22:28
12/27/09 22:28
Joined: Dec 2009
Posts: 74
Romania,Bucharest
Ted22 Offline OP
Junior Member
Ted22  Offline OP
Junior Member

Joined: Dec 2009
Posts: 74
Romania,Bucharest
I tried...doesen't work

Re: My bullets don't go to the middle of the crosshair.Look -> [Re: Ted22] #303298
12/27/09 22:44
12/27/09 22:44
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
oh, sorry I didn't see that you use the crosshair as the mouse map

but when i look at your code again, i see many many mistakes!


first: not VECTOR bullet_pos[3] because you don't need an vector array!

--> VECTOT bullet_pos;

second: while(mouse_mode = 1) that is no comparision

--> while(mouse_mode == 1)
but why do you need that?
if you want an endless loop use while(1)

third: you turn your guard, not the bullet!
--> vec_to_angle(your_bullet.pan, mouse_dir3d);

now to your problem:

use this:
VECTOR temp;
temp.x = mouse_pos.x - bmap_width(mouse_map)/2;
temp.y = mouse_pos.y - bmap_height(mouse_map)/2;
temp.z = 5000;
vec_to_screen(temp, camera);
c_trace(guard.x, temp, 0);
vec_set(temp, target.x);
vec_sub(temp, guard.x);
vec_to_angle(guard.pan, temp);


i hope i understand you right laugh

Re: My bullets don't go to the middle of the crosshair.Look -> [Re: Rei_Ayanami] #303299
12/27/09 22:45
12/27/09 22:45
Joined: Dec 2009
Posts: 74
Romania,Bucharest
Ted22 Offline OP
Junior Member
Ted22  Offline OP
Junior Member

Joined: Dec 2009
Posts: 74
Romania,Bucharest
can i modify this code in anyway to do what i want to do?

Re: My bullets don't go to the middle of the crosshair.Look -> [Re: Rei_Ayanami] #303304
12/27/09 23:10
12/27/09 23:10
Joined: Dec 2009
Posts: 74
Romania,Bucharest
Ted22 Offline OP
Junior Member
Ted22  Offline OP
Junior Member

Joined: Dec 2009
Posts: 74
Romania,Bucharest
Well,it's ur code is very logic but i guess i did something wrong...still doesen't works.
(vec_to_angle(guard.pan,mouse_dir3d);
<- i did it like this becos in another command to set bullet.pan = guard.pan;My code looks like this now:
function fire_bullets()

{
VECTOR bullet_pos;
vec_for_vertex(bullet_pos, guard, 6);
ent_create("bullet.mdl", bullet_pos, move_bullets);
while(1)
{
VECTOR temp;
temp.x = mouse_pos.x - bmap_width(crosshair_pcx)/2;
temp.y = mouse_pos.y - bmap_height(crosshair_pcx)/2;
temp.z = 5000;
vec_to_screen(temp, camera);
c_trace(guard.x, temp, 0);
vec_set(temp, target.x);
vec_sub(temp, guard.x);
vec_to_angle(guard.pan, temp);
vec_to_angle(guard.pan,mouse_dir3d);
wait(1);

}
}

Re: My bullets don't go to the middle of the crosshair.Look -> [Re: Ted22] #303305
12/27/09 23:17
12/27/09 23:17
Joined: Mar 2007
Posts: 112
MikeS Offline
Member
MikeS  Offline
Member

Joined: Mar 2007
Posts: 112
Ok, do i understand your problem tight?

Your bullets dont land where your crosshair is, is that right?

How do you check this? Targeting something, and see the bullet hit something in an different position?

Question to this, do they more often land at the upper side of your crosshair?

Greetings Mike

Re: My bullets don't go to the middle of the crosshair.Look -> [Re: MikeS] #303306
12/27/09 23:22
12/27/09 23:22
Joined: Dec 2009
Posts: 74
Romania,Bucharest
Ted22 Offline OP
Junior Member
Ted22  Offline OP
Junior Member

Joined: Dec 2009
Posts: 74
Romania,Bucharest
Yes,ur right,so imagine a square(that is my crosshair.pcx) and my bullets go to the sides of that square not to the middle.
I want my bullets to go exacly to the middle of that square.

Re: My bullets don't go to the middle of the crosshair.Look -> [Re: Ted22] #303307
12/27/09 23:26
12/27/09 23:26
Joined: Mar 2007
Posts: 112
MikeS Offline
Member
MikeS  Offline
Member

Joined: Mar 2007
Posts: 112
could you show me your move_bullets function?

Re: My bullets don't go to the middle of the crosshair.Look -> [Re: Ted22] #303309
12/27/09 23:32
12/27/09 23:32
Joined: Mar 2007
Posts: 112
MikeS Offline
Member
MikeS  Offline
Member

Joined: Mar 2007
Posts: 112
Originally Posted By: Ted22
Well,it's ur code is very logic but i guess i did something wrong...still doesen't works.
(vec_to_angle(guard.pan,mouse_dir3d);
<- i did it like this becos in another command to set bullet.pan = guard.pan;My code looks like this now:
function fire_bullets()

{
VECTOR bullet_pos;
vec_for_vertex(bullet_pos, guard, 6);
ent_create("bullet.mdl", bullet_pos, move_bullets);
while(1)
{
VECTOR temp;
temp.x = mouse_pos.x - bmap_width(crosshair_pcx)/2;
temp.y = mouse_pos.y - bmap_height(crosshair_pcx)/2;
temp.z = 5000;
vec_to_screen(temp, camera);
c_trace(guard.x, temp, 0);
vec_set(temp, target.x);
vec_sub(temp, guard.x);
vec_to_angle(guard.pan, temp);
// vec_to_angle(guard.pan,mouse_dir3d);
wait(1);

}
}


vec_to_angle(guard.pan,mouse_dir3d); try with commenting this out, you set the pan of the guard again on the pan of mouse_dir3d which is the upper left corner of your mouse map.
With this vec_to_angle(guard.pan, temp); you set it to the middle of the crosshair how i understand this.
If you then use bullet pan = guard pan, it should work i think

Page 1 of 2 1 2

Moderated by  HeelX, rvL_eXile 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1