• What do you need help with? V4 (January 2012)
    966 replies, posted
  • [QUOTE=WTF Nuke;34821399]Flub, I think it'll be easier if you just used std::cout rather than typing using std::cout. I might be wrong on this though, but I find it cleaner to just type std::cout rather than what you're doing.[/QUOTE] I mainly do it because I just want to keep a bunch of statements I'm gonna use at the beginning of every shitty program I write, so I don't have to rewrite it each time. Basically I just erase everything in int main(){} when I want to write a new program for practice.
  • It's a long shot, but in the source engine, anyone know why tracelines might not be registering hitboxes unless the traceline passes through the bbox of a player? I know for a fact this doesn't happen in dod:s for example, a player can be prone on the ground and their bounding box covers their torso at most yet the trace still impacts with the player hitboxes. Here's an example of it in my mod: [img]http://i.imgur.com/87kMd.jpg[/img] You can see the bbox around the player, the hitboxes on the player and the white lines representing the traces. They don't register hitting the arm hitboxes because it was outside the bbox. If I turn around slightly and shoot at the same arm hitbox but make it clip through the edge of the bbox, it works as intended. Any ideas?
  • Someone could help me how to use time.h ? Please. I want put automatically the time when the user data was registered.
  • [QUOTE=Jimbomcb;34834101]It's a long shot, but in the source engine, anyone know why tracelines might not be registering hitboxes unless the traceline passes through the bbox of a player? I know for a fact this doesn't happen in dod:s for example, a player can be prone on the ground and their bounding box covers their torso at most yet the trace still impacts with the player hitboxes. Here's an example of it in my mod: [img]http://i.imgur.com/87kMd.jpg[/img] You can see the bbox around the player, the hitboxes on the player and the white lines representing the traces. They don't register hitting the arm hitboxes because it was outside the bbox. If I turn around slightly and shoot at the same arm hitbox but make it clip through the edge of the bbox, it works as intended. Any ideas?[/QUOTE] It's probably because the Engine uses the Bounding Box as a fast pre-pass test. Since it never enters the bounding-box it never tests the hit boxes. Not sure there is an easy solution unfortunately. :(
  • So I've hit sort of a brick wall. I know what I want to do, I know how to do it in most sane languages (C, Python, Lua, etc.), but there isn't a single way to do it in Javascript that isn't fucking horrible. What I want to do is stop execution, then resume at the same point in code. Really, nothing more than a non-busy wait... something to indicate to the VM that it can take a break and go work on something else for a while. JS is probably the only language in the world that doesn't have such a thing, and, ironically, it's probably the only language in the world that really [i]needs[/i] it, since you're sharing resources with lots of other JS programs and browsers don't have multitasking schedulers. The setTimeout solution for this particular problem is really filthy.
  • How was it that you get a point in say a 2d image using an index? I seem to remeber it was something like: x = i / width; y = i % width;
  • [QUOTE=Richy19;34838655]How was it that you get a point in say a 2d image using an index? I seem to remeber it was something like: x = i / width; y = i % width;[/QUOTE] It's either: x = i % w; y = i / w; or: y = i % h; x = i / h; Depending on whether your image is column-major or row-major.
  • 2 C# questions, REALLY fucking urgent. First, how do I make it so a program opens a file in the software it's meant to be opened in (like a word document in word etc) Second, when using openxml, how do I stop the error where an edited excel file doesn't say it's unreadable when you try to open it afterwards and all the crap related to that. Thanks.
  • [QUOTE=Jimbomcb;34834101]It's a long shot, but in the source engine, anyone know why tracelines might not be registering hitboxes unless the traceline passes through the bbox of a player? I know for a fact this doesn't happen in dod:s for example, a player can be prone on the ground and their bounding box covers their torso at most yet the trace still impacts with the player hitboxes. Here's an example of it in my mod: [img]http://i.imgur.com/87kMd.jpg[/img] You can see the bbox around the player, the hitboxes on the player and the white lines representing the traces. They don't register hitting the arm hitboxes because it was outside the bbox. If I turn around slightly and shoot at the same arm hitbox but make it clip through the edge of the bbox, it works as intended. Any ideas?[/QUOTE] Sounds simply like you're not masking your trace correctly.
  • [QUOTE=amcfaggot;34838822]Sounds simply like you're not masking your trace correctly.[/QUOTE] The traces are being masked perfectly fine, I managed to find some of the engine level tracing stuff (from the hl2 leak by chance) and Lord Ned was right, it doesn't bother searching for hitboxes because it was using the bbox as a faster pre-pass test. Managed to work around it anyway.
  • I'm going to need some pathfinding but i'm not using tiles. So i'm thinking of using preset waypoints and just loop through them to find the closest to the target, and then move the NPC to the closest waypoint or something. Could I still use A* for something like that or what?
  • You can use A*, just make areas into nodes(they should be equal in size) and the NPCs will just follow the nodes to their destination node.
  • Hey guys, I need help with infix to prefix conversion, I understand the concept but I don't exactly know where to start out.
  • [QUOTE=evil-tedoz;34840506]Hey guys, I need help with infix to prefix conversion, I understand the concept but I don't exactly know where to start out.[/QUOTE] For infix to RPN (postfix): [url]http://en.wikipedia.org/wiki/Shunting_yard_algorithm[/url] I find that useful because RPN is easily parsed by a simple stack machine. You would probably be able to modify it a little bit to produce prefix, though.
  • So, I need some help guys.. I've made a resource manager, which scans a given folder and loads all the resources it can find. I also have a resource base class which have child classes for different kind of resources. My resource manager contains a factory to create resource instances of the different types. The problem I have is that when it finds a file, how does it know which kind of resource to instantiate?
  • [QUOTE=evil-tedoz;34841190]You could try to look for the extension, as in : .txt, .png, etc.[/QUOTE] My first solution was to allow the user to map simple wildcard patterns to resource types, like a "*.png" maps to a ImageResource, but then you can also do more advanced stuff like "map*.png", which would perhaps map to a MapResource. But then "map01.png" would match both the "*.png" and "map*.png", so which one should it choose? I'm not even sure I need that level of versatility :v:
  • [QUOTE=Z_guy;34841304]My first solution was to allow the user to map simple wildcard patterns to resource types, like a "*.png" maps to a ImageResource, but then you can also do more advanced stuff like "map*.png", which would perhaps map to a MapResource. But then "map01.png" would match both the "*.png" and "map*.png", so which one should it choose? I'm not even sure I need that level of versatility :v:[/QUOTE] Just use nongreedy matching - that way the wildcard in map*.png will match anything it can up to .png but it won't match the .png.
  • [QUOTE=Z_guy;34841056]The problem I have is that when it finds a file, how does it know which kind of resource to instantiate?[/QUOTE] For every supported resource type, include a type checker in addition to the loader. For binary formats, it's usually as simple as checking the magic number and version numbers. i.e. [cpp] bool isbsp(uint8_t *data, int n) { if (n < 4) return false; return data[0] == 'I' && data[1] == 'B' && data[2] == 'S' && data[3] == 'P'; } [/cpp] Then you do: [cpp] if (isbsp(data, n)) return loadbsp(data, n); if (ispng(data, n)) return loadpng(data, n); if (isjpg(data, n)) return loadjpg(data, n); // etc... [/cpp] Of course it's a little more difficult for plaintext formats. At that point you pretty much have to guess by the extension/source. I've never been a fan of file extensions, though. I wouldn't really go for wildcard-matching. I don't really have a good reason, it's just personal preference. I'd just split the last period-delimited substring off and check that against an extension string. IMHO, simpler, cleaner.
  • [QUOTE=ROBO_DONUT;34841742]For every supported resource type, include a type checker in addition to the loader. For binary formats, it's usually as simple as checking the magic number and version numbers. i.e. [cpp] bool isbsp(uint8_t *data, int n) { if (n < 4) return false; return data[0] == 'I' && data[1] == 'B' && data[2] == 'S' && data[3] == 'P'; } [/cpp] Then you do: [cpp] if (isbsp(data, n)) return loadbsp(data, n); if (ispng(data, n)) return loadpng(data, n); if (isjpg(data, n)) return loadjpg(data, n); // etc... [/cpp] Of course it's a little more difficult for plaintext formats. At that point you pretty much have to guess by the extension/source. I've never been a fan of file extensions, though. I wouldn't really go for wildcard-matching. I don't really have a good reason, it's just personal preference. I'd just split the last period-delimited substring off and check that against an extension string. IMHO, simpler, cleaner.[/QUOTE] Thank you, this was helpful, it got my cogs going again.
  • [QUOTE=shill le 2nd;34833466]Only value types (primitives and structs) get copied.[/QUOTE] C# doesn't have any concept of 'primitives'
  • [QUOTE=Jimbomcb;34839407]The traces are being masked perfectly fine, I managed to find some of the engine level tracing stuff (from the hl2 leak by chance) and Lord Ned was right, it doesn't bother searching for hitboxes because it was using the bbox as a faster pre-pass test. Managed to work around it anyway.[/QUOTE] You'll find that there are a decent number of things with Source that are like this. You're best keeping an extracted copy of the leak for reference; I do and it helps a lot. Glad you found out the issue.
  • What does it mean to "return f( x, y, z )" as opposed to "return n" in a function, in C++, whereas f is a function?
  • [QUOTE=Flubadoo;34846025]What does it mean to "return f( x, y, z )" as opposed to "return n" in a function, in C++, whereas f is a function?[/QUOTE] It means return whatever the function f(x, y, z) returns
  • So it runs the function f inside of the function where return f(x, y, z) was located?
  • Any idea why this snippet of C code makes me unable to type anything in the console? [cpp] char opt; do { opt = getchar(); } while (opt != 'e') [/cpp]
  • Fixed it, never mind. Didn't freeze - it just took a while the first time I ran the program which is weird. [quote=esalaka]why are you storing getchar in a char[/quote]I omitted the other code that comes in after "opt = getchar()" in the loop because it wasn't relevant to the problem.