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
Queer Queen 
Just finished a nice trick to change the serpent into a quaddam.
But don't touch it, cause it lives.., a bit husling with the skin file.

Yes, the src has a MISSILE weaponcode for each monster,
wizard is also much too strong. Number code for weapons won't work. Still beta.

Thanks for the demo, I'll look at it! 
@Spy 
You made your way quiet advanced on hard skill. Spy.
The missing sounds are qc depended.
I turned a bit strayed with the qtest.qc. adding the monsters,
especially the dragons, caused a lot of changes.

I assume the forced demo end had something to do with crashing,
it is still beta version, already glad it runs.

Thanks for taking your time. 
Partial Cross Post 
I am just getting started "cutting and pasting" QuakeC. I followed Preach's revised tutorial on monster spawning here:

https://tomeofpreach.wordpress.com/2017/10/08/teleporting-monsters-flag/

I'd like to add a small random delay automatically to each teleporting monster as you can do in Quoth. I am using custents multiple triggers to trigger these delays spawns. Similar to Quoth, it would be nice to have a little variation on the timing if the monsters all share a targetname.

I've tried a few things already, being exceedingly cautious not to mess up this code I can barely comprehend. I'm wondering if anyone would like to give me a hint of how to approach this little addition. 
 
Add a new function:
void monster_teleport_delay () {
self.think = monster_teleport_go;
self.nextthink =time + self.wait; // or self.delay if you prefer that
};

Then in your monster_teleport() function change self.use to be monster_teleport_delay; instead of monster_teleport_go.

DISCLAIMER: Untested. 
@qmaster 
thank you for the help... I will try this after work this evening! 
@qmaster 
Newb question: would this mean I need to add a wait or delay key value to the entities? I don't mind setting it manually but wanted to know if this is how this method works. 
Alternative 
If you don't want to set a wait value manually, instead of using self.wait in that code you can generate a random number between 0 and 1 using random() instead.

Can you see how to adapt the code to use random to create a delay of between 0 and 1 seconds?

How about a delay between 0 and 2 seconds?

What about between 0.5 and 1 seconds? 
... 
Obviously I posted that before reading the other thread. 
@Preach 
No worries thanks for the great tutorials. I am enjoying messing around with QC finally. Next, I am going to try and figure out a silent spawn without the tfog and audio next. I think I can do it. 
// 
 
Decision Made! 
After trying to implement random timings I felt it better to go with self.delay. More work but more control for the mapper. Thanks everyone! 
Te_lightning, Etc 
/*==========
te_lightning
==========*/
void(vector v1, vector v2) te_lightning =
{
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_LIGHTNING1);
WriteEntity (MSG_BROADCAST, world);
WriteCoord (MSG_BROADCAST, v1_x);
WriteCoord (MSG_BROADCAST, v1_y);
WriteCoord (MSG_BROADCAST, v1_z);
WriteCoord (MSG_BROADCAST, v2_x);
WriteCoord (MSG_BROADCAST, v2_y);
WriteCoord (MSG_BROADCAST, v2_z);
};

Writing some TE_ helper functions has gotten me curious. WHY is there an entity parameter needed for the lightning, beam, etc? Is it safe to just write world? 
 
I figured it out. It uses the entity as the start point regardless of the co-ordinates passed. And this is why the lightning beam starts at the origin of the player, regardless of anything else. 
 
beams last 0.2 seconds. QC respawns them every 0.1 seconds.

the entity argument is just there to avoid the resulting double-beams issue (trying to depend upon precise timing would be too unreliable with network latency etc, hence why they last longer).
Using world would break when you have two players firing beams, although some engines do understand world to mean 'don't replace any beams'.
tbh 99% of the time that entity arg will be self.

ignoring the startpoint and using the player's position is just to smooth things out so that the player doesn't leave the beam behind when moving sideways etc.

note that there's already an engine extension to provide those as builtins (with that name), so beware of potential conflicts if a modder uses *extensions.qc. 
W_FireLightning Start Origin Incorrect On Players? 
original code has

LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);

(even URQP has it that way)

But i had long changed it to

LightningDamage (org, (trace_endpos + (v_forward * 4)), self, 30);

this is especially obvious when shooting from RL window on DM3 and aiming at someone on the lower bridge.
this is because:

org = self.origin + '0 0 16';
traceline (org, org + v_forward*600, TRUE, self); 
 
The original is "waist lightning". Darkplaces has specific settings to let you pick which style you prefer, waist or gunpoint. 
@QMaster 
That only fixes the position of the bolt VISUALLY, which is what Spike was explaining. The above fixes the tracelines/damage as well. 
 
ya the original deals damage from the gun but visially it came from the hip
i keep confusing myself that sel.origin is the bottom of the model
where the feet touch the floor 
Trigger_push Project 
Still taking baby steps into QC with very little coding background. Wanted to check with experienced coders. This bit of code makes a trigger_push silent with a spawnflag. It appears to be working fine in game and no errors in FTEQCC but I feel like the syntax is still wrong.

Next steps will be to learn how to toggle it and add custom sounds.

//============================================================================

float PUSH_ONCE = 1;
float PUSH_SHHH = 2; //DMS push silently

void() trigger_push_touch =
{
if (other.classname == "grenade")
other.velocity = self.speed * self.movedir * 10;
else if (other.health > 0)
{
other.velocity = self.speed * self.movedir * 10;
if (other.classname == "player")
if (!(self.spawnflags & PUSH_SHHH)) //DMS
{
if (other.fly_sound < time)
{
other.fly_sound = time + 1.5;
sound (other, CHAN_AUTO, "ambience/windfly.wav", 1, ATTN_NORM);
}
}
}
if (self.spawnflags & PUSH_ONCE)
remove(self);
};


/*QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE
Pushes the player
*/
void() trigger_push =
{
InitTrigger ();
precache_sound ("ambience/windfly.wav");
self.touch = trigger_push_touch;
if (!self.speed)
self.speed = 1000;
};

//============================================================================ 
 
You could also check the spawnflags in the spawn function and only precache the sound if needed. 
 
Quakedroid would be about the only reason not to just precache everything. 
 
What does this mean?

if ( (rand()&3)==1 
 
if ( (rand()&3)==1
rand() returns a number between 0 and RAND_MAX.
&3 truncates all but the lowest 3 bits (so a random number between 0 and 3 inclusive).
==1 gives you a 1-in-4 chance of being true.
and there's no closing bracket, so the entire thing is a syntax error and won't even compile.

of course, rand's randomized bits are generally least reliable in the lower bits, so the above might be quite predictable, but it depends upon the rand implementation. 
Sv_move.c 
Truncatorial bitwise AND. Mkay.

So 25%ish chance in movetogoal to "bump around" using the wall following code if the monster can't step in the direction of its .enemy

I guess that makes (rand()&1) evaluate to 50%ish chance. 
 
lowest 2 bits, sorry. and yeah, bitwise and.

movetogoal is just all kinds of screwed tbh. its very much an attempt to replicate doom's monsters, but in a way that's 5+ times as expensive due to all the floor checks etc. it can't slide along walls so can't deal with narrow passageways, etc. it works well enough, but its far from ideal. 
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.