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
Digs 
Maybe try this one?
Or the wike tools
originals from 3D 
MadFox 
Thanks, but:
1. Looks like it's not single player sources
2&3. versions without fixed bugs 
Yes 
After downloading I also was surprised to find a mod progs.
I searched my whole archive as I was sure I downloaded it.
Can't find it though.

Seven made a new progs but it only works in DarkPlaces.

I wonder if the errors that appear in FTEQcc can be overcome by new coding, on behalve of the double count rotfish. 
@digs 
This one is probably the best with all the SP fixes:

https://gitorious.org/quakec-v1-01-clean

It took changes from "clean source" and "qip bug fixes" and combined it into one.

(Ignore the fact it says "1.01" -- that was the GPL base, you don't want to know more ...) 
@Baker 
Thanks!
After compile a have same 7 warnings. Example

doors.qc:626: warning F307: type mismatch: void() to void(entity attacker, float damage) entity.th_pain

doors:626: self.th_pain = SUB_Null;

function th_pain require 2 params, SUB_Null without params. Is it will work correctly? 
 
 
should work fine, see the 3 or 4 posts in the forum link above. 
 
@QMaster thanks 
Got A Tricky One 
So, I'm spawning monsters after the start of a level. Not just hiding them and then turning them on later, but actually creating new monster entities.

This involves a lot of tricky with spawn functions and precaches, but it works fine (props to gb/Preach).

What doesn't work is incrementing the monster count properly.

I'm using a custom writebyte to do this:


total_monsters = total_monsters + 1;

WriteByte (MSG_BROADCAST,SVC_UPDATESTAT);
WriteByte (MSG_BROADCAST,STAT_TOTALMONSTERS);
WriteLong (MSG_BROADCAST,total_monsters);


Which also works fine, but only the first time a monster is spawned. After that it increments the counter by 2 instead of 1. It doesn't keep on incrementing, no matter how many more I spawn, it just sticks at +2 per spawn.

I'm trying various solutions, but it almost seems like there is some engine side value which is being affected invisibly.

I've traced back all the occurances of total_monsters = total_monsters + 1; I can find and no luck. I've also shifted where/how its incremented a few times and turned off various parts of the process to try and localise the issue, but no luck so far.

Yes, I have an exclusion in walkmonster_start so that doesn't also add to the count...

Any ideas? I'm tempted to make it so that spawned creatures just don't add to the count, meaning the player can get >100% kills, but that's a sloppy fix. 
I Fixed It 
Stupid mistake in walkmonster_start 
 
Can I make a recursive function? What is the maximum stack depth? 
Recursion 
You can create a recursive function, the maximum stack depth is 32. This is possible to hit, see http://tomeofpreach.wordpress.com/2013/08/09/going-overboard-with-field-pointers/ for an example and a bit more detail.

Spike posted a warning somewhere on here that local variables to a recursive function are not reset between calls. So you should initialise all your variables like you would in C when writing a recursive function, rather than assume they get initialised to zero. 
@Preach 
Thanks. 32 is very small for my task. I'll have to think of something else 
 
How much time can be in progess the function? Can the engine to break it off if it is too long time? 
Instruction Limit 
The engine does have a limit, not strictly on time spent, but on number of instructions. You can only run 100,000 instructions in a single think, touch, spawn (etc) function before the QC concludes that there's a runaway loop and the engine packs it in. 
 
regarding locals getting clobbered in recursive functions, you can try '#pragma warning enable F302' to get fteqcc to print warnings when it detects that locals were not initialised before use.

fte/dp have a higher limit than 32.

you can get around the instruction limit by splitting up your routine into multiple thinks. in general your mod will be unplayable if you do not do this in the first place due to the stalls induced by running the qcvm.
in fte, there's some obscure 'sleep' builtin which will defer the current invocation/coroutine until a later time. doing this will preserve locals but not globals/fields. the instruction limit will be reset in the process. hurrah for infinite loops that won't lock up the game. just make sure nothing is harmed if some other think or whatever function removes the entities in the mean time... 
Preach 
I thought it was 100000 instructions per frame
Reset The Counter 
You get a new counter every time PR_ExecuteProgram is called, which means every time the engine calls a QC function of some kind.

They can even nest - suppose you are in a monster's think function, and use 50000 instructions before you call walkmove and collide with a player. You get a new lot of 100000 instructions to run the monster's collision function, then yet another set of 100000 to resolve the player's collision function, THEN you go back to the think function and get the remain 50000 instructions to wrap up there. 
 
ohhhh, nice to know i was being overly conservative then. this is like finding 20$ in my couch! 
Parsing Texture Names In QC 
Is it possible to return a string to a function that does traceline and returns the texturename of the wall that traceline hits. I understand that the entity returned would be world, but is it possible to get the texture name from the bsp surfacr? Like "brick2_4"? 
Nope 
 
 
probably darkplaces has this. 
Darkplace Does 
Check for extension DP_TRACE_HITCONTENTSMASK_SURFACEINFO

Then you can define:
string trace_dphittexturename;
then when you do a standard traceline, the texture name gets assigned to that variable.

One of the nice properties here is that there's no extra built-in function involved, so the code is very easy to make safe in engines which don't support the extension. In those engines, the texture name will always be "". So you can do stuff like special footsteps or impact particles on particular textures, and the other engines will gracefully degrade to the defaults for free! 
Example Using DP 
//----------------------------------------------------------------------
// Check for contact with sky brushes
//----------------------------------------------------------------------
float(vector targ_origin) check_pointcontent =
{
local float surfnum;
local string texturename;

surfnum = getsurfacenearpoint(world, targ_origin);
if (surfnum >= 0) {
texturename = getsurfacetexture(world, surfnum);
if (strncasecmp(texturename, "SKY", 3) == 0) return TRUE;
}
return FALSE;
}; 
The Same Function Without DP 
float(vector targ_origin) check_pointcontent =
{
����return (pointcontents(targ_origin) == CONTENT_SKY);
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.