Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 04-21-2010, 02:40 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Wow, pretty awesome that you posted this because I was just thinking about doing the exact same thing (but with something other than arrows) earlier today. Haven't tried it out yet, but nice work.
Reply With Quote
  #3  
Old 04-21-2010, 02:40 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
That is awesome, good job man. I was also trying to do that one day, but my trial and error method, instead of cold hard math wasn't working out, I just made it go in a straight line to where you click which isn't that cool.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #4  
Old 04-21-2010, 02:44 AM
Grey Grey is offline
Classic Developer
Grey's Avatar
Join Date: Mar 2007
Location: Wales, UK
Posts: 134
Grey will become famous soon enough
Send a message via AIM to Grey
Tidy. Bravo.
Reply With Quote
  #5  
Old 04-21-2010, 07:30 AM
Seeya Seeya is offline
ω
Seeya's Avatar
Join Date: Jul 2007
Location: Seminole, FL
Posts: 1,903
Seeya is a splendid one to beholdSeeya is a splendid one to beholdSeeya is a splendid one to beholdSeeya is a splendid one to beholdSeeya is a splendid one to behold
Send a message via AIM to Seeya
idk but i'm 99% sure that they have this on graal kingdoms

i think they call it a bow
__________________
Kale Vimes

Reply With Quote
  #6  
Old 04-21-2010, 07:34 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
Shoot arrows with your ****

Whaaaaaaaaaaaaaaat?

Cool stuff, like I said in IRC I was never able to calculate the numbers needed to do such a thing.
Reply With Quote
  #7  
Old 04-21-2010, 07:42 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
If I remember right, on graal kingdoms the bow didn't shoot where you clicked. But that was a long time ago for me?
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #8  
Old 04-21-2010, 07:44 AM
Seeya Seeya is offline
ω
Seeya's Avatar
Join Date: Jul 2007
Location: Seminole, FL
Posts: 1,903
Seeya is a splendid one to beholdSeeya is a splendid one to beholdSeeya is a splendid one to beholdSeeya is a splendid one to beholdSeeya is a splendid one to behold
Send a message via AIM to Seeya
setnick Kale (FAQ)
bows shoot where you click
__________________
Kale Vimes

Reply With Quote
  #9  
Old 04-21-2010, 07:45 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
Quote:
Originally Posted by adam View Post
If I remember right, on graal kingdoms the bow didn't shoot where you clicked. But that was a long time ago for me?
It works off the formula, I'm pretty sure. Bows will show an circle around your mouse. The farther your mouse(thus, your target), the larger the circle would grow. This circle indicates the radius of where your arrow could land(accuracy).

Thus, they have to use a similar formula to start with, and then add/deduct from it to account for the accuracy.
Reply With Quote
  #10  
Old 04-21-2010, 07:53 AM
Seeya Seeya is offline
ω
Seeya's Avatar
Join Date: Jul 2007
Location: Seminole, FL
Posts: 1,903
Seeya is a splendid one to beholdSeeya is a splendid one to beholdSeeya is a splendid one to beholdSeeya is a splendid one to beholdSeeya is a splendid one to behold
Send a message via AIM to Seeya
Quote:
Originally Posted by DustyPorViva View Post
It works off the formula, I'm pretty sure. Bows will show an circle around your mouse. The farther your mouse(thus, your target), the larger the circle would grow. This circle indicates the radius of where your arrow could land(accuracy).

Thus, they have to use a similar formula to start with, and then add/deduct from it to account for the accuracy.
qft
__________________
Kale Vimes

Reply With Quote
  #11  
Old 04-25-2010, 09:10 AM
Draenin Draenin is offline
Magnificent Bastard
Draenin's Avatar
Join Date: Dec 2004
Location: Bermuda Triangle
Posts: 6,790
Draenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud of
Send a message via AIM to Draenin Send a message via MSN to Draenin Send a message via Yahoo to Draenin
Excellent stuff, good sir. Yet another script you've made which will prove tremendously helpful to every developer in the future. :]
Reply With Quote
  #12  
Old 05-02-2010, 01:52 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Well apparently it's not as simple as going on GK and downloading it since no one there is any help.

Can someone attach the gani and image here?
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #13  
Old 05-02-2010, 11:02 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Quote:
Originally Posted by coreys View Post
Well apparently it's not as simple as going on GK and downloading it since no one there is any help.

Can someone attach the gani and image here?
Attached.
Attached Images
 
Attached Files
File Type: gani arrow.gani (3.3 KB, 251 views)
Reply With Quote
  #14  
Old 05-02-2010, 11:09 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
awesome dude
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.