Forum

Some questions for my singleplayer mod...

Post tutorials on how to do certain tasks within game or engine code here.

Moderator: InsideQC Admins

Some questions for my singleplayer mod...

Postby Daya » Thu Jun 13, 2013 5:05 pm

EDIT: I just realized I put this thread on the wrong section. Can someone move it to where it belong?

Hello everyone,

I felt in love with Quake last year, it has become my favourite FPS, And I'd like to mod it.
Now, please remember that I'm kind of a noob at programming, so except a lot of questions from me. Still, I visited the tutorial page in the site to get me a bit started on a general scale.
I plan for my mod to use darkplaces, but still using quake-styled textures and models.
For now, here's what I already accomplished on the programming side:
- replaced the standart shotgun into a sub-machine gun
- modified the super-shotgun a little bit
- multiple sounds for each type of armors and ammos

Now here comes the questions about the weapons:

1) I'd like for the close range weapon to be more effective, so here's my idea to change it: on top of the close range damage, I'd like it to shoot an instantaneous laser (like a railgun), but with limited range: the more you hold the fire button, the longer the laser will be, the maximum being mid-range. It will not go through enemies. How can I accomplish such a thing?

2) The nailgun in the mod uses the Super nailgun as a base (replacing the vanilla standart nailgun spot), and I'd like to change it so it behaves like the one in Quake 4's multiplayer (2 nails per shot with a spread and reduced firerate). I wrote "launch_spike (2, dir, '0.0225 0.0225 16');" instead of "launch_spike (self.origin + '0.4 0.4 16', dir);" (the original), but I got a compiling error instead. How can I do this?

3) This one is kinda simple: I'd like to integrate Team Fortress' Assault Canon in the game as a minigun weapon(with some tweaks of course, this thing is overpowered) (replacing the vanilla super nailgun spot). I have the files of the mod, but how can I access its code? Or, how can I replicate its function?

4) I'd like to replace the lightning gun to a gluon-gun type of weapon, with a beam that goes crazy (see the alt fire mode of UT2004's link gun)(maybe as a texture?) and with no length limitations aside for walls and enemies, and with the same sound properties as the one in Half life (a windup sound and loop sound during the hold fire sequence and a down sound while the player stops firing.). Any ideas on how to do this?

That's all for now. I might bump this thread from time to time through the progression of the mod in the programming department.
Daya
 
Posts: 12
Joined: Mon May 13, 2013 9:21 am

Re: Some questions for my singleplayer mod...

Postby jitspoe » Thu Jun 13, 2013 8:53 pm

For #2, the thing you have to keep in mind is that launch_spike is expecting 2 parameters: The first one specifies the position (origin) of the nail to start at. The second specifies the direction it goes. There's nothing specifying how many to launch. What you'll need to do is call the function twice, and randomize the direction a little bit.

You can probably look at the shotgun code to figure out how to do some direction randomization.
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Some questions for my singleplayer mod...

Postby Daya » Fri Jun 14, 2013 9:32 am

I duplicated the code, and effectively, it now shoots two nails per shot, but I still can't reduce the firerate even with the self.attack_finished command, and by manipulating the '0 0 16' portion I got some wierd stuff: for example, if I put '5 5 16', the change occurs only at which direction I go, and said change is like the standart nailgun, when it fires at the right side of my screen at a certain position. I tried augmenting the dir line into 100000 like in the shotgun code, but nothing happened, and I also tried puttin pluses and commas in "(self.origin + '0.2 0.2 16', dir)" but I got a situation when I finally got the nails to fire into 2 different directions, but the aiming was locked to a certain degree, and it was still not randomized.
Daya
 
Posts: 12
Joined: Mon May 13, 2013 9:21 am

Re: Some questions for my singleplayer mod...

Postby frag.machine » Fri Jun 14, 2013 1:32 pm

As already said, this function takes two arguments: the nail origin, and its direction. Adding another vector to the origin makes the nail start at an offset from the player origin, as you already realized. If you want to make the nails fly in slightly different directions, you must add a small random offset to the second parameter (like +/- 1% to the x, y and z components of the "dir" vector).
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2081
Joined: Sat Nov 25, 2006 1:49 pm

Re: Some questions for my singleplayer mod...

Postby Daya » Fri Jun 14, 2013 9:28 pm

Thanks to this link, I understood a bit more about the spread: http://www.moddb.com/games/quake/tutori ... fle-part-1

And after some trial & errors, I finally got what I wanted, but the spread only occurs on the top-right corner and bottom-left corner, and I still can't figure out how to reduce the firerate, since modifying "self.attack_finished" doesn't seem to work.

Here's my code for those interested:

Code: Select all
   
        sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
   self.attack_finished = time + 0.4; //original 0.2
   self.currentammo = self.ammo_nails = self.ammo_nails - 2;
   dir = aim (self, 1000);
   launch_spike (self.origin + '0 0 16', dir + v_right* 0.03 * random() + v_up* 0.03 * random()); //original (self.origin + '0 0 16', dir);
   launch_spike (self.origin + '0 0 16', dir + v_right* -0.03 * random() + v_up* -0.03 * random()); //original (self.origin + '0 0 16', dir);
   newmis.touch = superspike_touch;
   setmodel (newmis, "progs/s_spike.mdl");
   setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);      
   self.punchangle_x = -2;


And before anyone asks, I already tried "v_right* 0.03 * random() + v_up* 0.03 * random() + v_right* -0.03 * random()" and " v_right* -0.03 * random() + v_up* -0.03 * random() + v_right* 0.03 * random()" so that the shots can also go the opposite direction, but it only mirrors the original results.
Daya
 
Posts: 12
Joined: Mon May 13, 2013 9:21 am

Re: Some questions for my singleplayer mod...

Postby jitspoe » Fri Jun 14, 2013 9:46 pm

You're using positive random values in one call (up and to the right), and negative random values in the other (down and to the left). What you really want is a random number that can be both positive and negative. Try something like this:

Code: Select all
launch_spike (self.origin + '0 0 16', dir + v_right* 0.03 * (random() - random()) + v_up* 0.03 * (random() - random()));
launch_spike (self.origin + '0 0 16', dir + v_right* 0.03 * (random() - random()) + v_up* 0.03 * (random() - random()));


(Distribution of hits will be more toward the center of the screen)

or

Code: Select all
launch_spike (self.origin + '0 0 16', dir + v_right* 0.06 * (random() - 0.5) + v_up* 0.06 * (random() - 0.5));
launch_spike (self.origin + '0 0 16', dir + v_right* 0.06 * (random() - 0.5) + v_up* 0.06 * (random() - 0.5));


(A more even distribution -- shots have an equal chance of hitting anywhere in the spread area)

I'm not sure on the attack time -- it's been a long time since I've looked at the Quake 1 weapon code. There may be some other timer that's getting used instead.
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Some questions for my singleplayer mod...

Postby frag.machine » Fri Jun 14, 2013 10:43 pm

about the fire rate: make sure there's something like this in your weapon code before calling launch_spike():
Code: Select all
if (self.attack_finished > time)
{
  return;
}


Otherwise self.attack_finished makes no difference (hence no fire rate changes).
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2081
Joined: Sat Nov 25, 2006 1:49 pm

Re: Some questions for my singleplayer mod...

Postby Dr. Shadowborg » Fri Jun 14, 2013 11:03 pm

For #1, unless this new melee weapon is like the lightning gun, you'll need to add something like .float meleelaser, modify the fireaxe code to increase the traceline distance each time by whatever meleelaser is(also increasing meleelaser's value) and add a button check to reset meleelaser in playerpostthink. (client.qc)

#4 will be rather complicated. (depending on what you want it to do)

RE: SuperNailgun - If you're still using player_nail1() (which is located in player.qc) in your w_attack function, you'll have to resort to using something like self.nextthink = time + XX; within player_nail1 and player_nail2 to slow things down. (The problem here is that if you do it this way, your weaponframes will cycle slower, so you might want to add a few frame exceptions so that firing frames are normal speed, and cycling frames are slower) (addenda: apparently every frame except frame 0 is a firing frame for the SNG O_o, so adding a few non-firing cycle frames to the model may be in order)

If you do it the way fragmachine says, it will work, but you'll probably end up with some non-synced frames where it looks like your weapon is firing but isn't.
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1109
Joined: Sat Oct 16, 2004 3:34 pm

Re: Some questions for my singleplayer mod...

Postby frag.machine » Sat Jun 15, 2013 4:22 pm

@DrShadowBorg: I am assuming that weapon animation is handled in the same code that calls launch_spike, otherwise yeah, weapon firing will look out of sync. Handling the frames on the same place it launches the projectile makes life easier. :)
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2081
Joined: Sat Nov 25, 2006 1:49 pm

Re: Some questions for my singleplayer mod...

Postby Daya » Sat Jun 15, 2013 5:51 pm

jitspoe wrote:
Code: Select all
launch_spike (self.origin + '0 0 16', dir + v_right* 0.06 * (random() - 0.5) + v_up* 0.06 * (random() - 0.5));
launch_spike (self.origin + '0 0 16', dir + v_right* 0.06 * (random() - 0.5) + v_up* 0.06 * (random() - 0.5));



Thanks! This is exactly what I'm looking for!

Tried fragmachine's code for the firerate, and it works... mostly. The reduce firerate is applied, but there's no continued fire when I hold the fire key (but the continuous firing animation is still playing), meaning I have to press it everytime I want to fire bursts of nails, but on the good side, the animation resets when I push fire again. Now, this could be an interesting way to cancel fire holding if it wasn't for the animation looping while the key is pressed, and I still want to fire continuous bursts of nails while holding the firekey.
Animation-wise, I don't want to bother with it for now, because I plan to have new models of each of them (here's the nailgun: http://image.noelshack.com/fichiers/201 ... nailgn.png)

Dr. Shadowborg wrote:For #1, unless this new melee weapon is like the lightning gun, you'll need to add something like .float meleelaser, modify the fireaxe code to increase the traceline distance each time by whatever meleelaser is(also increasing meleelaser's value) and add a button check to reset meleelaser in playerpostthink. (client.qc)


I only want it to shoot a laser (so no lightning model, but I can still use it as a placeholder). Anyway what I imagined is that holding the firekey while having the axe/close range weapon will increase the "ammo" count. If the player releases the key before 10, the traditional axe animation and stats will occur. Beyond that, the laser will appear, with its length depending on the ammo count (the maximum being 100.). If this is possible, how can I code this?

Dr. Shadowborg wrote:#4 will be rather complicated. (depending on what you want it to do)


I didn't phrase myself correctly. What I want to do is to have no length limitations and no laser sticking (whatever it is in the original Quake, when the lightning bolt was still stuck on the same position you shot while you're aiming at another direction) and replace said model with a texture of an animated laser that goes crazy (I recall a video where the lightning gun has a texture where the lightning bolts went crazy).

But anyway, time for another questions:

1)I'd like for the pickup HUD to change like in Quake 2/3. What I'm saying is instead to show "You got 5 shells", I'd like to show "[shells picture] shells x 5", stuff like this. Also, is there a way to show powerup times like in Quake 3?

2)I'd like to include an item that slow down time, except your movements, your weapons and stuff like doors and elevators. Is that possible?
Daya
 
Posts: 12
Joined: Mon May 13, 2013 9:21 am

Re: Some questions for my singleplayer mod...

Postby frag.machine » Sat Jun 15, 2013 7:49 pm

Code: Select all
// add a .nail_finished float to the entity structure
if (self.nail_finished < time)
{
  // animate the weapon
  // call launch spike
  self.nail_finished = time + 0.4;
}
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2081
Joined: Sat Nov 25, 2006 1:49 pm

Re: Some questions for my singleplayer mod...

Postby Dr. Shadowborg » Sun Jun 16, 2013 10:22 pm

Daya wrote:Animation-wise, I don't want to bother with it for now, because I plan to have new models of each of them (here's the nailgun: http://image.noelshack.com/fichiers/201 ... nailgn.png)


You're probably better off doing it like the shotgun instead then, as player_nail1 and player_light1 are looping animations better suited to rapidfire-type weapons.

Just make something like a W_FireQ4Nailgun function with your projectile firing code, then replace the player_nail1() call in W_Attack with:
Code: Select all
player_shot1();
W_FireQ4Nailgun();
self.attack_finished = time + 0.4;


Neat looking model btw. :)

Daya wrote:I only want it to shoot a laser (so no lightning model, but I can still use it as a placeholder). Anyway what I imagined is that holding the firekey while having the axe/close range weapon will increase the "ammo" count. If the player releases the key before 10, the traditional axe animation and stats will occur. Beyond that, the laser will appear, with its length depending on the ammo count (the maximum being 100.). If this is possible, how can I code this?


What you seek is a variation on the charge cannon / variable distance grenade toss. For this, you should reference player_nail1 or player_light1 in player.qc, and modify it to either shoot a laser on release of the fire button or do the axe attack. (depending upon how much charge is present, shoot laser. You'll need to create a custom float like .float axecharge or something)

Daya wrote:I didn't phrase myself correctly. What I want to do is to have no length limitations and no laser sticking (whatever it is in the original Quake, when the lightning bolt was still stuck on the same position you shot while you're aiming at another direction) and replace said model with a texture of an animated laser that goes crazy (I recall a video where the lightning gun has a texture where the lightning bolts went crazy).


I see. Can't help you much with this one then, as I'm not yet well versed enough in DP / FTE-fu yet. :/

Daya wrote:But anyway, time for another questions:

1)I'd like for the pickup HUD to change like in Quake 2/3. What I'm saying is instead to show "You got 5 shells", I'd like to show "[shells picture] shells x 5", stuff like this. Also, is there a way to show powerup times like in Quake 3?

2)I'd like to include an item that slow down time, except your movements, your weapons and stuff like doors and elevators. Is that possible?


#1 - You'll need to use CSQC. A complex and not terribly well documented as yet feature.

#2 - Short answer is yes, but you'll need to do some extensive modifications to monsters and monster projectiles. Also, if you want the powerup to work in Coop / Multiplay then be prepared for a headache.
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1109
Joined: Sat Oct 16, 2004 3:34 pm

Re: Some questions for my singleplayer mod...

Postby Daya » Mon Jun 17, 2013 1:45 pm

Dr. Shadowborg wrote:
Code: Select all
player_shot1();
W_FireQ4Nailgun();
self.attack_finished = time + 0.4;



That did it, thanks! (I had to reduce it to 0.2 for both this part and the W_FireQ4Nailgun part so the firerate could really be 0.4 [which is wierd but whatever.])

Anyway here's something I wanted to ask since some times now: what exactly are the "float" commands you're all talking about? What are its function, how, when and where does it work? I've tried researching for it in google, but the explanations it gave where kinda cryptic.
Daya
 
Posts: 12
Joined: Mon May 13, 2013 9:21 am

Re: Some questions for my singleplayer mod...

Postby Dr. Shadowborg » Mon Jun 17, 2013 2:26 pm

Daya wrote:That did it, thanks! (I had to reduce it to 0.2 for both this part and the W_FireQ4Nailgun part so the firerate could really be 0.4 [which is wierd but whatever.])


Only the self.attack_finished = time + 0.4; in W_Attack should be adding to your refire delay. If something else does it too, then your .attack_finished is going to be pushed out a little bit. Exceptions to this rule should be charging weapons, and rapidfire weapons.


Daya wrote:Anyway here's something I wanted to ask since some times now: what exactly are the "float" commands you're all talking about? What are its function, how, when and where does it work? I've tried researching for it in google, but the explanations it gave where kinda cryptic.


They're variable declarations. Generally best declared as soon as possible, either at the bottom of defs.qc or in a separate file like mydefs.qc that's added to the compile queue in progs.src.

float myvariable; // Declares a single global variable. Can be accessed and modified simply by referring to it by name. i.e. myvariable = myvariable + 1; advances myvariable by 1.

.float myvariable; // Declares a variable that may be assigned to a specific entity. i.e. all entities have a .myvariable after declaration, but modifying a player / monster / other .myvariable will have no effect on anything else's .myvariable. Examples of .float declared variables are .attack_finished, .ammo_shells, etc.

local float myvariable; // Declares a variable that will only be used for the scope of a function. Deallocated after the function ends.

Note that entity, .entity, string, .string, etc. also exist and work in much the same way.
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1109
Joined: Sat Oct 16, 2004 3:34 pm

Re: Some questions for my singleplayer mod...

Postby gnounc » Mon Jun 17, 2013 5:45 pm

Dr. Shadowborg wrote:#1 - You'll need to use CSQC. A complex and not terribly well documented as yet feature.


viewtopic.php?f=2&t=5194]My CSQC HUD Tutorial
this is exactly what you're looking for.
CSQC is complicated on the backend. On the frontend, the part of the stick you'll be dealing with, its not
very complicated at all. Especially if all you want to do is some hudwork.

I dont believe I go over dynamic transparencies but I mention them in passing iirc.
What you'll want to do is clientstat player.items and check against each item you want to do something with
saving the time they were picked up in a float clientside, and drawing the apropriate graphic with
a bump in transparency and/or location every frame until you decide its been shown long enough.
(pickup time + duration)

If you get that basic hud tutorial up and running, ask again, and I'll point you to the finer details.
User avatar
gnounc
 
Posts: 424
Joined: Mon Apr 06, 2009 6:26 am

Next

Return to Programming Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest