Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

Hitscan ricocheting?

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
Orion Joined: 12 Jan 2007 Posts: 414 Location: Brazil |

Posted: Wed Oct 01, 2008 11:50 pm Post subject: Hitscan ricocheting? |

Guys, does someone know how to make a hitscan weapon ricochet its shots instantly using traceline()? Thanks! _________________ There's no signature here. Stop looking for one.

Back to top |

Lardarse Joined: 05 Nov 2005 Posts: 243 Location: Bristol, UK |

Posted: Thu Oct 02, 2008 6:54 am Post subject: |

Basic idea: Trace the first shot. Check to see if you hit something that you want to do damage to. Copy all of the relevant trace_* variables (anything you want to keep, as they're about to be overwritten) Use trace_endpos to work out where first contact is.
Optionally use trace_fraction to see how much further the bullet can travel.
Reflect the angle of the shot about trace_plane_normal (this is the tricky part)
Trace the next shot.
Lather, rinse, repeat as necessary.
How to actually get the angle to travel away at is the tricky part. Hopefully, someone like Dr. Shadowborg will come along and read this, because he's done bouncing weapons before, and they involve doing a short traceline to get trace_plane_normal as well. The first mission pack has the laser cannon, which has bouncing laser bolts, but code contains a bug which means that the angle created is incorrect. It's fairly easy to fix, though.
Of course, DP_MOVETYPEBOUNCEMISSILE takes all of the hassle out of bouncing lasers, but it also takes out all of the learning possibilities...

Back to top |

Orion Joined: 12 Jan 2007 Posts: 414 Location: Brazil |

Posted: Thu Oct 02, 2008 5:20 pm Post subject: |

I see. For a projectile weapon ricochet, it generally uses in the touch function (self.velocity = old_velocity + 2*trace_plane_normal;). And then, I created an entity which will spawn at trace_endpos, and its angles set to vectoangles(2*trace_plane_normal), and then doing another traceline using makevectors() with the entity's angles and trace using v_forward.
Here are some screenshots, but the shot won't ricochet if fired on the ground... But that's ok. Works just like HL's Gauss Gun (which doesn't ricochet ground shots).
_________________
There's no signature here. Stop looking for one.

Back to top |

Lardarse Joined: 05 Nov 2005 Posts: 243 Location: Bristol, UK |

Posted: Thu Oct 02, 2008 7:26 pm Post subject: |

Orion wrote:
For a projectile weapon ricochet, it generally uses in the touch function (self.velocity = old_velocity + 2*trace_plane_normal;).

That formula looks a little wrong, but I can't be sure exactly what's wrong with it. You may want to read this for more info.

Back to top |

Dr. Shadowborg Inside3D Staff Joined: 16 Oct 2004 Posts: 726 |

Posted: Thu Oct 02, 2008 7:34 pm Post subject: |

Look around in here for ReboVec. http://forums.inside3d.com/viewtopic.php?t=1146 _________________ "Roboto suggests Plasma Bazooka."

Back to top |

Spike Joined: 05 Nov 2004 Posts: 944 Location: UK |

Posted: Thu Oct 02, 2008 7:54 pm Post subject: |

acording to quake: newvel = oldvel - (oldvel*planenormal)*2*planenormal; Where 'vel' can be a direction. This preserves speed. Changing the 2 to 1 makes it slide along the plane. Changing it to 1.5 makes it bounce as much as a grenade does. Leaving it as 2 makes it a full bounce. Using 2.5 is silly. 5 is absurd.
_________________
What's a signature?

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group