Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

How do I have the engine know when I do something in qc? Goto page 1, 2 Next

| Inside3d Forums Forum Index -> Engine Programming

View previous topic :: View next topic
Author | Message
--- | ---
Mexicouger Joined: 01 May 2010 Posts: 129 |

Posted: Thu Jul 08, 2010 3:21 am Post subject: How do I have the engine know when I do something in qc? |

Ok, let's just say with the Morphball code in qc, it's float mball //Morphball mode float currentplayer //You are in human mode now How do I tell the engine in sbar.c, That I am in mball mode so I can draw a new HUD? I know this much
if (mball)
draw_pic blablabla
Or would it be better I just code the mball as a weapon. I would rather actually code in I guess what its's called a "cavr"(clueless).
Thanks. I don't know if I am clear enough

Back to top |

Baker Joined: 14 Mar 2006 Posts: 1538 |

Posted: Thu Jul 08, 2010 12:31 pm Post subject: |

The quick and dirty way is to use stuffcmd to send something like "mball_sbar 1" and have sbar.c have if (mball_sbar.value) ... If you do this method, obviously you'll need to create and register that cvar in the engine. _________________ Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...

Back to top |

Downsider Joined: 16 Sep 2008 Posts: 478 |

Posted: Thu Jul 08, 2010 2:40 pm Post subject: |

I already have some changes to the protocol, so for my projects I have a generic builtin for updating the HUD and the protocol supports the builtin on the client. Uses less bandwidth than an entire string of "m_ball 1\n" and it's important on the PSP.

Back to top |

Mexicouger Joined: 01 May 2010 Posts: 129 |

Posted: Thu Jul 08, 2010 3:25 pm Post subject: |

Ok, so at the top of sbar.c, There is a bunch of things being like defined or something like qpic_t and such. Do I just make an interger like.. int mball_1 And then in the Drawpic, go if (mball_1) drawpic blablablah
Or Did I define it wrong....

Back to top |

Baker Joined: 14 Mar 2006 Posts: 1538 |

Posted: Thu Jul 08, 2010 6:29 pm Post subject: |

Top of sbar.c cvar_t cl_mball = {"cl_mball", "0"}; And in Sbar_Init in sbar.c add Cvar_RegisterVariable (&cl_mball); This adds the cvar (cvar stands for console variable).
And to reference the value, do something like

Code:
if(cl_mball.value == whatever) { do stuff }

_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...

Back to top |

frag.machine Joined: 25 Nov 2006 Posts: 728 |

Posted: Thu Jul 08, 2010 7:18 pm Post subject: |

You could also inspect the entities with something like: EDIT: Hmm... Nevermind. This will be a lot more complex. Stick with the cvar idea. _________________ frag.machine - Q2K4 Project http://fragmachine.quakedev.com/

Back to top |

Mexicouger Joined: 01 May 2010 Posts: 129 |

Posted: Thu Jul 08, 2010 8:07 pm Post subject: |

Thanks guys!

Back to top |

Mexicouger Joined: 01 May 2010 Posts: 129 |

Posted: Fri Jul 09, 2010 1:59 am Post subject: |

Mexicouger wrote:
Thanks guys!

EDITL what is the Downfall to using cvars? And does displaying a 480x272 image on the psp screen drag down framerate? or does it just quickly make it go slow because It's loading

Back to top |

Spike Joined: 05 Nov 2004 Posts: 944 Location: UK |

Posted: Fri Jul 09, 2010 2:08 am Post subject: |

main downside to using cvars is that they're not generally reset on map changes. using them on engines which don't support that specific one results in nice big omgyoubrokeit console prints to the user. cvars are a bit bigger. users can change cvars with ease (at least if they have a keyboard).
you have to explicitly tell the client any time it changes (with a stat, you just change the stat and the engine sends the message only if its changed, at least from baseline.
Cvar_FindVar might not be super speedy.
_________________
What's a signature?

Back to top |

Baker Joined: 14 Mar 2006 Posts: 1538 |

Posted: Fri Jul 09, 2010 11:44 am Post subject: |

Mexicouger wrote:
EDITL what is the Downfall to using cvars? And does displaying a 480x272 image on the psp screen drag down framerate? or does it just quickly make it go slow because It's loading

The only real downside of using cvars is that it is hacky.
It will work and it will be easy.
You can always code it properly as part of the protocol or another truly integrated method later (more complicated), but the cvar method will get you satisfaction quickly.
A LOT of popular mods back in the day used the cvar method historically. That doesn't make it a "good way", but mods like Rocket Arena and Artifact Quake (and no doubt many, many others) have used the cvar method to do things. [And annoyed people a bit with problems like what Spike said above ...]
Frag machine said it best ...

frag.machine wrote:
You could also inspect the entities with something like: EDIT: Hmm... Nevermind. This will be a lot more complex. Stick with the cvar idea.

_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...

Back to top |

Spike Joined: 05 Nov 2004 Posts: 944 Location: UK |

Posted: Fri Jul 09, 2010 12:18 pm Post subject: |

or you could use: writebyte(MSG_ONE, svc_setstat); writebyte(MSG_ONE, 31); writelong(MSG_ONE, self.morphactive); in your mod whenever you want to activate/deactivate it
and read cl.stats[31] in your hud code (it is of course a 32bit int).
cl.stats[31] is automatically cleared to 0 on each map change.
warning: sbar will not update on saved games - if a field named 'float _foo;' is initialised to 1 in worldspawn, then any time it changes to 0, resend the stat and reset to 1.
I don't remember the value of svc_setstat, consult your engine's protocol.h file.
regular quake uses about 16 stats, but has space for 32. The lower ones are replicated automatically in a really stupid and limited way, but the ones that are not replicated can be set to whatever values you want by your qc code. Note that you can also increase the max stats to give you more fields.
mods like rocket arena didn't have a choice - they weren't engine mods and didn't depend upon any.
_________________
What's a signature?

Back to top |

Mexicouger Joined: 01 May 2010 Posts: 129 |

Posted: Fri Jul 09, 2010 6:08 pm Post subject: |

Hmm. So lemme Get this Straight. Those Writebyte things in qc are ways to comunicate with the engine? I saw some of those things in the engine and I didn't know if they were important or not. I didn't really care either. But now they look interesting because cvars is giving me troubles.
Here's my rig(for that bouding box problem I had). This is in qorld.c in SV_Hullforentitiy

Code:
VectorSubtract (maxs, mins, size); if (size[0] < 3) hull = &model->hulls[0]; if (cl_player.value == 1) //If you are a player hull = &model->hulls[1];
if (cl_mball1.value == 1) //If you are a ball
hull = &model->hulls[2];
else
hull = &model->hulls[1];

I think this is a very bad way to do things. I had to use another cvar to do the balls HUD. I really would like to know more on that Writebyte stuff. Can you explain a bit more?
And I would like to note the Problems that code gives me. And maybe you guys would know the Problem.
1- When I have some bots orr other players in, And I turn to the ball, Their HULL changes to the ball HULL, and they fall to the Ground(I think anyways). They will be running and suddenly fall to the ground.
2- I think the HULL is a bit bugged. I had to move the setsizee negative code from '-12 -12 -24' to '-11 -11 -40' That was just to get the ball out of the Ground.... The collision is coded as-24.
3- The bombs fall through the floor. It's like they Don't see the top part of the Brush. You can slightly see them explode underneath the flooring.
Why do I have these Problems? I just want to Drop the dang ball. How could a flippin ball give so much hassle...
Thanks for the help. I truly appreciate it

Back to top |

Baker Joined: 14 Mar 2006 Posts: 1538 |

Posted: Fri Jul 09, 2010 7:25 pm Post subject: |

Mexicouger wrote:
Hmm. So lemme Get this Straight. Those Writebyte things in qc are ways to comunicate with the engine? I saw some of those things in the engine and I didn't know if they were important or not. I didn't really care either. But now they look interesting because cvars is giving me troubles.
Here's my rig(for that bouding box problem I had). This is in qorld.c in SV_Hullforentitiy

Code:
VectorSubtract (maxs, mins, size); if (size[0] < 3) hull = &model->hulls[0]; if (cl_player.value == 1) //If you are a player hull = &model->hulls[1];
if (cl_mball1.value == 1) //If you are a ball
hull = &model->hulls[2];
else
hull = &model->hulls[1];

I think this is a very bad way to do things. I had to use another cvar to do the balls HUD. I really would like to know more on that Writebyte stuff. Can you explain a bit more?
And I would like to note the Problems that code gives me. And maybe you guys would know the Problem.
1- When I have some bots orr other players in, And I turn to the ball, Their HULL changes to the ball HULL, and they fall to the Ground(I think anyways). They will be running and suddenly fall to the ground.
2- I think the HULL is a bit bugged. I had to move the setsizee negative code from '-12 -12 -24' to '-11 -11 -40' That was just to get the ball out of the Ground.... The collision is coded as-24.
3- The bombs fall through the floor. It's like they Don't see the top part of the Brush. You can slightly see them explode underneath the flooring.
Why do I have these Problems? I just want to Drop the dang ball. How could a flippin ball give so much hassle...
Thanks for the help. I truly appreciate it

Well ... there is quite a bit wrong with the above. If someone else doesn't beat me to it later today I'll outline some of what isn't right with the above and how to solve some of it.
The short version is that you warped the question from "how do tell it to use an sbar field" to something WAY different. That hull thing you are doing doesn't go in the engine, it goes in QuakeC -- I'm not refering to the sizes of the hull but assigning it for an entity.
_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...

Back to top |

Mexicouger Joined: 01 May 2010 Posts: 129 |

Posted: Fri Jul 09, 2010 7:33 pm Post subject: |

Well I couldn't find an inbetween size. It was either 3 is greater than 0, or player hull was less than 32. That means: 0 hull: 0-2 player: 3-32 Monsters: 32^ So there is no spot for a flipping ball size... So I was stuck....

Back to top |

Sajt Joined: 16 Oct 2004 Posts: 1026 |

Posted: Fri Jul 09, 2010 9:16 pm Post subject: |

If the server is a listen server (not dedicated), and the local client is a ball, ALL entities get the ball hull (2), otherwise hull 1. Apparently no entity will ever get hull 0. If the server is a dedicated server (no local client), all entities will be hull 1, all the time. Not what you would want, I think. What you are doing wrong: You're using a client cvar in the server collision code, and you're not using "else if" so you're just overriding previous cases. The first two if clauses have no effect at all because they are always overridden by one of the last two.
"Why do I have these Problems? I just want to Drop the dang ball. How could a flippin ball give so much hassle..." - It's not so much the ball giving you trouble, but going blindly into 50,000 lines of code (or something) and changing stuff without understanding any of it. Of course it will blow up in your face. I'm not knocking at you for being early in the learning process, I'm just saying, this is why "just a ball" is causing so much trouble.
WriteByte is how you communicate between server and client. By sending a stat or stuffcmding a cvar, the server (QuakeC) is changing something on that client's machine only (assuming you used MSG_ONE and not MSG_BROADCAST or MSG_ALL). But world.c is server-side code, so using client info (stats, cvars, etc) is wrong, wrong, wrong. For the hulls, what you should be is creating a new entity field and simply reading it from the entity in the engine. I don't remember off-hand how to do this but you could search for "gravity" or "items2" to find out. Or you could just add a new field in defs.qc and get a new progdefs.h, since your mod has its own engine anyway.
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> Engine Programming | All times are GMT Goto page 1, 2 Next
Page 1 of 2

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group