Thread: push back
View Single Post
  #4  
Old 06-19-2009, 10:03 PM
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
hitplayer(this.id,0,hitfromx,hitfromy);

If you're using the default system, that should work. It will hit the player away from the given 'hitfromx/y'. this.id should find your own player, but I'm not entirely sure.

So... probably something like this...

Projectile:
PHP Code:
  temp.sx = (player.x+1.5) - (this.x+1.5);
  
temp.sy = (player.y+2) - (this.y+2);
  
temp.sangle getangle(sx,sy);
  
setshootparams("arrow",sangle); // You MUST send the angle at which the projectile is flying.
  
shoot(this.x,this.y,this.z,sangle,0,0,"projectilegani",null); 
Now this probably looks nothing like the projectile you're using, as I've rigged this in an NPC to shoot projectiles at my player. The point is, however, to pass the angle the projectile is traveling in setshootparams(). This is because projectiles that actually hit objects do not send which direction they are coming from, so you have to eventually calculate that yourself.

So onto the weapon itself(you should have one global weapon or such that all players get to handle projectile hits).:
PHP Code:
//#CLIENTSIDE
function onActionProjectile(obj,sangle) {
  if (
obj == "arrow") {                      // Is it an arrow? You should do these sort of checks
    
temp.hitx player.x+1.5+cos(sangle+pi); // Calculate where the projectil came from
    
temp.hity player.y+2-sin(sangle+pi);
    
hitplayer(this.id,0,hitx,hity);
  }

When the projectile hits the player, it will take the angle of the projectile, reverse it(by adding pi to it), and then calculate it 1 tile away from the player. This will give you an accurate idea of where the projectile landed a tile away, therefor letting you hit the player from there.
Reply With Quote