|
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. |
|
|
Unsolicited Advice
#780 posted by Preach on 2012/04/22 15:47:03
Suppose that you are writing a mod which other mappers will use, and you want mappers to be able to control a parameter. In this post I will use corpse-duration in a corpse removal system as an example. Traditionally if you wanted a global property then you would add a field to worldspawn to set it.
Apart from it being a bit of a waste to add a field to every entity which is only ever read from worldspawn, I think there is a better pattern, which is a bit more powerful. The key use-case is a property which a mapper might want to vary as well as set initially. Corpse lifetime arguably fits this criteria, for example: during a large horde combat you might want to remove corpses faster than the rest of the map.
My suggestion is to create a new entity function as follows:
float corpse_duration;
void() set_corpse_duration =
{
��corpse_duration = self.count;
��if(!self.targetname)
����remove(self);
}
Then the way to set the corpse_duration initially is adding a point entity with classname set_corpse_duration and count equal to the desired duration.
Can any of you keen entity hackers see how we change it dynamically? Well, we set up an entity with the desired count, but with "classname" "info_notnull" and "use" "set_corpse_duration". If we set a targetname then every time we trigger this entity it sets the corpse duration. If you want to codify it as less of a hack you could invent a new classname for this kind of entity like set_dynamic_property, but it doesn't need any supporting code.
The remove(self) bit of code is a bit ugly, but it makes sure that initially setting the property doesn't cost you an entity, yet the info_notnulls can be used multiple times.
Mismatched Flags
#781 posted by sock on 2012/04/23 01:59:24
I am trying to query a monster to see if the current enemy has an artifact enabled. I am using (self.enemy) and I checked to see if it a player. I query the flags (self.enemy.flags) and it does not show the player flags properly. I tested this by using an artifact routine (void() powerup_touch) to print to the console what it was doing and it produced a different flags value.
I double checked the classname field and other player variables and it is certainly looking at the same entity, except the monster query will not show the content of the flags correctly.
Is there something strange about queries with the player flags?
#782 posted by necros on 2012/04/23 03:02:29
what value are you seeing? how are you querying for flags? flags must be checked via bitwise operation (self.enemy.flags & FL_CLIENT) will return 1 (true) for the player.
are you saying you do the above operation and it returns false when the monster is angry at the player?
also note that players gain and loose flags a lot during play, godmode, notarget, onground, partialground...
Fixed
#783 posted by sock on 2012/04/23 05:35:19
I was mixing up .item and .flag queries. I was too tired to see the difference and could not understand why. doh!
Ideas/tutorials For Useful Entities...
#784 posted by wakey on 2012/04/25 00:26:40
to add to progs.dat.
I'm quite the noob when it comes to coding.
Included misc_model entity from a old tutorial, but that was just copy/paste and compile.
For example i would love to have such swinging door's/ pushable func_rotate things like in ne_ruins.
Googled, found no tutorial for that yet, and dont know what other stuff could come handy.
Suggestions?
Inside3D Is The Place For Everything QC
#785 posted by negke on 2012/04/25 10:48:57
They have a forum and a set of tutorials on the site.
necros code is a different matter. I think it's part QC and part evil arcane magic, or something.
QC Beginnings
#786 posted by Kinn on 2012/04/25 12:39:37
For example i would love to have such swinging door's/ pushable func_rotate things like in ne_ruins.
If this is your first foray into QC I would forget all that stuff and just start small. Most of the QC tutorials you can find online are the "make a grunt shoot rockets"-type stuff but they will help you learn the basics.
The sort of stuff necros does (pseudo-physics movers and whatnot) is not going to be achieved with copy and paste.
#787 posted by necros on 2012/04/25 19:01:18
this is from last year, but i haven't really done much to the pushable rotaters since then anyway.
http://necros.slipgateconstruct.com/temp/ne_rotation_pushableRotaters(17.12.11).qc
i doubt it will work by plugging in, and it should be obvious it requires the hipnotic rotation code, but you can at last see what's going on. it also needs a lot of work still-- there is no implementation for other axis of rotation because those must factor in gravity.
overall, the concept is pretty simple: the movewalls have a touch function now that takes the speed that the player touches them with and dumps it into the rotators which then decays that speed over time. there's more to it of course, like translating velocity into angular momentum and such, but i'm not going to explain the whole thing. i think i've posted about it before, but i forget where.
for coding qc:
knowing about unit vectors, dot product, normalizing vectors, reflection, etc... (but you can always google this stuff up and learn it on the spot if you are not averse to that)
if you know some physics, that can help too, but you don't need to be a rocket scientist. (wow, when will that saying get old? maybe it already has...)
Thx Necros & Negke
#788 posted by wakey on 2012/04/25 20:36:21
for the code & link.
Looks very complicated for me, but the concept sounds logical, hopefuly i will learn enough about qc to understand the code eventualy.
Let's see what i will find on inside3d :D
#789 posted by necros on 2012/05/04 01:56:14
um.. what is trace_plane_dist?
the name implies it's the distance to the plane it hit, but after testing, i was seeing very strange values being returned, some in the thousands from a short 80 unit trace.
#790 posted by necros on 2012/05/04 05:48:51
a bit more testing... seems to be the distance from the origin based on the axis of the plane, so a trace on a face on the y/z plane returns distance from origin along the x axis.
non-axial planes returns strange values, some kind of combination of the different axis based on the slope of the plane?
It Is Probably The Plane Distance Using The Plane Normal
#791 posted by czg on 2012/05/04 08:36:56
http://mathworld.wolfram.com/HessianNormalForm.html
You can define a plane in 3D space using its normal vector and distance from origin (in the direction of the normal)
#792 posted by necros on 2012/05/04 18:59:43
thanks for clearing that up. :)
#793 posted by necros on 2012/05/11 20:01:03
is there any way to 'reset' frame aliases back to 0?
or is making a new qc file the only way?
Compiler Extensions
#794 posted by Preach on 2012/05/11 21:04:56
QTEQCC supports resetting the frame aliases using
$framevalue 0
(literally, the keyword is framevalue)
The need to make an extension suggests it can't be done normally.
#795 posted by necros on 2012/05/11 21:27:57
you mean fteqcc?
anyway, thanks. :)
Centerprints
#796 posted by necros on 2012/07/16 19:49:42
What is the maximum centerprint length?
Does it matter if you use the extra centerprint that allows multiple arguments?
Fitzquake has a bug that allows longer centerprint strings, but Quakespasm 'fixed' this, so that strings that display fine in Fitzquake spam the console with errors and truncate the string in Quakespasm.
:(
Centerprint Article
#797 posted by sock on 2012/07/16 20:15:39
http://www.inside3d.com/qip/q1/qcenhanc.htm#centerprint
From the page :
* The maximum number of characters in one string or multiple strings printed at once is around 2000.
* The maximum number of characters per screen line is 40, independent from the current resolution.
* The maximum number of lines per screen is 13, as more will cause weird problems in 320x200.
The links says max 2000 chars but 13 lines of 40 characters is 520 total. I assume Quakespasm is not liking those above limits?
#798 posted by necros on 2012/07/16 20:22:00
I brought this up before, and iirc, the 'limit' was actually higher than it should be. Apparently, the centerprint had some kind of unchecked thing which allowed strings that were too long to go through and it was only through luck that data wasn't being corrupted somehow. (and probably why it was never noticed?).
Bizarre Problem...
#799 posted by necros on 2012/07/25 01:05:08
I've got a bmodel with MOVETYPE_PUSH and SOLID_TRIGGER that moves via velocity.
Normally, I can be inside this entity when it moves.
For some reason, if I touch a rotate_object (which has no touch function, is MOVETYPE_NONE and is SOLID_NOT), the moving trigger bmodel becomes blocked! (it runs it's .blocked function too).
It's the weirdest thing ever...
Reproduction
#800 posted by Preach on 2012/07/25 01:39:30
This sounds like it might be quite a specific problem and so hard to reproduce, can you e-mail me a map/progs that displays the behaviour?
Solution
#801 posted by Preach on 2012/07/26 02:04:42
This might be a little opaque for anyone outside of me and necros.
The engine code underlying this problem is quake's blocking detection system. It's crude to the point of being technically incorrect, but infrequently enough that nobody has cared - before now. When a door moves, each entity is tested against the door:
Is the entity within the bbox for the door?(i.e between its mins and maxs, not exact intersection) If not move on.
Is the entity currently stuck? If not move on.
At this point the code attempts to move the entity the same distance as the door moved, in the hope this pushes it clear.
To see if it worked, we test again if the entity is stuck.
If it is stuck, we declare the door blocked and revert all the movement for this frame.
The flaw in this system is that we only test if the entity is stuck, not if it is stuck in the door. You can test this with a map with a func door which encloses the player without touching them in any way, combined with a solid brush which impales the player inside. The door will crush you without ever making contact.
Here endeth the general lesson. Specifically for necros: Your post missed something important out, the func_pressureBolt is MOVETYPE_FLY, which apparently causes the player to count as stuck and hence block the trigger. You set MOVETYPE_NOCLIP at line 73, but change to MOVETYPE_FLY at line 95. If you delete line 95 your trigger will work again.
If you are worried this class of bug might recur in other circumstances, I can outline an alternate design which uses a static rather than moving trigger, just ask!
#802 posted by necros on 2012/07/26 03:02:23
If you hadn't found the solution, I would have done the trigger movement via setorigin (since there's no collisions to check (beyond .touch of course).
You set MOVETYPE_NOCLIP at line 73, but change to MOVETYPE_FLY at line 95
*sigh* man, one day I need to rewrite my code... that's just sad. :P
But yeah, you are a genius man. I never would have imagined the rotation controller entity was behind the problem. Both it and the accompanying rotate_objects are SOLID_NOT. Why would the engine even check collision if it's not solid? Maybe because movetype_fly was intended for use with projectiles?
Very strange!
Thanks for yet another awesome bit of quake wisdom. :)
Motionless
#803 posted by Preach on 2012/07/26 21:43:20
My suggestion was going to be have a trigger which starts off at full height. Then just add
��if(other.mins_z < self.owner.maxs_z)
����return;
to the touch function for that trigger. Here self.owner is the visible moving entity which marks the upper end of the trigger. If there was no visible part you could calculate the height mathematically based on the time since triggering.
I'm still not sure why MOVETYPE_FLY matters, it might also be tied up in using a bsp model for the func_pressureBolt...the physics code is pretty dense and circuitous.
#804 posted by necros on 2012/07/26 21:51:51
Is this also related to that bug where a lift moving up/down will get the player 'stuck'? I had it happen more on some lifts than others, for example, that big lift in ne_ruins with the rotaters did it so much, there is actually code that sets the blocking entity's origin 1 unit up to stop the player being crushed.
|
|
You must be logged in to post in this thread.
|
Website copyright © 2002-2024 John Fitzgibbons. All posts are copyright their respective authors.
|
|