View Single Post
  #1  
Old 04-21-2010, 02:09 AM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Shoot arrows where you click.




Works on terrain too.


You can shoot at flying people by clicking their shadows.

Don't see any arrows? Go to Graal Kingdoms to make it download.
Or you can use your own projectile gani if you change the script.

Install as a weapon and add to yourself.
PHP Code:
//#CLIENTSIDE

function onMouseDown()
{
  if (
leftmousebutton)
  {
    
temp.targetPlayer players[testplayer(mousexmousey)];
    
temp.targetNPC npcs[testnpc(mousexmousey)];
    if (
temp.targetNPC != null)
    {
      
temp.target = {temp.targetNPC.1.5temp.targetNPC.2.0temp.targetNPC.1};
    }
    elseif (
temp.targetPlayer.account != null && temp.targetPlayer.account != player.account)
    {
      
temp.target = {temp.targetPlayer.1.5temp.targetPlayer.2.0temp.targetPlayer.1};
    }
    else
    {
      
temp.target = {mousexmouseygetz(mousexmousey)};
    }
    
    
shootAt(player.xplayer.yplayer.ztemp.target[0], temp.target[1], temp.target[2], "arrow""barrow0.png");
  }
}

function 
shootAt(temp.oxtemp.oytemp.oztemp.txtemp.tytemp.tztemp.ganitemp.ganiparam)
{
  
temp.timeStep 0.05;
  
  
temp.origin = {temp.oxtemp.oytemp.oz};
  
temp.target = {temp.txtemp.tytemp.tz};
  
  
temp.dx = (temp.target[0] - 1.5) - temp.origin[0];
  
temp.dy = (temp.target[1] - 2.0) - temp.origin[1];
  
temp.dz temp.target[2] - temp.origin[2];
  
temp.horizontalDistance = (temp.dx^temp.dy^2) ^ 0.5//Pythagoras' theorem
  
temp.verticalDistance temp.dz;
  
temp.angle getangle(temp.dxtemp.dy);
  
  
//Look for 'ballistic trajectories' to find the equations used here.
  //Two lines of magic incantations to prevent an accuracy error. (Possibly caused by the projectile only being updated every 0.05 seconds)
  
temp.precognition_horizontalVelocity 20;
  
temp.timeToTarget shared.roundTo(temp.horizontalDistance temp.precognition_horizontalVelocitytemp.timeStep); //Constant horizontal velocity.
  //Alternatively: temp.timeToTarget = 1; //Constant time to reach target.
  
temp.horizontalVelocity = (temp.horizontalDistance temp.timeToTarget);
  
temp.verticalVelocity 0.5 * (gravity temp.timeStep) * temp.timeToTarget + (temp.verticalDistance temp.timeToTarget);
  
  
//Trigonometry
  
if (temp.horizontalVelocity != 0) {
    
temp.zangle arctan(temp.verticalVelocity temp.horizontalVelocity);
  }
  else {
    
//Happens when the origin and the target position are the same.
    
temp.zangle pi 2;
  }
  
  
temp.power temp.verticalVelocity sin(temp.zangle) * temp.timeStep;
  
  
shoot(temp.origin[0], temp.origin[1], temp.origin[2],
        
temp.angletemp.zangletemp.power,
        
temp.ganitemp.ganiparam);

Reply With Quote