View Single Post
  #22  
Old 02-07-2010, 07:57 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Serverside HD will always feel inaccurate unless you have a good ping/connection, as it's detecting player's where the server knows they are, rather than where you're seeing them on the clientside. However, a lot of how you do HD will depend on what sort of HD you want and a lot of logic.

For example, you'll want the 'hit origin' of the target to be at player.x+1.5 and playery+2. That's the center of the player's blocking area. So instead of detecting if the player's x is in the range, you detect iif the center is, like so:

if (pl.x+1.5 in |hittx + this.range,hittx|)

However, before the days of 'in', we would calculate HD via delta's. Like so:
PHP Code:
temp.hitx player.x+1.5+vecx(player.dir)*2;
temp.hity player.y+2+vecy(player.dir)*2;
if (
abs((pl.x+1.5) - hitx) <= 1.5 && abs((pl.y+2) - hity) <= 1.5) {
  
// Will hit a player in a 3 tile block of the player's immediate direction.
  // abs() calculates the absolute value. So whether the player is -2 tiles away from the hit, or 2, it will return as 2.
  // this makes it easier to process the data

However, using 'in' is just as well anymore.
Reply With Quote