Following a rocket after firing?

Locked
jkoder
Posts: 59
Joined: Tue Jun 17, 2008 9:10 pm

Following a rocket after firing?

Post by jkoder »

Hello,

Back again. Thanks to those who replied to my last thread.

Does anyone know how I would go about following a missile after firing it? What I have so far is
a rocket launcher which lets you control the rockets with the mouse remotely. I want to freeze the player
so he can no move and follow the rocket like you would follow a player as a spectator. Does anyone know
how to go about doing this?

Cheers

jk
Kaz
Posts: 1077
Joined: Wed Mar 08, 2006 3:43 am

Re: Following a rocket after firing?

Post by Kaz »

You'd want to change cg.refdef.vieworg to be the coordinates of the rocket entity. If you look in CG_Draw.c, in CG_DrawActive() the call: trap_R_RenderScene(&cg.refdef); is what tells the engine to render everything.
jkoder
Posts: 59
Joined: Tue Jun 17, 2008 9:10 pm

Re: Following a rocket after firing?

Post by jkoder »

Hi Kaz,

Thanks for the reply, really helpful!

Does that now mean I would need to provide a client-side download for
my mod also? Currently it is server side and I would prefer to keep it way if possible.

jk
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Following a rocket after firing?

Post by ^misantropia^ »

jkoder wrote:Does that now mean I would need to provide a client-side download for my mod also?
Yep. No way around it.
jkoder
Posts: 59
Joined: Tue Jun 17, 2008 9:10 pm

Re: Following a rocket after firing?

Post by jkoder »

Hello Again K and M.

I have been playing around with cg_draw but can't get this to work. What I tried was modify the CG_RocketTrail function
so that whilst it was looping to display the rocket and smoke puff I copy the rockets coordinates to
the cg.refdef.vierorg vec3_t like so

Code: Select all

for ( ; t <= ent->trailTime ; t += step ) {
		BG_EvaluateTrajectory( &es->pos, t, lastPos );
		VectorCopy( lastPos, cg.refdef.vieworg); // New line added to switch coordinates 
		smoke = CG_SmokePuff( lastPos, up, 
					  wi->trailRadius, 
					  1, 1, 1, 0.33f,
					  wi->wiTrailTime, 
					  t,
					  0,
					  0, 
					  cgs.media.smokePuffShader );
		// use the optimized local entity add
		smoke->leType = LE_SCALE_FADE;
	}
This half works but I the screen flickers in between what would be by normal view with out modification and what would be my view following the rocket. Do I need to set something else and is this approach anywhere close to what you were suggested?

Thanks again.

jk

EDIT: I just noticed that this works as expected if I set max fps to 20 or below. So it seems that the VectorCopy call is not running fast enough inside the loop to keep up with the rendering of frames with my standard fps rate. Any suggestions on where I could move this call to make it work at a higher fps?
Kaz
Posts: 1077
Joined: Wed Mar 08, 2006 3:43 am

Re: Following a rocket after firing?

Post by Kaz »

Hello JK :D

You could set up another refdef_t that contains the coords of the rocket, and then conditionally choose to draw either the rocket or cg.refdef in CG_Draw.c, as opposed to using the same instance.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Following a rocket after firing?

Post by ^misantropia^ »

I rather suspect the flicker is the result of the game drawing the player's perspective as usual and then you overriding it in CG_RocketTrail(). Take a look at CG_CalcViewValues() in cgame/cg_view.c, that is where the player's view origin and angles are initially set. You'll want to override the default behaviour when tracking a missile.
Kaz
Posts: 1077
Joined: Wed Mar 08, 2006 3:43 am

Re: Following a rocket after firing?

Post by Kaz »

M's approach would probably be more efficient, I was going to mention something like that also after finding the specific place that happened...
jkoder
Posts: 59
Joined: Tue Jun 17, 2008 9:10 pm

Re: Following a rocket after firing?

Post by jkoder »

Hello again,

I am back working on this part of my mod but I have a hit a snag. I can control and follow the rocket
but when I go past a couple of corners I stop following it (likely as it no longer exists as far the parent/client is concerned).

What I am doing is in g_missile/fire_rocket

Code: Select all

bolt->think = Guided_Missile_Think;
bolt->nextthink = level.time + FRAMETIME;
self->client->ps.stats[STAT_USING_ROCKET] = 1;
The above sets a flag that the client can read to know to follow. The think method controls the rocket based
on the muzzle and at the bottom I do this

Code: Select all

player->client->ps.stats[STAT_ROCKET_X] = (int) missile->s.pos.trBase[0];
player->client->ps.stats[STAT_ROCKET_Y] = (int) missile->s.pos.trBase[1];
player->client->ps.stats[STAT_ROCKET_Z] = (int) missile->s.pos.trBase[2];

missile->nextthink = level.time + FRAMETIME; 
And then on the client I am doing the following in cg_view/CG_CalcViewValues

Code: Select all

if(ps->stats[STAT_USING_ROCKET] == 1) {
   cg.refdef.vieworg[0] = (float)ps->stats[STAT_ROCKET_X];
   cg.refdef.vieworg[1] = (float)ps->stats[STAT_ROCKET_Y];
   cg.refdef.vieworg[2] = (float)ps->stats[STAT_ROCKET_Z];
}
Anyone know how I can tell Quake to follow the rocket until it has exploded and not just when it is completely out of view?

p.s. I think I will apply for my own personal forum section here :D

Cheers

Mike
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Following a rocket after firing?

Post by ^misantropia^ »

Sounds like a PVS issue. Let me get back on this, for now duty calls.
AnthonyJ
Posts: 130
Joined: Wed Nov 15, 2006 7:51 pm

Re: Following a rocket after firing?

Post by AnthonyJ »

Yea, agreed sounds like the rocket is going out of PVS. (PVS = "Potentially Visible Set", or some variation. This is used to limit the data transmitted to the clients to only things they need based on where they are in the map, lowering bandwidth, processing time etc).

One solution is to use SVF_PORTAL and set s.origin2 on the player to be the origin of the rocket. That way, it'll give you the PVS of both where the player is, and where the rocket is.

If you're giving a fullscreen view of the rocket you maybe don't really need the PVS from where the player is, but you certainly will need this if you have a second view showing the players view too.
jkoder
Posts: 59
Joined: Tue Jun 17, 2008 9:10 pm

Re: Following a rocket after firing?

Post by jkoder »

AnthonyJ wrote:Yea, agreed sounds like the rocket is going out of PVS. (PVS = "Potentially Visible Set", or some variation. This is used to limit the data transmitted to the clients to only things they need based on where they are in the map, lowering bandwidth, processing time etc).

One solution is to use SVF_PORTAL and set s.origin2 on the player to be the origin of the rocket. That way, it'll give you the PVS of both where the player is, and where the rocket is.

If you're giving a fullscreen view of the rocket you maybe don't really need the PVS from where the player is, but you certainly will need this if you have a second view showing the players view too.
That's the ticket.

I changed it and I can now follow the rockets. I still need to do a bit of work, it flickers moment a bit (I can see two missiles at the moment :( ) and I lose the sound of the rocket when I leave the players origin PVS but I am pretty sure I can fix this.

Given that the server is sending new coordinates every 0.1 seconds and the client is rendering the view at a much higher rate do you still think there is a way to get a smoother view of the missile? Client prediction will be awkward or maybe even impossible given that rocket is controlled by the client and the direction can change at anytime.

Thanks a lot for you help M and A.

EDIT: I changed the nextthink time from level.time + FRAMETIME (100) to level.time + 1 and it seems to work okay, a lot smoother and good enough to be able to release.
jkoder
Posts: 59
Joined: Tue Jun 17, 2008 9:10 pm

Re: Following a rocket after firing?

Post by jkoder »

Hello,

I have an issue seeing opposition player models when they are behond what would be my normal PVS. This workaround with the SVF_PORTAL flag and origin2 doesn't seem to help see other player models. I guess the same thing that effects what models I see is also the same reason I don't hear any rocket sfx when leaving my PVS.

Anyone know how to fix any of these issues?

Cheers

Mike
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Following a rocket after firing?

Post by ^misantropia^ »

A trick I used when implementing MVD (multi-view demo) support was to create a portal entity and set its position to that of the other player, so s/he was always in the PVS of the recording player.
jkoder
Posts: 59
Joined: Tue Jun 17, 2008 9:10 pm

Re: Following a rocket after firing?

Post by jkoder »

^misantropia^ wrote:A trick I used when implementing MVD (multi-view demo) support was to create a portal entity and set its position to that of the other player, so s/he was always in the PVS of the recording player.
Hi M,

Can you explain this in a little more detail I am not quite sure I follow...I think you mean to create a portal with the source being the player firing the weapon and the destination being the target wherever he may be?

Also, did you ever implement your idea which is mentioned on Quakedev (Quake dream list thread)? It's the one regarding teleporting to other servers? It could be a really cool idea and games could span multiple servers and maps, would obviously need a bit of work though.

Thanks again,

Mike
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Following a rocket after firing?

Post by ^misantropia^ »

Can you explain this in a little more detail I am not quite sure I follow...I think you mean to create a portal with the source being the player firing the weapon and the destination being the target wherever he may be?
I phrased it somewhat awkward but that was indeed (precisely) what I meant.
Also, did you ever implement your idea which is mentioned on Quakedev (Quake dream list thread)? It's the one regarding teleporting to other servers? It could be a really cool idea and games could span multiple servers and maps, would obviously need a bit of work though.
I did, but it never did catch on. Such is the story of my life. :smirk:

It's almost trivial to implement: add key with IP address to teleporter, send server command, client executes '/connect ADDRESS', done. Coordinating load over the servers in the ring is less trivial but it can be done - I piggybacked on the traditional getserverinfo infrastructure to send messages like 'server full'.

I wonder what I did with that code. I'm not one to throw code away but I don't remember where I left it.
jkoder
Posts: 59
Joined: Tue Jun 17, 2008 9:10 pm

Re: Following a rocket after firing?

Post by jkoder »

Thanks again M for your reply. I will work on implementing the portal hack to fix this.

Shame no one caught on to your idea, I think you were just too far ahead for them :)

The clan who will play my mod also play E+ and run two servers so I am going to add this
teleport feature so they can switch to their other server running E+. It's really crap that people
didn't see how much potential this idea has, with more work to handle player state and such across servers and
maps which allowed you to teleport to multiple servers depending on the portal you chose
it could have really added a new dimension to playing Quake online.

Can I ask what you actually do with the knowledge you have gained in Quake? Are you just at the point
at where you can't be bothered and just like advising others or simply don't have time or are you actually working
on something?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Following a rocket after firing?

Post by ^misantropia^ »

I have precious little time to spare, nowadays. I leave home at 06.30 in the morning, and I'm usually not back before 19.30 in the evening, so big projects are a bit beyond me now.

But we frequently play OpenArena at work, and every now and then I hack up a mini-mod for us to waste time with. :)
dutchmeat
Posts: 8
Joined: Mon Apr 02, 2007 1:31 pm

Re: Following a rocket after firing?

Post by dutchmeat »

Why don't you use trap_InPVS()?
-----------
Wolfenstein: Vampire;
[url]http://www.splashdamage.com/forums/showthread.php?t=16833[/url]
jkoder
Posts: 59
Joined: Tue Jun 17, 2008 9:10 pm

Re: Following a rocket after firing?

Post by jkoder »

Hi Dutchmeat,

I put this part of my mod on hold for now but thanks for the reply. I didn't actually notice this method
before but after checking I see it returns a qboolean and it's only called form g_team when playing CTF. I don't see how
I can use this to solve my problem, even if I override it to always return true it wont help because it's not called
when firing a rocket. How were you suggesting I should use it?

Thanks for your post.

Mike
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Following a rocket after firing?

Post by ^misantropia^ »

trap_InPVS() only allows you to check if an entity is in the client's PVS, not to force it into the client's PVS.
dutchmeat
Posts: 8
Joined: Mon Apr 02, 2007 1:31 pm

Re: Following a rocket after firing?

Post by dutchmeat »

Why would you want to force it in the pvs? The rocket already spawns in your pvs, so the only thing to do is use something like clientthink to check if the rocket still is in the pvs of the player.
-----------
Wolfenstein: Vampire;
[url]http://www.splashdamage.com/forums/showthread.php?t=16833[/url]
jkoder
Posts: 59
Joined: Tue Jun 17, 2008 9:10 pm

Re: Following a rocket after firing?

Post by jkoder »

dutchmeat wrote:Why would you want to force it in the pvs? The rocket already spawns in your pvs, so the only thing to do is use something like clientthink to check if the rocket still is in the pvs of the player.
Because I want to be able to view and control the rocket beyond my normal PVS which is based on where I am standing when I fire it. If I fire the rocket from outside on q3dm1 and I direct it towards the red armor inside of the map it is beyond my PVS and I no longer follow the rocket. The fix for this was posted above this but I also have another problem, enemy models are not rendered. The fix for this was also posted above but I didn't implement it yet.
dutchmeat
Posts: 8
Joined: Mon Apr 02, 2007 1:31 pm

Re: Following a rocket after firing?

Post by dutchmeat »

I think this (rtcw)tutorial will help you with the rendering; http://w.twwwo.be/rtcwmods/intermediate ... index.html

To be honest, I don't know how PVS works, but you might want to use InRadius(using MASK_SHOT?), instead of PVS.

Also you could try how this works;
http://www.quake3hut.co.uk/q3coding/Vis ... ke%203.htm
-----------
Wolfenstein: Vampire;
[url]http://www.splashdamage.com/forums/showthread.php?t=16833[/url]
Locked