Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Apr 2012 06:16
In other words, an easily modifiable script that can create new types of bullets in games. Adjusting speed is one thing, redefining more complex paths of travel other than straight is a bit less straight-forward. My question is, has anyone ever developed a system like this in DB before or am I going to have to figure it out from scratch?

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 6th Apr 2012 17:48
a script engine? i make them all the time in dbp..

more 3d models .x/.obj and more foramts here:
[href]https://www.turbosquid.com/Search/Index.cfm?keyword=gogetax1&x=0&y=0[href]
Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 6th Apr 2012 20:19
Not really sure what you are asking.
A modifiable script ... why? Think of a bullet system like a particle system. The gun is the emitter and the bullet is the particle. What happens when a particle leaves the emitter is entirely dependant on the world and the type of particle (is it affected by wind, gravity etc.) and exactly the same thing applies to a bullet system.

There really is no difference between bullets and particles, with the only possible exception being that most (but not all) particle systems don't utilise collision detection.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Apr 2012 02:37
well some bullets shoot straight, others might weave back and forth as they travel along a small sine wave. Maybe two bullets are shot at a time and spin around as they travel, kinda like a bolos. See how its more than just a simple trajectory path with some forces acting on it?
The script idea was so non-programmers could create their own unique weapon in the game.


Also trying to think of a way to leave a streak of light behind some bullets, a different issue than this thread.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 7th Apr 2012 05:52
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 8th Apr 2012 01:10
I think I get this.

By way of example, to get something to move along a sine wave, as you mentioned, you would control the frequency and the amplitude of to give you different sine waves so:

y = amplitude*sin(frequency)

So the bullet would need some variables for amplitude and frequency. For any path that can be described, it's really just a case of controlling the equation to give you the desired outcome.



By commenting and un-commenting the data you can see how different bullets types move up the screen. In this method, you can use any kind of equation you like. This is obviously a very simple demo but it gives a basic idea and it would be very simple to put the data into external files to give you the scripting method you talked about.

If I was to do this in 3D I would have seperate variables for the velocity and position and not use the MOVE OBJECT command, that way you can spin and roll the bullet model as you see fit. To get a bolos you would just have a single model that was two seperate spheres, the bullet would then have a "spin" as well as a forward speed to give you the bolos effect. Like Scraggle said, it starts to become more of a particle system than a straight bullet system.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 8th Apr 2012 02:53
Quote: "Also trying to think of a way to leave a streak of light behind some bullets, a different issue than this thread."


There's this : TheComet's Library - A Library of Useful Functions

Scroll down to the "Trails" section.

TheComet

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Apr 2012 08:31
I know how to use the sine wave, but you're basically doing what I'm trying to avoid. Separate functions for each type of bullet, which is pretty much what your case statement is doing. Right now I've had to create a separate routine for each type of bullet formation.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
The Weeping Corpse
14
Years of Service
User Offline
Joined: 19th Sep 2011
Location: United Kingdom
Posted: 8th Apr 2012 12:09 Edited at: 8th Apr 2012 12:59
I havent got time to write example code but I can point you in the correct direction

A 3D bezier curve will happily handle all types of projectile paths, from perfect straight lines to loops to crazy intersecting spirals.

You can even join 2 or more curves together so you are only limited by your imagination.

They are very easy to setup and use and you can extract the xyz vector along the curve as T (time = 0 to 1 where 0 = curve start, 1 = curve end and 0.5 for example = mid curve).

You can even setup the Beziers before your main loop and simply translate and rotate the control points into position so that the curve starts at your guns xyz.

You can define complex paths with a simple set of 4 control points positioned in 3D space. The bezier will then bend and twist its way in 3d space from the start control point to the end control point, the 2nd and 3rd control points influence the shape of the curve (think magnets)

so if you write a projectile engine that uses beziers you can reuse it for any type of bullet, simply by changing the input curve parameters.

These forums have example code for beziers. If you get stuck give me a shout.

http://en.wikipedia.org/wiki/B%C3%A9zier_curve

EDIT - this is a function copied from my Delphi library. You specify the 4 control points (p0, p1, p2, p3) as XYZ (VECTOR) and the mu represents T (from 0 to 1). The function returns a vector which is the point along the curve at T. This function can easily be converted to DB.

type
VECTOR = packed record
x: float;
y: float;
z: float;
end;

function CubicBezier(p0: VECTOR; p1: VECTOR; p2: VECTOR; p3: VECTOR; mu: float): VECTOR;
var
a: VECTOR;
b: VECTOR;
c: VECTOR;
p: VECTOR;
begin
c.x := 3 * (p1.x - p0.x);
c.y := 3 * (p1.y - p0.y);
c.z := 3 * (p1.z - p0.z);
b.x := 3 * (p2.x - p1.x) - c.x;
b.y := 3 * (p2.y - p1.y) - c.y;
b.z := 3 * (p2.z - p1.z) - c.z;
a.x := p3.x - p0.x - c.x - b.x;
a.y := p3.y - p0.y - c.y - b.y;
a.z := p3.z - p0.z - c.z - b.z;

p.x := a.x * mu * mu * mu + b.x * mu * mu + c.x * mu + p0.x;
p.y := a.y * mu * mu * mu + b.y * mu * mu + c.y * mu + p0.y;
p.z := a.z * mu * mu * mu + b.z * mu * mu + c.z * mu + p0.z;

result := p;
end;
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Apr 2012 03:39
It's an idea I can look into. Come to think of it, I did write a particle emitter once that followed a hermite spline.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 9th Apr 2012 04:37
Did you see the link I posted Phaelax?

TheComet

Login to post a reply

Server time is: 2026-07-09 23:12:38
Your offset time is: 2026-07-09 23:12:38