Forum

skin changing

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

skin changing

Postby Ghost_Fang » Tue Jan 26, 2010 3:13 am

Alright is it possible, to change a skin by the press of a button? Like lets say i make a separate skin for the quake shotty, nice hot pink. lol. can i code a function for it to switch skins with the press of a button. OR if these certain animations are playing have a certain skin. How would i do either of those?
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Postby Baker » Tue Jan 26, 2010 3:28 am

A rough skeleton of how press a button skin changes would work:

Bind an impulse to a key:

bind x "impulse 200"

In QuakeC, where the impulses are read (I'm thinking this in weapons.qc in ImpulseCommands function) have "if (self.impulse == 200) ChangeMySkin ();"

And have ChangeMySkin switch self.skin.

Something like this:

Code: Select all
void ChangeMySkin ()
{
     if (self.skin == 1) self.skin =2;
     else self.skin =1;
}


Maybe a REAL QuakeC coder can critique what I wrote above if that doesn't work as-is.

I'm not Mr. QuakeC.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby ceriux » Tue Jan 26, 2010 4:22 am

either that or he could call that function in the weapon change code for when he changes to the shotty. since hes looking to change the skin when he selects a new weapon.

this may, or may not work. but you can try it.

Code: Select all
else if (self.impulse == 2)
   {
      fl = IT_SHOTGUN;
      self.skin =2;
      if (self.ammo_shells < 1)
         am = 1;
   }


might be like... player.skin or something... idk. but something similar should work if this doesnt.

or maybe in player post think.

Code: Select all
if (self.weapon == IT_SHOTGUN)
{
self.skin =2;
}

ect...
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Ghost_Fang » Tue Jan 26, 2010 4:34 am

No i can see it now, its actually quite easy lol.
Instead of starting a new thread (or should I?)

How would i be able to make a "charge" shot?
Like hold down the button to charge something?
and if you charge it for maybe so many seconds the power doubles or something? Then release to fire
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Postby Baker » Tue Jan 26, 2010 5:01 am

Probably adding something to defs.qc like

.float currentCharge
.float isCharging

And having a hold down impulse and a release impulse ...

alias +charge "impulse 101" // When pressed, +charge
alias -charge "impulse 102" // When released, -charge
bind "enter" +charge

And when impulse 101 is detected in the qc (again maybe in weapons.qc in Impulsecommands) ...

Code: Select all
if (self.impulse == 101)  self.isCharging = 1;  // begin charging
if (self.impulse == 102) self.isCharging = 0; // stop charging


Somewhere you will have code like

Code: Select all
// If isCharging, add more to currentCharge
if (self.isCharging == 1) self.currentCharge == self.currentCharge + 0.25;


I am not sure where the best place to put the above code would be. And again, the above may need adaption and not work as-is.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby ceriux » Tue Jan 26, 2010 5:31 am

i think there's a tutorial for that in the tutorial section.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Sajt » Tue Jan 26, 2010 6:04 am

Note that you can't actually change the weapon model's skin (there is no ".weaponskin" field). You'll have to create a second copy of the model with the other skin, and swap out the model. But of course, if done in mid-animation, that can cause a "snap" in lerping on newer engines. Or else you can try something extra clever, like moving two differently textured polygons in and out of view on the model. Or... if you're not worried about old engine support you can use an extension like DP_ENT_VIEWMODEL.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby ceriux » Tue Jan 26, 2010 6:11 am

why hasnt there been a .weaponskin extension made? seems kind of... weird that there hasnt been...
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest