News | Forum | People | FAQ | Links | Search | Register | Log in
Coding Help
This is a counterpart to the "Mapping Help" thread. If you need help with QuakeC coding, or questions about how to do some engine modification, this is the place for you! We've got a few coders here on the forum and hopefully someone knows the answer.
First | Previous | Next | Last
Abandon All Hope Ye Who Concatenates Strings 
the vanilla engine has only two ways to concatenate strings.
The first is that some of the builtins that accept a 'single' string argument will perform an implicit strcat. this is useful primarily for centerprint, but also works with bprint+sprint+error+objerror too.
The second is that console prints don't have any implicit new-lines, so you can just call sprint 50 different times to construct a single line. There are numerous mods out there that do things like this in order to try to print various numbers etc.

Other than that, you're screwed. Have a nice day.

If you're okay with requiring engine extensions, fte+qss+dp all have strcat builtins, and are all mostly compatible.
However, note that each of these engines have different temp-string behaviour. Strings in QC are essentially just pointers, so the memory that the pointer/string refers to can actually change and contain some other string entirely (usually as a result of calling other builtins that return temp-strings).

vanilla: ftos and vtos both return the exact same bit of memory, with every single call.
qs/qss: multiple temp strings - after 16 different temp-string-returning builtins have been called (from anywhere) it'll start reusing
the oldest temp-string. Use strzone if you want it to last longer.
dp: unlimited temp strings - call strcat or whatever as much as you want, but they'll ALL be forgotten once the QC returns to the engine, so ANY field or global that contains a tempstring will cause warnings when saving the game, etc. Use strzone still to avoid that.
fteqw: persistent temp strings - call strcat or whatever as much as you want. Store them in fields too, if you want.


Actually, there is a way to do strcat even in vanilla, but its so evil, obtuse, and just generally annoying that I'm not going to describe it. It also breaks compatibility with almost every other engine too, and can even be broken by just the C compiler that the engine was compiled with!

So if you're explicitly targetting vanilla and your targetname thing, just use two fields.
Whereas if you're doing more complex stuff, then you'll need to get people to stop using vanilla or quakespasm, and start using a decent engine instead that actually supports strcat (probably qss, because its basically just a super-set of quakespasm making it an easier engine to 'sell'). 
 
get people to stop using vanilla or quakespasm, and start using a decent engine instead

Eat shit, you gigantic self-fellating cuntflap of a non-person. 
 
OTP, if your definition of 'decent' is one that leaves things crippled and requires obtuse workarounds, then that's your problem, not mine. 
 
Your engine can have every thing ever requested by mappers and players alike and itd be nullified by the lack of documentation.

Want us to make the switch? Create some documentation. Make the source easier to access. I have reasons to use your engines but the lack of documentation is a huge turn off 
@Mukor 
Use the pr_dumpplatform command and then just read through the resulting qsextensions.qc file if you want a list of the added qc extensions. Read the included comments if you want to figure out how to actually use it.

For particle effects, you can find some specs on fte's svn, or if you're sticking to dp-compatible stuff then you should be able to find info on that stuff on dp's site somewhere. 
 
Use the pr_dumpplatform command and then just read through the resulting qsextensions.qc file if you want a list of the added qc extensions.

Does this actually work in QSS? I can't find the resulting qc file 
Also 
you mentioned once that CSQC for custom HUDs could be coming for QSS - is this still planned? 
Another Question 
Now here is another thing:
Today I was testing and I noticed that no matter what ever T_Damage value I set for W_FireJazzAxeJazzaxe deals the same damage as in FireAxe.

I had set damage 40 for jazzaxe earlier and today I noticed it took me the same amount of hits to kill a shambler with the regular axe and jazzaxe.

Then I changed the regular axe damage to 600 and both axes kill the shambler instantly.

How do I fix this?
I want the jazzaxe to replace the normal axe like with the hammer in quoth and the jazzaxe should deal its own damage.
How do I do that?

(also I seem to have figured out how to add sounds like when you hit an enemy in AD and Drake.) 
Axes 
I can't be sure without seeing the code but it sounds like W_FireJazzAxe isn't being called.

First step would be checking W_Attack further down in weapons.qc and checking that your (presumed) if (self.weapon == IT_JAZZAXE) clause is pointing to a different player animation function than the normal axe.

If it is, then check that the relevant function in player.qc contains W_FireJazzAxe() instead of W_FireAxe() 
 
add a call to error("function name here"); into both functions.
then you'll see which one is actually getting called.
it should also give you a stack trace, so you can figure out where its getting called from too.

(or if you're using fteqccgui+fteqw, you can just set a breakpoint and then step through the code.) 
I Got It! 
The problem was this

void() player_jazzaxe1 = player_axe,not jazzaxe! 
... 
I don't want to clog this thread with my questions so I gave my email. 
Use Notepad++ 
It has a search in folders option to let you find every instance of .items2

.items2 was derived from the rogue mission pack since .items ran out of bits. 
So in which file can I find a way to derive?

Do I just add

.float items2 in defs.qc?

Then how do I add stuff to it? 
Treat It The Same As Self.items 
Ya just add it to defs.qc or anywhere in the compile order before you use it.

Add in any IT2_JAZZYSTUFFBITS = 1, 2, 4, 8, 16, etc flags. The only really tricky bit is in situations like weapons where you need to know when to check .items and when to check .items2 or you'll be able to switch to weapons you don't have, or accidentally give yourself quad or something. 
Can Teleportation To A Random Destination Be Done In Qc? 
if a trigger_teleport has multiple destinations with the matching targetname, it will always pick what I assume is the the one that is loaded first in the map and therefore has the lowest index of some sort that the find function looks for. I'm not really sure how it works since find is only defined as #18 in the code. I'm not very well versed in qc or regular c for that matter. I implement stuff by deriving heavily from existing code, so I'm at a loss here.

I need a more thorough find function that takes an additional index parameter that returns the first entity whose targetname and index match the given arguments. Then I would only need access to the amount of entities with that targetname and could generate a random number between 0 and that amount to use as the index argument.

I assume the reason find isn't defined in qc is that the the finding process can only be done by the engine, which would be a death sentence for my mod. I stand even less of a chance of understanding complex engine code than qc, and even if I did manage it the mod would be dependent on my custom engine branch which would make it an even harder sell to potential players.

I'm pretty much ready to throw in the towel, but I figured I'd try consulting the mighty code wizards first. Is there a way you could see making random teleportation work without engine modifications? 
 
just call find in a loop with the first arg set to the previous call's return value, until it returns world.
you then know how many matches there are, and you can pick a random index and select that destination with a second find loop.
no engine changes necessary. 
Thanks Spike 
works like a charm 
Alternative 
Here's a sneaky way to randomly select while only looping through the list once

https://tomeofpreach.wordpress.com/2013/10/19/random-entities-find/ 
Post 2513 
If my memory serves me well,
Custents has a random teleport code.
Or was it nsoe_devkit? 
It's Getting Annoying 
I keep getting this error
Warning Q208:progs CRC not recognised from quake or clones.
This always happens.
If I make a new weapon to add to RRP?
Happens.
Copy the fx_beam and telefrag?
Happens.
Part of my code is copied and modified from RRP,Custents and some other sources.

Today I had to reset all my code because of their error.I call it an error because it compiles,but you can't run the game.


How does this warning happen and why?
How should I fix it? 
 
Warning Q208:progs CRC not recognised from quake or clones.
This can be translated to:
Don't fuck with the initial part of defs.qc

NEVER change 'ANYTHING' before the 'end_sys_fields' line of defs.qc or you get that warning.

(actually, you can change comments, add some preprocessor (like #pragma warning error Q208 etc), etc, but if any of the basic types or names changes, or any symbols are added or removed, then you will have problems as the interface between the engine and progs will end up incompatible.)

(one option is to just include [fte|qs]extensions.qc (not dp's though) before your defs.qc, as it includes systemdefs appropriate to its configured target. you'll also get extension builtins defined for you.) 
Or Use A Separate Defscustom.qc For Your Mod Variables. 
 
2 posts not shown on this page because they were spam
First | Previous | Next | Last
You must be logged in to post in this thread.
Website copyright © 2002-2024 John Fitzgibbons. All posts are copyright their respective authors.