Forum

Two questions - self.skin and vector info

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Two questions - self.skin and vector info

Postby Chrispy » Fri Feb 25, 2011 6:07 am

Heya Inside3D, not too long ago I decided to check out some simple engine which is easy to get into and fortunately I've found that with Quake and QC... :)

I've been lurking both this site and other websites for some beginner tutorials and that's been a success... even though some of the tutorials are just copy and paste. :)

However, I'm having an issue with a tutorial I'm trying to do:

http://www.inside3d.com/qctut/qctut-36.shtml

What I did before this was duplicate soldier.mdl, and modify it so that it has an extra skin (skin0 is the normal skin, skin1 is my new skin, with the blood).

I've tried exactly what the tutorial's said but it doesn't work correctly. In-game, all enemies start off with the "blood" skin. What should happen is that the enemies start off with the normal skin (skin0), and when they get hurt/shot, their skin changes to blood skin (skin1).

In fact the opposite effect has happened... where enemies start off with blood skin (skin1), and when getting hit they change to the normal skin (skin0).

My code (weapons.qc):

Code: Select all
void(entity attacker, float damage)   army_pain =
{
   local float r;
   
   if (self.pain_finished > time)
      return;
      
      if(self.health < 20) {
      self.skin = 1; // give him a bloody skin
      }

...
...
...


Note that the tutorial has said to add this block of code inside the "if (r < 0.2)" block... I've tried that.

Right now the soldier's health is 30.


------------------


And my second question would be... well, it's not really a question, but if anyone has any good examples or tutorials on solely vector-related stuff for QuakeC, that would be great. I do have a reference manual, but the more info the better.

Cheers. :)
Chrispy
 
Posts: 15
Joined: Fri Feb 25, 2011 3:39 am

Re: Two questions - self.skin and vector info

Postby Nahuel » Fri Feb 25, 2011 3:14 pm

Chrispy wrote:Heya Inside3D, not too long ago I decided to check out some simple engine which is easy to get into and fortunately I've found that with Quake and QC... :)

I've been lurking both this site and other websites for some beginner tutorials and that's been a success... even though some of the tutorials are just copy and paste. :)

However, I'm having an issue with a tutorial I'm trying to do:

http://www.inside3d.com/qctut/qctut-36.shtml

What I did before this was duplicate soldier.mdl, and modify it so that it has an extra skin (skin0 is the normal skin, skin1 is my new skin, with the blood).

I've tried exactly what the tutorial's said but it doesn't work correctly. In-game, all enemies start off with the "blood" skin. What should happen is that the enemies start off with the normal skin (skin0), and when they get hurt/shot, their skin changes to blood skin (skin1).

In fact the opposite effect has happened... where enemies start off with blood skin (skin1), and when getting hit they change to the normal skin (skin0).

My code (weapons.qc):

Code: Select all
void(entity attacker, float damage)   army_pain =
{
   local float r;
   
   if (self.pain_finished > time)
      return;
      
      if(self.health < 20) {
      self.skin = 1; // give him a bloody skin
      }

...
...
...


Note that the tutorial has said to add this block of code inside the "if (r < 0.2)" block... I've tried that.

Right now the soldier's health is 30.


------------------


And my second question would be... well, it's not really a question, but if anyone has any good examples or tutorials on solely vector-related stuff for QuakeC, that would be great. I do have a reference manual, but the more info the better.

Cheers. :)



Hi Chrispy. This tutorial was one of the first who tried it and actually doing it never worked properly. But I saw something important. When you hurt a monster two events may occur "pain " or "death. "
Then the solution is simpler than the tutorial says:

open a fresh soldier.qc (
and under

void(entity attacker, float damage) army_pain =
{
local float r;

if (self.pain_finished > time)
return;

r = random(); .........


put THIS new code

if(self.health < 20) {
self.skin = 1; // give him a bloody skin

}
else
{
self.skin = 0; // normal skin

}



the new code wold be so
void(entity attacker, float damage) army_pain =
{
local float r;

if (self.pain_finished > time)
return;

r = random();
if(self.health < 20) {
self.skin = 1; // give him a bloody skin

}
else
{
self.skin = 0; // normal skin

}
if (r < 0.2)
{
self.pain_finished = time + 0.6;
army_pain1 ();
sound (self, CHAN_VOICE, "soldier/pain1.wav", 1, ATTN_NORM);
}
else if (r < 0.6)
{
self.pain_finished = time + 1.1;
army_painb1 ();
sound (self, CHAN_VOICE, "soldier/pain2.wav", 1, ATTN_NORM);
}
else
{
self.pain_finished = time + 1.1;
army_painc1 ();
sound (self, CHAN_VOICE, "soldier/pain2.wav", 1, ATTN_NORM);
}
};


All right, but sometimes it happens that the soldier died of only one shot (supershotgun) , he had a death without suffering:) :) :) .
But inevitably the soldier was bleedingd, then change the old code
void() army_die =
{
// check for gib
if (self.health < -35)
{
sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM);
ThrowHead ("progs/h_guard.mdl", self.health);
ThrowGib ("progs/gib1.mdl", self.health);
ThrowGib ("progs/gib2.mdl", self.health);
ThrowGib ("progs/gib3.mdl", self.health);
return;
}

// regular death
sound (self, CHAN_VOICE, "soldier/death1.wav", 1, ATTN_NORM);
if (random() < 0.5)
army_die1 ();
else
army_cdie1 ();
};

with this new
void() army_die =
{
// check for gib
if (self.health < -35)
{
sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM);
ThrowHead ("progs/h_guard.mdl", self.health);
ThrowGib ("progs/gib1.mdl", self.health);
ThrowGib ("progs/gib2.mdl", self.health);
ThrowGib ("progs/gib3.mdl", self.health);
return;
}
self.skin=1;
// regular death
sound (self, CHAN_VOICE, "soldier/death1.wav", 1, ATTN_NORM);
if (random() < 0.5)
army_die1 ();
else
army_cdie1 ();
};

save and close
Compile and run
Enjoy !!!!!!!!!!
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Postby Chrispy » Fri Feb 25, 2011 9:30 pm

Thx for the reply, but still the same problem unfortunately. May the problem's my modified soldier.mdl? :O

http://dl.dropbox.com/u/12453703/soldiermdl.zip
Chrispy
 
Posts: 15
Joined: Fri Feb 25, 2011 3:39 am

Postby lth » Fri Feb 25, 2011 11:28 pm

The problem is simply that you have your skins in the model in the wrong order; the names in are immaterial but their order as they appear in the list in qMe is what matters; the top one is numbered skin 0, the next as 1 and so on.
User avatar
lth
 
Posts: 144
Joined: Thu Nov 11, 2004 1:15 pm

Postby Chrispy » Sat Feb 26, 2011 12:17 am

Sweet! That fixed it, I just moved the skin up in qME. Thanks both of you guys. :)
Chrispy
 
Posts: 15
Joined: Fri Feb 25, 2011 3:39 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest