|
Posted by metlslime on 2007/08/08 04:57:56 |
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. |
|
|
#1702 posted by necros on 2015/09/10 01:20:09
oh come to think of it, i think i understand what you mean; if you have a monster charging at you and it hits an angled wall or railing or something, it can still walk towards you following the railing whereas walkmove would just stop dead.
#1703 posted by Lunaran on 2015/09/16 02:58:49
String concatenation without crazy hacked compilers: possible? I can do it by abusing the 'stuffcmd' buffer and changing the player's name, waiting a frame, getting the player's .netname and then stuffcmding it back, but this prints messages about the player's name changing.
String Concat
#1704 posted by Spike on 2015/09/16 03:21:20
depends what you're cating. part of the problem is that even if you can hack the player's netname like that, you have to do it for every single string.
one trick (abused quite effectively in prydon gate, also in frikbot to a lesser extent) is to use writebytes for your sprints and centerprints and stuff. this can generally get close enough without visible side effects, but does mean that your strings need to be hard coded to some extent.
the last part of your message can still use writestring, so at least that part of it doesn't need to be hardcoded.
quakeworld could do something with the server's localinfo, but this does still impose a frame's delay due to localcmd.
#1705 posted by Lunaran on 2015/09/16 04:35:11
Yeah, I'm trying to create guaranteed unique targetnames, so centerprint effectively goes into the void.
Fuck it, I might as well just make them all numbers.
Here's a real contribution: I made a Notepad++ userDefineLang.xml preset for QuakeC syntax highlighting.
http://pastebin.com/G0s8mw92
it also colors quake's required globals (like self etc) and all the builtins.
Well, That Doesn't Work
#1706 posted by Lunaran on 2015/09/16 05:23:28
apparently if you set something's targetname to just ftos(some_integer), it somehow changes to other numbers as you move around!
#1707 posted by necros on 2015/09/16 05:36:07
ftos stores the string it creates in a shared spot in memory. if you call ftos multiple times in a frame, all strings you assigned ftos to, even if they were different numbers, will have the number of the last ftos call.
this is true for vtos as well.
Ftos
#1708 posted by Spike on 2015/09/16 05:46:30
works in fte. :)
but yeah, in most engines, builtins that return temporary strings will overwrite the previously returned one(s), such that the old reference now refers to the new value. which is really useless.
either that or it starts complaining about stale/invalid tempstrings. including when saving games. potentially even with crash-to-console results...
as a general rule, if you have a tempstring, NEVER store it to a field or global (if you have the somewhat common frik_file engine extension, then you can use strzone for these usecases).
findfloat doesn't exist in vanilla qc (and hacking find to find a float is unreliable too, and potentially crashy), but you can use nextent to itterate over all entities manually. obviously its less efficient, but if you're really trying to avoid extensions then you won't have more than 600 ents anyway.
Ok I'm Going To Bed
#1709 posted by Lunaran on 2015/09/16 06:15:02
I spawn an entity, set its targetname to self.netname, check it with an eprint, change my name, eprint it again, and the fucking targetname on the entity has changed to my new name.
I don't have a fucking clue in the world what's going on here.
#1710 posted by Lunaran on 2015/09/16 06:17:33
wait, are ALL these string fields referenced rather than copied?
Styring References
#1711 posted by Preach on 2015/09/16 08:08:47
Lunaran: yes, it's a reference to your name string buffer. Some engines offer extensions like "zone" for allocating new buffers.
Depending on what you need to do with strings, there may be a way to do it building the string character by character at time of use. This is the way that Prydon Gate makes its menus, for example. I wrote some articles on how to organise this so it's not quite as awful as it sounds, starting at https://tomeofpreach.wordpress.com/2013/03/28/text-manipulation-in-quake-i-the-basics/
#1712 posted by Lunaran on 2015/09/16 14:51:35
I read those. Doesn't work for my needs, unfortunately. Seems any mechanism I use to exploit that buffer trick is going to be foiled by whatever field I try to exploit to capture its result. I don't want to start exploring engine specific code, either.
A giant lookup table it is then.
Lunaran
#1713 posted by mfx on 2015/09/16 20:26:38
Thx for the xml!
Lookup Tables
#1714 posted by Preach on 2015/09/16 20:47:40
What you up to Lunaran? Sometimes there are ways to avoid them in QC, as they're never a pleasant task to maintain.
#1715 posted by necros on 2015/09/16 22:47:21
I assumed a giant array of strings each with a unique name?
Yep
#1716 posted by Lunaran on 2015/09/17 06:52:35
f.write("\\tswitch(num)\\n\\t{\\n")
for i in xrange(256):
. s = str(i)
. f.write("\\t\\tcase "+s+": return "node"+s+"";\\n")
f.write("\\t}\\n\\treturn string_null;\\n}\\n\\n")
#1717 posted by Lunaran on 2015/09/17 06:53:00
hm. func is weird with backslashes.
QC Math To Calc Odd / Even Number
Has anyone run across or can post some QC that can tell weather or not a number on the positive number line is odd or even?
#1719 posted by Mandel on 2015/09/25 19:56:27
Surely, lacking a modulo operator, something like this must work:
if (number & 0x1) {
// odd
}
else {
// even
}
#1720 posted by Lunaran on 2015/09/25 22:46:35
"positive number line"
#1721 posted by Spike on 2015/09/25 23:22:05
float(float a, float n) modf = {
return a - (n * floor(a/n));
};
modulo with floating point types is fun.
but yeah, if its just odd vs even, just use value&1.
Weapon Animation Going Faster Than 10 Fps
#1722 posted by aDaya on 2015/09/30 11:21:13
For some who've been on the modelling help thread, I've been working on a machinegun weapon. I've been able to complete them and are ready to be implemented in the game.
Thing is, the viewmodel has been designed to run at 0.05 sec for each frame, more than the minimum 0.1 sec. But I've seen there's a way to go past this, as seen here: https://youtu.be/E5zyhlZ1xVI?t=2m22s .
I know Q2 got around that as well with the Chaingun's second spin, and from what I've seen in the sourcecode, the same fire pattern is applied a second time but with a 0.05 delay. Thing is, I have no idea how to accomplish it, can anyone help me on that?
Also, the weapon is supposed to fire at every two frames, the inbetween are for cosmetic purposes (meaning it'll fire as fast as the NG/SNG), and I intend to apply the same fire programming seen from the Nailgun/SNG (where the fire trigger is tied to the animation)
Variables For Storing Persistent Info Between Maps
#1723 posted by Kinn on 2015/09/30 11:24:07
I know we once had a long discussion about the most efficient and safe way to store information between maps (say if one was to try to make a hub-style continuity across maps) - anyone remember this, and got link to the posts?
Kinn
Not sure about that but I'm pretty sure Socks mod new mod has a better way to do this now.
#1725 posted by Lunaran on 2015/09/30 17:44:09
Daya - view weapon anim is driven by the player model's animation state, which is crappy. there's not-insignificant reengineering to be done to decouple them.
Kinn - parm1-parm16.
Kinn,
|
|
You must be logged in to post in this thread.
|
Website copyright © 2002-2024 John Fitzgibbons. All posts are copyright their respective authors.
|
|