Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Reflecting projectiles... (https://forums.graalonline.com/forums/showthread.php?t=73334)

DustyPorViva 04-07-2007 01:30 PM

Reflecting projectiles...
 
I'm working with some projectiles and bouncing them off walls... I'm just having a little problem with it.

Basically, it's easiest to approach it ala Pong. If it hits the wall on it's x axis to flip it's x velocity, and the same for its y velocity. The only problem is that's kind of hard to detect with projectiles. At first I had it when it hit a wall to determine it's 'direction' using getdir and it's velocity, but when dealing with 45° shots, it tends to screw up because it's determining the wrong direction.
Any help here?

godofwarares 04-07-2007 02:12 PM

What I would do is just shoot the same projectile from the point of impact, so that it looks the same.

Also, I would suggest storing the angle on the player using a simple script:

PHP Code:

temp.angle int(arctan((playerx dx) / (playery dy)) * pi 180); 

Of course, That would store the angle of where the projectile is going and then you can use that to figure out what angle to shoot the new projectile.

DustyPorViva 04-07-2007 02:18 PM

I have all that being done. What's not being able to be done right is determining whether to inverse the x or y velocity because I can't figure out how to detect whether the projectile is hitting the wall on it's x or y axis.

Kristi 04-07-2007 03:40 PM

Quote:

Originally Posted by DustyPorViva (Post 1297645)
I have all that being done. What's not being able to be done right is determining whether to inverse the x or y velocity because I can't figure out how to detect whether the projectile is hitting the wall on it's x or y axis.

Why not? the simplest solution in this situation would to be to set up two onwall checks in the shape of a cross through the ball. Then you would know which axis hit.

DustyPorViva 04-07-2007 03:45 PM

It's a projectile

Kristi 04-07-2007 04:05 PM

Quote:

Originally Posted by DustyPorViva (Post 1297651)
It's a projectile

Sorry I just woke up and took it out of context.
Make your own projectile via class? :D

cbk1994 04-07-2007 04:34 PM

onActionProjectile2(). You could find the right angles, then shoot() again in the right angle.

DustyPorViva 04-07-2007 05:44 PM

I already have the projectile worked out. It shoots back and all. I'm just having the problem of determining which side of the projectile actually hits the wall so I can reflect it properly.
And I dunno about the class thing, seems like a lot of effort and a lot less effecient to use a class.

Kristi 04-07-2007 07:43 PM

Quote:

Originally Posted by DustyPorViva (Post 1297666)
I already have the projectile worked out. It shoots back and all. I'm just having the problem of determining which side of the projectile actually hits the wall so I can reflect it properly.
And I dunno about the class thing, seems like a lot of effort and a lot less effecient to use a class.

a projectile is an object spawned with a clientside and serverside, it really is no different.

DustyPorViva 04-07-2007 09:35 PM

Yes, except that's way out of the way for something that's pretty simple and works in just about every way except for this one thing.


All times are GMT +2. The time now is 06:45 AM.

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