[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - Little problem with a touch function

Little problem with a touch function

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Little problem with a touch function

Postby CocoT » Tue Jun 12, 2007 11:35 am

Hi there :)

Okay, so I'm playing around with a little mini-mod and I have a little problem with a touch function. Basically, I'm using a yellow platform (in the form of a model) which turns red when you step on it, and (I would hope) stays red (and solid) when you stand on it, but then becomes transparent (and non-solid) when you stop touching it (in other words, when you step on another platform).
For some reason, I can't get the platform to remain solid as long as the player is standing on it.

This is the code:

.float touched;
.float touchytime;
.float alpha;

void() platform_touch =
{

if (self.touched == 0)
{
if (other.health > 1)
{
bprint("first touch");
self.skin = 1;
self.touched = 1;
sound(other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM);
}
}

if (self.touched == 1)
{
if (other.health > 1)
{
self.touchytime = time + 5;
bprint("constant touch");
}
}


};

void() platformthink =
{

self.touch = platform_touch;
if (self.touched == 0) self.touchytime = time + 1;

if (self.touched == 1 && (self.touchytime + 5) < time)
{
self.alpha = 0.4;
self.solid = SOLID_NOT;
}

self.think = platformthink;
self.nextthink = time + 1;

};

void() item_armor1 =
{
self.touch = platform_touch;
precache_model ("progs/armor.mdl");
setmodel (self, "progs/armor.mdl");
self.skin = 0;
setsize (self, '-64 -64 0', '64 64 20');

self.solid = SOLID_BBOX;
self.movetype = MOVETYPE_FLY;

self.think = platformthink;
self.nextthink = time + 1;
self.touchytime = time + 1;
};

I'm using the armor as the platform, as you can see. I know I could just make a new entity but, well, it does not make any difference since the mini-mod won't be using armors.
The weird thing is that I also never get my bprint messages, even though I do hear the sound when I step on a new platform and it does turn red (skin = 1). I have the feeling that there is something really simple that I'm missing, but I don't know what it is... Do you have suggestions?
Oh, and, when I continuously jump on the platform, it looks like the turning into non-solid takes longer... :?
- New location: Update your bookmarks!
User avatar
CocoT
 
Posts: 695
Joined: Tue Dec 14, 2004 5:39 pm
Location: Belly-Gum

Postby FrikaC » Tue Jun 12, 2007 12:13 pm

First off, the bprints are probably working but you're just not seeing them because you didn't put new lines (\n) at the end of the bprint statements, so they're getting bunched up on the console.

Secondly, .touch only occurs the first time the entities impact, I don't think it retriggers when you stand on something, unless you set force_retouch. My only suggestion here might be to instead check if the player is on top of the platform every think rather than use .touch to renew the timer.

Also, SOLID_BBOX will cause the player to slide around uncontrollably when atop it. If you set the FL_ONGROUND flag, you can overcome this.
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby Spike » Tue Jun 12, 2007 1:16 pm

.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby CocoT » Tue Jun 12, 2007 1:21 pm

- New location: Update your bookmarks!
User avatar
CocoT
 
Posts: 695
Joined: Tue Dec 14, 2004 5:39 pm
Location: Belly-Gum

Postby RenegadeC » Tue Jun 12, 2007 4:30 pm

User avatar
RenegadeC
 
Posts: 391
Joined: Fri Oct 15, 2004 10:19 pm
Location: The freezing hell; Canada

Postby CocoT » Tue Jun 12, 2007 5:04 pm

- New location: Update your bookmarks!
User avatar
CocoT
 
Posts: 695
Joined: Tue Dec 14, 2004 5:39 pm
Location: Belly-Gum

Postby RenegadeC » Tue Jun 12, 2007 5:31 pm

User avatar
RenegadeC
 
Posts: 391
Joined: Fri Oct 15, 2004 10:19 pm
Location: The freezing hell; Canada

Postby CocoT » Tue Jun 12, 2007 7:37 pm

- New location: Update your bookmarks!
User avatar
CocoT
 
Posts: 695
Joined: Tue Dec 14, 2004 5:39 pm
Location: Belly-Gum


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 3 guests