Coding concept/question

I’ve no clue how big a question this may be, but it’s not a simple question… I have worked on this and narrowed it down to a point.
I’ve long thought of creating my own version of Rise of the Triad ‘Drunk Missiles’ for my MOD. Went and got a copy of the original ROTT source code and have fiddled with the idea for many years.
Where I ended up was here.
I figured, instead of tapping into the sin array, (it looked like something way over my head, besides there’s so little useful info out there), why not ‘fake’ it. So I changed the TR_GRAVITY a little to suit my needs and voila, a great start. The missiles fire and soar up into the air… then I tried combining it with an existing variation of the homing missiles…
I’m no programmer, but I kinda got it to work. Haven’t quite finished with the TR_ code, but that and the homing section obviously fight quite a bit.
I went to the Code3Arena tutorials remembering ‘accelerating rockets’ tutorial went into this some, and after a quick refresher, it didn’t seem reasonable to put much into the TR_GRAVITY, following Hypothermia’s advice not to use it for much except very important stuff.
I was trying to find a way to turn the gravity off, and let the homing function take over, but once the TR_ANTIGRAVITY is used, it doesn’t seem to want to turn off, or maybe I’m not addressing the problem right… if it’s even possible to do it this way.
Any opinions?
I’ll post code if anyone wants to take a look… it’s kinda messy and has extra stuff in it… but it’s Neal Toronto’s work from the Altfire MOD source. I just gutted his TR_ORBITAL and used his homing missile code.

Sounds like an interesting project !

I played Rise of the Triad so long ago I don’t remember what these drunk missiles look like. Do you have a video ?

5 or more, Drunk missiles shoot out and up 50 to 100 feet, and each one soars in it’s own path fanned, or splayed out, but then they all home in on a single target. Hard to find the actual Rise of the Triad in video, that’s an oldy and moldy game :slight_smile: But here’s a couple videos that will give you a good visual of the concept. The macros saga are party what I was thinking of, but it’s a useful range in q3 I’m working for.

I didn’t notice a name for this game, but the drunk missles are perfect.

Here you have the macros saga, this is more what I was thinking of, but the Rise of the Triad missiles… seems like they were somewhere in the middle.

1 Like

The first video is from the 2013 remake of Rise of the triad :slight_smile:

I would add the quad rocket laucher of the first turok as a reference, even if it’s just cosmetic :

So, to make such anime-like missiles, you first have to modify (or add a new) the missile’s behavior.
Let me sum it up :

  • you shoot a bunch of missiles, each with a slightly different angle, like a spray
  • they vaguely do their own business for some time (more or less spiraling)
  • then they aim for a target.

is that what you’re trying to do ?

Yes, exactly. I’ve got to the part where I shoot a bunch of missiles, they have their own random start, but the random, individual, spiral stuff, seems beyond me.
Thanks for the video :slight_smile: Turok was one of the games I missed. Neat.

So, you should first put up a system that switches from one behavior to another. You can use the “spawnflags” int variable to store it :
0 = initial lauche
1= spiraling
2 = aiming for target.

The way you would switch between states can be decided by checking the “age” of the rocket. when spawned, I guess the frame number is stored in gentity->entityState->time. Then you just have to compare this number to the current frame in the game to get the age. Then if the age is over a certain number, you switch to the desired behavior.

For the spiraling rockets, the quaternions we talked about by email might come in handy to write a system that will be correct what ever the angle you’re shooting at.

Basically, I would first generate a vec3_t angle, where the yaw and pitch are generated from the sinusoidal functions, yaw = sin(time) * scale ; pitch = cos(time) * scale.

sinusoids are cool !

Then you convert these angles to a quaternion, you also convert the absolute velocity vector (one that is stored and never modified, inherited from the moment the rocket was shot) to a quaternion, and you multiply (conjugate) the second by the first. This should update the velocity in a way that could make it look like it’s spiraling.

Of course, I strongly advice you to put up some tests at each stage of the development to see if it works as intended ! for example, slow down the rocket speed, make the model bigger (in cg_ents.c), etc.

and of course, this is only a very vague idea of how I would make it, in the end there’s all the work of plugging back the results of the math to the velocity and angle of the rocket !

That all makes good sense. Your input is much appreciated.
I’d thought some of that out already, but you’ve pointed out some concrete examples and that may make a difference.
I’ve been trying to work with q3 for a long time and most of it is still beyond my grasp. I’ll do what I can with your suggestions. Thank you.