+use Alternative
#3085 posted by UnknownDud3 on 2022/04/22 00:15:27
Hey. I don't know much about quake modding yet but I am already curious if it's possible to implement a doom-like use command/key to interact with buttons, doors etc. Maybe there might be an example of such functionality?
@UnknownDud3
#3086 posted by metlslime on 2022/04/22 04:20:52
There is evidence in the code that they once had a use button, for example, there is a +use command that is defined in the engine code, and there is a ".float button1; //use" in the quakec source. But, the network protocol never sends or reads that data so it's not usable.
However, you can easily define your own use button -- the impulse system lets a mod define a large number of arbitrary inputs that the user can bind to keys and the quakec code can read and use. So you'd just have to bind a key to e.g. "impulse 50", then in your quakec code you can do whatever you want with that. Look in weapons.qc at the function "ImpulseCommands" for examples.
(also note, that you can put impulse checks for self.impulse in any place in your quakec code as long as it's in a function where "self" is expected to be a player.)
One final caveat, there can only be one "impulse" per frame so the player won't be able to both "switch weapons" and "use the door" on the same frame, one of those inputs will be ignored.
@metlslime
#3087 posted by UnknownDud3 on 2022/04/22 10:57:43
Thank you for the given information, I really appreciate your help! Though I still require any example (if one exists) where the use functionality is implemented as I can't figure it myself yet :(
About Use Again
#3088 posted by UnknownDud3 on 2022/04/22 16:48:40
I've looked through the qc files and found there are even functions for the use thing in buttons and doors code, but I can't get it what exactly has to be done to call them...
@UnknownDud3
#3089 posted by metlslime on 2022/04/22 18:46:41
When you see SUB_UseTargets in quakec, that is a different meaning of "use" than you're thinking. That's how various entities can trigger each other (e.g. when I pick up a key, it teleports some enemies. When I press a button, it opens a door.) Not the same concept as what you're looking for.
QuakeC String Hash
#3091 posted by ephemeris on 2023/01/10 04:56:55
TLDR is there a way to loop through string chars?
I am trying to implement a feature that requires passing a string through a level change. Specificly I want to preserve the last map the player was on so that I can pick the correct info_player_start. I found that the only string that persists across level changes is the username. I was able to get the feature to work by changing the user name to the current map then use this to match the correct info_player_start map field on the far side. For several reasons this solution sucks, now I want to compute a simple hash of the map name stuff that into a spawn param then compare that to hashes of the map field in player_start. How do I access individual chars in a string? reading the docs: string[index] does not look like it would work.
Ephemeris:
#3092 posted by metlslime on 2023/01/13 00:46:07
I don't think you can really do anything with strings in standard quakec. However, you should be able to accomplish your goal using numeric values instead.
Idea 1: the hacky way, hard-coding map names into quakec. You can check the worldmodel to see which map it is, set a value, then read it on the next map load. This is is how there is low gravity in e1m8
if (self.model == "maps/e1m8.bsp")
cvar_set ("some_unused_cvar", "1");
else
...
Idea 2: you can set a numeric property on the trigger_changelevel of each map, grab that value in quakec and set some variable to read when you get back to the start map. Then set the same unique values on the info_player_starts in your startmap. This is cleaner because all the special values live in map files not in your code.
More On Quake Strings.
#3093 posted by ephemeris on 2023/01/14 15:06:20
I suspect you are correct, I wanted to avoid the hard coded number field, it would work, but I had my heart set on using the map name.
As I find more and more docs, I am learning more than I ever wanted to know about quakec. fteqcc can index a string( string[index] ) but it requires a pragma target fte. and now nether DP nor quakespasm want to load the resultant progs.dat. I could probably go with fte and call it a day but I want to avoid limiting myself like that. Now I am trying to figure out what extensions darkplaces supports and there is a substr() function. this may work, No idea if can cast the result to a float(I suspect not). but that is my next attempt.
salutes and thanks for the encouraging words.
Euler Angles
#3094 posted by crystallize on 2023/01/23 20:19:25
How to calculate roll from a vector? I tried and atan2(-y, x) was best so far but roll can still jump from 162 to 77 when moving in loop-de-loop.
#3095 posted by metlslime on 2023/01/23 23:57:26
I don't think you can really get that. A single vector representing a forward direction doesn't have an inherent roll to it.
#3094
#3096 posted by Spoike on 2023/02/11 21:51:47
A number of engines have a two-arg version of vectoangles, the second being the 'upwards' vector that pairs with the regular 'forward' vector arg. It doesn't need to be fully perpendicular - its sole use is for computing the proper resulting roll angle.
You can then use makevectors twice, do some matrix maths to combine them (hurrah for order mattering), and then vectoangles2 to get back to eular angles.
vectoangles' buggy pitch values are still an issue though (along with mdl pitch too). just flip the sign as appropriate depending on bsp/spr/view/makevectors vs mdl/vectoangles.
QuArK Built In QuakeC Editor
#3097 posted by hbones on 2023/03/30 11:27:25
I've decided to use QuArK to start getting into quake modding (and I know it's not the best pick) but I like it as a full IDE. I was going to only use it for models and maps but by chance I found it supports QuakeC files with syntax highlighting, now the problem is that I don't really get it what exactly a QuakeC patch is that QuArK can make. I don't need to recompile id1 to get the progs? I'd really like to see a few examples. Another problem is that the text editor breaks spacing and cursor position after I put a bracket when syntax highlighting is on: https://x0.at/JDv2.png
Any way to fix that without disabling the highlighting?
#3098 posted by hbones on 2023/03/30 11:50:25
And now I just figured that whenever I try to "compile the QuakeC patch" within QuArK all I get is a memory access violation error...
https://x0.at/rufa.png
#3099 posted by Baker on 2023/03/30 13:13:29
You might consider using Visual Studio (freeish) and not using the QuakeC syntax and use real C syntax which fteqcc supports naming all your source files monsters.c or defs.h
Then you can autocomplete and go to definition and search/find like a true final boss.
It is known way to be productive in QuakeC, and a number of successful projects have a .vcproj file or similar in their QuakeC source dir.
And then just make .bat file shortcut on the desktop to fteqcc in your qc folder to compile your source.
#3100 posted by hbones on 2023/03/30 15:47:16
THanks for the reply, I am aware of other ways to work with QuakeC. Im just very curious about how it works in QuArK after seeing this video: https://www.youtube.com/watch?v=XB_em-5m7Z4
I have a little experience (really little) coding in QuakeC but I always thought you need to do changes to the existing sources and then compile them into a dat file although in the video just one QC file was used somehow
#3101 posted by Preach on 2023/03/30 18:19:53
I have a little experience (really little) coding in QuakeC but I always thought you need to do changes to the existing sources and then compile them into a dat file although in the video just one QC file was used somehow
What you thought was correct. Quark is not doing anything magical here - it's simply that the video has given you the wrong impression. The mod has been compiled earlier, using all the QC files off-camera. The video starts with the mod already compiled, and just happens to have one of the source files open on screen.
#3102 posted by hbones on 2023/03/30 23:06:12
Thank you for clarifying! May I also ask how to configure visual studio to work with QC? I only have experience with compiling the sources using FTEQCC directly
#3103 posted by Baker on 2023/03/31 03:12:58
You just have an empty project, drag files into the project and use it as a text editor.
I do the same thing you do to compile. I use the fteqcc directly (although I always use the fteqccgui for errors).
Visual Studio cannot compile QuakeC. The point is the code editor only.
#3104 posted by hbones on 2023/03/31 17:30:04
Also is there code highlighting in fteqccgui? According to some screenshots there is such functionality, but I have no idea where it's adjusted. And I noticed by rightclicking on something it can show the definition of that but it never works saying "there is no name currently selected", I tried to rightclick on a selected text and that didn't work too
#3102
#3105 posted by Spike on 2023/04/09 06:58:22
you can configure msvc to invoke external programs somehow. the ui for that has probably been changed completely since I last used msvc though.
when invoking fteqcc in this way be sure to use the '-fmsvcstyle' argument in order to have fteqcc spit out the error/warning output that msvc requires for being able to double-click errors/etc to jump to the lines indicated. otherwise it'll probably just ignore your attempts.
syntax highlighting is provided by the third-party scintilla component. if that wasn't enabled at compile time(read: because you compiled it yourself) then you get no syntax colouring - and a much worse editor experience too. all gui builds on TTH include it.
#3106 posted by Text_Fish on 2023/05/29 03:47:40
Has anybody created a (open source) mod of info_intermission that allows the mapper to point to a text file and make it print the contents on level change? Or one that achieves a similar effect to Quake's end of episode texts but without having to hardcode the text?
@Tex_Fish
#3107 posted by madfox on 2023/05/29 14:46:26
You could make use of the trigger_boss_gate.
This are the logic endings of an episode and switch with one of the four end runes to the text file, as they are used to complete the cycle.
Only thing you also have to do is change the progs.dat with a texteditor and use the same amount of text and replace it with your own.
@text_fish - Custom Intermission
#3108 posted by Preach on 2023/06/05 19:36:04
Untested code! This should be easy to patch into most mods:
1. Open client.qc, and look for the definition of info_intermission. Replace it with the following:
/*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16)
This is the camera point for the intermission.
Use mangle instead of angle, so you can set pitch or roll as well as yaw. 'pitch roll yaw'
*/
string custom_intermission;
void() info_intermission =
{
if(self.message) {
custom_intermission = self.message;
}
};
2. Scroll further down client.qc looking for the comment below. Insert the code in bold
//
// run some text if at the end of an episode
//
if (custom_intermission)
{
WriteByte (MSG_ALL, SVC_CDTRACK);
WriteByte (MSG_ALL, 2);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, SVC_FINALE);
WriteString (MSG_ALL, custom_intermission;
return;
}
else if (world.model == "maps/e1m7.bsp")...
Now you can add a "message" key on the info_intermission entity, and it will come up as the end text for the level. Note that if you have multiple info_intermission entities and give them [i]different[/i] messages, one message will overwrite all the others, and will display regardless of which viewpoint gets selected.
Spot The Error!
#3109 posted by Preach on 2023/06/05 19:38:23
Missed out a closing brace there.
WriteString (MSG_ALL, custom_intermission);
This is the kind of deliberate error Raymond Chen would put into a solution to make sure the recipient has their brain engaged. I'm not as cunning as he is though, it's just an honest mistake on my part...
|