self.health bug?
Moderator: InsideQC Admins
4 posts
• Page 1 of 1
self.health bug?
hey guys,
I found a small bug in my mod..
I noticed that when you have exactly 0 health you are kinda "half-dead"...
You still can shoot weapons and fire impulses..
After that i tested it with a base 1.06 qc too, same result..
Is there a way to avoid this?
I used this impulse to test it, and im always "half-dead" :/
I found a small bug in my mod..
I noticed that when you have exactly 0 health you are kinda "half-dead"...
You still can shoot weapons and fire impulses..
After that i tested it with a base 1.06 qc too, same result..
Is there a way to avoid this?
- Code: Select all
if (self.impulse == 203)
self.health = 0;
I used this impulse to test it, and im always "half-dead" :/
-

drm_wayne - Posts: 232
- Joined: Sat Feb 11, 2012 5:47 pm
Re: self.health bug?
drm_wayne wrote:hey guys,
I found a small bug in my mod..
I noticed that when you have exactly 0 health you are kinda "half-dead"...
You still can shoot weapons and fire impulses..
After that i tested it with a base 1.06 qc too, same result..
Is there a way to avoid this?
- Code: Select all
if (self.impulse == 203)
self.health = 0;
I used this impulse to test it, and im always "half-dead" :/
The problem here is you're setting health directly, and this is a big no-no, because the QC code checks some entity flags besides the health to determine if the player is dead. Try using T_Damage(self, self, self.health+1) instead (pretty sure this isn't the correct call to the function, can't check it right now).
BTW, there's already a "kill" command to suicide that you can easily bind to a key, so no need to reinvent the wheel.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
Re: self.health bug?
i just added the impulse for testing, i noticed when i get killed by an enemy and have self.health 0 i am "half-dead"...
i can still shoot weapons, kill command doesnt work (says im already dead)...
this is kinda annoying..
i can still shoot weapons, kill command doesnt work (says im already dead)...
this is kinda annoying..
-

drm_wayne - Posts: 232
- Joined: Sat Feb 11, 2012 5:47 pm
Re: self.health bug?
the client sees rounded values. any health less than 1 is thus considered dead by the client.
the qc code goes off other fields instead of just health.
it is thus good practise to detect death by < 1, to set it to 0 if its > 0, and to update the .deadflag field at the same time.
you cannot trivially just set health = 0, if only because that won't do the right player animations etc.
the qc code goes off other fields instead of just health.
it is thus good practise to detect death by < 1, to set it to 0 if its > 0, and to update the .deadflag field at the same time.
you cannot trivially just set health = 0, if only because that won't do the right player animations etc.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest