|
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. |
|
|
Gatlingsound ()
Sorry, the () is required otherwise it might cause that compile error:
if (gatlingsound ())
// pretty sure this will proceed only if true, but I have seen cases where negative intergers cause a true in some engines , IE: -1, -2 etc.
Lmao
#1851 posted by Kinn on 2015/12/04 21:13:23
float() gatlingsound =
{
return (TRUE); // add return
};
Can we just agree this is dumb as hell and not do it like this?
Just use a constant.
Soundbuffer ()
Also, I have made soundbuffers in my mod but using just the basic sound command "play" stuffed to the console. I suppose it could be done with regular sound calls, best to define a special sound channel for it though, IE : CHAN_BUFFSOUND = blah
Where blah is the sound channel number. Darkplaces suppoert up to 128 sound channels total, not sure if other engines expand the sound channel range.
Basicly:
.string buf1,buf2,buf3,buf4;
.float sounbuffer
So you play the first sound, then call a new function that lists all the possible sound strings that the playing sound can be, and returns a float value equal to the total time it takes to play the sound in seconds, for each given sound. Then -
self.soundbuffer = time + SUB_SNDLEN (current sound);
In PlayerPRethink () , you add
if (self.soundbuffer < time && (self.buf1 != "" || self.buf2 != "" || self.buf3 != "" || self.buf4 != ""))
SUB_ChkSndBuffer ();
From there you just make the new function that checks all 4 buffers if a string is present. If so, clear that buffer with a null (""), and send that old string over to the function to play a buffered sound. that function also needs to scope through all the buffers in order in the even lost of sounds are stored.
Most Engines Have 7 Xhannels
#1853 posted by necros on 2015/12/04 22:33:40
1 to 7 are explicit and 0 is whatever is free.
Of course, you can just spawn new entities and have unlimited channels.
#1854 posted by Spike on 2015/12/05 00:27:06
actually, that's a common falacy.
channel 0 is not 'whatever is free', its a 'don't terminate anything'.
of course if you do play lots of sounds at once then things can get VERY LOUD, which is why stuff tends to use an explicit channel, especially if the later half of the sound is a little echoy such that it sounds stupid when you have multiple instances playing with 0.1 sec intervals.
there may still be a global limit on the total number of sounds that can be playing at once, but thanks to static sounds this is typically quite a high limit (read: thousands).
It's Okay Guys
#1855 posted by aDaya on 2015/12/05 00:57:21
Preach's way was compatible with what I wanted to do, and it goes as expected and flawlessly.
But still, thanks for your attention.
#1856 posted by necros on 2015/12/05 02:05:00
i have also noticed if you try to play the same sound twice in the same frame, the engine will ignore it (or play at half volume?).
the only way around that i've seen is to create two separate .wav files that are identical and play the "different" sounds at the same time.
#1857 posted by Spike on 2015/12/05 14:47:35
if you start two sounds at once on the same entity (on different channels) all you will have done is to double the volume.
with different ents, you will have spacialisation differences so there is still a purpose, but it will still be extra loud.
FTE does randomize the start time of the second sample slightly (this is something q2 also does). This tends to make it a little more echoy without making it quite so obnoxiously loud - more sounds means that it'll *probably* be louder, but this isn't guarenteed as the time difference will negate this effect by a not insignificant amount so volume 1.2 or so instead of 2.0.
This is the sort of thing you want if you have 20 identical monsters all seeing you in the same frame.
It can also potentially help in deathmatch too.
Z-aware Grenade Shooters?
#1858 posted by aDaya on 2015/12/15 18:47:09
I'm continuing on doing monster reskins, and I want to make an Enforcer that's similar to the Defender, but I want it to shoot grenades while being Z-Aware, unlike the Ogres, and maybe make it explode on contact (they'll have to be weakened if I want to do that).
I remembered Inside3D/InsideQC had a tutorial for that, but for some reason I can't find it.
Can anybody help me on that case?
#1859 posted by Lunaran on 2015/12/15 21:20:53
#1860 posted by madfox on 2015/12/16 05:08:23
I remembered Inside3D/InsideQC had a tutorial for that, but for some reason I can't find it.
Try this one,it's not hijacked:
http://www.insideqc.com/qctut/
Thanks Lunaran, Also
#1861 posted by aDaya on 2015/12/16 11:34:46
I did a Grunt shooting accelerating rockets, I tried to make in a custom explosion sound, but it plays the vanilla one instead and the explosion sprite doesn't come up.
code: http://pastebin.com/0aBFGkFP
Another thing, still on that Defender-like: how to make him trigger an attack where the player is in a set distance? Looking at the Ogre code doesn't seem to answer me.
and MadFox, this is exactly where I went, but I couldn't find it.
Another Thing
#1862 posted by aDaya on 2015/12/16 12:00:53
What's the way of reducing the amount of stun taken by a hit for a monster? Is it related to armor values?
.th_pain Or Pleasure
#1863 posted by Preach on 2015/12/16 12:28:34
You need to look at the function in ".th_pain". Two good examples are knight_pain and sham_pain.
Typically there are three decisions to make in a pain function. The first is whether the monster had a pain animation recently or not. Usually this is a bit of code like:
if (self.pain_finished > time)
���return;
self.pain_finished stores the first moment the monster is allowed to go into pain again, and this code skips a pain animation entirely if it's too soon. This is a very important bit of code because it stops pain animations overlapping - without it you'd have monsters entirely stunlocked by a stream of nails.
The second choice is to decide if the damage is high enough to trigger pain. Typically only very large monsters do this, like the shambler:
if (random()*400 > damage)
���return;
This means we skip the pain animation randomly, in proportion to the damage inflicted. For example, a shambler will only go into pain from a 200hp hit 50% of the time. A full double-shotgun blast does ~50hp, so that's only a 1-in-8 chance of a pain animation. 400+ hp in one blow will always cause shambler to go into pain, but even a quad rocket to a shambler isn't powerful enough for that.
The last choice is selecting which pain animation to use, here's the code for the knight:
r = random();
if (r < 0.85)
{
���knight_pain1 ();
���self.pain_finished = time + 1;
}
else
{
���knight_painb1 ();
���self.pain_finished = time + 1;
}
The line knight_pain1(); start this pain animation immediately, and it will run to the end before the monster starts attacking again. The main difference between these two animations is that knight_painb is much longer. A way to make the pain animations less severe is to pick the short animations more often, so the monster resumes fighting earlier.
You'll also notice that it's this part of the code which sets the pain_finished time, in this case saying the knight won't go into pain for 1 second. The enf_pain is an elaboration on these ideas, as there are 4 pain animations to choose from, and the last one has a longer pain_finished time than the other. So another way to make your monster resistant to pain is to increase these times, but be careful! Setting these too high made the Quoth monsters irritating to fight, as they were too relentless.
Ogres Lob Grenades Into Cover
...is what I believe the original post on inside3d was. Me and Prime collaborated on this into Gnouc's clean src a while ago into a creepcam2 project. IT seemed to work pretty good from what I remember, and I thnk we put in a skill comparison to activate it as well. YOu can copy the code from the Ogres function here: [ https://github.com/teknoskillz/Creepcam2/blob/master/monsters/ogre.qc ]
Right Handed LG Pos
Trying to _perfect_ as best as possible the starting pos of the LG beam using a right handed vwep model sort of like the one in dpmod has. The tricky part is finding a compromize between the 1st person view, and the external viewposition. I believe there is no perfect fit, but this is the code I am experimenting with in W_FireLightning ()
local vector angl;
// angl = self.v_angle;
angl = self.angles;
normalize (v_forward);
org = ((self.origin + (v_right * 7)) + ((v_up * (10 + ((angl_x * -1) / 3)))) + (v_forward * (12 + (((0 - angl_x) / 1.05)))));
I believe the problem may be v_angle versus angles, as the first person view will always be using the v_angle perspective, and using .angles definately manages the external view better so far in my experiments.
Just curious if anyone ou tthere knows a better way? Im using Darkplaces as the engine and it has a waist level lightning option in the menu but on or off does not seem to show much difference in this case.
#1866 posted by Lunaran on 2015/12/17 10:22:25
that's going to change based on engine, right? fitz engines use a different weapon offset than other engines, and it's positioned differently when you look up or down.
CSQC
#1867 posted by kalango on 2015/12/17 12:48:56
Hey, anyone knows any resource for learning CSQC? Mostly HUD related CSQC. Every link i find seems to be dead.
Also i wanted to know if FTE supports CSQC for Hexen ;P
#1868 posted by Baker on 2015/12/17 13:14:38
Thanks For The Help On Grenade Lobbing, But
#1869 posted by aDaya on 2015/12/17 14:20:02
I'm still looking for a way for monsters to change attacks depending on its distance with the target/player
You Need
#1870 posted by ijed on 2015/12/17 14:35:53
A Choose Attack function.
Look at the bottom of the monster where it's Ai routines are initialised, you should find something like this:
self.th_stand = ogre_stand1;
self.th_walk = ogre_walk1;
self.th_run = ogre_run1;
self.th_die = ogre_die;
self.th_melee = ogre_melee;
self.th_missile = ogre_nail1;
self.th_pain = ogre_pain;
All the ones which have a '1' at the end are sending the monster to that animation sequence whenever the conditions are met. The others have a routine which decides which animation sequence to send them to, like this:
void() ogre_melee =
{
if (random() > 0.5)
ogre_smash1 ();
else
ogre_swing1 ();
};
So instead of just going directly to ogre_smash1(); it has a 50% chance of going to that OR ogre_swing1();
More On Choosing An Attack
#1871 posted by Preach on 2015/12/17 18:47:32
There's a good template to base your attack choosing decision on in SoldierCheckAttack. The first half of the function is basically checking if the player is visible. Look at the bits afterwards involving enemy_range - they set a variable chance of attack according to player distance.
You'd want to adapt that so it changes the attack itself rather than just the probability. I'd change the bit which uses self.th_missile to directly name the attack I want to use. e.g:
if (enemy_range == RANGE_NEAR)
{
���alien_spit_acid1()
���return TRUE;
}
else if (enemy_range == RANGE_MID)
{
���alien_fire_rocket1()
���return TRUE;
}
return FALSE;
There's an important extra bit of the puzzle here, in order to get a custom checkattack function you need to add it to CheckAnyAttack. Otherwise you get the default CheckAttack, which only gives you the choice of 1 melee attack and 1 missile attack.
@kalango
#1872 posted by Spike on 2015/12/17 19:37:27
FTE servers translate stuff such that the client can't really tell whether its hexen2 or quakeworld with a certain set of extensions.
so yes, fte+csqc+hexen2 should work fine on the condition that you can work with the extra stats that the server sets up to provide whatever hud functionality normally expected for a q2 mod.
for those stats, check http://sourceforge.net/p/fteqw/code/HEAD/tree/trunk/engine/common/bothdefs.h for the STAT_H2_ enum values.
you can override or add to these inside your SSHC code, if you need.
huds are otherwise 'just' a case of calling drawpic+drawstring etc.
the tiny font can be selected with drawfont=loadfont("", "gfx/tinyfont", "8", -1);
then switch drawfont between that and -1 or something.
its otherwise just a glorified quake mod.
#1873 posted by aDaya on 2015/12/17 23:22:04
Had to use Preach's method for Grenade lobbing because FTEQCC doesn't recognize "makevectors2" nor "grenade_velocity", but even with that and the HTML rewrites he doesn't recognize attack_elevation.
You Need To
#1874 posted by ijed on 2015/12/17 23:28:23
Add those to defs.qc.
Add them to the end of the list though, too high up and you change things the C code is expecting to be there.
|
|
You must be logged in to post in this thread.
|
Website copyright © 2002-2024 John Fitzgibbons. All posts are copyright their respective authors.
|
|