Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-16-2005, 02:59 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
'Power' parameter in the shoot command

I am attempting to create a projectile using the 'zangle' and 'power' parameters of the 'shoot' command, something like the bows on Graal Kingdoms. My problem is that I cannot find out the equation for 'power' based on the distance you want the projectile to be launched. I'm using a zangle of pi/4.

Any help would be much appreciated. (Please do not simply say "search the forums", as I have done so, but every conversation I've seen about the zangle in the shoot command has ended abruptly before 'power' was touched.)


Thanks,
Okiesmokie
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #2  
Old 01-16-2005, 03:24 AM
Sildae Sildae is offline
Elven sorceress!
Sildae's Avatar
Join Date: Dec 2001
Location: Lothlòrien
Posts: 159
Sildae is on a distinguished road
Use a loop to test increasing powers simulating shoot, until you have found one that works for the distance.
__________________
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man."
-- George Bernard Shaw
Reply With Quote
  #3  
Old 01-16-2005, 04:11 AM
Evil_Trunks Evil_Trunks is offline
Evil
Evil_Trunks's Avatar
Join Date: Dec 2004
Posts: 391
Evil_Trunks is on a distinguished road
Quote:
Originally Posted by Sildae
Use a loop to test increasing powers simulating shoot, until you have found one that works for the distance.
sike, that's a terrible way

just calculate the projectile physics, like i did

v = dt
d=1/2at^2 + vit

simultaneous equations, or whatever it's called, the time is the same in both equations (well, the time is double in the v=dt equation)

the information about projectile movement can be found in newfeatures.txt

i used a constant zangle of 45 degrees

i could just post you the entire script but that might be against the rules?
__________________


Last edited by Evil_Trunks; 01-16-2005 at 05:03 AM..
Reply With Quote
  #4  
Old 01-16-2005, 07:01 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Evil_Trunks
just calculate the projectile physics, like i did

v = dt
d=1/2at^2 + vit
What does the 'i' variable represent?


Quote:
Originally Posted by Evil_Trunks
the information about projectile movement can be found in newfeatures.txt
I saw that information, But I don't have a strong enough hold on physics and whatnot to be able to get the equation for power out of it.


Quote:
Originally Posted by Evil_Trunks
i used a constant zangle of 45 degrees
That's what pi/4 is, I think.


Quote:
Originally Posted by Evil_Trunks
i could just post you the entire script but that might be against the rules?
Only the shoot command, or the place where you calculate power is really required.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #5  
Old 01-16-2005, 07:03 AM
Evil_Trunks Evil_Trunks is offline
Evil
Evil_Trunks's Avatar
Join Date: Dec 2004
Posts: 391
Evil_Trunks is on a distinguished road
Quote:
Originally Posted by ApothiX
What does the 'i' variable represent?
vi, it stands for initial velocity, i was thinking i should have clarified this but i didn't for some reason...

Quote:
Originally Posted by ApothiX
Only the shoot command, or the place where you calculate power is really required.
you really sort of need to have taken physics to understand how to solve this

i didn't simplify any of the stuff that could be simplified

NPC Code:
this.power = ( ( this.dist * -0.1 ) / ( 2 * cos(this.zangle)  * -1 * sin(this.zangle) ) ) ^ 0.5;



you will probably want to offset your destination x y by -1.5 or something, since projectiles have a width/height of 48x48

otherwise the top left corner will land at the coordinates you used (i think)


here is the information I used, by the way, taken from newfeatures
(actually someone pasted it into the #gscript channel)
Quote:
Projectiles are easy to use and don't take a lot of bandwidth because only
the shooting of the projectile needs to be sent, the movement is calculated on
the different computers. The projectile is flying like a heavy object thrown
through the air: the horizontal movement speed keeps the same (moves
horzspeed=cos(zangle)*speed tiles all 0.05 seconds), the vertical speed is
initialized as vertspeed=sin(zangle)*speed and is decreased by 0.1 all 0.05 seconds;
then the new position (calculated all 0.05 seconds) is
newx = x + cos(angle)*horzspeed, newy = y - sin(angle)*horzspeed,
newz = z + vertspeed
I found this file where I saved my work
Quote:
Originally Posted by work
vertical

Vi = vertspeed = sin(zangle)*speed [tiles / 0.05 secs]
acceleration = -0.1 [tiles / 0.05 secs ^2]
Vf = 0
time = ? [0.05 secs]
Vf = Vi + at
t = ( Vf - Vi ) / a

horizontal

v = horzspeed = cos(zangle)*speed [tiles/ 0.05 secs]
d = distance [tiles]
t = ? [0.05 secs]
d=vt
t = d/v

combo

d/v = 2 * ( Vf - Vi ) / a
dist / ( cos(zangle)*speed ) = 2 * ( 0 - sin(zangle)*speed ) / -0.1
dist * -0.1 = 2* ( cos(zangle)*speed ) * ( 0 - sin(zangle)*speed )
dist * -0.1 = 2* cos(zangle) * speed ^ 2 * -1 * sin(zangle)
speed = ( ( dist * -0.1 ) / ( 2 * cos(zangle) * -1 * sin(zangle) ) ) ^ 0.5
Stefan uses speed to say power in the newfeatures explanation
__________________

Reply With Quote
  #6  
Old 01-16-2005, 08:56 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Thank you very much, your solution worked perfectly

The thing that threw me off was the 'speed' in newfeatures, I didn't know that meant power
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #7  
Old 01-16-2005, 08:22 PM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by Evil_Trunks
i used a constant zangle of 45 degrees
I highly doubt you did 45 degrees considering these is based off of radians...
pi/4 is the radian equivalent of 45 degrees.

The rest is just basic physics calculations. I haven't played with the shoot command much, but if it follows basic physics principles then all the equations stated should work out.
__________________
Who has time for life these days?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 11:54 AM.


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