Author Topic: Where the bullet collide  (Read 914 times)

0 Members and 1 Guest are viewing this topic.

Offline vladdark

  • Major(1)
  • Posts: 11
Where the bullet collide
« on: January 12, 2009, 02:02:13 pm »
It's possible in any way to know where (x,y) a bullet collide, even on the ground? I know how to do that if the bullet hit an enemy or a teammate with FriendlyFireOn with OnPlayerDamage and GetPlayerXY. But how about polygons?

For instance: Major shoot with a scripted Desert and, if the bullets don't touch any enemys, medikits will spawn (SpawnObject) on where the bullet hit on the ground. That's just an example, that's not exactly what I'm trying to do.

Maybe with AppOnIdle+GetPlayerStat+RayCast? But that doesn't work with slow bullets (e.g. M79, Law) cause the trajetory isn't a straight line, besides, it's strongly doubtful... Any ideas?

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Where the bullet collide
« Reply #1 on: January 12, 2009, 02:07:29 pm »
i think you can do that with a knife, look for the portal script

Offline vladdark

  • Major(1)
  • Posts: 11
Re: Where the bullet collide
« Reply #2 on: January 12, 2009, 03:17:28 pm »
Thanks, man, I completely forgot about that mod, now I think I can do that. Thanks. :)

Edited:
Only to note, here the code I wrote to locate a knife shooted by anyone, maybe that can help somebody who want to do that and doesn't have any clue:
Code: [Select]
var
numberID: byte;

procedure AppOnIdle(Ticks: integer);
begin
for numberID:=1 to 32 do begin
if GetObjectStat(numberID,'Active') and GetObjectStat(numberID,'Style') = 25 then
// That WriteConsole is only to debug
WriteConsole(0,'X: '+GetObjectStat(numberID,'X')+' / Y: '+GetObjectStat(numberID,'Y'),$EE81FAA1);
end;
end;
The code is really simple. =P
« Last Edit: January 12, 2009, 07:49:10 pm by vladdark »

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Where the bullet collide
« Reply #3 on: January 15, 2009, 03:43:16 pm »
hmm... have you tried that with a lot of other objects on the map at the same time? Cause i think max ID is something like 100

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: Where the bullet collide
« Reply #4 on: January 15, 2009, 07:57:13 pm »
Why did you make the NumberID variable global?
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline ZomgProniss

  • Camper
  • ***
  • Posts: 318
  • Known ingame as Proniss
Re: Where the bullet collide
« Reply #5 on: January 15, 2009, 08:39:07 pm »
what is the point in having this?


Offline vladdark

  • Major(1)
  • Posts: 11
Re: Where the bullet collide
« Reply #6 on: January 16, 2009, 04:51:54 am »
@chutem: 'Cause I was only testing that one script, so, global or not, doesn't made any difference to me on my test server... I posted it but it's not supposed to be used, it's only a example. =P

@ZomgProniss: I was trying to do a thing related to that... But, if you need a example... Well, did you ever saw a mine on another script? So, imagine that throwable; just for instance.

@danmer: You are right. But I really have no clue how to "clean" the script to track the right object and no one else...

If anyone know how to track the right knife (throwed by some player), or any other object who can be a bullet, even with a dozen of other knifes (or that other object) around, I will like a lot. lol

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Where the bullet collide
« Reply #7 on: January 16, 2009, 08:45:45 am »
When the bullet is created, get the closest person maybe? Unless if there's a GetObjectStat thing to check..